Search in sources :

Example 1 with IUserInputListenerFactory

use of org.freeplane.core.ui.IUserInputListenerFactory in project freeplane by freeplane.

the class SaveAcceleratorPresetsAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final String keyset = JOptionPane.showInputDialog(TextUtils.getText("enter_keyset_name"));
    if (keyset == null || keyset.equals("")) {
        return;
    }
    final File acceleratorsUserDirectory = LoadAcceleratorPresetsAction.getAcceleratorsUserDirectory();
    final File keysetFile = new File(acceleratorsUserDirectory, keyset + ".properties");
    if (keysetFile.exists()) {
        final int confirm = JOptionPane.showConfirmDialog(UITools.getMenuComponent(), TextUtils.getText("overwrite_keyset_question"), "Freeplane", JOptionPane.YES_NO_OPTION);
        if (confirm != JOptionPane.YES_OPTION) {
            return;
        }
    }
    try {
        acceleratorsUserDirectory.mkdirs();
        final OutputStream output = new BufferedOutputStream(new FileOutputStream(keysetFile));
        final IUserInputListenerFactory userInputListenerFactory = Controller.getCurrentModeController().getUserInputListenerFactory();
        ResourceController.getResourceController().getAcceleratorManager().storeAcceleratorPreset(output);
        output.close();
        userInputListenerFactory.rebuildMenus("load_accelerator_presets");
    } catch (final IOException e1) {
        UITools.errorMessage(TextUtils.getText("can_not_save_key_set"));
    }
}
Also used : IUserInputListenerFactory(org.freeplane.core.ui.IUserInputListenerFactory) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) BufferedOutputStream(java.io.BufferedOutputStream) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) File(java.io.File) BufferedOutputStream(java.io.BufferedOutputStream)

Example 2 with IUserInputListenerFactory

use of org.freeplane.core.ui.IUserInputListenerFactory in project freeplane by freeplane.

the class NodeView method setMainView.

void setMainView(final MainView newMainView) {
    if (contentPane != null) {
        assert (contentPane.getParent() == this);
        if (mainView != null)
            removeContent(MAIN_VIEWER_POSITION);
        addContent(newMainView, MAIN_VIEWER_POSITION);
        assert (contentPane.getParent() == this);
    } else if (mainView != null) {
        final Container c = mainView.getParent();
        int i;
        for (i = c.getComponentCount() - 1; i >= 0 && mainView != c.getComponent(i); i--) {
            ;
        }
        c.remove(i);
        c.add(newMainView, i);
    } else {
        add(newMainView);
    }
    mainView = newMainView;
    ModeController modeController = getMap().getModeController();
    if (modeController.canEdit(getModel())) {
        final IUserInputListenerFactory userInputListenerFactory = modeController.getUserInputListenerFactory();
        mainView.addMouseListener(userInputListenerFactory.getNodeMouseMotionListener());
        mainView.addMouseMotionListener(userInputListenerFactory.getNodeMouseMotionListener());
        mainView.addMouseWheelListener(userInputListenerFactory.getNodeMouseWheelListener());
        mainView.addKeyListener(userInputListenerFactory.getNodeKeyListener());
        addDragListener(userInputListenerFactory.getNodeDragListener());
        addDropListener(userInputListenerFactory.getNodeDropTargetListener());
    }
}
Also used : Container(java.awt.Container) IUserInputListenerFactory(org.freeplane.core.ui.IUserInputListenerFactory) ModeController(org.freeplane.features.mode.ModeController)

Example 3 with IUserInputListenerFactory

use of org.freeplane.core.ui.IUserInputListenerFactory in project freeplane by freeplane.

the class LastOpenedList method updateMenus.

private void updateMenus() {
    final IUserInputListenerFactory userInputListenerFactory = Controller.getCurrentModeController().getUserInputListenerFactory();
    userInputListenerFactory.rebuildMenus("lastOpenedMaps");
}
Also used : IUserInputListenerFactory(org.freeplane.core.ui.IUserInputListenerFactory)

Example 4 with IUserInputListenerFactory

use of org.freeplane.core.ui.IUserInputListenerFactory in project freeplane by freeplane.

the class MenuBuilderAcceptanceTest method setup.

@BeforeClass
public static void setup() {
    final IUserInputListenerFactory userInputListenerFactory = mock(IUserInputListenerFactory.class);
    when(userInputListenerFactory.getToolBar("/main_toolbar")).thenReturn(new JToolBar());
    when(userInputListenerFactory.getNodePopupMenu()).thenReturn(new JPopupMenu());
    when(userInputListenerFactory.getMapPopup()).thenReturn(new JPopupMenu());
    when(userInputListenerFactory.getMenuBar()).thenReturn(TestMenuBarFactory.createFreeplaneMenuBar());
    final PhaseProcessor buildProcessor = new MenuBuildProcessFactory(userInputListenerFactory, Controller.getCurrentModeController(), new FreeplaneResourceAccessor(), mock(IAcceleratorMap.class), new EntriesForAction(), Collections.<BuildPhaseListener>emptyList()).getBuildProcessor();
    final String menuResource = "/xml/mindmapmodemenu.xml";
    final InputStream resource = MenuBuilderAcceptanceTest.class.getResourceAsStream(menuResource);
    final BufferedReader reader = new BufferedReader(new InputStreamReader(resource));
    menuStructure = XmlEntryStructureBuilder.buildMenuStructure(reader);
    buildProcessor.build(menuStructure);
}
Also used : BuildPhaseListener(org.freeplane.core.ui.menubuilders.generic.BuildPhaseListener) InputStreamReader(java.io.InputStreamReader) IUserInputListenerFactory(org.freeplane.core.ui.IUserInputListenerFactory) EntriesForAction(org.freeplane.core.ui.menubuilders.action.EntriesForAction) InputStream(java.io.InputStream) PhaseProcessor(org.freeplane.core.ui.menubuilders.generic.PhaseProcessor) BufferedReader(java.io.BufferedReader) JToolBar(javax.swing.JToolBar) JPopupMenu(javax.swing.JPopupMenu) MenuBuildProcessFactory(org.freeplane.core.ui.menubuilders.menu.MenuBuildProcessFactory) BeforeClass(org.junit.BeforeClass)

Example 5 with IUserInputListenerFactory

use of org.freeplane.core.ui.IUserInputListenerFactory in project freeplane by freeplane.

the class MLogicalStyleController method initM.

public void initM() {
    final ModeController modeController = Controller.getCurrentModeController();
    modeController.getMapController().addNodeChangeListener(new StyleRemover());
    modeController.registerExtensionCopier(new ExtensionCopier());
    modeController.addAction(new RedefineStyleAction());
    modeController.addAction(new NewUserStyleAction());
    modeController.addAction(new ManageMapConditionalStylesAction());
    modeController.addAction(new ManageNodeConditionalStylesAction());
    modeController.addAction(new CopyStyleExtensionsAction());
    if (modeController.getModeName().equals("MindMap")) {
        modeController.addAction(new MapBackgroundColorAction());
        modeController.addAction(new MapBackgroundImageAction());
        modeController.addAction(new MapBackgroundClearAction());
        modeController.addAction(new SetBooleanMapPropertyAction(MapStyle.FIT_TO_VIEWPORT));
        modeController.addAction(new CopyMapStylesAction());
    }
    if (!modeController.getController().getViewController().isHeadless()) {
        modeController.addUiBuilder(Phase.ACTIONS, "style_actions", new StyleMenuBuilder(modeController), new ChildActionEntryRemover(modeController));
        final IUserInputListenerFactory userInputListenerFactory = modeController.getUserInputListenerFactory();
        Controller.getCurrentController().getMapViewManager().addMapSelectionListener(new IMapSelectionListener() {

            public void beforeMapChange(final MapModel oldMap, final MapModel newMap) {
            }

            public void afterMapChange(final MapModel oldMap, final MapModel newMap) {
                userInputListenerFactory.rebuildMenus(STYLE_ACTIONS);
            }
        });
        final MapController mapController = modeController.getMapController();
        mapController.addMapChangeListener(new IMapChangeListener() {

            public void onPreNodeMoved(NodeMoveEvent nodeMoveEvent) {
            }

            public void onPreNodeDelete(NodeDeletionEvent nodeDeletionEvent) {
            }

            public void onNodeMoved(NodeMoveEvent nodeMoveEvent) {
            }

            public void onNodeInserted(final NodeModel parent, final NodeModel child, final int newIndex) {
            }

            public void onNodeDeleted(NodeDeletionEvent nodeDeletionEvent) {
            }

            public void mapChanged(final MapChangeEvent event) {
                if (event.getProperty().equals(MapStyle.MAP_STYLES)) {
                    userInputListenerFactory.rebuildMenus(STYLE_ACTIONS);
                }
            }
        });
        mapController.addNodeSelectionListener(new INodeSelectionListener() {

            public void onSelect(final NodeModel node) {
                selectActions();
            }

            public void onDeselect(final NodeModel node) {
            }
        });
    }
}
Also used : IMapChangeListener(org.freeplane.features.map.IMapChangeListener) ChildActionEntryRemover(org.freeplane.core.ui.menubuilders.generic.ChildActionEntryRemover) MapBackgroundImageAction(org.freeplane.view.swing.features.filepreview.MapBackgroundImageAction) IExtensionCopier(org.freeplane.features.map.IExtensionCopier) ModeController(org.freeplane.features.mode.ModeController) MapModel(org.freeplane.features.map.MapModel) NodeModel(org.freeplane.features.map.NodeModel) NodeDeletionEvent(org.freeplane.features.map.NodeDeletionEvent) MapBackgroundClearAction(org.freeplane.view.swing.features.filepreview.MapBackgroundClearAction) MapChangeEvent(org.freeplane.features.map.MapChangeEvent) IMapSelectionListener(org.freeplane.features.map.IMapSelectionListener) IUserInputListenerFactory(org.freeplane.core.ui.IUserInputListenerFactory) SetBooleanMapPropertyAction(org.freeplane.features.styles.SetBooleanMapPropertyAction) MapController(org.freeplane.features.map.MapController) NodeMoveEvent(org.freeplane.features.map.NodeMoveEvent) INodeSelectionListener(org.freeplane.features.map.INodeSelectionListener)

Aggregations

IUserInputListenerFactory (org.freeplane.core.ui.IUserInputListenerFactory)12 JToolBar (javax.swing.JToolBar)3 FreeplaneMenuBar (org.freeplane.core.ui.components.FreeplaneMenuBar)2 EntriesForAction (org.freeplane.core.ui.menubuilders.action.EntriesForAction)2 Entry (org.freeplane.core.ui.menubuilders.generic.Entry)2 EntryAccessor (org.freeplane.core.ui.menubuilders.generic.EntryAccessor)2 FreeplaneActions (org.freeplane.features.mode.FreeplaneActions)2 ModeController (org.freeplane.features.mode.ModeController)2 Before (org.junit.Before)2 Test (org.junit.Test)2 Component (java.awt.Component)1 Container (java.awt.Container)1 BufferedOutputStream (java.io.BufferedOutputStream)1 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 OutputStream (java.io.OutputStream)1