freemind.modes
Class MapAdapter

java.lang.Object
  extended by javax.swing.tree.DefaultTreeModel
      extended by freemind.modes.MapAdapter
All Implemented Interfaces:
MindMap, java.io.Serializable, javax.swing.tree.TreeModel
Direct Known Subclasses:
BrowseMapModel, FileMapModel, MindMapMapModel, SchemeMapModel

public abstract class MapAdapter
extends javax.swing.tree.DefaultTreeModel
implements MindMap

See Also:
Serialized Form

Field Summary
protected  int changesPerformedSinceLastSave
          denotes the amount of changes since the last save.
protected static java.util.logging.Logger logger
           
protected  ModeController mModeController
           
protected  boolean readOnly
           
 
Fields inherited from class javax.swing.tree.DefaultTreeModel
asksAllowsChildren, listenerList, root
 
Constructor Summary
MapAdapter(FreeMindMain frame, ModeController modeController)
           
 
Method Summary
 void destroy()
          Destroy everything you have created upon opening.
protected  void fireTreeNodesChanged(java.lang.Object source, java.lang.Object[] path, int[] childIndices, java.lang.Object[] children)
           
protected  void fireTreeNodesInserted(java.lang.Object source, java.lang.Object[] path, int[] childIndices, java.lang.Object[] children)
          Notifies all listeners that have registered interest for notification on this event type.
protected  void fireTreeNodesRemoved(java.lang.Object source, java.lang.Object[] path, int[] childIndices, java.lang.Object[] children)
           
protected  void fireTreeStructureChanged(java.lang.Object source, java.lang.Object[] path, int[] childIndices, java.lang.Object[] children)
           
 java.lang.String getAsHTML(java.util.List mindMapNodes)
           
 java.lang.String getAsPlainText(java.util.List mindMapNodes)
           
 java.lang.String getAsRTF(java.util.List mindMapNodes)
           
 java.io.File getFile()
          Change this to always return null if your model doesn't support files.
 Filter getFilter()
           
 FreeMindMain getFrame()
           
 MindMapLinkRegistry getLinkRegistry()
           
 ModeController getModeController()
           
protected  int getNumberOfChangesSinceLastSave()
           
 MapRegistry getRegistry()
           
 java.lang.String getRestoreable()
          Returns a string that may be given to the modes restore() to get this map again.
 MindMapNode getRootNode()
           
protected  java.lang.String getText(java.lang.String textId)
           
 java.net.URL getURL()
          Return URL of the map (whether as local file or a web location)
 boolean isReadOnly()
           
 boolean isSaved()
           
abstract  void load(java.net.URL file)
           
 void nodeChanged(javax.swing.tree.TreeNode node)
          This method should not be called directly!
 void nodeRefresh(javax.swing.tree.TreeNode node)
           
abstract  boolean save(java.io.File file)
           
protected  void setFile(java.io.File file)
           
 void setFilter(Filter filter)
           
 void setRoot(MindMapNode root)
           
 void setSaved(boolean saved)
          Counts the amount of actions performed.
 java.lang.String tryToLock(java.io.File file)
          Attempts to lock the map using semaphore file.
 
Methods inherited from class javax.swing.tree.DefaultTreeModel
addTreeModelListener, asksAllowsChildren, getChild, getChildCount, getIndexOfChild, getListeners, getPathToRoot, getPathToRoot, getRoot, getTreeModelListeners, insertNodeInto, isLeaf, nodesChanged, nodeStructureChanged, nodesWereInserted, nodesWereRemoved, reload, reload, removeNodeFromParent, removeTreeModelListener, setAsksAllowsChildren, setRoot, valueForPathChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface freemind.modes.MindMap
getFilteredXml, getPathToRoot, getXml, nodeStructureChanged
 
Methods inherited from interface javax.swing.tree.TreeModel
addTreeModelListener, getChild, getChildCount, getIndexOfChild, getRoot, isLeaf, removeTreeModelListener, valueForPathChanged
 

Field Detail

changesPerformedSinceLastSave

protected int changesPerformedSinceLastSave
denotes the amount of changes since the last save. The initial value is zero, such that new models are not to be saved.


readOnly

protected boolean readOnly

logger

protected static java.util.logging.Logger logger

mModeController

protected final ModeController mModeController
Constructor Detail

MapAdapter

public MapAdapter(FreeMindMain frame,
                  ModeController modeController)
Method Detail

getModeController

public ModeController getModeController()
Specified by:
getModeController in interface MindMap
Returns:
The mode controller, the model belongs to.

save

public abstract boolean save(java.io.File file)

load

public abstract void load(java.net.URL file)
                   throws java.io.FileNotFoundException,
                          java.io.IOException,
                          XMLParseException,
                          java.net.URISyntaxException
Throws:
java.io.FileNotFoundException
java.io.IOException
XMLParseException
java.net.URISyntaxException

tryToLock

public java.lang.String tryToLock(java.io.File file)
                           throws java.lang.Exception
Attempts to lock the map using semaphore file.

Returns:
If the map is locked, return the name of the locking user, return null otherwise.
Throws:
java.lang.Exception

destroy

public void destroy()
Description copied from interface: MindMap
Destroy everything you have created upon opening.

Specified by:
destroy in interface MindMap

getFrame

public FreeMindMain getFrame()

isSaved

public boolean isSaved()
Specified by:
isSaved in interface MindMap
Returns:
true if map is clean (saved), false if it is dirty.

isReadOnly

public boolean isReadOnly()
Specified by:
isReadOnly in interface MindMap

setSaved

public void setSaved(boolean saved)
Counts the amount of actions performed.

Specified by:
setSaved in interface MindMap
Parameters:
saved - true if the file was saved recently. False otherwise.

getNumberOfChangesSinceLastSave

protected int getNumberOfChangesSinceLastSave()

getRootNode

public MindMapNode getRootNode()
Specified by:
getRootNode in interface MindMap

setRoot

public void setRoot(MindMapNode root)

getFile

public java.io.File getFile()
Change this to always return null if your model doesn't support files.

Specified by:
getFile in interface MindMap

getURL

public java.net.URL getURL()
                    throws java.net.MalformedURLException
Return URL of the map (whether as local file or a web location)

Specified by:
getURL in interface MindMap
Throws:
java.net.MalformedURLException

setFile

protected void setFile(java.io.File file)

getText

protected java.lang.String getText(java.lang.String textId)

getAsPlainText

public java.lang.String getAsPlainText(java.util.List mindMapNodes)
Specified by:
getAsPlainText in interface MindMap

getAsRTF

public java.lang.String getAsRTF(java.util.List mindMapNodes)
Specified by:
getAsRTF in interface MindMap

getAsHTML

public java.lang.String getAsHTML(java.util.List mindMapNodes)
Specified by:
getAsHTML in interface MindMap

getRestoreable

public java.lang.String getRestoreable()
Description copied from interface: MindMap
Returns a string that may be given to the modes restore() to get this map again. The Mode must take care that two different maps don't give the same restoreable key.

Specified by:
getRestoreable in interface MindMap

getLinkRegistry

public MindMapLinkRegistry getLinkRegistry()
Specified by:
getLinkRegistry in interface MindMap
Returns:
returns the link registry associated with this mode, or null, if no registry is present.

nodeChanged

public void nodeChanged(javax.swing.tree.TreeNode node)
This method should not be called directly!

Specified by:
nodeChanged in interface MindMap
Overrides:
nodeChanged in class javax.swing.tree.DefaultTreeModel

nodeRefresh

public void nodeRefresh(javax.swing.tree.TreeNode node)
Specified by:
nodeRefresh in interface MindMap

fireTreeNodesInserted

protected void fireTreeNodesInserted(java.lang.Object source,
                                     java.lang.Object[] path,
                                     int[] childIndices,
                                     java.lang.Object[] children)
Notifies all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.

Overrides:
fireTreeNodesInserted in class javax.swing.tree.DefaultTreeModel
Parameters:
source - the node being changed
path - the path to the root node
childIndices - the indices of the changed elements
children - the changed elements
See Also:
EventListenerList

fireTreeNodesRemoved

protected void fireTreeNodesRemoved(java.lang.Object source,
                                    java.lang.Object[] path,
                                    int[] childIndices,
                                    java.lang.Object[] children)
Overrides:
fireTreeNodesRemoved in class javax.swing.tree.DefaultTreeModel

fireTreeStructureChanged

protected void fireTreeStructureChanged(java.lang.Object source,
                                        java.lang.Object[] path,
                                        int[] childIndices,
                                        java.lang.Object[] children)
Overrides:
fireTreeStructureChanged in class javax.swing.tree.DefaultTreeModel

fireTreeNodesChanged

protected void fireTreeNodesChanged(java.lang.Object source,
                                    java.lang.Object[] path,
                                    int[] childIndices,
                                    java.lang.Object[] children)
Overrides:
fireTreeNodesChanged in class javax.swing.tree.DefaultTreeModel

getRegistry

public MapRegistry getRegistry()
Specified by:
getRegistry in interface MindMap

getFilter

public Filter getFilter()
Specified by:
getFilter in interface MindMap

setFilter

public void setFilter(Filter filter)
Specified by:
setFilter in interface MindMap