edu.cs.ai.kreator.datamodels
Class AbstractKreatorFile

java.lang.Object
  extended by java.io.File
      extended by edu.cs.ai.kreator.datamodels.AbstractKreatorFile
All Implemented Interfaces:
StainedListener, java.io.Serializable, java.lang.Comparable<java.io.File>
Direct Known Subclasses:
DataFile, Project

public abstract class AbstractKreatorFile
extends java.io.File
implements StainedListener

The abstract KreatorFile class extends Java File class and defines an objects (including its content) which can be shown in the FileTabbedPane.
It also implements a StainedListener, that observes stainable object, line the FileTab.

Author:
Sebastian Loh, Marc Finthammer
See Also:
Serialized Form

Field Summary
protected  java.lang.String fileContent
          The KReatorFile's contend that was load from the harddisk.
static org.apache.log4j.Logger LOG
           
 
Fields inherited from class java.io.File
pathSeparator, pathSeparatorChar, separator, separatorChar
 
Constructor Summary
protected AbstractKreatorFile(java.io.File file)
          Creates a new KReatorFile with the specified Project and File
 
Method Summary
 void addKReatorFileListener(KreatorFileListener listener)
          Adds a KReatorFileListerner to the KReatorFileModel.
protected  void fireModelChanged()
          Fires if the KReatorFileModel has changed.
static java.util.List<java.lang.String> getAllSupportedFileExtensions()
          Returns all extensions supported by KReator file.
 java.lang.String getFileContent()
          This method is used to update the KreatorFileListener representation of the KReatorFile.
abstract  void load()
          Loads the AbstractKreatorFile.
 void removeKReatorFileListener(KreatorFileListener listener)
          Removes a KReatorFileListerner from the KReatorFileModel.
abstract  void save()
          Saves the AbstractKreatorFile to the file system.
 void setFileContent(java.lang.String newContent)
          Sets the file content by a external causer.
 void stainedStatusChanged(boolean status)
          This method is called by a Stainable in order to indicate that its stained/clean state has changed.
 boolean viewsAreStained()
          viewsAreStained
 
Methods inherited from class java.io.File
canExecute, canRead, canWrite, compareTo, createNewFile, createTempFile, createTempFile, delete, deleteOnExit, equals, exists, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getFreeSpace, getName, getParent, getParentFile, getPath, getTotalSpace, getUsableSpace, hashCode, isAbsolute, isDirectory, isFile, isHidden, lastModified, length, list, list, listFiles, listFiles, listFiles, listRoots, mkdir, mkdirs, renameTo, setExecutable, setExecutable, setLastModified, setReadable, setReadable, setReadOnly, setWritable, setWritable, toString, toURI, toURL
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

LOG

public static final org.apache.log4j.Logger LOG

fileContent

protected java.lang.String fileContent
The KReatorFile's contend that was load from the harddisk. The fileContent is only updated by the save() operation. So the editor content and the fileContent attribute may differ until a save() is invoked.

Constructor Detail

AbstractKreatorFile

protected AbstractKreatorFile(java.io.File file)
                       throws java.io.FileNotFoundException,
                              java.io.IOException
Creates a new KReatorFile with the specified Project and File

Parameters:
project -
file -
Throws:
java.io.FileNotFoundException
java.io.IOException
Method Detail

load

public abstract void load()
                   throws java.io.FileNotFoundException,
                          java.io.IOException
Loads the AbstractKreatorFile.

Throws:
java.io.FileNotFoundException - if the specified location does not exist.
java.io.IOException - if the file could not be read from the specified location.

save

public abstract void save()
                   throws java.io.IOException
Saves the AbstractKreatorFile to the file system.

Throws:
java.io.IOException - if the file could not write on the file system.

getAllSupportedFileExtensions

public static java.util.List<java.lang.String> getAllSupportedFileExtensions()
Returns all extensions supported by KReator file.


getFileContent

public java.lang.String getFileContent()
This method is used to update the KreatorFileListener representation of the KReatorFile.

Returns:

setFileContent

public void setFileContent(java.lang.String newContent)
Sets the file content by a external causer.

Parameters:
newContent -

addKReatorFileListener

public void addKReatorFileListener(KreatorFileListener listener)
Adds a KReatorFileListerner to the KReatorFileModel.

Parameters:
listener -

removeKReatorFileListener

public void removeKReatorFileListener(KreatorFileListener listener)
Removes a KReatorFileListerner from the KReatorFileModel.

Parameters:
listener -

fireModelChanged

protected void fireModelChanged()
Fires if the KReatorFileModel has changed.


stainedStatusChanged

public void stainedStatusChanged(boolean status)
Description copied from interface: StainedListener
This method is called by a Stainable in order to indicate that its stained/clean state has changed.

Specified by:
stainedStatusChanged in interface StainedListener
Parameters:
status - true if the state is "stained", false if it "clean"

viewsAreStained

public boolean viewsAreStained()
viewsAreStained

Returns: