freemind.modes

Class MapAdapter

Implemented Interfaces:
MindMap, TreeModel
Known Direct Subclasses:
BrowseMapModel, FileMapModel, MindMapMapModel, SchemeMapModel

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

Field Summary

protected int
changesPerformedSinceLastSave
denotes the amount of changes since the last save.
protected boolean
readOnly

Constructor Summary

MapAdapter(FreeMindMain frame)

Method Summary

void
addTreeModelListener(TreeModelListener l)
void
applyPattern(NodeAdapter node, StylePattern pattern)
protected void
applyPattern(NodeAdapter node, StylePattern pattern, boolean visible)
void
changeNode(MindMapNode node, String newText)
Transferable
copy()
Transferable
copy(MindMapNode node)
Transferable
copySingle()
Transferable
cut()
Transferable
cut(MindMapNode node)
void
destroy()
void
displayNode(MindMapNode node, ArrayList NodesUnfoldedByDisplay)
boolean
find(MindMapNode node, String what, boolean caseSensitive)
boolean
findNext()
String
getAsPlainText(List mindMapNodes)
String
getAsRTF(List mindMapNodes)
Color
getBackgroundColor()
Object
getChild(Object parent, int index)
int
getChildCount(Object parent)
File
getFile()
Change this to always return null if your model doesn't support files.
String
getFindFromText()
String
getFindWhat()
FreeMindMain
getFrame()
int
getIndexOfChild(Object parent, Object child)
String
getLink(NodeAdapter node)
MindMapLinkRegistry
getLinkRegistry()
protected int
getNumberOfChangesSinceLastSave()
Object[]
getPathToRoot(TreeNode node)
String
getRestoreable()
Object
getRoot()
protected String
getText(String textId)
URL
getURL()
Return URL of the map (whether as local file or a web location)
void
insertNodeInto(MutableTreeNode newChild, MutableTreeNode parent, int index)
Use this method to add children because it will cause the appropriate event.
void
insertNodeInto(MindMapNode newChild, MindMapNode parent)
void
insertNodeIntoNoEvent(MindMapNode newChild, MindMapNode parent)
void
insertNodeIntoNoEvent(MindMapNode newChild, MindMapNode parent, boolean asSibling)
boolean
isLeaf(Object node)
boolean
isReadOnly()
boolean
isSaved()
abstract void
load(File file)
int
moveNodeTo(MindMapNode newChild, MindMapNode parent, int index, int direction)
The direction is used if side left and right are present.
protected void
nodeChanged(TreeNode node)
Invoke this method after you've changed how node is to be represented in the tree.
protected void
nodeStructureChanged(TreeNode node)
Invoke this method if you've totally changed the children of node and its childrens children...
protected void
nodesChanged(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
nodesWereInserted(TreeNode node, int[] childIndices)
Invoke this method after you've inserted some TreeNodes into node.
protected void
nodesWereRemoved(TreeNode parent, int[] childIndices, Object[] removedChildren)
Invoke this method after you've removed some TreeNodes from node.
void
paste(Transferable t, MindMapNode parent)
void
paste(Transferable t, MindMapNode target, boolean asSibling, boolean isLeft)
void
paste(MindMapNode node, MindMapNode parent)
protected void
reload(TreeNode node)
Invoke this method if you've modified the TreeNodes upon which this model depends.
void
removeNodeFromParent(MutableTreeNode node)
Joerg: Message this to remove node from its parent.
void
removeNodeFromParent(MutableTreeNode node, boolean notify)
void
removeTreeModelListener(TreeModelListener l)
abstract boolean
save(File file)
void
setBackgroundColor(Color backgroundColor)
protected void
setFile(File file)
void
setFolded(MindMapNode node, boolean folded)
void
setLink(NodeAdapter node, String link)
protected void
setRoot(MindMapNode root)
protected void
setSaved(boolean saved)
void
splitNode(MindMapNode node, int caretPosition, String newText)
String
tryToLock(File file)
Attempts to lock the map using semaphore file.
void
valueForPathChanged(TreePath path, Object newValue)

Field Details

changesPerformedSinceLastSave

protected int changesPerformedSinceLastSave
denotes the amount of changes since the last save. The initial value is one, to ensure, that the model is dirty.

readOnly

protected boolean readOnly

Constructor Details

MapAdapter

public MapAdapter(FreeMindMain frame)

Method Details

addTreeModelListener

public void addTreeModelListener(TreeModelListener l)

applyPattern

public void applyPattern(NodeAdapter node,
                         StylePattern pattern)

applyPattern

protected void applyPattern(NodeAdapter node,
                            StylePattern pattern,
                            boolean visible)

changeNode

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

copy

public Transferable copy()
Specified by:
copy in interface MindMap

copy

public Transferable copy(MindMapNode node)
Specified by:
copy in interface MindMap

copySingle

public Transferable copySingle()
Specified by:
copySingle in interface MindMap

cut

public final Transferable cut()
Specified by:
cut in interface MindMap

cut

public final Transferable cut(MindMapNode node)
Specified by:
cut in interface MindMap

destroy

public void destroy()
Specified by:
destroy in interface MindMap

displayNode

public void displayNode(MindMapNode node,
                        ArrayList NodesUnfoldedByDisplay)
Specified by:
displayNode in interface MindMap

find

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

findNext

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

getAsPlainText

public String getAsPlainText(List mindMapNodes)
Specified by:
getAsPlainText in interface MindMap

getAsRTF

public String getAsRTF(List mindMapNodes)
Specified by:
getAsRTF in interface MindMap

getBackgroundColor

public Color getBackgroundColor()
Specified by:
getBackgroundColor in interface MindMap

getChild

public Object getChild(Object parent,
                       int index)

getChildCount

public int getChildCount(Object parent)

getFile

public File getFile()
Change this to always return null if your model doesn't support files.
Specified by:
getFile in interface MindMap

getFindFromText

public String getFindFromText()
Specified by:
getFindFromText in interface MindMap

getFindWhat

public String getFindWhat()
Specified by:
getFindWhat in interface MindMap

getFrame

public FreeMindMain getFrame()

getIndexOfChild

public int getIndexOfChild(Object parent,
                           Object child)

getLink

public String getLink(NodeAdapter node)

getLinkRegistry

public MindMapLinkRegistry getLinkRegistry()
Specified by:
getLinkRegistry in interface MindMap

getNumberOfChangesSinceLastSave

protected int getNumberOfChangesSinceLastSave()

getPathToRoot

public Object[] getPathToRoot(TreeNode node)
Specified by:
getPathToRoot in interface MindMap

getRestoreable

public String getRestoreable()
Specified by:
getRestoreable in interface MindMap

getRoot

public Object getRoot()

getText

protected String getText(String textId)

getURL

public URL getURL()
            throws MalformedURLException
Return URL of the map (whether as local file or a web location)
Specified by:
getURL in interface MindMap

insertNodeInto

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

insertNodeInto

public void insertNodeInto(MindMapNode newChild,
                           MindMapNode parent)

insertNodeIntoNoEvent

public void insertNodeIntoNoEvent(MindMapNode newChild,
                                  MindMapNode parent)

insertNodeIntoNoEvent

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

isLeaf

public boolean isLeaf(Object node)

isReadOnly

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

isSaved

public boolean isSaved()

load

public abstract void load(File file)
            throws FileNotFoundException,
                   IOException,
                   XMLParseException

moveNodeTo

public int moveNodeTo(MindMapNode newChild,
                      MindMapNode parent,
                      int index,
                      int direction)
The direction is used if side left and right are present. then the next suitable place on the same side# is searched. if there is no such place, then the side is changed.
Returns:
returns the new index.

nodeChanged

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

nodeStructureChanged

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

nodesChanged

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

nodesWereInserted

protected void nodesWereInserted(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.

nodesWereRemoved

protected void nodesWereRemoved(TreeNode parent,
                                int[] childIndices,
                                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.

paste

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

paste

public void paste(Transferable t,
                  MindMapNode target,
                  boolean asSibling,
                  boolean isLeft)
Specified by:
paste in interface MindMap

paste

public void paste(MindMapNode node,
                  MindMapNode parent)

reload

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

removeNodeFromParent

public void removeNodeFromParent(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(MutableTreeNode node,
                                 boolean notify)

removeTreeModelListener

public void removeTreeModelListener(TreeModelListener l)

save

public abstract boolean save(File file)

setBackgroundColor

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

setFile

protected void setFile(File file)

setFolded

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

setLink

public void setLink(NodeAdapter node,
                    String link)

setRoot

protected void setRoot(MindMapNode root)

setSaved

protected void setSaved(boolean saved)

splitNode

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

tryToLock

public String tryToLock(File file)
            throws 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.

valueForPathChanged

public void valueForPathChanged(TreePath path,
                                Object newValue)