コード例 #1
0
 private HumanizedWidget getHumanizedWidget(Parameter.Widget widget) {
   for (HumanizedWidget humanizedWidget : humanizedWidgets) {
     if (humanizedWidget.getWidget() == widget) return humanizedWidget;
   }
   throw new AssertionError("Widget is not in humanized widget list.");
 }
コード例 #2
0
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() == labelField) {
     String newLabel = labelField.getText();
     if (newLabel.equals(parameter.getLabel())) return;
     nodeAttributesDialog.setParameterLabel(parameter, labelField.getText());
   } else if (e.getSource() == helpTextField) {
     String newHelpText = helpTextField.getText();
     if (newHelpText.equals(parameter.getHelpText())) return;
     nodeAttributesDialog.setParameterHelpText(parameter, helpTextField.getText());
   } else if (e.getSource() == widgetBox) {
     HumanizedWidget newWidget = (HumanizedWidget) widgetBox.getSelectedItem();
     if (parameter.getWidget() == newWidget.getWidget()) return;
     nodeAttributesDialog.setParameterWidget(parameter, newWidget.getWidget());
   } else if (e.getSource() == valueField) {
     String newValue = valueField.getText();
     if (parameter.getValue() != null && parameter.getValue().toString().equals(newValue)) return;
     try {
       nodeAttributesDialog.setParameterValue(
           parameter, parameter.parseValue(valueField.getText()));
     } catch (IllegalArgumentException e1) {
       showError("Value " + valueField.getText() + " is invalid: " + e1.getMessage());
     }
   } else if (e.getSource() == enableIfField) {
     String newEnableExpression = enableIfField.getText();
     if (newEnableExpression.equals(parameter.getEnableExpression())) return;
     nodeAttributesDialog.setParameterEnableExpression(parameter, newEnableExpression);
   } else if (e.getSource() == boundingMethodBox) {
     Parameter.BoundingMethod newMethod =
         Parameter.BoundingMethod.valueOf(
             boundingMethodBox.getSelectedItem().toString().toUpperCase(Locale.US));
     if (parameter.getBoundingMethod().equals(newMethod)) return;
     nodeAttributesDialog.setParameterBoundingMethod(parameter, newMethod);
   } else if (e.getSource() == minimumValueCheck) {
     if (minimumValueCheck.isSelected() && parameter.getMinimumValue() != null) return;
     nodeAttributesDialog.setParameterMinimumValue(
         parameter, minimumValueCheck.isSelected() ? 0f : null);
   } else if (e.getSource() == minimumValueField) {
     try {
       float v = Float.parseFloat(minimumValueField.getText());
       if (v == parameter.getMinimumValue()) return;
       nodeAttributesDialog.setParameterMinimumValue(parameter, v);
     } catch (Exception e1) {
       showError("Value " + minimumValueField.getText() + " is invalid: " + e1.getMessage());
     }
   } else if (e.getSource() == maximumValueCheck) {
     if (maximumValueCheck.isSelected() && parameter.getMaximumValue() != null) return;
     nodeAttributesDialog.setParameterMaximumValue(
         parameter, maximumValueCheck.isSelected() ? 0f : null);
   } else if (e.getSource() == maximumValueField) {
     try {
       float v = Float.parseFloat(maximumValueField.getText());
       if (v == parameter.getMaximumValue()) return;
       nodeAttributesDialog.setParameterMaximumValue(parameter, v);
     } catch (Exception e1) {
       showError("Value " + maximumValueField.getText() + " is invalid: " + e1.getMessage());
     }
   } else if (e.getSource() == displayLevelBox) {
     Parameter.DisplayLevel newDisplayLevel =
         Parameter.DisplayLevel.valueOf(
             displayLevelBox.getSelectedItem().toString().toUpperCase(Locale.US));
     if (parameter.getDisplayLevel() == newDisplayLevel) return;
     nodeAttributesDialog.setParameterDisplayLevel(parameter, newDisplayLevel);
   } else if (e.getSource() == addButton) {
     MenuItemDialog dialog = new MenuItemDialog((Dialog) SwingUtilities.getRoot(this));
     dialog.setVisible(true);
     if (dialog.isSuccessful()) {
       nodeAttributesDialog.addParameterMenuItem(parameter, dialog.getKey(), dialog.getLabel());
       menuItemsTable.tableChanged(new TableModelEvent(menuItemsTable.getModel()));
     }
   } else if (e.getSource() == removeButton) {
     Parameter.MenuItem item = parameter.getMenuItems().get(menuItemsTable.getSelectedRow());
     nodeAttributesDialog.removeParameterMenuItem(parameter, item);
   } else if (e.getSource() == upButton) {
     moveItemUp();
   } else if (e.getSource() == downButton) {
     moveItemDown();
   } else {
     throw new AssertionError("Unknown source " + e.getSource());
   }
   updateValues();
 }