@NotNull @Override public Component getTreeCellRendererComponent( @NotNull JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { if (value instanceof MyTreeNode) { MyTreeNode node = (MyTreeNode) value; myLabel.setText(getRenamedTitle(node.getKey().field.getName(), node.getText())); myLabel.setFont( myLabel .getFont() .deriveFont(node.getKey().groupName == null ? Font.BOLD : Font.PLAIN)); myLabel.setEnabled(node.isEnabled()); } else { myLabel.setText(getRenamedTitle(value.toString(), value.toString())); myLabel.setFont(myLabel.getFont().deriveFont(Font.BOLD)); myLabel.setEnabled(true); } Color foreground = selected ? UIUtil.getTableSelectionForeground() : UIUtil.getTableForeground(); myLabel.setForeground(foreground); return myLabel; }
@Override public Object valueOf(Object o) { if (o instanceof MyTreeNode) { MyTreeNode node = (MyTreeNode) o; return node.getText(); } return o.toString(); }
@Override public Object valueOf(Object o) { if (o instanceof MyTreeNode) { MyTreeNode node = (MyTreeNode) o; return node.getValue(); } return null; }
private static void applyNode(TreeNode node, final CodeStyleSettings settings) { if (node instanceof MyTreeNode) { ((MyTreeNode) node).apply(settings); } for (int j = 0; j < node.getChildCount(); j++) { TreeNode child = node.getChildAt(j); applyNode(child, settings); } }
private static void resetNode(TreeNode node, CodeStyleSettings settings) { if (node instanceof MyTreeNode) { ((MyTreeNode) node).reset(settings); } for (int j = 0; j < node.getChildCount(); j++) { TreeNode child = node.getChildAt(j); resetNode(child, settings); } }
@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; }
@Override public void setValue(Object o, Object o1) { MyTreeNode node = (MyTreeNode) o; node.setValue(o1); }