Package ptolemy.actor.gui
Class TextEffigy
- java.lang.Object
-
- All Implemented Interfaces:
java.lang.Cloneable
,Changeable
,Debuggable
,DebugListener
,Derivable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
- Direct Known Subclasses:
ExternalTextEffigy
public class TextEffigy extends Effigy
An effigy for a text file. If the ptolemy.user.texteditor property is set to "emacs", thenExternalTextEffigy
is used as an Effigy, otherwise this class is used as an Effigy.- Since:
- Ptolemy II 1.0
- Version:
- $Id$
- Author:
- Edward A. Lee, contributor Zoltan Kemenczy
- Pt.AcceptedRating:
- Red (neuendor)
- Pt.ProposedRating:
- Red (neuendor)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TextEffigy.Factory
A factory for creating new effigies.-
Nested classes/interfaces inherited from class ptolemy.kernel.CompositeEntity
CompositeEntity.ContainedObjectsIterator
-
-
Field Summary
-
Fields inherited from class ptolemy.actor.gui.Effigy
identifier, uri
-
Fields inherited from class ptolemy.kernel.CompositeEntity
_levelCrossingLinks
-
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
-
-
Constructor Summary
Constructors Constructor Description TextEffigy(CompositeEntity container, java.lang.String name)
Create a new effigy in the given directory with the given name.TextEffigy(Workspace workspace)
Create a new effigy in the specified workspace with an empty string for its name.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static javax.swing.text.Document
_createDocument(java.lang.String syntaxStyle)
Create a syntax document, if possible, and otherwise a plain document.static java.lang.String
extensionToSyntaxStyle(java.lang.String extension)
Return the syntax style to use for files with the given extension.javax.swing.text.Document
getDocument()
Return the document that this is an effigy of.java.lang.String
getSyntaxStyle()
Return the syntax style for the document, if one has been identified, and null otherwise.boolean
isModified()
Override the base class to compare the current text in the document against the original text.static TextEffigy
newTextEffigy(CompositeEntity container, java.lang.String text)
Create a new effigy in the given container containing the specified text.static TextEffigy
newTextEffigy(CompositeEntity container, java.lang.String text, java.lang.String syntaxStyle)
Create a new effigy in the given container containing the specified text.static TextEffigy
newTextEffigy(CompositeEntity container, java.net.URL base, java.net.URL in)
Create a new effigy in the given container by reading the specified URL.void
setDocument(javax.swing.text.Document document)
Set the document that this is an effigy of.void
setModified(boolean modified)
Record whether the data associated with this effigy has been modified since it was first read or last saved.void
writeFile(java.io.File file)
Write the text of the document to the specified file.-
Methods inherited from class ptolemy.actor.gui.Effigy
_checkContainer, _removeEntity, attributeChanged, closeTableaux, findToplevelEffigy, getTableauFactory, getWritableFile, isModifiable, isSystemEffigy, masterEffigy, numberOfOpenTableaux, setContainer, setModifiable, setSystemEffigy, setTableauFactory, showTableaux, topEffigy
-
Methods inherited from class ptolemy.kernel.CompositeEntity
_addEntity, _addRelation, _adjustDeferrals, _containedDecorators, _deepOpaqueEntityList, _description, _exportMoMLContents, _finishedAddEntity, _removeRelation, _validateSettables, allAtomicEntityList, allowLevelCrossingConnect, classDefinitionList, clone, connect, connect, containedObjectsIterator, deepCompositeEntityList, deepEntityList, deepGetEntities, deepNamedObjList, deepOpaqueEntityList, deepRelationSet, entityList, entityList, exportLinks, exportMoML, getAttribute, getEntities, getEntity, getPort, getRelation, getRelations, isAtomic, isOpaque, lazyAllAtomicEntityList, lazyAllCompositeEntityList, lazyAllCompositeTransparentAndOpaqueEntityList, lazyClassDefinitionList, lazyDeepEntityList, lazyEntityList, lazyRelationList, newRelation, numberOfEntities, numberOfRelations, numEntities, numRelations, relationList, removeAllEntities, removeAllRelations, setClassDefinition, statistics, uniqueName
-
Methods inherited from class ptolemy.kernel.ComponentEntity
_checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, newPort, propagateExistence, setName
-
Methods inherited from class ptolemy.kernel.Entity
_addPort, _removePort, connectedPortList, connectedPorts, connectionsChanged, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts
-
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getDisplayName, getFullName, getName, getName
-
-
-
-
Constructor Detail
-
TextEffigy
public TextEffigy(Workspace workspace)
Create a new effigy in the specified workspace with an empty string for its name.- Parameters:
workspace
- The workspace for this effigy.
-
TextEffigy
public TextEffigy(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
Create a new effigy in the given directory with the given name.- Parameters:
container
- The directory that contains this effigy.name
- The name of this effigy.- Throws:
IllegalActionException
- If the entity cannot be contained by the proposed container.NameDuplicationException
- If the name coincides with an entity already in the container.
-
-
Method Detail
-
extensionToSyntaxStyle
public static java.lang.String extensionToSyntaxStyle(java.lang.String extension)
Return the syntax style to use for files with the given extension.- Parameters:
extension
- The file extension.- Returns:
- A syntax style, or none if the extension is not recognized.
-
getDocument
public javax.swing.text.Document getDocument()
Return the document that this is an effigy of.- Returns:
- The document, or null if none has been set.
- See Also:
setDocument(Document)
-
getSyntaxStyle
public java.lang.String getSyntaxStyle()
Return the syntax style for the document, if one has been identified, and null otherwise.- Returns:
- A syntax style or null.
-
isModified
public boolean isModified()
Override the base class to compare the current text in the document against the original text.- Overrides:
isModified
in classEffigy
- Returns:
- True if the data has been modified.
- See Also:
Effigy.masterEffigy()
,Effigy.setModifiable(boolean)
-
newTextEffigy
public static TextEffigy newTextEffigy(CompositeEntity container, java.lang.String text) throws java.lang.Exception
Create a new effigy in the given container containing the specified text. The new effigy will have a new instance of DefaultStyledDocument associated with it.- Parameters:
container
- The container for the effigy.text
- The text to insert in the effigy.- Returns:
- A new instance of SyntaxTextEffigy.
- Throws:
java.lang.Exception
- If the text effigy cannot be contained by the specified container, or if the specified text cannot be inserted into the document.
-
newTextEffigy
public static TextEffigy newTextEffigy(CompositeEntity container, java.lang.String text, java.lang.String syntaxStyle) throws java.lang.Exception
Create a new effigy in the given container containing the specified text. The new effigy will have a new instance of DefaultStyledDocument associated with it.- Parameters:
container
- The container for the effigy.text
- The text to insert in the effigy.syntaxStyle
- The style of the text, for highlighting. This can be one of the styles defined in org.fife.ui.rsyntaxtextarea.SyntaxConstants, if that is installed, or null or an empty string for plain text. If the style is not recognized, then plain text will be assumed.- Returns:
- A new instance of SyntaxTextEffigy.
- Throws:
java.lang.Exception
- If the text effigy cannot be contained by the specified container, or if the specified text cannot be inserted into the document.
-
newTextEffigy
public static TextEffigy newTextEffigy(CompositeEntity container, java.net.URL base, java.net.URL in) throws java.lang.Exception
Create a new effigy in the given container by reading the specified URL. If the specified URL is null, then create a blank effigy. If the extension of the URL is one of several extensions used by binary formats, the file is not opened and this returns null. The new effigy will have a new instance of DefaultStyledDocument associated with it.- Parameters:
container
- The container for the effigy.base
- The base for relative file references, or null if there are no relative file references. This is ignored in this class.in
- The input URL, or null if there is none.- Returns:
- A new instance of SyntaxTextEffigy.
- Throws:
java.lang.Exception
- If the URL cannot be read, or if the data is malformed in some way.
-
setDocument
public void setDocument(javax.swing.text.Document document)
Set the document that this is an effigy of.- Parameters:
document
- The document- See Also:
getDocument()
-
setModified
public void setModified(boolean modified)
Description copied from class:Effigy
Record whether the data associated with this effigy has been modified since it was first read or last saved. If you call this with a true argument, then subsequent calls to isModified() will return true. This is used by instances of TableauFrame. This is recorded in the entity returned by topEntity(), which is the one associated with a file. This always sets a flag in the master effigy (as returned by masterEffigy()).- Overrides:
setModified
in classEffigy
- Parameters:
modified
- True if the data has been modified.- See Also:
Effigy.masterEffigy()
,Effigy.isModifiable()
,Effigy.isModified()
,Effigy.setModifiable(boolean)
-
writeFile
public void writeFile(java.io.File file) throws java.io.IOException
Write the text of the document to the specified file.
-
_createDocument
protected static javax.swing.text.Document _createDocument(java.lang.String syntaxStyle)
Create a syntax document, if possible, and otherwise a plain document.- Parameters:
syntaxStyle
- The syntax style.- Returns:
- A new document.
-
-