private ParameterizedCommand generateParameterizedCommand( final MHandledItem item, final IEclipseContext lclContext) { ECommandService cmdService = (ECommandService) lclContext .get(ECommandService.class.getName()); Map<String, Object> parameters = null; List<MParameter> modelParms = item.getParameters(); if (modelParms != null && !modelParms.isEmpty()) { parameters = new HashMap<String, Object>(); for (MParameter mParm : modelParms) { parameters.put(mParm.getName(), mParm.getValue()); } } ParameterizedCommand cmd = cmdService.createCommand(item.getCommand() .getElementId(), parameters); item.setWbCommand(cmd); return cmd; }
if (item.getCommand() == null) { getLogger().error("No command assigned to " + item); //$NON-NLS-1$ return null; if (Strings.isNullOrEmpty(item.getCommand().getElementId())) { getLogger().error("No command id assigned to " //$NON-NLS-1$ + item.getCommand().getElementId()); return null; ParameterizedCommand cmd = cmdService.createCommand(item.getCommand().getElementId(), parameters); return cmd;
public static ParameterizedCommand generateParameterizedCommand( final MHandledItem item, final IEclipseContext lclContext) { ECommandService cmdService = (ECommandService) lclContext .get(ECommandService.class.getName()); Map<String, Object> parameters = null; List<MParameter> modelParms = item.getParameters(); if (modelParms != null && !modelParms.isEmpty()) { parameters = new HashMap<String, Object>(); for (MParameter mParm : modelParms) { parameters.put(mParm.getName(), mParm.getValue()); } } ParameterizedCommand cmd = cmdService.createCommand(item.getCommand() .getElementId(), parameters); item.setWbCommand(cmd); return cmd; } }
private static ParameterizedCommand generateParameterizedCommand(final MHandledItem item, final IEclipseContext lclContext) { ECommandService cmdService = lclContext.get(ECommandService.class); Map<String, Object> parameters = null; List<MParameter> modelParms = item.getParameters(); if (modelParms != null && !modelParms.isEmpty()) { parameters = new HashMap<>(); for (MParameter mParm : modelParms) { parameters.put(mParm.getName(), mParm.getValue()); } } ParameterizedCommand cmd = cmdService.createCommand(item.getCommand().getElementId(), parameters); item.setWbCommand(cmd); return cmd; }
public void widgetSelected(SelectionEvent e) { if (e.detail != SWT.ARROW) { EHandlerService service = (EHandlerService) lclContext .get(EHandlerService.class.getName()); ParameterizedCommand cmd = item.getWbCommand(); if (cmd == null) { cmd = generateParameterizedCommand(item, lclContext); } if (cmd == null) { Activator.trace(Policy.DEBUG_MENUS, "Failed to execute: " + item.getCommand(), //$NON-NLS-1$ null); return; } final IEclipseContext staticContext = EclipseContextFactory .create(TIR_STATIC_CONTEXT); ContributionsAnalyzer.populateModelInterfaces(item, staticContext, item.getClass().getInterfaces()); service.executeHandler(cmd, staticContext); } }
@Override public void setModel(MItem item) { if (!(item instanceof MHandledItem)) { throw new IllegalArgumentException("Only instances of MHandledItem are allowed"); //$NON-NLS-1$ } super.setModel(item); generateCommand(); if (getModel().getCommand() == null) { if (logger != null) { logger.error("Element " + getModel().getElementId() + " invalid, no command defined."); //$NON-NLS-1$ //$NON-NLS-2$ } } }
public void setModel(MHandledItem item) { model = item; setId(model.getElementId()); generateCommand(); if (model.getCommand() == null) { if (logger != null) { logger.error("Element " + model.getElementId() + " invalid, no command defined."); //$NON-NLS-1$ //$NON-NLS-2$ } } updateVisible(); }
@Override @SuppressWarnings("restriction") protected void handleHelpRequest() { if(helpService==null) return; String helpContextId = getModel().getPersistedState().get(EHelpService.HELP_CONTEXT_ID); if (helpContextId != null) { helpService.displayHelp(helpContextId); return; } MCommand command = getModel().getCommand(); if (command == null || commandHelpService == null) { return; } String contextHelpId = commandHelpService.getHelpContextId(command.getElementId(), getContext(getModel())); if (contextHelpId != null) { helpService.displayHelp(contextHelpId); } }
getLogger().error("Failed to execute: " + handledItem.getCommand()); //$NON-NLS-1$ return;
protected void setItemText(MMenuItem model, MenuItem item) { String text = model.getLocalizedLabel(); if (model instanceof MHandledItem) { MHandledItem handledItem = (MHandledItem) model; IEclipseContext context = getContext(model); EBindingService bs = (EBindingService) context .get(EBindingService.class.getName()); ParameterizedCommand cmd = handledItem.getWbCommand(); if (cmd != null && (text == null || text.length() == 0)) { try { text = cmd.getName(); } catch (NotDefinedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } TriggerSequence sequence = bs.getBestSequenceFor(handledItem .getWbCommand()); if (sequence != null) { text = text + '\t' + sequence.format(); } item.setText(text == null ? handledItem.getCommand().getElementId() : text); } else { super.setItemText(model, item); } }
if (model.getCommand() != null && model.getWbCommand() == null) { String cmdId = model.getCommand().getElementId(); List<MParameter> modelParms = model.getParameters(); Map<String, String> parameters = new HashMap<String, String>(4);
@Override protected void updateToolItem() { ToolItem item = (ToolItem) widget; if (item.getImage() == null || getModel().getTags().contains(FORCE_TEXT)) { final String text = getModel().getLocalizedLabel(); if (text == null || text.length() == 0) { final MCommand command = getModel().getCommand(); if (command == null) { // Set some text so that the item stays visible in the menu item.setText("UnLabled"); //$NON-NLS-1$ } else { item.setText(command.getLocalizedCommandName()); } } else { item.setText(text); } } else { item.setText(""); //$NON-NLS-1$ } final String tooltip = getToolTipText(true); item.setToolTipText(tooltip); item.setSelection(getModel().isSelected()); item.setEnabled(getModel().isEnabled()); }
if (text == null || text.isEmpty()) { try { text = parmCmd.getName(getModel().getCommand().getLocalizedCommandName()); } catch (NotDefinedException e) { Activator.log(LogService.LOG_DEBUG, e.getMessage(), e);
if (getModel().getCommand() != null && getModel().getWbCommand() == null) { String cmdId = getModel().getCommand().getElementId(); if (cmdId == null) { logger.error("Unable to generate parameterized command for " + getModel() //$NON-NLS-1$