forked from LupusNobilis/java-org.hwo
210 lines
6.7 KiB
Java
210 lines
6.7 KiB
Java
package org.hwo.io.servicelink;
|
|
|
|
import java.awt.BorderLayout;
|
|
import java.awt.EventQueue;
|
|
|
|
import javax.swing.JFrame;
|
|
import javax.swing.JPanel;
|
|
import javax.swing.border.EmptyBorder;
|
|
|
|
import org.hwo.interactiveobjects.IInteractiveObjectEditor;
|
|
import org.hwo.io.servicelink.ServiceLink.ServiceNode.ServiceNodeRegister;
|
|
|
|
import java.awt.GridBagLayout;
|
|
|
|
import javax.swing.JLabel;
|
|
|
|
import java.awt.GridBagConstraints;
|
|
import java.awt.Insets;
|
|
|
|
import javax.swing.JTextField;
|
|
import javax.swing.JButton;
|
|
import javax.xml.ws.ServiceMode;
|
|
|
|
import java.awt.event.ActionListener;
|
|
import java.awt.event.ActionEvent;
|
|
import java.awt.event.WindowFocusListener;
|
|
import java.awt.event.WindowEvent;
|
|
|
|
public class RegisterEditor extends JFrame implements IInteractiveObjectEditor{
|
|
|
|
private JPanel contentPane;
|
|
private JTextField tfRegister;
|
|
private JLabel lblLabel;
|
|
private JTextField tfValueAct;
|
|
|
|
ServiceNodeRegister serviceNodeRegister;
|
|
private JPanel pEditor;
|
|
|
|
private RegisterEditorControl editorControl;
|
|
|
|
public RegisterEditor() {
|
|
addWindowFocusListener(new WindowFocusListener() {
|
|
public void windowGainedFocus(WindowEvent arg0) {
|
|
if (editorControl != null)
|
|
editorControl.requestFocusInWindow();
|
|
}
|
|
public void windowLostFocus(WindowEvent arg0) {
|
|
}
|
|
});
|
|
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
|
setBounds(100, 100, 628, 304);
|
|
contentPane = new JPanel();
|
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
|
setContentPane(contentPane);
|
|
GridBagLayout gbl_contentPane = new GridBagLayout();
|
|
gbl_contentPane.columnWidths = new int[]{0, 0, 0};
|
|
gbl_contentPane.rowHeights = new int[]{0, 0, 0, 0, 0, 0};
|
|
gbl_contentPane.columnWeights = new double[]{1.0, 1.0, Double.MIN_VALUE};
|
|
gbl_contentPane.rowWeights = new double[]{0.0, 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE};
|
|
contentPane.setLayout(gbl_contentPane);
|
|
|
|
JLabel lblRegister = new JLabel("Register:");
|
|
GridBagConstraints gbc_lblRegister = new GridBagConstraints();
|
|
gbc_lblRegister.anchor = GridBagConstraints.EAST;
|
|
gbc_lblRegister.insets = new Insets(0, 0, 5, 5);
|
|
gbc_lblRegister.gridx = 0;
|
|
gbc_lblRegister.gridy = 0;
|
|
contentPane.add(lblRegister, gbc_lblRegister);
|
|
|
|
tfRegister = new JTextField();
|
|
tfRegister.setEditable(false);
|
|
GridBagConstraints gbc_tfRegister = new GridBagConstraints();
|
|
gbc_tfRegister.insets = new Insets(0, 0, 5, 0);
|
|
gbc_tfRegister.fill = GridBagConstraints.HORIZONTAL;
|
|
gbc_tfRegister.gridx = 1;
|
|
gbc_tfRegister.gridy = 0;
|
|
contentPane.add(tfRegister, gbc_tfRegister);
|
|
tfRegister.setColumns(10);
|
|
|
|
JLabel lblBezeichnung = new JLabel("Bezeichnung:");
|
|
GridBagConstraints gbc_lblBezeichnung = new GridBagConstraints();
|
|
gbc_lblBezeichnung.anchor = GridBagConstraints.EAST;
|
|
gbc_lblBezeichnung.insets = new Insets(0, 0, 5, 5);
|
|
gbc_lblBezeichnung.gridx = 0;
|
|
gbc_lblBezeichnung.gridy = 1;
|
|
contentPane.add(lblBezeichnung, gbc_lblBezeichnung);
|
|
|
|
lblLabel = new JLabel("N/A");
|
|
GridBagConstraints gbc_lblLabel = new GridBagConstraints();
|
|
gbc_lblLabel.insets = new Insets(0, 0, 5, 0);
|
|
gbc_lblLabel.gridx = 1;
|
|
gbc_lblLabel.gridy = 1;
|
|
contentPane.add(lblLabel, gbc_lblLabel);
|
|
|
|
JLabel lblAlterWert = new JLabel("Alter Wert:");
|
|
GridBagConstraints gbc_lblAlterWert = new GridBagConstraints();
|
|
gbc_lblAlterWert.anchor = GridBagConstraints.EAST;
|
|
gbc_lblAlterWert.insets = new Insets(0, 0, 5, 5);
|
|
gbc_lblAlterWert.gridx = 0;
|
|
gbc_lblAlterWert.gridy = 2;
|
|
contentPane.add(lblAlterWert, gbc_lblAlterWert);
|
|
|
|
tfValueAct = new JTextField();
|
|
tfValueAct.setEditable(false);
|
|
GridBagConstraints gbc_tfValueAct = new GridBagConstraints();
|
|
gbc_tfValueAct.anchor = GridBagConstraints.NORTH;
|
|
gbc_tfValueAct.insets = new Insets(0, 0, 5, 0);
|
|
gbc_tfValueAct.fill = GridBagConstraints.HORIZONTAL;
|
|
gbc_tfValueAct.gridx = 1;
|
|
gbc_tfValueAct.gridy = 2;
|
|
contentPane.add(tfValueAct, gbc_tfValueAct);
|
|
tfValueAct.setColumns(10);
|
|
|
|
JLabel lblNeuerWert = new JLabel("Neuer Wert:");
|
|
GridBagConstraints gbc_lblNeuerWert = new GridBagConstraints();
|
|
gbc_lblNeuerWert.anchor = GridBagConstraints.NORTHEAST;
|
|
gbc_lblNeuerWert.insets = new Insets(0, 0, 5, 5);
|
|
gbc_lblNeuerWert.gridx = 0;
|
|
gbc_lblNeuerWert.gridy = 3;
|
|
contentPane.add(lblNeuerWert, gbc_lblNeuerWert);
|
|
|
|
pEditor = new JPanel();
|
|
GridBagConstraints gbc_pEditor = new GridBagConstraints();
|
|
gbc_pEditor.insets = new Insets(0, 0, 5, 0);
|
|
gbc_pEditor.fill = GridBagConstraints.BOTH;
|
|
gbc_pEditor.gridx = 1;
|
|
gbc_pEditor.gridy = 3;
|
|
contentPane.add(pEditor, gbc_pEditor);
|
|
pEditor.setLayout(new BorderLayout(0, 0));
|
|
|
|
JPanel panel = new JPanel();
|
|
GridBagConstraints gbc_panel = new GridBagConstraints();
|
|
gbc_panel.gridwidth = 2;
|
|
gbc_panel.fill = GridBagConstraints.BOTH;
|
|
gbc_panel.gridx = 0;
|
|
gbc_panel.gridy = 4;
|
|
contentPane.add(panel, gbc_panel);
|
|
GridBagLayout gbl_panel = new GridBagLayout();
|
|
gbl_panel.columnWidths = new int[]{0, 0, 0};
|
|
gbl_panel.rowHeights = new int[]{0, 0};
|
|
gbl_panel.columnWeights = new double[]{1.0, 1.0, Double.MIN_VALUE};
|
|
gbl_panel.rowWeights = new double[]{0.0, Double.MIN_VALUE};
|
|
panel.setLayout(gbl_panel);
|
|
|
|
JButton btnNewButton = new JButton("schreiben...");
|
|
btnNewButton.addActionListener(new ActionListener() {
|
|
public void actionPerformed(ActionEvent e) {
|
|
editorControl.updateRegister();
|
|
serviceNodeRegister.write();
|
|
setVisible(false);
|
|
}
|
|
});
|
|
GridBagConstraints gbc_btnNewButton = new GridBagConstraints();
|
|
gbc_btnNewButton.insets = new Insets(0, 0, 0, 5);
|
|
gbc_btnNewButton.gridx = 0;
|
|
gbc_btnNewButton.gridy = 0;
|
|
panel.add(btnNewButton, gbc_btnNewButton);
|
|
|
|
JButton btnNewButton_1 = new JButton("abbrechen");
|
|
btnNewButton_1.addActionListener(new ActionListener() {
|
|
public void actionPerformed(ActionEvent e) {
|
|
setVisible(false);
|
|
}
|
|
});
|
|
GridBagConstraints gbc_btnNewButton_1 = new GridBagConstraints();
|
|
gbc_btnNewButton_1.gridx = 1;
|
|
gbc_btnNewButton_1.gridy = 0;
|
|
panel.add(btnNewButton_1, gbc_btnNewButton_1);
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
public void setInteractiveObject(Object o) {
|
|
serviceNodeRegister = (ServiceNodeRegister)o;
|
|
|
|
serviceNodeRegister.read();
|
|
|
|
tfRegister.setText(serviceNodeRegister.register.toString());
|
|
lblLabel.setText(serviceNodeRegister.label);
|
|
tfValueAct.setText(serviceNodeRegister.value());
|
|
|
|
if (editorControl != null)
|
|
pEditor.remove(editorControl.getComponent());
|
|
|
|
if (serviceNodeRegister.isInteger())
|
|
{
|
|
editorControl = new IntegerEditor();
|
|
} else if (serviceNodeRegister.isFloat())
|
|
{
|
|
editorControl = new FloatEditor();
|
|
} else if (serviceNodeRegister.isBitField())
|
|
{
|
|
editorControl = new BitFieldEditor();
|
|
}
|
|
editorControl.setRegister(serviceNodeRegister);
|
|
pEditor.add(editorControl.getComponent());
|
|
pEditor.invalidate();
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
public Object getInteractiveObject() {
|
|
return serviceNodeRegister;
|
|
}
|
|
|
|
}
|