menuItemsTable.tableChanged(new TableModelEvent(menuItemsTable.getModel()));
revalidate();
}
public void actionPerformed(ActionEvent e) {
Port port = getPort();
if (e.getSource() == labelField) {
if (labelField.getText().equals(port.getDisplayLabel())) return;
nodeAttributesDialog.setPortLabel(portName, labelField.getText());
} else if (e.getSource() == descriptionField) {
nodeAttributesDialog.setPortDescription(portName, descriptionField.getText());
} else if (e.getSource() == widgetBox) {
HumanizedObject newWidget = (HumanizedObject) widgetBox.getSelectedItem();
if (port.getWidget() == newWidget.getObject()) return;
nodeAttributesDialog.setPortWidget(portName, (Port.Widget) newWidget.getObject());
} else if (e.getSource() == rangeBox) {
HumanizedObject newRange = (HumanizedObject) rangeBox.getSelectedItem();
if (port.getRange() == newRange.getObject()) return;
nodeAttributesDialog.setPortRange(portName, (Port.Range) newRange.getObject());
} else if (e.getSource() == valueField) {
String newValue = valueField.getText();
if (port.getValue() != null && port.getValue().toString().equals(newValue)) return;
try {
nodeAttributesDialog.setPortValue(portName, Port.parseValue(port.getType(), valueField.getText()));
} catch (IllegalArgumentException e1) {
showError("Value " + valueField.getText() + " is invalid: " + e1.getMessage());
}
} else if (e.getSource() == minimumValueCheck) {
if (minimumValueCheck.isSelected() && port.getMinimumValue() != null) return;
nodeAttributesDialog.setPortMinimumValue(portName, minimumValueCheck.isSelected() ? (double) 0f : null);
} else if (e.getSource() == minimumValueField) {
try {
float v = Float.parseFloat(minimumValueField.getText());
if (v == port.getMinimumValue()) return;
nodeAttributesDialog.setPortMinimumValue(portName, (double) v);
} catch (Exception e1) {
showError("Value " + minimumValueField.getText() + " is invalid: " + e1.getMessage());
}
} else if (e.getSource() == maximumValueCheck) {
if (maximumValueCheck.isSelected() && port.getMaximumValue() != null) return;
nodeAttributesDialog.setPortMaximumValue(portName, maximumValueCheck.isSelected() ? (double) 0f : null);
} else if (e.getSource() == maximumValueField) {
try {
float v = Float.parseFloat(maximumValueField.getText());
if (v == port.getMaximumValue()) return;
nodeAttributesDialog.setPortMaximumValue(portName, (double) v);
} catch (Exception e1) {
showError("Value " + maximumValueField.getText() + " is invalid: " + e1.getMessage());
}
} else if (e.getSource() == addButton) {
MenuItemDialog dialog = new MenuItemDialog((Dialog) SwingUtilities.getRoot(this));
dialog.setVisible(true);
if (dialog.isSuccessful()) {
nodeAttributesDialog.addPortMenuItem(portName, dialog.getKey(), dialog.getLabel());
menuItemsTable.tableChanged(new TableModelEvent(menuItemsTable.getModel()));
}
} else if (e.getSource() == removeButton) {
MenuItem item = port.getMenuItems().get(menuItemsTable.getSelectedRow());
nodeAttributesDialog.removePortMenuItem(portName, item);
} else if (e.getSource() == upButton) {
moveMenuItemUp();
} else if (e.getSource() == downButton) {
moveMenuItemDown();