/******************************************************************************************************************* * * 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)); }
@Override @Nonnull protected Node copyNode (final @Nonnull Node delegate) { return nodeFactory.createNode(getNode().getClass(), delegate); } }
@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); } } }