Search in sources :

Example 1 with JToolbarComponentBuilder

use of org.freeplane.core.ui.menubuilders.menu.JToolbarComponentBuilder in project freeplane by freeplane.

the class JToolbarComponentBuilderTest method createsToolbarButtonWithAction.

@Test
public void createsToolbarButtonWithAction() {
    Entry actionEntry = new Entry();
    final AFreeplaneAction action = Mockito.mock(AFreeplaneAction.class);
    new EntryAccessor().setAction(actionEntry, action);
    Entry toolbarEntry = new Entry();
    final FreeplaneToolBar toolbar = new FreeplaneToolBar("toolbar", SwingConstants.HORIZONTAL);
    new EntryAccessor().setComponent(toolbarEntry, toolbar);
    toolbarEntry.addChild(actionEntry);
    final JToolbarComponentBuilder toolbarActionGroupBuilder = new JToolbarComponentBuilder();
    toolbarActionGroupBuilder.visit(actionEntry);
    JButton button = (JButton) new EntryAccessor().getComponent(actionEntry);
    assertThat(button.getAction(), CoreMatchers.<Action>equalTo(action));
    assertThat(button.getParent(), CoreMatchers.equalTo((Container) toolbar));
}
Also used : Entry(org.freeplane.core.ui.menubuilders.generic.Entry) AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) Container(java.awt.Container) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) FreeplaneToolBar(org.freeplane.core.ui.components.FreeplaneToolBar) JButton(javax.swing.JButton) JToolbarComponentBuilder(org.freeplane.core.ui.menubuilders.menu.JToolbarComponentBuilder) Test(org.junit.Test)

Example 2 with JToolbarComponentBuilder

use of org.freeplane.core.ui.menubuilders.menu.JToolbarComponentBuilder 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;
// }
// });
}
Also used : MUIFactory(org.freeplane.features.styles.mindmapmode.MUIFactory) MAttributeController(org.freeplane.features.attribute.mindmapmode.MAttributeController) ProgressFactory(org.freeplane.view.swing.features.progress.mindmapmode.ProgressFactory) MMapController(org.freeplane.features.map.mindmapmode.MMapController) IKeyStrokeProcessor(org.freeplane.core.ui.IKeyStrokeProcessor) Container(java.awt.Container) RootPaneContainer(javax.swing.RootPaneContainer) MClipboardController(org.freeplane.features.clipboard.mindmapmode.MClipboardController) MEdgeController(org.freeplane.features.edge.mindmapmode.MEdgeController) ExportController(org.freeplane.features.export.mindmapmode.ExportController) MCloudController(org.freeplane.features.cloud.mindmapmode.MCloudController) SetAcceleratorOnNextClickAction(org.freeplane.core.ui.SetAcceleratorOnNextClickAction) MIconController(org.freeplane.features.icon.mindmapmode.MIconController) UserInputListenerFactory(org.freeplane.view.swing.ui.UserInputListenerFactory) RootPaneContainer(javax.swing.RootPaneContainer) EditAttributesAction(org.freeplane.view.swing.map.attribute.EditAttributesAction) Box(javax.swing.Box) MNoteController(org.freeplane.features.note.mindmapmode.MNoteController) MLinkController(org.freeplane.features.link.mindmapmode.MLinkController) FreeplaneToolBar(org.freeplane.core.ui.components.FreeplaneToolBar) KeyStroke(javax.swing.KeyStroke) RevisionPlugin(org.freeplane.features.nodestyle.mindmapmode.RevisionPlugin) MNodeDropListener(org.freeplane.view.swing.ui.mindmapmode.MNodeDropListener) ShowNotesInMapAction(org.freeplane.view.swing.map.ShowNotesInMapAction) JToolbarComponentBuilder(org.freeplane.core.ui.menubuilders.menu.JToolbarComponentBuilder) ComponentBuilder(org.freeplane.core.ui.menubuilders.action.ComponentBuilder) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) MLocationController(org.freeplane.features.nodelocation.mindmapmode.MLocationController) MMapMouseListener(org.freeplane.view.swing.ui.mindmapmode.MMapMouseListener) JTabbedPane(javax.swing.JTabbedPane) MFileManager(org.freeplane.features.url.mindmapmode.MFileManager) IEditHandler(org.freeplane.core.ui.IEditHandler) KeyEvent(java.awt.event.KeyEvent) FoldingController(org.freeplane.features.map.FoldingController) Entry(org.freeplane.core.ui.menubuilders.generic.Entry) MNodeMotionListener(org.freeplane.view.swing.ui.mindmapmode.MNodeMotionListener) MNodeMouseWheelListener(org.freeplane.view.swing.ui.mindmapmode.MNodeMouseWheelListener) MLogicalStyleController(org.freeplane.features.styles.mindmapmode.MLogicalStyleController) FrameController(org.freeplane.features.ui.FrameController) ViewerController(org.freeplane.view.swing.features.filepreview.ViewerController) MTextController(org.freeplane.features.text.mindmapmode.MTextController) MEncryptionController(org.freeplane.features.encrypt.mindmapmode.MEncryptionController) ChangeNodeLevelController(org.freeplane.features.map.mindmapmode.ChangeNodeLevelController) MMapController(org.freeplane.features.map.mindmapmode.MMapController) MAttributeController(org.freeplane.features.attribute.mindmapmode.MAttributeController) FilterController(org.freeplane.features.filter.FilterController) IconController(org.freeplane.features.icon.IconController) Controller(org.freeplane.features.mode.Controller) MLinkController(org.freeplane.features.link.mindmapmode.MLinkController) PresentationController(org.freeplane.features.presentations.mindmapmode.PresentationController) MEdgeController(org.freeplane.features.edge.mindmapmode.MEdgeController) ResourceController(org.freeplane.core.resources.ResourceController) ViewController(org.freeplane.features.ui.ViewController) CloudController(org.freeplane.features.cloud.CloudController) MCloudController(org.freeplane.features.cloud.mindmapmode.MCloudController) FrameController(org.freeplane.features.ui.FrameController) AutomaticLayoutController(org.freeplane.features.styles.AutomaticLayoutController) AttributeController(org.freeplane.features.attribute.AttributeController) MNoteController(org.freeplane.features.note.mindmapmode.MNoteController) MLogicalStyleController(org.freeplane.features.styles.mindmapmode.MLogicalStyleController) EdgeController(org.freeplane.features.edge.EdgeController) MapController(org.freeplane.features.map.MapController) MIconController(org.freeplane.features.icon.mindmapmode.MIconController) FoldingController(org.freeplane.features.map.FoldingController) NodeStyleController(org.freeplane.features.nodestyle.NodeStyleController) SpellCheckerController(org.freeplane.features.spellchecker.mindmapmode.SpellCheckerController) ClipboardController(org.freeplane.features.clipboard.ClipboardController) NoteController(org.freeplane.features.note.NoteController) ExportController(org.freeplane.features.export.mindmapmode.ExportController) LogicalStyleController(org.freeplane.features.styles.LogicalStyleController) LinkController(org.freeplane.features.link.LinkController) LocationController(org.freeplane.features.nodelocation.LocationController) MLocationController(org.freeplane.features.nodelocation.mindmapmode.MLocationController) MNodeStyleController(org.freeplane.features.nodestyle.mindmapmode.MNodeStyleController) MClipboardController(org.freeplane.features.clipboard.mindmapmode.MClipboardController) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) MNodeDragListener(org.freeplane.view.swing.ui.mindmapmode.MNodeDragListener) FButtonBar(org.freeplane.core.ui.components.FButtonBar) JPopupMenu(javax.swing.JPopupMenu) MMapController(org.freeplane.features.map.mindmapmode.MMapController) MapController(org.freeplane.features.map.MapController) ToggleToolbarAction(org.freeplane.features.ui.ToggleToolbarAction) MNodeStyleController(org.freeplane.features.nodestyle.mindmapmode.MNodeStyleController) IMouseListener(org.freeplane.core.ui.IMouseListener) ComponentProvider(org.freeplane.core.ui.menubuilders.menu.ComponentProvider) JToolbarComponentBuilder(org.freeplane.core.ui.menubuilders.menu.JToolbarComponentBuilder) DefaultNodeKeyListener(org.freeplane.view.swing.ui.DefaultNodeKeyListener) JRootPane(javax.swing.JRootPane) MTextController(org.freeplane.features.text.mindmapmode.MTextController) CollapseableBoxBuilder(org.freeplane.features.ui.CollapseableBoxBuilder)

Example 3 with JToolbarComponentBuilder

use of org.freeplane.core.ui.menubuilders.menu.JToolbarComponentBuilder in project freeplane by freeplane.

the class MenuBuilderIntegrationTest method setup.

@Before
public void setup() {
    freeplaneActions = mock(FreeplaneActions.class);
    recursiveMenuStructureBuilder = new RecursiveMenuStructureProcessor();
    recursiveMenuStructureBuilder.setDefaultBuilderPair(EntryVisitor.EMTPY, EntryVisitor.EMTPY);
    final IUserInputListenerFactory userInputListenerFactory = mock(IUserInputListenerFactory.class);
    toolbar = new JToolBar();
    when(userInputListenerFactory.getToolBar("/main_toolbar")).thenReturn(toolbar);
    recursiveMenuStructureBuilder.addBuilder("toolbar", new JToolbarBuilder(userInputListenerFactory));
    recursiveMenuStructureBuilder.setSubtreeDefaultBuilderPair("toolbar", "toolbar.action");
    recursiveMenuStructureBuilder.addBuilderPair("toolbar.action", new BuilderDestroyerPair(new JToolbarComponentBuilder(), null));
}
Also used : RecursiveMenuStructureProcessor(org.freeplane.core.ui.menubuilders.generic.RecursiveMenuStructureProcessor) FreeplaneActions(org.freeplane.features.mode.FreeplaneActions) IUserInputListenerFactory(org.freeplane.core.ui.IUserInputListenerFactory) BuilderDestroyerPair(org.freeplane.core.ui.menubuilders.generic.BuilderDestroyerPair) JToolbarBuilder(org.freeplane.core.ui.menubuilders.menu.JToolbarBuilder) JToolbarComponentBuilder(org.freeplane.core.ui.menubuilders.menu.JToolbarComponentBuilder) JToolBar(javax.swing.JToolBar) Before(org.junit.Before)

Example 4 with JToolbarComponentBuilder

use of org.freeplane.core.ui.menubuilders.menu.JToolbarComponentBuilder in project freeplane by freeplane.

the class JToolbarComponentBuilderTest method createsToolbarButtonWithSelectableAction.

@Test
public void createsToolbarButtonWithSelectableAction() {
    Entry actionEntry = new Entry();
    final AFreeplaneAction action = Mockito.mock(AFreeplaneAction.class);
    when(action.isSelectable()).thenReturn(true);
    new EntryAccessor().setAction(actionEntry, action);
    Entry toolbarEntry = new Entry();
    final FreeplaneToolBar toolbar = new FreeplaneToolBar("toolbar", SwingConstants.HORIZONTAL);
    new EntryAccessor().setComponent(toolbarEntry, toolbar);
    toolbarEntry.addChild(actionEntry);
    final JToolbarComponentBuilder toolbarActionGroupBuilder = new JToolbarComponentBuilder();
    toolbarActionGroupBuilder.visit(actionEntry);
    JAutoToggleButton button = (JAutoToggleButton) new EntryAccessor().getComponent(actionEntry);
    assertThat(button.getAction(), CoreMatchers.<Action>equalTo(action));
    assertThat(button.getParent(), CoreMatchers.equalTo((Container) toolbar));
}
Also used : JAutoToggleButton(org.freeplane.core.ui.components.JAutoToggleButton) Entry(org.freeplane.core.ui.menubuilders.generic.Entry) AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) Container(java.awt.Container) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) FreeplaneToolBar(org.freeplane.core.ui.components.FreeplaneToolBar) JToolbarComponentBuilder(org.freeplane.core.ui.menubuilders.menu.JToolbarComponentBuilder) Test(org.junit.Test)

Example 5 with JToolbarComponentBuilder

use of org.freeplane.core.ui.menubuilders.menu.JToolbarComponentBuilder in project freeplane by freeplane.

the class JToolbarComponentBuilderTest method createsVerticalToolbarSeparator.

@Test
public void createsVerticalToolbarSeparator() {
    Entry separatorEntry = new Entry();
    separatorEntry.setBuilders(asList("separator"));
    Entry toolbarEntry = new Entry();
    final FreeplaneToolBar toolbar = new FreeplaneToolBar("toolbar", SwingConstants.HORIZONTAL);
    new EntryAccessor().setComponent(toolbarEntry, toolbar);
    toolbarEntry.addChild(separatorEntry);
    final JToolbarComponentBuilder toolbarActionGroupBuilder = new JToolbarComponentBuilder();
    toolbarActionGroupBuilder.visit(separatorEntry);
    JToolBar.Separator separator = (JToolBar.Separator) new EntryAccessor().getComponent(separatorEntry);
    assertThat(separator.getParent(), CoreMatchers.equalTo((Container) toolbar));
    assertThat(separator.getOrientation(), CoreMatchers.equalTo(SwingConstants.VERTICAL));
}
Also used : Entry(org.freeplane.core.ui.menubuilders.generic.Entry) Container(java.awt.Container) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) FreeplaneToolBar(org.freeplane.core.ui.components.FreeplaneToolBar) JToolbarComponentBuilder(org.freeplane.core.ui.menubuilders.menu.JToolbarComponentBuilder) JToolBar(javax.swing.JToolBar) Test(org.junit.Test)

Aggregations

JToolbarComponentBuilder (org.freeplane.core.ui.menubuilders.menu.JToolbarComponentBuilder)5 Container (java.awt.Container)4 FreeplaneToolBar (org.freeplane.core.ui.components.FreeplaneToolBar)4 Entry (org.freeplane.core.ui.menubuilders.generic.Entry)4 EntryAccessor (org.freeplane.core.ui.menubuilders.generic.EntryAccessor)3 JToolBar (javax.swing.JToolBar)2 AFreeplaneAction (org.freeplane.core.ui.AFreeplaneAction)2 Test (org.junit.Test)2 KeyEvent (java.awt.event.KeyEvent)1 Box (javax.swing.Box)1 JButton (javax.swing.JButton)1 JPopupMenu (javax.swing.JPopupMenu)1 JRootPane (javax.swing.JRootPane)1 JTabbedPane (javax.swing.JTabbedPane)1 KeyStroke (javax.swing.KeyStroke)1 RootPaneContainer (javax.swing.RootPaneContainer)1 ResourceController (org.freeplane.core.resources.ResourceController)1 IEditHandler (org.freeplane.core.ui.IEditHandler)1 IKeyStrokeProcessor (org.freeplane.core.ui.IKeyStrokeProcessor)1 IMouseListener (org.freeplane.core.ui.IMouseListener)1