@Override public void childrenAdded (NodeMemberEvent ev) { loadNodes(); }
@Override public void run() { try { Thread.sleep(retryPeriod); retrier.retry(); } catch (InterruptedException e) { } } });
@Override @Nonnull protected Node copyNode (final @Nonnull Node delegate) { return nodeFactory.createNode(getNode().getClass(), delegate); } }
@Override @Nonnull protected Node[] createNodes (final @Nonnull Object key) { if (key instanceof Node) { final Node node = (Node)key; if (isWaitingNode(node)) { return new Node[] { new GenericFilterNode(node) }; } return new Node[] { nodeFactory.createNode(getNode().getClass(), node) }; } else { return new Node[] { nodeFactory.createNode(getNode().getClass(), new NodePresentationModel(key)) }; } }
public void loadNodes() { final List<Object> keys = new ArrayList<Object>(); final Node[] nn = delegateChildren.getNodes(); if ((nn.length == 1) && isWaitingNode(nn[0])) { keys.add(nn[0]); } else if (nn.length > 0) { for (final Object o : composite.findChildren().results()) { try { keys.add(findRepresentantOf(o)); } catch (NotFoundException e) { keys.add(o); } } } setKeys(keys); }
/******************************************************************************************************************* * * ******************************************************************************************************************/ @Override public void handleException (final @CheckForNull Node node, final @Nonnull ChildFactory<?> childFactory, final @Nonnull Throwable throwable) { logger.fine("handleException(%s, %s, %s)", node, childFactory, throwable); logger.warning("While populating children nodes: ", throwable); logger.throwing(CLASS, "handleException()", throwable); if (node != null) { final Retrier retrier = new Retrier(node.getChildren(), (SafeChildFactory<?>) childFactory); node.getChildren().add(new Node[]{new ErrorNode(errorMessage, errorIconPath, throwable, retrier)}); } } }
@Nonnull private static org.openide.nodes.Children createChildren (final @Nonnull Node delegateNode, final @Nonnull Lookup lookup, final @Nonnull Object[] extraArgs) { // // If we have a different Composite than the delegate, we have to compute children on our own. // Otherwise, we use a DecoratorChildren as usual for FilterNodes that do not manipulate children. // final Composite<?, Finder<?>> newComposite = lookup.lookup(Composite.class); final Composite<?, Finder<?>> oldComposite = delegateNode.getLookup().lookup(Composite.class); if (newComposite == oldComposite) { return new DecoratorChildren(delegateNode, extraArgs); } else { // Can't occur, since newComposite != oldComposite, and removing a Composite is not supported assert newComposite != null : "newComposite is null"; // TODO: should reuse the existing nodes. Should use the DecoratorChildren as usual, but // rearranging nodes according to the order provided by the Composite, eventually ignoring things // not created by the composite. New items created in the Composite should be mapped to GenericNode. return new RearrangingChildren(delegateNode, newComposite, extraArgs); } } }
this.nodeFactory = new ReflectiveNodeFactory(extraArgs); loadNodes(); // FIXME: in addNotify()
@Override @Nonnull public Node decorate (final @Nonnull Node node) { final DefaultSortable sortable = new DefaultSortable(); final Node sortableNode = new LookupFilterDecoratorNode(node, new SortableCompositeLookupFilter(sortable)); sortable.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange (final @Nonnull PropertyChangeEvent event) { // Forces the reloading of children in sortableNode //@bluebook-ignore-begin final RearrangingChildren children = (RearrangingChildren)sortableNode.getChildren(); children.loadNodes(); //@bluebook-ignore-end } }); return sortableNode; } }
/******************************************************************************************************************* * * Creates a {@code GenericDecoratorNode} given the delegate node, and (optional) extra arguments * (meaningful if your subclasses need them). The extra arguments are passed as they are to constructor of children * nodes. * * @param delegate the delegate node * @param extraArgs the optional extra arguments * ******************************************************************************************************************/ public GenericDecoratorNode (final @Nonnull Node delegate, final @Nonnull Object ... extraArgs) { super(delegate, new DecoratorChildren(delegate, extraArgs)); }
public void refreshChildren() { System.err.println("REFRESH " + getChildren().getClass()); // System.err.println("REFRESH " + this + " CHILDREN " + getChildren().snapshot()); //// setChildren(org.openide.nodes.Children.LEAF); // System.err.println("AFTER REFRESH " + this + " CHILDREN " + getChildren().snapshot()); } }
public DecoratorChildren (final @Nonnull Node parent, final @Nonnull Object ... extraArgs) { super(parent); Parameters.notNull("parent", parent); nodeFactory = new ReflectiveNodeFactory(extraArgs); }
@Override @Nonnull public Lookup filter (final @Nonnull Lookup lookup) { final Composite<Object, Finder<Object>> delegateComposite = lookup(lookup, Composite); final SortableCompositeDecorator<Object> sortableComposite = new SortableCompositeDecorator<Object>(delegateComposite, sortable); return createLookupWith(createLookupReplacing(lookup, Composite, sortableComposite), sortable); } };
@Nonnull public Node createNode (final @Nonnull Class<? extends Node> nodeClass, final @Nonnull Node delegate) { final Object[] args = new Object[extraArgs.length + 1]; args[0] = delegate; System.arraycopy(extraArgs, 0, args, 1, extraArgs.length); try { return nodeClass.getConstructor(argTypes).newInstance(args); } catch (NoSuchMethodException e) { throw newExceptionBadConstructor(nodeClass, e); } catch (SecurityException e) { throw newExceptionBadConstructor(nodeClass, e); } catch (Exception e) { // RuntimeError would be caught by the Platform runtime throw new Error(e); } }
/******************************************************************************************************************* * * ******************************************************************************************************************/ @Nonnull private static Children createChildrenFromComposite (final @Nonnull Object object) { try { return Children.create(new CompositeChildFactory(find(object, Composite)), true); } catch (NotFoundException e) { return Children.LEAF; } }
@Override public void childrenRemoved (NodeMemberEvent ev) { loadNodes(); }
@Override public void propertyChange (final @Nonnull PropertyChangeEvent event) { // Forces the reloading of children in sortableNode //@bluebook-ignore-begin final RearrangingChildren children = (RearrangingChildren)sortableNode.getChildren(); children.loadNodes(); //@bluebook-ignore-end } });