1 org.eclips.ui package org.eclipse.ui. 2 Package org.eclipse.ui Description l Application...

Post on 19-Dec-2015

233 views 0 download

Tags:

Transcript of 1 org.eclips.ui package org.eclipse.ui. 2 Package org.eclipse.ui Description l Application...

1

org.eclips.ui package

org.eclipse.ui

2

Package org.eclipse.ui Description

Application programming interfaces for interaction with any extension of the Eclipse Platform User Interface.

3

PlatformUI class (Starting class) provides access to a single workbench. 

A workbench is the root object for the UI and has one or more workbench windows. 

Each workbench window has a collection of workbench pages, only one of which is active and visible to the end user. 

Each workbench page has a collection of workbench parts.  » A page's parts are arranged (tiled or stacked) for

presentation on the screen.  » Within a page and its parts the user can interact with

and modify a model (typically resources in a workspace).  

4

IWorkbenchIWorkbenchWindow

IEditorPart

IWorkbenchPage

IViewPart

IWorkbenchPart

PlatfromUI

getWrokbench()

1m

1

mactivePage

1

1

1

m

Containment Hierarchy of UI components

5

There are two kinds of workbench parts: views and editors. 

An editor is typically used to edit or browse a document or input object. 

A view is typically used to navigate a hierarchy of information (like the workspace), open an editor, or display properties for the active editor.

6

The platform creates a workbench when the workbench plug-in is activated. 

Since this happens at most once during the life of the running platform, there is only one workbench instance. Due to its singular nature, it is commonly referred to as the workbench.

Within a workbench the user will interact with many different resource types.  Because different tools are required for each, the workbench defines a number of extension points which allow for the integration of new tools.  There are extension points for views, editors, action sets, import wizards, export wizards, etc.  

7

8

org.eclipse.ui.PlatformUI public final class PlatformUI extends Object

» The central class for access to the Eclipse Platform User Interface.

» cannot be instantiated; all functionality is provided by static methods.

» Features provided: access to the workbench. static String PLUGIN_ID = "org.eclipse.ui"

» Identifies the workbench plugin. static IWorkbench getWorkbench()

» Returns the workbench interface.

9

IWorkbench A workbench is the root object for the Eclipse

Platform user interface. » has one or more main windows which present

to the end user information based on some underlying model, typically on resources in an underlying workspace.

» usually starts with a single open window, and automatically closes when its last window closes.

10

Method Summary  void addWindowListener( IWindowListener listener)

»  Adds a window listener.  boolean close()

» Closes this workbench and all its open windows.  IWorkbenchWindow

getActiveWorkbenchWindow()» Returns the currently active window for this workbench (if

any).  IDecoratorManager getDecoratorManager()

» Returns the decorator manager.  IEditorRegistry getEditorRegistry()

» Returns the editor registry for the workbench.  IMarkerHelpRegistry getMarkerHelpRegistry()

» Returns the marker help registry for the workbench.

11

 IPerspectiveRegistry getPerspectiveRegistry()» Returns the perspective registry for the workbench.

 PreferenceManager getPreferenceManager()» Returns the preference manager for the workbench.

 IPreferenceStore getPreferenceStore()» Returns the preference store for the workbench.

 ISharedImages getSharedImages()» Returns the shared images for the workbench.

 IWorkbenchWindow[] getWorkbenchWindows()» Returns a list of the open main windows associated

with this workbench.  IWorkingSetManager getWorkingSetManager()

» Returns the working set manager for the workbench.

12

 IWorkbenchWindow openWorkbenchWindow (IAdaptable input) » Creates and opens a new workbench window with one

page.  IWorkbenchWindow openWorkbenchWindow

(String perspID, IAdaptable input) » Creates and opens a new workbench window with one

page.  void removeWindowListener(IWindowListener l)

» Removes a window listener.  boolean restart()

» Closes then restarts this workbench.

13

 IWorkbenchPage showPerspective (String perspectiveId, IWorkbenchWindow  window)

IWorkbenchPage showPerspective( String perspectiveId, IWorkbenchWindow window, IAdaptable input)» Shows the specified perspective to the user.

14

IWorkbenchSite All Known Subinterfaces:

» IEditorSite, IPageSite, » IViewSite, IWorkbenchPartSite

All Known Implementing Classes:» MultiPageEditorSite, PageSite

The common interface between the workbench and its parts, including pages within parts.

Not intended to be implemented or extended by clients.

15

Method Summary IWorkbenchPage getPage()

» Returns the page containing this workbench site.  Shell getShell()

» Returns the shell for this workbench site.  IWorkbenchWindow getWorkbenchWindow()

» Returns the workbench window containing this workbench site.

 ISelectionProvider getSelectionProvider()» Returns the selection provider for this workbench site.

 void setSelectionProvider(ISelectionProvider provider)» Sets the selection provider for this workbench site.

16

IWorkbenchPage public interface IWorkbenchPage extends IPartService,

ISelectionService A workbench page consists of an arrangement of views

and editors intended to be presented together to the user in a single workbench window.

A page can contain 0 or more views and 0 or more editors. » These views and editors are contained wholly within

the page and are not shared with other pages. » The layout and visible action set for the page is defined

by a perspective.

17

The number of views and editors within a page is restricted to simplify part management for the user. In particular: » Only one instance of a particular view type

may exist within a workbench page. » Only one editor can exist for each editor input

(i.e., resource) within a page. This interface is not intended to be implemented

by clients.

18

Method Summary void activate(IWorkbenchPart part)

» Activates the given part.part must belongs to this page. void addPropertyChangeListener

(IPropertyChangeListener listener)» Deprecated. 

void bringToTop(IWorkbenchPart part)» Moves the given part forward in the Z order of this page so

as to make it visible, without changing which part has focus.  boolean close()

» Closes this workbench page.  boolean closeAllEditors(boolean save)

» Closes all of the editors belonging to this workbench page.

19

boolean closeEditor ( IEditorPart editor, boolean save)» Closes the given editor.

IEditorPart findEditor(IEditorInput input)» Returns the editor with the specified input.

 IViewPart findView(String viewId)» Returns the view in this page with the specified id.

 IEditorPart getActiveEditor()» Returns the active editor open in this page.

 IEditorPart[] getDirtyEditors()» Returns a list of dirty editors in this page.

 IEditorReference[] getEditorReferences()» Returns a array of references to open editors in this page.

20

 int getEditorReuseThreshold()» Deprecated.  

 IEditorPart[] getEditors()» Deprecated. use getEditorReferences() instead

 IAdaptable getInput()» Returns the input for this page.

 String getLabel()» Returns the page label.

 IPerspectiveDescriptor getPerspective()» Returns the current perspective descriptor for this page.

 IViewReference[] getViewReferences() » Returns a list of the reference to views visible on this

page.

21

IViewPart[] getViews()» Deprecated. use getViewReferences() instead.

 IWorkbenchWindow getWorkbenchWindow()» Returns the workbench window of this page.

 IWorkingSet getWorkingSet()» Deprecated. individual views should store a working

set if needed  void hideActionSet(String actionSetID)

» Hides an action set in this page.  void hideView(IViewPart view)

» Hides the given view.

22

 boolean isEditorAreaVisible()» Returns whether the page's current perspective is showing the

editor area.  IEditorPart openEditor( (IEditorInput | IFile ) input [,

String editorId [, boolean activate]])» Opens an editor on the given input object.» editorId is the extension id in plugin.xml

IEditorPart openEditor(IMarker marker [, boolean activate]) » Opens an editor on the file resource of the given marker.

 void openSystemEditor(IFile input)» Opens an operating system editor on a given file.

void removePropertyChangeListener (IPropertyChangeListener listener)» Deprecated. 

23

 void resetPerspective()» Changes the visible views, their layout, and the visible

action sets within the page to match the current perspective descriptor.

 boolean saveAllEditors(boolean confirm)» Saves the contents of all dirty editors belonging to this

workbench page.  boolean saveEditor(IEditorPart editor,

boolean confirm)» Saves the contents of the given editor if dirty.

 void savePerspective()» Saves the visible views, their layout, and the visible

action sets for this page to the current perspective descriptor.

24

void savePerspectiveAs( IPerspectiveDescriptor  perspective)» Saves the visible views, their layout, and the visible action

sets for this page to the given perspective descriptor. void setEditorAreaVisible(boolean showEditorArea)

» Show or hide the editor area for the page's active perspective.

void setEditorReuseThreshold(int openEditors)» Deprecated. 

 void setPerspective(IPerspectiveDescriptor perspective)» Changes the visible views, their layout, and the visible

action sets within the page to match the given perspective descriptor.

25

 void showActionSet(String actionSetID)» Shows an action set in this page.

 IViewPart showView(String viewId)» Shows a view in this page and give it focus.