コード例 #1
0
 public MyValueEditor() {
   final ActionListener itemChoosen =
       new ActionListener() {
         @Override
         public void actionPerformed(@NotNull ActionEvent e) {
           if (myCurrentNode != null) {
             myCurrentNode.setValue(getCellEditorValue());
             somethingChanged();
           }
         }
       };
   myBooleanEditor.addActionListener(itemChoosen);
   myOptionsEditor.addActionListener(itemChoosen);
   myBooleanEditor.putClientProperty("JComponent.sizeVariant", "small");
   myOptionsEditor.putClientProperty("JComponent.sizeVariant", "small");
 }
コード例 #2
0
    @Override
    public Component getTableCellEditorComponent(
        JTable table, Object value, boolean isSelected, int row, int column) {
      final DefaultMutableTreeNode defaultNode =
          (DefaultMutableTreeNode)
              ((TreeTable) table).getTree().getPathForRow(row).getLastPathComponent();
      myCurrentEditor = null;
      myCurrentNode = null;
      if (defaultNode instanceof MyTreeNode) {
        MyTreeNode node = (MyTreeNode) defaultNode;
        myCurrentNode = node;
        if (node.getKey() instanceof BooleanOption) {
          myCurrentEditor = myBooleanEditor;
          myBooleanEditor.setSelected(node.getValue() == Boolean.TRUE);
          myBooleanEditor.setEnabled(node.isEnabled());
        } else if (node.getKey() instanceof IntOption) {
          IntOption intOption = (IntOption) node.getKey();
          myCurrentEditor = myIntOptionsEditor;
          myIntOptionsEditor.setText(
              intOption.isDefaultValue(node.getValue()) ? "" : node.getValue().toString());
          myIntOptionsEditor.setMinValue(intOption.getMinValue());
          myIntOptionsEditor.setMaxValue(intOption.getMaxValue());
          myIntOptionsEditor.setDefaultValue(intOption.getDefaultValue());
        } else {
          myCurrentEditor = myOptionsEditor;
          myOptionsEditor.setCell(table, row, column);
          myOptionsEditor.setText(String.valueOf(node.getValue()));
          myOptionsEditor.setOptions(((SelectionOption) node.getKey()).options);
          myOptionsEditor.setDefaultValue(node.getValue());
        }
      }

      if (myCurrentEditor != null) {
        myCurrentEditor.setBackground(table.getBackground());
      }
      return myCurrentEditor;
    }
コード例 #3
0
    @Override
    public Object getCellEditorValue() {
      if (myCurrentEditor == myOptionsEditor) {
        // new Alarm(Alarm.ThreadToUse.SWING_THREAD).addRequest(new Runnable() {
        //                                                       @Override
        //                                                       public void run() {
        //                                                         somethingChanged();
        //                                                       }
        //                                                     }, 100);
        return myOptionsEditor.getEditorValue();
      } else if (myCurrentEditor == myBooleanEditor) {
        return myBooleanEditor.isSelected();
      } else if (myCurrentEditor == myIntOptionsEditor) {
        return myIntOptionsEditor.getPresentableValue();
      }

      return null;
    }