Java Code Examples for org.openide.util.Enumerations#array()

The following examples show how to use org.openide.util.Enumerations#array() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractFolder.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Creates enumeration of existing subfiles in all tree
* of files.
*
* @param rec should it be recursive or not
* @return enumeration of AbstractFolders
*/
final Enumeration<AbstractFolder> existingSubFiles(boolean rec) {
    if (!rec) {
        return Enumerations.array(subfiles());
    } else {
        class P implements org.openide.util.Enumerations.Processor<AbstractFolder, AbstractFolder> {
            public AbstractFolder process(AbstractFolder af, Collection<AbstractFolder> toAdd) {
                toAdd.addAll(Arrays.asList(af.subfiles()));

                return af;
            }
        }

        return Enumerations.queue(Enumerations.singleton(this), new P());
    }
}
 
Example 2
Source File: MultiFileSystem.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Computes a list of FileObjects in the right order
* that can represent this instance.
*
* @param name of resource to find
* @return enumeration of FileObject
*/
Enumeration<FileObject> delegates(final String name) {
    Enumeration<FileSystem> en = Enumerations.array(systems);

    // XXX order (stably) by weight
    class Resources implements Enumerations.Processor<FileSystem, FileObject> {
        public @Override FileObject process(FileSystem fs, Collection<FileSystem> ignore) {
            if (fs == null) {
                return null;
            } else {
                return findResourceOn(fs, name);
            }
        }
    }

    return Enumerations.filter(en, new Resources());
}
 
Example 3
Source File: BaseFileObj.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private Enumeration<FileChangeListener> getListeners() {
    synchronized (EVENT_SUPPORT_LOCK) {
        if (eventSupport == null) {
            return Enumerations.empty();
        }
        return Enumerations.array(eventSupport.getListeners(FileChangeListener.class));
    }
}
 
Example 4
Source File: AngularDoc.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void startLoading() {
    LOG.fine("start loading doc"); //NOI18N
    Directive[] dirs = Directive.values();
    directives = Enumerations.array(dirs);
    progress = ProgressHandleFactory.createHandle(Bundle.doc_building());
    progress.start(dirs.length);

    buildDoc();
}
 
Example 5
Source File: FileObjectArchive.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@NonNull
@Override
public Iterable<JavaFileObject> getFiles(
        @NonNull final String folderName,
        @NullAllowed final ClassPath.Entry entry,
        @NullAllowed final Set<JavaFileObject.Kind> kinds,
        @NullAllowed final JavaFileFilterImplementation filter,
        final boolean recursive) throws IOException {
    final FileObject folder = root.getFileObject(folderName);
    if (folder == null || !(entry == null || entry.includes(folder))) {
        return Collections.<JavaFileObject>emptySet();
    }
    final Enumeration<? extends FileObject> children;
    final List<JavaFileObject> result;
    if (recursive) {
        children = Enumerations.filter(
                folder.getChildren(recursive),
                (p,x)->{
                    return  !p.isFolder() && isInJavaPackage(folder,p) ?
                            p :
                            null;
                });
        result = new ArrayList<>(/*unknown size*/);
    } else {
        final FileObject[] chlds = folder.getChildren();
        children = Enumerations.array(chlds);
        result = new ArrayList<>(chlds.length);
    }
    while (children.hasMoreElements()) {
        final FileObject fo = children.nextElement();
        if (fo.isData() && (entry == null || entry.includes(fo))) {
            final Kind kind = FileObjects.getKind(fo.getExt());
            if (kinds == null || kinds.contains (kind)) {
                JavaFileObject file;
                if (kind == Kind.CLASS) {
                    file = FileObjects.fileObjectFileObject(fo, root, filter, null);
                } else {
                    file = FileObjects.sourceFileObject(fo, root, filter,false);
                }
                result.add(file);
            }
        }
    }
    return result;
}
 
Example 6
Source File: CreateFromTemplateHandlerTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected Enumeration<DataLoader> loaders() {
    return Enumerations.<DataLoader>array(new DataLoader[] { 
        SimpleLoader.getLoader(SimpleLoader.class),
        TwoPartLoader.getLoader(TwoPartLoader.class),
    });
}
 
Example 7
Source File: DefaultCreationNoTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected Enumeration<DataLoader> loaders() {
    return Enumerations.<DataLoader>array(new DataLoader[] { 
        SimpleLoader.getLoader(SimpleLoader.class),
    });
}
 
Example 8
Source File: DefaultCreationTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected Enumeration<DataLoader> loaders() {
    return Enumerations.<DataLoader>array(new DataLoader[] { 
        SimpleLoader.getLoader(SimpleLoader.class),
    });
}
 
Example 9
Source File: SCFTHandlerTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected Enumeration<DataLoader> loaders() {
    return Enumerations.<DataLoader>array(new DataLoader[] { 
        TwoPartLoader.getLoader(TwoPartLoader.class),
        SimpleLoader.getLoader(SimpleLoader.class),
    });
}
 
Example 10
Source File: PropertiesProviderTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected Enumeration<DataLoader> loaders() {
    return Enumerations.<DataLoader>array(new DataLoader[] { 
        TwoPartLoader.getLoader(TwoPartLoader.class),
        SimpleLoader.getLoader(SimpleLoader.class),
    });
}
 
Example 11
Source File: CreateFromTemplateHandlerTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected Enumeration<DataLoader> loaders() {
    return Enumerations.<DataLoader>array(new DataLoader[] { 
        SimpleLoader.getLoader(SimpleLoader.class),
        TwoPartLoader.getLoader(TwoPartLoader.class),
    });
}
 
Example 12
Source File: FightWithWrongOrderOfLoadersTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected Enumeration loaders() {
    return Enumerations.array(ARR);
}
 
Example 13
Source File: MultiDataObjectDeleteSecondaryEntryTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
protected Enumeration loaders() {
    return Enumerations.array(ARR);
}
 
Example 14
Source File: Children.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** Get the nodes as an enumeration.
* @return enumeration of nodes
*/
public final Enumeration<Node> nodes() {
    return Enumerations.array(getNodes());
}
 
Example 15
Source File: EnumerationsTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected <T> Enumeration<T> array(T[] arr) {
    return Enumerations.array(arr);
}
 
Example 16
Source File: SCFTHandlerTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected Enumeration<DataLoader> loaders() {
    return Enumerations.<DataLoader>array(new DataLoader[] { 
        TwoPartLoader.getLoader(TwoPartLoader.class),
        SimpleLoader.getLoader(SimpleLoader.class),
    });
}