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

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

Introduction

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

Prototype

public SubContributionItem(IContributionItem item) 

Source Link

Document

Creates a new SubContributionItem.

Usage

From source file:org.eclipse.sirius.table.ui.tools.internal.editor.DTableMenuListener.java

License:Open Source License

/**
 * Add the open sub menu and its actions if needed.
 * //from w  w w. java  2  s.  c  om
 * @param manager
 *            The menu manager
 */
private void addOpenRepresentationMenu(final IMenuManager manager) {
    // Create a new sub-menu manager
    final MenuManager openMenuManager = new MenuManager("Open", DTableMenuListener.MENU_OPEN_REPRESENTATION_ID);
    // Create the item to add to the main manager
    final SubContributionItem openMenuItem = new SubContributionItem(openMenuManager);
    manager.add(openMenuItem);
    // Add menus to open existing representations (created by
    // RepresentationCreationDescription)
    final Separator existingGroup = new Separator(DTableMenuListener.EXISTING_REPRESENTATION_GROUP_SEPARATOR);
    openMenuManager.add(existingGroup);
    // Add menus to open existing representations (corresponding
    // to the RepresentationNavigationDescription)
    final Separator openRepresentationGroup = new Separator(MenuHelper.OPEN_REPRESENTATION_GROUP_SEPARATOR);
    openMenuManager.add(openRepresentationGroup);
    final DTableElement currentTableElement = getCurrentTableElement();
    if (currentTableElement != null) {
        // Add actions to open existing representation
        createOpenAction(openMenuItem, currentTableElement);
    } else {
        // Add actions to open representation
        createOpenAction(openMenuItem, dTable);
    }
}

From source file:org.eclipse.sirius.table.ui.tools.internal.editor.DTableMenuListener.java

License:Open Source License

/**
 * Add the new sub menu and its actions if needed.
 * //  w ww .  j  ava 2 s . co  m
 * @param manager
 *            The menu manager
 */
private void addNewRepresentationMenu(final IMenuManager manager) {
    // Create a new sub-menu manager
    final MenuManager newMenuManager = new MenuManager("New", DTableMenuListener.MENU_NEW_REPRESENTATION_ID);
    // Create the item to add to the main manager
    final SubContributionItem newMenuItem = new SubContributionItem(newMenuManager);
    manager.add(newMenuItem);
    // Add menus to create new representations (corresponding to
    // the RepresentationCreationDescription)
    final Separator createGroup = new Separator(DTableMenuListener.NEW_REPRESENTATION_GROUP_SEPARATOR);
    newMenuManager.add(createGroup);
    final DTableElement currentTableElement = getCurrentTableElement();
    // Add actions to create new representation
    if (currentTableElement instanceof DCell) {
        createDetailsActions(currentTableElement, newMenuItem);
    } else if (currentTableElement instanceof DLine) {
        createDetailsActions(currentTableElement, newMenuItem);
    }
}

From source file:org.eclipse.sirius.table.ui.tools.internal.editor.DTableMenuListener.java

License:Open Source License

private void addExportMenu(final IMenuManager manager) {
    // Create a new sub-menu manager
    final MenuManager exportMenuManager = new MenuManager("Export", DTableMenuListener.MENU_EXPORT_ID);
    // Create the item to add to the main manager
    final SubContributionItem menuItem = new SubContributionItem(exportMenuManager);
    menuItem.setVisible(true);//w  w w  .j  a  va 2  s . c o m
    manager.add(menuItem);
    exportMenuManager.add(new Separator(DTableMenuListener.VIEWPOINT_GROUP_SEPARATOR));
    final IAction action = new Action("CSV",
            DTableViewerManager.getImageRegistry().getDescriptor(DTableViewerManager.EXPORT_IMG)) {

        /**
         * {@inheritDoc}
         * 
         * @see org.eclipse.jface.action.Action#run()
         */
        @Override
        public void run() {
            final IHandlerService handlerService = (IHandlerService) treeViewManager.getEditor().getSite()
                    .getService(IHandlerService.class);
            try {
                handlerService.executeCommand("org.eclipse.sirius.table.ui.exportToCsv", null); //$NON-NLS-1$
            } catch (final CommandException ex) {
                throw new RuntimeException("export to csv command not found");
            }
        }
    };
    exportMenuManager.appendToGroup(DTableMenuListener.VIEWPOINT_GROUP_SEPARATOR, action);
}

From source file:org.eclipse.sirius.table.ui.tools.internal.editor.DTableMenuListener.java

License:Open Source License

/**
 * Add the viewpoint sub menu and its actions if needed.
 * /*  w  w w  . j a v a2s  .  c  o  m*/
 * @param manager
 *            The menu manager
 */
private void addHideRevealMenu(final IMenuManager manager) {
    // Create a new sub-menu manager
    final MenuManager hideRevealMenuManager = new MenuManager("Show/Hide",
            DTableMenuListener.MENU_HIDEREVEAL_ID);
    // Create the item to add to the main manager
    final SubContributionItem viewpointMenuItem = new SubContributionItem(hideRevealMenuManager);
    viewpointMenuItem.setVisible(true);
    manager.add(viewpointMenuItem);
    hideRevealMenuManager.add(new Separator(DTableMenuListener.VIEWPOINT_GROUP_SEPARATOR));

    // Columns visibility
    DColumn activeColumn = null;
    if (treeViewManager.getActiveColumn() > 0) {
        activeColumn = dTable.getColumns().get(treeViewManager.getActiveColumn() - 1);
    }

    if (activeColumn != null && activeColumn.isVisible()) {
        hideColumnAction.setColumn(activeColumn);
        if (hideColumnAction.isEnabled()) {
            hideRevealMenuManager.appendToGroup(DTableMenuListener.VIEWPOINT_GROUP_SEPARATOR, hideColumnAction);
        }
    }

    hideRevealMenuManager.appendToGroup(DTableMenuListener.VIEWPOINT_GROUP_SEPARATOR, showAllColumnsAction);

    hideRevealMenuManager.appendToGroup(DTableMenuListener.VIEWPOINT_GROUP_SEPARATOR, hideRevealColumnsAction);

    hideRevealMenuManager.appendToGroup(DTableMenuListener.VIEWPOINT_GROUP_SEPARATOR, new Separator());

    // Lines visibility
    final Collection<DLine> selectedLines = treeViewManager.getSelectedLines();
    if (selectedLines != null && !selectedLines.isEmpty()) {
        Predicate<DLine> isVisible = new Predicate<DLine>() {
            public boolean apply(DLine input) {
                return input.isVisible();
            }
        };
        Iterable<DLine> visibleSelection = Iterables.filter(selectedLines, isVisible);

        hideLineAction.setLines(Lists.newArrayList(visibleSelection));
        if (hideLineAction.isEnabled()) {
            hideRevealMenuManager.appendToGroup(DTableMenuListener.VIEWPOINT_GROUP_SEPARATOR, hideLineAction);
        }
    }
    hideRevealMenuManager.appendToGroup(DTableMenuListener.VIEWPOINT_GROUP_SEPARATOR, showAllLinesAction);

    hideRevealMenuManager.appendToGroup(DTableMenuListener.VIEWPOINT_GROUP_SEPARATOR, hideRevealLinesAction);
}

From source file:org.eclipse.sirius.tree.ui.tools.internal.editor.DTreeMenuListener.java

License:Open Source License

/**
 * Add the open sub menu and its actions if needed.
 * /*from  w w w .ja  va 2 s. com*/
 * @param manager
 *            The menu manager
 */
private void addOpenRepresentationMenu(final IMenuManager manager) {
    // Create a new sub-menu manager
    final MenuManager openMenuManager = new MenuManager("Open", DTreeMenuListener.MENU_OPEN_REPRESENTATION_ID);
    // Create the item to add to the main manager
    final SubContributionItem openMenuItem = new SubContributionItem(openMenuManager);
    manager.add(openMenuItem);
    // Add menus to open existing representations (created by
    // RepresentationCreationDescription)
    final Separator existingGroup = new Separator(DTreeMenuListener.EXISTING_REPRESENTATION_GROUP_SEPARATOR);
    openMenuManager.add(existingGroup);
    // Add menus to open existing representations (corresponding
    // to the RepresentationNavigationDescription)
    final Separator openRepresentationGroup = new Separator(MenuHelper.OPEN_REPRESENTATION_GROUP_SEPARATOR);
    openMenuManager.add(openRepresentationGroup);
    final Collection<DTreeItem> currentTreeElements = treeViewManager.getSelectedItems();
    if (currentTreeElements != null && currentTreeElements.size() == 1) {
        DTreeItem currentTreeElement = currentTreeElements.iterator().next();
        // Add actions to open existing representation
        createOpenAction(openMenuItem, currentTreeElement);
    } else {
        // Add actions to open existing representation
        createOpenAction(openMenuItem, dTree);
    }
}

From source file:org.eclipse.sirius.tree.ui.tools.internal.editor.DTreeMenuListener.java

License:Open Source License

/**
 * Add the new sub menu and its actions if needed.
 * /*from w w w .  j  ava  2 s .  c  om*/
 * @param manager
 *            The menu manager
 */
private void addNewRepresentationMenu(final IMenuManager manager) {
    // Create a new sub-menu manager
    final MenuManager newMenuManager = new MenuManager("New", DTreeMenuListener.MENU_NEW_REPRESENTATION_ID);
    // Create the item to add to the main manager
    final SubContributionItem newMenuItem = new SubContributionItem(newMenuManager);
    manager.add(newMenuItem);
    // Add menus to create new representations (corresponding to
    // the RepresentationCreationDescription)
    final Separator createGroup = new Separator(DTreeMenuListener.NEW_REPRESENTATION_GROUP_SEPARATOR);
    newMenuManager.add(createGroup);
    final Collection<DTreeItem> currentTreeElements = treeViewManager.getSelectedItems();
    if (currentTreeElements != null && currentTreeElements.size() == 1) {
        DTreeItem currentTreeElement = currentTreeElements.iterator().next();
        // Add actions to navigate to new representation
        if (currentTreeElement != null) {
            createDetailsActions(currentTreeElement, newMenuItem);
        }
    }
}