Class FilePropSaveable
- All Implemented Interfaces:
IAdaptable,ISaveablesSource
- Author:
- Christopher Mindus
Field Summary
FieldsMethod Summary
Modifier and TypeMethodDescriptionvoiddoSave(IProgressMonitor monitor) Saves the contents of this saveable.booleanClients must implement equals and hashCode as defined inObject.equals(Object)andObject.hashCode().Saveable[]Returns the saveables currently active in the workbench part.<T> TgetAdapter(Class<T> adapter) This implementation ofIAdaptable.getAdapter(Class)returnsnull.Returns the image descriptor for this saveable.getName()Returns the name of this saveable for display purposes.Saveable[]Returns the saveables presented by the workbench part.Returns the tool tip text for this saveable.inthashCode()Clients must implement equals and hashCode as defined inObject.equals(Object)andObject.hashCode().booleanisDirty()Returns whether the contents of this saveable have changed since the last save operation.booleanisSaving()Flag for saving.voidThe Editor has had its dirty state changed: verify and inform.booleanshow(IWorkbenchPage page) Attempts to show this saveable in the given page and returnstrueon success.showEditor(IWorkbenchPage page) Attempts to show this saveable in the given page and returns the editor started or shown.
Field Details
EMPTY
This saveable in a single array.
Method Details
show
Attempts to show this saveable in the given page and returnstrueon success.showEditor
Attempts to show this saveable in the given page and returns the editor started or shown.- Parameters:
page- The workbench page in which to show this saveable.- Returns:
- The editor part, or null for none.
getName
Returns the name of this saveable for display purposes.getToolTipText
Returns the tool tip text for this saveable. This text is used to differentiate between two inputs with the same name.- Specified by:
getToolTipTextin classSaveable- Returns:
- the tool tip text; never
null.
getImageDescriptor
Returns the image descriptor for this saveable.- Specified by:
getImageDescriptorin classSaveable- Returns:
- The image descriptor for this model.
isSaving
public boolean isSaving()Flag for saving.doSave
Saves the contents of this saveable.If the save is cancelled through user action, or for any other reason, the part should invoke
setCancelledon theIProgressMonitorto inform the caller.This method is long-running; progress and cancellation are provided by the given progress monitor.
- Specified by:
doSavein classSaveable- Parameters:
monitor- The progress monitor.- Throws:
CoreException- If the save fails; it is the caller's responsibility to report the failure to the user.
isDirty
public boolean isDirty()Returns whether the contents of this saveable have changed since the last save operation.Note: this method is called frequently, for example by actions to determine their enabled status.
onDirtyChanged
public void onDirtyChanged()The Editor has had its dirty state changed: verify and inform.equals
Clients must implement equals and hashCode as defined inObject.equals(Object)andObject.hashCode(). Two saveables should be equal if their dirty state is shared, and saving one will save the other. If two saveables are equal, their names, tooltips, and images should be the same because only one of them will be shown when prompting the user to save.hashCode
public int hashCode()Clients must implement equals and hashCode as defined inObject.equals(Object)andObject.hashCode(). Two saveables should be equal if their dirty state is shared, and saving one will save the other. If two saveables are equal, their hash codes MUST be the same, and their names, tooltips, and images should be the same because only one of them will be shown when prompting the user to save.IMPORTANT: Implementers should ensure that the hashCode returned is sufficiently unique so as not to collide with hashCodes returned by other implementations. It is suggested that the defining plug-in's ID be used as part of the returned hashCode, as in the following example:
int PRIME = 31; int hash = ...; // compute the "normal" hash code, e.g. based on some identifier unique within the defining plug-in return hash * PRIME + MY_PLUGIN_ID.hashCode();getAdapter
This implementation ofIAdaptable.getAdapter(Class)returnsnull. Subclasses may override. This allows two unrelated subclasses of Saveable to implementequals(Object)andhashCode()based on an underlying implementation class that is shared by both Saveable subclasses.- Specified by:
getAdapterin interfaceIAdaptable- Overrides:
getAdapterin classSaveable- Returns:
- This implementation always returns
null.
getSaveables
Returns the saveables presented by the workbench part. If the return value of this method changes during the lifetime of this part (i.e. after initialization and control creation but before disposal) the part must notify an implicit listener usingISaveablesLifecycleListener.handleLifecycleEvent(SaveablesLifecycleEvent).Additions of saveables to the list of saveables of this part are announced using an event of type
SaveablesLifecycleEvent.POST_OPEN. Removals are announced in a two-stage process, first using an event of typeSaveablesLifecycleEvent.PRE_CLOSEfollowed by an event of typeSaveablesLifecycleEvent.POST_CLOSE. Since firing thePRE_CLOSEevent may trigger prompts to save dirty saveables, the cancellation status of the event must be checked by the part after the notification. When removing only non-dirty saveables,POST_CLOSEnotification is sufficient.The listener is obtained from the part site by calling
partSite.getService(ISaveablesLifecycleListener.class).The part must not notify from its initialization methods (e.g.
initorcreatePartControl), or from its dispose method. Parts that implementIReusableEditormust notify when their input is changed throughIReusableEditor.setInput(IEditorInput).- Specified by:
getSaveablesin interfaceISaveablesSource- Returns:
- The saveables presented by the workbench part.
- See Also:
getActiveSaveables
Returns the saveables currently active in the workbench part.Certain workbench actions, such as Save, target only the active saveables in the active part. For example, the active saveables could be determined based on the current selection in the part.
- Specified by:
getActiveSaveablesin interfaceISaveablesSource- Returns:
- The saveables currently active in the workbench part.