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

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

Introduction

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

Prototype

@Override
    public void update(String property) 

Source Link

Usage

From source file:com.archimatetool.editor.views.tree.search.SearchWidget.java

License:Open Source License

private void populatePropertiesMenu(MenuManager propertiesMenu) {
    // Models that are loaded are the ones in the Models Tree
    List<String> list = new ArrayList<String>();

    for (IArchimateModel model : IEditorModelManager.INSTANCE.getModels()) {
        getAllUniquePropertyKeysForModel(model, list);
    }/*from w w w.ja  v  a 2  s.  c  o  m*/

    for (final String key : list) {
        IAction action = new Action(key, IAction.AS_CHECK_BOX) {
            @Override
            public void run() {
                if (isChecked()) {
                    fSearchFilter.addPropertiesFilter(key);
                } else {
                    fSearchFilter.removePropertiesFilter(key);
                }
            }
        };

        propertiesMenu.add(action);
    }

    propertiesMenu.update(true);
}

From source file:com.architexa.org.eclipse.gef.ui.palette.customize.PaletteCustomizerDialog.java

License:Open Source License

/**
 * Uses a <code>MenuManager</code> to create the context menu for the outline.  The
 * <code>IActions</code> used to create the context menu are those created in 
 * {@link #createOutlineActions()}./*from   w w w . j  av a 2 s. c o m*/
 * 
 * @return   The newly created Menu
 */
protected Menu createOutlineContextMenu() {
    // MenuManager for the tree's context menu
    final MenuManager outlineMenu = new MenuManager();

    List actions = getOutlineActions();
    // Add all the actions to the context menu
    for (Iterator iter = actions.iterator(); iter.hasNext();) {
        IAction action = (IAction) iter.next();
        if (action instanceof IMenuCreator)
            outlineMenu.add(new ActionContributionItem(action) {
                public boolean isDynamic() {
                    return true;
                }
            });
        else
            outlineMenu.add(action);
        // Add separators after new and delete
        if (action instanceof NewAction || action instanceof DeleteAction) {
            outlineMenu.add(new Separator());
        }
    }

    outlineMenu.addMenuListener(new IMenuListener() {
        public void menuAboutToShow(IMenuManager manager) {
            outlineMenu.update(true);
        }
    });

    outlineMenu.createContextMenu(tree);
    return outlineMenu.getMenu();
}

From source file:com.drgarbage.bytecodevisualizer.view.OperandStackViewPage.java

License:Apache License

private void configureToolBar() {

    IActionBars bars = getSite().getActionBars();
    IToolBarManager tbm = bars.getToolBarManager();

    showTreeViewAction = new Action() {
        public void run() {
            activateView(OperandStackView_ID.TREE_VIEW);
        }//from  w ww  .ja  v  a 2s.  c o  m
    };
    showTreeViewAction.setImageDescriptor(CoreImg.bytecodeViewIcon_16x16);
    tbm.add(showTreeViewAction);
    showTreeViewAction.setText(BytecodeVisualizerMessages.TreeViewAction_Text);
    showTreeViewAction.setToolTipText(BytecodeVisualizerMessages.TreeViewAction_Text);
    showTreeViewAction.setChecked(true);

    showBasicBlockViewAction = new Action() {
        public void run() {
            activateView(OperandStackView_ID.BASICBKLOCK_VIEW);
        }
    };
    showBasicBlockViewAction.setImageDescriptor(CoreImg.basicblockViewIcon_16x16);
    tbm.add(showBasicBlockViewAction);
    showBasicBlockViewAction.setText(BytecodeVisualizerMessages.BasicViewAction_Text);
    showBasicBlockViewAction.setToolTipText(BytecodeVisualizerMessages.BasicViewAction_Text);
    showBasicBlockViewAction.setChecked(false);

    showInstructioneListViewAction = new Action() {
        public void run() {
            activateView(OperandStackView_ID.INSTR_LIST_VIEW);
        }
    };
    showInstructioneListViewAction.setImageDescriptor(CoreImg.bytecode_listview_16x16);
    showInstructioneListViewAction.setText(BytecodeVisualizerMessages.InstructionListView_Text);
    showInstructioneListViewAction.setToolTipText(BytecodeVisualizerMessages.InstructionListView_Text);
    tbm.add(showInstructioneListViewAction);
    showInstructioneListViewAction.setChecked(false);

    enableActions(false);

    showAnalyseReportAction = new Action() {
        public void run() {
            OperandStackReportDialog analyseReport = new OperandStackReportDialog();
            analyseReport.setText(OperandStackAnalysis.executeAll(operandStack, methodInput));
            analyseReport.open();
        }
    };

    showAnalyseReportAction.setImageDescriptor(
            PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_FILE));
    showAnalyseReportAction.setText(BytecodeVisualizerMessages.OpenOpstackAnalyseAction_Text);
    showAnalyseReportAction.setToolTipText(BytecodeVisualizerMessages.OpenOpstackAnalyseAction_Tooltip);

    tbm.add(new Separator());
    tbm.add(showAnalyseReportAction);

    tbm.update(true);

    /* menu */
    final IMenuManager imb = bars.getMenuManager();

    /* submenu */
    MenuManager subMenuViewLayout = new MenuManager(BytecodeVisualizerMessages.subMenuViewLayout_Text, null);
    final MenuManager subMenuShowColumn = new MenuManager(BytecodeVisualizerMessages.subMenuShowColumn_Text,
            null);
    final MenuManager subMenuFormat = new MenuManager(BytecodeVisualizerMessages.subMenuFormat_Text, null);

    imb.add(subMenuViewLayout);
    imb.add(subMenuShowColumn);
    imb.add(subMenuFormat);
    imb.add(new Separator());
    imb.add(showAnalyseReportAction);

    subMenuViewLayout.add(showTreeViewAction);
    subMenuViewLayout.add(showBasicBlockViewAction);
    subMenuViewLayout.add(showInstructioneListViewAction);

    showOSBeforeColumnAction = new Action() {
        public void run() {
            if (column3.getWidth() == 0) {
                column3.setWidth(100);
                column3.setResizable(true);
                setChecked(true);
            } else {
                column3.setWidth(0);
                column3.setResizable(false);
                setChecked(false);
            }
            subMenuShowColumn.update(true);
        }
    };
    showOSBeforeColumnAction.setText(BytecodeVisualizerMessages.OpstackBeforeColumnName);

    showOSAfterColumnAction = new Action() {
        public void run() {
            if (column4.getWidth() == 0) {
                column4.setWidth(100);
                column4.setResizable(true);
                setChecked(true);
            } else {
                column4.setWidth(0);
                column4.setResizable(false);
                setChecked(false);
            }
            subMenuShowColumn.update(true);
        }
    };
    showOSAfterColumnAction.setText(BytecodeVisualizerMessages.OpstackAfterColumnName);

    showOSDepthColumnAction = new Action() {
        public void run() {
            if (column5.getWidth() == 0) {
                column5.setWidth(40);
                column5.setResizable(true);
                setChecked(true);
            } else {
                column5.setWidth(0);
                column5.setResizable(false);
                setChecked(false);
            }
            subMenuShowColumn.update(true);
        }
    };
    showOSDepthColumnAction.setText(BytecodeVisualizerMessages.OpstackDepthColumnName);

    showDescriptionColumnAction = new Action() {
        public void run() {
            if (column6.getWidth() == 0) {
                column6.setWidth(100);
                column6.setResizable(true);
                setChecked(true);
            } else {
                column6.setWidth(0);
                column6.setResizable(false);
                setChecked(false);
            }
            subMenuShowColumn.update(true);
        }
    };
    showDescriptionColumnAction.setText(BytecodeVisualizerMessages.OpstackDescriptionColumnName);

    showOSBeforeColumnAction.setChecked(true);
    showOSAfterColumnAction.setChecked(true);
    showOSDepthColumnAction.setChecked(true);

    subMenuShowColumn.add(showOSBeforeColumnAction);
    subMenuShowColumn.add(showOSAfterColumnAction);
    subMenuShowColumn.add(showOSDepthColumnAction);
    subMenuShowColumn.add(showDescriptionColumnAction);

    displaySimpleAction = new Action() {
        public void run() {
            opstackRepresenationFormat = OpstackRepresenation.SIMPLE;
            activateDisplayFormat(OperandStackDisplayFormat_ID.DISPLAY_SIMPLE);
            subMenuFormat.update(true);
        }

        public String getText() {
            return BytecodeVisualizerMessages.DisplayFormatSIMPLE;
        }
    };
    displaySimpleAction.setChecked(true);

    displayAllAction = new Action() {
        public void run() {
            opstackRepresenationFormat = OpstackRepresenation.ALL;
            activateDisplayFormat(OperandStackDisplayFormat_ID.DISPLAY_ALL);
            subMenuFormat.update(true);
        }

        public String getText() {
            return BytecodeVisualizerMessages.DisplayFormatALL;
        }
    };
    displayAllAction.setChecked(false);

    displayValuesAction = new Action() {
        public void run() {
            opstackRepresenationFormat = OpstackRepresenation.VALUES;
            activateDisplayFormat(OperandStackDisplayFormat_ID.DISPLAY_VALUES);
            subMenuFormat.update(true);
        }

        public String getText() {
            return BytecodeVisualizerMessages.DisplayFormatVALUES;
        }
    };
    displayValuesAction.setChecked(false);

    displayTypesAction = new Action() {
        public void run() {
            opstackRepresenationFormat = OpstackRepresenation.TYPES;
            activateDisplayFormat(OperandStackDisplayFormat_ID.DISPLAY_TYPES);
            subMenuFormat.update(true);
        }

        public String getText() {
            return BytecodeVisualizerMessages.DisplayFormatTYPES;
        }
    };
    displayTypesAction.setChecked(false);

    subMenuFormat.add(displaySimpleAction);
    subMenuFormat.add(displayTypesAction);
    subMenuFormat.add(displayValuesAction);
    subMenuFormat.add(displayAllAction);

}

From source file:com.google.code.t4eclipse.tools.view.provider.MenuItemContentProvider.java

License:Open Source License

@SuppressWarnings("null")
public Object[] getChildren(Object parentElement) {
    if (parentElement instanceof MenuItem) {
        MenuItem item = (MenuItem) parentElement;

        if (item.isDisposed()) {
            return null;
        }/*from  ww  w . java2s .  c  om*/

        Object data = item.getData();
        if (data == null) {
            return null;
        }

        if (data instanceof MenuManager) {
            MenuManager mm = (MenuManager) data;

            if (mm != null) {
                return mm.getMenu().getItems();
            }
        }

        if (data instanceof ActionSetContributionItem) {
            ActionSetContributionItem ascItem = (ActionSetContributionItem) data;
            IContributionItem cItem = ascItem.getInnerItem();
            if (cItem instanceof MenuManager) {
                MenuManager mm = (MenuManager) cItem;
                mm.update(true);
                return mm.getMenu().getItems();
            }
        }
    }

    return null;

}

From source file:com.google.code.t4eclipse.tools.view.provider.MenuItemContentProvider.java

License:Open Source License

@SuppressWarnings("null")
public boolean hasChildren(Object element) {
    if (element instanceof MenuItem) {
        MenuItem item = (MenuItem) element;

        Object data = item.getData();
        if (data == null) {
            return false;
        }/*from  w  ww  .j  a  v  a  2s.c om*/

        if (data instanceof MenuManager) {
            MenuManager mm = (MenuManager) data;
            mm.update(true);

            if (mm != null)
                return mm.getMenu().getItemCount() > 0;
        }

        if (data instanceof ActionSetContributionItem) {
            ActionSetContributionItem ascItem = (ActionSetContributionItem) data;
            IContributionItem cItem = ascItem.getInnerItem();
            if (cItem instanceof MenuManager) {
                MenuManager mm = (MenuManager) cItem;
                mm.update(true);
                return mm.getMenu().getItemCount() > 0;
            }

            //            if(cItem instanceof PluginActionContributionItem) {
            //               PluginActionContributionItem pacItem = (PluginActionContributionItem)cItem;
            //               IAction action = pacItem.getAction();
            //               if(action instanceof WWinPluginPulldown) {
            //                  WWinPluginPulldown wppAction = (WWinPluginPulldown)action;
            //                  ObjectResult result = ReflectionUtil.getField("delegate", wppAction);
            //                  if(result.result == null) {
            //                     return false;
            //                  }
            //                  
            //                  ExternalToolMenuDelegate delegate = (ExternalToolMenuDelegate)result.result;
            //                  //TODO fMenu                  
            //               }
            //            }
        }
    }

    return false;
}

From source file:com.nokia.tools.ui.ide.MenuCustomizer.java

License:Open Source License

public void hideExternMenus() {
    WorkbenchWindow window = (WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    MenuManager manager = window.getMenuManager();

    IContributionItem[] items = manager.getItems();
    for (int i = 0; i < items.length; i++) {
        if (hiddenMenus.contains(items[i].getId())) {
            String idBeforeThis = i > 0 ? items[i - 1].getId() : null;
            IContributionItem item = manager.remove(items[i]);
            if (item != null) {
                hiddenItems.add(new HiddenItem(idBeforeThis, item));
            }// w w  w . ja  v  a  2 s  . c o m
        }
    }
    manager.update(true);
}

From source file:com.nokia.tools.ui.ide.MenuCustomizer.java

License:Open Source License

public void restoreExternMenus() {
    WorkbenchWindow window = (WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    MenuManager manager = window.getMenuManager();
    for (Iterator<HiddenItem> i = hiddenItems.iterator(); i.hasNext();) {
        HiddenItem item = i.next();/*w  w w.  jav a  2 s.  c om*/
        try {
            manager.insertAfter(item.idBeforeThis, item.item);
        } catch (Exception e) {
        }
        i.remove();
    }
    manager.update(true);
}

From source file:de.loskutov.anyedit.actions.internal.StartupHelper.java

License:Open Source License

private static void insert(IDirtyWorkaround myAction, MenuManager menu) {
    IContributionItem item;//w  w  w .  j  ava  2  s. c  o  m
    String id = myAction.getId();
    // get "file->save" action
    item = menu.find(id);
    if (item != null) {
        // copy references to opened editor/part
        myAction.copyStateAndDispose(item);
        // remember position
        int controlIdx = menu.indexOf(id);
        // clean old one
        menu.remove(item);
        item = new ActionContributionItem(myAction);
        menu.insert(controlIdx, item);
        // refresh menu gui
        menu.update(true);
    }
}

From source file:eu.numberfour.n4js.product.N4JSApplicationActionBarAdvisor.java

License:Open Source License

@Override
public void fillActionBars(final int flags) {
    delegate.fillActionBars(flags);/*from w  w w  .ja  v a  2s. c  om*/

    // To remove 'Build Working Set' contribution item from the main menu.
    final IMenuManager menuManager = configurer.getMenuManager();
    final MenuManager projectManager = getMenuManager(PROJECT_MENU_PREDICATE, menuManager);
    if (null != projectManager) {
        final MenuManager workingSetManager = getMenuManager(WORKING_SET_MENU_PREDICATE, projectManager);
        projectManager.remove(workingSetManager);
        projectManager.update(true);
    }
}

From source file:org.csstudio.display.builder.rcp.RCPHacks.java

License:Open Source License

/** Remove unrelated menu entries (once)
 *  @param window/*ww  w. java 2  s  . co m*/
 */
private static void patchMenu(final WorkbenchWindow window) {
    if (patched_menu)
        return;
    patched_menu = true;
    final MenuManager manager = window.getMenuManager();
    // File/Top Files needs to be removed because it would
    // allow user to open BOY displays.
    MenuManager file = null;
    for (IContributionItem item : manager.getItems())
        if (item instanceof MenuManager && item.getId().equals("file")) {
            file = (MenuManager) item;
            break;
        }
    if (file == null)
        return;
    for (IContributionItem item : file.getItems())
        if (item instanceof MenuManager && ((MenuManager) item).getMenuText().equals("Top Files")) {
            file.remove(item);
            break;
        }
    manager.update(true);
}