Package org.eclipse.ui.internal
Class DefaultSaveable
java.lang.Object
org.eclipse.ui.internal.InternalSaveable
org.eclipse.ui.Saveable
org.eclipse.ui.internal.DefaultSaveable
- All Implemented Interfaces:
IAdaptable
A default
Saveable
implementation that wrappers a regular workbench
part (one that does not itself adapt to Saveable).- Since:
- 3.2
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
doSave
(IProgressMonitor monitor) Saves the contents of this saveable.boolean
Clients must implement equals and hashCode as defined inObject.equals(Object)
andObject.hashCode()
.Returns the image descriptor for this saveable.getName()
Returns the name of this saveable for display purposes.Returns the tool tip text for this saveable.int
hashCode()
Clients must implement equals and hashCode as defined inObject.equals(Object)
andObject.hashCode()
.boolean
isDirty()
Returns whether the contents of this saveable have changed since the last save operation.boolean
show
(IWorkbenchPage page) Attempts to show this saveable in the given page and returnstrue
on success.Methods inherited from class org.eclipse.ui.Saveable
disableUI, doSave, enableUI, getAdapter
-
Constructor Details
-
DefaultSaveable
Creates a new DefaultSaveable.- Parameters:
part
- the part represented by this model
-
-
Method Details
-
doSave
Description copied from class:Saveable
Saves the contents of this saveable.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.
-
getName
Description copied from class:Saveable
Returns the name of this saveable for display purposes. -
getImageDescriptor
Description copied from class:Saveable
Returns the image descriptor for this saveable.- Specified by:
getImageDescriptor
in classSaveable
- Returns:
- the image descriptor for this model; may be
null
if there is no image
-
getToolTipText
Description copied from class:Saveable
Returns the tool tip text for this saveable. This text is used to differentiate between two inputs with the same name. For instance, MyClass.java in folder X and MyClass.java in folder Y. The format of the text varies between input types.- Specified by:
getToolTipText
in classSaveable
- Returns:
- the tool tip text; never
null
-
isDirty
public boolean isDirty()Description copied from class:Saveable
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.
-
hashCode
public int hashCode()Description copied from class:Saveable
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();
-
equals
Description copied from class:Saveable
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. -
show
Description copied from class:Saveable
Attempts to show this saveable in the given page and returnstrue
on success. The default implementation does nothing and returnsfalse
.
-