freemind.modes

Class ControllerAdapter

Implemented Interfaces:
ModeController
Known Direct Subclasses:
BrowseController, FileController, MindMapController, SchemeController

public abstract class ControllerAdapter
extends java.lang.Object
implements ModeController

Derive from this class to implement the Controller for your mode. Overload the methods you need for your data model, or use the defaults. There are some default Actions you may want to use for easy editing of your model. Take MindMapController as a sample.

Nested Class Summary

protected class
ControllerAdapter.CopyAction
protected class
ControllerAdapter.CopySingleAction
protected class
ControllerAdapter.CutAction
protected class
ControllerAdapter.EditAction
protected class
ControllerAdapter.EditCopyAction
protected class
ControllerAdapter.EditLongAction
protected class
ControllerAdapter.FileOpener
protected class
ControllerAdapter.FindAction
protected class
ControllerAdapter.FindNextAction
protected class
ControllerAdapter.FollowLinkAction
protected class
ControllerAdapter.GotoLinkNodeAction
protected class
ControllerAdapter.NewChildAction
protected class
ControllerAdapter.NewChildWithoutFocusAction
protected class
ControllerAdapter.NewMapAction
protected class
ControllerAdapter.NewPreviousSiblingAction
protected class
ControllerAdapter.NewSiblingAction
protected class
ControllerAdapter.NodeDownAction
protected class
ControllerAdapter.NodeUpAction
protected class
ControllerAdapter.OpenAction
protected class
ControllerAdapter.PasteAction
protected class
ControllerAdapter.RemoveAction
protected class
ControllerAdapter.SaveAction
protected class
ControllerAdapter.SaveAsAction
protected class
ControllerAdapter.SetImageByFileChooserAction
protected class
ControllerAdapter.SetLinkByFileChooserAction
protected class
ControllerAdapter.SetLinkByTextFieldAction
protected class
ControllerAdapter.ToggleChildrenFoldedAction
protected class
ControllerAdapter.ToggleFoldedAction

Field Summary

int
NEW_CHILD
int
NEW_CHILD_WITHOUT_FOCUS
int
NEW_SIBLING_BEFORE
int
NEW_SIBLING_BEHIND
Action
copy
Action
copySingle
Action
cut
Action
paste
protected freemind.modes.ControllerAdapter.ControllerPopupMenuListener
popupListenerSingleton
Take care! This listener is also used for modelpopups (as for graphical links).

Constructor Summary

ControllerAdapter()
ControllerAdapter(Mode mode)

Method Summary

protected void
add(JMenu menu, Action action)
protected JMenuItem
add(JMenu menu, Action action, String keystroke)
void
addNew(NodeView target, int newNodeMode, KeyEvent e)
void
anotherNodeSelected(MindMapNode n)
protected boolean
binOptionIsTrue(String option)
boolean
close()
Return false if user has canceled.
void
doubleClick(MouseEvent e)
void
edit(KeyEvent e, boolean addNew, boolean editLong)
boolean
extendSelection(MouseEvent e)
This extends the currently selected nodes.
Controller
getController()
protected FileFilter
getFileFilter()
You may want to implement this...
FreeMindMain
getFrame()
protected String
getLinkByFileChooser(FileFilter fileFilter)
MapAdapter
getMap()
protected MapModule
getMapModule()
protected Mode
getMode()
JPopupMenu
getPopupForModel(java.lang.Object obj)
Default implementation: no context menu.
URL
getResource(String name)
protected LinkedList
getSelecteds()
fc, 24.1.2004: having two methods getSelecteds with different return values (linkedlists of models resp.
protected String
getText(String textId)
Get text identification of the map
MapView
getView()
void
handleLoadingException(Exception ex)
boolean
isBlocked()
void
load(File file)
You may decide to overload this or take the default and implement the functionality in your MapModel (implements MindMap)
void
loadURL()
void
loadURL(String relative)
void
mapOpened(boolean open)
Call this method if you have opened a map for this mode with true, and if you have closed a map of this mode with false.
void
mouseWheelMoved(MouseWheelEvent e)
void
newMap()
protected void
newMap(MindMap map)
MapAdapter
newModel()
You _must_ implement this if you use one of the following actions: OpenAction, NewMapAction.
protected abstract MindMapNode
newNode()
void
nodeChanged(MindMapNode n)
void
open()
void
plainClick(MouseEvent e)
boolean
save()
boolean
save(File file)
Return false is the action was cancelled, e.g.
boolean
saveAs()
Save as; return false is the action was cancelled
protected void
setAllActions(boolean enabled)
Overwrite this to set all of your actions which are dependent on whether there is a map or not.
protected void
setImageByFileChooser()
protected void
setLinkByFileChooser()
protected void
setLinkByTextField()
protected void
setMode(Mode mode)
void
showPopupMenu(MouseEvent e)
protected void
toggleChildrenFolded()
If any children are folded, unfold all folded children.
void
toggleFolded()
protected void
updateMapModuleName()

Field Details

NEW_CHILD

public final int NEW_CHILD

NEW_CHILD_WITHOUT_FOCUS

public final int NEW_CHILD_WITHOUT_FOCUS

NEW_SIBLING_BEFORE

public final int NEW_SIBLING_BEFORE

NEW_SIBLING_BEHIND

public final int NEW_SIBLING_BEHIND

copy

public Action copy

copySingle

public Action copySingle

cut

public Action cut

paste

public Action paste

popupListenerSingleton

protected final freemind.modes.ControllerAdapter.ControllerPopupMenuListener popupListenerSingleton
Take care! This listener is also used for modelpopups (as for graphical links).

Constructor Details

ControllerAdapter

public ControllerAdapter()

ControllerAdapter

public ControllerAdapter(Mode mode)

Method Details

add

protected void add(JMenu menu,
                   Action action)

add

protected JMenuItem add(JMenu menu,
                        Action action,
                        String keystroke)
Returns:
returns the new JMenuItem.

addNew

public void addNew(NodeView target,
                   int newNodeMode,
                   KeyEvent e)
Specified by:
addNew in interface ModeController

anotherNodeSelected

public void anotherNodeSelected(MindMapNode n)
Specified by:
anotherNodeSelected in interface ModeController

binOptionIsTrue

protected boolean binOptionIsTrue(String option)

close

public boolean close()
Return false if user has canceled.
Specified by:
close in interface ModeController

doubleClick

public void doubleClick(MouseEvent e)
Specified by:
doubleClick in interface ModeController

edit

public void edit(KeyEvent e,
                 boolean addNew,
                 boolean editLong)
Specified by:
edit in interface ModeController

extendSelection

public boolean extendSelection(MouseEvent e)
This extends the currently selected nodes.
Specified by:
extendSelection in interface ModeController
Returns:
true, if the method changed the selection.

getController

public Controller getController()

getFileFilter

protected FileFilter getFileFilter()
You may want to implement this... It returns the FileFilter that is used by the open() and save() JFileChoosers.

getFrame

public FreeMindMain getFrame()

getLinkByFileChooser

protected String getLinkByFileChooser(FileFilter fileFilter)

getMap

public MapAdapter getMap()

getMapModule

protected MapModule getMapModule()

getMode

protected Mode getMode()

getPopupForModel

public JPopupMenu getPopupForModel(java.lang.Object obj)
Default implementation: no context menu.
Specified by:
getPopupForModel in interface ModeController

getResource

public URL getResource(String name)

getSelecteds

protected LinkedList getSelecteds()
fc, 24.1.2004: having two methods getSelecteds with different return values (linkedlists of models resp. views) is asking for trouble. @see MapView

getText

protected String getText(String textId)
Get text identification of the map

getView

public MapView getView()

handleLoadingException

public void handleLoadingException(Exception ex)

isBlocked

public boolean isBlocked()
Specified by:
isBlocked in interface ModeController

load

public void load(File file)
            throws FileNotFoundException,
                   IOException,
                   XMLParseException
You may decide to overload this or take the default and implement the functionality in your MapModel (implements MindMap)
Specified by:
load in interface ModeController

loadURL

public void loadURL()

loadURL

public void loadURL(String relative)

mapOpened

public void mapOpened(boolean open)
Call this method if you have opened a map for this mode with true, and if you have closed a map of this mode with false. It updates the Actions that are dependent on whether there is a map or not. --> What to do if either newMap or load or close are overwritten by a concrete implementation? uups.

mouseWheelMoved

public void mouseWheelMoved(MouseWheelEvent e)
Specified by:
mouseWheelMoved in interface ModeController

newMap

public void newMap()
Specified by:
newMap in interface ModeController

newMap

protected void newMap(MindMap map)

newModel

public MapAdapter newModel()
You _must_ implement this if you use one of the following actions: OpenAction, NewMapAction.

newNode

protected abstract MindMapNode newNode()

nodeChanged

public void nodeChanged(MindMapNode n)
Specified by:
nodeChanged in interface ModeController

open

public void open()
Specified by:
open in interface ModeController

plainClick

public void plainClick(MouseEvent e)
Specified by:
plainClick in interface ModeController

save

public boolean save()
Specified by:
save in interface ModeController

save

public boolean save(File file)
Return false is the action was cancelled, e.g. when it has to lead to saving as.
Specified by:
save in interface ModeController

saveAs

public boolean saveAs()
Save as; return false is the action was cancelled
Specified by:
saveAs in interface ModeController

setAllActions

protected void setAllActions(boolean enabled)
Overwrite this to set all of your actions which are dependent on whether there is a map or not.

setImageByFileChooser

protected void setImageByFileChooser()

setLinkByFileChooser

protected void setLinkByFileChooser()

setLinkByTextField

protected void setLinkByTextField()

setMode

protected void setMode(Mode mode)

showPopupMenu

public void showPopupMenu(MouseEvent e)
Specified by:
showPopupMenu in interface ModeController

toggleChildrenFolded

protected void toggleChildrenFolded()
If any children are folded, unfold all folded children. Otherwise, fold all children.

toggleFolded

public void toggleFolded()
Specified by:
toggleFolded in interface ModeController

updateMapModuleName

protected void updateMapModuleName()