Class IDE
- Since:
- 3.0
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Preferences defined by the IDE workbench.static interface
Standard shared images defined by the IDE. -
Field Summary
Modifier and TypeFieldDescriptionstatic final String
An optional attribute within a workspace marker (IMarker
) which identifies the preferred editor type to be opened.static final QualifiedName
The persistent property key used on IFile resources to contain the preferred editor ID to use.static final String
The resource based perspective identifier.static final String
A preference key to decide whichIUnassociatedEditorStrategy
to use when trying to open files without associated editors. -
Method Summary
Modifier and TypeMethodDescriptioncomputeSelectedResources
(IStructuredSelection originalSelection) Extracts and returns theIResource
s in the given selection or the resource objects they adapts to.static IContentType
getContentType
(IFile file) Return the content type for the given file.static IEditorDescriptor
getDefaultEditor
(IFile file) Returns the default editor for a given file.static IEditorDescriptor
getDefaultEditor
(IFile file, boolean determineContentType) Returns the default editor for a given file.static IEditorDescriptor
getEditorDescriptor
(String name) Deprecated.static IEditorDescriptor
getEditorDescriptor
(String name, boolean inferContentType) Deprecated.Since 3.12, usegetEditorDescriptor(String, boolean, boolean)
instead.static IEditorDescriptor
getEditorDescriptor
(String name, boolean inferContentType, boolean allowInteractive) Returns an editor descriptor appropriate for opening a file resource with the given name.static IEditorDescriptor
getEditorDescriptor
(IFile file) Deprecated.Since 3.12, usegetEditorDescriptor(IFile, boolean, boolean)
static IEditorDescriptor
getEditorDescriptor
(IFile file, boolean determineContentType) Deprecated.Since 3.12, usegetEditorDescriptor(IFile, boolean, boolean)
instead.static IEditorDescriptor
getEditorDescriptor
(IFile file, boolean determineContentType, boolean allowInteractive) Returns an editor descriptor appropriate for opening the given file resource.static IEditorDescriptor
getEditorDescriptorForFileStore
(IFileStore fileStore, boolean allowInteractive) Returns an editor descriptor appropriate for opening the given file store.static IMarkerHelpRegistry
Returns the marker help registry for the workbench.static void
gotoMarker
(IEditorPart editor, IMarker marker) Sets the cursor and selection state for the given editor to reveal the position of the given marker.static IContentType
guessContentType
(IFile file) Guess at the content type of the given file based on the filename.static IEditorPart
openEditor
(IWorkbenchPage page, URI uri, String editorId, boolean activate) Opens an editor on the given IFileStore object.static IEditorPart
openEditor
(IWorkbenchPage page, IFile input) Opens an editor on the given file resource.static IEditorPart
openEditor
(IWorkbenchPage page, IFile input, boolean activate) Opens an editor on the given file resource.static IEditorPart
openEditor
(IWorkbenchPage page, IFile input, boolean activate, boolean determineContentType) Opens an editor on the given file resource.static IEditorPart
openEditor
(IWorkbenchPage page, IFile input, String editorId) Opens an editor on the given file resource.static IEditorPart
openEditor
(IWorkbenchPage page, IFile input, String editorId, boolean activate) Opens an editor on the given file resource.static IEditorPart
openEditor
(IWorkbenchPage page, IMarker marker) Opens an editor on the file resource of the given marker.static IEditorPart
openEditor
(IWorkbenchPage page, IMarker marker, boolean activate) Opens an editor on the file resource of the given marker.static IEditorPart
openEditor
(IWorkbenchPage page, IEditorInput input, String editorId) Opens an editor on the given object.static IEditorPart
openEditor
(IWorkbenchPage page, IEditorInput input, String editorId, boolean activate) Opens an editor on the given object.static IEditorPart
openEditorOnFileStore
(IWorkbenchPage page, IFileStore fileStore) Opens an editor on the given IFileStore object.static IEditorReference[]
openEditors
(IWorkbenchPage page, IFile[] inputs) Opens editors on given file resources.static IEditorPart
openInternalEditorOnFileStore
(IWorkbenchPage page, IFileStore fileStore) Opens an internal editor on the given IFileStore object.static IEditorDescriptor
overrideDefaultEditorAssociation
(IEditorInput editorInput, IContentType contentType, IEditorDescriptor editorDescriptor) Applies theorg.eclipse.ui.ide.editorAssociationOverride
extensions to the given input.static IEditorDescriptor[]
overrideEditorAssociations
(String fileName, IContentType contentType, IEditorDescriptor[] editorDescriptors) Applies theorg.eclipse.ui.ide.editorAssociationOverride
extensions to the given input.static IEditorDescriptor[]
overrideEditorAssociations
(IEditorInput editorInput, IContentType contentType, IEditorDescriptor[] editorDescriptors) Applies theorg.eclipse.ui.ide.editorAssociationOverride
extensions to the given input.static boolean
promptToConfirm
(Shell shell, String title, String message, IResourceDelta delta, String[] ignoreModelProviderIds, boolean syncExec) Prompt the user to inform them of the possible side effects of an operation on resources.static void
Register workbench adapters programmatically.static boolean
saveAllEditors
(IResource[] resourceRoots, boolean confirm) Save all dirty editors in the workbench whose editor input is a child resource of one of theIResource
's provided.static void
setDefaultEditor
(IFile file, String editorID) Sets the default editor id for a given file.
-
Field Details
-
EDITOR_KEY
The persistent property key used on IFile resources to contain the preferred editor ID to use.Example of retrieving the persisted editor id:
IFile file = ... IEditorDescriptor editorDesc = null; try { String editorID = file.getPersistentProperty(EDITOR_KEY); if (editorID != null) { editorDesc = editorReg.findEditor(editorID); } } catch (CoreException e) { // handle problem accessing persistent property here }
Example of persisting the editor id:
IFile file = ... try { file.setPersistentProperty(EDITOR_KEY, editorDesc.getId()); } catch (CoreException e) { // handle problem setting persistent property here }
-
EDITOR_ID_ATTR
An optional attribute within a workspace marker (IMarker
) which identifies the preferred editor type to be opened.- See Also:
-
RESOURCE_PERSPECTIVE_ID
The resource based perspective identifier.- See Also:
-
UNASSOCIATED_EDITOR_STRATEGY_PREFERENCE_KEY
A preference key to decide whichIUnassociatedEditorStrategy
to use when trying to open files without associated editors.- Since:
- 3.12
- See Also:
-
-
Method Details
-
getMarkerHelpRegistry
Returns the marker help registry for the workbench.- Returns:
- the marker help registry
-
gotoMarker
Sets the cursor and selection state for the given editor to reveal the position of the given marker. This is done on a best effort basis. If the editor does not provide anIGotoMarker
interface (either directly or viaIAdaptable.getAdapter
), this has no effect.- Parameters:
editor
- the editormarker
- the marker
-
openEditor
public static IEditorPart openEditor(IWorkbenchPage page, IEditorInput input, String editorId) throws PartInitException Opens an editor on the given object.If the page already has an editor open on the target object then that editor is brought to front; otherwise, a new editor is opened.
- Parameters:
page
- the page in which the editor will be openedinput
- the editor inputeditorId
- the id of the editor extension to use- Returns:
- an open editor or
null
if an external editor was opened - Throws:
PartInitException
- if the editor could not be initialized- See Also:
-
openEditor
public static IEditorPart openEditor(IWorkbenchPage page, URI uri, String editorId, boolean activate) throws PartInitException Opens an editor on the given IFileStore object.Unlike the other
openEditor
methods, this one can be used to open files that reside outside the workspace resource set.If the page already has an editor open on the target object then that editor is brought to front; otherwise, a new editor is opened.
- Parameters:
page
- the page in which the editor will be openeduri
- the URI of the file store representing the file to openeditorId
- the id of the editor extension to useactivate
- iftrue
the editor will be activated opened- Returns:
- an open editor or
null
if an external editor was opened - Throws:
PartInitException
- if the editor could not be initialized- Since:
- 3.3
- See Also:
-
openEditor
public static IEditorPart openEditor(IWorkbenchPage page, IEditorInput input, String editorId, boolean activate) throws PartInitException Opens an editor on the given object.If the page already has an editor open on the target object then that editor is brought to front; otherwise, a new editor is opened. If
activate == true
the editor will be activated.- Parameters:
page
- the page in which the editor will be openedinput
- the editor inputeditorId
- the id of the editor extension to useactivate
- iftrue
the editor will be activated- Returns:
- an open editor or
null
if an external editor was opened - Throws:
PartInitException
- if the editor could not be initialized- See Also:
-
openEditor
public static IEditorPart openEditor(IWorkbenchPage page, IFile input, boolean activate) throws PartInitException Opens an editor on the given file resource. This method will attempt to resolve the editor based on content-type bindings as well as traditional name/extension bindings.If the page already has an editor open on the target object then that editor is brought to front; otherwise, a new editor is opened. If
activate == true
the editor will be activated.- Parameters:
page
- the page in which the editor will be openedinput
- the editor inputactivate
- iftrue
the editor will be activated- Returns:
- an open editor or
null
if an external editor was opened or if opening was canceled - Throws:
PartInitException
- if the editor could not be initialized- See Also:
-
openEditor
public static IEditorPart openEditor(IWorkbenchPage page, IFile input, boolean activate, boolean determineContentType) throws PartInitException Opens an editor on the given file resource. This method will attempt to resolve the editor based on content-type bindings as well as traditional name/extension bindings ifdetermineContentType
istrue
.If the page already has an editor open on the target object then that editor is brought to front; otherwise, a new editor is opened. If
activate == true
the editor will be activated.- Parameters:
page
- the page in which the editor will be openedinput
- the editor inputactivate
- iftrue
the editor will be activateddetermineContentType
- attempt to resolve the content type for this file- Returns:
- an open editor or
null
if an external editor was opened or if opening was canceled - Throws:
PartInitException
- if the editor could not be initialized- Since:
- 3.1
- See Also:
-
openEditor
Opens an editor on the given file resource. This method will attempt to resolve the editor based on content-type bindings as well as traditional name/extension bindings.If the page already has an editor open on the target object then that editor is brought to front; otherwise, a new editor is opened.
- Parameters:
page
- the page in which the editor will be openedinput
- the editor input- Returns:
- an open editor or
null
if an external editor was opened or if opening was canceled - Throws:
PartInitException
- if the editor could not be initialized- See Also:
-
openEditor
public static IEditorPart openEditor(IWorkbenchPage page, IFile input, String editorId) throws PartInitException Opens an editor on the given file resource.If the page already has an editor open on the target object then that editor is brought to front; otherwise, a new editor is opened.
- Parameters:
page
- the page in which the editor will be openedinput
- the editor inputeditorId
- the id of the editor extension to use- Returns:
- an open editor or
null
if an external editor was opened - Throws:
PartInitException
- if the editor could not be initialized- See Also:
-
openEditor
public static IEditorPart openEditor(IWorkbenchPage page, IFile input, String editorId, boolean activate) throws PartInitException Opens an editor on the given file resource.If the page already has an editor open on the target object then that editor is brought to front; otherwise, a new editor is opened. If
activate == true
the editor will be activated.- Parameters:
page
- the page in which the editor will be openedinput
- the editor inputeditorId
- the id of the editor extension to useactivate
- iftrue
the editor will be activated- Returns:
- an open editor or
null
if an external editor was opened - Throws:
PartInitException
- if the editor could not be initialized- See Also:
-
getEditorDescriptor
@Deprecated public static IEditorDescriptor getEditorDescriptor(IFile file) throws PartInitException Deprecated.Since 3.12, usegetEditorDescriptor(IFile, boolean, boolean)
Returns an editor descriptor appropriate for opening the given file resource.The editor descriptor is determined using a multi-step process. This method will attempt to resolve the editor based on content-type bindings as well as traditional name/extension bindings.
- The
IResource
is consulted for a persistent property namedIDE.EDITOR_KEY
containing the preferred editor id to be used. - The workbench editor registry is consulted to determine if an editor
extension has been registered for the file type. If so, an instance of
the editor extension is opened on the file. See
IEditorRegistry.getDefaultEditor(String)
. - The operating system is consulted to determine if an in-place component editor is available (e.g. OLE editor on Win32 platforms).
- The operating system is consulted to determine if an external editor is available.
- The workbench editor registry is consulted to determine if the default text editor is available.
- Parameters:
file
- the file- Returns:
- an editor descriptor, appropriate for opening the file
- Throws:
PartInitException
- if no editor can be found
- The
-
getEditorDescriptor
@Deprecated public static IEditorDescriptor getEditorDescriptor(IFile file, boolean determineContentType) throws PartInitException Deprecated.Since 3.12, usegetEditorDescriptor(IFile, boolean, boolean)
instead.Returns an editor descriptor appropriate for opening the given file resource.The editor descriptor is determined using a multi-step process. This method will attempt to resolve the editor based on content-type bindings as well as traditional name/extension bindings if
determineContentType
istrue
.- The
IResource
is consulted for a persistent property namedIDE.EDITOR_KEY
containing the preferred editor id to be used. - The workbench editor registry is consulted to determine if an editor
extension has been registered for the file type. If so, an instance of
the editor extension is opened on the file. See
IEditorRegistry.getDefaultEditor(String)
. - The operating system is consulted to determine if an in-place component editor is available (e.g. OLE editor on Win32 platforms).
- The operating system is consulted to determine if an external editor is available.
- The workbench editor registry is consulted to determine if the default text editor is available.
- Parameters:
file
- the filedetermineContentType
- query the content type system for the content type of the file- Returns:
- an editor descriptor, appropriate for opening the file
- Throws:
PartInitException
- if no editor can be found- Since:
- 3.1
- The
-
getEditorDescriptor
public static IEditorDescriptor getEditorDescriptor(IFile file, boolean determineContentType, boolean allowInteractive) throws PartInitException, OperationCanceledException Returns an editor descriptor appropriate for opening the given file resource.The editor descriptor is determined using a multi-step process. This method will attempt to resolve the editor based on content-type bindings as well as traditional name/extension bindings if
determineContentType
istrue
.- The
IResource
is consulted for a persistent property namedIDE.EDITOR_KEY
containing the preferred editor id to be used. - The workbench editor registry is consulted to determine if an editor
extension has been registered for the file type. If so, an instance of the
editor extension is opened on the file. See
IEditorRegistry.getDefaultEditor(String)
. - The preferred
IUnassociatedEditorStrategy
is consulted. - The
SystemEditorOrTextEditorStrategy
is consulted, whose behavior is- The operating system is consulted to determine if an in-place component editor is available (e.g. OLE editor on Win32 platforms).
- The operating system is consulted to determine if an external editor is available.
- The workbench editor registry is consulted to determine if the default text editor is available.
- Parameters:
file
- the filedetermineContentType
- query the content type system for the content type of the fileallowInteractive
- whether we allow user interactions- Returns:
- an editor descriptor, appropriate for opening the file
- Throws:
PartInitException
- if no editor can be foundOperationCanceledException
- in case descriptor lookup was canceled by the user- Since:
- 3.12
- The
-
getEditorDescriptorForFileStore
public static IEditorDescriptor getEditorDescriptorForFileStore(IFileStore fileStore, boolean allowInteractive) throws PartInitException Returns an editor descriptor appropriate for opening the given file store.The editor descriptor is determined using a multi-step process. This method will attempt to resolve the editor based on content-type bindings as well as traditional name/extension bindings.
- The workbench editor registry is consulted to determine if an editor
extension has been registered for the file type. If so, an instance of the
editor extension is opened on the file. See
IEditorRegistry.getDefaultEditor(String)
. - The preferred
IUnassociatedEditorStrategy
is consulted. - The
SystemEditorOrTextEditorStrategy
is consulted, whose behavior is- The operating system is consulted to determine if an in-place component editor is available (e.g. OLE editor on Win32 platforms).
- The operating system is consulted to determine if an external editor is available.
- The workbench editor registry is consulted to determine if the default text editor is available.
- Parameters:
fileStore
- the file storeallowInteractive
- Whether user interactions are allowed- Returns:
- editor descriptor of an editor, appropriate for opening the file
- Throws:
PartInitException
- if no editor can be found- Since:
- 3.16
- The workbench editor registry is consulted to determine if an editor
extension has been registered for the file type. If so, an instance of the
editor extension is opened on the file. See
-
overrideDefaultEditorAssociation
public static IEditorDescriptor overrideDefaultEditorAssociation(IEditorInput editorInput, IContentType contentType, IEditorDescriptor editorDescriptor) Applies theorg.eclipse.ui.ide.editorAssociationOverride
extensions to the given input.Note: It is recommended to get the descriptor for the default editor by calling
getDefaultEditor(IFile, boolean)
. This method here should only be used if this is not possible for whatever reason.- Parameters:
editorInput
- the editor input for the editorcontentType
- the content type of the input ornull
if not availableeditorDescriptor
- the current association for the given input ornull
if none- Returns:
- the editor descriptor to be used for the given input or
null
if none. Can beeditorDescriptor
. - Since:
- 3.8
- See Also:
-
overrideEditorAssociations
public static IEditorDescriptor[] overrideEditorAssociations(IEditorInput editorInput, IContentType contentType, IEditorDescriptor[] editorDescriptors) Applies theorg.eclipse.ui.ide.editorAssociationOverride
extensions to the given input.- Parameters:
editorInput
- the editor input for the editorcontentType
- the content type of the input ornull
if not availableeditorDescriptors
- the current association for the given input- Returns:
- the editor descriptors to be used for the given input - can be
editorDescriptors
. The order is not relevant. - Since:
- 3.8
- See Also:
-
overrideEditorAssociations
public static IEditorDescriptor[] overrideEditorAssociations(String fileName, IContentType contentType, IEditorDescriptor[] editorDescriptors) Applies theorg.eclipse.ui.ide.editorAssociationOverride
extensions to the given input.- Parameters:
fileName
- the name of the file for which to choose the editorcontentType
- the content type of the input ornull
if not availableeditorDescriptors
- the current association for the given input- Returns:
- the editor descriptors to be used for the given input - can be
editorDescriptors
. The order is not relevant. - Since:
- 3.8
- See Also:
-
getEditorDescriptor
@Deprecated public static IEditorDescriptor getEditorDescriptor(String name) throws PartInitException Deprecated.Since 3.12, usegetEditorDescriptor(String, boolean, boolean)
instead.Returns an editor descriptor appropriate for opening a file resource with the given name.The editor descriptor is determined using a multi-step process. This method will attempt to infer content type from the file name.
- The workbench editor registry is consulted to determine if an editor
extension has been registered for the file type. If so, an instance of
the editor extension is opened on the file. See
IEditorRegistry.getDefaultEditor(String)
. - The operating system is consulted to determine if an in-place component editor is available (e.g. OLE editor on Win32 platforms).
- The operating system is consulted to determine if an external editor is available.
- The workbench editor registry is consulted to determine if the default text editor is available.
- Parameters:
name
- the file name- Returns:
- an editor descriptor, appropriate for opening the file
- Throws:
PartInitException
- if no editor can be found- Since:
- 3.1
- The workbench editor registry is consulted to determine if an editor
extension has been registered for the file type. If so, an instance of
the editor extension is opened on the file. See
-
getEditorDescriptor
@Deprecated public static IEditorDescriptor getEditorDescriptor(String name, boolean inferContentType) throws PartInitException Deprecated.Since 3.12, usegetEditorDescriptor(String, boolean, boolean)
instead.Returns an editor descriptor appropriate for opening a file resource with the given name.The editor descriptor is determined using a multi-step process. This method will attempt to infer the content type of the file if
inferContentType
istrue
.- The workbench editor registry is consulted to determine if an editor
extension has been registered for the file type. If so, an instance of
the editor extension is opened on the file. See
IEditorRegistry.getDefaultEditor(String)
. - The operating system is consulted to determine if an in-place component editor is available (e.g. OLE editor on Win32 platforms).
- The operating system is consulted to determine if an external editor is available.
- The workbench editor registry is consulted to determine if the default text editor is available.
- Parameters:
name
- the file nameinferContentType
- attempt to infer the content type from the file name if this istrue
- Returns:
- an editor descriptor, appropriate for opening the file
- Throws:
PartInitException
- if no editor can be found- Since:
- 3.1
- The workbench editor registry is consulted to determine if an editor
extension has been registered for the file type. If so, an instance of
the editor extension is opened on the file. See
-
getEditorDescriptor
public static IEditorDescriptor getEditorDescriptor(String name, boolean inferContentType, boolean allowInteractive) throws PartInitException, OperationCanceledException Returns an editor descriptor appropriate for opening a file resource with the given name.The editor descriptor is determined using a multi-step process. This method will attempt to infer the content type of the file if
inferContentType
istrue
.- The workbench editor registry is consulted to determine if an editor
extension has been registered for the file type. If so, an instance of the
editor extension is opened on the file. See
IEditorRegistry.getDefaultEditor(String)
. - The preferred
IUnassociatedEditorStrategy
is consulted. - The
SystemEditorOrTextEditorStrategy
is consulted, whose behavior is- The operating system is consulted to determine if an in-place component editor is available (e.g. OLE editor on Win32 platforms).
- The operating system is consulted to determine if an external editor is available.
- The workbench editor registry is consulted to determine if the default text editor is available.
- Parameters:
name
- the file nameinferContentType
- attempt to infer the content type from the file name if this istrue
allowInteractive
- whether we allow user interactions.- Returns:
- an editor descriptor, appropriate for opening the file
- Throws:
PartInitException
- if no editor can be foundOperationCanceledException
- in case descriptor lookup was canceled by the user- Since:
- 3.12
- The workbench editor registry is consulted to determine if an editor
extension has been registered for the file type. If so, an instance of the
editor extension is opened on the file. See
-
openEditor
Opens an editor on the file resource of the given marker.If this page already has an editor open on the marker resource file that editor is brought to front; otherwise, a new editor is opened.The cursor and selection state of the editor are then updated from information recorded in the marker.
If the marker contains an
EDITOR_ID_ATTR
attribute the attribute value will be used to determine the editor type to be opened. If not, the registered editor for the marker resource file will be used.- Parameters:
page
- the workbench page to open the editor inmarker
- the marker to open- Returns:
- an open editor or
null
not possible - Throws:
PartInitException
- if the editor could not be initialized- See Also:
-
openEditor
public static IEditorPart openEditor(IWorkbenchPage page, IMarker marker, boolean activate) throws PartInitException Opens an editor on the file resource of the given marker.If this page already has an editor open on the marker resource file that editor is brought to front; otherwise, a new editor is opened. If
activate == true
the editor will be activated. The cursor and selection state of the editor are then updated from information recorded in the marker.If the marker contains an
EDITOR_ID_ATTR
attribute the attribute value will be used to determine the editor type to be opened. If not, the registered editor for the marker resource file will be used.- Parameters:
page
- the workbench page to open the editor inmarker
- the marker to openactivate
- iftrue
the editor will be activated- Returns:
- an open editor or
null
if not possible or if opening was canceled - Throws:
PartInitException
- if the editor could not be initialized
-
openEditorOnFileStore
public static IEditorPart openEditorOnFileStore(IWorkbenchPage page, IFileStore fileStore) throws PartInitException Opens an editor on the given IFileStore object.Unlike the other
openEditor
methods, this one can be used to open files that reside outside the workspace resource set.If the page already has an editor open on the target object then that editor is brought to front; otherwise, a new editor is opened.
- Parameters:
page
- the page in which the editor will be openedfileStore
- the IFileStore representing the file to open- Returns:
- an open editor or
null
if an external editor was opened or if opening was canceled - Throws:
PartInitException
- if the editor could not be initialized- Since:
- 3.3
- See Also:
-
openInternalEditorOnFileStore
public static IEditorPart openInternalEditorOnFileStore(IWorkbenchPage page, IFileStore fileStore) throws PartInitException Opens an internal editor on the given IFileStore object.Unlike the other
openEditor
methods, this one can be used to open files that reside outside the workspace resource set.If the page already has an editor open on the target object then that editor is brought to front; otherwise, a new editor is opened.
- Parameters:
page
- the page in which the editor will be openedfileStore
- the IFileStore representing the file to open- Returns:
- an open editor or
null
if an external editor was opened - Throws:
PartInitException
- if no internal editor can be found or if the editor could not be initialized- Since:
- 3.6
- See Also:
-
saveAllEditors
Save all dirty editors in the workbench whose editor input is a child resource of one of theIResource
's provided. Opens a dialog to prompt the user ifconfirm
is true. Return true if successful. Return false if the user has canceled the command.- Parameters:
resourceRoots
- the resource roots under which editor input should be saved, other will be left dirtyconfirm
-true
to ask the user before saving unsaved changes (recommended), andfalse
to save unsaved changes without asking- Returns:
true
if the command succeeded, andfalse
if the operation was canceled by the user or an error occurred while saving- Since:
- 3.0
-
setDefaultEditor
Sets the default editor id for a given file. This value will be used to determine the default editor descriptor for the file in future calls togetDefaultEditor(IFile)
.- Parameters:
file
- the fileeditorID
- the editor id
-
getDefaultEditor
Returns the default editor for a given file. This method will attempt to resolve the editor based on content-type bindings as well as traditional name/extension bindings.A default editor id may be registered for a specific file using
setDefaultEditor
. If the given file has a registered default editor id the default editor will derived from it. If not, the default editor is determined by taking the file name for the file and obtaining the default editor for that name.- Parameters:
file
- the file- Returns:
- the descriptor of the default editor, or
null
if not found
-
getDefaultEditor
Returns the default editor for a given file. This method will attempt to resolve the editor based on content-type bindings as well as traditional name/extension bindings ifdetermineContentType
istrue
.A default editor id may be registered for a specific file using
setDefaultEditor
. If the given file has a registered default editor id the default editor will derived from it. If not, the default editor is determined by taking the file name for the file and obtaining the default editor for that name.- Parameters:
file
- the filedetermineContentType
- determine the content type for the given file- Returns:
- the descriptor of the default editor, or
null
if not found - Since:
- 3.1
-
computeSelectedResources
Extracts and returns theIResource
s in the given selection or the resource objects they adapts to.- Parameters:
originalSelection
- the original selection, possibly empty- Returns:
- list of resources (element type:
IResource
), possibly empty
-
getContentType
Return the content type for the given file.- Parameters:
file
- the file to test- Returns:
- the content type, or
null
if it cannot be determined. - Since:
- 3.1
-
guessContentType
Guess at the content type of the given file based on the filename.- Parameters:
file
- the file to test- Returns:
- the content type, or
null
if it cannot be determined. - Since:
- 3.2
-
promptToConfirm
public static boolean promptToConfirm(Shell shell, String title, String message, IResourceDelta delta, String[] ignoreModelProviderIds, boolean syncExec) Prompt the user to inform them of the possible side effects of an operation on resources. Do not prompt for side effects from ignored model providers. A model provider can be ignored if it is the client calling this API. Any message from the provided model provider id or any model providers it extends will be ignored.- Parameters:
shell
- the shell to parent the prompt dialogtitle
- the title of the dialogmessage
- the message for the dialogdelta
- a delta built using anIResourceChangeDescriptionFactory
ignoreModelProviderIds
- model providers to be ignoredsyncExec
- prompt in a sync exec (required when called from a non-UI thread)- Returns:
- whether the user chose to continue
- Since:
- 3.2
-
registerAdapters
public static void registerAdapters()Register workbench adapters programmatically. This is necessary to enable certain types of content in the explorers.Note: this method should only be called once, in your application's WorkbenchAdvisor#initialize(IWorkbenchConfigurer) method.
- Since:
- 3.5
-
openEditors
public static IEditorReference[] openEditors(IWorkbenchPage page, IFile[] inputs) throws MultiPartInitException Opens editors on given file resources.If the page already has an editor open on the target object then that editor is brought to front; otherwise, a new editor is opened. The editor created for the first input will be activated.
- Parameters:
page
- the page in which the editor will be openedinputs
- the inputs for the editors- Returns:
- references to the editors opened; the corresponding editors might not be materialized
- Throws:
MultiPartInitException
- if at least one of the editors could not be initialized- Since:
- 3.5
-
getEditorDescriptor(String, boolean, boolean)
instead.