private void gatherCommands(List<MCommand> commandList) { for (MCommand cmd : commandList) { commands.put(cmd.getElementId(), cmd); } }
private void createCommand(MCommand cmdModel) { IParameter[] parms = null; String id = cmdModel.getElementId(); String name = localize(cmdModel.getCommandName(), cmdModel); String desc = localize(cmdModel.getDescription(), cmdModel); List<MCommandParameter> modelParms = cmdModel.getParameters(); if (modelParms != null && !modelParms.isEmpty()) { ArrayList<Parameter> parmList = new ArrayList<>(); for (MCommandParameter cmdParm : modelParms) { ParameterType parameterType = null; if (cmdParm.getTypeId() != null && cmdParm.getTypeId().length() > 0) { parameterType = commandManager.getParameterType(cmdParm.getTypeId()); } parmList.add(new Parameter(cmdParm.getElementId(), cmdParm.getName(), null, parameterType, cmdParm.isOptional())); } parms = parmList.toArray(new Parameter[parmList.size()]); } Category cat = undefinedCategory; if (cmdModel.getCategory() != null) { cat = commandService.getCategory(cmdModel.getCategory().getElementId()); } commandService.defineCommand(id, name, desc, cat, parms, cmdModel.getPersistedState().get("HelpContextId")); //$NON-NLS-1$ }
if (!cmdName.equals(mCommand.getCommandName())) { mCommand.setCommandName(cmdName); String cmdDesc = cmd.getDescription(); if (cmdDesc != null) mCommand.setDescription(cmdDesc); commands.put(command.getElementId(), command); } catch (NotDefinedException e) { WorkbenchPlugin.log(e);
public static MMenuItem createItem(MApplication application, CommandContributionItem cci) { MCommand command = getMCommand(application, cci); if (command != null) { CommandContributionItemParameter data = cci.getData(); MHandledMenuItem menuItem = MenuFactoryImpl.eINSTANCE.createHandledMenuItem(); menuItem.setCommand(command); menuItem.setContributorURI(command.getContributorURI()); if (data.label != null) { menuItem.setLabel(data.label); } else { menuItem.setLabel(command.getCommandName()); } if (data.mnemonic != null) { menuItem.setMnemonics(data.mnemonic); } if (data.icon != null) { menuItem.setIconURI(getIconURI(data.icon, application.getContext())); } else { menuItem.setIconURI(getIconURI(command.getElementId(), application.getContext(), ICommandImageService.TYPE_DEFAULT)); } String itemId = cci.getId(); menuItem.setElementId(itemId == null ? command.getElementId() : itemId); return menuItem; } return null; }
MHandledToolItem toolItem = MenuFactoryImpl.eINSTANCE.createHandledToolItem(); toolItem.setCommand(command); toolItem.setContributorURI(command.getContributorURI()); toolItem.setVisible(cci.isVisible()); iconURI = getIconURI(command.getElementId(), application.getContext(), ICommandImageService.TYPE_DEFAULT); toolItem.setLabel(command.getCommandName()); } else { toolItem.setIconURI(iconURI); disabledIconURI = getIconURI(command.getElementId(), application.getContext(), ICommandImageService.TYPE_DISABLED); toolItem.setTooltip(data.label); } else { toolItem.setTooltip(command.getDescription()); toolItem.setElementId(itemId == null ? command.getElementId() : itemId); return toolItem;
if (action instanceof OpenPreferencesAction) { for (MCommand command : application.getCommands()) { if (IWorkbenchCommandConstants.WINDOW_PREFERENCES.equals(command.getElementId())) { MHandledMenuItem menuItem = MenuFactoryImpl.eINSTANCE.createHandledMenuItem(); menuItem.setCommand(command); menuItem.setLabel(command.getCommandName()); menuItem.setIconURI(getIconURI(action.getImageDescriptor(), application.getContext())); if (id.equals(command.getElementId())) { MHandledMenuItem menuItem = MenuFactoryImpl.eINSTANCE.createHandledMenuItem(); menuItem.setCommand(command); menuItem.setLabel(action.getText()); } else { menuItem.setLabel(command.getCommandName());
final MCategory categoryModel) throws NotDefinedException { MCommand command = modelService.createModelElement(MCommand.class); command.setElementId(cmd.getId()); command.setCategory(categoryModel); command.setCommandName(cmd.getName()); command.setDescription(cmd.getDescription()); parmModel.setTypeId(parmType.getId()); command.getParameters().add(parmModel);
cmd.setCommandName(text); cmd.setElementId(cmdId); app.getCommands().add(cmd);
if (id != null) { for (MCommand command : application.getCommands()) { if (id.equals(command.getElementId())) { MHandledToolItem toolItem = MenuFactoryImpl.eINSTANCE.createHandledToolItem(); toolItem.setCommand(command); toolItem.setContributorURI(command.getContributorURI()); toolItem.setVisible(item.isVisible()); ICommandImageService.TYPE_DEFAULT); if (iconURI == null) { toolItem.setLabel(command.getCommandName()); } else { toolItem.setIconURI(iconURI);
if (commandById == null) { commandById = CommandsFactoryImpl.eINSTANCE.createCommand(); commandById.setElementId(commandId); commandById.setCommandName(commandId); application.getCommands().add(commandById);
public MCommand getCommand(String elementId) { if (elementIdToCommandMap == null) { Map<String, MCommand> result = new HashMap<String, MCommand>(); for (MCommand command : getCommands()) { MCommand otherCommand = result.put(command.getElementId(), command); if (otherCommand != null) { result.put(command.getElementId(), otherCommand); } } elementIdToCommandMap = result; } return elementIdToCommandMap.get(elementId); }
cmd.setCommandName(text); cmd.setElementId(cmdId); app.getCommands().add(cmd);
public MCommand getCommand(String elementId) { if (elementIdToCommandMap == null) { Map<String, MCommand> result = new HashMap<String, MCommand>(); for (MCommand command : getCommands()) { MCommand otherCommand = result.put(command.getElementId(), command); if (otherCommand != null) { result.put(command.getElementId(), otherCommand); } } elementIdToCommandMap = result; } return elementIdToCommandMap.get(elementId); }
if (commandById == null) { commandById = CommandsFactoryImpl.eINSTANCE.createCommand(); commandById.setElementId(commandId); commandById.setCommandName(commandId); application.getCommands().add(commandById);
protected MCommand findCommand(String commandId) { for (MCommand cmd : application.getCommands()) { if (commandId.equals(cmd.getElementId())) { return cmd; } } return null; }
public static MCommand getMCommand(MApplication application, CommandContributionItem contribution) { ParameterizedCommand command = contribution.getCommand(); if (command != null) { for (MCommand mcommand : application.getCommands()) { if (mcommand.getElementId().equals(command.getId())) { return mcommand; } } } return null; }
Set<MCommand> toBeRemoved = new HashSet<>(); for (MCommand command : commands) { final String elementId = command.getElementId(); if ("e4.exit".equals(elementId)) { //$NON-NLS-1$ toBeRemoved.add(command);
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 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; }