站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc 5.0.0

DataEditorSupport (NetBeans Loaders API) - NetBeans API Javadoc 5.0.0

 

org.openide.text
Class DataEditorSupport

java.lang.Object
  extended byorg.openide.windows.CloneableOpenSupport
      extended byorg.openide.text.CloneableEditorSupport
          extended byorg.openide.text.DataEditorSupport

public class DataEditorSupport
extends CloneableEditorSupport

Support for associating an editor and a Swing Document to a data object.


Nested Class Summary
static class DataEditorSupport.Env
          Environment that connects the data object and the CloneableEditorSupport.
 
Nested classes inherited from class org.openide.text.CloneableEditorSupport
CloneableEditorSupport.Pane
 
Field Summary
 
Fields inherited from class org.openide.text.CloneableEditorSupport
EDITOR_MODE
 
Fields inherited from class org.openide.windows.CloneableOpenSupport
allEditors, env
 
Constructor Summary
DataEditorSupport(DataObject obj, CloneableEditorSupport.Env env)
          Editor support for a given data object.
 
Method Summary
protected  boolean canClose()
          Checks whether is possible to close support components.
static CloneableEditorSupport create(DataObject obj, MultiDataObject.Entry entry, CookieSet set)
          Factory method to create simple CloneableEditorSupport for a given entry of a given DataObject.
protected  StyledDocument createStyledDocument(EditorKit kit)
          Let's the super method create the document and also annotates it with Title and StreamDescription properities.
protected  String documentID()
           
static DataObject findDataObject(Line l)
          Support method that extracts a DataObject from a Line.
 DataObject getDataObject()
          Getter of the data object that this support is associated with.
protected  void initializeCloneableEditor(CloneableEditor editor)
          Annotates the editor with icon from the data object and also sets appropriate selected node.
protected  String messageHtmlName()
           
protected  String messageLine(Line line)
          Computes display name for a line based on the name of the associated DataObject and the line number.
protected  String messageName()
          Constructs message that should be used to name the editor component.
protected  String messageOpened()
          Message to display when an object has been opened.
protected  String messageOpening()
          Message to display when an object is being opened.
protected  String messageSave()
          Constructs message that should be displayed when the data object is modified and is being closed.
protected  String messageToolTip()
          Text to use as tooltip for component.
protected  void notifyClosed()
          Called when closed all components.
 void saveDocument()
          Saves document.
 
Methods inherited from class org.openide.text.CloneableEditorSupport
addChangeListener, addPropertyChangeListener, close, createCloneableEditor, createCloneableTopComponent, createEditorKit, createPane, createPositionRef, createUndoRedoManager, firePropertyChange, getDocument, getInputStream, getLineSet, getOpenedPanes, getUndoRedo, isDocumentLoaded, isModified, loadFromStreamToKit, notifyModified, notifyUnmodified, open, openAt, openDocument, prepareDocument, print, reloadDocument, removeChangeListener, removePropertyChangeListener, saveFromKitToStream, setMIMEType, updateTitles, wrapEditorComponent
 
Methods inherited from class org.openide.windows.CloneableOpenSupport
close, edit, openCloneableTopComponent, view
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataEditorSupport

public DataEditorSupport(DataObject obj,
                         CloneableEditorSupport.Env env)
Editor support for a given data object. The file is taken from the data object and is updated if the object moves or renames itself.

Parameters:
obj - object to work with
env - environment to pass to
Method Detail

create

public static CloneableEditorSupport create(DataObject obj,
                                            MultiDataObject.Entry entry,
                                            CookieSet set)
Factory method to create simple CloneableEditorSupport for a given entry of a given DataObject. The common use inside DataObject looks like this:
  getCookieSet().add((Node.Cookie) DataEditorSupport.create(this, getPrimaryEntry(), getCookieSet()));
 

Parameters:
obj - the data object
entry - the entry to read and write from
set - cookie set to add remove additional cookies (currently only SaveCookie)
Returns:
a subclass of DataEditorSupport that implements at least OpenCookie, EditCookie, EditorCookie.Observable, PrintCookie, CloseCookie
Since:
5.2

getDataObject

public final DataObject getDataObject()
Getter of the data object that this support is associated with.

Returns:
data object passed in constructor

messageOpening

protected String messageOpening()
Message to display when an object is being opened.

Returns:
the message or null if nothing should be displayed

messageOpened

protected String messageOpened()
Message to display when an object has been opened.

Returns:
the message or null if nothing should be displayed

messageSave

protected String messageSave()
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()
Constructs message that should be used to name the editor component.

Returns:
name of the editor

messageHtmlName

protected String messageHtmlName()

documentID

protected String documentID()

messageToolTip

protected String messageToolTip()
Text to use as tooltip for component.

Returns:
text to show to the user

messageLine

protected String messageLine(Line line)
Computes display name for a line based on the name of the associated DataObject and the line number.

Parameters:
line - the line object to compute display name for
Returns:
display name for the line like "MyFile.java:243"
Since:
4.3

initializeCloneableEditor

protected void initializeCloneableEditor(CloneableEditor editor)
Annotates the editor with icon from the data object and also sets appropriate selected node. But only in the case the data object is valid. This implementation also listen to display name and icon chamges of the node and keeps editor top component up-to-date. If you override this method and not call super, please note that you will have to keep things synchronized yourself.

Parameters:
editor - the editor that has been created and should be annotated

notifyClosed

protected void notifyClosed()
Called when closed all components. Overrides superclass method, also unregisters listening on node delegate.


createStyledDocument

protected StyledDocument createStyledDocument(EditorKit kit)
Let's the super method create the document and also annotates it with Title and StreamDescription properities.

Parameters:
kit - kit to user to create the document
Returns:
the document annotated by the properties

canClose

protected boolean canClose()
Checks whether is possible to close support components. Overrides superclass method, adds checking for read-only property of saving file and warns user in that case.


saveDocument

public void saveDocument()
                  throws IOException
Saves document. Overrides superclass method, adds checking for read-only property of saving file and warns user in that case.

Throws:
IOException

findDataObject

public static DataObject findDataObject(Line l)
Support method that extracts a DataObject from a Line. If the line is created by a DataEditorSupport then associated DataObject can be accessed by this method.

Parameters:
l - line object
Returns:
data object or null
Since:
4.3

 

Built on May 3 2007.  |  Portions Copyright 1997-2005 Sun Microsystems, Inc. All rights reserved.