Example usage for org.eclipse.jface.preference PreferenceDialog open

List of usage examples for org.eclipse.jface.preference PreferenceDialog open

Introduction

In this page you can find the example usage for org.eclipse.jface.preference PreferenceDialog open.

Prototype

public int open() 

Source Link

Document

Opens this window, creating it first if it has not yet been created.

Usage

From source file:org.dawb.workbench.ui.data.PlotDataComponent.java

License:Open Source License

/**
 * Puts actions on right click menu and in action bar.
 * @param bars//  ww w.  ja  va2  s .c o  m
 */
private void createActions(final IActionBars bars) {

    final MenuManager menuManager = new MenuManager();
    menuManager.setRemoveAllWhenShown(true);
    dataViewer.getControl().setMenu(menuManager.createContextMenu(dataViewer.getControl()));

    final List<Object> rightClickActions = new ArrayList<Object>(11);
    createDimensionalActions(rightClickActions, false);

    PlotDataComponent.this.dataReduction = new Action("Data reduction...",
            Activator.getImageDescriptor("icons/data-reduction.png")) {
        @Override
        public void run() {
            DataReductionWizard wiz = null;
            try {
                wiz = (DataReductionWizard) EclipseUtils.openWizard(DataReductionWizard.ID, false);
            } catch (Exception e) {
                logger.error("Cannot open wizard " + DataReductionWizard.ID, e);
            }
            wiz.setData(getFile(), getSelectionNames().get(0),
                    (IDataReductionToolPage) getAbstractPlottingSystem().getActiveTool(), getSliceSet());
            wiz.setSlice(getSliceSet(), getSliceData());

            // TODO Should be non modal, it takes a while.
            WizardDialog wd = new WizardDialog(Display.getDefault().getActiveShell(), wiz);
            wd.setTitle(wiz.getWindowTitle());
            wd.create();
            wd.getShell().setSize(650, 800);
            DialogUtils.centerDialog(Display.getDefault().getActiveShell(), wd.getShell());
            wd.open();
        }
    };

    final Action showSignal = new Action("Show only data with a 'signal' attribute", IAction.AS_CHECK_BOX) {
        public void run() {
            Activator.getDefault().getPreferenceStore().setValue(EditorConstants.SHOW_SIGNAL_ONLY, isChecked());
            refresh();
        }
    };
    showSignal.setImageDescriptor(Activator.getImageDescriptor("icons/signal.png"));
    bars.getToolBarManager().add(showSignal);
    bars.getToolBarManager().add(new Separator("signal.group"));
    showSignal.setChecked(
            Activator.getDefault().getPreferenceStore().getBoolean(EditorConstants.SHOW_SIGNAL_ONLY));

    final Action copy = new Action("Copy selected data (it can then be pasted to another data list.)",
            Activator.getImageDescriptor("icons/copy.gif")) {
        public void run() {
            final ITransferableDataObject sel = (ITransferableDataObject) ((IStructuredSelection) dataViewer
                    .getSelection()).getFirstElement();
            if (sel == null)
                return;
            transferableService.setBuffer(sel);
        }
    };
    bars.getToolBarManager().add(copy);
    copy.setEnabled(false);

    final Action paste = new Action("Paste", Activator.getImageDescriptor("icons/paste.gif")) {
        public void run() {
            ITransferableDataObject checkedObject = getCheckedObject(transferableService.getBuffer());
            if (checkedObject == null)
                return;
            data.add(checkedObject);
            checkedObject.setChecked(!checkedObject.isChecked());
            selectionChanged(checkedObject, true);
            dataViewer.refresh();

            final ISliceSystem system = (ISliceSystem) editor.getAdapter(ISliceSystem.class);
            if (system != null)
                system.refresh();
        }
    };
    bars.getToolBarManager().add(paste);
    paste.setEnabled(false);

    final Action delete = new Action("Delete", Activator.getImageDescriptor("icons/delete.gif")) {
        public void run() {
            final Object sel = ((StructuredSelection) dataViewer.getSelection()).getFirstElement();
            final ITransferableDataObject ob = (ITransferableDataObject) sel;
            if (ob != null) {
                boolean ok = data.remove(ob);
                if (ok)
                    ob.dispose();
            }
            dataViewer.refresh();
        }
    };
    bars.getToolBarManager().add(delete);
    delete.setEnabled(false);

    // Fix to http://jira.diamond.ac.uk/browse/SCI-1558
    // remove feature.
    final Action createFilter = null;
    final Action clearFilter = null;

    // Used to have ability to choose a python script to filter datasets:
    //      bars.getToolBarManager().add(new Separator());
    //      final Action createFilter = new Action("Create Filter", Activator.getImageDescriptor("icons/filter.png")) {
    //         public void run() {
    //            final Object sel           = ((StructuredSelection)dataViewer.getSelection()).getFirstElement();
    //            final ITransferableDataObject ob  = (ITransferableDataObject)sel;
    //            if (ob==null) return;
    //            chooseFilterFile(ob);
    //         }
    //      };
    //      bars.getToolBarManager().add(createFilter);
    //      createFilter.setEnabled(false);
    //      
    //      final Action clearFilter = new Action("Clear filter", Activator.getImageDescriptor("icons/delete_filter.png")) {
    //         public void run() {
    //            final Object sel           = ((StructuredSelection)dataViewer.getSelection()).getFirstElement();
    //            final ITransferableDataObject ob  = (ITransferableDataObject)sel;
    //            if (ob==null) return;
    //            clearFilterFile(ob);
    //         }
    //      };
    //      bars.getToolBarManager().add(clearFilter);
    //      clearFilter.setEnabled(false);

    final Action export = new Action("Export...", Activator.getImageDescriptor("icons/export_wiz.gif")) {
        public void run() {

            final ConvertWizard cwizard = new ConvertWizard();
            final IStructuredSelection sel = (IStructuredSelection) dataViewer.getSelection();
            cwizard.setSelectionOverride(sel.toList());
            WizardDialog dialog = new WizardDialog(container.getShell(), cwizard);
            dialog.setPageSize(new Point(400, 450));
            dialog.create();
            dialog.open();

        }
    };
    export.setEnabled(false);
    bars.getToolBarManager().add(new Separator());
    bars.getToolBarManager().add(export);
    bars.getToolBarManager().add(new Separator());

    dataViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            final Object sel = ((StructuredSelection) dataViewer.getSelection()).getFirstElement();
            final ITransferableDataObject ob = (ITransferableDataObject) sel;
            updateActions(copy, paste, delete, createFilter, clearFilter, export, ob, bars);
        }
    });

    final InjectPyDevConsoleAction inject = new InjectPyDevConsoleAction("Open Scripting");
    inject.setParameter(InjectPyDevConsole.CREATE_NEW_CONSOLE_PARAM, Boolean.TRUE.toString());
    inject.setParameter(InjectPyDevConsole.SETUP_SCISOFTPY_PARAM,
            InjectPyDevConsole.SetupScisoftpy.ALWAYS.toString());
    inject.setParameter(InjectPyDevConsole.VIEW_NAME_PARAM, editor.getTitle());

    menuManager.addMenuListener(new IMenuListener() {
        @Override
        public void menuAboutToShow(IMenuManager manager) {

            if (staggerSupported) {
                updatePlotDimenionsSelected((IAction) rightClickActions.get(1),
                        (IAction) rightClickActions.get(2), (IAction) rightClickActions.get(3),
                        getPlottingSystem().getPlotType());
            }

            for (Object action : rightClickActions) {
                if (action instanceof IAction) {
                    menuManager.add((IAction) action);
                } else if (action instanceof IContributionItem) {
                    menuManager.add((IContributionItem) action);
                }
            }

            menuManager.add(new Separator(getClass().getName() + "sep1"));
            menuManager.add(new Action("Clear") {
                @Override
                public void run() {
                    for (ITransferableDataObject co : data) {
                        co.setChecked(false);
                    }
                    selections.clear();
                    dataViewer.refresh();
                    fireSelectionListeners(Collections.<ITransferableDataObject>emptyList());
                }
            });

            menuManager.add(new Separator(getClass().getName() + ".copyPaste"));

            final Object sel = ((StructuredSelection) dataViewer.getSelection()).getFirstElement();
            final ITransferableDataObject ob = (ITransferableDataObject) sel;
            menuManager.add(copy);
            menuManager.add(paste);
            menuManager.add(delete);
            menuManager.add(new Separator(getClass().getName() + ".filter"));
            if (createFilter != null)
                menuManager.add(createFilter);
            if (clearFilter != null)
                menuManager.add(clearFilter);

            updateActions(copy, paste, delete, createFilter, clearFilter, export, ob, null);

            menuManager.add(new Separator(getClass().getName() + ".export"));
            menuManager.add(export);

            if (H5Loader.isH5(getFileName())) {
                menuManager.add(new Separator(getClass().getName() + "sep2"));

                dataReduction.setEnabled(false);
                menuManager.add(dataReduction);
            }

            menuManager.add(new Separator(getClass().getName() + ".error"));

            /**
             * What follows is adding some actions for setting errors on other plotted data sets.
             * The logic is a bit convoluted at the moment.
             */
            final ILazyDataset currentSelectedData = ob != null ? getLazyValue(ob.getVariable(), null) : null;

            if (currentSelectedData != null) {
                if (selections != null && selections.size() > 0) {
                    menuManager.add(new Action("Set '" + ob.getName() + "' as error on other plotted data...") {
                        @Override
                        public void run() {
                            final PlotDataChooseDialog dialog = new PlotDataChooseDialog(
                                    Display.getDefault().getActiveShell());
                            dialog.init(selections, ob);
                            final ITransferableDataObject plotD = dialog.choose();
                            if (plotD != null) {
                                ILazyDataset set = (ILazyDataset) getLazyValue(plotD.getVariable(), null);

                                if (set instanceof IErrorDataset) { // Data was all read in already.
                                    IErrorDataset errSet = (IErrorDataset) set;
                                    // Read plotted data into memory, so can read error data too.
                                    errSet.setError(getVariableValue(ob.getVariable(), null));

                                } else { // Set errors lazily
                                    set.setError(currentSelectedData);
                                }
                                fireSelectionListeners(selections);

                            }
                        }
                    });
                }

                final boolean isDatasetError = currentSelectedData instanceof IErrorDataset
                        && ((IErrorDataset) currentSelectedData).hasErrors();
                final boolean isLazyError = currentSelectedData.getError() != null;
                if (isDatasetError || isLazyError) {
                    menuManager.add(new Action("Clear error on '" + currentSelectedData.getName() + "'") {
                        @Override
                        public void run() {
                            currentSelectedData.setError(null);
                            fireSelectionListeners(selections);
                        }
                    });
                }
            }

            // TODO Send the dataset via the flattening service.
            if (currentSelectedData != null && currentSelectedData instanceof IDataset) {

                inject.setData(ob.getVariable(), (IDataset) currentSelectedData);
                inject.setText("Open '" + currentSelectedData.getName() + "' in scripting console");

                menuManager.add(inject);
            }

            menuManager.add(new Separator(getClass().getName() + "sep3"));
            menuManager.add(new Action("Preferences...") {
                @Override
                public void run() {
                    PreferenceDialog pref = PreferencesUtil.createPreferenceDialogOn(
                            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                            "org.edna.workbench.editors.preferencePage", null, null);
                    if (pref != null)
                        pref.open();
                }
            });

            menuManager.addMenuListener(new IMenuListener() {
                @Override
                public void menuAboutToShow(IMenuManager manager) {
                    if (dataReduction != null)
                        dataReduction.setEnabled(isDataReductionToolActive());
                }
            });
        }
    });

}

From source file:org.dawb.workbench.ui.data.PlotDataComponent.java

License:Open Source License

private void createDimensionalActions(List<Object> rightClickActions, boolean isToolbar) {

    this.dataComponentActions = new ArrayList<IAction>(11);

    final Action preferences = new Action("Configure column preferences...",
            Activator.getImageDescriptor("icons/application_view_columns.png")) {
        public void run() {
            PreferenceDialog pref = PreferencesUtil.createPreferenceDialogOn(
                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), EditorPreferencePage.ID,
                    null, null);/*w  w w .  j  a va 2s . co m*/
            if (pref != null)
                pref.open();
        }

    };

    if (staggerSupported) {
        // Warning this is horrible:
        final Action xyAction = new Action("XY Plot", SWT.TOGGLE) {
            @Override
            public void run() {
                setPlotMode(PlotType.XY);
            }
        };
        xyAction.setImageDescriptor(Activator.getImageDescriptor("/icons/chart_curve.png"));
        xyAction.setToolTipText("XY Graph of Data, overlayed for multiple data.");
        dataComponentActions.add(xyAction);

        final Action staggeredAction = new Action("XY staggered in Z", SWT.TOGGLE) {
            @Override
            public void run() {
                setPlotMode(PlotType.XY_STACKED);
            }
        };
        staggeredAction.setImageDescriptor(Activator.getImageDescriptor("/icons/chart_curve_staggered.png"));
        staggeredAction.setToolTipText("XY Graph of Data, staggered in Z for multiple data.");
        dataComponentActions.add(staggeredAction);

        final Action xyzAction = new Action("XYZ", SWT.TOGGLE) {
            @Override
            public void run() {
                setPlotMode(PlotType.XY_STACKED_3D);
            }
        };
        xyzAction.setImageDescriptor(Activator.getImageDescriptor("/icons/chart_curve_3D.png"));
        xyzAction.setToolTipText("XYZ, X is the first chosen data and Z the last.");
        dataComponentActions.add(xyzAction);

        rightClickActions.add(new Separator());
        rightClickActions.add(xyAction);
        rightClickActions.add(staggeredAction);
        rightClickActions.add(xyzAction);
        rightClickActions.add(new Separator());

        updatePlotDimenionsSelected(xyAction, staggeredAction, xyzAction, getPlottingSystem().getPlotType());

        // Removed when part disposed.
        addPlotModeListener(new PlotModeListener() {
            @Override
            public void plotChangePerformed(PlotType plotMode) {
                updatePlotDimenionsSelected(xyAction, staggeredAction, xyzAction, plotMode);
                updateSelection(true);
            }
        });

        final Display dis = PlatformUI.getWorkbench().getDisplay();
        if (isToolbar) {
            dis.asyncExec(new Runnable() {
                @Override
                public void run() {
                    updatePlotDimenionsSelected(xyAction, staggeredAction, xyzAction,
                            getPlottingSystem().getPlotType());
                }
            });
        }
    }

    final Action setX = new Action("Set selected data as x-axis") {
        public void run() {

            final TransferableDataObject sel = (TransferableDataObject) ((IStructuredSelection) dataViewer
                    .getSelection()).getFirstElement();
            if (sel == null)
                return;

            setAsX(sel);
        }
    };
    setX.setImageDescriptor(Activator.getImageDescriptor("/icons/to_x.png"));
    setX.setToolTipText("Changes the plot to use selected data set as the x-axis.");
    dataComponentActions.add(setX);
    rightClickActions.add(setX);
    rightClickActions.add(new Separator());

    final Action addExpression = new Action("Add expression") {
        public void run() {
            final ICommandService cs = (ICommandService) PlatformUI.getWorkbench()
                    .getService(ICommandService.class);
            try {
                cs.getCommand("org.dawb.workbench.editors.addExpression")
                        .executeWithChecks(new ExecutionEvent());
            } catch (Exception e) {
                logger.error("Cannot run action", e);
            }

        }
    };
    addExpression.setImageDescriptor(Activator.getImageDescriptor("/icons/add_expression.png"));
    addExpression
            .setToolTipText("Adds an expression which can be plotted. Must be function of other data sets.");
    dataComponentActions.add(addExpression);
    rightClickActions.add(addExpression);

    final Action deleteExpression = new Action("Delete expression") {
        public void run() {
            final ICommandService cs = (ICommandService) PlatformUI.getWorkbench()
                    .getService(ICommandService.class);
            try {
                cs.getCommand("org.dawb.workbench.editors.deleteExpression")
                        .executeWithChecks(new ExecutionEvent());
            } catch (Exception e) {
                logger.error("Cannot run action", e);
            }
        }
    };
    deleteExpression.setImageDescriptor(Activator.getImageDescriptor("/icons/delete_expression.png"));
    deleteExpression.setToolTipText("Deletes an expression.");
    dataComponentActions.add(deleteExpression);
    rightClickActions.add(deleteExpression);

    dataComponentActions.add(preferences);

}

From source file:org.dawb.workbench.ui.editors.CSVDataEditor.java

License:Open Source License

private void createActions(final ContributionManager toolMan) {

    final Action refresh = new Action("Refresh", IAction.AS_PUSH_BUTTON) {
        @Override/*from ww w. ja va2s. com*/
        public void run() {
            update();
        }
    };
    refresh.setImageDescriptor(Activator.getImageDescriptor("icons/reset.gif"));
    toolMan.add(refresh);

    toolMan.add(new Separator(getClass().getName() + "Sep1"));

    final Action exportCsv = new Action("Export current plotted data to csv file", IAction.AS_PUSH_BUTTON) {
        @Override
        public void run() {
            CSVUtils.createCSV(EclipseUtils.getIFile(getEditorInput()), data, "_plot");
        }
    };
    exportCsv.setImageDescriptor(Activator.getImageDescriptor("icons/page_white_excel.png"));
    toolMan.add(exportCsv);

    toolMan.add(new Separator(getClass().getName() + "Sep1"));

    final Action format = new Action("Preferences...", IAction.AS_PUSH_BUTTON) {
        @Override
        public void run() {
            PreferenceDialog pref = PreferencesUtil.createPreferenceDialogOn(
                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                    "uk.ac.diamond.scisoft.analysis.rcp.preferencePage", null, null);
            if (pref != null)
                pref.open();
        }
    };
    format.setImageDescriptor(Activator.getImageDescriptor("icons/application_view_list.png"));
    toolMan.add(format);
}

From source file:org.dawb.workbench.ui.editors.preference.EditorPreferencesHandler.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    PreferenceDialog pref = PreferencesUtil.createPreferenceDialogOn(
            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), EditorPreferencePage.ID, null,
            null);//  w  w w  . java  2  s  . co m
    if (pref != null)
        pref.open();
    return Boolean.TRUE;
}

From source file:org.dawnsci.breadcrumb.navigation.views.AbstractNavigationView.java

License:Open Source License

protected void createActions() {

    final IToolBarManager man = getViewSite().getActionBars().getToolBarManager();
    final MenuManager menuMan = new MenuManager();

    man.add(new Separator("breadcrumb.group"));

    Action add = new Action("Add another breadcrumb search",
            Activator.getImageDescriptor("icons/ui-tooltip--plus.png")) {
        public void run() {
            addBreadcrumb();/* w ww .j av a2s.c  o m*/
        }
    };
    man.add(add);

    man.add(new Separator("refresh.group"));
    menuMan.add(new Separator("refresh.group"));

    Action refresh = new Action("Refresh table", Activator.getImageDescriptor("icons/refresh_16x16.png")) {
        public void run() {
            refreshDataCollections();
        }
    };
    man.add(refresh);

    refresh = new Action("Refresh connection", Activator.getImageDescriptor("icons/refresh_red.png")) {
        public void run() {
            boolean ok = MessageDialog.openConfirm(Display.getDefault().getActiveShell(),
                    "Confirm Full Refresh",
                    "Are you sure that you would like to do a complete refresh?\n\nThis will loose your selected visit(s) and ask you to start again.");
            if (!ok)
                return;
            connectionManager.logoff();
            connectionManager.connect();
        }
    };
    man.add(refresh);

    // Actions to search data collection table
    for (INavigationDelegateMode mode : pages.keySet()) {
        INavigationDelegate delegate = pages.get(mode);
        if (delegate instanceof AbstractTableDelegate) {
            ((AbstractTableDelegate) delegate).createActions(getViewSite().getActionBars().getToolBarManager(),
                    menuMan);
        }
    }

    // Actions to log in and log out
    connectionManager.createLogActions(getViewSite().getActionBars().getToolBarManager());

    man.add(new Separator("preference.group"));
    menuMan.add(new Separator("preference.group"));

    if (getPreferencePageId() != null) {
        Action ispyPref = new Action("Preferences... (Connection and polling)",
                Activator.getImageDescriptor("icons/data.gif")) {
            @Override
            public void run() {
                PreferenceDialog pref = PreferencesUtil.createPreferenceDialogOn(
                        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), getPreferencePageId(),
                        null, null);
                if (pref != null)
                    pref.open();
            }
        };
        man.add(ispyPref);
        getViewSite().getActionBars().getMenuManager().add(ispyPref);
    }

    Action prefs = new Action("Image Preferences... (For data collection images in gallery)",
            Activator.getImageDescriptor("icons/data.gif")) {
        @Override
        public void run() {
            PreferenceDialog pref = PreferencesUtil.createPreferenceDialogOn(
                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), ViewConstants.PAGE_ID,
                    null, null);
            if (pref != null)
                pref.open();
        }
    };

    getViewSite().getActionBars().getMenuManager().add(prefs);
    menuMan.add(prefs);

    man.add(new SpacerContributionItem(50));

    final CheckableActionGroup grp = new CheckableActionGroup();
    for (final INavigationDelegateMode mode : getDefaultNavigationMode().allValues()) {
        if (mode.isInToolbar()) {
            final Action action = new Action(mode.getLabel(), IAction.AS_CHECK_BOX) {
                public void run() {
                    navigationMode = mode;
                    final INavigationDelegate prov = pages.get(mode);
                    if (prov != null) {
                        setActiveUI(prov.getControl(), mode);
                        selectionChanged(null);
                        // TODO Might want to leave selection so that do not loose plots one day.
                        prov.getSelectionProvider().setSelection(prov.getSelectionProvider().getSelection());
                    }
                }
            };
            action.setId(mode.getId());
            action.setImageDescriptor(mode.getIcon());

            final ActionContributionItem item = new ActionContributionItem(action);
            if (Activator.getDefault().getPreferenceStore().getBoolean(NavigationConstants.SHOW_MODE_LABEL)) {
                item.setMode(ActionContributionItem.MODE_FORCE_TEXT);
            }
            man.add(item);
            grp.add(action);
            action.setChecked(navigationMode == mode);
        }
    }
    man.add(new Separator("tablemode.group"));
    menuMan.add(new Separator("tablemode.group"));

    Activator.getDefault().getPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent event) {
            if (NavigationConstants.SHOW_MODE_LABEL.equals(event.getProperty())) {
                boolean isShowLabel = Activator.getDefault().getPreferenceStore()
                        .getBoolean(NavigationConstants.SHOW_MODE_LABEL);
                int modeCode = isShowLabel ? ActionContributionItem.MODE_FORCE_TEXT : 0;
                for (final INavigationDelegateMode mode : getDefaultNavigationMode().allValues()) {
                    final IContributionItem item = man.find(mode.getId());
                    if (item instanceof ActionContributionItem) {
                        ((ActionContributionItem) item).setMode(modeCode);
                    }
                }
                man.update(true);
            }
        }
    });

    for (INavigationDelegateMode mode : pages.keySet()) {
        INavigationDelegate delegate = pages.get(mode);
        if (delegate instanceof AbstractTableDelegate) {
            ((AbstractTableDelegate) delegate).setMenu(menuMan);
        }
    }

}

From source file:org.dawnsci.commandserver.ui.dialog.PropertiesDialog.java

License:Open Source License

protected Control createDialogArea(Composite parent) {

    // create a composite with standard margins and spacing
    Composite composite = (Composite) super.createDialogArea(parent);
    composite.setLayout(new GridLayout(1, false));

    final CLabel warning = new CLabel(composite, SWT.LEFT);
    warning.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    warning.setImage(Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/error.png").createImage());
    warning.setText("Expert queue configuration parameters, please use with caution.");

    TableViewer viewer = new TableViewer(composite,
            SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
    viewer.setUseHashlookup(true);/*from w  ww .j  a  v  a  2  s. c  om*/
    viewer.getTable().setHeaderVisible(true);
    viewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    createColumns(viewer);
    viewer.setContentProvider(createContentProvider());

    viewer.setInput(props);

    final Button adv = new Button(composite, SWT.PUSH);
    adv.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false));
    adv.setText("Advanced...");

    adv.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            PreferenceDialog pref = PreferencesUtil.createPreferenceDialogOn(getShell(),
                    "org.dawnsci.commandserver.ui.activemqPage", null, null);
            if (pref != null)
                pref.open();
        }
    });

    return composite;
}

From source file:org.dawnsci.mx.ui.editors.MXPlotImageEditor.java

License:Open Source License

@Override
public void createPartControl(final Composite parent) {

    final Composite main = new Composite(parent, SWT.NONE);
    final GridLayout gridLayout = new GridLayout(1, false);
    gridLayout.verticalSpacing = 0;/* w ww.  jav  a 2  s.co  m*/
    gridLayout.marginWidth = 0;
    gridLayout.marginHeight = 0;
    gridLayout.horizontalSpacing = 0;
    main.setLayout(gridLayout);

    this.tools = new Composite(main, SWT.RIGHT);
    tools.setLayout(new GridLayout(2, false));
    GridUtils.removeMargins(tools);
    tools.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false));

    // We use a local toolbar to make it clear to the user the tools
    // that they can use, also because the toolbar actions are 
    // hard coded.

    ToolBarManager toolMan = new ToolBarManager(SWT.FLAT | SWT.RIGHT | SWT.WRAP);
    final ToolBar toolBar = toolMan.createControl(tools);
    toolBar.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));

    //createCustomToolbarActionsRight(toolMan);
    //
    ToolBarManager rightMan = new ToolBarManager(SWT.FLAT | SWT.RIGHT | SWT.WRAP);
    final ToolBar rightBar = rightMan.createControl(tools);
    rightBar.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));

    final MenuManager menuMan = new MenuManager();
    //final IActionBars bars = this.getEditorSite().getActionBars();
    //ActionBarWrapper wrapper = new ActionBarWrapper(toolMan,menuMan,null,(IActionBars2)bars);
    //ActionBarWrapper wrapper = new ActionBarWrapper(toolMan,null,null,null);

    // NOTE use name of input. This means that although two files of the same
    // name could be opened, the editor name is clearly visible in the GUI and
    // is usually short.
    final String plotName = this.getEditorInput().getName();

    final Composite plot = new Composite(main, SWT.NONE);
    plot.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    plot.setLayout(new FillLayout());

    getPlottingSystem().createPlotPart(plot, plotName, null, PlotType.IMAGE, this);
    createPlot();
    IPlotActionSystem actionsys = getPlottingSystem().getPlotActionSystem();
    actionsys.fillZoomActions(toolMan);
    actionsys.fillRegionActions(toolMan);
    actionsys.fillToolActions(toolMan, ToolPageRole.ROLE_2D);

    MenuAction dropdown = new MenuAction("Resolution rings");
    dropdown.setImageDescriptor(Activator.getImageDescriptor("/icons/resolution_rings.png"));

    augmenter.addActions(dropdown);
    toolMan.add(dropdown);

    Action menuAction = new Action("", Activator.getImageDescriptor("/icons/DropDown.png")) {
        @Override
        public void run() {
            final Menu mbar = menuMan.createContextMenu(toolBar);
            mbar.setVisible(true);
        }
    };
    rightMan.add(menuAction);

    menuMan.add(new Action("Diffraction Viewer Preferences", null) {
        @Override
        public void run() {
            PreferenceDialog pref = PreferencesUtil.createPreferenceDialogOn(
                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                    "uk.ac.diamond.scisoft.analysis.rcp.diffractionViewerPreferencePage", null, null);
            if (pref != null)
                pref.open();
        }
    });

    if (toolMan != null)
        toolMan.update(true);
    if (rightMan != null)
        rightMan.update(true);

    getEditorSite().setSelectionProvider(getPlottingSystem().getSelectionProvider());
}

From source file:org.dawnsci.mx.ui.editors.MXPlotImageEditor.java

License:Open Source License

/**
 * Override to provide extra content.//  ww w  . j a  v  a2 s .  c  o  m
 * @param toolMan
 */
protected void createCustomToolbarActionsRight(final ToolBarManager toolMan) {

    toolMan.add(new Separator(getClass().getName() + "Separator1"));

    final Action tableColumns = new Action("Open editor preferences.", IAction.AS_PUSH_BUTTON) {
        @Override
        public void run() {
            PreferenceDialog pref = PreferencesUtil.createPreferenceDialogOn(
                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                    "uk.ac.diamond.scisoft.mxv1.rcp.mxv1PreferencePage", null, null);
            if (pref != null)
                pref.open();
        }
    };
    tableColumns.setChecked(false);
    tableColumns.setImageDescriptor(Activator.getImageDescriptor("icons/application_view_columns.png"));

    toolMan.add(tableColumns);

}

From source file:org.dawnsci.plotting.system.LightWeightPlotActions.java

License:Open Source License

/**
 * Create some special image manipulation 
 * @param xyGraph2//  w w  w .  j a  v  a2s  .c om
 */
private void createSpecialImageActions(XYRegionGraph xyGraph2) {

    final ICommandService service = (ICommandService) PlatformUI.getWorkbench()
            .getService(ICommandService.class);

    final Command command = service.getCommand("org.embl.cca.dviewer.phaCommand");

    if (command != null) {
        final Action action = new Action("Run PHA algorithm to highlight spots.", IAction.AS_CHECK_BOX) {
            public void run() {
                final ExecutionEvent event = new ExecutionEvent(command, Collections.EMPTY_MAP, this,
                        actionBarManager.getSystem());
                try {
                    command.executeWithChecks(event);
                } catch (Throwable e) {
                    logger.error("Cannot execute command '" + command.getId(), e);
                }
            }
        };
        action.setImageDescriptor(PlottingSystemActivator.getImageDescriptor("icons/pha.png"));

        final Action prefs = new Action("PHA Preferences...") {
            public void run() {
                PreferenceDialog pref = PreferencesUtil.createPreferenceDialogOn(
                        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                        "org.embl.cca.dviewer.rcp.preference.pha", null, null);
                if (pref != null)
                    pref.open();
            }
        };
        prefs.setImageDescriptor(PlottingSystemActivator.getImageDescriptor("icons/pha-preferences.png"));

        actionBarManager.registerToolBarGroup(ToolbarConfigurationConstants.SPECIALS.getId());
        actionBarManager.registerAction(ToolbarConfigurationConstants.SPECIALS.getId(), action,
                ActionType.IMAGE, ManagerType.TOOLBAR);
        actionBarManager.registerAction(ToolbarConfigurationConstants.SPECIALS.getId(), prefs, ActionType.IMAGE,
                ManagerType.TOOLBAR);
    }
}

From source file:org.dawnsci.plotting.system.LightWeightPlotActions.java

License:Open Source License

private void createPreferencesAction() {
    actionBarManager.registerMenuBarGroup("org.dawnsci.plotting.system.toolbar.preferences");
    final Action openPreferences = new Action("Toolbar Preferences...") {
        public void run() {
            PreferenceDialog pref = PreferencesUtil.createPreferenceDialogOn(
                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                    "org.dawnsci.plotting.system.toolbarPreferencePage", null, null);
            if (pref != null)
                pref.open();
        }//  ww w.  j  av a  2  s  .  com
    };
    actionBarManager.registerAction("org.dawnsci.plotting.system.toolbar.preferences", openPreferences,
            ActionType.ALL, ManagerType.MENUBAR);
}