Example usage for org.eclipse.jface.action IToolBarManager update

List of usage examples for org.eclipse.jface.action IToolBarManager update

Introduction

In this page you can find the example usage for org.eclipse.jface.action IToolBarManager update.

Prototype

void update(boolean force);

Source Link

Document

Updates this manager's underlying widget(s) with any changes which have been made to it or its items.

Usage

From source file:uk.ac.diamond.scisoft.analysis.rcp.plotting.Plot1DStackUI.java

License:Apache License

private void buildToolActions(IToolBarManager manager, final DataSetPlotter plotter, final Shell shell,
        final Plot1DGraphTable colourTable) {

    zoomAction = new Action() {
        @Override/*  w ww .j av a  2s .  co  m*/
        public void run() {
            plotter.undoZoom();
        }
    };
    zoomAction.setText("Undo zoom");
    zoomAction.setToolTipText("Undo a zoom level");
    zoomAction.setImageDescriptor(AnalysisRCPActivator.getImageDescriptor("icons/minify.png"));
    colourLegend = new Action("", IAction.AS_CHECK_BOX) {
        @Override
        public void run() {
            Plot1DGraphTable colourTable = plotter.getColourTable();
            for (int i = 0; i < colourTable.getLegendSize(); i++) {
                Plot1DAppearance app = colourTable.getLegendEntry(i);
                app.setColour((colourLegend.isChecked() ? PlotColorUtility.getDefaultColour(i)
                        : java.awt.Color.BLACK));
            }
            plotter.updateAllAppearance();
            plotter.refresh(true);
        }
    };

    colourLegend.setText("Use colours");
    colourLegend.setToolTipText("Switch between monochrome and colour");
    colourLegend.setChecked(true);
    colourLegend.setImageDescriptor(AnalysisRCPActivator.getImageDescriptor("icons/rainbow.png"));

    changeColour = new Action() {
        @Override
        public void run() {
            PlotAppearanceDialog pad = new PlotAppearanceDialog(shell, colourTable);
            boolean success = pad.open();
            if (success) {
                plotter.updateAllAppearance();
                plotter.refresh(true);
            }
        }
    };

    changeColour.setText("Change Plot appearance");
    changeColour.setToolTipText("Change the appearance of a plot");
    changeColour.setImageDescriptor(AnalysisRCPActivator.getImageDescriptor("icons/color_wheel.png"));
    activateRegionZoom = new Action("", IAction.AS_CHECK_BOX) {
        @Override
        public void run() {
            activateAreaZoom.setChecked(false);
            plotter.setZoomEnabled(activateRegionZoom.isChecked());
            plotter.setZoomMode(false);
        }
    };

    activateRegionZoom.setText("Region Zoom");
    activateRegionZoom.setToolTipText("Region zoom mode");
    activateRegionZoom.setImageDescriptor(AnalysisRCPActivator.getImageDescriptor("icons/magnify.png"));
    activateAreaZoom = new Action("", IAction.AS_CHECK_BOX) {
        @Override
        public void run() {
            activateRegionZoom.setChecked(false);
            plotter.setZoomEnabled(activateAreaZoom.isChecked());
            plotter.setZoomMode(true);
        }
    };

    activateAreaZoom.setText("Area Zoom");
    activateAreaZoom.setToolTipText("Area zoom mode");
    activateAreaZoom.setImageDescriptor(AnalysisRCPActivator.getImageDescriptor("icons/zoom_in.png"));

    tooglePerspectiveAction = new Action("", IAction.AS_CHECK_BOX) {
        @Override
        public void run() {
            plotter.setPerspectiveCamera(tooglePerspectiveAction.isChecked(), true);
        }
    };
    tooglePerspectiveAction.setImageDescriptor(AnalysisRCPActivator.getImageDescriptor("icons/camera_add.png"));
    tooglePerspectiveAction.setText("Switch Ortho/Persp");
    tooglePerspectiveAction.setToolTipText("Switch between orthographic and perspective view");
    tooglePerspectiveAction.setChecked(getCameraPerspectiveChoice() == 1);
    resetView = new Action() {
        @Override
        public void run() {
            mainPlotter.resetView();
            mainPlotter.refresh(false);
        }
    };
    resetView.setText("Reset view");
    resetView.setToolTipText("Reset panning and zooming");
    resetView.setImageDescriptor(AnalysisRCPActivator.getImageDescriptor("icons/house_go.png"));

    boundingBox = new Action("", IAction.AS_CHECK_BOX) {
        @Override
        public void run() {
            plotter.enableBoundingBox(boundingBox.isChecked());
            plotter.refresh(false);
        }
    };
    boundingBox.setText("Bounding box on/off");
    boundingBox.setToolTipText("Bounding box on/off");
    boundingBox.setImageDescriptor(AnalysisRCPActivator.getImageDescriptor("icons/box.png"));
    boundingBox.setChecked(true);
    //expansionAction = new SliderAction(plotter);
    manager.add(activateRegionZoom);
    manager.add(activateAreaZoom);
    manager.add(zoomAction);
    manager.add(colourLegend);
    manager.add(changeColour);
    manager.add(tooglePerspectiveAction);
    manager.add(resetView);
    manager.add(boundingBox);
    //manager.add(expansionAction);
    manager.update(true);
}

From source file:uk.ac.diamond.scisoft.analysis.rcp.plotting.Plot1DUIComplete.java

License:Apache License

/**
 * @param manager //  w  w  w. jav a  2  s  .c o  m
 * 
 */
@Override
public void buildToolActions(IToolBarManager manager) {
    try {
        switchToTabs = getSidePlotView().createSwitchActions(this);
        for (Action action : switchToTabs) {
            manager.add(action);
        }
    } catch (IllegalStateException ex) {
    }

    manager.add(new Separator(getClass().getName() + "Data"));
    manager.add(displayPlotPos);
    manager.add(rightClickOnGraphAction);
    manager.add(new Separator(getClass().getName() + "History"));
    manager.add(addToHistory);
    manager.add(removeFromHistory);
    manager.add(new Separator(getClass().getName() + "Zoom"));
    manager.add(activateRegionZoom);
    manager.add(activateAreaZoom);
    manager.add(zoomAction);
    manager.add(resetZoomAction);
    manager.add(new Separator(getClass().getName() + "Appearance"));
    manager.add(changeColour);
    manager.add(activateXgrid);
    manager.add(activateYgrid);
    manager.add(new Separator(getClass().getName() + printButtonText));
    manager.add(saveGraph);
    manager.add(copyGraph);
    manager.add(printGraph);
    manager.add(new Separator(getClass().getName() + "Menu"));
    // Needed when toolbar is attached to an editor
    // or else the bar looks empty.
    manager.update(true);

}

From source file:uk.ac.diamond.scisoft.analysis.rcp.plotting.Plot2DMultiUI.java

License:Apache License

private void buildToolActions(IToolBarManager manager, final DataSetPlotter plotter, final Shell shell) {

    resetView = new Action() {
        @Override//from   w  w  w  .  j  ava  2s .  c o m
        public void run() {
            mainPlotter.resetView();
            mainPlotter.refresh(false);
        }
    };
    resetView.setText("Reset view");
    resetView.setToolTipText("Reset panning and zooming");
    resetView.setImageDescriptor(AnalysisRCPActivator.getImageDescriptor("icons/house_go.png"));
    /*      
          monitorValues = new Action("",IAction.AS_CHECK_BOX) {
             @Override
             public void run() {
    plotter.setPlotActionEnabled(monitorValues.isChecked());
             }
          };
          monitorValues.setText("Monitor position");
          monitorValues.setToolTipText("Monitor the position in the image");
          monitorValues.setImageDescriptor(AnalysisRCPActivator.getImageDescriptor("icons/monitor.png"));
    */
    saveGraph = new Action() {

        // Cache file name otherwise they have to keep
        // choosing the folder.
        private String filename;

        @Override
        public void run() {

            FileDialog dialog = new FileDialog(shell, SWT.SAVE);

            String[] filterExtensions = new String[] { "*.jpg;*.JPG;*.jpeg;*.JPEG;*.png;*.PNG", "*.ps;*.eps",
                    "*.svg;*.SVG" };
            if (filename != null) {
                dialog.setFilterPath((new File(filename)).getParent());
            } else {
                String filterPath = "/";
                String platform = SWT.getPlatform();
                if (platform.equals("win32") || platform.equals("wpf")) {
                    filterPath = "c:\\";
                }
                dialog.setFilterPath(filterPath);
            }
            dialog.setFilterNames(PlotExportUtil.FILE_TYPES);
            dialog.setFilterExtensions(filterExtensions);
            filename = dialog.open();
            if (filename == null)
                return;

            plotter.saveGraph(filename, PlotExportUtil.FILE_TYPES[dialog.getFilterIndex()]);
        }
    };
    saveGraph.setText(saveButtonText);
    saveGraph.setToolTipText(saveToolTipText);
    saveGraph.setImageDescriptor(AnalysisRCPActivator.getImageDescriptor(saveImagePath));

    copyGraph = new Action() {
        @Override
        public void run() {
            plotter.copyGraph();
        }
    };
    copyGraph.setText(copyButtonText);
    copyGraph.setToolTipText(copyToolTipText);
    copyGraph.setImageDescriptor(AnalysisRCPActivator.getImageDescriptor(copyImagePath));

    printGraph = new Action() {
        @Override
        public void run() {
            plotter.printGraph();
        }
    };
    printGraph.setText(printButtonText);
    printGraph.setToolTipText(printToolTipText);
    printGraph.setImageDescriptor(AnalysisRCPActivator.getImageDescriptor(printImagePath));

    canvasAspect = new Action("", IAction.AS_CHECK_BOX) {
        @Override
        public void run() {
            plotter.imagePlotSetCanvasAspectRatio(canvasAspect.isChecked());
            plotter.refresh(false);
        }
    };
    canvasAspect.setText("Canvas");
    canvasAspect.setToolTipText("Switch between canvas/data aspect ratio");
    canvasAspect.setImageDescriptor(AnalysisRCPActivator.getImageDescriptor("icons/arrow_out.png"));

    /*   manager.add(new Separator());
       try {
          switchToTabs = getSidePlotView().createSwitchActions(this);
            
          for (Action action: switchToTabs) {
    manager.add(action);
          }
       } catch (IllegalStateException ex) {}*/
    manager.add(new Separator());

    manager.add(resetView);
    //   manager.add(monitorValues);
    manager.add(new Separator(getClass().getName() + printButtonText));
    manager.add(saveGraph);
    manager.add(copyGraph);
    manager.add(printGraph);
    manager.add(new Separator(getClass().getName() + "Canvas"));
    manager.add(canvasAspect);
    manager.update(true);
}

From source file:uk.ac.diamond.scisoft.analysis.rcp.plotting.Plot2DUI.java

License:Apache License

private void buildToolActions(IToolBarManager manager, final DataSetPlotter plotter, final Shell shell) {

    resetView = new Action() {
        @Override//  ww w.j a  va 2  s.  com
        public void run() {
            mainPlotter.resetView();
            mainPlotter.refresh(false);
        }
    };
    resetView.setText("Reset view");
    resetView.setToolTipText("Reset panning and zooming");
    resetView.setImageDescriptor(AnalysisRCPActivator.getImageDescriptor("icons/house_go.png"));

    monitorValues = new Action("", IAction.AS_CHECK_BOX) {
        @Override
        public void run() {
            plotter.setPlotActionEnabled(monitorValues.isChecked());
        }
    };
    monitorValues.setText("Monitor position");
    monitorValues.setToolTipText("Monitor the position in the image");
    monitorValues.setImageDescriptor(AnalysisRCPActivator.getImageDescriptor("icons/monitor.png"));

    saveGraph = new Action() {

        // Cache file name otherwise they have to keep
        // choosing the folder.
        private String filename;

        @Override
        public void run() {

            FileDialog dialog = new FileDialog(shell, SWT.SAVE);

            String[] filterExtensions = new String[] { "*.jpg;*.JPG;*.jpeg;*.JPEG;*.png;*.PNG", "*.ps;*.eps",
                    "*.svg;*.SVG" };
            if (filename != null) {
                dialog.setFilterPath((new File(filename)).getParent());
            } else {
                String filterPath = "/";
                String platform = SWT.getPlatform();
                if (platform.equals("win32") || platform.equals("wpf")) {
                    filterPath = "c:\\";
                }
                dialog.setFilterPath(filterPath);
            }
            dialog.setFilterNames(PlotExportUtil.FILE_TYPES);
            dialog.setFilterExtensions(filterExtensions);
            filename = dialog.open();
            if (filename == null)
                return;

            plotter.saveGraph(filename, PlotExportUtil.FILE_TYPES[dialog.getFilterIndex()]);
        }
    };
    saveGraph.setText(saveButtonText);
    saveGraph.setToolTipText(saveToolTipText);
    saveGraph.setImageDescriptor(AnalysisRCPActivator.getImageDescriptor(saveImagePath));

    copyGraph = new Action() {
        @Override
        public void run() {
            plotter.copyGraph();
        }
    };
    copyGraph.setText(copyButtonText);
    copyGraph.setToolTipText(copyToolTipText);
    copyGraph.setImageDescriptor(AnalysisRCPActivator.getImageDescriptor(copyImagePath));

    printGraph = new Action() {
        @Override
        public void run() {
            plotter.printGraph();
        }
    };
    printGraph.setText(printButtonText);
    printGraph.setToolTipText(printToolTipText);
    printGraph.setImageDescriptor(AnalysisRCPActivator.getImageDescriptor(printImagePath));

    canvasAspect = new Action("", IAction.AS_CHECK_BOX) {
        @Override
        public void run() {
            plotter.imagePlotSetCanvasAspectRatio(canvasAspect.isChecked());
            plotter.refresh(false);
        }
    };

    canvasAspect.setText("Canvas");
    canvasAspect.setToolTipText("Switch between canvas/data aspect ratio");
    canvasAspect.setImageDescriptor(AnalysisRCPActivator.getImageDescriptor("icons/arrow_out.png"));

    manager.add(new Separator());
    try {
        switchToTabs = getSidePlotView().createSwitchActions(this);

        for (Action action : switchToTabs) {
            manager.add(action);
        }
    } catch (IllegalStateException ex) {
    }
    manager.add(new Separator());

    manager.add(resetView);
    manager.add(monitorValues);
    manager.add(new Separator(getClass().getName() + printButtonText));
    manager.add(saveGraph);
    manager.add(copyGraph);
    manager.add(printGraph);
    manager.add(new Separator(getClass().getName() + "Canvas"));
    manager.add(canvasAspect);

    // Needed when toolbar is attached to an editor
    // or else the bar looks empty.
    manager.update(true);
}

From source file:uk.ac.diamond.scisoft.analysis.rcp.plotting.PlotScatter2DUI.java

License:Apache License

/**
 * @param manager /*from  w w  w  .j  a v  a2 s.  co  m*/
 * 
 */
@Override
public void buildToolActions(IToolBarManager manager) {
    manager.add(new Separator(getClass().getName() + "Data"));
    manager.add(displayPlotPos);
    //   manager.add(rightClickOnGraphAction);
    manager.add(new Separator(getClass().getName() + "History"));
    //      manager.add(addToHistory);
    //      manager.add(removeFromHistory);
    manager.add(new Separator(getClass().getName() + "Zoom"));
    manager.add(activateRegionZoom);
    manager.add(activateAreaZoom);
    manager.add(zoomAction);
    manager.add(resetZoomAction);
    manager.add(new Separator(getClass().getName() + "Appearance"));
    manager.add(changeColour);
    //      manager.add(activateXgrid);
    //      manager.add(activateYgrid);
    manager.add(new Separator(getClass().getName() + "Print"));
    manager.add(saveGraph);
    manager.add(copyGraph);
    manager.add(printGraph);

    // Needed when toolbar is attached to an editor
    // or else the bar looks empty.
    manager.update(true);

}

From source file:uk.ac.diamond.scisoft.analysis.rcp.plotting.PlotScatter3DUI.java

License:Apache License

private void buildToolActions(IToolBarManager manager, final DataSetPlotter plotter, final Shell shell) {
    resetView = new Action() {
        @Override/*w w w  .  j a v a 2 s. c  o  m*/
        public void run() {
            mainPlotter.resetView();
            mainPlotter.refresh(false);
        }
    };
    resetView.setText("Reset view");
    resetView.setToolTipText("Reset panning and zooming");
    resetView.setImageDescriptor(AnalysisRCPActivator.getImageDescriptor("icons/house_go.png"));
    boundingBox = new Action("", IAction.AS_CHECK_BOX) {
        @Override
        public void run() {
            plotter.enableBoundingBox(boundingBox.isChecked());
            plotter.refresh(false);
        }
    };
    boundingBox.setText("Bounding box on/off");
    boundingBox.setToolTipText("Bounding box on/off");
    boundingBox.setImageDescriptor(AnalysisRCPActivator.getImageDescriptor("icons/box.png"));
    boundingBox.setChecked(true);
    saveGraph = new Action() {

        // Cache file name otherwise they have to keep
        // choosing the folder.
        private String filename;

        @Override
        public void run() {

            FileDialog dialog = new FileDialog(shell, SWT.SAVE);

            String[] filterExtensions = new String[] { "*.jpg;*.JPG;*.jpeg;*.JPEG;*.png;*.PNG", "*.ps;*.eps",
                    "*.svg;*.SVG" };
            if (filename != null) {
                dialog.setFilterPath((new File(filename)).getParent());
            } else {
                String filterPath = "/";
                String platform = SWT.getPlatform();
                if (platform.equals("win32") || platform.equals("wpf")) {
                    filterPath = "c:\\";
                }
                dialog.setFilterPath(filterPath);
            }
            dialog.setFilterNames(PlotExportUtil.FILE_TYPES);
            dialog.setFilterExtensions(filterExtensions);
            filename = dialog.open();
            if (filename == null)
                return;

            plotter.saveGraph(filename, PlotExportUtil.FILE_TYPES[dialog.getFilterIndex()]);
        }
    };
    saveGraph.setText(saveButtonText);
    saveGraph.setToolTipText(saveToolTipText);
    saveGraph.setImageDescriptor(AnalysisRCPActivator.getImageDescriptor(saveImagePath));

    copyGraph = new Action() {
        @Override
        public void run() {
            plotter.copyGraph();
        }
    };
    copyGraph.setText(copyButtonText);
    copyGraph.setToolTipText(copyToolTipText);
    copyGraph.setImageDescriptor(AnalysisRCPActivator.getImageDescriptor(copyImagePath));

    printGraph = new Action() {
        @Override
        public void run() {
            plotter.printGraph();
        }
    };
    printGraph.setText(printButtonText);
    printGraph.setToolTipText(printToolTipText);
    printGraph.setImageDescriptor(AnalysisRCPActivator.getImageDescriptor(printImagePath));

    manager.add(resetView);
    manager.add(boundingBox);
    manager.add(new Separator(getClass().getName() + "Print"));
    manager.add(saveGraph);
    manager.add(copyGraph);
    manager.add(printGraph);

    // Needed when toolbar is attached to an editor
    // or else the bar looks empty.
    manager.update(true);

}

From source file:uk.ac.diamond.scisoft.analysis.rcp.plotting.PlotSurf3DUI.java

License:Apache License

private void buildToolActions(IToolBarManager manager, final DataSetPlotter plotter, final Shell shell) {
    resetView = new Action() {
        @Override/*from   w w  w . j  ava 2  s  .  co  m*/
        public void run() {
            mainPlotter.resetView();
            mainPlotter.refresh(false);
        }
    };
    resetView.setText("Reset view");
    resetView.setToolTipText("Reset panning and zooming");
    resetView.setImageDescriptor(AnalysisRCPActivator.getImageDescriptor("icons/house_go.png"));

    boundingBox = new Action("", IAction.AS_CHECK_BOX) {
        @Override
        public void run() {
            plotter.enableBoundingBox(boundingBox.isChecked());
            plotter.refresh(false);
        }
    };
    boundingBox.setText("Bounding box on/off");
    boundingBox.setToolTipText("Bounding box on/off");
    boundingBox.setImageDescriptor(AnalysisRCPActivator.getImageDescriptor("icons/box.png"));
    boundingBox.setChecked(true);
    xCoordGrid = new Action("", IAction.AS_CHECK_BOX) {
        @Override
        public void run() {
            plotter.setTickGridLines(xCoordGrid.isChecked(), yCoordGrid.isChecked(), zCoordGrid.isChecked());
            plotter.refresh(false);
        }
    };
    xCoordGrid.setChecked(true);
    xCoordGrid.setText("X grid lines ON/OFF");
    xCoordGrid.setToolTipText("Toggle x axis grid lines on/off");
    xCoordGrid.setImageDescriptor(AnalysisRCPActivator.getImageDescriptor("icons/text_align_justify_rot.png"));
    yCoordGrid = new Action("", IAction.AS_CHECK_BOX) {
        @Override
        public void run() {
            plotter.setTickGridLines(xCoordGrid.isChecked(), yCoordGrid.isChecked(), zCoordGrid.isChecked());
            plotter.refresh(false);

        }
    };
    yCoordGrid.setChecked(true);
    yCoordGrid.setText("Y grid lines ON/OFF");
    yCoordGrid.setToolTipText("Toggle y axis grid lines on/off");
    yCoordGrid.setImageDescriptor(AnalysisRCPActivator.getImageDescriptor("icons/text_align_justify.png"));

    zCoordGrid = new Action("", IAction.AS_CHECK_BOX) {
        @Override
        public void run() {
            plotter.setTickGridLines(xCoordGrid.isChecked(), yCoordGrid.isChecked(), zCoordGrid.isChecked());
            plotter.refresh(false);

        }
    };
    zCoordGrid.setChecked(true);
    zCoordGrid.setText("Z grid lines ON/OFF");
    zCoordGrid.setToolTipText("Toggle z axis grid lines on/off");
    zCoordGrid.setImageDescriptor(AnalysisRCPActivator.getImageDescriptor("icons/text_align_justify.png"));

    saveGraph = new Action() {

        // Cache file name otherwise they have to keep
        // choosing the folder.
        private String filename;

        @Override
        public void run() {

            FileDialog dialog = new FileDialog(shell, SWT.SAVE);

            String[] filterExtensions = new String[] { "*.jpg;*.JPG;*.jpeg;*.JPEG;*.png;*.PNG", "*.ps;*.eps",
                    "*.svg;*.SVG" };
            if (filename != null) {
                dialog.setFilterPath((new File(filename)).getParent());
            } else {
                String filterPath = "/";
                String platform = SWT.getPlatform();
                if (platform.equals("win32") || platform.equals("wpf")) {
                    filterPath = "c:\\";
                }
                dialog.setFilterPath(filterPath);
            }
            dialog.setFilterNames(PlotExportUtil.FILE_TYPES);
            dialog.setFilterExtensions(filterExtensions);
            filename = dialog.open();
            if (filename == null)
                return;

            plotter.saveGraph(filename, PlotExportUtil.FILE_TYPES[dialog.getFilterIndex()]);
        }
    };
    saveGraph.setText(saveButtonText);
    saveGraph.setToolTipText(saveToolTipText);
    saveGraph.setImageDescriptor(AnalysisRCPActivator.getImageDescriptor(saveImagePath));

    copyGraph = new Action() {
        @Override
        public void run() {
            plotter.copyGraph();
        }
    };
    copyGraph.setText(copyButtonText);
    copyGraph.setToolTipText(copyToolTipText);
    copyGraph.setImageDescriptor(AnalysisRCPActivator.getImageDescriptor(copyImagePath));

    printGraph = new Action() {
        @Override
        public void run() {
            plotter.printGraph();
        }
    };
    printGraph.setText(printButtonText);
    printGraph.setToolTipText(printToolTipText);
    printGraph.setImageDescriptor(AnalysisRCPActivator.getImageDescriptor(printImagePath));

    manager.add(resetView);
    manager.add(boundingBox);
    manager.add(xCoordGrid);
    manager.add(yCoordGrid);
    manager.add(zCoordGrid);
    manager.add(new Separator(getClass().getName() + printButtonText));
    manager.add(saveGraph);
    manager.add(copyGraph);
    manager.add(printGraph);

    // Needed when toolbar is attached to an editor
    // or else the bar looks empty.
    manager.update(true);

}

From source file:uk.co.dancowan.robots.srv.ui.views.camera.CameraView.java

License:Open Source License

private void createToolbar() {
    IToolBarManager manager = getViewSite().getActionBars().getToolBarManager();
    manager.removeAll();/*w  ww.  j  av a2  s . c om*/

    IContributionItem actions = new GroupMarker("actions");
    manager.add(actions);

    mPanels.getCurrentPanel().addToToolBar(manager);

    manager.update(true);
}

From source file:ummisco.gama.ui.navigator.GamaNavigator.java

@Override
public void createPartControl(final Composite compo) {
    this.parent = GamaToolbarFactory.createToolbars(this, compo);

    super.createPartControl(parent);
    restoreState();//w  w  w  . ja va 2  s  . c om
    final IToolBarManager tb = getViewSite().getActionBars().getToolBarManager();
    for (final IContributionItem item : tb.getItems()) {
        if (item instanceof ActionContributionItem) {
            final ActionContributionItem aci = (ActionContributionItem) item;
            final IAction action = aci.getAction();
            if (action instanceof LinkEditorAction) {
                link = action;
                tb.remove(aci);
            } else if (action instanceof org.eclipse.ui.internal.navigator.actions.CollapseAllAction) {
                tb.remove(aci);
            }

        }
    }
    linkItem.setSelection(link.isChecked());
    tb.update(true);
    tb.insertBefore("toolbar.toggle", byDate.toCheckAction());
    tb.insertBefore("toolbar.toggle", expandAll.toAction());
    tb.insertBefore(expandAll.getId(), collapseAll.toAction());

    try {
        final IDecoratorManager mgr = PlatformUI.getWorkbench().getDecoratorManager();
        mgr.setEnabled("msi.gama.application.date.decorator", false);
    } catch (final CoreException e) {
        e.printStackTrace();
    }
    properties = new PropertyDialogAction(new SameShellProvider(getSite().getShell()),
            getSite().getSelectionProvider());
    findControl.initialize();

}

From source file:ummisco.gama.ui.views.toolbar.GamaToolbarFactory.java

public static Composite createToolbars(final IToolbarDecoratedView view, final Composite composite) {
    final Composite intermediateComposite = createIntermediateCompositeFor(view, composite);
    final Composite toolbarComposite = createToolbarComposite(intermediateComposite);
    final Composite childComposite = new Composite(intermediateComposite, SWT.None);
    childComposite.setLayoutData(getLayoutDataForChild());
    childComposite.setLayout(getLayoutForChild());

    final GamaToolbar2 tb = new GamaToolbar2(toolbarComposite, SWT.FLAT | SWT.HORIZONTAL | SWT.NO_FOCUS,
            TOOLBAR_HEIGHT);//  ww w.  jav a2s  . co  m
    final GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
    data.minimumWidth = TOOLBAR_HEIGHT * 2;
    tb.setLayoutData(data);
    composite.addDisposeListener(e -> disposeToolbar(view, tb));
    buildToolbar(view, tb);

    // Creating the toggles
    final ToggleAction toggle = new ToggleAction() {

        @Override
        public void run() {
            final boolean show = !tb.isVisible();
            tb.setVisible(show);
            ((GridData) tb.getParent().getLayoutData()).exclude = !show;
            tb.getParent().setVisible(show);
            tb.getParent().getParent().layout();
            setIcon(show);
        }

        @Override
        protected void setIcon(final boolean show) {
            setImageDescriptor(
                    GamaIcons.create(show ? "action.toolbar.toggle.small2" : "action.toolbar.toggle.small3")
                            .descriptor());
        }
    };

    tb.setToogleAction(toggle);

    // Install the toogles in the view site
    final IWorkbenchSite site = view.getSite();
    if (site instanceof IViewSite) {
        final IToolBarManager tm = ((IViewSite) site).getActionBars().getToolBarManager();
        tm.add(toggle);
        if (view instanceof IGamaView.Display) {
            final Action toggleSideControls = new ToggleSideControls() {
                @Override
                public void run() {
                    ((IGamaView.Display) view).toggleSideControls();
                }
            };

            final Action toggleOverlay = new ToggleOverlay() {
                @Override
                public void run() {
                    ((IGamaView.Display) view).toggleOverlay();
                }
            };
            tm.add(toggleOverlay);
            tm.add(toggleSideControls);
        }
        tm.update(true);
    }

    if (!view.toolbarVisible()) {
        toggle.run();
        // tb.setVisible(false);
        // ((GridData) tb.getParent().getLayoutData()).exclude = true;
        // tb.getParent().setVisible(false);
        // tb.getParent().getParent().layout();
        // toggle.setIcon(false);
    }
    return childComposite;
}