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

The following examples show how to use org.openide.util.Enumerations#singleton() . 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: StylesGrammarQueryManager.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
@Override
public Enumeration enabled(GrammarEnvironment ctx) {
    FileObject f = ctx.getFileObject();
    if (f != null && !f.getMIMEType().equals(StylesDataObject.SETTINGS_MIME_TYPE)) {
        return null;
    }
    Enumeration en = ctx.getDocumentChildren();
    while (en.hasMoreElements()) {
        Node next = (Node) en.nextElement();
        if (next.getNodeType() == Node.ELEMENT_NODE) {
            Element root = (Element) next;
            if ("resources".equals(root.getNodeName())) { // NOI18N
                return Enumerations.singleton(next);
            }
        }
    }
    return null;
}
 
Example 2
Source File: BoolsGrammarQueryManager.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
@Override
public Enumeration enabled(GrammarEnvironment ctx) {
    FileObject f = ctx.getFileObject();
    if (f != null && !f.getMIMEType().equals(BoolsDataObject.SETTINGS_MIME_TYPE)) {
        return null;
    }
    Enumeration en = ctx.getDocumentChildren();
    while (en.hasMoreElements()) {
        Node next = (Node) en.nextElement();
        if (next.getNodeType() == Node.ELEMENT_NODE) {
            Element root = (Element) next;
            if ("resources".equals(root.getNodeName())) { // NOI18N
                return Enumerations.singleton(next);
            }
        }
    }
    return null;
}
 
Example 3
Source File: ArrayGrammarQueryManager.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
@Override
public Enumeration enabled(GrammarEnvironment ctx) {
    FileObject f = ctx.getFileObject();
    if (f != null && !f.getMIMEType().equals(ArrayDataObject.SETTINGS_MIME_TYPE)) {
        return null;
    }
    Enumeration en = ctx.getDocumentChildren();
    while (en.hasMoreElements()) {
        Node next = (Node) en.nextElement();
        if (next.getNodeType() == Node.ELEMENT_NODE) {
            Element root = (Element) next;
            if ("resources".equals(root.getNodeName())) { // NOI18N
                return Enumerations.singleton(next);
            }
        }
    }
    return null;
}
 
Example 4
Source File: AttrsGrammarQueryManager.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
@Override
public Enumeration enabled(GrammarEnvironment ctx) {
    FileObject f = ctx.getFileObject();
    if (f != null && !f.getMIMEType().equals(AttrsDataObject.SETTINGS_MIME_TYPE)) {
        return null;
    }
    Enumeration en = ctx.getDocumentChildren();
    while (en.hasMoreElements()) {
        Node next = (Node) en.nextElement();
        if (next.getNodeType() == Node.ELEMENT_NODE) {
            Element root = (Element) next;
            if ("resources".equals(root.getNodeName())) { // NOI18N
                return Enumerations.singleton(next);
            }
        }
    }
    return null;
}
 
Example 5
Source File: UnknownValuesGrammarQueryManager.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
@Override
public Enumeration enabled(GrammarEnvironment ctx) {
    FileObject f = ctx.getFileObject();
    if (f != null && !f.getMIMEType().equals(UnknownValuesDataObject.SETTINGS_MIME_TYPE)) {
        return null;
    }
    Enumeration en = ctx.getDocumentChildren();
    while (en.hasMoreElements()) {
        Node next = (Node) en.nextElement();
        if (next.getNodeType() == Node.ELEMENT_NODE) {
            Element root = (Element) next;
            if ("resources".equals(root.getNodeName())) { // NOI18N
                return Enumerations.singleton(next);
            }
        }
    }
    return null;
}
 
Example 6
Source File: OperationListenerTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected Enumeration loaders () {
    if (extra == null) {
        return Enumerations.empty ();
    } else {
        return Enumerations.singleton (extra);
    }
}
 
Example 7
Source File: ErrorManager.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** Calls all delegates. */
public Throwable annotate(
    Throwable t, int severity, String message, final String localizedMessage, Throwable stackTrace,
    java.util.Date date
) {
    if (delegates.isEmpty()) {
        LogRecord rec = new LogRecord(convertSeverity(severity, true, Level.ALL), message);
        if (stackTrace != null) {
            rec.setThrown(stackTrace);
        }
        if (date != null) {
            rec.setMillis(date.getTime());
        }
        if (localizedMessage != null) {
            ResourceBundle rb = new ResourceBundle() {
                public Object handleGetObject(String key) {
                    if ("msg".equals(key)) { // NOI18N
                        return localizedMessage;
                    } else {
                        return null;
                    }
                }
                
                public Enumeration<String> getKeys() {
                    return Enumerations.singleton("msg"); // NOI18N
                }
            };
            rec.setResourceBundle(rb);
            rec.setMessage("msg"); // NOI18N
        }
        
        AnnException ann = AnnException.findOrCreate(t, true);
        if (ann != null) {  //#148778 - Although ann should not be null, it was reported it can happen.
            ann.addRecord(rec);
        }
        
        return t;
    }
    
    for (ErrorManager em : delegates) {
        em.annotate(t, severity, message, localizedMessage, stackTrace, date);
    }

    return t;
}
 
Example 8
Source File: SavableDataObjectTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
protected Enumeration<? extends DataLoader> loaders() {
    return Enumerations.singleton(SavaLoader.getLoader(SavaLoader.class));
}
 
Example 9
Source File: XMLDataObjectSubclassTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
protected Enumeration<? extends DataLoader> loaders() {
    return Enumerations.singleton(DataLoader.getLoader(MyXMLLoader.class));
}
 
Example 10
Source File: DataLoaderGetActionsTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected Enumeration<? extends DataLoader> loaders() {
    return Enumerations.singleton(DataLoader.getLoader(MyDL.class));
}
 
Example 11
Source File: DataFolderTimeOrderTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
protected Enumeration<? extends org.openide.loaders.DataLoader> loaders() {
    return Enumerations.singleton(DataLoader.getLoader(DataObjectInvalidationTest.SlowDataLoader.class));
}
 
Example 12
Source File: FakeJavaDataLoaderPool.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public Enumeration<? extends DataLoader> loaders() {
    return Enumerations.singleton(new JavaDataLoader());
}
 
Example 13
Source File: DefaultDataObjectTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
protected Enumeration<? extends DataLoader> loaders() {
    return Enumerations.singleton(JspLoader.getLoader(JspLoader.class));
}
 
Example 14
Source File: EnumerationsTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected <T> Enumeration<T> singleton(T obj) {
    return Enumerations.singleton(obj);
}
 
Example 15
Source File: CreateFromTemplateTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected Enumeration<DataLoader> loaders() {
    return Enumerations.<DataLoader>singleton(SimpleLoader.getLoader(SimpleLoader.class));
}
 
Example 16
Source File: MultiDataObjectContinuousTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected Enumeration<DataLoader> loaders() {
    return Enumerations.<DataLoader>singleton(SimpleLoader.getLoader(SimpleLoader.class));
}
 
Example 17
Source File: MultiDataObjectVersion1Test.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
protected Enumeration loaders() {
    return Enumerations.singleton(SimpleLoader.getLoader(SimpleLoader.class));
}
 
Example 18
Source File: JavadocTestSupport.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
protected Enumeration<? extends DataLoader> loaders() {
    return Enumerations.singleton(JavaDataLoader.findObject(JavaDataLoader.class, true));
}
 
Example 19
Source File: MultiDataObjectTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected Enumeration loaders() {
    return Enumerations.singleton(SimpleLoader.getLoader(SimpleLoader.class));
}
 
Example 20
Source File: IndentEngineIntTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected Enumeration<DataLoader> loaders() {
    return Enumerations.<DataLoader>singleton(SimpleLoader.getLoader(SimpleLoader.class));
}