Package org.eclipse.jdt.ui
Class JavaUI
java.lang.Object
org.eclipse.jdt.ui.JavaUI
Central access point for the Java UI plug-in (id
"org.eclipse.jdt.ui"
).
This class provides static methods for:
- creating various kinds of selection dialogs to present a collection of Java elements to the user and let them make a selection.
- opening a Java editor on a compilation unit.
This class provides static methods and fields only; it is not intended to be instantiated or subclassed by clients.
- Restriction:
- This class is not intended to be instantiated by clients.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Deprecated.As of 1.0static final String
The id of the Java action set (value"org.eclipse.jdt.ui.JavaActionSet"
).static final String
The id of the Java Browsing Perspective (value"org.eclipse.jdt.ui.JavaBrowsingPerspective"
).static final String
The editor part id of the editor that presents Java binary class files (value"org.eclipse.jdt.ui.ClassFileEditor"
).static final String
The preference page id of the class path variables preference page (value"org.eclipse.jdt.ui.preferences.ClasspathVariablesPreferencePage"
).static final String
The id of the Java Coding action set (value"org.eclipse.jdt.ui.CodingActionSet"
).static final String
static final String
The editor part id of the editor that presents Java compilation units (value"org.eclipse.jdt.ui.CompilationUnitEditor"
).static final String
The id of the Java Element Creation action set (value"org.eclipse.jdt.ui.JavaElementCreationActionSet"
).static final String
The id of the Java hierarchy perspective (value"org.eclipse.jdt.ui.JavaHierarchyPerspective"
).static final String
static final String
The view part id of the Javadoc view (value"org.eclipse.jdt.ui.JavadocView"
).static final String
The view part id of the Java Browsing Members view (value"org.eclipse.jdt.ui.MembersView"
).static final String
The editor part id of the module-info.class editor (value"org.eclipse.jdt.ui.ModuleInfoClassFileEditor"
).static final String
The editor part id of the module-info.class editor with no source (value"org.eclipse.jdt.ui.ModuleInfoClassFileEditorNoSource"
).static final String
The editor part id of the module-info.java editor (value"org.eclipse.jdt.ui.ModuleInfoEditor"
).static final String
The id of the Java action set for open actions (value"org.eclipse.jdt.ui.A_OpenActionSet"
).static final String
The view part id of the Packages view (value"org.eclipse.jdt.ui.PackageExplorer"
).static final String
The view part id of the Java Browsing Packages view (value"org.eclipse.jdt.ui.PackagesView"
).static final String
The id of the Java perspective (value"org.eclipse.jdt.ui.JavaPerspective"
).static final String
The id of the Java plug-in (value"org.eclipse.jdt.ui"
).static final String
The view part id of the Java Browsing Projects view (value"org.eclipse.jdt.ui.ProjectsView"
).static final String
The id of the Java Search action set (valueorg.eclipse.jdt.ui.SearchActionSet"
).static final String
The editor part id of the code snippet editor (value"org.eclipse.jdt.ui.SnippetEditor"
).static final String
The view part id of the source (declaration) view (value"org.eclipse.jdt.ui.SourceView"
).static final String
The view part id of the type hierarchy part (value"org.eclipse.jdt.ui.TypeHierarchy"
).static final String
The view part id of the Java Browsing Types view (value"org.eclipse.jdt.ui.TypesView"
).static final String
The preference page id of the user library preference page (value"org.eclipse.jdt.ui.preferences.UserLibraryPreferencePage"
). -
Method Summary
Modifier and TypeMethodDescriptionstatic org.eclipse.ui.dialogs.SelectionDialog
createMainTypeDialog
(org.eclipse.swt.widgets.Shell parent, org.eclipse.jface.operation.IRunnableContext context, IJavaSearchScope scope, int style, boolean multipleSelection) Creates a selection dialog that lists all types in the given scope containing a standardmain
method.static org.eclipse.ui.dialogs.SelectionDialog
createMainTypeDialog
(org.eclipse.swt.widgets.Shell parent, org.eclipse.jface.operation.IRunnableContext context, IJavaSearchScope scope, int style, boolean multipleSelection, String filter) Creates a selection dialog that lists all types in the given scope containing a standardmain
method.static org.eclipse.ui.dialogs.SelectionDialog
createPackageDialog
(org.eclipse.swt.widgets.Shell shell, boolean multipleSelection, int flags, String filter) Creates a selection dialog that lists all packages of all the Java projects.static org.eclipse.ui.dialogs.SelectionDialog
createPackageDialog
(org.eclipse.swt.widgets.Shell parent, IJavaProject project, int style) Creates a selection dialog that lists all packages of the given Java project.static org.eclipse.ui.dialogs.SelectionDialog
createPackageDialog
(org.eclipse.swt.widgets.Shell parent, IJavaProject project, int style, String filter) Creates a selection dialog that lists all packages of the given Java project.static org.eclipse.ui.dialogs.SelectionDialog
createPackageDialog
(org.eclipse.swt.widgets.Shell parent, IPackageFragmentRoot root) Creates a selection dialog that lists all packages under the given package fragment root.static org.eclipse.ui.dialogs.SelectionDialog
createPackageDialog
(org.eclipse.swt.widgets.Shell parent, IPackageFragmentRoot root, String filter) Creates a selection dialog that lists all packages under the given package fragment root.static org.eclipse.ui.dialogs.SelectionDialog
createPackageDialog
(org.eclipse.swt.widgets.Shell parent, org.eclipse.jface.operation.IRunnableContext context, IJavaSearchScope scope, boolean multipleSelection, boolean removeDuplicates, String filter) Creates a selection dialog that lists all packages of the given Java search scope.static org.eclipse.ui.dialogs.SelectionDialog
createPackageDialog
(org.eclipse.swt.widgets.Shell parent, org.eclipse.jface.operation.IRunnableContext context, IJavaSearchScope scope, boolean multipleSelection, int flags, String filter) Creates a selection dialog that lists all packages of the given Java search scope.static org.eclipse.ui.dialogs.SelectionDialog
createTypeDialog
(org.eclipse.swt.widgets.Shell parent, org.eclipse.jface.operation.IRunnableContext context, org.eclipse.core.resources.IProject project, int style, boolean multipleSelection) Creates a selection dialog that lists all types in the given project.static org.eclipse.ui.dialogs.SelectionDialog
createTypeDialog
(org.eclipse.swt.widgets.Shell parent, org.eclipse.jface.operation.IRunnableContext context, IJavaSearchScope scope, int style, boolean multipleSelection) Creates a selection dialog that lists all types in the given scope.static org.eclipse.ui.dialogs.SelectionDialog
createTypeDialog
(org.eclipse.swt.widgets.Shell parent, org.eclipse.jface.operation.IRunnableContext context, IJavaSearchScope scope, int style, boolean multipleSelection, String filter) Creates a selection dialog that lists all types in the given scope.static org.eclipse.ui.dialogs.SelectionDialog
createTypeDialog
(org.eclipse.swt.widgets.Shell parent, org.eclipse.jface.operation.IRunnableContext context, IJavaSearchScope scope, int style, boolean multipleSelection, String filter, TypeSelectionExtension extension) Creates a selection dialog that lists all types in the given scope.static IBufferFactory
Deprecated.IBufferFactory
has been replaced byWorkingCopyOwner
.static IColorManager
Returns the color manager the Java UI plug-in which is used to manage any Java-specific colors needed for such things like syntax highlighting.static org.eclipse.ui.texteditor.IDocumentProvider
Returns the DocumentProvider used for Java compilation units.static IJavaElement
getEditorInputJavaElement
(org.eclipse.ui.IEditorInput editorInput) Returns the Java element wrapped by the given editor input.static ITypeRoot
getEditorInputTypeRoot
(org.eclipse.ui.IEditorInput editorInput) Returns theITypeRoot
wrapped by the given editor input.static URL
getJavadocBaseLocation
(IJavaElement element) Returns the Javadoc base URL for an element.static URL
getJavadocLocation
(IJavaElement element, boolean includeAnchor) Returns the Javadoc URL for an element.static org.eclipse.swt.dnd.Transfer
Returns the transfer instance used to copy/paste Java elements to and from the clipboard.static URL
getLibraryJavadocLocation
(org.eclipse.core.runtime.IPath archivePath) Deprecated.Javadoc is now attached to the classpath entry.static URL
Returns the Javadoc location for library's classpath entry ornull
if no location is available.static URL
getProjectJavadocLocation
(IJavaProject project) Returns the Javadoc location for a Java project ornull
if no location is available.static ISharedImages
Returns the shared images for the Java UI.static IWorkingCopy[]
Deprecated.UseJavaCore.getWorkingCopies(org.eclipse.jdt.core.WorkingCopyOwner)
instead withnull
as argument for owner.static IWorkingCopy[]
Deprecated.UseJavaCore.getWorkingCopies(org.eclipse.jdt.core.WorkingCopyOwner)
instead and filter the list withIJavaProject.isOnClasspath(IJavaElement)
.static IWorkingCopyManager
Returns the working copy manager for the Java UI plug-in.static org.eclipse.ui.IEditorPart
openInEditor
(IJavaElement element) Opens an editor on the given Java element in the active page.static org.eclipse.ui.IEditorPart
openInEditor
(IJavaElement element, boolean activate, boolean reveal) Opens an editor on the given Java element in the active page.static void
revealInEditor
(org.eclipse.ui.IEditorPart part, IJavaElement element) Reveals the given java element in the given editor.static void
revealInEditor
(org.eclipse.ui.IEditorPart part, ISourceReference element) Deprecated.userevealInEditor(IEditorPart, IJavaElement)
insteadstatic void
setLibraryJavadocLocation
(org.eclipse.core.runtime.IPath archivePath, URL url) Deprecated.Javadoc is now attached to the classpath entry.static void
setLibraryJavadocLocations
(org.eclipse.core.runtime.IPath[] archivePaths, URL[] urls) Deprecated.Javadoc is now attached to the classpath entry.static void
setProjectJavadocLocation
(IJavaProject project, URL url) Sets the Javadoc location for a Java project.
-
Field Details
-
ID_PLUGIN
The id of the Java plug-in (value"org.eclipse.jdt.ui"
).- See Also:
-
ID_PERSPECTIVE
The id of the Java perspective (value"org.eclipse.jdt.ui.JavaPerspective"
).- See Also:
-
ID_HIERARCHYPERSPECTIVE
The id of the Java hierarchy perspective (value"org.eclipse.jdt.ui.JavaHierarchyPerspective"
).- See Also:
-
ID_ACTION_SET
The id of the Java action set (value"org.eclipse.jdt.ui.JavaActionSet"
).- See Also:
-
ID_ELEMENT_CREATION_ACTION_SET
The id of the Java Element Creation action set (value"org.eclipse.jdt.ui.JavaElementCreationActionSet"
).- Since:
- 2.0
- See Also:
-
ID_CODING_ACTION_SET
The id of the Java Coding action set (value"org.eclipse.jdt.ui.CodingActionSet"
).- Since:
- 2.0
- See Also:
-
ID_OPEN_ACTION_SET
The id of the Java action set for open actions (value"org.eclipse.jdt.ui.A_OpenActionSet"
).- Since:
- 2.0
- See Also:
-
ID_SEARCH_ACTION_SET
The id of the Java Search action set (valueorg.eclipse.jdt.ui.SearchActionSet"
).- Since:
- 2.0
- See Also:
-
ID_CU_EDITOR
The editor part id of the editor that presents Java compilation units (value"org.eclipse.jdt.ui.CompilationUnitEditor"
).- See Also:
-
ID_CF_EDITOR
The editor part id of the editor that presents Java binary class files (value"org.eclipse.jdt.ui.ClassFileEditor"
).- See Also:
-
ID_SNIPPET_EDITOR
The editor part id of the code snippet editor (value"org.eclipse.jdt.ui.SnippetEditor"
).- See Also:
-
ID_MODULE_INFO_EDITOR
The editor part id of the module-info.java editor (value"org.eclipse.jdt.ui.ModuleInfoEditor"
).- Since:
- 3.14
- See Also:
-
ID_MODULE_INFO_CF_EDITOR
The editor part id of the module-info.class editor (value"org.eclipse.jdt.ui.ModuleInfoClassFileEditor"
).- Since:
- 3.14
- See Also:
-
ID_MODULE_INFO_CF_EDITOR_NO_SOURCE
The editor part id of the module-info.class editor with no source (value"org.eclipse.jdt.ui.ModuleInfoClassFileEditorNoSource"
).- Since:
- 3.14
- See Also:
-
ID_PACKAGES
The view part id of the Packages view (value"org.eclipse.jdt.ui.PackageExplorer"
).When this id is used to access a view part with
IWorkbenchPage.findView
orshowView
, the returnedIViewPart
can be safely cast to anIPackagesViewPart
.- See Also:
-
IPackagesViewPart
IWorkbenchPage.findView(java.lang.String)
IWorkbenchPage.showView(java.lang.String)
- Constant Field Values
-
ID_TYPE_HIERARCHY
The view part id of the type hierarchy part (value"org.eclipse.jdt.ui.TypeHierarchy"
).When this id is used to access a view part with
IWorkbenchPage.findView
orshowView
, the returnedIViewPart
can be safely cast to anITypeHierarchyViewPart
.- See Also:
-
ITypeHierarchyViewPart
IWorkbenchPage.findView(java.lang.String)
IWorkbenchPage.showView(java.lang.String)
- Constant Field Values
-
ID_SOURCE_VIEW
The view part id of the source (declaration) view (value"org.eclipse.jdt.ui.SourceView"
).- Since:
- 3.0
- See Also:
-
IWorkbenchPage.findView(java.lang.String)
IWorkbenchPage.showView(java.lang.String)
- Constant Field Values
-
ID_JAVADOC_VIEW
The view part id of the Javadoc view (value"org.eclipse.jdt.ui.JavadocView"
).- Since:
- 3.0
- See Also:
-
IWorkbenchPage.findView(java.lang.String)
IWorkbenchPage.showView(java.lang.String)
- Constant Field Values
-
ID_BROWSING_PERSPECTIVE
The id of the Java Browsing Perspective (value"org.eclipse.jdt.ui.JavaBrowsingPerspective"
).- Since:
- 2.0
- See Also:
-
ID_PROJECTS_VIEW
The view part id of the Java Browsing Projects view (value"org.eclipse.jdt.ui.ProjectsView"
).- Since:
- 2.0
- See Also:
-
ID_PACKAGES_VIEW
The view part id of the Java Browsing Packages view (value"org.eclipse.jdt.ui.PackagesView"
).- Since:
- 2.0
- See Also:
-
ID_TYPES_VIEW
The view part id of the Java Browsing Types view (value"org.eclipse.jdt.ui.TypesView"
).- Since:
- 2.0
- See Also:
-
ID_MEMBERS_VIEW
The view part id of the Java Browsing Members view (value"org.eclipse.jdt.ui.MembersView"
).- Since:
- 2.0
- See Also:
-
ID_USER_LIBRARY_PREFERENCE_PAGE
The preference page id of the user library preference page (value"org.eclipse.jdt.ui.preferences.UserLibraryPreferencePage"
).- Since:
- 3.4
- See Also:
-
ID_CLASSPATH_VARIABLES_PREFERENCE_PAGE
The preference page id of the class path variables preference page (value"org.eclipse.jdt.ui.preferences.ClasspathVariablesPreferencePage"
).- Since:
- 3.4
- See Also:
-
ID_COMPILER_COMPLIANCE_PROPERTY_PAGE
- Since:
- 3.15
- See Also:
-
ID_JAVA_BUILD_PREFERENCE_PROPERTY_PAGE
- Since:
- 3.15
- See Also:
-
ATTR_CMDLINE
Deprecated.As of 1.0The class org.eclipse.debug.core.model.IProcess allows attaching String properties to processes. The Java UI contributes a property page for IProcess that will show the contents of the property with this key. The intent of this property is to show the command line a process was launched with.- See Also:
-
-
Method Details
-
createPackageDialog
public static org.eclipse.ui.dialogs.SelectionDialog createPackageDialog(org.eclipse.swt.widgets.Shell parent, IJavaProject project, int style, String filter) throws JavaModelException Creates a selection dialog that lists all packages of the given Java project. The caller is responsible for opening the dialog withWindow.open
, and subsequently extracting the selected package (of typeIPackageFragment
) viaSelectionDialog.getResult
.- Parameters:
parent
- the parent shell of the dialog to be createdproject
- the Java projectstyle
- flags defining the style of the dialog; the valid flags are:IJavaElementSearchConstants.CONSIDER_BINARIES
, indicating that packages from binary package fragment roots should be included in addition to those from source package fragment roots;IJavaElementSearchConstants.CONSIDER_REQUIRED_PROJECTS
, indicating that packages from required projects should be included as well.filter
- the initial pattern to filter the set of packages. For example "com" shows all packages starting with "com". The meta character '?' representing any character and '*' representing any string are supported. Clients can pass an empty string if no filtering is required.- Returns:
- a new selection dialog
- Throws:
JavaModelException
- if the selection dialog could not be opened- Since:
- 2.0
-
createPackageDialog
public static org.eclipse.ui.dialogs.SelectionDialog createPackageDialog(org.eclipse.swt.widgets.Shell parent, org.eclipse.jface.operation.IRunnableContext context, IJavaSearchScope scope, boolean multipleSelection, boolean removeDuplicates, String filter) Creates a selection dialog that lists all packages of the given Java search scope. The caller is responsible for opening the dialog withWindow.open
, and subsequently extracting the selected package (of typeIPackageFragment
) viaSelectionDialog.getResult
.- Parameters:
parent
- the parent shell of the dialog to be createdcontext
- the runnable context to run the search inscope
- the scope defining the available packages.multipleSelection
- true if multiple selection is allowedremoveDuplicates
- true if only one package is shown per package namefilter
- the initial pattern to filter the set of packages. For example "com" shows all packages starting with "com". The meta character '?' representing any character and '*' representing any string are supported. Clients can pass an empty string if no filtering is required.- Returns:
- a new selection dialog
- Since:
- 3.2
-
createPackageDialog
public static org.eclipse.ui.dialogs.SelectionDialog createPackageDialog(org.eclipse.swt.widgets.Shell parent, org.eclipse.jface.operation.IRunnableContext context, IJavaSearchScope scope, boolean multipleSelection, int flags, String filter) Creates a selection dialog that lists all packages of the given Java search scope. The caller is responsible for opening the dialog withWindow.open
, and subsequently extracting the selected package (of typeIPackageFragment
) viaSelectionDialog.getResult
.- Parameters:
parent
- the parent shell of the dialog to be createdcontext
- the runnable context to run the search inscope
- the scope defining the available packages.multipleSelection
- true if multiple selection is allowedflags
- a combination ofPackageSelectionDialog.F_REMOVE_DUPLICATES
,PackageSelectionDialog.F_SHOW_PARENTS
,PackageSelectionDialog.F_HIDE_DEFAULT_PACKAGE
andPackageSelectionDialog.F_HIDE_EMPTY_INNER
filter
- the initial pattern to filter the set of packages. For example "com" shows all packages starting with "com". The meta character '?' representing any character and '*' representing any string are supported. Clients can pass an empty string if no filtering is required.- Returns:
- a new selection dialog
- Since:
- 3.26
-
createPackageDialog
public static org.eclipse.ui.dialogs.SelectionDialog createPackageDialog(org.eclipse.swt.widgets.Shell shell, boolean multipleSelection, int flags, String filter) Creates a selection dialog that lists all packages of all the Java projects.- Parameters:
shell
- the parent shell of the dialog to be createdmultipleSelection
- true if multiple selection is allowedflags
- a combination ofPackageSelectionDialog.F_REMOVE_DUPLICATES
,PackageSelectionDialog.F_SHOW_PARENTS
,PackageSelectionDialog.F_HIDE_DEFAULT_PACKAGE
andPackageSelectionDialog.F_HIDE_EMPTY_INNER
filter
- the initial pattern to filter the set of packages. For example "com" shows all packages starting with "com". The meta character '?' representing any character and '*' representing any string are supported. Clients can pass an empty string if no filtering is required.- Returns:
- a new selection dialog
- Since:
- 3.26
-
createPackageDialog
public static org.eclipse.ui.dialogs.SelectionDialog createPackageDialog(org.eclipse.swt.widgets.Shell parent, IJavaProject project, int style) throws JavaModelException Creates a selection dialog that lists all packages of the given Java project. The caller is responsible for opening the dialog withWindow.open
, and subsequently extracting the selected package (of typeIPackageFragment
) viaSelectionDialog.getResult
.- Parameters:
parent
- the parent shell of the dialog to be createdproject
- the Java projectstyle
- flags defining the style of the dialog; the valid flags are:IJavaElementSearchConstants.CONSIDER_BINARIES
, indicating that packages from binary package fragment roots should be included in addition to those from source package fragment roots;IJavaElementSearchConstants.CONSIDER_REQUIRED_PROJECTS
, indicating that packages from required projects should be included as well.- Returns:
- a new selection dialog
- Throws:
JavaModelException
- if the selection dialog could not be opened
-
createPackageDialog
public static org.eclipse.ui.dialogs.SelectionDialog createPackageDialog(org.eclipse.swt.widgets.Shell parent, IPackageFragmentRoot root, String filter) throws JavaModelException Creates a selection dialog that lists all packages under the given package fragment root. The caller is responsible for opening the dialog withWindow.open
, and subsequently extracting the selected package (of typeIPackageFragment
) viaSelectionDialog.getResult
.- Parameters:
parent
- the parent shell of the dialog to be createdroot
- the package fragment rootfilter
- the initial pattern to filter the set of packages. For example "com" shows all packages starting with "com". The meta character '?' representing any character and '*' representing any string are supported. Clients can pass an empty string if no filtering is required.- Returns:
- a new selection dialog
- Throws:
JavaModelException
- if the selection dialog could not be opened- Since:
- 2.0
-
createPackageDialog
public static org.eclipse.ui.dialogs.SelectionDialog createPackageDialog(org.eclipse.swt.widgets.Shell parent, IPackageFragmentRoot root) throws JavaModelException Creates a selection dialog that lists all packages under the given package fragment root. The caller is responsible for opening the dialog withWindow.open
, and subsequently extracting the selected package (of typeIPackageFragment
) viaSelectionDialog.getResult
.- Parameters:
parent
- the parent shell of the dialog to be createdroot
- the package fragment root- Returns:
- a new selection dialog
- Throws:
JavaModelException
- if the selection dialog could not be opened
-
createTypeDialog
public static org.eclipse.ui.dialogs.SelectionDialog createTypeDialog(org.eclipse.swt.widgets.Shell parent, org.eclipse.jface.operation.IRunnableContext context, org.eclipse.core.resources.IProject project, int style, boolean multipleSelection) throws JavaModelException Creates a selection dialog that lists all types in the given project. The caller is responsible for opening the dialog withWindow.open
, and subsequently extracting the selected type(s) (of typeIType
) viaSelectionDialog.getResult
.- Parameters:
parent
- the parent shell of the dialog to be createdcontext
- the runnable context used to show progress when the dialog is being populatedproject
- the Java projectstyle
- flags defining the style of the dialog; the only valid values areIJavaElementSearchConstants.CONSIDER_CLASSES
,IJavaElementSearchConstants.CONSIDER_INTERFACES
,IJavaElementSearchConstants.CONSIDER_ANNOTATION_TYPES
,IJavaElementSearchConstants.CONSIDER_ENUMS
,IJavaElementSearchConstants.CONSIDER_ALL_TYPES
,IJavaElementSearchConstants.CONSIDER_CLASSES_AND_INTERFACES
,IJavaElementSearchConstants.CONSIDER_CLASSES_AND_ENUMS
, andIJavaElementSearchConstants.CONSIDER_INTERFACES_AND_ANNOTATIONS
. Please note that the bitwise OR combination of the elementary constants is not supported.multipleSelection
-true
if multiple selection is allowed- Returns:
- a new selection dialog
- Throws:
JavaModelException
- if the selection dialog could not be opened
-
createTypeDialog
public static org.eclipse.ui.dialogs.SelectionDialog createTypeDialog(org.eclipse.swt.widgets.Shell parent, org.eclipse.jface.operation.IRunnableContext context, IJavaSearchScope scope, int style, boolean multipleSelection) throws JavaModelException Creates a selection dialog that lists all types in the given scope. The caller is responsible for opening the dialog withWindow.open
, and subsequently extracting the selected type(s) (of typeIType
) viaSelectionDialog.getResult
.- Parameters:
parent
- the parent shell of the dialog to be createdcontext
- the runnable context used to show progress when the dialog is being populatedscope
- the scope that limits which types are includedstyle
- flags defining the style of the dialog; the only valid values areIJavaElementSearchConstants.CONSIDER_CLASSES
,IJavaElementSearchConstants.CONSIDER_INTERFACES
,IJavaElementSearchConstants.CONSIDER_ANNOTATION_TYPES
,IJavaElementSearchConstants.CONSIDER_ENUMS
,IJavaElementSearchConstants.CONSIDER_ALL_TYPES
,IJavaElementSearchConstants.CONSIDER_CLASSES_AND_INTERFACES
,IJavaElementSearchConstants.CONSIDER_CLASSES_AND_ENUMS
, andIJavaElementSearchConstants.CONSIDER_INTERFACES_AND_ANNOTATIONS
. Please note that the bitwise OR combination of the elementary constants is not supported.multipleSelection
-true
if multiple selection is allowed- Returns:
- a new selection dialog
- Throws:
JavaModelException
- if the selection dialog could not be opened
-
createTypeDialog
public static org.eclipse.ui.dialogs.SelectionDialog createTypeDialog(org.eclipse.swt.widgets.Shell parent, org.eclipse.jface.operation.IRunnableContext context, IJavaSearchScope scope, int style, boolean multipleSelection, String filter) throws JavaModelException Creates a selection dialog that lists all types in the given scope. The caller is responsible for opening the dialog withWindow.open
, and subsequently extracting the selected type(s) (of typeIType
) viaSelectionDialog.getResult
.- Parameters:
parent
- the parent shell of the dialog to be createdcontext
- the runnable context used to show progress when the dialog is being populatedscope
- the scope that limits which types are includedstyle
- flags defining the style of the dialog; the only valid values areIJavaElementSearchConstants.CONSIDER_CLASSES
,IJavaElementSearchConstants.CONSIDER_INTERFACES
,IJavaElementSearchConstants.CONSIDER_ANNOTATION_TYPES
,IJavaElementSearchConstants.CONSIDER_ENUMS
,IJavaElementSearchConstants.CONSIDER_ALL_TYPES
,IJavaElementSearchConstants.CONSIDER_CLASSES_AND_INTERFACES
,IJavaElementSearchConstants.CONSIDER_CLASSES_AND_ENUMS
, andIJavaElementSearchConstants.CONSIDER_INTERFACES_AND_ANNOTATIONS
. Please note that the bitwise OR combination of the elementary constants is not supported.multipleSelection
-true
if multiple selection is allowedfilter
- 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.- Returns:
- a new selection dialog
- Throws:
JavaModelException
- if the selection dialog could not be opened- Since:
- 2.0
-
createTypeDialog
public static org.eclipse.ui.dialogs.SelectionDialog createTypeDialog(org.eclipse.swt.widgets.Shell parent, org.eclipse.jface.operation.IRunnableContext context, IJavaSearchScope scope, int style, boolean multipleSelection, String filter, TypeSelectionExtension extension) throws JavaModelException Creates a selection dialog that lists all types in the given scope. The caller is responsible for opening the dialog withWindow.open
, and subsequently extracting the selected type(s) (of typeIType
) viaSelectionDialog.getResult
.- Parameters:
parent
- the parent shell of the dialog to be createdcontext
- the runnable context used to show progress when the dialog is being populatedscope
- the scope that limits which types are includedstyle
- flags defining the style of the dialog; the only valid values areIJavaElementSearchConstants.CONSIDER_CLASSES
,IJavaElementSearchConstants.CONSIDER_INTERFACES
,IJavaElementSearchConstants.CONSIDER_ANNOTATION_TYPES
,IJavaElementSearchConstants.CONSIDER_ENUMS
,IJavaElementSearchConstants.CONSIDER_ALL_TYPES
,IJavaElementSearchConstants.CONSIDER_CLASSES_AND_INTERFACES
,IJavaElementSearchConstants.CONSIDER_CLASSES_AND_ENUMS
, andIJavaElementSearchConstants.CONSIDER_INTERFACES_AND_ANNOTATIONS
. Please note that the bitwise OR combination of the elementary constants is not supported.multipleSelection
-true
if multiple selection is allowedfilter
- 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.extension
- a user interface extension to the type selection dialog ornull
if no extension is desired- Returns:
- a new selection dialog
- Throws:
JavaModelException
- if the selection dialog could not be opened- Since:
- 3.2
-
createMainTypeDialog
public static org.eclipse.ui.dialogs.SelectionDialog createMainTypeDialog(org.eclipse.swt.widgets.Shell parent, org.eclipse.jface.operation.IRunnableContext context, IJavaSearchScope scope, int style, boolean multipleSelection, String filter) Creates a selection dialog that lists all types in the given scope containing a standardmain
method. The caller is responsible for opening the dialog withWindow.open
, and subsequently extracting the selected type(s) (of typeIType
) viaSelectionDialog.getResult
.- Parameters:
parent
- the parent shell of the dialog to be createdcontext
- the runnable context used to show progress when the dialog is being populatedscope
- the scope that limits which types are includedstyle
- flags defining the style of the dialog; the only valid values areIJavaElementSearchConstants.CONSIDER_BINARIES
,CONSIDER_EXTERNAL_JARS
, or their bitwise OR, or0
multipleSelection
-true
if multiple selection is allowedfilter
- the initial pattern to filter the set of types containing a main method. For example "App" shows all types starting with "app". The meta character '?' representing any character and '*' representing any string are supported. Clients can pass an empty string if no filtering is required.- Returns:
- a new selection dialog
- Since:
- 2.0
-
createMainTypeDialog
public static org.eclipse.ui.dialogs.SelectionDialog createMainTypeDialog(org.eclipse.swt.widgets.Shell parent, org.eclipse.jface.operation.IRunnableContext context, IJavaSearchScope scope, int style, boolean multipleSelection) Creates a selection dialog that lists all types in the given scope containing a standardmain
method. The caller is responsible for opening the dialog withWindow.open
, and subsequently extracting the selected type(s) (of typeIType
) viaSelectionDialog.getResult
.- Parameters:
parent
- the parent shell of the dialog to be createdcontext
- the runnable context used to show progress when the dialog is being populatedscope
- the scope that limits which types are includedstyle
- flags defining the style of the dialog; the only valid values areIJavaElementSearchConstants.CONSIDER_BINARIES
,CONSIDER_EXTERNAL_JARS
, or their bitwise OR, or0
multipleSelection
-true
if multiple selection is allowed- Returns:
- a new selection dialog
-
openInEditor
public static org.eclipse.ui.IEditorPart openInEditor(IJavaElement element) throws JavaModelException, org.eclipse.ui.PartInitException Opens an editor on the given Java element in the active page. Valid elements are all Java elements that areISourceReference
. For elements inside a compilation unit or class file, the parent is opened in the editor is opened and the element revealed. If there already is an open Java editor for the given element, it is returned.- Parameters:
element
- the input element; either a compilation unit (ICompilationUnit
) or a class file (IClassFile
) or source references inside.- Returns:
- returns the editor part of the opened editor or
null
if the element is not aISourceReference
or the file was opened in an external editor. - Throws:
org.eclipse.ui.PartInitException
- if the editor could not be initialized or no workbench page is activeJavaModelException
- if this element does not exist or if an exception occurs while accessing its underlying resource
-
openInEditor
public static org.eclipse.ui.IEditorPart openInEditor(IJavaElement element, boolean activate, boolean reveal) throws JavaModelException, org.eclipse.ui.PartInitException Opens an editor on the given Java element in the active page. Valid elements are all Java elements that areISourceReference
. For elements inside a compilation unit or class file, the parent is opened in the editor is opened. If there already is an open Java editor for the given element, it is returned.- Parameters:
element
- the input element; either a compilation unit (ICompilationUnit
) or a class file (IClassFile
) or source references inside.activate
- if set, the editor will be activated.reveal
- if set, the element will be revealed.- Returns:
- returns the editor part of the opened editor or
null
if the element is not aISourceReference
or the file was opened in an external editor. - Throws:
org.eclipse.ui.PartInitException
- if the editor could not be initialized or no workbench page is activeJavaModelException
- if this element does not exist or if an exception occurs while accessing its underlying resource- Since:
- 3.3
-
revealInEditor
@Deprecated public static void revealInEditor(org.eclipse.ui.IEditorPart part, ISourceReference element) Deprecated.userevealInEditor(IEditorPart, IJavaElement)
insteadReveals the source range of the given source reference element in the given editor. No checking is done if the editor displays a compilation unit or class file that contains the given source reference. The editor simply reveals the source range denoted by the given source reference.- Parameters:
part
- the editor displaying the compilation unit or class fileelement
- the source reference element defining the source range to be revealed
-
revealInEditor
Reveals the given java element in the given editor. If the element is not an instance ofISourceReference
this method result in a NOP. If it is a source reference no checking is done if the editor displays a compilation unit or class file that contains the source reference element. The editor simply reveals the source range denoted by the given element.- Parameters:
part
- the editor displaying a compilation unit or class fileelement
- the element to be revealed- Since:
- 2.0
-
getWorkingCopyManager
Returns the working copy manager for the Java UI plug-in.- Returns:
- the working copy manager for the Java UI plug-in
-
getEditorInputJavaElement
Returns the Java element wrapped by the given editor input.- Parameters:
editorInput
- the editor input- Returns:
- the Java element wrapped by
editorInput
ornull
if none - Since:
- 3.2
-
getEditorInputTypeRoot
Returns theITypeRoot
wrapped by the given editor input.- Parameters:
editorInput
- the editor input- Returns:
- the
ITypeRoot
wrapped byeditorInput
ornull
if the editor input does not stand for a ITypeRoot - Since:
- 3.4
-
getBufferFactory
Deprecated.IBufferFactory
has been replaced byWorkingCopyOwner
. The Java UI plug-in uses the primary working copy owner that can be accessed withnull
in API's that require an ownerReturns the buffer factory for the Java UI plug-in.- Returns:
- the buffer factory for the Java UI plug-in
- Since:
- 2.0
- See Also:
-
getDocumentProvider
public static org.eclipse.ui.texteditor.IDocumentProvider getDocumentProvider()Returns the DocumentProvider used for Java compilation units.- Returns:
- the DocumentProvider for Java compilation units.
- Since:
- 2.0
- See Also:
-
IDocumentProvider
-
setLibraryJavadocLocation
@Deprecated public static void setLibraryJavadocLocation(org.eclipse.core.runtime.IPath archivePath, URL url) Deprecated.Javadoc is now attached to the classpath entry. Evaluate the libraries classpath entry and reconfigure the Javadoc location there.Sets the Javadoc location for an archive with the given path.- Parameters:
archivePath
- the path of the library; this can be an workspace path or an external path in case of an external library.url
- the Javadoc location to set. This location should contain index.html and a file 'package-list'.null
clears the current documentation location.- Since:
- 2.0
-
setLibraryJavadocLocations
@Deprecated public static void setLibraryJavadocLocations(org.eclipse.core.runtime.IPath[] archivePaths, URL[] urls) Deprecated.Javadoc is now attached to the classpath entry. Evaluate the libraries classpath entry and reconfigure the Javadoc location there.Sets the Javadoc locations for archives with the given paths.- Parameters:
archivePaths
- the paths of the libraries. can be workspace paths or external paths in case of an external library.urls
- the Javadoc locations to set. Each location corresponds to the archive path of the same index. A location should contain index.html and a file 'package-list'.null
is a valid location entry and clears the current documentation location. The length of the location array must be equals to the number of archive paths passed.- Since:
- 3.0
-
getLibraryJavadocLocation
Deprecated.Javadoc is now attached to the classpath entry. UsegetJavadocBaseLocation(IJavaElement)
with the archive'sIPackageFragmentRoot
or usegetLibraryJavadocLocation(IClasspathEntry)
with the archive'sIClasspathEntry
.Returns the Javadoc location for an archive ornull
if no location is available.- Parameters:
archivePath
- the path of the library. This can be an workspace path or an external path in case of an external library.- Returns:
- the Javadoc location for an archive or
null
. - Since:
- 2.0
-
getLibraryJavadocLocation
Returns the Javadoc location for library's classpath entry ornull
if no location is available. Note that only classpath entries of kindIClasspathEntry.CPE_LIBRARY
andIClasspathEntry.CPE_VARIABLE
support Javadoc locations.- Parameters:
entry
- the classpath entry to get the Javadoc location for- Returns:
- the Javadoc location or
null
if no Javadoc location is available - Throws:
IllegalArgumentException
- Thrown when the entry isnull
or not of kindIClasspathEntry.CPE_LIBRARY
orIClasspathEntry.CPE_VARIABLE
.- Since:
- 3.1
-
setProjectJavadocLocation
Sets the Javadoc location for a Java project. This location is used for all types located in the project's source folders.- Parameters:
project
- the projecturl
- the Javadoc location to set. This location should contain index.html and a file 'package-list'.null
clears the current documentation location.- Since:
- 2.1
-
getProjectJavadocLocation
Returns the Javadoc location for a Java project ornull
if no location is available. This location is used for all types located in the project's source folders.- Parameters:
project
- the project- Returns:
- the Javadoc location for a Java project or
null
- Since:
- 2.1
-
getJavadocBaseLocation
Returns the Javadoc base URL for an element. The base location contains the index file. This location doesn't have to exist. Returnsnull
if no javadoc location has been attached to the element's library or project. Example of a returned URL is http://www.junit.org/junit/javadoc.- Parameters:
element
- the element for which the documentation URL is requested.- Returns:
- the base location
- Throws:
JavaModelException
- thrown when the element can not be accessed- Since:
- 2.0
-
getJavadocLocation
public static URL getJavadocLocation(IJavaElement element, boolean includeAnchor) throws JavaModelException Returns the Javadoc URL for an element. Example of a returned URL is http://www.junit.org/junit/javadoc/junit/extensions/TestSetup.html. This returned location doesn't have to exist. Returnsnull
if no javadoc location has been attached to the element's library or project.- Parameters:
element
- the element for which the documentation URL is requested.includeAnchor
- If set, the URL contains an anchor for member references: http://www.junit.org/junit/javadoc/junit/extensions/TestSetup.html#run(junit.framework.TestResult). Note that this involves type resolving and is a more expensive call than without anchor.- Returns:
- the Javadoc URL for the element
- Throws:
JavaModelException
- thrown when the element can not be accessed- Since:
- 2.0
-
getJavaElementClipboardTransfer
public static org.eclipse.swt.dnd.Transfer getJavaElementClipboardTransfer()Returns the transfer instance used to copy/paste Java elements to and from the clipboard. Objects managed by this transfer instance are of typeIJavaElement[]
. So to access data from the clipboard clients should use the following code snippet:IJavaElement[] elements= (IJavaElement[])clipboard.getContents(JavaUI.getJavaElementClipboardTransfer());
To put elements into the clipboard use the following snippet:IJavaElement[] javaElements= ...; clipboard.setContents( new Object[] { javaElements }, new Transfer[] { JavaUI.getJavaElementClipboardTransfer() } );
- Returns:
- returns the transfer object used to copy/paste Java elements to and from the clipboard
- Since:
- 3.0
-
getColorManager
Returns the color manager the Java UI plug-in which is used to manage any Java-specific colors needed for such things like syntax highlighting.- Returns:
- the color manager to be used for Java text viewers
- Since:
- 3.2