com.tensegrity.gui.document
Class AbstractDocument

java.lang.Object
  extended bycom.tensegrity.gui.document.AbstractDocument
All Implemented Interfaces:
Container, Document, Observer
Direct Known Subclasses:
SwingDocument, SwtDocument

public abstract class AbstractDocument
extends java.lang.Object
implements Document

Class AbstractDocument implements functionality common to all Document implementations.

Version:
$Id: AbstractDocument.java,v 1.19 2006/04/20 08:38:56 BurkhardWick Exp $
Author:
Stepan Rutz

Field Summary
 
Fields inherited from interface com.tensegrity.gui.document.Document
GLUE_LEFTBOTTOM, GLUE_LEFTCENTEREXTEND, GLUE_LEFTTOP, GLUE_RIGHTBOTTOM, GLUE_RIGHTCENTEREXTEND, GLUE_RIGHTTOP, TYPE_FIXED_SIZE, TYPE_PACK_IS_OK, TYPE_TOOLDOCUMENT
 
Constructor Summary
AbstractDocument(java.lang.String name)
          Constructs a new document,
 
Method Summary
 void closeHandler()
          To be overridden by subclasses for doing cleanup work.
 int getCopyCounter()
          Returns the copy_counter and increments it by one afterwards.
 DocumentDataProvider getDocumentDataProvider(java.lang.String key)
          Returns the DocumentDataProvider that can provide the requested information described by the given key.
 java.lang.Object getDocumentSetting(java.lang.String key)
          Retrieves the value of an application defined document setting that has been previously stored in this instance.
 AttributeList getDocumentSettings()
          Returns all document settings serialized as AttributeList.
 java.io.File getFile()
          Gets the file of this document if it was saved or loaded before.
 int getFlags()
          Returns flags describing the nature of the document.
 java.lang.String getName()
          Retrieves the name of the document.
 boolean isModified()
          Returns whether the document needs saving or not.
 void setDocumentSetting(java.lang.String key, java.lang.Object value)
          Stores the value for an application defined document setting.
 void setDocumentSettings(AttributeList settings)
          Sets document settings from an AttributeList structure that has usually been read from a file.
 void setFile(java.io.File file)
          Sets the file of this document.
 void setModified()
          Sets the document to be unmodified.
 void setName(java.lang.String name)
          Sets the name of the document.
 void setSelected(boolean b)
          Sets the selected flag of this container.
 void setUnmodified()
          Sets the document to be unmodified.
abstract  void update(Observable o, java.lang.Object arg)
          Triggers a repaint.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.tensegrity.gui.container.Container
getApplicationFrame
 

Constructor Detail

AbstractDocument

public AbstractDocument(java.lang.String name)
Constructs a new document,

Parameters:
name - the document's name.
Method Detail

getFlags

public int getFlags()
Returns flags describing the nature of the document.

Specified by:
getFlags in interface Document
Returns:
flags describing the nature of the document.

getName

public java.lang.String getName()
Retrieves the name of the document.

Specified by:
getName in interface Container
Returns:
the document's name.

setName

public void setName(java.lang.String name)
Sets the name of the document.

Specified by:
setName in interface Container
Parameters:
name - the document's name.

getCopyCounter

public int getCopyCounter()
Returns the copy_counter and increments it by one afterwards.

Specified by:
getCopyCounter in interface Document
Returns:
the copy counter value.

getFile

public final java.io.File getFile()
Gets the file of this document if it was saved or loaded before. Otherwise the file reference returned is null.

Specified by:
getFile in interface Document
Returns:
the file of this document.

setFile

public final void setFile(java.io.File file)
Sets the file of this document. It should be set when the document is either loaded or saved. That is the invariant.

Specified by:
setFile in interface Document
Parameters:
file - the file of this document.

update

public abstract void update(Observable o,
                            java.lang.Object arg)
Triggers a repaint.

Specified by:
update in interface Observer
Parameters:
o - the observable that triggered the call.
arg - an object carrying additional information.

closeHandler

public void closeHandler()
To be overridden by subclasses for doing cleanup work.

Specified by:
closeHandler in interface Document

isModified

public boolean isModified()
Returns whether the document needs saving or not.

Specified by:
isModified in interface Document
Returns:
boolean flag that indicates whether saving is needed or not.

setUnmodified

public void setUnmodified()
Sets the document to be unmodified.

Specified by:
setUnmodified in interface Document

setModified

public void setModified()
Sets the document to be unmodified.

Specified by:
setModified in interface Document

setSelected

public void setSelected(boolean b)
Description copied from interface: Container
Sets the selected flag of this container.

Specified by:
setSelected in interface Container
Parameters:
b - true to indicate that this container is selected.

setDocumentSetting

public void setDocumentSetting(java.lang.String key,
                               java.lang.Object value)
Description copied from interface: Document
Stores the value for an application defined document setting. Depending on the type of the document and its implementation this can be an information like a creation date or a visualization option for the document contents. The key has to be a valid name for an attribute and the value has to be a valid value that can be serialized and built by the framework persistence (GraphDocumentReader and GraphDocumentWriter). You may pass null as value to remove the setting from the document.

Specified by:
setDocumentSetting in interface Document
Parameters:
key - The key to store the setting under
value - The new value for the setting or null to remove the setting

getDocumentSetting

public java.lang.Object getDocumentSetting(java.lang.String key)
Description copied from interface: Document
Retrieves the value of an application defined document setting that has been previously stored in this instance.

Specified by:
getDocumentSetting in interface Document
Parameters:
key - The key of the setting
Returns:
The current value of the setting
See Also:
Document.setDocumentSetting(String, Object)

getDocumentSettings

public AttributeList getDocumentSettings()
Description copied from interface: Document
Returns all document settings serialized as AttributeList. This is used by the GraphDocumentWriter to serialize the document.

Specified by:
getDocumentSettings in interface Document
Returns:
all document settings as AttributeList

setDocumentSettings

public void setDocumentSettings(AttributeList settings)
Description copied from interface: Document
Sets document settings from an AttributeList structure that has usually been read from a file. The document will parse the contents and will store the settings in an internal map. Afterwards each of the settings will be available through the method Document.getDocumentSetting(String).

Specified by:
setDocumentSettings in interface Document
Parameters:
settings - all document settings as AttributeList

getDocumentDataProvider

public DocumentDataProvider getDocumentDataProvider(java.lang.String key)
Description copied from interface: Document
Returns the DocumentDataProvider that can provide the requested information described by the given key. The method returns null, if there is no matching provider.

Specified by:
getDocumentDataProvider in interface Document
Parameters:
key - The key describing the requested information
Returns:
the DocumentDataProvider implementation
See Also:
DocumentDataProvider


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.