Java Code Examples for org.eclipse.jdt.core.search.IJavaSearchConstants#INTERFACE

The following examples show how to use org.eclipse.jdt.core.search.IJavaSearchConstants#INTERFACE . 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: ModelBasedSearchableEnvironment.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
private static int convertSearchFilterToModelFilter(int searchFilter) {
	switch (searchFilter) {
		case IJavaSearchConstants.CLASS:
			return NameLookup.ACCEPT_CLASSES;
		case IJavaSearchConstants.INTERFACE:
			return NameLookup.ACCEPT_INTERFACES;
		case IJavaSearchConstants.ENUM:
			return NameLookup.ACCEPT_ENUMS;
		case IJavaSearchConstants.ANNOTATION_TYPE:
			return NameLookup.ACCEPT_ANNOTATIONS;
		case IJavaSearchConstants.CLASS_AND_ENUM:
			return NameLookup.ACCEPT_CLASSES | NameLookup.ACCEPT_ENUMS;
		case IJavaSearchConstants.CLASS_AND_INTERFACE:
			return NameLookup.ACCEPT_CLASSES | NameLookup.ACCEPT_INTERFACES;
		default:
			return NameLookup.ACCEPT_ALL;
	}
}
 
Example 2
Source File: ClientBundleResourceDialog.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
private IType chooseResourceType() {
  IJavaSearchScope scope;
  try {
    scope = SearchEngine.createHierarchyScope(ClientBundleUtilities.findResourcePrototypeType(javaProject));
    FilteredTypesSelectionDialog dialog = new FilteredTypesSelectionDialog(
        getShell(), false, PlatformUI.getWorkbench().getProgressService(),
        scope, IJavaSearchConstants.INTERFACE);
    dialog.setTitle("Resource Type Selection");
    dialog.setMessage("Choose a resource type:");

    if (dialog.open() == Window.OK) {
      return (IType) dialog.getFirstResult();
    }
  } catch (JavaModelException e) {
    GWTPluginLog.logError(e);
  }

  return null;
}
 
Example 3
Source File: AddResourcesToClientBundleDialog.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
private IType chooseClientBundleType() {
  try {
    // Create a search scope for finding ClientBundle subtypes
    IJavaSearchScope scope = SearchEngine.createHierarchyScope(ClientBundleUtilities.findClientBundleType(getJavaProject()));

    // Configure the type selection dialog
    FilteredTypesSelectionDialog dialog = new FilteredTypesSelectionDialog(
        getShell(), false, PlatformUI.getWorkbench().getProgressService(),
        scope, IJavaSearchConstants.INTERFACE);
    dialog.setTitle("ClientBundle Type Selection");
    dialog.setMessage("Choose a type:");

    if (dialog.open() == Window.OK) {
      return (IType) dialog.getFirstResult();
    }
  } catch (JavaModelException e) {
    GWTPluginLog.logError(e);
  }

  return null;
}
 
Example 4
Source File: JavaContext.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private int getSearchForConstant(int typeKinds) {
	final int CLASSES= SimilarElementsRequestor.CLASSES;
	final int INTERFACES= SimilarElementsRequestor.INTERFACES;
	final int ENUMS= SimilarElementsRequestor.ENUMS;
	final int ANNOTATIONS= SimilarElementsRequestor.ANNOTATIONS;

	switch (typeKinds & (CLASSES | INTERFACES | ENUMS | ANNOTATIONS)) {
		case CLASSES: return IJavaSearchConstants.CLASS;
		case INTERFACES: return IJavaSearchConstants.INTERFACE;
		case ENUMS: return IJavaSearchConstants.ENUM;
		case ANNOTATIONS: return IJavaSearchConstants.ANNOTATION_TYPE;
		case CLASSES | INTERFACES: return IJavaSearchConstants.CLASS_AND_INTERFACE;
		case CLASSES | ENUMS: return IJavaSearchConstants.CLASS_AND_ENUM;
		default: return IJavaSearchConstants.TYPE;
	}
}
 
Example 5
Source File: TypeInfoFilter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private boolean matchesModifiers(TypeNameMatch type) {
	if (fElementKind == IJavaSearchConstants.TYPE)
		return true;
	int modifiers= type.getModifiers() & TYPE_MODIFIERS;
	switch (fElementKind) {
		case IJavaSearchConstants.CLASS:
			return modifiers == 0;
		case IJavaSearchConstants.ANNOTATION_TYPE:
			return Flags.isAnnotation(modifiers);
		case IJavaSearchConstants.INTERFACE:
			return modifiers == Flags.AccInterface;
		case IJavaSearchConstants.ENUM:
			return Flags.isEnum(modifiers);
		case IJavaSearchConstants.CLASS_AND_INTERFACE:
			return modifiers == 0 || modifiers == Flags.AccInterface;
		case IJavaSearchConstants.CLASS_AND_ENUM:
			return modifiers == 0 || Flags.isEnum(modifiers);
		case IJavaSearchConstants.INTERFACE_AND_ANNOTATION:
			return Flags.isInterface(modifiers);
	}
	return false;
}
 
Example 6
Source File: AddImportsOperation.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private int getSearchForConstant(int typeKinds) {
	final int CLASSES= SimilarElementsRequestor.CLASSES;
	final int INTERFACES= SimilarElementsRequestor.INTERFACES;
	final int ENUMS= SimilarElementsRequestor.ENUMS;
	final int ANNOTATIONS= SimilarElementsRequestor.ANNOTATIONS;

	switch (typeKinds & (CLASSES | INTERFACES | ENUMS | ANNOTATIONS)) {
		case CLASSES: return IJavaSearchConstants.CLASS;
		case INTERFACES: return IJavaSearchConstants.INTERFACE;
		case ENUMS: return IJavaSearchConstants.ENUM;
		case ANNOTATIONS: return IJavaSearchConstants.ANNOTATION_TYPE;
		case CLASSES | INTERFACES: return IJavaSearchConstants.CLASS_AND_INTERFACE;
		case CLASSES | ENUMS: return IJavaSearchConstants.CLASS_AND_ENUM;
		default: return IJavaSearchConstants.TYPE;
	}
}
 
Example 7
Source File: JavaUI.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 3 votes vote down vote up
/**
 * Creates a selection dialog that lists all types in the given scope.
 * The caller is responsible for opening the dialog with <code>Window.open</code>,
 * and subsequently extracting the selected type(s) (of type
 * <code>IType</code>) via <code>SelectionDialog.getResult</code>.
 *
 * @param parent the parent shell of the dialog to be created
 * @param context the runnable context used to show progress when the dialog
 *   is being populated
 * @param scope the scope that limits which types are included
 * @param style flags defining the style of the dialog; the only valid values are
 *   {@link IJavaElementSearchConstants#CONSIDER_CLASSES},
 *   {@link IJavaElementSearchConstants#CONSIDER_INTERFACES},
 *   {@link IJavaElementSearchConstants#CONSIDER_ANNOTATION_TYPES},
 *   {@link IJavaElementSearchConstants#CONSIDER_ENUMS},
 *   {@link IJavaElementSearchConstants#CONSIDER_ALL_TYPES},
 *   {@link IJavaElementSearchConstants#CONSIDER_CLASSES_AND_INTERFACES},
 *   {@link IJavaElementSearchConstants#CONSIDER_CLASSES_AND_ENUMS}, and
 *   {@link IJavaElementSearchConstants#CONSIDER_INTERFACES_AND_ANNOTATIONS}. Please note that
 *   the bitwise OR combination of the elementary constants is not supported.
 * @param multipleSelection <code>true</code> if multiple selection is allowed
 * @param filter the initial pattern to filter the set of types. For example "Abstract" shows
 *  all types starting with "abstract". The meta character '?' representing any character and
 *  '*' representing any string are supported. Clients can pass an empty string if no filtering
 *  is required.
 * @param extension a user interface extension to the type selection dialog or <code>null</code>
 *  if no extension is desired
 *
 * @return a new selection dialog
 *
 * @exception JavaModelException if the selection dialog could not be opened
 *
 * @since 3.2
 */
public static SelectionDialog createTypeDialog(Shell parent, IRunnableContext context, IJavaSearchScope scope, int style,
		boolean multipleSelection, String filter, TypeSelectionExtension extension) throws JavaModelException {
	int elementKinds= 0;
	if (style == IJavaElementSearchConstants.CONSIDER_ALL_TYPES) {
		elementKinds= IJavaSearchConstants.TYPE;
	} else if (style == IJavaElementSearchConstants.CONSIDER_INTERFACES) {
		elementKinds= IJavaSearchConstants.INTERFACE;
	} else if (style == IJavaElementSearchConstants.CONSIDER_CLASSES) {
		elementKinds= IJavaSearchConstants.CLASS;
	} else if (style == IJavaElementSearchConstants.CONSIDER_ANNOTATION_TYPES) {
		elementKinds= IJavaSearchConstants.ANNOTATION_TYPE;
	} else if (style == IJavaElementSearchConstants.CONSIDER_ENUMS) {
		elementKinds= IJavaSearchConstants.ENUM;
	} else if (style == IJavaElementSearchConstants.CONSIDER_CLASSES_AND_INTERFACES) {
		elementKinds= IJavaSearchConstants.CLASS_AND_INTERFACE;
	} else if (style == IJavaElementSearchConstants.CONSIDER_CLASSES_AND_ENUMS) {
		elementKinds= IJavaSearchConstants.CLASS_AND_ENUM;
	} else if (style == DEPRECATED_CONSIDER_TYPES) {
		elementKinds= IJavaSearchConstants.CLASS_AND_INTERFACE;
	} else if (style == IJavaElementSearchConstants.CONSIDER_INTERFACES_AND_ANNOTATIONS) {
		elementKinds= IJavaSearchConstants.INTERFACE_AND_ANNOTATION;
	} else {
		throw new IllegalArgumentException("Invalid style constant."); //$NON-NLS-1$
	}
	FilteredTypesSelectionDialog dialog= new FilteredTypesSelectionDialog(parent, multipleSelection,
		context, scope, elementKinds, extension);
	dialog.setMessage(JavaUIMessages.JavaUI_defaultDialogMessage);
	dialog.setInitialPattern(filter);
	return dialog;
}
 
Example 8
Source File: SuperInterfaceSelectionDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 3 votes vote down vote up
/**
 * Creates new instance of SuperInterfaceSelectionDialog
 *
 * @param parent
 *            shell to parent the dialog on
 * @param context
 *            context used to execute long-running operations associated
 *            with this dialog
 * @param page
 *            page that opened this dialog
 * @param p
 *            the java project which will be considered when searching for
 *            interfaces
 */
public SuperInterfaceSelectionDialog(Shell parent, IRunnableContext context, NewTypeWizardPage page, IJavaProject p) {
	super(parent, true, context, createSearchScope(p), IJavaSearchConstants.INTERFACE);
	fTypeWizardPage= page;
	// to restore the content of the dialog field if the dialog is canceled
	fOldContent= fTypeWizardPage.getSuperInterfaces();
	setStatusLineAboveButtons(true);
}
 
Example 9
Source File: SuperCapacitySelectionDialog.java    From sarl with Apache License 2.0 3 votes vote down vote up
/**
 * Creates new instance.
 *
 * @param parent shell to parent the dialog on.
 * @param context context used to execute long-running operations associated with this dialog.
 * @param project the java project which will be considered when searching for interfaces.
 * @param wizardPage the wizard page.
 * @param extension the wizard type selection extension.
 * @param multi indicates if multiple elements could be selected.
 */
public SuperCapacitySelectionDialog(Shell parent, IRunnableContext context, IJavaProject project,
		T wizardPage, SarlSpecificTypeSelectionExtension extension,
		boolean multi) {
	super(parent, context, wizardPage,
			createSearchScope(project, Capacity.class, true),
			IJavaSearchConstants.INTERFACE, extension, multi);
}