Eclipse Platform
Release 3.3

org.eclipse.ui.texteditor
Class AbstractTextEditor.TextEditorSavable

java.lang.Object
  extended byorg.eclipse.ui.internal.InternalSaveable
      extended byorg.eclipse.ui.Saveable
          extended byorg.eclipse.ui.texteditor.AbstractTextEditor.TextEditorSavable
All Implemented Interfaces:
IAdaptable
Enclosing class:
AbstractTextEditor

protected static class AbstractTextEditor.TextEditorSavable
extends Saveable

This text editor's savable.

Since:
3.3

Constructor Summary
AbstractTextEditor.TextEditorSavable(ITextEditor textEditor)
          Creates a new savable for this text editor.
 
Method Summary
 void disconnectEditor()
          Disconnects the editor from this savable.
 void doSave(IProgressMonitor monitor)
          Saves the contents of this saveable.
 boolean equals(Object obj)
          Clients must implement equals and hashCode as defined in Object.equals(Object) and Object.hashCode().
 Object getAdapter(Class adapter)
          Explicit comment needed to suppress wrong waning caused by http://bugs.sun.com/bugdatabase/view_bug.do?
 ImageDescriptor getImageDescriptor()
          Returns the image descriptor for this saveable.
 String getName()
          Returns the name of this saveable for display purposes.
 String getToolTipText()
          Returns the tool tip text for this saveable.
 int hashCode()
          Clients must implement equals and hashCode as defined in Object.equals(Object) and Object.hashCode().
 boolean isDirty()
          Returns whether the contents of this saveable have changed since the last save operation.
 boolean supportsBackgroundSave()
           
 
Methods inherited from class org.eclipse.ui.Saveable
disableUI, doSave, enableUI, show
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractTextEditor.TextEditorSavable

public AbstractTextEditor.TextEditorSavable(ITextEditor textEditor)
Creates a new savable for this text editor.

Parameters:
textEditor - the text editor
Method Detail

disconnectEditor

public void disconnectEditor()
Disconnects the editor from this savable.


getName

public String getName()
Description copied from class: Saveable
Returns the name of this saveable for display purposes.

Specified by:
getName in class Saveable
Returns:
the model's name; never null.

getToolTipText

public String 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 class Saveable
Returns:
the tool tip text; never null

getImageDescriptor

public ImageDescriptor getImageDescriptor()
Description copied from class: Saveable
Returns the image descriptor for this saveable.

Specified by:
getImageDescriptor in class Saveable
Returns:
the image descriptor for this model; may be null if there is no image

doSave

public void doSave(IProgressMonitor monitor)
            throws CoreException
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 the IProgressMonitor to inform the caller.

This method is long-running; progress and cancellation are provided by the given progress monitor.

Specified by:
doSave in class Saveable
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()
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.

Specified by:
isDirty in class Saveable
Returns:
true if the contents have been modified and need saving, and false if they have not changed since the last save

supportsBackgroundSave

public boolean supportsBackgroundSave()

hashCode

public int hashCode()
Description copied from class: Saveable
Clients must implement equals and hashCode as defined in Object.equals(Object) and Object.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();
 

Specified by:
hashCode in class Saveable
Returns:
a hash code

equals

public boolean equals(Object obj)
Description copied from class: Saveable
Clients must implement equals and hashCode as defined in Object.equals(Object) and Object.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.

Specified by:
equals in class Saveable
Parameters:
obj -
Returns:
true if this Saveable is equal to the given object

getAdapter

public Object getAdapter(Class adapter)
Explicit comment needed to suppress wrong waning caused by http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4848177

Specified by:
getAdapter in interface IAdaptable
Overrides:
getAdapter in class Saveable
See Also:
Saveable.getAdapter(java.lang.Class)

Eclipse Platform
Release 3.3

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2007. All rights reserved.