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:net.refractions.udig.project.ui.internal.ProjectExplorer.java

License:Open Source License

private void addToobarActions() {

    getActionBars().getToolBarManager().add(createLinkAction());
    getActionBars().getToolBarManager().add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
}

From source file:net.refractions.udig.project.ui.internal.ProjectExplorer.java

License:Open Source License

private void addMenuActions() {
    getActionBars().getMenuManager().add(getOpenProjectAction());
    getActionBars().getMenuManager().add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));

}

From source file:net.refractions.udig.project.ui.internal.ProjectExplorer.java

License:Open Source License

/**
 * @see org.eclipse.jface.action.IMenuListener#menuAboutToShow(org.eclipse.jface.action.IMenuManager)
 *///  ww w  .j  ava  2  s.  c  o  m
public void menuAboutToShow(IMenuManager manager) {
    boolean addOpenAction = false;
    for (Iterator iter = ((IStructuredSelection) treeViewer.getSelection()).iterator(); iter.hasNext();) {
        Object obj = iter.next();
        if (obj instanceof IProjectElement) {
            addOpenAction = true;
            break;
        }
    }

    if (addOpenAction) {
        manager.add(getOpenAction());
    }
    manager.add(getOpenProjectAction());
    manager.add(delAction);

    manager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
    // LayerApplicabilityMenuCreator creator = getApplicabilityMenu();
    // if (creator != null)
    // manager.add(creator.getMenuManager());

    manager.add(ApplicationGIS.getToolManager().createOperationsContextMenu(treeViewer.getSelection()));
    manager.add(new Separator());
    manager.add(ActionFactory.EXPORT.create(getSite().getWorkbenchWindow()));
    if (!treeViewer.getSelection().isEmpty()
            && ((IStructuredSelection) treeViewer.getSelection()).getFirstElement() instanceof Map) {
        manager.add(new Separator());
        manager.add(getPropertiesAction());
    }

}

From source file:net.refractions.udig.project.ui.internal.tool.display.MenuToolCategory.java

License:Open Source License

/**
 * Adds items action in the correct locations in the menu.
 * /*from w ww  . j a v  a2  s  . c o m*/
 * @param manager
 */
public void contribute(IMenuManager manager) {
    IWorkbench workbench = PlatformUI.getWorkbench();
    IContextService contextService = (IContextService) workbench.getService(IContextService.class);
    Collection<String> active = (Collection<String>) contextService.getActiveContextIds();

    MenuManager actionMenu = new MenuManager(name, id);
    final String actionExt = "action.ext";
    actionMenu.add(new GroupMarker(actionExt)); //$NON-NLS-1$
    actionMenu.add(new GroupMarker("modal.ext")); //$NON-NLS-1$
    for (ModalItem item : this) {
        ToolProxy tool = (ToolProxy) item;
        String categoryId = tool.getCategoryId();
        if (contextService.getDefinedContextIds().contains(categoryId)) {
            // we have an context for this tool category
            if (!active.contains(categoryId)) {
                continue; // skip this category please!
            }
        }
        if (tool.getType() == ToolProxy.ACTION) {
            String menuPath = tool.getMenuPath();
            IAction action = tool.getAction();

            if (menuPath != null) {
                String root = menuPath.substring(0, menuPath.lastIndexOf("/")); //$NON-NLS-1$
                String groupName = menuPath.substring(menuPath.lastIndexOf("/") + 1, menuPath.length()); //$NON-NLS-1$
                if (groupName.equals(Constants.M_TOOL)) {
                    groupName = "map";
                }
                IMenuManager targetMenu = manager.findMenuUsingPath(root);
                if (targetMenu != null) {
                    IContributionItem find = targetMenu.find(groupName);
                    if (find != null && find instanceof GroupMarker) {
                        //targetMenu.appendToGroup(groupName, action); //$NON-NLS-1$
                        targetMenu.appendToGroup(groupName, tool.getAction());
                        targetMenu.setVisible(true);
                    } else {
                        targetMenu.add(action);
                        targetMenu.setVisible(true);
                    }
                } else
                    actionMenu.appendToGroup(actionExt, tool.getAction()); //$NON-NLS-1$
            } else {
                actionMenu.appendToGroup(actionExt, tool.getAction()); //$NON-NLS-1$
            }
        }
        if (tool.getType() == ToolProxy.MODAL) {
            MenuCurrentToolItem menuItem = new MenuCurrentToolItem(tool);
            tool.addContribution(menuItem);
            actionMenu.appendToGroup("modal.ext", menuItem); //$NON-NLS-1$
        }
    }
    if (actionMenu.getItems().length > 0) {
        // Handle left over tools! Place them in the map menu?
        String menuPath = "map"; // was Constants.M_TOOL
        IMenuManager toolManager = manager.findMenuUsingPath(menuPath);
        if (toolManager == null) {
            toolManager = new MenuManager(Messages.MenuToolCategory_menu_manager_title, "tools"); //$NON-NLS-1$
            manager.add(toolManager);
            toolManager.add(new GroupMarker(actionExt)); //$NON-NLS-1$
            toolManager.add(new GroupMarker("modal.ext")); //$NON-NLS-1$
        }
        if (toolManager.find(actionExt) == null) {
            toolManager.add(new GroupMarker(actionExt)); //$NON-NLS-1$
        }
        toolManager.appendToGroup(actionExt, actionMenu); //$NON-NLS-1$
        toolManager.setVisible(true);
    }
}

From source file:net.refractions.udig.project.ui.internal.tool.display.ToolManager.java

License:Open Source License

/**
 * Used to contribute Tools to the provided menu manger.
 * <p>//from   www.j  av  a  2s  .co m
 * The following contributions are made:
 * <ul>
 * <li>navigate: forward and backward buttons
 * <li>map: an entry for each tool category
 * </ul>
 */
public void contributeToMenu(IMenuManager manager) {
    IMenuManager navigateMenu = manager.findMenuUsingPath(IWorkbenchActionConstants.M_NAVIGATE);

    if (navigateMenu == null) {
        // I would like to arrange for the Navigate menu to already
        // be in place before the ToolManager is kicked into action
        // (this is part of the missions to have uDig plugins walk
        //  softly when being hosted in other RCP applications)
        // See UDIGActionBarAdvisor for hosting requirements.
        navigateMenu = new MenuManager(Messages.ToolManager_menu_manager_title,
                IWorkbenchActionConstants.M_NAVIGATE);

        IContributionItem additions = manager.find(IWorkbenchActionConstants.MB_ADDITIONS);
        if (additions == null || !(additions instanceof GroupMarker)) {
            manager.add(navigateMenu);
        } else {
            manager.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, navigateMenu);
        }
        navigateMenu.add(new GroupMarker(IWorkbenchActionConstants.NAV_START));
        navigateMenu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
        navigateMenu.add(new GroupMarker(IWorkbenchActionConstants.NAV_END));
    }
    IWorkbench workbench = PlatformUI.getWorkbench();
    IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
    // we are using the global BACK and FORWARD actions here
    // and will register "handlers" for these commands 
    navigateMenu.appendToGroup(IWorkbenchActionConstants.NAV_END, ActionFactory.BACK.create(window));
    navigateMenu.appendToGroup(IWorkbenchActionConstants.NAV_END, ActionFactory.FORWARD.create(window));

    if (!manager.isVisible()) {
        // since this is the top level menu bar why would it not be visible?
        manager.setVisible(true);
    }
    IMenuManager mapMenu = manager.findMenuUsingPath("map");
    if (mapMenu == null) {
        // Once again the hosting RCP application should of provided
        // us with a Map menu; but let's be careful and make our own here
        // if needed.
        // See UDIGActionBarAdvisor for hosting requirements.
        mapMenu = new MenuManager(Messages.ToolManager_menu_manager_title, "map");
        manager.add(mapMenu);
        mapMenu.add(new GroupMarker("mapStart"));
        mapMenu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
        mapMenu.add(new GroupMarker("mapEnd"));
    }
    // churn through each category and add stuff as needed
    // note we check with the cmdService to see what we if the actionSet
    // associated with this cateogry is turned on by the
    // current perspective.
    for (MenuToolCategory category : menuCategories) {
        category.contribute(manager);
    }
}

From source file:net.refractions.udig.tool.select.TableView.java

License:Open Source License

private void createContextMenu() {
    contextMenu = new MenuManager();

    contextMenu.setRemoveAllWhenShown(true);
    contextMenu.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager mgr) {
            contextMenu.add(deleteAction);
            contextMenu.add(zoom);//from www  . j ava 2  s.  c o  m
            contextMenu.add(promoteSelection);
            contextMenu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
            contextMenu.add(ApplicationGIS.getToolManager().createOperationsContextMenu(getSelection()));
            contextMenu.add(ActionFactory.EXPORT.create(getSite().getWorkbenchWindow()));
        }

    });

    // Create menu.
    table.setMenuManager(contextMenu);
    getSite().registerContextMenu(contextMenu, this);
}

From source file:net.refractions.udig.ui.UDIGMenuBuilder.java

License:Open Source License

/**
 * @param menuBar/*from   ww w .j  a v a2  s .co  m*/
 * @param window The window that contains this menu
 */
public void fillMenuBar(IMenuManager menuBar, IWorkbenchWindow window) {

    IMenuManager fileMenu = menuBar.findMenuUsingPath(IWorkbenchActionConstants.M_FILE);
    if (fileMenu == null) {
        fileMenu = new MenuManager(Messages.UDIGWorkbenchAdvisor_file, IWorkbenchActionConstants.M_FILE);
        if (menuBar.getItems().length > 0) {
            menuBar.insertBefore(menuBar.getItems()[0].getId(), fileMenu);
        } else {
            menuBar.add(fileMenu);
        }
    }

    IMenuManager editMenu = menuBar.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
    if (editMenu == null) {
        editMenu = new MenuManager(Messages.UDIGWorkbenchAdvisor_edit, IWorkbenchActionConstants.M_EDIT);
        menuBar.insertAfter(IWorkbenchActionConstants.M_FILE, editMenu);
    }
    if (menuBar.findUsingPath(IWorkbenchActionConstants.MB_ADDITIONS) == null) {
        menuBar.insertAfter(IWorkbenchActionConstants.M_EDIT,
                new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
    }
    IMenuManager windowMenu = menuBar.findMenuUsingPath(IWorkbenchActionConstants.M_WINDOW);
    if (windowMenu == null) {
        windowMenu = new MenuManager(Messages.UDIGWorkbenchAdvisor_window, IWorkbenchActionConstants.M_WINDOW);
        menuBar.insertAfter(IWorkbenchActionConstants.MB_ADDITIONS, windowMenu);
    }
    IMenuManager helpMenu = menuBar.findMenuUsingPath(IWorkbenchActionConstants.M_HELP);
    if (helpMenu == null) {
        helpMenu = new MenuManager(Messages.UDIGWorkbenchAdvisor_help, IWorkbenchActionConstants.M_HELP);
        menuBar.insertAfter(IWorkbenchActionConstants.M_WINDOW, helpMenu);
    }

    fillFileMenu(window, fileMenu);
    fillEditMenu(window, editMenu);
    fillWindowMenu(window, windowMenu);
    fillHelpMenu(window, helpMenu);
    UiPlugin.getDefault().getOperationMenuFactory().setWindow(window);
    menuBar.insertBefore(IWorkbenchActionConstants.MB_ADDITIONS,
            UiPlugin.getDefault().getOperationMenuFactory().getMenu());
    menuBar.insertBefore(IWorkbenchActionConstants.MB_ADDITIONS, createNavigationMenu());
    menuBar.insertBefore(IWorkbenchActionConstants.MB_ADDITIONS, createLayerMenu());
    menuBar.insertBefore(IWorkbenchActionConstants.MB_ADDITIONS, createToolMenu());
    UiPlugin.getDefault().getOperationMenuFactory().contributeActions(menuBar);
}

From source file:net.refractions.udig.ui.UDIGMenuBuilder.java

License:Open Source License

private ToolBarManager createFileBar(IWorkbenchWindow window) {
    ToolBarManager toolbar = new ToolBarManager(SWT.FLAT);
    toolbar.add(new NewObjectContribution(window));

    toolbar.add(ActionFactory.SAVE.create(window));
    toolbar.add(ActionFactory.SAVE_ALL.create(window));

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

    return toolbar;
}

From source file:net.refractions.udig.ui.UDIGMenuBuilder.java

License:Open Source License

private void setupFileMenuStructure(IMenuManager fileMenu) {
    if (fileMenu.findUsingPath(IWorkbenchActionConstants.FILE_START) == null) {
        if (fileMenu.getItems().length > 0) {
            fileMenu.insertBefore(fileMenu.getItems()[0].getId(), new GroupMarker(Constants.FILE_START));
        } else {//w  w  w . ja  va2  s  .  com
            fileMenu.add(new GroupMarker(Constants.FILE_START));
        }
    }

    if (fileMenu.findUsingPath(Constants.OPEN_EXT) == null) {
        fileMenu.insertAfter(Constants.FILE_START, new GroupMarker(Constants.OPEN_EXT));
    }

    if (fileMenu.findUsingPath(Constants.CLOSE_EXT) == null) {
        fileMenu.insertAfter(Constants.OPEN_EXT, new GroupMarker(Constants.CLOSE_EXT));
    }

    if (fileMenu.findUsingPath(Constants.SAVE_EXT) == null) {
        fileMenu.insertAfter(Constants.CLOSE_EXT, new GroupMarker(Constants.SAVE_EXT));
    }

    if (fileMenu.findUsingPath(IWorkbenchActionConstants.MB_ADDITIONS) == null) {
        fileMenu.insertAfter(Constants.SAVE_EXT, new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
    }

    if (fileMenu.findUsingPath(Constants.FILE_END) == null) {
        fileMenu.insertAfter(IWorkbenchActionConstants.MB_ADDITIONS, new GroupMarker(Constants.FILE_END));
    }

    fileMenu.insertAfter(Constants.OPEN_EXT, new Separator());
    fileMenu.insertAfter(Constants.CLOSE_EXT, new Separator());
    fileMenu.insertAfter(Constants.SAVE_EXT, new Separator());
    fileMenu.insertAfter(IWorkbenchActionConstants.MB_ADDITIONS, new Separator());
}

From source file:net.refractions.udig.ui.UDIGMenuBuilder.java

License:Open Source License

private void fillFileMenu(IWorkbenchWindow window, IMenuManager fileMenu) {
    setupFileMenuStructure(fileMenu);/*w w w  .jav  a  2 s .co  m*/

    IMenuManager newMenu = fileMenu.findMenuUsingPath(ActionFactory.NEW.getId());
    if (newMenu == null) {
        newMenu = new MenuManager(Messages.UDIGWorkbenchAdvisor_new, ActionFactory.NEW.getId());
        fileMenu.insertAfter(Constants.FILE_START, newMenu);
    }

    newMenu.add(new GroupMarker(Constants.NEW_START));

    List<IConfigurationElement> list = ExtensionPointList
            .getExtensionPointList(NewObjectContribution.NEW_ACTION_ID);
    Collections.sort(list, new NewObjectDelegateComparator());
    for (IConfigurationElement element : list) {
        final NewObjectDelegate item = new NewObjectDelegate(element, window);
        Action newAction = new Action() {
            @Override
            public void runWithEvent(org.eclipse.swt.widgets.Event event) {
                item.runAction();
            }
        };
        newAction.setText(item.text);
        newAction.setImageDescriptor(item.icon);
        newMenu.appendToGroup(Constants.NEW_START, newAction);
    }
    newMenu.add(ContributionItemFactory.NEW_WIZARD_SHORTLIST.create(window));

    if (fileMenu.findUsingPath(ActionFactory.CLOSE.getId()) == null) {
        IAction close = ActionFactory.CLOSE.create(window);
        fileMenu.insertAfter(Constants.CLOSE_EXT, close);
    }

    if (fileMenu.findUsingPath(ActionFactory.CLOSE_ALL.getId()) == null) {
        IAction closeAll = ActionFactory.CLOSE_ALL.create(window);
        fileMenu.insertAfter(ActionFactory.CLOSE.getId(), closeAll);
    }

    if (fileMenu.findUsingPath(ActionFactory.SAVE.getId()) == null) {
        IAction save = ActionFactory.SAVE.create(window);
        fileMenu.insertBefore(Constants.SAVE_EXT, save);
    }

    if (fileMenu.findUsingPath(ActionFactory.SAVE_ALL.getId()) == null) {
        IAction saveAll = ActionFactory.SAVE_ALL.create(window);
        fileMenu.insertBefore(Constants.SAVE_EXT, saveAll);
    }

    //fileMenu.insertAfter(Constants.SAVE_EXT, new GroupMarker(Constants.REVERT_EXT));
    fileMenu.insertAfter(Constants.SAVE_EXT, new GroupMarker(Constants.COMMIT_EXT));

    fileMenu.insertBefore(Constants.FILE_END, new GroupMarker(Constants.RENAME_EXT));
    fileMenu.insertAfter(Constants.RENAME_EXT, new Separator());

    if (fileMenu.findUsingPath(ActionFactory.REFRESH.getId()) == null) {
        fileMenu.insertBefore(IWorkbenchActionConstants.MB_ADDITIONS,
                new GroupMarker(ActionFactory.REFRESH.getId()));
    }

    if (fileMenu.findUsingPath(ActionFactory.IMPORT.getId()) == null) {
        IAction _import = ActionFactory.IMPORT.create(window);
        fileMenu.insertBefore(Constants.FILE_END, _import);
        fileMenu.insertAfter(ActionFactory.IMPORT.getId(), new Separator());
    }

    if (fileMenu.findUsingPath(ActionFactory.EXPORT.getId()) == null) {
        IAction _export = ActionFactory.EXPORT.create(window);
        fileMenu.insertBefore(Constants.FILE_END, _export);
        fileMenu.insertAfter(ActionFactory.EXPORT.getId(), new Separator());
    }

    fileMenu.insertBefore(Constants.FILE_END, new GroupMarker(Constants.CONFIG_EXT));
    fileMenu.insertAfter(Constants.CONFIG_EXT, new Separator());

    if (fileMenu.findUsingPath(ActionFactory.QUIT.getId()) == null) {
        IAction exit = ActionFactory.QUIT.create(window);
        fileMenu.insertAfter(Constants.FILE_END, exit);
    }
}