freemind.modes

Class ControllerAdapter

public abstract class ControllerAdapter extends 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 classControllerAdapter.CopyAction
protected classControllerAdapter.CopySingleAction
protected classControllerAdapter.CutAction
protected classControllerAdapter.EditAction
protected classControllerAdapter.EditCopyAction
protected classControllerAdapter.EditLongAction
protected classControllerAdapter.FileOpener
protected classControllerAdapter.FindAction
protected classControllerAdapter.FindNextAction
protected classControllerAdapter.FollowLinkAction
protected classControllerAdapter.GotoLinkNodeAction
protected classControllerAdapter.NewChildAction
protected classControllerAdapter.NewChildWithoutFocusAction
protected classControllerAdapter.NewMapAction
protected classControllerAdapter.NewPreviousSiblingAction
protected classControllerAdapter.NewSiblingAction
protected classControllerAdapter.NodeDownAction
protected classControllerAdapter.NodeUpAction
protected classControllerAdapter.OpenAction
protected classControllerAdapter.PasteAction
protected classControllerAdapter.RemoveAction
protected classControllerAdapter.SaveAction
protected classControllerAdapter.SaveAsAction
protected classControllerAdapter.SetImageByFileChooserAction
protected classControllerAdapter.SetLinkByFileChooserAction
protected classControllerAdapter.SetLinkByTextFieldAction
protected classControllerAdapter.ToggleChildrenFoldedAction
protected classControllerAdapter.ToggleFoldedAction
Field Summary
Actioncopy
ActioncopySingle
Actioncut
intNEW_CHILD
intNEW_CHILD_WITHOUT_FOCUS
intNEW_SIBLING_BEFORE
intNEW_SIBLING_BEHIND
Actionpaste
protected ControllerAdapter.ControllerPopupMenuListenerpopupListenerSingleton
Take care!
Constructor Summary
ControllerAdapter()
ControllerAdapter(Mode mode)
Method Summary
protected JMenuItemadd(JMenu menu, Action action, String keystroke)
protected voidadd(JMenu menu, Action action)
voidaddNew(NodeView target, int newNodeMode, KeyEvent e)
voidanotherNodeSelected(MindMapNode n)
protected booleanbinOptionIsTrue(String option)
booleanclose()
Return false if user has canceled.
voiddoubleClick(MouseEvent e)
voidedit(KeyEvent e, boolean addNew, boolean editLong)
booleanextendSelection(MouseEvent e)
ControllergetController()
protected FileFiltergetFileFilter()
You may want to implement this...
FreeMindMaingetFrame()
protected StringgetLinkByFileChooser(FileFilter fileFilter)
MapAdaptergetMap()
protected MapModulegetMapModule()
protected ModegetMode()
JPopupMenugetPopupForModel(Object obj)
Default implementation: no context menu.
URLgetResource(String name)
protected LinkedListgetSelecteds()
fc, 24.1.2004: having two methods getSelecteds with different return values (linkedlists of models resp. views) is asking for trouble.
protected StringgetText(String textId)
Get text identification of the map
MapViewgetView()
voidhandleLoadingException(Exception ex)
booleanisBlocked()
voidload(File file)
You may decide to overload this or take the default and implement the functionality in your MapModel (implements MindMap)
voidloadURL(String relative)
voidloadURL()
voidmapOpened(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.
voidmouseWheelMoved(MouseWheelEvent e)
voidnewMap()
protected voidnewMap(MindMap map)
MapAdapternewModel()
You _must_ implement this if you use one of the following actions: OpenAction, NewMapAction.
protected abstract MindMapNodenewNode()
voidnodeChanged(MindMapNode n)
voidopen()
voidplainClick(MouseEvent e)
booleansave()
booleansave(File file)
Return false is the action was cancelled, e.g. when it has to lead to saving as.
booleansaveAs()
Save as; return false is the action was cancelled
protected voidsetAllActions(boolean enabled)
Overwrite this to set all of your actions which are dependent on whether there is a map or not.
protected voidsetImageByFileChooser()
protected voidsetLinkByFileChooser()
protected voidsetLinkByTextField()
protected voidsetMode(Mode mode)
voidshowPopupMenu(MouseEvent e)
protected voidtoggleChildrenFolded()
If any children are folded, unfold all folded children.
voidtoggleFolded()
protected voidupdateMapModuleName()

Field Detail

copy

public Action copy

copySingle

public Action copySingle

cut

public Action cut

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

paste

public Action paste

popupListenerSingleton

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

Constructor Detail

ControllerAdapter

public ControllerAdapter()

ControllerAdapter

public ControllerAdapter(Mode mode)

Method Detail

add

protected JMenuItem add(JMenu menu, Action action, String keystroke)

Returns: returns the new JMenuItem.

add

protected void add(JMenu menu, Action action)

addNew

public void addNew(NodeView target, int newNodeMode, KeyEvent e)

anotherNodeSelected

public void anotherNodeSelected(MindMapNode n)

binOptionIsTrue

protected boolean binOptionIsTrue(String option)

close

public boolean close()
Return false if user has canceled.

doubleClick

public void doubleClick(MouseEvent e)

edit

public void edit(KeyEvent e, boolean addNew, boolean editLong)

extendSelection

public boolean extendSelection(MouseEvent e)

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(Object obj)
Default implementation: no context menu.

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

load

public void load(File file)
You may decide to overload this or take the default and implement the functionality in your MapModel (implements MindMap)

loadURL

public void loadURL(String relative)

loadURL

public void loadURL()

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)

newMap

public void newMap()

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)

open

public void open()

plainClick

public void plainClick(MouseEvent e)

save

public boolean save()

save

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

saveAs

public boolean saveAs()
Save as; return false is the action was cancelled

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)

toggleChildrenFolded

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

toggleFolded

public void toggleFolded()

updateMapModuleName

protected void updateMapModuleName()