Search in sources :

Example 1 with NodeNewFolderAction

use of org.freeplane.plugin.workspace.actions.NodeNewFolderAction in project freeplane by freeplane.

the class MModeWorkspaceController method setupActions.

private void setupActions(ModeController modeController) {
    WorkspaceController.addAction(new WorkspaceExpandAction());
    WorkspaceController.addAction(new WorkspaceCollapseAction());
    WorkspaceController.addAction(new WorkspaceNewProjectAction());
    WorkspaceController.addAction(new WorkspaceImportProjectAction());
    WorkspaceController.addAction(new NodeNewFolderAction());
    WorkspaceController.addAction(new NodeNewLinkAction());
    WorkspaceController.addAction(new NodeOpenLocationAction());
    // WORKSPACE - fixed: #332
    WorkspaceController.addAction(new NodeCutAction());
    WorkspaceController.addAction(new NodeCopyAction());
    WorkspaceController.addAction(new NodePasteAction());
    WorkspaceController.addAction(new NodeRenameAction());
    WorkspaceController.addAction(new NodeRemoveAction());
    WorkspaceController.addAction(new NodeRefreshAction());
    WorkspaceController.addAction(new WorkspaceRemoveProjectAction());
    WorkspaceController.replaceAction(new WorkspaceNewMapAction());
    WorkspaceController.addAction(new FileNodeNewMindmapAction());
    WorkspaceController.addAction(new FileNodeNewFileAction());
    WorkspaceController.addAction(new FileNodeDeleteAction());
    WorkspaceController.addAction(new PhysicalFolderSortOrderAction());
}
Also used : NodePasteAction(org.freeplane.plugin.workspace.actions.NodePasteAction) PhysicalFolderSortOrderAction(org.freeplane.plugin.workspace.actions.PhysicalFolderSortOrderAction) WorkspaceExpandAction(org.freeplane.plugin.workspace.actions.WorkspaceExpandAction) NodeRenameAction(org.freeplane.plugin.workspace.actions.NodeRenameAction) WorkspaceNewMapAction(org.freeplane.plugin.workspace.actions.WorkspaceNewMapAction) NodeRemoveAction(org.freeplane.plugin.workspace.actions.NodeRemoveAction) FileNodeNewMindmapAction(org.freeplane.plugin.workspace.actions.FileNodeNewMindmapAction) FileNodeDeleteAction(org.freeplane.plugin.workspace.actions.FileNodeDeleteAction) NodeCutAction(org.freeplane.plugin.workspace.actions.NodeCutAction) FileNodeNewFileAction(org.freeplane.plugin.workspace.actions.FileNodeNewFileAction) WorkspaceNewProjectAction(org.freeplane.plugin.workspace.actions.WorkspaceNewProjectAction) WorkspaceCollapseAction(org.freeplane.plugin.workspace.actions.WorkspaceCollapseAction) NodeRefreshAction(org.freeplane.plugin.workspace.actions.NodeRefreshAction) WorkspaceImportProjectAction(org.freeplane.plugin.workspace.actions.WorkspaceImportProjectAction) NodeNewFolderAction(org.freeplane.plugin.workspace.actions.NodeNewFolderAction) NodeNewLinkAction(org.freeplane.plugin.workspace.actions.NodeNewLinkAction) WorkspaceRemoveProjectAction(org.freeplane.plugin.workspace.actions.WorkspaceRemoveProjectAction) NodeOpenLocationAction(org.freeplane.plugin.workspace.actions.NodeOpenLocationAction) NodeCopyAction(org.freeplane.plugin.workspace.actions.NodeCopyAction)

Example 2 with NodeNewFolderAction

use of org.freeplane.plugin.workspace.actions.NodeNewFolderAction in project freeplane by freeplane.

the class MModeWorkspaceController method setupController.

private void setupController(ModeController modeController) {
    modeController.removeExtension(UrlManager.class);
    UrlManager.install(new MModeWorkspaceUrlManager());
    modeController.removeExtension(LinkController.class);
    LinkController.install(MModeWorkspaceLinkController.getController());
    // add link type entry to the chooser
    MModeWorkspaceLinkController.getController().prepareOptionPanelBuilder(((MModeController) modeController).getOptionPanelBuilder());
    modeController.addINodeViewLifeCycleListener(new INodeViewLifeCycleListener() {

        public void onViewCreated(Container nodeView) {
            NodeView node = (NodeView) nodeView;
            final DropTarget dropTarget = new DropTarget(node.getMainView(), new MNodeDropListener() {

                public void drop(final DropTargetDropEvent dtde) {
                    DropTargetDropEvent evt = dtde;
                    if (dtde.getTransferable().isDataFlavorSupported(WorkspaceTransferable.WORKSPACE_NODE_FLAVOR)) {
                        evt = new DropTargetDropEvent(dtde.getDropTargetContext(), dtde.getLocation(), dtde.getDropAction(), dtde.getSourceActions(), false);
                    }
                    super.drop(evt);
                }
            });
            dropTarget.setActive(true);
        }

        public void onViewRemoved(Container nodeView) {
        }
    });
    modeController.addMenuContributor(new IMenuContributor() {

        public void updateMenus(ModeController modeController, MenuBuilder builder) {
            final String MENU_PROJECT_KEY = "/menu_bar/project";
            // insert project menu into main menu
            JMenu projectMenu = new JMenu(TextUtils.getText("menu.project.entry.label"));
            projectMenu.setMnemonic('o');
            builder.addMenuItem("/menu_bar/format", projectMenu, MENU_PROJECT_KEY, MenuBuilder.AFTER);
            builder.addAction(MENU_PROJECT_KEY, WorkspaceController.getAction(WorkspaceNewProjectAction.KEY), MenuBuilder.AS_CHILD);
            builder.addAction(MENU_PROJECT_KEY, WorkspaceController.getAction(WorkspaceImportProjectAction.KEY), MenuBuilder.AS_CHILD);
            builder.addSeparator(MENU_PROJECT_KEY, MenuBuilder.AS_CHILD);
            final String MENU_PROJECT_ADD_KEY = builder.getMenuKey(MENU_PROJECT_KEY, "new");
            final JMenu addMenu = new JMenu(TextUtils.getText("workspace.action.new.label"));
            builder.addMenuItem(MENU_PROJECT_KEY, addMenu, MENU_PROJECT_ADD_KEY, MenuBuilder.AS_CHILD);
            builder.addAction(MENU_PROJECT_ADD_KEY, new NodeNewFolderAction(), MenuBuilder.AS_CHILD);
            builder.addAction(MENU_PROJECT_ADD_KEY, new NodeNewLinkAction(), MenuBuilder.AS_CHILD);
            final WorkspaceRemoveProjectAction rmProjectAction = new WorkspaceRemoveProjectAction();
            builder.addAction(MENU_PROJECT_KEY, rmProjectAction, MenuBuilder.AS_CHILD);
            builder.addSeparator(MENU_PROJECT_KEY, MenuBuilder.AS_CHILD);
            setDefaultAccelerator(builder.getShortcutKey(builder.getMenuKey(MENU_PROJECT_KEY, WorkspaceProjectOpenLocationAction.KEY)), "control alt L");
            final WorkspaceProjectOpenLocationAction openLocAction = new WorkspaceProjectOpenLocationAction();
            builder.addAction(MENU_PROJECT_KEY, openLocAction, MenuBuilder.AS_CHILD);
            projectMenu.getPopupMenu().addPopupMenuListener(new PopupMenuListener() {

                public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
                    rmProjectAction.setEnabled();
                    openLocAction.setEnabled();
                    if (WorkspaceController.getCurrentProject() == null) {
                        addMenu.setEnabled(false);
                    } else {
                        addMenu.setEnabled(true);
                    }
                }

                public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
                }

                public void popupMenuCanceled(PopupMenuEvent e) {
                }
            });
        }

        private void setDefaultAccelerator(final String shortcutKey, String accelerator) {
            if (accelerator != null) {
                if (null == ResourceController.getResourceController().getProperty(shortcutKey, null)) {
                    if (Compat.isMacOsX()) {
                        accelerator = accelerator.replaceFirst("CONTROL", "META").replaceFirst("control", "meta");
                    }
                    ResourceController.getResourceController().setDefaultProperty(shortcutKey, accelerator);
                }
            }
        }
    });
}
Also used : PopupMenuListener(javax.swing.event.PopupMenuListener) ModeController(org.freeplane.features.mode.ModeController) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) NodeView(org.freeplane.view.swing.map.NodeView) MenuBuilder(org.freeplane.core.ui.MenuBuilder) PopupMenuEvent(javax.swing.event.PopupMenuEvent) INodeViewLifeCycleListener(org.freeplane.features.ui.INodeViewLifeCycleListener) Container(java.awt.Container) IMenuContributor(org.freeplane.core.ui.IMenuContributor) NodeNewFolderAction(org.freeplane.plugin.workspace.actions.NodeNewFolderAction) NodeNewLinkAction(org.freeplane.plugin.workspace.actions.NodeNewLinkAction) MNodeDropListener(org.freeplane.view.swing.ui.mindmapmode.MNodeDropListener) WorkspaceRemoveProjectAction(org.freeplane.plugin.workspace.actions.WorkspaceRemoveProjectAction) DropTarget(java.awt.dnd.DropTarget) WorkspaceProjectOpenLocationAction(org.freeplane.plugin.workspace.actions.WorkspaceProjectOpenLocationAction) DropTargetDropEvent(java.awt.dnd.DropTargetDropEvent) JMenu(javax.swing.JMenu)

Aggregations

NodeNewFolderAction (org.freeplane.plugin.workspace.actions.NodeNewFolderAction)2 NodeNewLinkAction (org.freeplane.plugin.workspace.actions.NodeNewLinkAction)2 WorkspaceRemoveProjectAction (org.freeplane.plugin.workspace.actions.WorkspaceRemoveProjectAction)2 Container (java.awt.Container)1 DropTarget (java.awt.dnd.DropTarget)1 DropTargetDropEvent (java.awt.dnd.DropTargetDropEvent)1 JMenu (javax.swing.JMenu)1 PopupMenuEvent (javax.swing.event.PopupMenuEvent)1 PopupMenuListener (javax.swing.event.PopupMenuListener)1 IMenuContributor (org.freeplane.core.ui.IMenuContributor)1 MenuBuilder (org.freeplane.core.ui.MenuBuilder)1 ModeController (org.freeplane.features.mode.ModeController)1 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)1 INodeViewLifeCycleListener (org.freeplane.features.ui.INodeViewLifeCycleListener)1 FileNodeDeleteAction (org.freeplane.plugin.workspace.actions.FileNodeDeleteAction)1 FileNodeNewFileAction (org.freeplane.plugin.workspace.actions.FileNodeNewFileAction)1 FileNodeNewMindmapAction (org.freeplane.plugin.workspace.actions.FileNodeNewMindmapAction)1 NodeCopyAction (org.freeplane.plugin.workspace.actions.NodeCopyAction)1 NodeCutAction (org.freeplane.plugin.workspace.actions.NodeCutAction)1 NodeOpenLocationAction (org.freeplane.plugin.workspace.actions.NodeOpenLocationAction)1