void setEnabled(MHandledMenuItem item) { if (!item.isToBeRendered() || !item.isVisible() || item.getWidget() == null) { return; } ParameterizedCommand cmd = item.getWbCommand(); if (cmd == null) { return; } final IEclipseContext lclContext = renderer.getContext(item); EHandlerService service = lclContext.get(EHandlerService.class); final IEclipseContext staticContext = EclipseContextFactory .create(MMRF_STATIC_CONTEXT); ContributionsAnalyzer.populateModelInterfaces(item, staticContext, item .getClass().getInterfaces()); try { item.setEnabled(service.canExecute(cmd, staticContext)); } finally { staticContext.dispose(); } }
item.setElementId(MenuHelper.getId(commandAddition)); String commandId = MenuHelper.getCommandId(commandAddition); MCommand commandById = ContributionsAnalyzer.getCommandById(application, commandId); item.setCommand(commandById); Map parms = MenuHelper.getParameters(commandAddition); for (Object obj : parms.entrySet()) { parm.setName(e.getKey().toString()); parm.setValue(e.getValue().toString()); item.getParameters().add(parm); if (descriptor == null) { descriptor = commandImageService == null ? null : commandImageService .getImageDescriptor(item.getElementId()); item.setIconURI(MenuHelper.getImageUrl(descriptor)); item.setIconURI(iconUrl); item.setLabel(MenuHelper.getLabel(commandAddition)); item.setMnemonics(MenuHelper.getMnemonic(commandAddition)); item.setTooltip(MenuHelper.getTooltip(commandAddition)); item.setType(MenuHelper.getStyle(commandAddition)); item.setVisibleWhen(MenuHelper.getVisibleWhen(commandAddition)); String helpContextId = MenuHelper.getHelpContextId(commandAddition); if (helpContextId != null) { item.getPersistedState().put(EHelpService.HELP_CONTEXT_ID, helpContextId);
if (itemModel.getVisibleWhen() != null) { processVisible(itemModel); if (!itemModel.isVisible()) { return null; if (itemModel.getType() == ItemType.PUSH) flags = SWT.PUSH; else if (itemModel.getType() == ItemType.CHECK) flags = SWT.CHECK; else if (itemModel.getType() == ItemType.RADIO) flags = SWT.RADIO; ParameterizedCommand cmd = itemModel.getWbCommand(); if (cmd == null) { IEclipseContext lclContext = getContext(itemModel); setEnabled(itemModel, newItem); newItem.setImage(getImage(itemModel)); newItem.setSelection(itemModel.isSelected());
private void setEnabled(MHandledMenuItem itemModel, MenuItem newItem) { ParameterizedCommand cmd = itemModel.getWbCommand(); if (cmd == null) { return; } final IEclipseContext lclContext = getContext(itemModel); EHandlerService service = lclContext.get(EHandlerService.class); final IEclipseContext staticContext = EclipseContextFactory .create(HMI_STATIC_CONTEXT); ContributionsAnalyzer.populateModelInterfaces(itemModel, staticContext, itemModel.getClass().getInterfaces()); try { itemModel.setEnabled(service.canExecute(cmd, staticContext)); } finally { staticContext.dispose(); } newItem.setEnabled(itemModel.isEnabled()); }
.getWbCommand(); EHandlerService handlerService = evalContext .get(EHandlerService.class); staticContext, item.getClass().getInterfaces()); try { ((MHandledMenuItem) element).setEnabled(handlerService .canExecute(cmd, staticContext)); } finally {
final String i18nLabel = hmi.getLocalizedLabel(); if (i18nLabel != null) { text = i18nLabel; } else if (hmi.getWbCommand() != null) { try { text = hmi.getWbCommand().getName(); } catch (NotDefinedException e) {
/** * @param parentManager * @param itemModel */ void processHandledItem(MenuManager parentManager, MHandledMenuItem itemModel) { IContributionItem ici = getContribution(itemModel); if (ici != null) { return; } itemModel.setRenderer(this); final IEclipseContext lclContext = getContext(itemModel); HandledContributionItem ci = ContextInjectionFactory.make(HandledContributionItem.class, lclContext); ci.setModel(itemModel); ci.setVisible(itemModel.isVisible()); addToManager(parentManager, itemModel, ci); linkModelToContribution(itemModel, ci); }
/** * @param parentManager * @param itemModel */ void processHandledItem(MenuManager parentManager, MHandledMenuItem itemModel) { IContributionItem ici = getContribution(itemModel); if (ici != null) { return; } final IEclipseContext lclContext = getContext(itemModel); HandledContributionItem ci = ContextInjectionFactory.make( HandledContributionItem.class, lclContext); ci.setModel(itemModel); ci.setVisible(itemModel.isVisible()); addToManager(parentManager, itemModel, ci); linkModelToContribution(itemModel, ci); }
MCommand command = ((MHandledMenuItem) menuElement).getCommand(); String commandId = command.getElementId(); CommandContributionItemParameter ccip = new CommandContributionItemParameter(
.getWbCommand(); EHandlerService handlerService = evalContext .get(EHandlerService.class); staticContext, item.getClass().getInterfaces()); try { ((MHandledMenuItem) element).setEnabled(handlerService .canExecute(cmd, staticContext)); } finally {
void setEnabled(MHandledMenuItem item) { if (!item.isToBeRendered() || !item.isVisible() || item.getWidget() == null) { return; } ParameterizedCommand cmd = item.getWbCommand(); if (cmd == null) { return; } final IEclipseContext lclContext = renderer.getContext(item); EHandlerService service = lclContext.get(EHandlerService.class); final IEclipseContext staticContext = EclipseContextFactory .create(MMRF_STATIC_CONTEXT); ContributionsAnalyzer.populateModelInterfaces(item, staticContext, item .getClass().getInterfaces()); try { item.setEnabled(service.canExecute(cmd, staticContext)); } finally { staticContext.dispose(); } }