org.openide.text
Class EditorSupport

java.lang.Object
  |
  +--org.openide.windows.CloneableOpenSupport
        |
        +--org.openide.loaders.OpenSupport
              |
              +--org.openide.text.EditorSupport
All Implemented Interfaces:
CloseCookie, EditorCookie, LineCookie, Node.Cookie, OpenCookie, PrintCookie

Deprecated. Use DataEditorSupport instead

public class EditorSupport
extends OpenSupport
implements EditorCookie, OpenCookie, CloseCookie, PrintCookie

Support for associating an editor and a Swing Document to a data object. Can be assigned as a cookie to any editable data object. Then this data object will be capable of being opened in an editor, and there will be ways of retrieving and acting upon the Swing document which is editing it.


Inner Class Summary
static class EditorSupport.Editor
          Deprecated. Cloneable top component to hold the editor kit.
 
Inner classes inherited from class org.openide.loaders.OpenSupport
OpenSupport.Env
 
Inner classes inherited from class org.openide.windows.CloneableOpenSupport
CloneableOpenSupport.Env
 
Field Summary
static String EDITOR_MODE
          Deprecated. Use CloneableEditorSupport.EDITOR_MODE instead.
protected  String modifiedAppendix
          Deprecated.  
 
Fields inherited from class org.openide.loaders.OpenSupport
entry
 
Fields inherited from class org.openide.windows.CloneableOpenSupport
allEditors, env
 
Constructor Summary
EditorSupport(MultiDataObject.Entry entry)
          Deprecated. Support an existing loader entry.
 
Method Summary
 void addChangeListener(ChangeListener l)
          Deprecated. Adds a listener for status changes.
protected  boolean canClose()
          Deprecated. Should test whether all data is saved, and if not, prompt the user to save.
 boolean close()
          Deprecated. Closes all opened editors (if the user agrees) and flushes content of the document to the file.
protected  boolean close(boolean ask)
          Deprecated. Closes the editor, asks if necessary.
protected  CloneableTopComponent createCloneableTopComponent()
          Deprecated. A method to create a new component.
protected  EditorKit createEditorKit()
          Deprecated. Creates editor kit for this source.
 PositionRef createPositionRef(int offset, Position.Bias bias)
          Deprecated. Create a position reference for the given offset.
protected  UndoRedo.Manager createUndoRedoManager()
          Deprecated. Create an undo/redo manager.
protected  MultiDataObject findDataObject()
          Deprecated. Finds data object the entry belongs to.
 StyledDocument getDocument()
          Deprecated. Get the document.
 Line.Set getLineSet()
          Deprecated. Get the line set for all paragraphs in the document.
 JEditorPane[] getOpenedPanes()
          Deprecated. Get a list of all editor panes opened on this object.
 boolean isDocumentLoaded()
          Deprecated. Test whether the document is in memory, or whether loading is still in progress.
 boolean isModified()
          Deprecated. Test whether the document is modified.
protected  void loadFromStreamToKit(StyledDocument doc, InputStream stream, EditorKit kit)
          Deprecated. Actually read file data into an editor kit's document from an input stream.
protected  String messageName()
          Deprecated. Constructs message that should be used to name the editor component.
protected  String messageOpened()
          Deprecated. Message to display when an object has been opened.
protected  String messageOpening()
          Deprecated. Message to display when an object is being opened.
protected  String messageSave()
          Deprecated. Constructs message that should be displayed when the data object is modified and is being closed.
protected  String messageToolTip()
          Deprecated. Text to use as tooltip for component.
protected  void notifyClosed()
          Deprecated. Called when the document is closed and released from memory.
protected  boolean notifyModified()
          Deprecated. Overrides the super method to add a save cookie if the document has been marked modified.
protected  void notifyUnmodified()
          Deprecated. Notification method called when the document become unmodified.
protected  EditorSupport.Editor openAt(PositionRef pos)
          Deprecated. Forcibly create one editor component.
 StyledDocument openDocument()
          Deprecated. Get the document associated with this cookie.
 Task prepareDocument()
          Deprecated. Load the document into memory.
 void print()
          Deprecated. The implementation of @see org.openide.cookies.PrintCookie#print() method.
protected  void reloadDocument()
          Deprecated. Reload the document in response to external modification.
protected  Task reloadDocumentTask()
          Deprecated. Starts reloading of document.
 void removeChangeListener(ChangeListener l)
          Deprecated. Removes a listener for status changes.
 void saveDocument()
          Deprecated. Save the document in this thread.
protected  void saveFromKitToStream(StyledDocument doc, EditorKit kit, OutputStream stream)
          Deprecated. Actually write file data to an output stream from an editor kit's document.
 void setActions(SystemAction[] actions)
          Deprecated.  
 void setMIMEType(String s)
          Deprecated. Set the MIME type for the document.
 void setModificationListening(boolean listenToModifs)
          Deprecated. Utility method which enables or disables listening to modifications on asociated document.
protected  void updateTitles()
          Deprecated. Updates titles of all editors.
 
Methods inherited from class org.openide.windows.CloneableOpenSupport
edit, open, openCloneableTopComponent, view
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.openide.cookies.EditorCookie
open
 
Methods inherited from interface org.openide.cookies.OpenCookie
open
 

Field Detail

EDITOR_MODE

public static final String EDITOR_MODE
Deprecated. Use CloneableEditorSupport.EDITOR_MODE instead.

Common name for editor mode.

modifiedAppendix

protected String modifiedAppendix
Deprecated.  

Constructor Detail

EditorSupport

public EditorSupport(MultiDataObject.Entry entry)
Deprecated. 
Support an existing loader entry. The file is taken from the entry and is updated if the entry is moved or renamed.
Parameters:
entry - entry to create instance from
Method Detail

messageOpening

protected String messageOpening()
Deprecated. 
Message to display when an object is being opened.
Overrides:
messageOpening in class OpenSupport
Returns:
the message or null if nothing should be displayed

messageOpened

protected String messageOpened()
Deprecated. 
Message to display when an object has been opened.
Overrides:
messageOpened in class OpenSupport
Returns:
the message or null if nothing should be displayed

messageSave

protected String messageSave()
Deprecated. 
Constructs message that should be displayed when the data object is modified and is being closed.
Returns:
text to show to the user

messageName

protected String messageName()
Deprecated. 
Constructs message that should be used to name the editor component.
Returns:
name of the editor

messageToolTip

protected String messageToolTip()
Deprecated. 
Text to use as tooltip for component.
Returns:
text to show to the user

updateTitles

protected void updateTitles()
Deprecated. 
Updates titles of all editors.

createCloneableTopComponent

protected CloneableTopComponent createCloneableTopComponent()
Deprecated. 
Description copied from class: CloneableOpenSupport
A method to create a new component. Must be overridden in subclasses.
Overrides:
createCloneableTopComponent in class CloneableOpenSupport
Following copied from class: org.openide.windows.CloneableOpenSupport
Returns:
the cloneable top component for this support

createUndoRedoManager

protected UndoRedo.Manager createUndoRedoManager()
Deprecated. 
Create an undo/redo manager. This manager is then attached to the document, and listens to all changes made in it.

The default implementation simply uses UndoRedo.Manager.

Returns:
the undo/redo manager

close

public boolean close()
Deprecated. 
Closes all opened editors (if the user agrees) and flushes content of the document to the file.
Specified by:
close in interface EditorCookie
Overrides:
close in class CloneableOpenSupport
Returns:
false if the operation is cancelled

close

protected boolean close(boolean ask)
Deprecated. 
Closes the editor, asks if necessary.
Overrides:
close in class CloneableOpenSupport
Parameters:
ask - true if we should ask the user
Returns:
true if succesfully closed

prepareDocument

public Task prepareDocument()
Deprecated. 
Load the document into memory. This is done in different thread. A task for the thread is returned so anyone may test whether the loading has been finished or is still in process.
Specified by:
prepareDocument in interface EditorCookie
Returns:
task for control over loading

openDocument

public StyledDocument openDocument()
                            throws IOException
Deprecated. 
Get the document associated with this cookie. It is an instance of Swing's StyledDocument but it should also understand the NetBeans NbDocument.GUARDED to prevent certain lines from being edited by the user.

If the document is not loaded the method blocks until it is.

Specified by:
openDocument in interface EditorCookie
Returns:
the styled document for this cookie that understands the guarded attribute
Throws:
IOException - if the document could not be loaded

getDocument

public StyledDocument getDocument()
Deprecated. 
Get the document. This method may be called before the document initialization (prepareTask) has been completed, in such a case the document must not be modified.
Specified by:
getDocument in interface EditorCookie
Returns:
document or null if it is not yet loaded

isDocumentLoaded

public boolean isDocumentLoaded()
Deprecated. 
Test whether the document is in memory, or whether loading is still in progress.
Returns:
true if document is loaded

saveDocument

public void saveDocument()
                  throws IOException
Deprecated. 
Save the document in this thread. Create 'orig' document for the case that the save would fail.
Specified by:
saveDocument in interface EditorCookie
Throws:
IOException - on I/O error

saveFromKitToStream

protected void saveFromKitToStream(StyledDocument doc,
                                   EditorKit kit,
                                   OutputStream stream)
                            throws IOException,
                                   BadLocationException
Deprecated. 
Actually write file data to an output stream from an editor kit's document. Called during a file save by saveDocument().

The default implementation just calls EditorKit.write(...). Subclasses could override this to provide support for persistent guard blocks, for example.

Parameters:
doc - the document to write from
kit - the associated editor kit
stream - the open stream to write to
Throws:
IOException - if there was a problem writing the file
BadLocationException - should not normally be thrown
See Also:
loadFromStreamToKit(javax.swing.text.StyledDocument, java.io.InputStream, javax.swing.text.EditorKit)

isModified

public boolean isModified()
Deprecated. 
Test whether the document is modified.
Specified by:
isModified in interface EditorCookie
Returns:
true if the document is in memory and is modified; otherwise false

findDataObject

protected MultiDataObject findDataObject()
Deprecated. 
Finds data object the entry belongs to.
Returns:
data object or null

createPositionRef

public final PositionRef createPositionRef(int offset,
                                           Position.Bias bias)
Deprecated. 
Create a position reference for the given offset. The position moves as the document is modified and reacts to closing and opening of the document.
Parameters:
offset - the offset to create position at
bias - the Position.Bias for new creating position.
Returns:
position reference for that offset

getLineSet

public Line.Set getLineSet()
Deprecated. 
Get the line set for all paragraphs in the document.
Specified by:
getLineSet in interface LineCookie
Returns:
positions of all paragraphs on last save

setMIMEType

public void setMIMEType(String s)
Deprecated. 
Set the MIME type for the document.
Parameters:
s - the new MIME type

setActions

public void setActions(SystemAction[] actions)
Deprecated.  


createEditorKit

protected EditorKit createEditorKit()
Deprecated. 
Creates editor kit for this source.
Returns:
editor kit

setModificationListening

public void setModificationListening(boolean listenToModifs)
Deprecated. 
Utility method which enables or disables listening to modifications on asociated document.

Could be useful if we have to modify document, but do not want the Save and Save All actions to be enabled/disabled automatically. Initially modifications are listened to.

Parameters:
listenToModifs - whether to listen to modifications

addChangeListener

public void addChangeListener(ChangeListener l)
Deprecated. 
Adds a listener for status changes. An event is fired when the document is moved or removed from memory.
Parameters:
l - new listener

removeChangeListener

public void removeChangeListener(ChangeListener l)
Deprecated. 
Removes a listener for status changes.
Parameters:
l - listener to remove

print

public void print()
Deprecated. 
The implementation of @see org.openide.cookies.PrintCookie#print() method.
Specified by:
print in interface PrintCookie

loadFromStreamToKit

protected void loadFromStreamToKit(StyledDocument doc,
                                   InputStream stream,
                                   EditorKit kit)
                            throws IOException,
                                   BadLocationException
Deprecated. 
Actually read file data into an editor kit's document from an input stream. Called during a file load by prepareDocument().

The default implementation just calls EditorKit.read(...). Subclasses could override this to provide support for persistent guard blocks, for example.

Parameters:
doc - the document to read into
stream - the open stream to read from
kit - the associated editor kit
Throws:
IOException - if there was a problem reading the file
BadLocationException - should not normally be thrown
See Also:
saveFromKitToStream(javax.swing.text.StyledDocument, javax.swing.text.EditorKit, java.io.OutputStream)

reloadDocument

protected void reloadDocument()
Deprecated. 
Reload the document in response to external modification.
See Also:
reloadDocumentTask()

reloadDocumentTask

protected Task reloadDocumentTask()
Deprecated. 
Starts reloading of document. Could not be named reloadDocument, because of backward compatibility.
Returns:
task one can listen on when reloading the document

openAt

protected EditorSupport.Editor openAt(PositionRef pos)
Deprecated. 
Forcibly create one editor component. Then set the caret to the given position.
Parameters:
pos - where to place the caret
Returns:
always non-null editor

canClose

protected boolean canClose()
Deprecated. 
Should test whether all data is saved, and if not, prompt the user to save.
Overrides:
canClose in class CloneableOpenSupport
Returns:
true if everything can be closed

getOpenedPanes

public JEditorPane[] getOpenedPanes()
Deprecated. 
Description copied from interface: EditorCookie
Get a list of all editor panes opened on this object. The first item in the array should represent the component that is currently selected or that was most recently selected. (Typically, multiple panes will only be open as a result of cloning the editor component.)

The resulting panes are useful for a range of tasks; most commonly, getting the current cursor position or text selection, including the Caret object.

This method may also be used to test whether an object is already open in an editor, without actually opening it.

Specified by:
getOpenedPanes in interface EditorCookie
Following copied from interface: org.openide.cookies.EditorCookie
Returns:
an array of panes, or null if no pane is open from this file. In no case is an empty array returned.

notifyUnmodified

protected void notifyUnmodified()
Deprecated. 
Notification method called when the document become unmodified. Called after save or after reload of document.

notifyModified

protected boolean notifyModified()
Deprecated. 
Overrides the super method to add a save cookie if the document has been marked modified.
Returns:
true if the environment accepted being marked as modified or false if it refused it and the document should still be unmodified

notifyClosed

protected void notifyClosed()
Deprecated. 
Called when the document is closed and released from memory.


Built on December 12 2001.  |  Portions Copyright 1997-2001 Sun Microsystems, Inc. All rights reserved.