Skip to content

Commit

Permalink
Refactored MindMapController
Browse files Browse the repository at this point in the history
  • Loading branch information
derekprovance committed May 9, 2016
1 parent 68251b7 commit cd4a298
Showing 1 changed file with 14 additions and 40 deletions.
54 changes: 14 additions & 40 deletions freemind/modes/mindmapmode/MindMapController.java
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,7 @@ public class MindMapController extends ControllerAdapter implements

public static final String REGEXP_FOR_NUMBERS_IN_STRINGS = "([+\\-]?[0-9]*[.,]?[0-9]+)\\b";
private static final String ACCESSORIES_PLUGINS_NODE_NOTE = "accessories.plugins.NodeNote";
/**
* @author foltin
* @date 19.11.2013
*/

private final class NodeInformationTimerAction implements ActionListener {
private boolean mIsInterrupted = false;
private boolean mIsDone = true;
Expand All @@ -231,9 +228,6 @@ public boolean isRunning() {
return !mIsDone;
}

/**
* @return true, if successfully interrupted.
*/
public boolean interrupt() {
mIsInterrupted = true;
int i = 1000;
Expand Down Expand Up @@ -311,9 +305,6 @@ public void actionPerformedInternally(ActionEvent pE) {
}

private final class MapSourceChangeDialog implements Runnable {
/**
*
*/
private boolean mReturnValue = true;

private MapSourceChangeDialog() {
Expand Down Expand Up @@ -795,11 +786,8 @@ public void startupController() {
try {
RegistrationContainer container = (RegistrationContainer) pluginRegistration;
Class registrationClass = container.hookRegistrationClass;
Constructor hookConstructor = registrationClass
.getConstructor(new Class[]{ModeController.class,
MindMap.class});
HookRegistration registrationInstance = (HookRegistration) hookConstructor
.newInstance(new Object[]{this, getMap()});
Constructor hookConstructor = registrationClass.getConstructor(new Class[]{ModeController.class, MindMap.class});
HookRegistration registrationInstance = (HookRegistration) hookConstructor.newInstance(new Object[]{this, getMap()});
// register the instance to enable basePlugins.
hookFactory.registerRegistrationContainer(container,
registrationInstance);
Expand All @@ -809,21 +797,18 @@ public void startupController() {
Resources.getInstance().logException(e);
}
}
invokeHooksRecursively((NodeAdapter) getRootNode(), getMap());
invokeHooksRecursively(getRootNode(), getMap());

// register mouse motion handler:
getMapMouseMotionListener().register(
new MindMapMouseMotionManager(this));
getNodeDropListener().register(
new MindMapNodeDropListener(this));
getNodeKeyListener().register(
new CommonNodeKeyListener(this, MindMapController.this::edit));
getNodeMotionListener().register(
new MindMapNodeMotionListener(this));
getNodeMouseMotionListener().register(
new CommonNodeMouseMotionListener(this));
getMap().registerMapSourceChangedObserver(this,
mGetEventIfChangedAfterThisTimeInMillies);
registerMouseMotionHandler();
}

private void registerMouseMotionHandler() {
getMapMouseMotionListener().register(new MindMapMouseMotionManager(this));
getNodeDropListener().register(new MindMapNodeDropListener(this));
getNodeKeyListener().register(new CommonNodeKeyListener(this, MindMapController.this::edit));
getNodeMotionListener().register(new MindMapNodeMotionListener(this));
getNodeMouseMotionListener().register(new CommonNodeMouseMotionListener(this));
getMap().registerMapSourceChangedObserver(this, mGetEventIfChangedAfterThisTimeInMillies);
}

public void shutdownController() {
Expand Down Expand Up @@ -909,7 +894,6 @@ public FileFilter getFileFilter() {
public void nodeChanged(MindMapNode n) {
super.nodeChanged(n);
final MapModule mapModule = getController().getMapModule();
// only for the selected node (fc, 2.5.2004)
if (mapModule != null
&& n == mapModule.getModeController().getSelected()) {
updateToolbar(n);
Expand Down Expand Up @@ -974,7 +958,6 @@ public interface NewNodeCreator {
}

public class DefaultMindMapNodeCreator implements NewNodeCreator {

public MindMapNode createNode(Object userObject, MindMap map) {
return new MindMapNodeModel(userObject, map);
}
Expand All @@ -993,9 +976,6 @@ public MindMapNode newNode(Object userObject, MindMap map) {
return myNewNodeCreator.createNode(userObject, map);
}


/**
*/
public void updateMenus(StructuredMenuHolder holder) {

processMenuCategory(holder, mMenuStructure.getListChoiceList(), "");
Expand All @@ -1020,7 +1000,6 @@ public void updateMenus(StructuredMenuHolder holder) {
createPatternSubMenu(holder, formatMenuString);

// editMenu.add(getIconMenu());

}

/**
Expand Down Expand Up @@ -1107,10 +1086,6 @@ public JPopupMenu getPopupMenu() {
return popupmenu;
}

/**
* Link implementation: If this is a link, we want to make a popup with at
* least removelink available.
*/
public JPopupMenu getPopupForModel(java.lang.Object obj) {
if (obj instanceof MindMapArrowLinkModel) {
// yes, this is a link.
Expand Down Expand Up @@ -1171,7 +1146,6 @@ public JPopupMenu getPopupForModel(java.lang.Object obj) {
return null;
}

// convenience methods
public MindMapMapModel getMindMapMapModel() {
return (MindMapMapModel) getMap();
}
Expand Down

0 comments on commit cd4a298

Please sign in to comment.