freemind.modes
Class MapAdapter

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

public abstract class MapAdapter
extends java.lang.Object
implements MindMap


Field Summary
protected  boolean readOnly
           
protected  boolean saved
           
 
Constructor Summary
MapAdapter(FreeMindMain frame)
           
 
Method Summary
 void addTreeModelListener(javax.swing.event.TreeModelListener l)
           
 void applyPattern(NodeAdapter node, StylePattern pattern)
           
 void changeNode(MindMapNode node, java.lang.String newText)
           
 java.awt.datatransfer.Transferable copy()
           
 java.awt.datatransfer.Transferable copy(MindMapNode node)
           
 java.awt.datatransfer.Transferable copySingle()
           
 java.awt.datatransfer.Transferable cut()
           
 java.awt.datatransfer.Transferable cut(MindMapNode node)
           
 void destroy()
          Destroy everything you have created upon opening.
 boolean find(MindMapNode node, java.lang.String what, boolean caseSensitive)
           
 boolean findNext()
           
 java.lang.String getAsPlainText(java.util.List mindMapNodes)
           
 java.lang.String getAsRTF(java.util.List mindMapNodes)
           
 java.awt.Color getBackgroundColor()
           
 java.lang.Object getChild(java.lang.Object parent, int index)
           
 int getChildCount(java.lang.Object parent)
           
 java.io.File getFile()
          Change this to always return null if your model doesn't support files.
 java.lang.String getFindFromText()
           
 java.lang.String getFindWhat()
           
 FreeMindMain getFrame()
           
 int getIndexOfChild(java.lang.Object parent, java.lang.Object child)
           
 java.lang.String getLink(NodeAdapter node)
           
 java.lang.Object[] getPathToRoot(javax.swing.tree.TreeNode node)
           
 java.lang.String getRestoreable()
          Returns a string that may be given to the modes restore() to get this map again.
 java.lang.Object getRoot()
           
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)
 void insertNodeInto(MindMapNode newChild, MindMapNode parent)
           
 void insertNodeInto(javax.swing.tree.MutableTreeNode newChild, javax.swing.tree.MutableTreeNode parent, int index)
          Use this method to add children because it will cause the appropriate event.
 void insertNodeIntoNoEvent(MindMapNode newChild, MindMapNode parent)
           
 void insertNodeIntoNoEvent(MindMapNode newChild, MindMapNode parent, boolean asSibling)
           
 boolean isLeaf(java.lang.Object node)
           
 boolean isReadOnly()
           
 boolean isSaved()
           
abstract  void load(java.io.File file)
           
protected  void nodeChanged(javax.swing.tree.TreeNode node)
          Invoke this method after you've changed how node is to be represented in the tree.
protected  void nodesChanged(javax.swing.tree.TreeNode node, int[] childIndices)
          Invoke this method after you've changed how the children identified by childIndicies are to be represented in the tree.
protected  void nodeStructureChanged(javax.swing.tree.TreeNode node)
          Invoke this method if you've totally changed the children of node and its childrens children...
protected  void nodesWereInserted(javax.swing.tree.TreeNode node, int[] childIndices)
          Invoke this method after you've inserted some TreeNodes into node.
protected  void nodesWereRemoved(javax.swing.tree.TreeNode parent, int[] childIndices, java.lang.Object[] removedChildren)
          Invoke this method after you've removed some TreeNodes from node.
 void paste(MindMapNode node, MindMapNode parent)
           
 void paste(java.awt.datatransfer.Transferable t, MindMapNode parent)
           
 void paste(java.awt.datatransfer.Transferable t, MindMapNode target, boolean asSibling)
           
protected  void reload(javax.swing.tree.TreeNode node)
          Invoke this method if you've modified the TreeNodes upon which this model depends.
 void removeNodeFromParent(javax.swing.tree.MutableTreeNode node)
          Joerg: Message this to remove node from its parent.
 void removeNodeFromParent(javax.swing.tree.MutableTreeNode node, boolean notify)
           
 void removeTreeModelListener(javax.swing.event.TreeModelListener l)
           
abstract  boolean save(java.io.File file)
           
 void setBackgroundColor(java.awt.Color backgroundColor)
           
protected  void setFile(java.io.File file)
           
 void setFolded(MindMapNode node, boolean folded)
           
 void setLink(NodeAdapter node, java.lang.String link)
           
protected  void setRoot(MindMapNode root)
           
protected  void setSaved(boolean saved)
           
 void splitNode(MindMapNode node, int caretPosition, java.lang.String newText)
           
 java.lang.String tryToLock(java.io.File file)
          Attempts to lock the map using semaphore file.
 void valueForPathChanged(javax.swing.tree.TreePath path, java.lang.Object newValue)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

saved

protected boolean saved

readOnly

protected boolean readOnly
Constructor Detail

MapAdapter

public MapAdapter(FreeMindMain frame)
Method Detail

save

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

load

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

tryToLock

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

Parameters:
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()

isReadOnly

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

setSaved

protected void setSaved(boolean saved)

getFindWhat

public java.lang.String getFindWhat()
Specified by:
getFindWhat in interface MindMap

getFindFromText

public java.lang.String getFindFromText()
Specified by:
getFindFromText in interface MindMap

getBackgroundColor

public java.awt.Color getBackgroundColor()
Specified by:
getBackgroundColor in interface MindMap

setBackgroundColor

public void setBackgroundColor(java.awt.Color backgroundColor)
Specified by:
setBackgroundColor in interface MindMap

getRoot

public java.lang.Object getRoot()
Specified by:
getRoot in interface javax.swing.tree.TreeModel

setRoot

protected 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)

setFolded

public void setFolded(MindMapNode node,
                      boolean folded)
Specified by:
setFolded in interface MindMap

setLink

public void setLink(NodeAdapter node,
                    java.lang.String link)

getLink

public java.lang.String getLink(NodeAdapter node)

getPathToRoot

public java.lang.Object[] getPathToRoot(javax.swing.tree.TreeNode node)
Specified by:
getPathToRoot in interface MindMap

splitNode

public void splitNode(MindMapNode node,
                      int caretPosition,
                      java.lang.String newText)
Specified by:
splitNode in interface MindMap

cut

public final java.awt.datatransfer.Transferable cut(MindMapNode node)
Specified by:
cut in interface MindMap

cut

public final java.awt.datatransfer.Transferable cut()
Specified by:
cut in interface MindMap

copy

public java.awt.datatransfer.Transferable copy(MindMapNode node)
Specified by:
copy in interface MindMap

copy

public java.awt.datatransfer.Transferable copy()
Specified by:
copy in interface MindMap

copySingle

public java.awt.datatransfer.Transferable copySingle()
Specified by:
copySingle in interface MindMap

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

paste

public void paste(java.awt.datatransfer.Transferable t,
                  MindMapNode parent)
Specified by:
paste in interface MindMap

paste

public void paste(java.awt.datatransfer.Transferable t,
                  MindMapNode target,
                  boolean asSibling)
Specified by:
paste in interface MindMap

paste

public void paste(MindMapNode node,
                  MindMapNode parent)

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

insertNodeIntoNoEvent

public void insertNodeIntoNoEvent(MindMapNode newChild,
                                  MindMapNode parent)

insertNodeIntoNoEvent

public void insertNodeIntoNoEvent(MindMapNode newChild,
                                  MindMapNode parent,
                                  boolean asSibling)

insertNodeInto

public void insertNodeInto(MindMapNode newChild,
                           MindMapNode parent)

insertNodeInto

public void insertNodeInto(javax.swing.tree.MutableTreeNode newChild,
                           javax.swing.tree.MutableTreeNode parent,
                           int index)
Use this method to add children because it will cause the appropriate event.


removeNodeFromParent

public void removeNodeFromParent(javax.swing.tree.MutableTreeNode node)
Joerg: Message this to remove node from its parent. This will message nodesWereRemoved to create the appropriate event. This is the preferred way to remove a node as it handles the event creation for you.


removeNodeFromParent

public void removeNodeFromParent(javax.swing.tree.MutableTreeNode node,
                                 boolean notify)

changeNode

public void changeNode(MindMapNode node,
                       java.lang.String newText)
Specified by:
changeNode in interface MindMap

getChild

public java.lang.Object getChild(java.lang.Object parent,
                                 int index)
Specified by:
getChild in interface javax.swing.tree.TreeModel

getChildCount

public int getChildCount(java.lang.Object parent)
Specified by:
getChildCount in interface javax.swing.tree.TreeModel

getIndexOfChild

public int getIndexOfChild(java.lang.Object parent,
                           java.lang.Object child)
Specified by:
getIndexOfChild in interface javax.swing.tree.TreeModel

isLeaf

public boolean isLeaf(java.lang.Object node)
Specified by:
isLeaf in interface javax.swing.tree.TreeModel

addTreeModelListener

public void addTreeModelListener(javax.swing.event.TreeModelListener l)
Specified by:
addTreeModelListener in interface javax.swing.tree.TreeModel

removeTreeModelListener

public void removeTreeModelListener(javax.swing.event.TreeModelListener l)
Specified by:
removeTreeModelListener in interface javax.swing.tree.TreeModel

valueForPathChanged

public void valueForPathChanged(javax.swing.tree.TreePath path,
                                java.lang.Object newValue)
Specified by:
valueForPathChanged in interface javax.swing.tree.TreeModel

applyPattern

public void applyPattern(NodeAdapter node,
                         StylePattern pattern)

find

public boolean find(MindMapNode node,
                    java.lang.String what,
                    boolean caseSensitive)
Specified by:
find in interface MindMap

findNext

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

nodesWereRemoved

protected void nodesWereRemoved(javax.swing.tree.TreeNode parent,
                                int[] childIndices,
                                java.lang.Object[] removedChildren)
Invoke this method after you've removed some TreeNodes from node. childIndices should be the index of the removed elements and must be sorted in ascending order. And removedChildren should be the array of the children objects that were removed.


nodesWereInserted

protected void nodesWereInserted(javax.swing.tree.TreeNode node,
                                 int[] childIndices)
Invoke this method after you've inserted some TreeNodes into node. childIndices should be the index of the new elements and must be sorted in ascending order.


nodeChanged

protected void nodeChanged(javax.swing.tree.TreeNode node)
Invoke this method after you've changed how node is to be represented in the tree.


nodesChanged

protected void nodesChanged(javax.swing.tree.TreeNode node,
                            int[] childIndices)
Invoke this method after you've changed how the children identified by childIndicies are to be represented in the tree.


nodeStructureChanged

protected void nodeStructureChanged(javax.swing.tree.TreeNode node)
Invoke this method if you've totally changed the children of node and its childrens children... This will post a treeStructureChanged event.


reload

protected void reload(javax.swing.tree.TreeNode node)
Invoke this method if you've modified the TreeNodes upon which this model depends. The model will notify all of its listeners that the model has changed below the node node (PENDING).