Example usage for org.eclipse.jface.action GroupMarker GroupMarker

List of usage examples for org.eclipse.jface.action GroupMarker GroupMarker

Introduction

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

Prototype

public GroupMarker(String groupName) 

Source Link

Document

Create a new group marker with the given name.

Usage

From source file:org.csstudio.dal.ui.internal.connectionview.ConnectionStateView.java

License:Open Source License

/**
 * {@inheritDoc}/*  w w  w.  ja  v  a2 s . com*/
 */
@Override
public void createPartControl(final Composite parent) {
    // layout
    parent.setLayout(new GridLayout());

    // create button panel
    final Composite buttons = new Composite(parent, SWT.NONE);
    buttons.setLayout(new FillLayout());
    buttons.setLayoutData(LayoutUtil.createGridDataForHorizontalFillingCell());

    final FilterButton buttonAll = new FilterButton(buttons, SWT.FLAT, "all", ConnectionState.values());
    final FilterButton buttonConnected = new FilterButton(buttons, SWT.FLAT, "connected",
            ConnectionState.CONNECTED);
    final FilterButton buttonNotConnected = new FilterButton(buttons, SWT.FLAT, "not connected",
            ConnectionState.CONNECTION_LOST, ConnectionState.INITIAL, ConnectionState.CONNECTION_FAILED,
            ConnectionState.DISCONNECTED, ConnectionState.UNKNOWN);

    // create the viewer and ...
    _viewer = createChannelTable(parent);

    // .. initialize layout
    _viewer.getControl().setLayoutData(LayoutUtil.createGridDataForFillingCell());

    // .. initialize content provider
    _viewer.setContentProvider(new IStructuredContentProvider() {
        /**
         * {@inheritDoc}
         */
        @Override
        public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput) {

        }

        /**
         * {@inheritDoc}
         */
        @Override
        public Object[] getElements(final Object parent) {
            final List<IConnector> statistics = ((IProcessVariableConnectionService) parent).getConnectors();

            // refresh the filter button states
            buttonAll.refreshLabel(statistics);
            buttonConnected.refreshLabel(statistics);
            buttonNotConnected.refreshLabel(statistics);

            return statistics.toArray();
        }

        /**
         * {@inheritDoc}
         */
        @Override
        public void dispose() {

        }

    });

    // ... initialize label provider
    _viewer.setLabelProvider(new LabelProvider());
    _viewer.setInput(
            ProcessVariableConnectionServiceFactory.getDefault().getProcessVariableConnectionService());

    // ... initialize comparators (important for sorting)
    _viewer.setComparator(new ViewerComparator() {
        @Override
        public int compare(final Viewer viewer, final Object e1, final Object e2) {
            return _sortDirection.getComparator().compare((IConnector) e1, (IConnector) e2);
        }
    });

    // ... initialize tooltip support
    ColumnViewerToolTipSupport.enableFor(_viewer, ToolTip.NO_RECREATE);

    // ... initialize context menu
    final MenuManager menuManager = new MenuManager();
    // menuManager.addMenuListener(new IMenuListener() {
    //
    // public void menuAboutToShow(final IMenuManager manager) {
    // manager.add(new GroupMarker(
    // IWorkbenchActionConstants.MB_ADDITIONS));
    // }
    // });

    menuManager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));

    _viewer.getControl().setMenu(menuManager.createContextMenu(_viewer.getControl()));

    getViewSite().registerContextMenu(menuManager, _viewer);
    getViewSite().setSelectionProvider(_viewer);

    // initialize the update job
    _updateJob = new UIJob("Update Connector State View") {
        @Override
        public IStatus runInUIThread(final IProgressMonitor monitor) {
            _viewer.refresh();
            if (!monitor.isCanceled()) {
                _updateJob.schedule(2000);
                return Status.OK_STATUS;
            } else {
                return Status.CANCEL_STATUS;
            }
        }
    };

    _updateJob.schedule(5000);

}

From source file:org.csstudio.dal.ui.internal.developmentsupport.util.ContainerView.java

License:Open Source License

/**
 * Configures all listeners for the TreeViewer.
 *//*www .j av  a 2s  .  c o m*/
private void configureContextMenu(final TreeViewer tv) {
    final MenuManager menuMgr = new MenuManager("", ID); //$NON-NLS-1$
    //        menuMgr.add(new GroupMarker(IWorkbenchIds.GROUP_CSS_MB3));
    menuMgr.add(new Separator());
    menuMgr.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));

    menuMgr.setRemoveAllWhenShown(true);

    final Menu contextMenu = menuMgr.createContextMenu(tv.getTree());
    tv.getTree().setMenu(contextMenu);

    // Register viewer with site. This has to be done before making the
    // actions.
    getViewSite().registerContextMenu(menuMgr, tv);
    getViewSite().setSelectionProvider(tv);
}

From source file:org.csstudio.display.builder.rcp.run.ContextMenuSupport.java

License:Open Source License

private void fillContextMenu(final IMenuManager manager) {
    final Widget context_menu_widget = view.getActiveWidget();
    if (context_menu_widget == null) {
        logger.log(Level.WARNING, "Missing context_menu_widget");
        manager.add(new Action("No widget") {
        });/*from   w w w. j  a v a2  s  .c  o m*/
    } else {
        // Widget info
        manager.add(new WidgetInfoAction(context_menu_widget));

        // Actions of the widget
        for (ActionInfo info : context_menu_widget.propActions().getValue().getActions()) {
            if (info.getType() == ActionType.OPEN_DISPLAY) {
                // Add variant for all the available Target types: Replace, new Tab, ...
                final OpenDisplayActionInfo open_info = (OpenDisplayActionInfo) info;
                for (Target target : Target.values()) {
                    // STANDALONE can be achieved via StandaloneAction on new display
                    if (target == Target.STANDALONE)
                        continue;
                    final String desc = target == Target.REPLACE ? open_info.getDescription()
                            : open_info.getDescription() + " (" + target + ")";
                    manager.add(new ActionInfoWrapper(context_menu_widget, new OpenDisplayActionInfo(desc,
                            open_info.getFile(), open_info.getMacros(), target)));
                }
            } else
                manager.add(new ActionInfoWrapper(context_menu_widget, info));
        }

        // Actions of the widget runtime
        final WidgetRuntime<Widget> runtime = RuntimeUtil.getRuntime(context_menu_widget);
        if (runtime == null)
            throw new NullPointerException("Missing runtime for " + context_menu_widget);
        for (RuntimeAction info : runtime.getRuntimeActions())
            manager.add(new RuntimeActionWrapper(context_menu_widget, info));
    }

    // Placeholder for ProcessVariable object contributions
    manager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));

    manager.add(new Separator());

    if (context_menu_widget != null) {
        final Node node = JFXBaseRepresentation.getJFXNode(context_menu_widget);
        final Scene scene = node.getScene();

        manager.add(new SaveSnapshotAction(shell, scene));
        manager.add(new PrintAction(shell, scene));
        manager.add(new SendEMailAction(shell, scene));
        manager.add(new SendLogbookAction(shell, scene));
        manager.add(new FullScreenAction(view.getSite().getPage()));

        if (support_standalone)
            manager.add(new StandaloneAction(view));
    }

    // Placeholder for the display editor.
    // If editor.rcp plugin is included, it adds "Open in editor"
    manager.add(new Separator("display_editor"));
    manager.add(new ReloadDisplayAction());
}

From source file:org.csstudio.display.pace.gui.GUI.java

License:Open Source License

/** Fill context menu with actions for the currently selected cells.
 *  @param manager Menu manager//from w  w w . j av  a2s  .c  o  m
 *  @see IMenuListener
 */
@Override
public void menuAboutToShow(final IMenuManager manager) {
    final Cell cells[] = getSelectedCells();
    manager.add(new RestoreCellAction(cells));
    manager.add(new SetCellValueAction(table_viewer.getTable().getShell(), cells));
    // Placeholder for CSS PV contributions
    manager.add(new GroupMarker("additions")); //$NON-NLS-1$
    manager.add(new Separator());
}

From source file:org.csstudio.scan.ui.scanmonitor.GUI.java

License:Open Source License

/** Add context menu to table
 *  @param site/*  w w  w. j  a  v  a 2s.  c om*/
 */
private void createContextMenu(final IWorkbenchPartSite site) {
    final Shell shell = table_viewer.getControl().getShell();
    final MenuManager manager = new MenuManager();
    manager.setRemoveAllWhenShown(true);
    manager.addMenuListener(new IMenuListener() {
        @Override
        public void menuAboutToShow(final IMenuManager manager) {
            final ScanInfo[] infos = getSelectedScans();
            manager.add(new GroupMarker("scan")); //$NON-NLS-1$
            if (infos == null)
                return;
            // Allow resume if anything's paused
            for (ScanInfo info : infos)
                if (info.getState() == ScanState.Paused) {
                    manager.add(new ResumeAction(shell, model, infos));
                    break;
                }
            // Allow pause when anything's running
            for (ScanInfo info : infos)
                if (info.getState() == ScanState.Running) {
                    manager.add(new PauseAction(shell, model, infos));
                    manager.add(new NextAction(shell, model, infos));
                    break;
                }
            // Abort if anything is not done
            for (ScanInfo info : infos)
                if (!info.getState().isDone()) {
                    manager.add(new AbortAction(shell, model, infos));
                    break;
                }
            // Remove if anything is done
            for (ScanInfo info : infos)
                if (info.getState().isDone()) {
                    manager.add(new RemoveAction(shell, model, infos));
                    break;
                }
            manager.add(new RemoveCompletedAction(shell, model));
            if (infos.length >= 1)
                manager.add(new ShowDevicesAction(shell, model, infos));
            manager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
        }
    });

    final Table table = table_viewer.getTable();
    final Menu menu = manager.createContextMenu(table);
    menu.addMenuListener(new MenuListener() {
        @Override
        public void menuShown(final MenuEvent e) {
            context_menu_is_active = true;
        }

        @Override
        public void menuHidden(final MenuEvent e) {
            context_menu_is_active = false;
            if (suppressed_table_updates)
                // We _are_ on the UI thread, refreshing the table now
                // will change the selection, and then selection-based
                // context menu entries won't work even though they were
                // shown in the menu OK.
                // -> Schedule this later
                table_viewer.getTable().getDisplay().asyncExec(new Runnable() {
                    @Override
                    public void run() {
                        suppressed_table_updates = false;
                        table_viewer.refresh(false);
                    }
                });
        }
    });
    table.setMenu(menu);

    // Allow contributions to the menu
    if (site != null)
        site.registerContextMenu(manager, table_viewer);
}

From source file:org.csstudio.trends.databrowser2.editor.DataBrowserEditor.java

License:Open Source License

/** Dynamically fill context menu
 *  @param manager//w  w  w. ja  va 2 s. c om
 */
private void fillContextMenu(final IMenuManager manager) {
    final Activator activator = Activator.getDefault();
    final Shell shell = getSite().getShell();
    Point location = plot.getPlot().getDisplay().getCursorLocation();
    location = plot.getPlot().toControl(location);
    boolean inXAxis = plot.getPlot().inXAxis(location);
    int inYAxis = plot.getPlot().inYAxis(location);
    final UndoableActionManager op_manager = plot.getPlot().getUndoableActionManager();
    if (inYAxis != -1) {
        AxisConfig axis_config = model.getAxis(inYAxis);
        manager.add(new AutoscaleAxisAction(axis_config));
        manager.add(new ScaleTypeAxisAction(axis_config));
        manager.add(new GridAxisAction(axis_config));
        manager.add(new Separator());
        manager.add(new AxisNameAxisAction(axis_config));
        manager.add(new TraceNameAxisAction(axis_config));
        manager.add(new AxisNameEditAction(axis_config));
        manager.add(new AxisMinMaxEditAction(axis_config));
    } else if (inXAxis)
        manager.add(new TimeAxisGridAction(Messages.GridTT, model));
    else {
        manager.add(plot.getPlot().getToolbarAction());
        manager.add(plot.getPlot().getLegendAction());
        manager.add(new Separator());
        manager.add(new AddPVAction(op_manager, shell, model, false));
        manager.add(new AddPVAction(op_manager, shell, model, true));
        final boolean is_rcp = SingleSourcePlugin.getUIHelper().getUI() == UI.RCP;
        if (is_rcp) {
            try {
                for (IAction imp : SampleImporters.createImportActions(op_manager, shell, model))
                    manager.add(imp);
            } catch (Exception ex) {
                ExceptionDetailsErrorDialog.openError(shell, Messages.Error, ex);
            }
        }
        manager.add(new RemoveUnusedAxesAction(op_manager, model));
        manager.add(new RefreshAction(controller));
        manager.add(new Separator());

        manager.add(new OpenPropertiesAction());
        manager.add(new OpenViewAction(SearchView.ID, Messages.OpenSearchView,
                activator.getImageDescriptor("icons/search.gif")));
        if (is_rcp)
            manager.add(new OpenViewAction(ExportView.ID, Messages.OpenExportView,
                    activator.getImageDescriptor("icons/export.png")));
        manager.add(new OpenViewAction(SampleView.ID, Messages.InspectSamples,
                activator.getImageDescriptor("icons/inspect.gif")));

        manager.add(new OpenPerspectiveAction(activator.getImageDescriptor("icons/databrowser.png"),
                Messages.OpenDataBrowserPerspective, Perspective.ID));
        manager.add(new OpenViewAction(WaveformView.ID, Messages.OpenWaveformView,
                activator.getImageDescriptor("icons/wavesample.gif")));

        manager.add(new Separator());
        manager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
        if (is_rcp) {
            manager.add(new Separator());
            manager.add(plot.getPlot().getSnapshotAction());
            if (EMailSender.isEmailSupported())
                manager.add(new SendEMailAction(shell, plot.getPlot()));
            manager.add(new PrintAction(shell, plot.getPlot()));
            if (SendToElogAction.isElogAvailable())
                manager.add(new SendToElogAction(shell, plot.getPlot()));
        }
    }
}

From source file:org.csstudio.trends.databrowser2.propsheet.AxesTableHandler.java

License:Open Source License

/** Add context menu to axes_table */
private void createContextMenu() {
    final MenuManager menu = new MenuManager();
    menu.setRemoveAllWhenShown(true);/*from  w  ww.  j  a  va 2  s .c om*/
    menu.addMenuListener(new IMenuListener() {
        @Override
        public void menuAboutToShow(IMenuManager manager) {
            menu.add(new AddAxisAction(operations_manager, model));
            if (!axes_table.getSelection().isEmpty())
                menu.add(new DeleteAxesAction(operations_manager, axes_table, model));
            if (model.getEmptyAxis() != null)
                menu.add(new RemoveUnusedAxesAction(operations_manager, model));
            menu.add(new Separator());
            menu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
        }
    });
    final Table table = axes_table.getTable();
    table.setMenu(menu.createContextMenu(table));
}

From source file:org.csstudio.trends.databrowser2.propsheet.DataBrowserPropertySheetPage.java

License:Open Source License

/** Create context menu and toolbar actions for the traces table */
private void createTracesMenuAndToolbarActions() {
    final MenuManager menu = new MenuManager();
    menu.setRemoveAllWhenShown(true);/*  w  w  w .j  av a 2  s  .c  o  m*/
    final Shell shell = trace_table.getControl().getShell();
    final AddPVAction add_pv = new AddPVAction(operations_manager, shell, model, false);
    final AddPVAction add_formula = new AddPVAction(operations_manager, shell, model, true);
    final EditItemsAction edit_pv = new EditItemsAction(operations_manager, shell, trace_table, model);
    final DeleteItemsAction delete_pv = new DeleteItemsAction(operations_manager, trace_table, model);
    menu.addMenuListener(new IMenuListener() {
        @Override
        public void menuAboutToShow(IMenuManager manager) {
            final PVItem pvs[] = getSelectedPVs();
            menu.add(add_pv);
            menu.add(add_formula);
            menu.add(edit_pv);
            if (pvs.length == 1)
                menu.add(new MoveItemAction(operations_manager, model, pvs[0], true));
            menu.add(delete_pv);
            if (pvs.length == 1)
                menu.add(new MoveItemAction(operations_manager, model, pvs[0], false));
            menu.add(new RemoveUnusedAxesAction(operations_manager, model));
            if (pvs.length > 0) {
                menu.add(new AddArchiveAction(operations_manager, shell, pvs));
                menu.add(new UseDefaultArchivesAction(operations_manager, pvs));
            }
            menu.add(new Separator());
            menu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
        }
    });

    final Table table = trace_table.getTable();
    table.setMenu(menu.createContextMenu(table));
    // Allow object contributions based on selected items
    getSite().registerContextMenu(menu.getId(), menu, trace_table);

    // Add to tool bar
    final IToolBarManager toolbar = getSite().getActionBars().getToolBarManager();
    toolbar.add(add_pv);
    toolbar.add(add_formula);
}

From source file:org.csstudio.trends.databrowser2.propsheet.DataBrowserPropertySheetPage.java

License:Open Source License

/** Create context menu for the archive table,
 *  which depends on the currently selected PVs
 *///from   w  w  w  .java 2  s.c o m
private void createArchiveMenu() {
    // Create dynamic context menu, content changes depending on selections
    final MenuManager menu = new MenuManager();
    menu.setRemoveAllWhenShown(true);
    menu.addMenuListener(new IMenuListener() {
        @Override
        public void menuAboutToShow(IMenuManager manager) {
            // Determine selected PV Items
            final PVItem pvs[] = getSelectedPVs();
            if (pvs.length <= 0)
                return;

            menu.add(new AddArchiveAction(operations_manager, control.getShell(), pvs));
            menu.add(new UseDefaultArchivesAction(operations_manager, pvs));

            // Only allow removal of archives from single PV
            if (pvs.length == 1) {
                // Determine selected archives
                final IStructuredSelection arch_sel = (IStructuredSelection) archive_table.getSelection();
                if (!arch_sel.isEmpty()) {
                    final Object[] objects = arch_sel.toArray();
                    final ArchiveDataSource archives[] = new ArchiveDataSource[objects.length];
                    for (int i = 0; i < archives.length; i++)
                        archives[i] = (ArchiveDataSource) objects[i];
                    menu.add(new DeleteArchiveAction(operations_manager, pvs[0], archives));
                }
            }
            menu.add(new Separator());
            menu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
        }
    });
    final Table table = archive_table.getTable();
    table.setMenu(menu.createContextMenu(table));
}

From source file:org.csstudio.trends.databrowser3.editor.DataBrowserEditor.java

License:Open Source License

/** Dynamically fill context menu
 *  @param manager/*  w w  w  .j av a  2 s . c  o  m*/
 */
private void fillContextMenu(final IMenuManager manager) {
    final Activator activator = Activator.getDefault();
    final Shell shell = getSite().getShell();
    final UndoableActionManager op_manager = plot.getPlot().getUndoableActionManager();
    manager.add(toggle_toolbar);
    manager.add(toggle_legend);
    manager.add(new Separator());
    manager.add(new AddPVAction(op_manager, shell, model, false));
    manager.add(new AddPVAction(op_manager, shell, model, true));
    final boolean is_rcp = SingleSourcePlugin.getUIHelper().getUI() == UI.RCP;
    if (is_rcp) {
        try {
            for (IAction imp : SampleImporters.createImportActions(op_manager, shell, model))
                manager.add(imp);
        } catch (Exception ex) {
            ExceptionDetailsErrorDialog.openError(shell, Messages.Error, ex);
        }
    }
    manager.add(new RemoveUnusedAxesAction(op_manager, model));
    manager.add(new RefreshAction(controller));
    manager.add(new Separator());

    manager.add(new OpenPropertiesAction());
    manager.add(new OpenViewAction(SearchView.ID, Messages.OpenSearchView,
            activator.getImageDescriptor("icons/search.gif")));
    if (is_rcp)
        manager.add(new OpenViewAction(ExportView.ID, Messages.OpenExportView,
                activator.getImageDescriptor("icons/export.png")));
    manager.add(new OpenViewAction(SampleView.ID, Messages.InspectSamples,
            activator.getImageDescriptor("icons/inspect.gif")));

    manager.add(new OpenPerspectiveAction(activator.getImageDescriptor("icons/databrowser.png"),
            Messages.OpenDataBrowserPerspective, Perspective.ID));
    manager.add(new OpenViewAction(WaveformView.ID, Messages.OpenWaveformView,
            activator.getImageDescriptor("icons/wavesample.gif")));

    manager.add(new Separator());
    manager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));

    if (is_rcp) {
        manager.add(new Separator());
        manager.add(snapshot);
        if (EMailSender.isEmailSupported())
            manager.add(new SendEMailAction(shell, plot.getPlot()));
        manager.add(new PrintAction(shell, plot.getPlot()));
        if (SendToElogAction.isElogAvailable())
            manager.add(new SendToElogAction(shell, plot.getPlot()));
    }
}