use of org.freeplane.features.mode.mindmapmode.MModeController in project freeplane by freeplane.
the class MMapController method convertCloneToNode.
private void convertCloneToNode(final NodeModel node) {
final MModeController mModeController = getMModeController();
final ClipboardController clipboardController = mModeController.getExtension(ClipboardController.class);
final NodeModel duplicate = clipboardController.duplicate(node, false);
IActor converter = new IActor() {
@Override
public void act() {
node.swapData(duplicate);
nodeChanged(node);
}
@Override
public void undo() {
node.swapData(duplicate);
nodeChanged(node);
}
@Override
public String getDescription() {
return "convertClonesToIndependentNodes";
}
};
final boolean shouldConvertChildNodes = node.subtreeClones().size() > 1;
mModeController.execute(converter, node.getMap());
if (shouldConvertChildNodes)
for (NodeModel child : node.getChildren()) convertCloneToNode(child);
}
use of org.freeplane.features.mode.mindmapmode.MModeController in project freeplane by freeplane.
the class HeadlessMModeControllerFactory method createStandardControllers.
private void createStandardControllers() {
final Controller controller = Controller.getCurrentController();
modeController = new MModeController(controller);
modeController.setUserInputListenerFactory(new UserInputListenerFactory(modeController));
controller.addModeController(modeController);
controller.selectModeForBuild(modeController);
new MMapController(modeController);
final MFileManager fileManager = new MFileManager();
UrlManager.install(fileManager);
MMapIO.install(modeController);
controller.getMapViewManager().addMapViewChangeListener(fileManager);
new MIconController(modeController).install(modeController);
new ProgressFactory().installActions(modeController);
EdgeController.install(new MEdgeController(modeController));
CloudController.install(new MCloudController(modeController));
NoteController.install(new MNoteController(modeController));
new MTextController(modeController).install(modeController);
LinkController.install(new MLinkController(modeController));
NodeStyleController.install(new MNodeStyleController(modeController));
ClipboardController.install(new MClipboardController());
LocationController.install(new MLocationController());
final MLogicalStyleController logicalStyleController = new MLogicalStyleController(modeController);
LogicalStyleController.install(logicalStyleController);
logicalStyleController.initM();
AttributeController.install(new MAttributeController(modeController));
modeController.addAction(new EditAttributesAction());
SpellCheckerController.install(modeController);
ExportController.install(new ExportController("/xml/ExportWithXSLT.xml"));
MapStyle.install(true);
new RevisionPlugin();
FoldingController.install(new FoldingController());
}
use of org.freeplane.features.mode.mindmapmode.MModeController in project freeplane by freeplane.
the class MModeControllerFactory method createStandardControllers.
private void createStandardControllers() {
final Controller controller = Controller.getCurrentController();
modeController = new MModeController(controller);
final UserInputListenerFactory userInputListenerFactory = new UserInputListenerFactory(modeController);
final IMouseListener nodeMouseMotionListener = new MNodeMotionListener();
userInputListenerFactory.setNodeMouseMotionListener(nodeMouseMotionListener);
userInputListenerFactory.setNodeMouseWheelListener(new MNodeMouseWheelListener(userInputListenerFactory.getMapMouseWheelListener()));
final JPopupMenu popupmenu = new JPopupMenu();
userInputListenerFactory.setNodePopupMenu(popupmenu);
modeController.setUserInputListenerFactory(userInputListenerFactory);
controller.addModeController(modeController);
controller.selectModeForBuild(modeController);
new MMapController(modeController);
final MFileManager fileManager = new MFileManager();
UrlManager.install(fileManager);
MMapIO.install(modeController);
controller.getMapViewManager().addMapViewChangeListener(fileManager);
new MIconController(modeController).install(modeController);
new ProgressFactory().installActions(modeController);
final MapController mapController = modeController.getMapController();
EdgeController.install(new MEdgeController(modeController));
CloudController.install(new MCloudController(modeController));
NoteController.install(new MNoteController(modeController));
userInputListenerFactory.setMapMouseListener(new MMapMouseListener());
final MTextController textController = new MTextController(modeController);
textController.install(modeController);
LinkController.install(new MLinkController(modeController));
NodeStyleController.install(new MNodeStyleController(modeController));
ClipboardController.install(new MClipboardController());
userInputListenerFactory.setNodeDragListener(new MNodeDragListener());
userInputListenerFactory.setNodeDropTargetListener(new MNodeDropListener());
LocationController.install(new MLocationController());
final MLogicalStyleController logicalStyleController = new MLogicalStyleController(modeController);
LogicalStyleController.install(logicalStyleController);
logicalStyleController.initM();
AttributeController.install(new MAttributeController(modeController));
userInputListenerFactory.setNodeKeyListener(new DefaultNodeKeyListener(new IEditHandler() {
public void edit(final KeyEvent e, final FirstAction action, final boolean editLong) {
((MTextController) MTextController.getController(modeController)).getEventQueue().activate(e);
textController.edit(action, editLong);
}
}));
userInputListenerFactory.setNodeMotionListener(new MNodeMotionListener());
modeController.addAction(new EditAttributesAction());
SpellCheckerController.install(modeController);
ExportController.install(new ExportController("/xml/ExportWithXSLT.xml"));
MapStyle.install(true);
final FreeplaneToolBar toolbar = new FreeplaneToolBar("main_toolbar", SwingConstants.HORIZONTAL);
final FrameController frameController = (FrameController) controller.getViewController();
UIComponentVisibilityDispatcher.install(frameController, toolbar, "toolbarVisible");
userInputListenerFactory.addToolBar("/main_toolbar", ViewController.TOP, toolbar);
userInputListenerFactory.addToolBar("/filter_toolbar", FilterController.TOOLBAR_SIDE, FilterController.getController(controller).getFilterToolbar());
userInputListenerFactory.addToolBar("/status", ViewController.BOTTOM, frameController.getStatusBar());
final JTabbedPane formattingPanel = new JTabbedPane();
Box resisableTabs = new CollapseableBoxBuilder(frameController).setPropertyNameBase("styleScrollPaneVisible").createBox(formattingPanel, Direction.RIGHT);
userInputListenerFactory.addToolBar("/format", ViewController.RIGHT, resisableTabs);
final JRootPane rootPane = ((RootPaneContainer) frameController.getMenuComponent()).getRootPane();
final FButtonBar fButtonToolBar = new FButtonBar(rootPane);
UIComponentVisibilityDispatcher.install(frameController, fButtonToolBar, "fbarVisible");
fButtonToolBar.setVisible(ResourceController.getResourceController().getBooleanProperty("fbarVisible"));
userInputListenerFactory.addToolBar("/fbuttons", ViewController.TOP, fButtonToolBar);
userInputListenerFactory.setKeyEventProcessor(new IKeyStrokeProcessor() {
@Override
public boolean processKeyBinding(KeyStroke ks, KeyEvent e) {
return ResourceController.getResourceController().getAcceleratorManager().processKeyBinding(ks, e) || fButtonToolBar.processKeyBinding(ks, e);
}
});
controller.addAction(new ToggleToolbarAction("ToggleFBarAction", "/fbuttons"));
SModeControllerFactory.install();
modeController.addAction(new SetAcceleratorOnNextClickAction());
modeController.addAction(new ShowNotesInMapAction());
// userInputListenerFactory.getMenuBuilder().setAcceleratorChangeListener(fButtonToolBar);
ResourceController.getResourceController().getAcceleratorManager().addAcceleratorChangeListener(modeController, fButtonToolBar);
userInputListenerFactory.addToolBar("/icon_toolbar", ViewController.LEFT, ((MIconController) IconController.getController()).getIconToolBarScrollPane());
modeController.addAction(new ToggleToolbarAction("ToggleLeftToolbarAction", "/icon_toolbar"));
new RevisionPlugin();
FoldingController.install(new FoldingController());
uiFactory = new MUIFactory();
mapController.addNodeChangeListener(uiFactory);
mapController.addNodeSelectionListener(uiFactory);
mapController.addMapChangeListener(uiFactory);
controller.getMapViewManager().addMapSelectionListener(uiFactory);
modeController.addExtension(MUIFactory.class, uiFactory);
modeController.addUiBuilder(Phase.ACTIONS, "main_toolbar_font_name", new ComponentBuilder(new ComponentProvider() {
@Override
public Component createComponent(Entry entry) {
final Container fontBox = uiFactory.createFontBox();
return fontBox;
}
}), EntryVisitor.EMTPY);
modeController.addUiBuilder(Phase.ACTIONS, "main_toolbar_font_size", new ComponentBuilder(new ComponentProvider() {
@Override
public Component createComponent(Entry entry) {
return uiFactory.createSizeBox();
}
}), EntryVisitor.EMTPY);
modeController.addUiBuilder(Phase.ACTIONS, "main_toolbar_style", new ComponentBuilder(new ComponentProvider() {
@Override
public Component createComponent(Entry entry) {
return uiFactory.createStyleBox();
}
}), EntryVisitor.EMTPY);
modeController.addUiBuilder(Phase.UI, "main_toolbar_zoom", new JToolbarComponentBuilder(new ComponentProvider() {
@Override
public Component createComponent(Entry entry) {
return controller.getMapViewManager().createZoomBox();
}
}));
// IconController.getController(modeController).addStateIconProvider(new IStateIconProvider() {
// public UIIcon getStateIcon(NodeModel node) {
// final URI link = NodeLinks.getLink(node);
// return wrapIcon(LinkController.getLinkIcon(link, node));
// }
//
// private UIIcon wrapIcon(final Icon linkIcon) {
// UIIcon icon = null;
// if(linkIcon != null) {
// if(linkIcon instanceof UIIcon) {
// icon = (UIIcon) linkIcon;
// }
// else {
// icon = new UIIcon("ownIcon", null) {
// public Icon getIcon() {
// return linkIcon;
// }
// };
// }
// }
// return icon;
// }
// });
}
use of org.freeplane.features.mode.mindmapmode.MModeController in project freeplane by freeplane.
the class MMapMouseListener method mouseClicked.
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2 && Compat.isCtrlEvent(e)) {
final MapView mapView = (MapView) e.getComponent();
final Object object = mapView.detectCollision(new Point(originX, originY));
if (object != null)
return;
final ModeController modeController = Controller.getCurrentModeController();
final IExtension freeNode = modeController.getExtension(FreeNode.class);
if (freeNode != null && modeController instanceof MModeController) {
final JComponent rootContent = mapView.getRoot().getMainView();
final Point contentPt = new Point();
UITools.convertPointToAncestor(rootContent, contentPt, mapView);
final float zoom = mapView.getZoom();
final Point eventPoint = e.getPoint();
int x = (int) ((eventPoint.x - contentPt.x) / zoom);
final int y = (int) ((eventPoint.y - contentPt.y) / zoom);
final int rootContentNormalWidth = (int) (rootContent.getWidth() / zoom);
final boolean newNodeIsLeft = x < rootContentNormalWidth / 2;
if (newNodeIsLeft) {
x = rootContentNormalWidth - x;
}
final Point pt = new Point(x, y);
((MMapController) modeController.getMapController()).addFreeNode(pt, newNodeIsLeft);
}
} else
super.mouseClicked(e);
}
use of org.freeplane.features.mode.mindmapmode.MModeController in project freeplane by freeplane.
the class AddOnDetailsPanel method formatMenuLocation.
private String formatMenuLocation(ScriptAddOnProperties.Script script) {
final MModeController modeController = (MModeController) Controller.getCurrentModeController();
Entry top = modeController.getUserInputListenerFactory().getGenericMenuStructure();
final String canonicalPath = entryNavigator.replaceAliases(script.menuLocation);
final String[] pathElements = canonicalPath.split("/");
Entry entry = top;
final ListIterator<String> pathIterator = Arrays.asList(pathElements).listIterator();
while (pathIterator.hasNext()) {
String name = pathIterator.next();
if (!name.isEmpty()) {
final Entry child = entry.getChild(name);
if (child == null) {
pathIterator.previous();
break;
}
entry = child;
}
}
if (entry == null)
return script.menuLocation;
final FreeplaneResourceAccessor resourceAccessor = new FreeplaneResourceAccessor();
final EntryAccessor entryAccessor = new EntryAccessor(resourceAccessor);
final String entryLocationDescription = entryAccessor.getLocationDescription(entry);
if (!pathIterator.hasNext())
return entryLocationDescription;
StringBuilder menuLocationDescription = new StringBuilder(entryLocationDescription);
while (pathIterator.hasNext()) {
menuLocationDescription.append(EntryAccessor.MENU_ELEMENT_SEPARATOR);
menuLocationDescription.append(ScriptingMenuUtils.scriptNameToMenuItemTitle(pathIterator.next()));
}
return menuLocationDescription.toString();
}
Aggregations