w-i-p
parent
53537905b3
commit
76caec8285
|
@ -0,0 +1,6 @@
|
||||||
|
org.hwo=HWOs Java Framework
|
||||||
|
interface=Gränssnitt
|
||||||
|
ok=OK
|
||||||
|
cancel=avbryta
|
||||||
|
SerialPortChooser.0=Välj granssnitt:
|
||||||
|
|
|
@ -1,120 +0,0 @@
|
||||||
package org.hwo.io.servicelink;
|
|
||||||
|
|
||||||
import java.awt.Component;
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
import javax.swing.JCheckBox;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
|
|
||||||
import org.hwo.io.servicelink.ServiceLink.ServiceNode;
|
|
||||||
import org.hwo.io.servicelink.ServiceLink.ServiceNode.ServiceNodeRegister;
|
|
||||||
import java.awt.FlowLayout;
|
|
||||||
import javax.swing.JScrollPane;
|
|
||||||
import java.awt.GridBagLayout;
|
|
||||||
import java.awt.GridBagConstraints;
|
|
||||||
import javax.swing.BoxLayout;
|
|
||||||
|
|
||||||
public class BitFieldEditor extends JPanel implements RegisterEditorControl {
|
|
||||||
|
|
||||||
private ServiceNodeRegister serviceNodeRegister;
|
|
||||||
|
|
||||||
private JCheckBox[] checkboxes;
|
|
||||||
private JScrollPane scrollPane;
|
|
||||||
private JPanel pBits;
|
|
||||||
|
|
||||||
public BitFieldEditor() {
|
|
||||||
GridBagLayout gridBagLayout = new GridBagLayout();
|
|
||||||
gridBagLayout.columnWidths = new int[]{0, 0};
|
|
||||||
gridBagLayout.rowHeights = new int[]{0, 0};
|
|
||||||
gridBagLayout.columnWeights = new double[]{1.0, Double.MIN_VALUE};
|
|
||||||
gridBagLayout.rowWeights = new double[]{1.0, Double.MIN_VALUE};
|
|
||||||
setLayout(gridBagLayout);
|
|
||||||
|
|
||||||
scrollPane = new JScrollPane();
|
|
||||||
GridBagConstraints gbc_scrollPane = new GridBagConstraints();
|
|
||||||
gbc_scrollPane.fill = GridBagConstraints.BOTH;
|
|
||||||
gbc_scrollPane.gridx = 0;
|
|
||||||
gbc_scrollPane.gridy = 0;
|
|
||||||
add(scrollPane, gbc_scrollPane);
|
|
||||||
|
|
||||||
pBits = new JPanel();
|
|
||||||
scrollPane.setViewportView(pBits);
|
|
||||||
pBits.setLayout(new BoxLayout(pBits, BoxLayout.Y_AXIS));
|
|
||||||
|
|
||||||
checkboxes = new JCheckBox[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initialize()
|
|
||||||
{
|
|
||||||
for (JCheckBox cb:checkboxes)
|
|
||||||
{
|
|
||||||
remove(cb);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (serviceNodeRegister != null)
|
|
||||||
{
|
|
||||||
checkboxes = new JCheckBox[32];
|
|
||||||
for (int i=0;i<32;i++)
|
|
||||||
{
|
|
||||||
if (serviceNodeRegister.getBitField().getLabels()[i]!=null)
|
|
||||||
{
|
|
||||||
checkboxes[i] = new JCheckBox();
|
|
||||||
checkboxes[i].setText(serviceNodeRegister.getBitField().getLabels()[i]);
|
|
||||||
|
|
||||||
pBits.add(checkboxes[i]);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
synchronize();
|
|
||||||
}
|
|
||||||
invalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void synchronize()
|
|
||||||
{
|
|
||||||
for (int i=0;i<32;i++)
|
|
||||||
{
|
|
||||||
if (checkboxes[i]!=null)
|
|
||||||
checkboxes[i].setSelected(
|
|
||||||
(serviceNodeRegister.getIntValue() & (1<<i))!=0
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setRegister(ServiceNodeRegister serviceNodeRegister) {
|
|
||||||
setServiceNodeRegister(serviceNodeRegister);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateRegister() {
|
|
||||||
Integer v = serviceNodeRegister.getIntValue();
|
|
||||||
|
|
||||||
for (int i=0;i<32;i++)
|
|
||||||
{
|
|
||||||
if (checkboxes[i]!=null)
|
|
||||||
{
|
|
||||||
if (checkboxes[i].isSelected())
|
|
||||||
v |= 1<<i;
|
|
||||||
else
|
|
||||||
v &= ~(1<<i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
serviceNodeRegister.setIntValue(v);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Component getComponent() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServiceNodeRegister getServiceNodeRegister() {
|
|
||||||
return serviceNodeRegister;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setServiceNodeRegister(ServiceNodeRegister serviceNodeRegister) {
|
|
||||||
this.serviceNodeRegister = serviceNodeRegister;
|
|
||||||
initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,216 +0,0 @@
|
||||||
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;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
serviceNodeRegister.read();
|
|
||||||
} catch (ServiceLinkRequestFailedException slex)
|
|
||||||
{
|
|
||||||
System.err.println("RegisterEditor: " + slex);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
package org.hwo.io.servicelink;
|
|
||||||
|
|
||||||
import java.awt.Component;
|
|
||||||
|
|
||||||
import javax.tools.JavaCompiler;
|
|
||||||
|
|
||||||
import org.hwo.io.servicelink.ServiceLink.ServiceNode.ServiceNodeRegister;
|
|
||||||
|
|
||||||
public interface RegisterEditorControl {
|
|
||||||
|
|
||||||
public void setRegister(ServiceNodeRegister serviceNodeRegister);
|
|
||||||
public boolean requestFocusInWindow();
|
|
||||||
public void updateRegister();
|
|
||||||
|
|
||||||
public Component getComponent();
|
|
||||||
}
|
|
|
@ -173,7 +173,6 @@ public class ServiceLink {
|
||||||
|
|
||||||
public class ServiceNode
|
public class ServiceNode
|
||||||
{
|
{
|
||||||
@InteractiveObject(editor=RegisterEditor.class)
|
|
||||||
public class ServiceNodeRegister
|
public class ServiceNodeRegister
|
||||||
{
|
{
|
||||||
@TableColumn(label="Register",readonly=true,width=60)
|
@TableColumn(label="Register",readonly=true,width=60)
|
||||||
|
|
|
@ -0,0 +1,204 @@
|
||||||
|
package org.hwo.io.servicelink.register;
|
||||||
|
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.swing.JCheckBox;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
|
import org.hwo.io.servicelink.ServiceLink;
|
||||||
|
import org.hwo.io.servicelink.ServiceLink.ServiceNode;
|
||||||
|
import org.hwo.io.servicelink.ServiceLink.ServiceNode.ServiceNodeRegister;
|
||||||
|
|
||||||
|
import java.awt.FlowLayout;
|
||||||
|
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
|
||||||
|
import java.awt.Checkbox;
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
|
||||||
|
import javax.swing.BoxLayout;
|
||||||
|
|
||||||
|
public class BitFieldEditor extends JPanel implements ServiceRegisterControl {
|
||||||
|
|
||||||
|
private ServiceNodeRegister serviceNodeRegister;
|
||||||
|
private ServiceRegister serviceRegister;
|
||||||
|
|
||||||
|
private JCheckBox[] checkboxes;
|
||||||
|
private JScrollPane scrollPane;
|
||||||
|
private JPanel pBits;
|
||||||
|
|
||||||
|
private Integer intValue;
|
||||||
|
|
||||||
|
private List<Field> fields;
|
||||||
|
|
||||||
|
public class Field
|
||||||
|
{
|
||||||
|
int start,
|
||||||
|
len;
|
||||||
|
|
||||||
|
String text;
|
||||||
|
|
||||||
|
JCheckBox checkbox;
|
||||||
|
|
||||||
|
public Field(int start,int len)
|
||||||
|
{
|
||||||
|
this.start = start;
|
||||||
|
this.len = len;
|
||||||
|
this.text = String.format("B%d",start);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Field(int start)
|
||||||
|
{
|
||||||
|
this.start = start;
|
||||||
|
this.len = 1;
|
||||||
|
this.text = String.format("B%d",start);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setText(String text)
|
||||||
|
{
|
||||||
|
this.text = text;
|
||||||
|
}
|
||||||
|
public String getText()
|
||||||
|
{
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTextRepresentation()
|
||||||
|
{
|
||||||
|
if (BitFieldEditor.this.getIntValue() != null)
|
||||||
|
{
|
||||||
|
if ((BitFieldEditor.this.getIntValue() & (1<<start)) != 0)
|
||||||
|
{
|
||||||
|
return getText();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
public Component getComponent()
|
||||||
|
{
|
||||||
|
if (checkbox == null)
|
||||||
|
{
|
||||||
|
checkbox = new JCheckBox();
|
||||||
|
checkbox.setText(getText());
|
||||||
|
}
|
||||||
|
return checkbox;
|
||||||
|
}
|
||||||
|
public void sync()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public BitFieldEditor() {
|
||||||
|
GridBagLayout gridBagLayout = new GridBagLayout();
|
||||||
|
gridBagLayout.columnWidths = new int[]{0, 0};
|
||||||
|
gridBagLayout.rowHeights = new int[]{0, 0};
|
||||||
|
gridBagLayout.columnWeights = new double[]{1.0, Double.MIN_VALUE};
|
||||||
|
gridBagLayout.rowWeights = new double[]{1.0, Double.MIN_VALUE};
|
||||||
|
setLayout(gridBagLayout);
|
||||||
|
|
||||||
|
scrollPane = new JScrollPane();
|
||||||
|
GridBagConstraints gbc_scrollPane = new GridBagConstraints();
|
||||||
|
gbc_scrollPane.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_scrollPane.gridx = 0;
|
||||||
|
gbc_scrollPane.gridy = 0;
|
||||||
|
add(scrollPane, gbc_scrollPane);
|
||||||
|
|
||||||
|
pBits = new JPanel();
|
||||||
|
scrollPane.setViewportView(pBits);
|
||||||
|
pBits.setLayout(new BoxLayout(pBits, BoxLayout.Y_AXIS));
|
||||||
|
|
||||||
|
checkboxes = new JCheckBox[0];
|
||||||
|
|
||||||
|
initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initialize()
|
||||||
|
{
|
||||||
|
removeAllFieldComponents();
|
||||||
|
createFieldControls();
|
||||||
|
|
||||||
|
doLayout();
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void createFieldControls()
|
||||||
|
{
|
||||||
|
fields = new ArrayList<BitFieldEditor.Field>();
|
||||||
|
for (int i=0;i<32;i++)
|
||||||
|
{
|
||||||
|
Field field = new Field(i);
|
||||||
|
fields.add(field);
|
||||||
|
addFieldComponent(field.getComponent());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void removeAllFieldComponents()
|
||||||
|
{
|
||||||
|
pBits.removeAll();
|
||||||
|
}
|
||||||
|
protected void addFieldComponent(Component component)
|
||||||
|
{
|
||||||
|
pBits.add(component);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void synchronize()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Component getComponent() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTextRepresentation() {
|
||||||
|
if (this.serviceRegister != null)
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
setIntValue(
|
||||||
|
this.serviceRegister.readIntegerValue()
|
||||||
|
);
|
||||||
|
|
||||||
|
Iterator<Field> iter = fields.iterator();
|
||||||
|
while (iter.hasNext())
|
||||||
|
{
|
||||||
|
String te = iter.next().getTextRepresentation();
|
||||||
|
if (te.length()>0)
|
||||||
|
{
|
||||||
|
sb.append(
|
||||||
|
te
|
||||||
|
);
|
||||||
|
if (!iter.hasNext())
|
||||||
|
break;
|
||||||
|
sb.append(", ");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
|
||||||
|
}
|
||||||
|
return "NC";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setServiceRegister(ServiceRegister serviceRegister) {
|
||||||
|
this.serviceRegister = serviceRegister;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getIntValue()
|
||||||
|
{
|
||||||
|
return this.intValue;
|
||||||
|
}
|
||||||
|
public void setIntValue(Integer value)
|
||||||
|
{
|
||||||
|
this.intValue = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package org.hwo.io.servicelink;
|
package org.hwo.io.servicelink.register;
|
||||||
|
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.event.FocusEvent;
|
import java.awt.event.FocusEvent;
|
||||||
|
@ -6,13 +6,16 @@ import java.awt.event.FocusListener;
|
||||||
|
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
|
|
||||||
|
import org.hwo.io.servicelink.ServiceLink;
|
||||||
|
import org.hwo.io.servicelink.ServiceLink.ServiceNode;
|
||||||
import org.hwo.io.servicelink.ServiceLink.ServiceNode.ServiceNodeRegister;
|
import org.hwo.io.servicelink.ServiceLink.ServiceNode.ServiceNodeRegister;
|
||||||
|
|
||||||
public class FloatEditor extends JTextField implements RegisterEditorControl {
|
public class FloatRegisterEditor extends JTextField implements ServiceRegisterControl {
|
||||||
|
|
||||||
private ServiceNodeRegister serviceNodeRegister;
|
private ServiceNodeRegister serviceNodeRegister;
|
||||||
|
private ServiceRegister serviceRegister;
|
||||||
|
|
||||||
public FloatEditor()
|
public FloatRegisterEditor()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
@ -29,11 +32,6 @@ public class FloatEditor extends JTextField implements RegisterEditorControl {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setRegister(ServiceNodeRegister serviceNodeRegister) {
|
|
||||||
setServiceNodeRegister(serviceNodeRegister);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServiceNodeRegister getServiceNodeRegister() {
|
public ServiceNodeRegister getServiceNodeRegister() {
|
||||||
return serviceNodeRegister;
|
return serviceNodeRegister;
|
||||||
}
|
}
|
||||||
|
@ -43,17 +41,27 @@ public class FloatEditor extends JTextField implements RegisterEditorControl {
|
||||||
setText(serviceNodeRegister.getFloatValue().toString());
|
setText(serviceNodeRegister.getFloatValue().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateRegister() {
|
|
||||||
Float f = Float.parseFloat(getText());
|
|
||||||
if (f!=null)
|
|
||||||
serviceNodeRegister.setFloatValue(f);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component getComponent() {
|
public Component getComponent() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTextRepresentation() {
|
||||||
|
if (serviceRegister != null)
|
||||||
|
{
|
||||||
|
Float v = serviceRegister.readFloatValue();
|
||||||
|
if (v == null)
|
||||||
|
return "-";
|
||||||
|
return String.format("0x%08x %f", v, v);
|
||||||
|
} else {
|
||||||
|
return "NC";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setServiceRegister(ServiceRegister serviceRegister) {
|
||||||
|
this.serviceRegister = serviceRegister;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,18 +1,22 @@
|
||||||
package org.hwo.io.servicelink;
|
package org.hwo.io.servicelink.register;
|
||||||
|
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.event.FocusEvent;
|
import java.awt.event.FocusEvent;
|
||||||
import java.awt.event.FocusListener;
|
import java.awt.event.FocusListener;
|
||||||
|
import java.math.BigInteger;
|
||||||
|
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
|
|
||||||
|
import org.hwo.io.servicelink.ServiceLink;
|
||||||
|
import org.hwo.io.servicelink.ServiceLink.ServiceNode;
|
||||||
import org.hwo.io.servicelink.ServiceLink.ServiceNode.ServiceNodeRegister;
|
import org.hwo.io.servicelink.ServiceLink.ServiceNode.ServiceNodeRegister;
|
||||||
|
|
||||||
public class IntegerEditor extends JTextField implements RegisterEditorControl {
|
public class IntegerRegisterEditor extends JTextField implements ServiceRegisterControl {
|
||||||
|
|
||||||
private ServiceNodeRegister serviceNodeRegister;
|
private ServiceNodeRegister serviceNodeRegister;
|
||||||
|
private ServiceRegister serviceRegister;
|
||||||
|
|
||||||
public IntegerEditor()
|
public IntegerRegisterEditor()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
@ -29,11 +33,6 @@ public class IntegerEditor extends JTextField implements RegisterEditorControl {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setRegister(ServiceNodeRegister serviceNodeRegister) {
|
|
||||||
setServiceNodeRegister(serviceNodeRegister);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServiceNodeRegister getServiceNodeRegister() {
|
public ServiceNodeRegister getServiceNodeRegister() {
|
||||||
return serviceNodeRegister;
|
return serviceNodeRegister;
|
||||||
}
|
}
|
||||||
|
@ -43,17 +42,26 @@ public class IntegerEditor extends JTextField implements RegisterEditorControl {
|
||||||
setText(serviceNodeRegister.getIntValue().toString());
|
setText(serviceNodeRegister.getIntValue().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateRegister() {
|
|
||||||
Integer i = Integer.decode(getText());
|
|
||||||
if (i!=null)
|
|
||||||
serviceNodeRegister.setIntValue(i);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component getComponent() {
|
public Component getComponent() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTextRepresentation() {
|
||||||
|
if (serviceRegister != null)
|
||||||
|
{
|
||||||
|
Integer v = serviceRegister.readIntegerValue();
|
||||||
|
if (v == null)
|
||||||
|
return "-";
|
||||||
|
return String.format("0x%08x %d", v, v);
|
||||||
|
} else
|
||||||
|
return "NC";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setServiceRegister(ServiceRegister serviceRegister) {
|
||||||
|
this.serviceRegister = serviceRegister;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,179 @@
|
||||||
|
package org.hwo.io.servicelink.register;
|
||||||
|
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Hashtable;
|
||||||
|
|
||||||
|
import org.hwo.interactiveobjects.InteractiveObject;
|
||||||
|
import org.hwo.io.servicelink.ServiceLink;
|
||||||
|
import org.hwo.io.servicelink.ServiceLink.ServiceTelegram;
|
||||||
|
import org.hwo.io.servicelink.ServiceLinkException;
|
||||||
|
import org.hwo.models.TableMapper.TableColumn;
|
||||||
|
|
||||||
|
@InteractiveObject(editor=ServiceRegisterEditorDialog.class)
|
||||||
|
public class ServiceRegister {
|
||||||
|
|
||||||
|
static HashMap<String, Class<? extends ServiceRegisterControl>> controls;
|
||||||
|
public static void addServiceRegisterControl(String regType,Class<? extends ServiceRegisterControl> clazz)
|
||||||
|
{
|
||||||
|
controls.put(regType, clazz);
|
||||||
|
}
|
||||||
|
public static ServiceRegisterControl createControlForType(String registerType)
|
||||||
|
{
|
||||||
|
Class<? extends ServiceRegisterControl> clazz;
|
||||||
|
if (controls.containsKey(registerType))
|
||||||
|
clazz = controls.get(registerType);
|
||||||
|
else
|
||||||
|
clazz = controls.get(null);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ServiceRegisterControl src = clazz.newInstance();
|
||||||
|
|
||||||
|
return src;
|
||||||
|
} catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ServiceLink serviceLink;
|
||||||
|
private Integer ax,
|
||||||
|
node,
|
||||||
|
register;
|
||||||
|
|
||||||
|
private String registerType;
|
||||||
|
private String registerName;
|
||||||
|
|
||||||
|
private ServiceRegisterControl
|
||||||
|
serviceRegisterControl;
|
||||||
|
|
||||||
|
public ServiceRegister()
|
||||||
|
{
|
||||||
|
serviceLink = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ServiceRegister(ServiceLink serviceLink)
|
||||||
|
{
|
||||||
|
this.serviceLink = serviceLink;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ServiceRegisterControl getServiceRegisterControl()
|
||||||
|
{
|
||||||
|
if (serviceRegisterControl == null)
|
||||||
|
{
|
||||||
|
serviceRegisterControl = createControlForType(getRegisterType());
|
||||||
|
serviceRegisterControl.setServiceRegister(this);
|
||||||
|
}
|
||||||
|
return serviceRegisterControl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ServiceLink getServiceLink() {
|
||||||
|
return serviceLink;
|
||||||
|
}
|
||||||
|
public void setServiceLink(ServiceLink serviceLink) {
|
||||||
|
this.serviceLink = serviceLink;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Integer getAx() {
|
||||||
|
return ax;
|
||||||
|
}
|
||||||
|
public void setAx(Integer ax) {
|
||||||
|
this.ax = ax;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Integer getNode() {
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
public void setNode(Integer node) {
|
||||||
|
this.node = node;
|
||||||
|
}
|
||||||
|
|
||||||
|
@TableColumn(label="Register",firstColumn=true)
|
||||||
|
public Integer getRegister() {
|
||||||
|
return register;
|
||||||
|
}
|
||||||
|
public void setRegister(Integer register) {
|
||||||
|
this.register = register;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getRegisterType() {
|
||||||
|
return registerType;
|
||||||
|
}
|
||||||
|
public void setRegisterType(String registerType) {
|
||||||
|
this.registerType = registerType;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@TableColumn(label="Bezeichnung",after="Register")
|
||||||
|
public String getRegisterName() {
|
||||||
|
return registerName;
|
||||||
|
}
|
||||||
|
public void setRegisterName(String registerName) {
|
||||||
|
this.registerName = registerName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@TableColumn(label="Wert",after="Bezeichnung")
|
||||||
|
public String getTextRepresentation()
|
||||||
|
{
|
||||||
|
return getServiceRegisterControl().getTextRepresentation();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Float readFloatValue()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return this.serviceLink.readFloat(ax.byteValue(), node.byteValue(), register.shortValue());
|
||||||
|
} catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public void writeFloatValue(Float value)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this.serviceLink.writeFloat(ax.byteValue(), node.byteValue(), register.shortValue(),value);
|
||||||
|
} catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer readIntegerValue()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return this.serviceLink.readInt(ax.byteValue(), node.byteValue(), register.shortValue());
|
||||||
|
} catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public void writeIntegerValue(Integer value)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this.serviceLink.writeInt(ax.byteValue(), node.byteValue(), register.shortValue(),value);
|
||||||
|
} catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static {
|
||||||
|
controls = new HashMap<String, Class<? extends ServiceRegisterControl>>();
|
||||||
|
|
||||||
|
addServiceRegisterControl(null, IntegerRegisterEditor.class);
|
||||||
|
addServiceRegisterControl("float", FloatRegisterEditor.class);
|
||||||
|
addServiceRegisterControl("Bitfield", BitFieldEditor.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package org.hwo.io.servicelink.register;
|
||||||
|
|
||||||
|
import java.awt.Component;
|
||||||
|
|
||||||
|
import javax.tools.JavaCompiler;
|
||||||
|
|
||||||
|
import org.hwo.io.servicelink.ServiceLink;
|
||||||
|
import org.hwo.io.servicelink.ServiceLink.ServiceNode;
|
||||||
|
import org.hwo.io.servicelink.ServiceLink.ServiceNode.ServiceNodeRegister;
|
||||||
|
|
||||||
|
public interface ServiceRegisterControl {
|
||||||
|
|
||||||
|
public boolean requestFocusInWindow();
|
||||||
|
|
||||||
|
public Component getComponent();
|
||||||
|
|
||||||
|
public void setServiceRegister(ServiceRegister serviceRegister);
|
||||||
|
String getTextRepresentation();
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,201 @@
|
||||||
|
package org.hwo.io.servicelink.register;
|
||||||
|
|
||||||
|
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.interactiveobjects.IInteractiveObjectEditor;
|
||||||
|
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import javax.swing.border.TitledBorder;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.BoxLayout;
|
||||||
|
|
||||||
|
public class ServiceRegisterEditorDialog extends JDialog implements IInteractiveObjectEditor{
|
||||||
|
|
||||||
|
private final JPanel contentPanel = new JPanel();
|
||||||
|
|
||||||
|
private ServiceRegister serviceRegister;
|
||||||
|
private JTextField textField;
|
||||||
|
private JTextField textField_1;
|
||||||
|
private JTextField textField_2;
|
||||||
|
private JPanel panelEditorControl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Launch the application.
|
||||||
|
*/
|
||||||
|
public static void main(String[] args) {
|
||||||
|
try {
|
||||||
|
ServiceRegisterEditorDialog dialog = new ServiceRegisterEditorDialog();
|
||||||
|
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||||
|
dialog.setVisible(true);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the dialog.
|
||||||
|
*/
|
||||||
|
public ServiceRegisterEditorDialog() {
|
||||||
|
setBounds(100, 100, 519, 318);
|
||||||
|
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};
|
||||||
|
gbl_contentPanel.rowHeights = new int[]{0, 0, 0};
|
||||||
|
gbl_contentPanel.columnWeights = new double[]{1.0, Double.MIN_VALUE};
|
||||||
|
gbl_contentPanel.rowWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
|
||||||
|
contentPanel.setLayout(gbl_contentPanel);
|
||||||
|
{
|
||||||
|
JPanel panel = new JPanel();
|
||||||
|
panel.setBorder(new TitledBorder(null, "Service Register", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||||
|
GridBagConstraints gbc_panel = new GridBagConstraints();
|
||||||
|
gbc_panel.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_panel.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_panel.gridx = 0;
|
||||||
|
gbc_panel.gridy = 0;
|
||||||
|
contentPanel.add(panel, gbc_panel);
|
||||||
|
GridBagLayout gbl_panel = new GridBagLayout();
|
||||||
|
gbl_panel.columnWidths = new int[]{0, 0, 0};
|
||||||
|
gbl_panel.rowHeights = new int[]{0, 0, 0, 0};
|
||||||
|
gbl_panel.columnWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
|
||||||
|
gbl_panel.rowWeights = new double[]{0.0, 0.0, 0.0, Double.MIN_VALUE};
|
||||||
|
panel.setLayout(gbl_panel);
|
||||||
|
{
|
||||||
|
JLabel lblAchse = new JLabel("Achse:");
|
||||||
|
GridBagConstraints gbc_lblAchse = new GridBagConstraints();
|
||||||
|
gbc_lblAchse.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_lblAchse.anchor = GridBagConstraints.EAST;
|
||||||
|
gbc_lblAchse.gridx = 0;
|
||||||
|
gbc_lblAchse.gridy = 0;
|
||||||
|
panel.add(lblAchse, gbc_lblAchse);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
textField = new JTextField();
|
||||||
|
GridBagConstraints gbc_textField = new GridBagConstraints();
|
||||||
|
gbc_textField.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_textField.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_textField.gridx = 1;
|
||||||
|
gbc_textField.gridy = 0;
|
||||||
|
panel.add(textField, gbc_textField);
|
||||||
|
textField.setColumns(10);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
JLabel lblKnoten = new JLabel("Knoten:");
|
||||||
|
GridBagConstraints gbc_lblKnoten = new GridBagConstraints();
|
||||||
|
gbc_lblKnoten.anchor = GridBagConstraints.EAST;
|
||||||
|
gbc_lblKnoten.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_lblKnoten.gridx = 0;
|
||||||
|
gbc_lblKnoten.gridy = 1;
|
||||||
|
panel.add(lblKnoten, gbc_lblKnoten);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
textField_1 = new JTextField();
|
||||||
|
GridBagConstraints gbc_textField_1 = new GridBagConstraints();
|
||||||
|
gbc_textField_1.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_textField_1.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_textField_1.gridx = 1;
|
||||||
|
gbc_textField_1.gridy = 1;
|
||||||
|
panel.add(textField_1, gbc_textField_1);
|
||||||
|
textField_1.setColumns(10);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
JLabel lblRegister = new JLabel("Register:");
|
||||||
|
GridBagConstraints gbc_lblRegister = new GridBagConstraints();
|
||||||
|
gbc_lblRegister.anchor = GridBagConstraints.EAST;
|
||||||
|
gbc_lblRegister.insets = new Insets(0, 0, 0, 5);
|
||||||
|
gbc_lblRegister.gridx = 0;
|
||||||
|
gbc_lblRegister.gridy = 2;
|
||||||
|
panel.add(lblRegister, gbc_lblRegister);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
textField_2 = new JTextField();
|
||||||
|
GridBagConstraints gbc_textField_2 = new GridBagConstraints();
|
||||||
|
gbc_textField_2.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_textField_2.gridx = 1;
|
||||||
|
gbc_textField_2.gridy = 2;
|
||||||
|
panel.add(textField_2, gbc_textField_2);
|
||||||
|
textField_2.setColumns(10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
panelEditorControl = new JPanel();
|
||||||
|
GridBagConstraints gbc_panelEditorControl = new GridBagConstraints();
|
||||||
|
gbc_panelEditorControl.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_panelEditorControl.gridx = 0;
|
||||||
|
gbc_panelEditorControl.gridy = 1;
|
||||||
|
contentPanel.add(panelEditorControl, gbc_panelEditorControl);
|
||||||
|
panelEditorControl.setLayout(new BoxLayout(panelEditorControl, BoxLayout.X_AXIS));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
JPanel buttonPane = new JPanel();
|
||||||
|
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
|
||||||
|
getContentPane().add(buttonPane, BorderLayout.SOUTH);
|
||||||
|
{
|
||||||
|
JButton okButton = new JButton("OK");
|
||||||
|
okButton.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
|
accept();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
okButton.setActionCommand("OK");
|
||||||
|
buttonPane.add(okButton);
|
||||||
|
getRootPane().setDefaultButton(okButton);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
JButton cancelButton = new JButton("Cancel");
|
||||||
|
cancelButton.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
cancel();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
cancelButton.setActionCommand("Cancel");
|
||||||
|
buttonPane.add(cancelButton);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void accept()
|
||||||
|
{
|
||||||
|
setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cancel()
|
||||||
|
{
|
||||||
|
setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeView()
|
||||||
|
{
|
||||||
|
panelEditorControl.removeAll();
|
||||||
|
if (serviceRegister != null)
|
||||||
|
{
|
||||||
|
panelEditorControl.add( serviceRegister.getServiceRegisterControl().getComponent() );
|
||||||
|
}
|
||||||
|
|
||||||
|
doLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setInteractiveObject(Object o) {
|
||||||
|
serviceRegister = (ServiceRegister)o;
|
||||||
|
initializeView();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getInteractiveObject() {
|
||||||
|
return serviceRegister;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -8,6 +8,7 @@ import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -358,6 +359,13 @@ public class TableMapper extends AbstractTableModel
|
||||||
this.p_rows = rows;
|
this.p_rows = rows;
|
||||||
fireTableDataChanged();
|
fireTableDataChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRows(Object[] rows)
|
||||||
|
{
|
||||||
|
this.p_rows = Arrays.asList(rows);
|
||||||
|
fireTableDataChanged();
|
||||||
|
}
|
||||||
|
|
||||||
public List getRows()
|
public List getRows()
|
||||||
{
|
{
|
||||||
return this.p_rows;
|
return this.p_rows;
|
||||||
|
|
|
@ -221,6 +221,7 @@ public class JSearchTextField extends JTextField implements FocusListener {
|
||||||
|
|
||||||
if (!popupList.isVisible())
|
if (!popupList.isVisible())
|
||||||
{
|
{
|
||||||
|
popupList.setPopupSize(getSize().width, 250);
|
||||||
popupList.show(this, 0, getHeight());
|
popupList.show(this, 0, getHeight());
|
||||||
popupList.setVisible(true);
|
popupList.setVisible(true);
|
||||||
grabFocus();
|
grabFocus();
|
||||||
|
|
Loading…
Reference in New Issue