use of org.freeplane.features.clipboard.mindmapmode.MClipboardController 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, UITools.useRibbonsMenu());
final IMouseListener nodeMouseMotionListener = new MNodeMotionListener();
userInputListenerFactory.setNodeMouseMotionListener(nodeMouseMotionListener);
final JPopupMenu popupmenu = new JPopupMenu();
userInputListenerFactory.setNodePopupMenu(popupmenu);
modeController.setUserInputListenerFactory(userInputListenerFactory);
controller.addModeController(modeController);
controller.selectModeForBuild(modeController);
new MMapController(modeController);
if (userInputListenerFactory.useRibbonMenu()) {
RibbonBuilder builder = userInputListenerFactory.getMenuBuilder(RibbonBuilder.class);
final RibbonMapChangeAdapter mapChangeAdapter = builder.getMapChangeAdapter();
modeController.getMapController().addNodeSelectionListener(mapChangeAdapter);
modeController.getMapController().addNodeChangeListener(mapChangeAdapter);
modeController.getMapController().addMapChangeListener(mapChangeAdapter);
controller.getMapViewManager().addMapSelectionListener(mapChangeAdapter);
}
final MFileManager fileManager = new MFileManager();
UrlManager.install(fileManager);
MMapIO.install(modeController);
controller.getMapViewManager().addMapViewChangeListener(fileManager);
IconController.install(new MIconController(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(textController);
LinkController.install(new MLinkController());
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");
if (!userInputListenerFactory.useRibbonMenu()) {
userInputListenerFactory.addToolBar("/main_toolbar", ViewController.TOP, toolbar);
}
userInputListenerFactory.addToolBar("/filter_toolbar", ViewController.BOTTOM, 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);
modeController.getUserInputListenerFactory().addToolBar("/format", ViewController.RIGHT, resisableTabs);
KeyBindingProcessor keyProcessor = new KeyBindingProcessor();
modeController.addExtension(KeyBindingProcessor.class, keyProcessor);
keyProcessor.addKeyStrokeProcessor(userInputListenerFactory.getAcceleratorManager());
final FButtonBar fButtonToolBar = new FButtonBar(frameController.getRootPaneContainer().getRootPane(), keyProcessor);
UIComponentVisibilityDispatcher.install(frameController, fButtonToolBar, "fbarVisible");
fButtonToolBar.setVisible(ResourceController.getResourceController().getBooleanProperty("fbarVisible"));
userInputListenerFactory.addToolBar("/fbuttons", ViewController.TOP, fButtonToolBar);
controller.addAction(new ToggleToolbarAction("ToggleFBarAction", "/fbuttons"));
SModeControllerFactory.install();
modeController.addAction(new SetAcceleratorOnNextClickAction());
modeController.addAction(new ShowNotesInMapAction());
// userInputListenerFactory.getMenuBuilder().setAcceleratorChangeListener(fButtonToolBar);
userInputListenerFactory.getAcceleratorManager().addAcceleratorChangeListener(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);
final MToolbarContributor menuContributor = new MToolbarContributor(uiFactory);
modeController.addExtension(MUIFactory.class, uiFactory);
modeController.addMenuContributor(menuContributor);
new CloneStateIconSupplier().registerStateIconProvider();
// 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.clipboard.mindmapmode.MClipboardController in project freeplane by freeplane.
the class HeadlessMModeControllerFactory method createStandardControllers.
private void createStandardControllers() {
final Controller controller = Controller.getCurrentController();
modeController = new MModeController(controller);
controller.addModeController(modeController);
controller.selectModeForBuild(modeController);
new MMapController(modeController);
final MFileManager fileManager = new MFileManager();
UrlManager.install(fileManager);
MMapIO.install(modeController);
controller.getMapViewManager().addMapViewChangeListener(fileManager);
IconController.install(new MIconController(modeController));
new ProgressFactory().installActions(modeController);
EdgeController.install(new MEdgeController(modeController));
CloudController.install(new MCloudController(modeController));
NoteController.install(new MNoteController(modeController));
final MTextController textController = new MTextController(modeController);
TextController.install(textController);
LinkController.install(new MLinkController());
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.clipboard.mindmapmode.MClipboardController in project freeplane by freeplane.
the class NodeProxy method pasteAsClone.
@Override
public void pasteAsClone() {
final MClipboardController clipboardController = (MClipboardController) ClipboardController.getController();
clipboardController.addClone(clipboardController.getClipboardContents(), getDelegate());
}
use of org.freeplane.features.clipboard.mindmapmode.MClipboardController in project freeplane by freeplane.
the class NodeProxy method appendBranchImpl.
private Proxy.Node appendBranchImpl(Proxy.NodeRO node, boolean withChildren) {
final MClipboardController clipboardController = (MClipboardController) ClipboardController.getController();
final NodeModel newNodeModel = clipboardController.duplicate(((NodeProxy) node).getDelegate(), withChildren);
final MMapController mapController = (MMapController) getModeController().getMapController();
mapController.insertNode(newNodeModel, getDelegate());
return new NodeProxy(newNodeModel, getScriptContext());
}
use of org.freeplane.features.clipboard.mindmapmode.MClipboardController in project freeplane by freeplane.
the class MNodeDropListener method drop.
public void drop(final DropTargetDropEvent dtde) {
try {
int dropAction = dtde.getDropAction();
final Transferable t = dtde.getTransferable();
final MainView mainView = (MainView) dtde.getDropTargetContext().getComponent();
final NodeView targetNodeView = mainView.getNodeView();
final MapView mapView = targetNodeView.getMap();
mapView.select();
final NodeModel targetNode = targetNodeView.getModel();
final Controller controller = Controller.getCurrentController();
if (dtde.isLocalTransfer() && t.isDataFlavorSupported(MindMapNodesSelection.dropActionFlavor)) {
final String sourceAction = (String) t.getTransferData(MindMapNodesSelection.dropActionFlavor);
if (sourceAction.equals("LINK")) {
dropAction = DnDConstants.ACTION_LINK;
}
if (sourceAction.equals("COPY")) {
dropAction = DnDConstants.ACTION_COPY;
}
}
mainView.setDraggedOver(NodeView.DRAGGED_OVER_NO);
mainView.repaint();
if (dtde.isLocalTransfer() && (dropAction == DnDConstants.ACTION_MOVE) && !isDropAcceptable(dtde)) {
dtde.rejectDrop();
return;
}
final boolean dropAsSibling = mainView.dropAsSibling(dtde.getLocation().getX());
ModeController modeController = controller.getModeController();
final MMapController mapController = (MMapController) modeController.getMapController();
if ((dropAction == DnDConstants.ACTION_MOVE || dropAction == DnDConstants.ACTION_COPY)) {
final NodeModel parent = dropAsSibling ? targetNode.getParentNode() : targetNode;
if (!mapController.isWriteable(parent)) {
dtde.rejectDrop();
final String message = TextUtils.getText("node_is_write_protected");
UITools.errorMessage(message);
return;
}
}
final boolean isLeft = mainView.dropLeft(dtde.getLocation().getX());
if (!dtde.isLocalTransfer()) {
dtde.acceptDrop(DnDConstants.ACTION_COPY);
((MClipboardController) ClipboardController.getController()).paste(t, targetNode, dropAsSibling, isLeft, dropAction);
dtde.dropComplete(true);
return;
}
dtde.acceptDrop(dropAction);
if (dropAction == DnDConstants.ACTION_LINK) {
int yesorno = JOptionPane.YES_OPTION;
if (controller.getSelection().size() >= 5) {
yesorno = JOptionPane.showConfirmDialog(controller.getViewController().getContentPane(), TextUtils.getText("lots_of_links_warning"), Integer.toString(controller.getSelection().size()) + " links to the same node", JOptionPane.YES_NO_OPTION);
}
if (yesorno == JOptionPane.YES_OPTION) {
for (final Iterator<NodeModel> it = controller.getSelection().getSelection().iterator(); it.hasNext(); ) {
final NodeModel selectedNodeModel = (it.next());
((MLinkController) LinkController.getController(modeController)).addConnector(selectedNodeModel, targetNode);
}
}
} else {
Transferable trans = null;
final Collection<NodeModel> selecteds = mapController.getSelectedNodes();
if (DnDConstants.ACTION_MOVE == dropAction) {
NodeModel actualNode = targetNode;
do {
if (selecteds.contains(actualNode)) {
final String message = TextUtils.getText("cannot_move_to_child");
JOptionPane.showMessageDialog(controller.getViewController().getContentPane(), message, "Freeplane", JOptionPane.WARNING_MESSAGE);
dtde.dropComplete(true);
return;
}
actualNode = (actualNode.isRoot()) ? null : actualNode.getParentNode();
} while (actualNode != null);
final NodeModel[] array = selecteds.toArray(new NodeModel[selecteds.size()]);
final List<NodeModel> sortedSelection = controller.getSelection().getSortedSelection(true);
for (final NodeModel node : sortedSelection) {
boolean changeSide = isLeft != node.isLeft();
if (dropAsSibling) {
mapController.moveNodeBefore(node, targetNode, isLeft, changeSide);
} else {
mapController.moveNodeAsChild(node, targetNode, isLeft, changeSide);
}
}
if (dropAsSibling || !targetNode.isFolded())
controller.getSelection().replaceSelection(array);
else
controller.getSelection().selectAsTheOnlyOneSelected(targetNode);
} else {
trans = ClipboardController.getController().copy(controller.getSelection());
((MClipboardController) ClipboardController.getController()).paste(trans, targetNode, dropAsSibling, isLeft);
controller.getSelection().selectAsTheOnlyOneSelected(targetNode);
}
}
} catch (final Exception e) {
LogUtils.severe("Drop exception:", e);
dtde.dropComplete(false);
return;
}
dtde.dropComplete(true);
}
Aggregations