Example usage for org.eclipse.jdt.core.search IJavaSearchConstants ENUM

List of usage examples for org.eclipse.jdt.core.search IJavaSearchConstants ENUM

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.search IJavaSearchConstants ENUM.

Prototype

int ENUM

To view the source code for org.eclipse.jdt.core.search IJavaSearchConstants ENUM.

Click Source Link

Document

The searched element is an enum.

Usage

From source file:com.openlegacy.enterprise.ide.eclipse.editors.pages.details.rpc.FieldsRpcEnumFieldDetailsPage.java

License:Open Source License

@Override
protected void addContent(FormToolkit toolkit, Composite client) {
    // create row for selecting Enum type
    Text enumControl = FormRowCreator.createStringRowWithBrowseButton(toolkit, client, mapTexts,
            getDefaultModifyListener(), Messages.getString("rpc.field.enum"), "", Constants.JAVA_TYPE, null, //$NON-NLS-1$//$NON-NLS-2$
            IJavaSearchConstants.ENUM, false, null, JAVA_DOCUMENTATION_TYPE.RPC, "");

    enumControl.addModifyListener(getEnumModifyListener());

    createEnumValuesSection(toolkit, client);
}

From source file:edu.brown.cs.bubbles.bedrock.BedrockJava.java

License:Open Source License

/********************************************************************************/

void handleJavaSearch(String proj, String bid, String patstr, String foritems, boolean defs, boolean refs,
        boolean impls, boolean equiv, boolean exact, boolean system, IvyXmlWriter xw) throws BedrockException {
    IJavaProject ijp = getJavaProject(proj);

    our_plugin.waitForEdits();/*ww w. j a v a 2  s  . c  o  m*/

    int forflags = 0;
    if (foritems == null)
        forflags = IJavaSearchConstants.TYPE;
    else if (foritems.equalsIgnoreCase("CLASS"))
        forflags = IJavaSearchConstants.CLASS;
    else if (foritems.equalsIgnoreCase("INTERFACE"))
        forflags = IJavaSearchConstants.INTERFACE;
    else if (foritems.equalsIgnoreCase("ENUM"))
        forflags = IJavaSearchConstants.ENUM;
    else if (foritems.equalsIgnoreCase("ANNOTATION"))
        forflags = IJavaSearchConstants.ANNOTATION_TYPE;
    else if (foritems.equalsIgnoreCase("CLASS&ENUM"))
        forflags = IJavaSearchConstants.CLASS_AND_ENUM;
    else if (foritems.equalsIgnoreCase("CLASS&INTERFACE"))
        forflags = IJavaSearchConstants.CLASS_AND_INTERFACE;
    else if (foritems.equalsIgnoreCase("TYPE"))
        forflags = IJavaSearchConstants.TYPE;
    else if (foritems.equalsIgnoreCase("FIELD"))
        forflags = IJavaSearchConstants.FIELD;
    else if (foritems.equalsIgnoreCase("METHOD"))
        forflags = IJavaSearchConstants.METHOD;
    else if (foritems.equalsIgnoreCase("CONSTRUCTOR"))
        forflags = IJavaSearchConstants.CONSTRUCTOR;
    else if (foritems.equalsIgnoreCase("PACKAGE"))
        forflags = IJavaSearchConstants.PACKAGE;
    else if (foritems.equalsIgnoreCase("FIELDWRITE"))
        forflags = IJavaSearchConstants.FIELD | IJavaSearchConstants.WRITE_ACCESSES;
    else if (foritems.equalsIgnoreCase("FIELDREAD"))
        forflags = IJavaSearchConstants.FIELD | IJavaSearchConstants.READ_ACCESSES;
    else
        forflags = IJavaSearchConstants.TYPE;

    int limit = 0;
    if (defs && refs)
        limit = IJavaSearchConstants.ALL_OCCURRENCES;
    else if (defs)
        limit = IJavaSearchConstants.DECLARATIONS;
    else if (refs)
        limit = IJavaSearchConstants.REFERENCES;
    else if (impls)
        limit = IJavaSearchConstants.IMPLEMENTORS;

    int mrule = SearchPattern.R_PATTERN_MATCH;
    if (equiv)
        mrule = SearchPattern.R_EQUIVALENT_MATCH;
    else if (exact)
        mrule = SearchPattern.R_EXACT_MATCH;

    SearchPattern pat = SearchPattern.createPattern(patstr, forflags, limit, mrule);
    if (pat == null) {
        throw new BedrockException(
                "Invalid java search pattern `" + patstr + "' " + forflags + " " + limit + " " + mrule);
    }

    FindFilter filter = null;
    if (forflags == IJavaSearchConstants.METHOD) {
        String p = patstr;
        int idx = p.indexOf("(");
        if (idx > 0)
            p = p.substring(0, idx);
        idx = p.lastIndexOf(".");
        if (idx > 0) {
            if (defs)
                filter = new ClassFilter(p.substring(0, idx));
        }
    }

    // TODO: create scope for only user's items
    IJavaElement[] pelt;
    if (ijp != null)
        pelt = new IJavaElement[] { ijp };
    else
        pelt = getAllProjects();

    ICompilationUnit[] working = getWorkingElements(pelt);
    for (ICompilationUnit xcu : working) {
        try {
            BedrockPlugin.logD("WORK WITH " + xcu.isWorkingCopy() + " " + xcu.getPath() + xcu.getSourceRange());
        } catch (JavaModelException e) {
            BedrockPlugin.logD("WORK WITH ERROR: " + e);
        }
    }

    IJavaSearchScope scp = null;
    int fg = IJavaSearchScope.SOURCES | IJavaSearchScope.REFERENCED_PROJECTS;
    if (system) {
        fg |= IJavaSearchScope.SYSTEM_LIBRARIES | IJavaSearchScope.APPLICATION_LIBRARIES;
        scp = SearchEngine.createWorkspaceScope();
    } else {
        scp = SearchEngine.createJavaSearchScope(pelt, fg);
    }

    SearchEngine se = new SearchEngine(working);
    SearchParticipant[] parts = new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() };
    FindHandler fh = new FindHandler(xw, filter, system);

    BedrockPlugin.logD("BEGIN SEARCH " + pat);
    BedrockPlugin.logD("SEARCH SCOPE " + system + " " + fg + " " + scp);

    try {
        se.search(pat, parts, scp, fh, null);
    } catch (Throwable e) {
        throw new BedrockException("Problem doing Java search: " + e, e);
    }
}

From source file:org.eclim.plugin.jdt.command.search.SearchCommand.java

License:Open Source License

/**
 * Translates the string type to the int equivalent.
 *
 * @param type The String type.//from w w w  .  ja  v a2s .  co  m
 * @return The int type.
 */
protected int getType(String type) {
    if (TYPE_ANNOTATION.equals(type)) {
        return IJavaSearchConstants.ANNOTATION_TYPE;
    } else if (TYPE_CLASS.equals(type)) {
        return IJavaSearchConstants.CLASS;
    } else if (TYPE_CLASS_OR_ENUM.equals(type)) {
        return IJavaSearchConstants.CLASS_AND_ENUM;
    } else if (TYPE_CLASS_OR_INTERFACE.equals(type)) {
        return IJavaSearchConstants.CLASS_AND_INTERFACE;
    } else if (TYPE_CONSTRUCTOR.equals(type)) {
        return IJavaSearchConstants.CONSTRUCTOR;
    } else if (TYPE_ENUM.equals(type)) {
        return IJavaSearchConstants.ENUM;
    } else if (TYPE_FIELD.equals(type)) {
        return IJavaSearchConstants.FIELD;
    } else if (TYPE_INTERFACE.equals(type)) {
        return IJavaSearchConstants.INTERFACE;
    } else if (TYPE_METHOD.equals(type)) {
        return IJavaSearchConstants.METHOD;
    } else if (TYPE_PACKAGE.equals(type)) {
        return IJavaSearchConstants.PACKAGE;
    }
    return IJavaSearchConstants.TYPE;
}

From source file:org.eclipse.ajdt.internal.ui.dialogs.TypeSelectionDialog2.java

License:Open Source License

private void ensureConsistency() throws InvocationTargetException, InterruptedException {
    // we only have to ensure history consistency here since the search engine
    // takes care of working copies.
    class ConsistencyRunnable implements IRunnableWithProgress {
        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            if (fgFirstTime) {
                // Join the initialize after load job.
                IJobManager manager = Platform.getJobManager();
                manager.join(JavaUI.ID_PLUGIN, monitor);
            }/*from  w  w w . ja  v a2 s .c o  m*/
            OpenTypeHistory history = OpenTypeHistory.getInstance();
            if (fgFirstTime || history.isEmpty()) {
                monitor.beginTask(JavaUIMessages.TypeSelectionDialog_progress_consistency, 100);
                if (history.needConsistencyCheck()) {
                    refreshSearchIndices(new SubProgressMonitor(monitor, 90));
                    history.checkConsistency(new SubProgressMonitor(monitor, 10));
                } else {
                    refreshSearchIndices(monitor);
                }
                monitor.done();
                fgFirstTime = false;
            } else {
                history.checkConsistency(monitor);
            }
        }

        public boolean needsExecution() {
            OpenTypeHistory history = OpenTypeHistory.getInstance();
            return fgFirstTime || history.isEmpty() || history.needConsistencyCheck();
        }

        private void refreshSearchIndices(IProgressMonitor monitor) throws InvocationTargetException {
            try {
                new SearchEngine().searchAllTypeNames(null, 0,
                        // make sure we search a concrete name. This is faster according to Kent  
                        "_______________".toCharArray(), //$NON-NLS-1$
                        SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE, IJavaSearchConstants.ENUM,
                        SearchEngine.createWorkspaceScope(), new TypeNameRequestor() {
                        }, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, monitor);
            } catch (JavaModelException e) {
                throw new InvocationTargetException(e);
            }
        }
    }
    ConsistencyRunnable runnable = new ConsistencyRunnable();
    if (!runnable.needsExecution())
        return;
    IRunnableContext context = fRunnableContext != null ? fRunnableContext
            : PlatformUI.getWorkbench().getProgressService();
    context.run(true, true, runnable);
}