Search in sources :

Example 1 with OneTouchCollapseResizer

use of org.freeplane.core.ui.components.OneTouchCollapseResizer in project freeplane by freeplane.

the class RibbonBuilder method setMinimized.

public void setMinimized(boolean b) {
    ribbon.setMinimized(b);
    OneTouchCollapseResizer otcr = OneTouchCollapseResizer.findResizerFor(ribbon);
    if (otcr != null) {
        otcr.recalibrate();
    }
}
Also used : OneTouchCollapseResizer(org.freeplane.core.ui.components.OneTouchCollapseResizer)

Example 2 with OneTouchCollapseResizer

use of org.freeplane.core.ui.components.OneTouchCollapseResizer in project freeplane by freeplane.

the class CollapseableBoxBuilder method createBox.

public Box createBox(final Component component, final Direction direction) {
    Box resisableComponent = direction.createBox();
    UIComponentVisibilityDispatcher.install(frameController, resisableComponent, propertyNameBase);
    final UIComponentVisibilityDispatcher dispatcher = UIComponentVisibilityDispatcher.dispatcher(resisableComponent);
    final String sizePropertyName = dispatcher.getPropertyName() + ".size";
    final boolean expanded = dispatcher.isVisible();
    OneTouchCollapseResizer resizer = new OneTouchCollapseResizer(direction);
    dispatcher.setResizer(resizer);
    switch(direction) {
        case RIGHT:
        case DOWN:
            resisableComponent.add(resizer);
            resisableComponent.add(component);
            break;
        default:
            resisableComponent.add(component);
            resisableComponent.add(resizer);
            break;
    }
    if (resizeable) {
        try {
            int size = ResourceController.getResourceController().getIntProperty(sizePropertyName, DEFAULT_SIZE);
            if (size <= 10) {
                size = DEFAULT_SIZE;
            }
            direction.setPreferredSize(component, size);
        } catch (Exception e) {
        // blindly accept
        }
        resizer.addResizerListener(new ResizerListener() {

            public void componentResized(ResizeEvent event) {
                if (event.getComponent().equals(component)) {
                    ResourceController.getResourceController().setProperty(sizePropertyName, String.valueOf(direction.getPreferredSize(component)));
                }
            }
        });
    } else
        resizer.setSliderLocked(true);
    resizer.addCollapseListener(new ComponentCollapseListener() {

        public void componentCollapsed(ResizeEvent event) {
            if (event.getComponent().equals(component)) {
                dispatcher.setProperty(false);
            }
        }

        public void componentExpanded(ResizeEvent event) {
            if (event.getComponent().equals(component)) {
                dispatcher.setProperty(true);
            }
        }
    });
    resizer.setExpanded(expanded);
    return resisableComponent;
}
Also used : ComponentCollapseListener(org.freeplane.core.ui.components.OneTouchCollapseResizer.ComponentCollapseListener) Box(javax.swing.Box) ResizerListener(org.freeplane.core.ui.components.ResizerListener) OneTouchCollapseResizer(org.freeplane.core.ui.components.OneTouchCollapseResizer) ResizeEvent(org.freeplane.core.ui.components.ResizeEvent)

Example 3 with OneTouchCollapseResizer

use of org.freeplane.core.ui.components.OneTouchCollapseResizer in project freeplane by freeplane.

the class MModeWorkspaceController method setupView.

private void setupView(ModeController modeController) {
    FileSystemManager.setDirectoryConflictHandler(new DirectoryMergeConflictDialog());
    FileSystemManager.setFileConflictHandler(new FileExistsConflictDialog());
    boolean expanded = true;
    try {
        expanded = !Boolean.parseBoolean(settings.getProperty(WORKSPACE_VIEW_COLLAPSED, "false"));
    } catch (Exception e) {
    // ignore -> default is true
    }
    OneTouchCollapseResizer otcr = new OneTouchCollapseResizer(Direction.LEFT);
    otcr.addCollapseListener(getWorkspaceView());
    ResizerEventAdapter adapter = new ResizerEventAdapter() {

        public void componentResized(ResizeEvent event) {
            if (event.getSource().equals(getView())) {
                settings.setProperty(WORKSPACE_VIEW_WIDTH, String.valueOf(((JComponent) event.getSource()).getPreferredSize().width));
            }
        }

        public void componentCollapsed(ResizeEvent event) {
            if (event.getSource().equals(getView())) {
                settings.setProperty(WORKSPACE_VIEW_COLLAPSED, "true");
            }
        }

        public void componentExpanded(ResizeEvent event) {
            if (event.getSource().equals(getView())) {
                settings.setProperty(WORKSPACE_VIEW_COLLAPSED, "false");
            }
        }
    };
    otcr.addResizerListener(adapter);
    otcr.addCollapseListener(adapter);
    Box resizableTools = Box.createHorizontalBox();
    try {
        int width = Integer.parseInt(settings.getProperty(WORKSPACE_VIEW_WIDTH, "250"));
        getWorkspaceView().setPreferredSize(new Dimension(width, 40));
    } catch (Exception e) {
    // blindly accept
    }
    resizableTools.add(getWorkspaceView());
    resizableTools.add(otcr);
    otcr.setExpanded(expanded);
    modeController.getUserInputListenerFactory().addToolBar("workspace", ViewController.LEFT, resizableTools);
    getWorkspaceView().setModel(getModel());
    getView().expandPath(getModel().getRoot().getTreePath());
    for (AWorkspaceProject project : getModel().getProjects()) {
        getView().expandPath(project.getModel().getRoot().getTreePath());
    }
    getView().getNodeTypeIconManager().addNodeTypeIconHandler(LinkTypeFileNode.class, new LinkTypeFileIconHandler());
    getView().getNodeTypeIconManager().addNodeTypeIconHandler(DefaultFileNode.class, new DefaultFileNodeIconHandler());
    getView().refreshView();
}
Also used : AWorkspaceProject(org.freeplane.plugin.workspace.model.project.AWorkspaceProject) FileExistsConflictDialog(org.freeplane.plugin.workspace.handler.FileExistsConflictDialog) Box(javax.swing.Box) Dimension(java.awt.Dimension) LinkTypeFileIconHandler(org.freeplane.plugin.workspace.handler.LinkTypeFileIconHandler) IOException(java.io.IOException) ResizeEvent(org.freeplane.core.ui.components.ResizeEvent) DirectoryMergeConflictDialog(org.freeplane.plugin.workspace.handler.DirectoryMergeConflictDialog) DefaultFileNodeIconHandler(org.freeplane.plugin.workspace.handler.DefaultFileNodeIconHandler) OneTouchCollapseResizer(org.freeplane.core.ui.components.OneTouchCollapseResizer)

Aggregations

OneTouchCollapseResizer (org.freeplane.core.ui.components.OneTouchCollapseResizer)3 Box (javax.swing.Box)2 ResizeEvent (org.freeplane.core.ui.components.ResizeEvent)2 Dimension (java.awt.Dimension)1 IOException (java.io.IOException)1 ComponentCollapseListener (org.freeplane.core.ui.components.OneTouchCollapseResizer.ComponentCollapseListener)1 ResizerListener (org.freeplane.core.ui.components.ResizerListener)1 DefaultFileNodeIconHandler (org.freeplane.plugin.workspace.handler.DefaultFileNodeIconHandler)1 DirectoryMergeConflictDialog (org.freeplane.plugin.workspace.handler.DirectoryMergeConflictDialog)1 FileExistsConflictDialog (org.freeplane.plugin.workspace.handler.FileExistsConflictDialog)1 LinkTypeFileIconHandler (org.freeplane.plugin.workspace.handler.LinkTypeFileIconHandler)1 AWorkspaceProject (org.freeplane.plugin.workspace.model.project.AWorkspaceProject)1