jcreek.cke.document
Class KnowledgeModelController

java.lang.Object
  extended byjcreek.cke.document.KnowledgeModelController

public class KnowledgeModelController
extends java.lang.Object

Title: JavaCreek Description: A Case Based Reasoning approach developed in Java Copyright: Copyright (c) 1999 Company: Phil Systems

Version:
Author:
Victor Dias

Field Summary
protected  boolean dirty
          True if document is dirty and needs saving.
protected  java.io.File file
          File to read and write to.
protected  SerializeFormat format
          Object supporting the Serialize format.
protected static KnowledgeModelController instance
          Reference to the single instance of this class.
protected  KnowledgeModel km
          The knowledge Model for this document
protected  javax.swing.event.EventListenerList listeners
          List of event listeners.
protected  boolean titled
          True if the document is titled and has a name.
 
Constructor Summary
protected KnowledgeModelController()
          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.
 Entity[] getConceptList()
           
 java.io.File getFile()
          Returns the reference to the file object for this document.
 KnowledgeModel 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.
static KnowledgeModelController instanceOf()
          Returns the reference to the single instance of this class.
 boolean isDirty()
          Returns the current dirty status of this document.
 boolean isTitled()
          Returns true if the file is currently named.
 boolean openTestModel()
          Opens a test Model
 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 save()
          Saves this document (the graph data) to the associated disk file.
 boolean saveAs(java.io.File file)
          Saves this document (the graph data) to a new file, and hereinafter is associated with this new file.
 void setFile(java.io.File file)
          Sets the file this document is associated with.
 void setTitled(boolean titled)
          Tells the document whether it has a title or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

km

protected KnowledgeModel km
The knowledge Model for this document


format

protected SerializeFormat format
Object supporting the Serialize format.


file

protected java.io.File file
File to read and write to.


dirty

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


titled

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


listeners

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


instance

protected static KnowledgeModelController instance
Reference to the single instance of this class.

Constructor Detail

KnowledgeModelController

protected KnowledgeModelController()
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.

Parameters:
l - listern to add to this document
See Also:
removeUndoableEditListener(javax.swing.event.UndoableEditListener)

close

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


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

getFile

public java.io.File getFile()
Returns the reference to the file object for this document.

Returns:
reference to file object

getModel

public KnowledgeModel 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.

Returns:
reference to model object

getTitle

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

Returns:
name of the document

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.

Returns:
true if dirty, false if not dirty

isTitled

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

Returns:
true if titled, false if unnamed

performCommand

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

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.

Parameters:
e - change event

removeUndoableEditListener

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

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.

Returns:
true if successful, false if error

openTestModel

public boolean openTestModel()
Opens a test Model

Returns:
true if successful, false if error

save

public boolean save()
Saves this document (the graph data) to the associated disk file. The format is determined by the CreekFormat class used by the particular CreekDocument implementation.

Returns:
true if successful, false if error

saveAs

public boolean saveAs(java.io.File file)
Saves this document (the graph data) to a new file, and hereinafter is associated with this new file.

Parameters:
file - new file to save to
Returns:
true if successful, false if error

setFile

public void setFile(java.io.File file)
Sets the file this document is associated with. Documents should not allow setting the file more than once.

Parameters:
file - file object

setTitled

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

Parameters:
titled - true if document has a titled

instanceOf

public static KnowledgeModelController instanceOf()
Returns the reference to the single instance of this class. If an instance does not exist it will be created.

Returns:
the instance of this class

getConceptList

public Entity[] getConceptList()


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