WIP 20161013
parent
756f0f2d4d
commit
52cac8e5d9
|
@ -14,6 +14,7 @@ import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.hwo.pulscounter.SnapShot;
|
import org.hwo.pulscounter.SnapShot;
|
||||||
|
import org.hwo.pulscounter.simplescript.SimpleScript;
|
||||||
|
|
||||||
import static org.hwo.logging.Logging.*;
|
import static org.hwo.logging.Logging.*;
|
||||||
import static org.hwo.logging.LogLevel.*;
|
import static org.hwo.logging.LogLevel.*;
|
||||||
|
@ -190,5 +191,9 @@ public class PulsCounterDatabase {
|
||||||
return snapshots.toArray(new SnapShot[0]);
|
return snapshots.toArray(new SnapShot[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SimpleScript[] getSimpleScripts(){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,5 +8,8 @@ create table if not exists props (id uuid primary key,name varchar(255) unique,v
|
||||||
create table if not exists devices (id uuid,serial varchar(12));
|
create table if not exists devices (id uuid,serial varchar(12));
|
||||||
create table if not exists snapshots (id uuid,device integer,snap_id integer,timestamp integer,counters integer array[32],analogs integer array[8],inputs integer,outputs integer,pullups integer,inverts integer,field0 integer);
|
create table if not exists snapshots (id uuid,device integer,snap_id integer,timestamp integer,counters integer array[32],analogs integer array[8],inputs integer,outputs integer,pullups integer,inverts integer,field0 integer);
|
||||||
|
|
||||||
|
create table if not exists scripts (id uuid primary key,name varchar(128),description text,elements integer ARRAY default ARRAY[]);
|
||||||
|
|
||||||
|
delete from props where name='db.schema.version';
|
||||||
insert into props (id,name,value) values(uuid(),'db.schema.version','0');
|
insert into props (id,name,value) values(uuid(),'db.schema.version','0');
|
||||||
|
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
package org.hwo.pulscounter.elements;
|
|
||||||
|
|
||||||
import org.hwo.datetime.DateTime;
|
|
||||||
|
|
||||||
public class RawValueEntry {
|
|
||||||
|
|
||||||
int channel;
|
|
||||||
DateTime dateTime;
|
|
||||||
int value;
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,73 +0,0 @@
|
||||||
package org.hwo.pulscounter.elements;
|
|
||||||
|
|
||||||
import org.hwo.datetime.Date;
|
|
||||||
import org.hwo.datetime.TimeOfDay;
|
|
||||||
import org.hwo.datetime.DateTime;
|
|
||||||
|
|
||||||
|
|
||||||
public class WorkShift {
|
|
||||||
|
|
||||||
private String name;
|
|
||||||
private String comment;
|
|
||||||
|
|
||||||
private TimeOfDay begins;
|
|
||||||
private TimeOfDay ends;
|
|
||||||
|
|
||||||
public WorkShift(){
|
|
||||||
this.name = "";
|
|
||||||
this.comment = "";
|
|
||||||
this.begins = new TimeOfDay();
|
|
||||||
this.ends = new TimeOfDay();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isOverMidnight(){
|
|
||||||
return ends.isEarlierThan(begins);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getComment() {
|
|
||||||
return comment;
|
|
||||||
}
|
|
||||||
public void setComment(String comment) {
|
|
||||||
this.comment = comment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TimeOfDay getBegins() {
|
|
||||||
return begins;
|
|
||||||
}
|
|
||||||
public void setBegins(TimeOfDay begins) {
|
|
||||||
this.begins = begins;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TimeOfDay getEnds() {
|
|
||||||
return ends;
|
|
||||||
}
|
|
||||||
public void setEnds(TimeOfDay ends) {
|
|
||||||
this.ends = ends;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DateTime getShiftBegins(Date date){
|
|
||||||
DateTime dt = new DateTime(date, begins);
|
|
||||||
return dt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DateTime getShiftEnds(Date date){
|
|
||||||
DateTime dt = new DateTime(date, ends);
|
|
||||||
if (isOverMidnight()){
|
|
||||||
dt.getDate().addDays(1);
|
|
||||||
}
|
|
||||||
return dt;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return this.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,97 +0,0 @@
|
||||||
package org.hwo.pulscounter.elements;
|
|
||||||
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Statement;
|
|
||||||
import java.util.Hashtable;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.hwo.datetime.Date;
|
|
||||||
import org.hwo.datetime.DateTime;
|
|
||||||
|
|
||||||
public class WorkShiftRecord {
|
|
||||||
|
|
||||||
public class ChannelRecords{
|
|
||||||
|
|
||||||
public class ChannelRecord
|
|
||||||
{
|
|
||||||
DateTime timestamp;
|
|
||||||
Integer value;
|
|
||||||
|
|
||||||
public ChannelRecord(DateTime timestamp,int value){
|
|
||||||
this.timestamp = timestamp;
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DateTime getTimestamp() {
|
|
||||||
return timestamp;
|
|
||||||
}
|
|
||||||
public void setTimestamp(DateTime timestamp) {
|
|
||||||
this.timestamp = timestamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
public void setValue(int value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int channel;
|
|
||||||
List<ChannelRecord> values;
|
|
||||||
|
|
||||||
public ChannelRecords(int channel){
|
|
||||||
this.channel = channel;
|
|
||||||
this.values = new LinkedList<WorkShiftRecord.ChannelRecords.ChannelRecord>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addValue(DateTime timestamp,int value){
|
|
||||||
this.values.add(new ChannelRecord(timestamp, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sort(){
|
|
||||||
/* List<ChannelRecord> sorted = new LinkedList<WorkShiftRecord.ChannelRecords.ChannelRecord>();
|
|
||||||
|
|
||||||
for (ChannelRecord r: values){
|
|
||||||
if (values.size() == 0)
|
|
||||||
sorted.add(r);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.values = sorted;
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ChannelRecord> getRecords(){
|
|
||||||
return this.values;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
WorkShift workShift;
|
|
||||||
Date date;
|
|
||||||
|
|
||||||
Hashtable<Integer, ChannelRecords>
|
|
||||||
records;
|
|
||||||
|
|
||||||
public WorkShiftRecord(WorkShift shift,Date date){
|
|
||||||
workShift = shift;
|
|
||||||
this.date = date;
|
|
||||||
records = new Hashtable<Integer, WorkShiftRecord.ChannelRecords>();
|
|
||||||
|
|
||||||
loadRecords();
|
|
||||||
}
|
|
||||||
|
|
||||||
void loadRecords(){
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer[] getChannels(){
|
|
||||||
return (Integer[]) this.records.keySet().toArray(new Integer[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChannelRecords getChannelRecords(int channel){
|
|
||||||
return records.get(channel);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,259 @@
|
||||||
|
package org.hwo.pulscounter.simplescript;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.hwo.models.TableMapper.TableColumn;
|
||||||
|
|
||||||
|
public class SimpleScript {
|
||||||
|
|
||||||
|
private UUID id;
|
||||||
|
private String name;
|
||||||
|
private String description;
|
||||||
|
private ArrayList<SimpleScriptElement> simpleScriptElements;
|
||||||
|
|
||||||
|
public SimpleScript(){
|
||||||
|
id = UUID.randomUUID();
|
||||||
|
name = "";
|
||||||
|
description = "";
|
||||||
|
simpleScriptElements = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public SimpleScript(String name,String description,SimpleScriptElement elements[]){
|
||||||
|
this.id = UUID.randomUUID();
|
||||||
|
this.name = name;
|
||||||
|
this.description = description;
|
||||||
|
this.simpleScriptElements = new ArrayList<>();
|
||||||
|
this.simpleScriptElements.addAll(Arrays.asList(elements));
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
public void setId(UUID id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<SimpleScriptElement> getSimpleScriptElements() {
|
||||||
|
return simpleScriptElements;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public enum ScriptOperation {
|
||||||
|
|
||||||
|
SET_ZERO (0x00),
|
||||||
|
SET_ONE (0x01),
|
||||||
|
SET_A (0x02),
|
||||||
|
SET_B (0x03),
|
||||||
|
A_PLUS_B (0x04),
|
||||||
|
A_MINUS_B (0x05),
|
||||||
|
A_MUL_B (0x06),
|
||||||
|
A_DIV_B (0x07),
|
||||||
|
A_AND_B (0x08),
|
||||||
|
A_OR_B (0x09),
|
||||||
|
A_XOR_B (0x0A),
|
||||||
|
/* 0x0b..0x0f: frei */
|
||||||
|
SET_NOT_A (0x10),
|
||||||
|
SET_NOT_B (0x11)
|
||||||
|
/* 0x12..0x1f: frei */
|
||||||
|
;
|
||||||
|
|
||||||
|
ScriptOperation(int n){
|
||||||
|
this.n = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ScriptOperation operations[] = {
|
||||||
|
SET_ZERO, // 0x00
|
||||||
|
SET_ONE,
|
||||||
|
SET_A,
|
||||||
|
SET_B,
|
||||||
|
A_PLUS_B, // 0x04
|
||||||
|
A_MINUS_B,
|
||||||
|
A_MUL_B,
|
||||||
|
A_DIV_B,
|
||||||
|
A_AND_B, // 0x08
|
||||||
|
A_OR_B,
|
||||||
|
A_XOR_B,
|
||||||
|
null,
|
||||||
|
null, // 0x0c
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
SET_NOT_A, // 0x10
|
||||||
|
SET_NOT_B,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null, // 0x14
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null, // 0x18
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null, // 0x1C
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
};
|
||||||
|
|
||||||
|
public static ScriptOperation get(int code){
|
||||||
|
return operations[code];
|
||||||
|
}
|
||||||
|
|
||||||
|
int n;
|
||||||
|
|
||||||
|
public int getCode(){
|
||||||
|
return this.n;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ScriptCondition {
|
||||||
|
NEVER (0x00),
|
||||||
|
ALWAYS (0x01),
|
||||||
|
A_EQ_ZERO (0x02),
|
||||||
|
A_NEQ_ZERO (0x03),
|
||||||
|
A_EQ_B (0x04),
|
||||||
|
A_NEQ_B (0x05),
|
||||||
|
A_LT_B (0x06),
|
||||||
|
A_GT_B (0x07)
|
||||||
|
;
|
||||||
|
|
||||||
|
static ScriptCondition scriptConditions[] = {
|
||||||
|
NEVER,
|
||||||
|
ALWAYS,
|
||||||
|
A_EQ_ZERO,
|
||||||
|
A_NEQ_ZERO,
|
||||||
|
A_EQ_B,
|
||||||
|
A_NEQ_B,
|
||||||
|
A_LT_B,
|
||||||
|
A_GT_B
|
||||||
|
};
|
||||||
|
|
||||||
|
static ScriptCondition get(int code){
|
||||||
|
return scriptConditions[code];
|
||||||
|
}
|
||||||
|
|
||||||
|
private int code;
|
||||||
|
|
||||||
|
ScriptCondition(int code){
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCode(){
|
||||||
|
return this.code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class SimpleScriptElement{
|
||||||
|
private int code;
|
||||||
|
|
||||||
|
public SimpleScriptElement(){
|
||||||
|
code = 0;
|
||||||
|
}
|
||||||
|
public SimpleScriptElement(int code){
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SimpleScriptElement(int a,int b,int z,ScriptCondition scriptCondition,ScriptOperation scriptOperation){
|
||||||
|
setA(a);
|
||||||
|
setB(b);
|
||||||
|
setZ(z);
|
||||||
|
setScriptCondition(scriptCondition);
|
||||||
|
setScriptOperation(scriptOperation);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
public void setCode(int code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
@TableColumn(label="A",order=0)
|
||||||
|
public int getA(){
|
||||||
|
return code & 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
@TableColumn(label="B",order=10)
|
||||||
|
public int getB(){
|
||||||
|
return (code >> 8) & 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
@TableColumn(label="Z",order=90)
|
||||||
|
public int getZ(){
|
||||||
|
return (code >> 16) & 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCondition(){
|
||||||
|
return (code >> 24) & 0xff;
|
||||||
|
}
|
||||||
|
public int getOperation(){
|
||||||
|
return (code >> 27) & 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setA(int a){
|
||||||
|
code &= ~0xff;
|
||||||
|
code |= a & 0xff;
|
||||||
|
}
|
||||||
|
public void setB(int b){
|
||||||
|
code &= ~( 0xff << 8 );
|
||||||
|
code |= (b & 0xff) << 8;
|
||||||
|
}
|
||||||
|
public void setZ(int z){
|
||||||
|
code &= ~( 0xff << 16 );
|
||||||
|
code |= (z & 0xff) << 16;
|
||||||
|
}
|
||||||
|
public void setCondition(int condition){
|
||||||
|
code &= ~( 0x07 << 24 );
|
||||||
|
code |= (condition & 0x07) << 24;
|
||||||
|
}
|
||||||
|
public void setOperation(int operation){
|
||||||
|
code &= ~( 0x1f << 27 );
|
||||||
|
code |= (operation & 0x1F) << 27;
|
||||||
|
}
|
||||||
|
|
||||||
|
@TableColumn(label="Operation",order=50)
|
||||||
|
ScriptOperation getScriptOperation(){
|
||||||
|
return ScriptOperation.get(getOperation());
|
||||||
|
}
|
||||||
|
public void setScriptOperation(ScriptOperation scriptOperation){
|
||||||
|
if (scriptOperation == null){
|
||||||
|
setOperation(0);
|
||||||
|
} else {
|
||||||
|
setOperation(scriptOperation.getCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@TableColumn(label="Bedingung",order=40)
|
||||||
|
public ScriptCondition getScriptCondition(){
|
||||||
|
return ScriptCondition.get(getCondition());
|
||||||
|
}
|
||||||
|
public void setScriptCondition(ScriptCondition scriptCondition){
|
||||||
|
if (scriptCondition == null){
|
||||||
|
setCondition(0);
|
||||||
|
} else {
|
||||||
|
setCondition(scriptCondition.getCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -125,6 +125,7 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
private JButton bIntfDel;
|
private JButton bIntfDel;
|
||||||
private JPanel panel_4;
|
private JPanel panel_4;
|
||||||
private JTextArea tfConnectionSettings;
|
private JTextArea tfConnectionSettings;
|
||||||
|
private JButton btnSkripte;
|
||||||
|
|
||||||
|
|
||||||
public static void startGUI(){
|
public static void startGUI(){
|
||||||
|
@ -330,6 +331,15 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
});
|
});
|
||||||
toolBar.add(btnDatenExportieren);
|
toolBar.add(btnDatenExportieren);
|
||||||
|
|
||||||
|
btnSkripte = new JButton("Skripte");
|
||||||
|
btnSkripte.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
SimpleScriptEditor editor = new SimpleScriptEditor();
|
||||||
|
editor.setVisible(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
toolBar.add(btnSkripte);
|
||||||
|
|
||||||
splitter = new JSplitPane();
|
splitter = new JSplitPane();
|
||||||
splitter.setBorder(null);
|
splitter.setBorder(null);
|
||||||
splitter.setOneTouchExpandable(true);
|
splitter.setOneTouchExpandable(true);
|
||||||
|
|
|
@ -0,0 +1,162 @@
|
||||||
|
package org.hwo.pulscounter.ui;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.FlowLayout;
|
||||||
|
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JDialog;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.border.EmptyBorder;
|
||||||
|
|
||||||
|
import org.hwo.models.TableMapper.TableColumn;
|
||||||
|
import org.hwo.pulscounter.simplescript.SimpleScript;
|
||||||
|
import org.hwo.pulscounter.simplescript.SimpleScript.ScriptCondition;
|
||||||
|
import org.hwo.pulscounter.simplescript.SimpleScript.SimpleScriptElement;
|
||||||
|
import static org.hwo.pulscounter.simplescript.SimpleScript.ScriptCondition.*;
|
||||||
|
import static org.hwo.pulscounter.simplescript.SimpleScript.SimpleScriptElement.*;
|
||||||
|
import org.hwo.ui.JMappedTable;
|
||||||
|
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import javax.swing.JTable;
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.JTextArea;
|
||||||
|
|
||||||
|
public class SimpleScriptEditor extends JDialog {
|
||||||
|
|
||||||
|
private SimpleScript simpleScript;
|
||||||
|
private boolean accepted;
|
||||||
|
|
||||||
|
private final JPanel contentPanel = new JPanel();
|
||||||
|
private JMappedTable mtScriptElements;
|
||||||
|
private JTextField tfName;
|
||||||
|
private JTextArea taDescription;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the dialog.
|
||||||
|
*/
|
||||||
|
public SimpleScriptEditor() {
|
||||||
|
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||||
|
setBounds(100, 100, 921, 474);
|
||||||
|
getContentPane().setLayout(new BorderLayout());
|
||||||
|
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
|
getContentPane().add(contentPanel, BorderLayout.CENTER);
|
||||||
|
GridBagLayout gbl_contentPanel = new GridBagLayout();
|
||||||
|
gbl_contentPanel.columnWidths = new int[]{0, 0, 0};
|
||||||
|
gbl_contentPanel.rowHeights = new int[]{0, 0, 0, 0};
|
||||||
|
gbl_contentPanel.columnWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
|
||||||
|
gbl_contentPanel.rowWeights = new double[]{0.0, 1.0, 1.0, Double.MIN_VALUE};
|
||||||
|
contentPanel.setLayout(gbl_contentPanel);
|
||||||
|
{
|
||||||
|
JLabel lblBezeichnung = new JLabel("Bezeichnung:");
|
||||||
|
GridBagConstraints gbc_lblBezeichnung = new GridBagConstraints();
|
||||||
|
gbc_lblBezeichnung.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_lblBezeichnung.anchor = GridBagConstraints.NORTH;
|
||||||
|
gbc_lblBezeichnung.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_lblBezeichnung.gridx = 0;
|
||||||
|
gbc_lblBezeichnung.gridy = 0;
|
||||||
|
contentPanel.add(lblBezeichnung, gbc_lblBezeichnung);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
tfName = new JTextField();
|
||||||
|
GridBagConstraints gbc_tfName = new GridBagConstraints();
|
||||||
|
gbc_tfName.anchor = GridBagConstraints.NORTH;
|
||||||
|
gbc_tfName.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_tfName.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_tfName.gridx = 1;
|
||||||
|
gbc_tfName.gridy = 0;
|
||||||
|
contentPanel.add(tfName, gbc_tfName);
|
||||||
|
tfName.setColumns(10);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
JLabel lblBescrheibung = new JLabel("Beschreibung:");
|
||||||
|
GridBagConstraints gbc_lblBescrheibung = new GridBagConstraints();
|
||||||
|
gbc_lblBescrheibung.anchor = GridBagConstraints.NORTH;
|
||||||
|
gbc_lblBescrheibung.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_lblBescrheibung.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_lblBescrheibung.gridx = 0;
|
||||||
|
gbc_lblBescrheibung.gridy = 1;
|
||||||
|
contentPanel.add(lblBescrheibung, gbc_lblBescrheibung);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
taDescription = new JTextArea();
|
||||||
|
GridBagConstraints gbc_taDescription = new GridBagConstraints();
|
||||||
|
gbc_taDescription.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_taDescription.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_taDescription.gridx = 1;
|
||||||
|
gbc_taDescription.gridy = 1;
|
||||||
|
contentPanel.add(taDescription, gbc_taDescription);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
JScrollPane scrollPane = new JScrollPane();
|
||||||
|
GridBagConstraints gbc_scrollPane = new GridBagConstraints();
|
||||||
|
gbc_scrollPane.gridwidth = 2;
|
||||||
|
gbc_scrollPane.insets = new Insets(0, 0, 0, 5);
|
||||||
|
gbc_scrollPane.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_scrollPane.gridx = 0;
|
||||||
|
gbc_scrollPane.gridy = 2;
|
||||||
|
contentPanel.add(scrollPane, gbc_scrollPane);
|
||||||
|
{
|
||||||
|
mtScriptElements = new JMappedTable(SimpleScriptElement.class);
|
||||||
|
scrollPane.setViewportView(mtScriptElements);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
JPanel buttonPane = new JPanel();
|
||||||
|
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
|
||||||
|
getContentPane().add(buttonPane, BorderLayout.SOUTH);
|
||||||
|
{
|
||||||
|
JButton okButton = new JButton("OK");
|
||||||
|
okButton.setActionCommand("OK");
|
||||||
|
buttonPane.add(okButton);
|
||||||
|
getRootPane().setDefaultButton(okButton);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
JButton cancelButton = new JButton("Cancel");
|
||||||
|
cancelButton.setActionCommand("Cancel");
|
||||||
|
buttonPane.add(cancelButton);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
initialize();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void accept(){
|
||||||
|
accepted = true;
|
||||||
|
setVisible(false);
|
||||||
|
}
|
||||||
|
private void cancel(){
|
||||||
|
setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAccepted() {
|
||||||
|
return accepted;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initialize(){
|
||||||
|
if (simpleScript == null){
|
||||||
|
simpleScript = new SimpleScript("Ein Skript", "Eine Beschreibung", new SimpleScriptElement[]{
|
||||||
|
new SimpleScriptElement(),
|
||||||
|
new SimpleScriptElement()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
tfName.setText(simpleScript.getName());
|
||||||
|
taDescription.setText(simpleScript.getDescription());
|
||||||
|
mtScriptElements.getTableMapper().setRows(simpleScript.getSimpleScriptElements());
|
||||||
|
}
|
||||||
|
|
||||||
|
public SimpleScript getSimpleScript(){
|
||||||
|
return this.simpleScript;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSimpleScript(SimpleScript simpleScript){
|
||||||
|
this.simpleScript = simpleScript;
|
||||||
|
initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue