/******************************************************************************************************************* * * {@inheritDoc} * ******************************************************************************************************************/ @Override public boolean canDestroy() { try { find(object, Removable.class); return true; } catch (NotFoundException e) { return false; } }
/******************************************************************************************************************* * * {@inheritDoc} * ******************************************************************************************************************/ @Override public final boolean canRename() { try { find(object, MutableDisplayable); return true; } catch (NotFoundException e) { return false; } }
/******************************************************************************************************************* * * {@inheritDoc} * ******************************************************************************************************************/ @Override @CheckForNull public Action getPreferredAction() { try { return find(object, ActionProvider).getPreferredAction(); } catch (NotFoundException e) { return null; } }
/******************************************************************************************************************* * * {@inheritDoc} * ******************************************************************************************************************/ @Override @CheckForNull public Action[] getActions (final boolean context) { try { return find(object, ActionProvider).getActions().toArray(new Action[0]); } catch (NotFoundException e) { return new Action[0]; } }
/******************************************************************************************************************* * * ******************************************************************************************************************/ private void installIconChangeListener() { try { // FIXME: weak listener? Is the IconProvider allowed to change? find(object, MutableIconProvider).addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange (final @Nonnull PropertyChangeEvent event) { fireIconChange(); } }); } catch (NotFoundException e) { // ok, no MutableIconProvider } }
/******************************************************************************************************************* * * ******************************************************************************************************************/ @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; } }
/******************************************************************************************************************* * * {@inheritDoc} * ******************************************************************************************************************/ @Override @Nonnull public String getShortDescription() { try { return find(object, Describable).getDescription(); } catch (NotFoundException e) { return super.getShortDescription(); } }
/******************************************************************************************************************* * * ******************************************************************************************************************/ @Nonnull private Image findIcon (final int size) { try { return ImageUtilities.icon2Image(find(object, IconProvider).getIcon(size)); } catch (NotFoundException e) { return EMPTY_ICON; } }
final Removable removable = find(object, Removable.class);
/******************************************************************************************************************* * * Creates an {@code GenericNode} given the referred object, the children and a {@link Lookup}. * * @param object the referring object * @param children the children * @param lookup the {@code Lookup} * ******************************************************************************************************************/ public NodePresentationModel (final @Nonnull Object object, final @Nonnull Children children, final @Nonnull Lookup lookup) { super(children, createLookup(object, lookup)); this.object = object; try { name = find(object, Displayable).getDisplayName(); } catch (NotFoundException e) { name = "???"; // do this first logger.severe("No Displayable available for %s in %s", this, object); } installDisplayNameListener(); installIconChangeListener(); }
try displayable = find(object, MutableDisplayable);