@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); } };
@Override @Nonnull public Lookup filter (final @Nonnull Lookup lookup) { try { final Displayable originalDisplayable = safeLookup(lookup, Displayable); final Displayable decoraredDisplayable = new HiddenFilesInItalicsDisplayable(originalDisplayable); final Lookup lookup1 = createLookupReplacing(lookup, Displayable, decoraredDisplayable); return createLookupWith(lookup1, HtmlDisplayName.INSTANCE); } catch (NotFoundException e) // nodes with no Displayable, e.g. "Please wait..." { return cloned(lookup); } } };
@Nonnull public static <T> Lookup createLookupReplacing (final @Nonnull Lookup lookup, final @Nonnull Class<? super T> replacedClass, final @Nonnull T object) { return createLookupWith(createLookupWithout(lookup, replacedClass), object); }
private void initialize() { if (!initialized) { initialized = true; if (lookup(object, TextReadable, null) != null) { actions.add(new OpenTextReadableAction(lookup(object, TextReadable))); } else if (lookup(object, BinaryReadable, null) != null) { actions.add(new OpenBinaryReadableAction(lookup(object, BinaryReadable))); } } } };
@Override @Nonnull public Lookup filter (final @Nonnull Lookup lookup) { final FileModel3 fileModel = lookup.lookup(FileModel3.class); final IconProvider iconProvider = new IconProvider() { @Override @Nonnull public Icon getIcon (final @Nonnegative int size) { return FileSystemView.getFileSystemView().getSystemIcon(new File(fileModel.getPath())); } }; return createLookupWith(lookup, iconProvider); } };
@Nonnull public static <T> T lookup (final @Nonnull Object object, final @Nonnull Class<T> clazz) { try { final Field defaultField = clazz.getDeclaredField("DEFAULT"); return lookup(object, clazz, (T)defaultField.get(null)); } catch (NoSuchFieldException e) { throw new IllegalArgumentException("Class " + clazz + " doesn't provide a public static DEFAULT implementation", e); } catch (SecurityException e) { throw new IllegalArgumentException("Class " + clazz + " doesn't provide a public static DEFAULT implementation", e); } catch (IllegalArgumentException e) { throw new IllegalArgumentException("Class " + clazz + " doesn't provide a public static DEFAULT implementation", e); } catch (IllegalAccessException e) { throw new IllegalArgumentException("Class " + clazz + " doesn't provide a public static DEFAULT implementation", e); } } //@bluebook-end 2
@Nonnegative public int count (final @Nonnull Object object) { int r = 1; for (final Object child : EnhancedLookups.lookup(object, Composite.class, Composite.DEFAULT).findChildren().results()) { r += count(child); } return r; } }
@Nonnegative public int count (final @Nonnull Object object) { int r = 1; for (final Object child : lookup(object, Composite).findChildren().results()) { r += count(child); } return r; } }
@Nonnull public static <T, R> R accept (final @Nonnull T object, final @Nonnull Visitor<T, R> visitor) throws NotFoundException { visitor.visit(object); for (final Object child : lookup(object, Composite).findChildren().results()) { accept((T)child, visitor); } return visitor.getValue(); } }