Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.eclipse.ui.forms.editor
Class FormEditor  view FormEditor download FormEditor.java

java.lang.Object
  extended byorg.eclipse.ui.part.WorkbenchPart
      extended byorg.eclipse.ui.part.EditorPart
          extended byorg.eclipse.ui.part.MultiPageEditorPart
              extended byorg.eclipse.ui.forms.editor.FormEditor
All Implemented Interfaces:
org.eclipse.core.runtime.IAdaptable, org.eclipse.ui.IEditorPart, org.eclipse.core.runtime.IExecutableExtension, org.eclipse.ui.ISaveablePart, org.eclipse.ui.IWorkbenchPart, org.eclipse.ui.IWorkbenchPart2

public abstract class FormEditor
extends org.eclipse.ui.part.MultiPageEditorPart

This class forms a base of multi-page form editors that typically use one or more pages with forms and one page for raw source of the editor input.

Pages are added 'lazily' i.e. adding a page reserves a tab for it but does not cause the page control to be created. Page control is created when an attempt is made to select the page in question. This allows editors with several tabs and complex pages to open quickly.

Subclasses should extend this class and implement addPages method. One of the two addPage methods should be called to contribute pages to the editor. One adds complete (standalone) editors as nested tabs. These editors will be created right away and will be hooked so that key bindings, selection service etc. is compatible with the one for the standalone case. The other method adds classes that implement IFormPage interface. These pages will be created lazily and they will share the common key binding and selection service.

Since:
3.0

Nested Class Summary
private static class FormEditor.FormEditorSelectionProvider
           
 
Field Summary
private  int currentPage
           
protected  java.util.Vector pages
           
private  org.eclipse.ui.IEditorPart sourcePage
           
private  org.eclipse.ui.forms.widgets.FormToolkit toolkit
           
 
Fields inherited from class org.eclipse.ui.part.MultiPageEditorPart
 
Fields inherited from class org.eclipse.ui.part.EditorPart
 
Fields inherited from class org.eclipse.ui.part.WorkbenchPart
 
Fields inherited from interface org.eclipse.ui.IEditorPart
PROP_DIRTY, PROP_INPUT
 
Fields inherited from interface org.eclipse.ui.IWorkbenchPart
PROP_TITLE
 
Constructor Summary
FormEditor()
          The constructor.
 
Method Summary
 int addPage(org.eclipse.swt.widgets.Control control)
          Adds a simple SWT control as a page.
 int addPage(org.eclipse.ui.IEditorPart editor, org.eclipse.ui.IEditorInput input)
          Adds the complete editor part to the multi-page editor.
 int addPage(IFormPage page)
          Adds the form page to this editor.
protected abstract  void addPages()
          Subclass should implement this method to add pages to the editor using 'addPage(IFormPage)' method.
 void close(boolean save)
          Closes the editor programmatically.
protected  void configurePage(int index, IFormPage page)
          Configures the form page.
protected  void createPages()
          Creates the common toolkit for this editor and adds pages to the editor.
protected  org.eclipse.ui.forms.widgets.FormToolkit createToolkit(org.eclipse.swt.widgets.Display display)
          Creates the form toolkit.
 void dispose()
          Disposes the pages and the toolkit after disposing the editor itself.
 void editorDirtyStateChanged()
          Called to indicate that the editor has been made dirty or the changes have been saved.
 IFormPage findPage(java.lang.String pageId)
          Finds the page instance that has the provided id.
 org.eclipse.ui.IEditorPart getActiveEditor()
          Widens the visibility of the method in the superclass.
 IFormPage getActivePageInstance()
          Returns active page instance if the currently selected page index is not -1, or null if it is.
protected  int getCurrentPage()
          Returns the current page index.
 org.eclipse.ui.forms.widgets.FormToolkit getToolkit()
          Returns the toolkit owned by this editor.
 void init(org.eclipse.ui.IEditorSite site, org.eclipse.ui.IEditorInput input)
          Overrides super to plug in a different selection provider.
protected  void pageChange(int newPageIndex)
          Notifies this multi-page editor that the page with the given id has been activated.
private  void registerPage(java.lang.Object page)
           
 void removePage(int pageIndex)
          Overrides the superclass to remove the page from the page table.
 IFormPage selectReveal(java.lang.Object pageInput)
          Iterates through the pages calling similar method until a page is found that contains the desired page input.
protected  void setActivePage(int pageIndex)
          Sets the currently active page.
 IFormPage setActivePage(java.lang.String pageId)
          Sets the active page using the unique page identifier.
 IFormPage setActivePage(java.lang.String pageId, java.lang.Object pageInput)
          Sets the active page using the unique page identifier and sets its input to the provided object.
protected  void updateActionBarContributor(int pageIndex)
          Notifies action bar contributor about page change.
private  void updatePageIndices()
           
 
Methods inherited from class org.eclipse.ui.part.MultiPageEditorPart
createPartControl, createSite, getActivePage, getContainer, getControl, getEditor, getPageCount, getPageImage, getPageText, handlePropertyChange, isDirty, setControl, setFocus, setPageImage, setPageText
 
Methods inherited from class org.eclipse.ui.part.EditorPart
doSave, doSaveAs, getEditorInput, getEditorSite, getTitleToolTip, isSaveAsAllowed, isSaveOnCloseNeeded, setContentDescription, setInitializationData, setInput, setPartName
 
Methods inherited from class org.eclipse.ui.part.WorkbenchPart
addPropertyListener, firePropertyChange, getAdapter, getConfigurationElement, getContentDescription, getDefaultImage, getPartName, getSite, getTitle, getTitleImage, removePropertyListener, setSite, setTitle, setTitleImage, setTitleToolTip, showBusy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.ui.IWorkbenchPart
addPropertyListener, getSite, getTitle, getTitleImage, removePropertyListener
 
Methods inherited from interface org.eclipse.core.runtime.IAdaptable
getAdapter
 

Field Detail

toolkit

private org.eclipse.ui.forms.widgets.FormToolkit toolkit

pages

protected java.util.Vector pages

sourcePage

private org.eclipse.ui.IEditorPart sourcePage

currentPage

private int currentPage
Constructor Detail

FormEditor

public FormEditor()
The constructor.

Method Detail

init

public void init(org.eclipse.ui.IEditorSite site,
                 org.eclipse.ui.IEditorInput input)
          throws org.eclipse.ui.PartInitException
Overrides super to plug in a different selection provider.


createPages

protected void createPages()
Creates the common toolkit for this editor and adds pages to the editor.


createToolkit

protected org.eclipse.ui.forms.widgets.FormToolkit createToolkit(org.eclipse.swt.widgets.Display display)
Creates the form toolkit. The method can be implemented to substitute a subclass of the toolkit that should be used for this editor. A typical use of this method would be to create the form toolkit using one shared FormColors object to share resources across the multiple editor instances.


addPages

protected abstract void addPages()
Subclass should implement this method to add pages to the editor using 'addPage(IFormPage)' method.


addPage

public int addPage(IFormPage page)
            throws org.eclipse.ui.PartInitException
Adds the form page to this editor. Form page will be loaded lazily. Its part control will not be created until it is activated for the first time.


addPage

public int addPage(org.eclipse.swt.widgets.Control control)
Adds a simple SWT control as a page. Overrides superclass implementation to keep track of pages.


addPage

public int addPage(org.eclipse.ui.IEditorPart editor,
                   org.eclipse.ui.IEditorInput input)
            throws org.eclipse.ui.PartInitException
Adds the complete editor part to the multi-page editor.


configurePage

protected void configurePage(int index,
                             IFormPage page)
                      throws org.eclipse.ui.PartInitException
Configures the form page.


removePage

public void removePage(int pageIndex)
Overrides the superclass to remove the page from the page table.


updatePageIndices

private void updatePageIndices()

editorDirtyStateChanged

public void editorDirtyStateChanged()
Called to indicate that the editor has been made dirty or the changes have been saved.


dispose

public void dispose()
Disposes the pages and the toolkit after disposing the editor itself. Subclasses must call 'super' when reimplementing the method.


getToolkit

public org.eclipse.ui.forms.widgets.FormToolkit getToolkit()
Returns the toolkit owned by this editor.


getActiveEditor

public org.eclipse.ui.IEditorPart getActiveEditor()
Widens the visibility of the method in the superclass.


getCurrentPage

protected int getCurrentPage()
Returns the current page index. The value is identical to the value of 'getActivePage()' except during the page switch, when this method still has the old active page index.

Another important difference is during the editor closing. When the tab folder is disposed, 'getActivePage()' will return -1, while this method will still return the last active page.


pageChange

protected void pageChange(int newPageIndex)
Description copied from class: org.eclipse.ui.part.MultiPageEditorPart
Notifies this multi-page editor that the page with the given id has been activated. This method is called when the user selects a different tab.

The MultiPageEditorPart implementation of this method sets focus to the new page, and notifies the action bar contributor (if there is one). This checks whether the action bar contributor is an instance of MultiPageEditorActionBarContributor, and, if so, calls setActivePage with the active nested editor. This also fires a selection change event if required.

Subclasses may extend this method.


setActivePage

public IFormPage setActivePage(java.lang.String pageId)
Sets the active page using the unique page identifier.


findPage

public IFormPage findPage(java.lang.String pageId)
Finds the page instance that has the provided id.


setActivePage

public IFormPage setActivePage(java.lang.String pageId,
                               java.lang.Object pageInput)
Sets the active page using the unique page identifier and sets its input to the provided object.


selectReveal

public IFormPage selectReveal(java.lang.Object pageInput)
Iterates through the pages calling similar method until a page is found that contains the desired page input.


getActivePageInstance

public IFormPage getActivePageInstance()
Returns active page instance if the currently selected page index is not -1, or null if it is.


setActivePage

protected void setActivePage(int pageIndex)
Description copied from class: org.eclipse.ui.part.MultiPageEditorPart
Sets the currently active page.


updateActionBarContributor

protected void updateActionBarContributor(int pageIndex)
Notifies action bar contributor about page change.


close

public void close(boolean save)
Closes the editor programmatically.


registerPage

private void registerPage(java.lang.Object page)
                   throws org.eclipse.ui.PartInitException