Class FormPage
- java.lang.Object
-
- org.eclipse.core.commands.common.EventManager
-
- org.eclipse.ui.part.WorkbenchPart
-
- org.eclipse.ui.part.EditorPart
-
- org.eclipse.ui.forms.editor.FormPage
-
- All Implemented Interfaces:
IAdaptable
,IExecutableExtension
,IFormPage
,IEditorPart
,ISaveablePart
,IWorkbenchPart
,IWorkbenchPart2
,IWorkbenchPart3
,IWorkbenchPartOrientation
public class FormPage extends EditorPart implements IFormPage
A base class that all pages that should be added to FormEditor must subclass. Form page has an instance of PageForm that extends managed form. Subclasses should override method 'createFormContent(ManagedForm)' to fill the form with content. Note that page itself can be loaded lazily (on first open). Consequently, the call to create the form content can come after the editor has been opened for a while (in fact, it is possible to open and close the editor and never create the form because no attempt has been made to show the page).- Since:
- 3.0
-
-
Field Summary
-
Fields inherited from interface org.eclipse.ui.IEditorPart
PROP_DIRTY, PROP_INPUT
-
Fields inherited from interface org.eclipse.ui.IWorkbenchPart
PROP_TITLE
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canLeaveThePage()
By default, editor will be allowed to flip the page.protected void
createFormContent(IManagedForm managedForm)
Subclasses should override this method to create content in the form hosted in this page.void
createPartControl(Composite parent)
Creates the part control by creating the managed form using the parent editor's toolkit.void
dispose()
Disposes the managed form.void
doSave(IProgressMonitor monitor)
Saves the contents of this part.void
doSaveAs()
Saves the contents of this part to another object.FormEditor
getEditor()
Returns the parent editor.String
getId()
Returns the unique identifier that can be used to reference this page.int
getIndex()
Returns the saved page index.IManagedForm
getManagedForm()
Returns the managed form owned by this page.Control
getPartControl()
Returns the form page control.Image
getTitleImage()
Returnsnull
- form page has no title image.void
init(IEditorSite site, IEditorInput input)
Initializes the form page.void
initialize(FormEditor editor)
Primes the form page with the parent editor instance.boolean
isActive()
Tests if the page is active by asking the parent editor if this page is the currently active page.boolean
isDirty()
Implemented by testing if the managed form is dirty.boolean
isEditor()
Form pages are not editors.boolean
isSaveAsAllowed()
Returns whether the "Save As" operation is supported by this part.boolean
selectReveal(Object object)
Attempts to select and reveal the given object by passing the request to the managed form.void
setActive(boolean active)
Implements the required method by refreshing the form when set active.void
setFocus()
Sets the focus by delegating to the managed form.void
setIndex(int index)
Preserves the page index.-
Methods inherited from class org.eclipse.ui.part.EditorPart
checkSite, getEditorInput, getEditorSite, getTitleToolTip, isSaveOnCloseNeeded, setContentDescription, setInitializationData, setInput, setInputWithNotify, setPartName
-
Methods inherited from class org.eclipse.ui.part.WorkbenchPart
addPartPropertyListener, addPropertyListener, firePartPropertyChanged, firePropertyChange, getAdapter, getConfigurationElement, getContentDescription, getDefaultImage, getOrientation, getPartName, getPartProperties, getPartProperty, getSite, getTitle, removePartPropertyListener, removePropertyListener, setPartProperty, setSite, setTitle, setTitleImage, setTitleToolTip, showBusy
-
Methods inherited from class org.eclipse.core.commands.common.EventManager
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.core.runtime.IAdaptable
getAdapter
-
Methods inherited from interface org.eclipse.ui.IEditorPart
getEditorInput, getEditorSite
-
Methods inherited from interface org.eclipse.ui.ISaveablePart
isSaveOnCloseNeeded
-
Methods inherited from interface org.eclipse.ui.IWorkbenchPart
addPropertyListener, getSite, getTitle, getTitleToolTip, removePropertyListener
-
-
-
-
Constructor Detail
-
FormPage
public FormPage(FormEditor editor, String id, String title)
A constructor that creates the page and initializes it with the editor.- Parameters:
editor
- the parent editorid
- the unique identifiertitle
- the page title
-
-
Method Detail
-
init
public void init(IEditorSite site, IEditorInput input)
Initializes the form page.- Specified by:
init
in interfaceIEditorPart
- Specified by:
init
in classEditorPart
- Parameters:
site
- the editor siteinput
- the editor input- See Also:
IEditorPart.init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)
-
initialize
public void initialize(FormEditor editor)
Primes the form page with the parent editor instance.- Specified by:
initialize
in interfaceIFormPage
- Parameters:
editor
- the parent editor
-
getEditor
public FormEditor getEditor()
Returns the parent editor.
-
getManagedForm
public IManagedForm getManagedForm()
Returns the managed form owned by this page.- Specified by:
getManagedForm
in interfaceIFormPage
- Returns:
- the managed form
-
setActive
public void setActive(boolean active)
Implements the required method by refreshing the form when set active. Subclasses must call super when overriding this method.
-
isActive
public boolean isActive()
Tests if the page is active by asking the parent editor if this page is the currently active page.
-
createPartControl
public void createPartControl(Composite parent)
Creates the part control by creating the managed form using the parent editor's toolkit. Subclasses should overridecreateFormContent(IManagedForm)
to populate the form with content.- Specified by:
createPartControl
in interfaceIWorkbenchPart
- Specified by:
createPartControl
in classWorkbenchPart
- Parameters:
parent
- the page parent composite
-
createFormContent
protected void createFormContent(IManagedForm managedForm)
Subclasses should override this method to create content in the form hosted in this page.- Parameters:
managedForm
- the form hosted in this page.
-
getPartControl
public Control getPartControl()
Returns the form page control.- Specified by:
getPartControl
in interfaceIFormPage
- Returns:
- managed form's control
-
dispose
public void dispose()
Disposes the managed form.- Specified by:
dispose
in interfaceIWorkbenchPart
- Overrides:
dispose
in classWorkbenchPart
-
getId
public String getId()
Returns the unique identifier that can be used to reference this page.
-
getTitleImage
public Image getTitleImage()
Returnsnull
- form page has no title image. Subclasses may override.- Specified by:
getTitleImage
in interfaceIWorkbenchPart
- Overrides:
getTitleImage
in classWorkbenchPart
- Returns:
null
-
setFocus
public void setFocus()
Sets the focus by delegating to the managed form.- Specified by:
setFocus
in interfaceIWorkbenchPart
- Specified by:
setFocus
in classWorkbenchPart
-
doSave
public void doSave(IProgressMonitor monitor)
Description copied from interface:ISaveablePart
Saves the contents of this part.If the save is successful, the part should fire a property changed event reflecting the new dirty state (
PROP_DIRTY
property).If the save is cancelled through user action, or for any other reason, the part should invoke
setCancelled
on theIProgressMonitor
to inform the caller.This method is long-running; progress and cancellation are provided by the given progress monitor.
- Specified by:
doSave
in interfaceISaveablePart
- Specified by:
doSave
in classEditorPart
- Parameters:
monitor
- the progress monitor- See Also:
ISaveablePart.doSave(org.eclipse.core.runtime.IProgressMonitor)
-
doSaveAs
public void doSaveAs()
Description copied from interface:ISaveablePart
Saves the contents of this part to another object.Implementors are expected to open a "Save As" dialog where the user will be able to select a new name for the contents. After the selection is made, the contents should be saved to that new name. During this operation a
IProgressMonitor
should be used to indicate progress.If the save is successful, the part fires a property changed event reflecting the new dirty state (
PROP_DIRTY
property).- Specified by:
doSaveAs
in interfaceISaveablePart
- Specified by:
doSaveAs
in classEditorPart
- See Also:
ISaveablePart.doSaveAs()
-
isSaveAsAllowed
public boolean isSaveAsAllowed()
Description copied from interface:ISaveablePart
Returns whether the "Save As" operation is supported by this part.- Specified by:
isSaveAsAllowed
in interfaceISaveablePart
- Specified by:
isSaveAsAllowed
in classEditorPart
- Returns:
true
if "Save As" is supported, andfalse
if not supported- See Also:
ISaveablePart.isSaveAsAllowed()
-
isDirty
public boolean isDirty()
Implemented by testing if the managed form is dirty.- Specified by:
isDirty
in interfaceISaveablePart
- Specified by:
isDirty
in classEditorPart
- Returns:
true
if the managed form is dirty,false
otherwise.- See Also:
ISaveablePart.isDirty()
-
setIndex
public void setIndex(int index)
Preserves the page index.
-
getIndex
public int getIndex()
Returns the saved page index.
-
isEditor
public boolean isEditor()
Form pages are not editors.
-
selectReveal
public boolean selectReveal(Object object)
Attempts to select and reveal the given object by passing the request to the managed form.- Specified by:
selectReveal
in interfaceIFormPage
- Parameters:
object
- the object to select and reveal in the page if possible.- Returns:
true
if the page has been successfully selected and revealed by one of the managed form parts,false
otherwise.
-
canLeaveThePage
public boolean canLeaveThePage()
By default, editor will be allowed to flip the page.- Specified by:
canLeaveThePage
in interfaceIFormPage
- Returns:
true
-
-