protected void onSpecificationChange() { selectionListener.enable = false; // for (Node o : (Node[]) em.getSelectedNodes()) { // ((DecoratedNode) o).setHtmlDecorator(null); // } DecoratedNode root = (DecoratedNode) em.getRootContext(); Optional<DecoratedNode> node = root.breadthFirstIterable() .firstMatch( new Predicate<DecoratedNode>() { @Override public boolean apply(DecoratedNode input) { return isCurrentSpecificationNode(input.getOriginal()); } }); if (node.isPresent()) { // node.get().setHtmlDecorator(DecoratedNode.Html.BOLD); try { em.setSelectedNodes(new Node[] {node.get()}); } catch (PropertyVetoException ex) { // do nothing? } } selectionListener.enable = true; }
public SpecSelectionComponent(boolean showSystemOnly) { this.tree = new BeanTreeView(); this.em = new ExplorerManager(); this.selectionListener = new SelectionListener(); this.specification = newProperty(SPECIFICATION_PROPERTY, null); this.icon = newProperty(ICON_PROPERTY, null); tree.setRootVisible(false); tree.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); DecoratedNode root = new DecoratedNode( new DummyWsNode(WorkspaceFactory.getInstance().getActiveWorkspace(), SPECS_ID), showSystemOnly ? ItemWsNodeFilter.SYSTEM_ONLY : Predicates.<Node>alwaysTrue()); for (DecoratedNode o : root.breadthFirstIterable()) { o.setPreferredActionDecorator(DecoratedNode.PreferredAction.DO_NOTHING); } em.setRootContext(root); setLayout(new BorderLayout()); add(tree, BorderLayout.CENTER); setPreferredSize(new Dimension(225, 300)); em.addVetoableChangeListener(selectionListener); addPropertyChangeListener( new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { String p = evt.getPropertyName(); if (p.equals(SPECIFICATION_PROPERTY)) { onSpecificationChange(); } } }); }