FieldEditor.java
package algorithmen.umleditor;
import java.awt.*;
import javax.swing.*;
/**
* Editor für ein Datenfeld.
*/
public class FieldEditor extends Editor {
protected JTextField nameField;
protected JTextField typeField;
protected JTextField valueField;
protected JCheckBox staticField;
protected JComboBox accessField;
public FieldEditor(Field f, Frame p) {
super(f, 460, 150, p);
}
public FieldEditor(Field f, Dialog p) {
super(f, 460, 150, p);
}
protected void update() {
Field f = (Field) model;
f.setName(nameField.getText());
f.setStatic(staticField.isSelected());
f.setType(typeField.getText());
f.setVisibility((Visibility) accessField.getSelectedItem());
f.setValue(valueField.getText());
}
protected void buildMainPanel(JPanel mp) {
mp.setLayout(new GridLayout(3, 2));
Field f = (Field) model;
// add name field
JPanel namePanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
namePanel.add(new JLabel("Name:"));
nameField = new JTextField(f.getName(), 15);
namePanel.add(nameField);
mp.add(namePanel);
// add static field
JPanel staticPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
staticPanel.add(new JLabel("statisch:"));
staticField = new JCheckBox();
staticField.setSelected(f.isStatic());
staticPanel.add(staticField);
mp.add(staticPanel);
// add type field
JPanel typePanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
typePanel.add(new JLabel("Typ:"));
typeField = new JTextField(f.getType(), 15);
typePanel.add(typeField);
mp.add(typePanel);
// add access field
JPanel accessPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
accessPanel.add(new JLabel("Zugriffsklasse:"));
accessField = new JComboBox(Visibility.getVisibilities());
accessPanel.add(accessField);
mp.add(accessPanel);
// add value field
JPanel valuePanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
valuePanel.add(new JLabel("Wert:"));
valueField = new JTextField(f.getValue(), 15);
valuePanel.add(valueField);
mp.add(valuePanel);
}
}