public class DataEditorSupport extends CloneableEditorSupport
Document
to a data object.Modifier and Type | Class and Description |
---|---|
static class |
DataEditorSupport.Env
Environment that connects the data object and the CloneableEditorSupport.
|
CloneableEditorSupport.Pane
BEGIN_COMMIT_GROUP, EDITOR_MODE, END_COMMIT_GROUP, MARK_COMMIT_GROUP
allEditors, env
Constructor and Description |
---|
DataEditorSupport(DataObject obj,
CloneableEditorSupport.Env env)
Editor support for a given data object.
|
DataEditorSupport(DataObject obj,
Lookup lkp,
CloneableEditorSupport.Env env)
Editor support for given data object.
|
Modifier and Type | Method and Description |
---|---|
static String |
annotateName(String label,
boolean html,
boolean modified,
boolean readOnly)
Marks up a tab name according to modified and read-only status.
|
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.
|
static CloneableEditorSupport |
create(DataObject obj,
MultiDataObject.Entry entry,
CookieSet set,
Callable<CloneableEditorSupport.Pane> paneFactory)
Factory method to create a bit more complicated 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 properties.
|
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 void |
loadFromStreamToKit(StyledDocument doc,
InputStream stream,
EditorKit kit) |
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.
|
StyledDocument |
openDocument() |
void |
saveAs(FileObject folder,
String fileName)
Save the document under a new file name and/or extension.
|
void |
saveDocument()
Saves document.
|
protected void |
saveFromKitToStream(StyledDocument doc,
EditorKit kit,
OutputStream stream) |
static String |
toolTip(FileObject file,
boolean modified,
boolean readOnly)
Constructs a tool tip possibly marked up with document modified and read-only status.
|
addChangeListener, addPropertyChangeListener, afterRedirect, asynchronousOpen, close, createCloneableEditor, createCloneableTopComponent, createEditorKit, createPane, createPositionRef, createUndoRedoManager, firePropertyChange, getDocument, getEditorKit, getInputStream, getLineSet, getOpenedPanes, getUndoRedo, isDocumentLoaded, isModified, notifyModified, notifyUnmodified, open, openAt, prepareDocument, print, reloadDocument, removeChangeListener, removePropertyChangeListener, setMIMEType, toString, updateTitles, wrapEditorComponent
close, edit, openCloneableTopComponent, view
public DataEditorSupport(DataObject obj, CloneableEditorSupport.Env env)
obj
- object to work withenv
- environment to pass topublic DataEditorSupport(DataObject obj, @NullAllowed Lookup lkp, CloneableEditorSupport.Env env)
DataObject.getLookup()
.obj
- object to create editor forlkp
- lookup to use. if null
, then DataObject.getLookup()
is used.env
- environment responsible for loading/storing the stramspublic static CloneableEditorSupport create(DataObject obj, MultiDataObject.Entry entry, CookieSet set)
getCookieSet().add((Node.Cookie) DataEditorSupport.create(this, getPrimaryEntry(), getCookieSet()));
obj
- the data objectentry
- the entry to read and write fromset
- cookie set to add remove additional cookies (currently only SaveCookie
)OpenCookie
,
EditCookie
,
EditorCookie.Observable
,
PrintCookie
,
CloseCookie
public static CloneableEditorSupport create(DataObject obj, MultiDataObject.Entry entry, CookieSet set, @NullAllowed Callable<CloneableEditorSupport.Pane> paneFactory)
getCookieSet().add((Node.Cookie) DataEditorSupport.create(
this, getPrimaryEntry(), getCookieSet(),
new Callable<Pane>() {
public Pane call() {
return new {@link CloneableEditor YourSubclassOfCloneableEditor}(support);
}
}
));
The method can be used to instantiate multi view editor by returning
MultiViews.createCloneableMultiView("text/yourmime", this).obj
- the data objectentry
- the entry to read and write fromset
- cookie set to add remove additional cookies (currently only SaveCookie
)paneFactory
- callback to create editor(s) for this support (if null CloneableEditor
will be created)OpenCookie
,
EditCookie
,
EditorCookie.Observable
,
PrintCookie
,
CloseCookie
public final DataObject getDataObject()
protected String messageOpening()
messageOpening
in class CloneableOpenSupport
protected String messageOpened()
messageOpened
in class CloneableOpenSupport
protected String messageSave()
messageSave
in class CloneableEditorSupport
public static String annotateName(String label, boolean html, boolean modified, boolean readOnly)
DataEditorSupport.messageName()
and DataEditorSupport.messageHtmlName()
but useful for other editor-like windows.
Behavior currently varies according to the system property nb.tabnames.html
.
label
- incoming label (null not permitted, so take care with Node.getHtmlDisplayName()
)html
- if true, label
may include HTML markup (with or without initial <html>
), and result may as wellmodified
- mark up the label as for a document which is modified in memoryreadOnly
- mark up the label as for a document based on a read-only fileprotected String messageName()
messageName
in class CloneableEditorSupport
protected String messageHtmlName()
messageHtmlName
in class CloneableEditorSupport
protected String documentID()
documentID
in class CloneableEditorSupport
public static String toolTip(FileObject file, boolean modified, boolean readOnly)
DataEditorSupport.messageToolTip()
but useful for other editor-like windows.
Behavior currently varies according to the system property nb.tabnames.html
.
file
- a file representing the tabmodified
- mark up the tool tip as for a document which is modified in memoryreadOnly
- mark up the tool tip as for a document based on a read-only fileprotected String messageToolTip()
messageToolTip
in class CloneableEditorSupport
protected String messageLine(Line line)
messageLine
in class CloneableEditorSupport
line
- the line object to compute display name forprotected void initializeCloneableEditor(CloneableEditor editor)
initializeCloneableEditor
in class CloneableEditorSupport
editor
- the editor that has been created and should be annotatedprotected void notifyClosed()
notifyClosed
in class CloneableEditorSupport
protected StyledDocument createStyledDocument(EditorKit kit)
createStyledDocument
in class CloneableEditorSupport
kit
- kit to user to create the documentprotected boolean canClose()
canClose
in class CloneableEditorSupport
protected void loadFromStreamToKit(StyledDocument doc, InputStream stream, EditorKit kit) throws IOException, BadLocationException
loadFromStreamToKit
in class CloneableEditorSupport
IOException
BadLocationException
protected void saveFromKitToStream(StyledDocument doc, EditorKit kit, OutputStream stream) throws IOException, BadLocationException
saveFromKitToStream
in class CloneableEditorSupport
IOException
BadLocationException
public StyledDocument openDocument() throws IOException
openDocument
in class CloneableEditorSupport
IOException
public void saveDocument() throws IOException
saveDocument
in class CloneableEditorSupport
IOException
public static DataObject findDataObject(Line l)
l
- line objectpublic void saveAs(FileObject folder, String fileName) throws IOException
folder
- New folder to save the DataObject to.fileName
- New file name to save the DataObject to.IOException
- If the operation failed