コード例 #1
0
 public void setValue(AbstractMenuItemType menuItem) {
   oldValue = menuItem;
   if (menuItem != null) {
     nameTextField.setText(menuItem.getName());
     descriptionTextField.setText(menuItem.getDescription());
     iconTextField.setText(menuItem.getIcon());
     if (menuItem instanceof MenuItemType) {
       CommandType command = ((MenuItemType) menuItem).getCommand();
       commandComboBox.setSelectedItem(command.getRef());
       List<String> arguments = new ArrayList<>(command.getArgument());
       argumentTableModel = new ArgumentTableModel(arguments);
       argumentTable.setModel(argumentTableModel);
       argumentTable
           .getSelectionModel()
           .addListSelectionListener(
               new ListSelectionListener() {
                 @Override
                 public void valueChanged(ListSelectionEvent e) {
                   deleteArgumentButton.setEnabled(argumentTable.getSelectedRowCount() > 0);
                   moveArgumentDownButton.setEnabled(
                       argumentTable.getSelectedRow() < argumentTableModel.getRowCount() - 1);
                   moveArgumentUpButton.setEnabled(argumentTable.getSelectedRow() > 0);
                 }
               });
     } else {
       hideCommandComponents();
     }
   }
 }
コード例 #2
0
  public AbstractMenuItemType getValue() {
    AbstractMenuItemType menuItem;
    if (commandComboBox.isVisible()) {
      MenuItemType menuItemType = new MenuItemType();
      CommandType command = new CommandType();
      command.setRef((String) commandComboBoxModel.getSelectedItem());
      for (int row = 0; row < argumentTableModel.getRowCount(); row++) {
        final String value = (String) argumentTableModel.getValueAt(row, 0);
        if (value != null && value.length() > 0) {
          command.getArgument().add(value);
        }
      }
      menuItemType.setCommand(command);
      menuItem = menuItemType;
    } else {
      menuItem = new MenuGroupType();
    }
    menuItem.setName(nameTextField.getText());
    menuItem.setDescription(descriptionTextField.getText());
    menuItem.setIcon(iconTextField.getText());

    return menuItem;
  }