163 lines
5.1 KiB
Java
163 lines
5.1 KiB
Java
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();
|
|
}
|
|
|
|
}
|