Overview

 
Package  Use  Tree  Deprecated  Index  Help 
Eclipse Platform
Release 3.0
 PREV CLASS   NEXT CLASS FRAMES    NO FRAMES  
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD


 

org.eclipse.ui.ide
Class IDE

java.lang.Object
  extended byorg.eclipse.ui.ide.IDE


public final class IDE
extends Object

Collection of IDE-specific APIs factored out of existing workbench. This class cannot be instantiated; all functionality is provided by static methods and fields.

Since:
3.0


Nested Class Summary
static interface IDE.Preferences
          Preferences defined by the IDE workbench.
static interface IDE.SharedImages
          Standard shared images defined by the IDE.
 
Field Summary
static String EDITOR_ID_ATTR
          An optional attribute within a workspace marker (IMarker) which identifies the preferred editor type to be opened.
static QualifiedName EDITOR_KEY
          The persistent property key used on IFile resources to contain the preferred editor ID to use.
static String RESOURCE_PERSPECTIVE_ID
          The resource based perspective identifier.
 
Method Summary
static List computeSelectedResources(IStructuredSelection originalSelection)
          Extracts and returns the IResources in the given selection or the resource objects they adapts to.
static IEditorDescriptor getDefaultEditor(IFile file)
          Returns the default editor for a given file.
static IEditorDescriptor getEditorDescriptor(IFile file)
          Returns an editor descriptor appropriate for opening the given file resource.
static IMarkerHelpRegistry getMarkerHelpRegistry()
          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 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 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, 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 boolean saveAllEditors(IResource[] resourceRoots, boolean confirm)
          Save all dirty editors in the workbench whose editor input is a child resource of one of the IResource's provided.
static void setDefaultEditor(IFile file, String editorID)
          Sets the default editor id for a given file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

 

Field Detail

 

 

EDITOR_KEY

public static final QualifiedName 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

public static final String EDITOR_ID_ATTR

An optional attribute within a workspace marker (IMarker) which identifies the preferred editor type to be opened.

See Also:
Constant Field Values


 

 

RESOURCE_PERSPECTIVE_ID

public static final String RESOURCE_PERSPECTIVE_ID

The resource based perspective identifier.

See Also:
Constant Field Values
Method Detail

 

 

getMarkerHelpRegistry

public static IMarkerHelpRegistry getMarkerHelpRegistry()

Returns the marker help registry for the workbench.

Returns:
the marker help registry


 

 

gotoMarker

public 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. This is done on a best effort basis. If the editor does not provide an IGotoMarker interface (either directly or via IAdaptable.getAdapter), this has no effect.

Parameters:
editor - the editor
marker - 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 opened
input - the editor input
editorId - 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:
IWorkbenchPage.openEditor(IEditorInput, String)


 

 

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 opened
input - the editor input
editorId - the id of the editor extension to use
activate - if true 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:
IWorkbenchPage.openEditor(IEditorInput, String, boolean)


 

 

openEditor

public static IEditorPart openEditor(IWorkbenchPage page,
                                     IFile input,
                                     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 opened
input - the editor input
activate - if true 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:
IWorkbenchPage.openEditor(org.eclipse.ui.IEditorInput, String, boolean)


 

 

openEditor

public static IEditorPart openEditor(IWorkbenchPage page,
                                     IFile input)
                              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 opened
input - the editor input
Returns:
an open editor or null if an external editor was opened
Throws:
PartInitException - if the editor could not be initialized
See Also:
IWorkbenchPage.openEditor(IEditorInput, String)


 

 

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 opened
input - the editor input
editorId - 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:
IWorkbenchPage.openEditor(IEditorInput, String)


 

 

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 opened
input - the editor input
editorId - the id of the editor extension to use
activate - if true 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:
IWorkbenchPage.openEditor(IEditorInput, String, boolean)


 

 

getEditorDescriptor

public static IEditorDescriptor getEditorDescriptor(IFile file)
                                             throws PartInitException

Returns an editor descriptor appropriate for opening the given file resource.

The editor descriptor is determined using a multistep process.

  1. The file is consulted for a persistent property named IDE.EDITOR_KEY containing the preferred editor id to be used.
  2. 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).
  3. The operating system is consulted to determine if an in-place component editor is available (e.g. OLE editor on Win32 platforms).
  4. The operating system is consulted to determine if an external editor is available.

Parameters:
file - the file
Returns:
an editor descriptor, appropriate for opening the file
Throws:
PartInitException - if no editor can be found


 

 

openEditor

public static IEditorPart openEditor(IWorkbenchPage page,
                                     IMarker marker)
                              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.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 in
marker - the marker to open
Returns:
an open editor or null not possible
Throws:
PartInitException - if the editor could not be initialized
See Also:
openEditor(org.eclipse.ui.IWorkbenchPage, org.eclipse.core.resources.IMarker, boolean)


 

 

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 in
marker - the marker to open
activate - if true the editor will be activated
Returns:
an open editor or null not possible
Throws:
PartInitException - if the editor could not be initialized


 

 

saveAllEditors

public static boolean saveAllEditors(IResource[] resourceRoots,
                                     boolean confirm)

Save all dirty editors in the workbench whose editor input is a child resource of one of the IResource's provided. Opens a dialog to prompt the user if confirm is true. Return true if successful. Return false if the user has cancelled the command.

Parameters:
resourceRoots - the resource roots under which editor input should be saved, other will be left dirty
confirm - prompt the user if true
Returns:
boolean false if the operation was cancelled.
Since:
3.0


 

 

setDefaultEditor

public static void setDefaultEditor(IFile file,
                                    String editorID)

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 to getDefaultEditor(IFile).

Parameters:
file - the file
editorID - the editor id


 

 

getDefaultEditor

public static IEditorDescriptor getDefaultEditor(IFile file)

Returns the default editor for a given file.

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


 

 

computeSelectedResources

public static List computeSelectedResources(IStructuredSelection originalSelection)

Extracts and returns the IResources 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


 

Overview

 
Package  Use  Tree  Deprecated  Index  Help 
Eclipse Platform
Release 3.0
 PREV CLASS   NEXT CLASS FRAMES    NO FRAMES  
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD


Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2004. All rights reserved.