jcreek.cke.document
Class SerializeGraphDocument

java.lang.Object
  extended byjcreek.cke.document.SerializeGraphDocument
All Implemented Interfaces:
Context, CreekDocument, java.util.EventListener, ModelChangeListener, java.beans.PropertyChangeListener, java.io.Serializable

public class SerializeGraphDocument
extends java.lang.Object
implements CreekDocument, java.beans.PropertyChangeListener, ModelChangeListener

Implements the CreekDocument interface for the serialize file format with the graph model. This is instantiated when the CreekDocumentGroup opens a file with the extension "km".

Version:
Author:
See Also:
, , , Serialized Form

Field Summary
protected  boolean dirty
          True if document is dirty and needs saving.
protected  javax.swing.event.EventListenerList listeners
          List of event listeners.
protected  GraphModel model
          Our model.
protected  java.lang.String title
           
protected  boolean titled
          True if the document is titled and has a name.
protected  ConceptView view
          Our view.
 
Constructor Summary
SerializeGraphDocument()
          Creates a new SerializeGraphDocument object.
 
Method Summary
 void addUndoableEditListener(javax.swing.event.UndoableEditListener l)
          Registers an UndoableEditListener with this document.
 void close()
          We're being shutdown, remove listeners from lists.
protected  void fireEdit(javax.swing.undo.UndoableEdit ue)
          Fires an undoable edit event to all the listeners registered for such events.
 KnowledgeModel getKnowledgeModel()
           
 CreekModel getModel()
          Returns the reference to the object acting as the model for this document.
 java.lang.String getTitle()
          Returns the name of the file this document is reading and writing to.
 ConceptView getView()
          Returns the reference to the object acting as the view for this document.
 boolean isDirty()
          Returns the current dirty status of this document.
 boolean isTitled()
          Returns true if the file is currently named.
 void modelChanged(ModelChangeEvent e)
          Returns the reference to the file object for this document.
 void open()
          The document is opened.
 boolean performCommand(CreekCommand command)
          Perform the given command and fire an undoable edit event.
 void propertyChange(java.beans.PropertyChangeEvent e)
          The state of the model changed, mark ourselves dirty.
 void removeUndoableEditListener(javax.swing.event.UndoableEditListener l)
          Removes an UndoableEditListener from this document.
 boolean revert()
          Reverts this document (the graph data) to the last-saved version of the disk file.
 boolean revert(Graph g, java.lang.String savedTitle)
           
 void setTitle(java.lang.String title)
          Returns the reference to the file object for this document.
 void setTitled(boolean titled)
          Tells the document whether it has a title or not.
 void setView(ConceptView view)
          Sets the view this document is associated with.
 java.lang.String toString()
           
protected  void updateModel(Entity c)
           
protected  void updateModel(Relation c)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

model

protected GraphModel model
Our model.


view

protected transient ConceptView view
Our view.


dirty

protected transient boolean dirty
True if document is dirty and needs saving.


titled

protected boolean titled
True if the document is titled and has a name.


title

protected java.lang.String title

listeners

protected transient javax.swing.event.EventListenerList listeners
List of event listeners.

Constructor Detail

SerializeGraphDocument

public SerializeGraphDocument()
Creates a new SerializeGraphDocument object. It defaults to a untitled document with no associated file or view.

Method Detail

addUndoableEditListener

public void addUndoableEditListener(javax.swing.event.UndoableEditListener l)
Registers an UndoableEditListener with this document. As commands are performed on the document undoable edit events will be sent out to all the listeners.

Specified by:
addUndoableEditListener in interface CreekDocument
Parameters:
l - listern to add to this document
See Also:
removeUndoableEditListener(javax.swing.event.UndoableEditListener)

open

public void open()
Description copied from interface: CreekDocument
The document is opened.

Specified by:
open in interface CreekDocument

close

public void close()
We're being shutdown, remove listeners from lists.

Specified by:
close in interface CreekDocument

fireEdit

protected void fireEdit(javax.swing.undo.UndoableEdit ue)
Fires an undoable edit event to all the listeners registered for such events.

Parameters:
ue - undoable edit

getModel

public CreekModel getModel()
Returns the reference to the object acting as the model for this document. The particular implementation of this model depends on the implemention of CreekDocument.

Specified by:
getModel in interface CreekDocument
Returns:
reference to model object

getTitle

public java.lang.String getTitle()
Returns the name of the file this document is reading and writing to.

Specified by:
getTitle in interface CreekDocument
Returns:
name of the document

setTitle

public void setTitle(java.lang.String title)
Description copied from interface: CreekDocument
Returns the reference to the file object for this document.

Specified by:
setTitle in interface CreekDocument
Returns:
reference to file object

getView

public ConceptView getView()
Returns the reference to the object acting as the view for this document. The particular implementation of this view depends on the implemention of CreekDocument.

Specified by:
getView in interface CreekDocument
Returns:
reference to view object

isDirty

public boolean isDirty()
Returns the current dirty status of this document. If the document is dirty and needs to be saved, true will be returned.

Specified by:
isDirty in interface CreekDocument
Returns:
true if dirty, false if not dirty

isTitled

public boolean isTitled()
Returns true if the file is currently named.

Specified by:
isTitled in interface CreekDocument
Returns:
true if titled, false if unnamed

performCommand

public boolean performCommand(CreekCommand command)
Perform the given command and fire an undoable edit event.

Specified by:
performCommand in interface CreekDocument
Parameters:
command - command to be performed
Returns:
true if command was performed successfully

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent e)
The state of the model changed, mark ourselves dirty. If we're newly marked dirty, notify the document group that we've become dirty.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
e - change event

removeUndoableEditListener

public void removeUndoableEditListener(javax.swing.event.UndoableEditListener l)
Removes an UndoableEditListener from this document.

Specified by:
removeUndoableEditListener in interface CreekDocument
Parameters:
l - listern to remove from this document
See Also:
addUndoableEditListener(javax.swing.event.UndoableEditListener)

revert

public boolean revert()
Reverts this document (the graph data) to the last-saved version of the disk file. If the document is untitled, then the graph will simply be cleared and nothing will be read from file.

Specified by:
revert in interface CreekDocument
Returns:
true if successful, false if error

revert

public boolean revert(Graph g,
                      java.lang.String savedTitle)
Specified by:
revert in interface CreekDocument

setTitled

public void setTitled(boolean titled)
Tells the document whether it has a title or not.

Specified by:
setTitled in interface CreekDocument
Parameters:
titled - true if document has a titled

setView

public void setView(ConceptView view)
Sets the view this document is associated with. Documents should not allow setting the view more than once.

Specified by:
setView in interface CreekDocument
Parameters:
view - view object

toString

public java.lang.String toString()

getKnowledgeModel

public KnowledgeModel getKnowledgeModel()
Specified by:
getKnowledgeModel in interface Context

modelChanged

public void modelChanged(ModelChangeEvent e)
Returns the reference to the file object for this document.

Specified by:
modelChanged in interface ModelChangeListener
Returns:
reference to file object

updateModel

protected void updateModel(Entity c)

updateModel

protected void updateModel(Relation c)


Created at IDI, NTNU by the Artificial Intelligence and Learning group