类org.eclipse.ui.commands.ICommandService源码实例Demo

下面列出了怎么用org.eclipse.ui.commands.ICommandService的API类实例代码及写法,或者点击链接到github查看源代码。

@Inject
public void initializeAtStartup(final IWorkbench workbench, final ICommandService commandService) {
	/*
	 * Check the UI state of the IHandler/Command which indicates if the user
	 * enabled automatic PlusCal conversion.
	 */
	final Command command = commandService.getCommand("toolbox.command.module.translate.automatially");
	final State state = command.getState(RegistryToggleState.STATE_ID);
	if (!((Boolean) state.getValue()).booleanValue()) {
		return;
	}
	// This IHander is stateful even across Toolbox restarts. In other words, if the
	// user enables automatic PlusCal translation, it will remain enabled even after
	// a Toolbox restart. This means we have to register this EventHandler at the
	// IEventBroker during Toolbox startup.
	// It is vital that we use the Workbench's IEventBroker instance. If e.g. we
	// would use an IEventBroker from higher up the IEclipseContext hierarchy, the
	// broker would be disposed when a new spec gets opened while the IHandler's state
	// remains enabled.
	workbench.getService(IEventBroker.class).unsubscribe(this);
	Assert.isTrue(workbench.getService(IEventBroker.class).subscribe(TLAEditor.PRE_SAVE_EVENT, this));
}
 
源代码2 项目: elexis-3-core   文件: EditLocalDocumentUtil.java
/**
 * If {@link Preferences#P_TEXT_EDIT_LOCAL} is set, the
 * <code> ch.elexis.core.ui.command.startEditLocalDocument </code> command is called with the
 * provided {@link Brief}, and the provided {@link IViewPart} is hidden.
 * 
 * @param view
 * @param brief
 * @return returns true if edit local is started and view is hidden
 */
public static boolean startEditLocalDocument(IViewPart view, Brief brief){
	if (CoreHub.localCfg.get(Preferences.P_TEXT_EDIT_LOCAL, false) && brief != null) {
		// open for editing
		ICommandService commandService =
			(ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
		Command command =
			commandService.getCommand("ch.elexis.core.ui.command.startEditLocalDocument"); //$NON-NLS-1$
		
		PlatformUI.getWorkbench().getService(IEclipseContext.class)
			.set(command.getId().concat(".selection"), new StructuredSelection(brief));
		try {
			command.executeWithChecks(
				new ExecutionEvent(command, Collections.EMPTY_MAP, view, null));
		} catch (ExecutionException | NotDefinedException | NotEnabledException
				| NotHandledException e) {
			MessageDialog.openError(view.getSite().getShell(), Messages.TextView_errortitle,
				Messages.TextView_errorlocaleditmessage);
		}
		view.getSite().getPage().hideView(view);
		return true;
	}
	return false;
}
 
@Override
public boolean performOk() {
    if (super.performOk()) {
        final String value = BonitaStudioPreferencesPlugin.getDefault().getPreferenceStore()
                .getString(BonitaCoolBarPreferenceConstant.COOLBAR_DEFAULT_SIZE);
        try {
            final ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
            if (value.equals(BonitaCoolBarPreferenceConstant.SMALL)) {
                service.getCommand("org.bonitasoft.studio.application.smallCoolbar").executeWithChecks(new ExecutionEvent());
            } else if (value.equals(BonitaCoolBarPreferenceConstant.NORMAL)) {
                service.getCommand("org.bonitasoft.studio.application.normalCoolbar").executeWithChecks(new ExecutionEvent());

            }
        } catch (final Exception e) {
            BonitaStudioLog.error(e);
        }
    }
    return false;
}
 
源代码4 项目: EasyShell   文件: Utils.java
private static void executeCommand(IWorkbench workbench, String commandName, Map<String, Object> params) {
    if (workbench == null) {
        workbench = PlatformUI.getWorkbench();
    }
    // get command
    ICommandService commandService = (ICommandService)workbench.getService(ICommandService.class);
    Command command = commandService != null ? commandService.getCommand(commandName) : null;
    // get handler service
    //IBindingService bindingService = (IBindingService)workbench.getService(IBindingService.class);
    //TriggerSequence[] triggerSequenceArray = bindingService.getActiveBindingsFor("de.anbos.eclipse.easyshell.plugin.commands.open");
    IHandlerService handlerService = (IHandlerService)workbench.getService(IHandlerService.class);
    if (command != null && handlerService != null) {
        ParameterizedCommand paramCommand = ParameterizedCommand.generateCommand(command, params);
        try {
            handlerService.executeCommand(paramCommand, null);
        } catch (Exception e) {
            Activator.logError(Activator.getResourceString("easyshell.message.error.handlerservice.execution"), paramCommand.toString(), e, true);
        }
    }
}
 
源代码5 项目: eip-designer   文件: CompareWithRouteAction.java
@Override
public void run(IAction action) {
   System.err.println("In run(IACtion)");
   if (serviceLocator == null) {
      serviceLocator = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
   } 
   
   // Create an ExecutionEvent using Eclipse machinery.
   ICommandService srv = (ICommandService) serviceLocator.getService(ICommandService.class);
   IHandlerService hsrv = (IHandlerService) serviceLocator.getService(IHandlerService.class);
   ExecutionEvent event = hsrv.createExecutionEvent(srv.getCommand(ActionCommands.COMPARE_WITH_ROUTE_ACTION), null);
   // Fill it my current active selection.
   if (event.getApplicationContext() instanceof IEvaluationContext) {
      ((IEvaluationContext) event.getApplicationContext()).addVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME, mySelection);
   }
   
   try {
      handler.execute(event);
   } catch (ExecutionException e) {
      Activator.handleError(e.getMessage(), e, true);
   }
}
 
源代码6 项目: eip-designer   文件: PersistToRouteModelAction.java
@Override
public void run(IAction action) {
   if (serviceLocator == null) {
      serviceLocator = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
   } 
   
   // Create an ExecutionEvent using Eclipse machinery.
   ICommandService srv = (ICommandService) serviceLocator.getService(ICommandService.class);
   IHandlerService hsrv = (IHandlerService) serviceLocator.getService(IHandlerService.class);
   ExecutionEvent event = hsrv.createExecutionEvent(srv.getCommand(ActionCommands.PERSIST_TO_ROUTE_MODEL_ACTION), null);
   // Fill it my current active selection.
   if (event.getApplicationContext() instanceof IEvaluationContext) {
      ((IEvaluationContext) event.getApplicationContext()).addVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME, mySelection);
   }
   
   try {
      handler.execute(event);
   } catch (ExecutionException e) {
      Activator.handleError(e.getMessage(), e, true);
   }
}
 
源代码7 项目: eip-designer   文件: CompareWithRouteAction.java
@Override
public void run(IAction action) {
   System.err.println("In run(IACtion)");
   if (serviceLocator == null) {
      serviceLocator = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
   } 
   
   // Create an ExecutionEvent using Eclipse machinery.
   ICommandService srv = (ICommandService) serviceLocator.getService(ICommandService.class);
   IHandlerService hsrv = (IHandlerService) serviceLocator.getService(IHandlerService.class);
   ExecutionEvent event = hsrv.createExecutionEvent(srv.getCommand(ActionCommands.COMPARE_WITH_ROUTE_ACTION), null);
   // Fill it my current active selection.
   if (event.getApplicationContext() instanceof IEvaluationContext) {
      ((IEvaluationContext) event.getApplicationContext()).addVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME, mySelection);
   }
   
   try {
      handler.execute(event);
   } catch (ExecutionException e) {
      Activator.handleError(e.getMessage(), e, true);
   }
}
 
源代码8 项目: eip-designer   文件: PersistToRouteModelAction.java
@Override
public void run(IAction action) {
   if (serviceLocator == null) {
      serviceLocator = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
   } 
   
   // Create an ExecutionEvent using Eclipse machinery.
   ICommandService srv = (ICommandService) serviceLocator.getService(ICommandService.class);
   IHandlerService hsrv = (IHandlerService) serviceLocator.getService(IHandlerService.class);
   ExecutionEvent event = hsrv.createExecutionEvent(srv.getCommand(ActionCommands.PERSIST_TO_ROUTE_MODEL_ACTION), null);
   // Fill it my current active selection.
   if (event.getApplicationContext() instanceof IEvaluationContext) {
      ((IEvaluationContext) event.getApplicationContext()).addVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME, mySelection);
   }
   
   try {
      handler.execute(event);
   } catch (ExecutionException e) {
      Activator.handleError(e.getMessage(), e, true);
   }
}
 
/**
 * setup
 */
private void setup()
{
	try
	{
		// listen for execution events
		Object service = PlatformUI.getWorkbench().getService(ICommandService.class);

		if (service instanceof ICommandService)
		{
			ICommandService commandService = (ICommandService) service;

			commandService.addExecutionListener(this);
		}
	}
	catch (IllegalStateException e)
	{
		// workbench not yet started, or may be running headless (like in core unit tests)
	}
	// listen for element visibility events
	BundleManager manager = BundleManager.getInstance();

	manager.addElementVisibilityListener(this);
}
 
/**
 * tearDown
 */
private void tearDown()
{
	// stop listening for visibility events
	BundleManager manager = BundleManager.getInstance();

	manager.removeElementVisibilityListener(this);

	// stop listening for execution events
	Object service = PlatformUI.getWorkbench().getService(ICommandService.class);

	if (service instanceof ICommandService)
	{
		ICommandService commandService = (ICommandService) service;

		commandService.removeExecutionListener(this);
	}

	// drop all references
	this._commandToIdsMap.clear();
	this._idToCommandsMap.clear();
	this._nonlimitedCommands.clear();
}
 
源代码11 项目: APICloud-Studio   文件: UIUtils.java
public static void setCoolBarVisibility(boolean visible)
{
	IWorkbenchWindow activeWorkbenchWindow = getActiveWorkbenchWindow();
	if (activeWorkbenchWindow instanceof WorkbenchWindow)
	{
		WorkbenchWindow workbenchWindow = (WorkbenchWindow) activeWorkbenchWindow;
		workbenchWindow.setCoolBarVisible(visible);
		workbenchWindow.setPerspectiveBarVisible(visible);

		// Try to force a refresh of the text on the action
		IWorkbenchPart activePart = getActivePart();
		if (activePart != null)
		{
			ICommandService cmdService = (ICommandService) activePart.getSite().getService(ICommandService.class);
			cmdService.refreshElements("org.eclipse.ui.ToggleCoolbarAction", null); //$NON-NLS-1$
		}
	}
}
 
源代码12 项目: elexis-3-core   文件: EditEigenartikelUi.java
public static void executeWithParams(PersistentObject parameter){
	try {
		// get the command
		IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
		ICommandService cmdService = (ICommandService) window.getService(ICommandService.class);
		Command cmd = cmdService.getCommand(EditEigenartikelUi.COMMANDID);
		// create the parameter
		HashMap<String, Object> param = new HashMap<String, Object>();
		param.put(EditEigenartikelUi.PARAMETERID, parameter);
		// build the parameterized command
		ParameterizedCommand pc = ParameterizedCommand.generateCommand(cmd, param);
		// execute the command
		IHandlerService handlerService =
			(IHandlerService) PlatformUI.getWorkbench().getActiveWorkbenchWindow()
				.getService(IHandlerService.class);
		handlerService.executeCommand(pc, null);
	} catch (Exception ex) {
		throw new RuntimeException(EditEigenleistungUi.COMMANDID, ex);
	}
}
 
public void registerCommands(CompilationUnitEditor editor) {
	IWorkbench workbench= PlatformUI.getWorkbench();
	ICommandService commandService= (ICommandService) workbench.getAdapter(ICommandService.class);
	IHandlerService handlerService= (IHandlerService) workbench.getAdapter(IHandlerService.class);
	if (commandService == null || handlerService == null) {
		return;
	}

	if (fCorrectionHandlerActivations != null) {
		JavaPlugin.logErrorMessage("correction handler activations not released"); //$NON-NLS-1$
	}
	fCorrectionHandlerActivations= new ArrayList<IHandlerActivation>();

	Collection<String> definedCommandIds= commandService.getDefinedCommandIds();
	for (Iterator<String> iter= definedCommandIds.iterator(); iter.hasNext();) {
		String id= iter.next();
		if (id.startsWith(ICommandAccess.COMMAND_ID_PREFIX)) {
			boolean isAssist= id.endsWith(ICommandAccess.ASSIST_SUFFIX);
			CorrectionCommandHandler handler= new CorrectionCommandHandler(editor, id, isAssist);
			IHandlerActivation activation= handlerService.activateHandler(id, handler, new LegacyHandlerSubmissionExpression(null, null, editor.getSite()));
			fCorrectionHandlerActivations.add(activation);
		}
	}
}
 
public boolean test(final Object receiver, final String property,
		final Object[] args, final Object expectedValue) {
	if (receiver instanceof IServiceLocator && args.length == 1
			&& args[0] instanceof String) {
		final IServiceLocator locator = (IServiceLocator) receiver;
		if (TOGGLE_PROPERTY_NAME.equals(property)) {
			final String commandId = args[0].toString();
			final ICommandService commandService = (ICommandService) locator
					.getService(ICommandService.class);
			final Command command = commandService.getCommand(commandId);
			final State state = command
					.getState(RegistryToggleState.STATE_ID);
			if (state != null) {
				return state.getValue().equals(expectedValue);
			}
		}
	}
	return false;
}
 
源代码15 项目: elexis-3-core   文件: ErstelleRnnCommand.java
public static Object ExecuteWithParams(IViewSite origin, Tree<?> tSelection){
	IHandlerService handlerService = (IHandlerService) origin.getService(IHandlerService.class);
	ICommandService cmdService = (ICommandService) origin.getService(ICommandService.class);
	try {
		Command command = cmdService.getCommand(ID);
		Parameterization px =
			new Parameterization(command.getParameter("ch.elexis.RechnungErstellen.parameter"), //$NON-NLS-1$
				new TreeToStringConverter().convertToString(tSelection));
		ParameterizedCommand parmCommand =
			new ParameterizedCommand(command, new Parameterization[] {
				px
			});
		
		return handlerService.executeCommand(parmCommand, null);
		
	} catch (Exception ex) {
		throw new RuntimeException("add.command not found"); //$NON-NLS-1$
	}
}
 
源代码16 项目: e4macs   文件: KbdMacroLoadHandler.java
/**
 * Verify statically that this macro will execute properly
 * - Ensure the current Eclipse defines the commands used by the macro 
 * 
 * @param editor
 * @param kbdMacro
 * @return true if validates, else false
 */
private String checkMacro(ITextEditor editor, KbdMacro kbdMacro) {
	String result = null;
	ICommandService ics = (editor != null ) ? (ICommandService) editor.getSite().getService(ICommandService.class) : 
		(ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);		
	@SuppressWarnings("unchecked")	// Eclipse documents the type 
	Collection<String> cmdIds = (Collection<String>)ics.getDefinedCommandIds();
	for (KbdEvent e : kbdMacro.getKbdMacro()) {
		String cmdId;
		if ((cmdId = e.getCmd()) != null) {
			if (!cmdIds.contains(cmdId)) {
				result = cmdId;
				break;
			}
		}
	}
	return result;
}
 
源代码17 项目: e4macs   文件: KbdMacroDefineHandler.java
/**
 * Define the Command to be used when executing the named kbd macro
 * 
 * @param editor
 * @param id - the full command id
 * @param name - the short name
 * @param category - the category to use in the definition
 * @return the Command
 */
Command defineKbdMacro(ITextEditor editor, String id, String name, String category) {
	Command command = null;
	if (id != null) {
		// Now create the executable command 
		ICommandService ics = (editor != null ) ? (ICommandService) editor.getSite().getService(ICommandService.class) : 
			(ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);		
		command = ics.getCommand(id);
		IParameter[] parameters = null;
		try {
			// kludge: Eclipse has no way to dynamically define a parameter, so grab it from a known command
			IParameter p = ics.getCommand(PARAMETER_CMD).getParameter(PARAMETER);
			parameters = new IParameter[] { p };
		} catch (Exception e) { 
		}
		command.define(name, String.format(KBD_DESCRIPTION,name), ics.getCategory(category), parameters);
		command.setHandler(new KbdMacroNameExecuteHandler(name));
	}
	return command;
}
 
源代码18 项目: elexis-3-core   文件: FindingsUiUtil.java
/**
 * Execute the UI command found by the commandId, using the {@link ICommandService}.
 * 
 * @param commandId
 * @param selection
 * @return
 */
public static Object executeCommand(String commandId, IFinding selection){
	try {
		ICommandService commandService =
			(ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
		
		Command cmd = commandService.getCommand(commandId);
		if(selection != null) {
			PlatformUI.getWorkbench().getService(IEclipseContext.class)
				.set(commandId.concat(".selection"), new StructuredSelection(selection));
		}
		ExecutionEvent ee = new ExecutionEvent(cmd, Collections.EMPTY_MAP, null, null);
		return cmd.executeWithChecks(ee);
	} catch (Exception e) {
		LoggerFactory.getLogger(FindingsUiUtil.class)
			.error("cannot execute command with id: " + commandId, e);
	}
	return null;
}
 
源代码19 项目: e4macs   文件: KbdMacroSupport.java
/**
 * Start the definition of a keyboard macro
 * 
 * @param editor
 * @param append - if true, append to the current definition
 */
public void startKbdMacro(ITextEditor editor, boolean append) {
	
	if (!isExecuting()) {
		setEditor(editor);
		isdefining = true;
		ics = (ICommandService) editor.getSite().getService(ICommandService.class);
		// listen for command executions
		ics.addExecutionListener(this);
		addDocumentListener(editor);
		if (!append || kbdMacro == null) {
			kbdMacro = new KbdMacro();
		}
		setViewer(findSourceViewer(editor));
		if (viewer instanceof ITextViewerExtension) {
			((ITextViewerExtension) viewer).prependVerifyKeyListener(whileDefining);
		} else {
			viewer = null;
		}
		// add a listener for ^G
		Beeper.addBeepListener(KbdMacroBeeper.beeper);
		currentCommand = null;
	}
}
 
源代码20 项目: e4macs   文件: CommandSupport.java
/**
 * Get the current set of defined categories corresponding to the included category names
 * 
 * @param ics
 * @return the filtered set of categories
 * 
 * @throws NotDefinedException
 */
private HashSet<Category> getCategories(ICommandService ics) throws NotDefinedException 
{
	if (catHash.isEmpty() && catIncludes != null) {
		Category[] cats = ics.getDefinedCategories();
		for (int i = 0; i < cats.length; i++) {
			for (int j = 0; j < catIncludes.length; j++) {
				if (catIncludes[j].equals(cats[i].getId())) {
					catHash.add(cats[i]);
					break;
				}
			}
		}
	}
	return catHash;
}
 
源代码21 项目: bonita-studio   文件: TestFullScenario.java
/**
 * @throws ExecutionException
 */
public void editAndSave() throws Exception {
    processEditor = getTheOnlyOneEditor();
    processEditor.getEditingDomain().getCommandStack().execute(
            new SetCommand(processEditor.getEditingDomain(),
                    task,
                    ProcessPackage.Literals.ELEMENT__NAME,
                    TESTNAME));

    final IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class);
    final ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
    final Command saveCommand = commandService.getCommand("org.eclipse.ui.file.save");
    final ExecutionEvent executionEvent = new ExecutionEvent(saveCommand, Collections.EMPTY_MAP, null,
            handlerService.getClass());
    saveCommand.executeWithChecks(executionEvent);
}
 
源代码22 项目: elexis-3-core   文件: EditEigenleistungUi.java
public static void executeWithParams(PersistentObject parameter){
	try {
		// get the command
		IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
		ICommandService cmdService = (ICommandService) window.getService(ICommandService.class);
		Command cmd = cmdService.getCommand(EditEigenleistungUi.COMMANDID);
		// create the parameter
		HashMap<String, Object> param = new HashMap<String, Object>();
		param.put(EditEigenleistungUi.PARAMETERID, parameter);
		// build the parameterized command
		ParameterizedCommand pc = ParameterizedCommand.generateCommand(cmd, param);
		// execute the command
		IHandlerService handlerService =
			(IHandlerService) PlatformUI.getWorkbench().getActiveWorkbenchWindow()
				.getService(IHandlerService.class);
		handlerService.executeCommand(pc, null);
	} catch (Exception ex) {
		throw new RuntimeException(EditEigenleistungUi.COMMANDID, ex);
	}
}
 
源代码23 项目: wildwebdeveloper   文件: TestJSON.java
@Test
public void testFormatEnabled() throws IOException, PartInitException, CoreException {
	File file = File.createTempFile("test", ".json");
	IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
	IDE.openEditorOnFileStore(activePage, EFS.getStore(file.toURI()));
	ICommandService service = activePage.getWorkbenchWindow().getService(ICommandService.class);
	Command formatCommand = service.getCommand("org.eclipse.lsp4e.format");
	assertNotNull("Format command not found", formatCommand);
	assertTrue("Format command not defined", formatCommand.isDefined());
	assertTrue("Format command not enabled", formatCommand.isEnabled());
	assertTrue("Format command not handled", formatCommand.isHandled());
}
 
源代码24 项目: n4js   文件: N4JSExternalLibraryStartup.java
@Override
public void earlyStartup() {
	// Client code can still clone the repository on demand. (Mind plug-in UI tests.)

	// TODO this should be a job that we can wait for
	new Thread(() -> {
		// trigger index loading which will potentially announce a recovery build on all projects to be
		// necessary

		// XXX it is crucial to call isEmpty before isRecoveryBuildRequired is checked, since isEmpty
		// will set internal state that is afterwards queried by isRecoveryBuildRequired
		boolean indexIsEmpty = builderState.isEmpty();

		// check if this recovery build was really required
		if (descriptionPersister.isRecoveryBuildRequired() || indexIsEmpty) {
			// TODO return something like a Future that allows to say
			// descriptionPersister.scheduleRecoveryBuildOnContributions().andThen(buildManager...)
			descriptionPersister.scheduleRecoveryBuildOnContributions();
			Map<String, String> args = Maps.newHashMap();
			IBuildFlag.RECOVERY_BUILD.addToMap(args);
			builderStateDiscarder.forgetLastBuildState(Arrays.asList(workspace.getRoot().getProjects()), args);
		}
	}).start();

	// Add listener to monitor Cut and Copy commands
	ICommandService commandService = PlatformUI.getWorkbench().getAdapter(ICommandService.class);
	if (commandService != null) {
		commandService.addExecutionListener(new CheckNodeModulesSyncOnRefresh());
	}
}
 
protected IStatus openConfigureDialog() throws ExecutionException {
    ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
    Command cmd = service.getCommand("org.bonitasoft.studio.configuration.configure");
    Map<String, Object> parameters = new HashMap<String, Object>();
    String configuration = ConfigurationPlugin.getDefault().getPreferenceStore().getString(ConfigurationPreferenceConstants.DEFAULT_CONFIGURATION);
    parameters.put("configuration", configuration);
    parameters.put("process", process);
    return (IStatus) new ConfigureHandler().execute(new ExecutionEvent(cmd, parameters, null, null));
}
 
源代码26 项目: ContentAssist   文件: CommandExecutionManager.java
/**
 * Unregisters a command manager with the command service of the workbench.
 * @param cm the command manager
 */
public static void unregister(CommandExecutionManager cm) {
    ICommandService cs = (ICommandService)PlatformUI.getWorkbench().getService(ICommandService.class);
    if (cs != null) {
        cs.removeExecutionListener(cm);
    }
}
 
源代码27 项目: elexis-3-core   文件: MedicationComposite.java
public void setViewerSortOrder(ViewerSortOrder vso){
	medicationTableComposite.getTableViewer().setComparator(vso.vc);
	medicationHistoryTableComposite.getTableViewer().setComparator(vso.vc);
	
	ICommandService service =
		(ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
	Command command = service.getCommand(ApplyCustomSortingHandler.CMD_ID);
	command.getState(ApplyCustomSortingHandler.STATE_ID)
		.setValue(vso.equals(ViewerSortOrder.MANUAL));
}
 
源代码28 项目: neoscada   文件: TrendControlImage.java
protected void startHdView ()
{
    try
    {
        final ICommandService commandService = (ICommandService)PlatformUI.getWorkbench ().getService ( ICommandService.class );
        final IHandlerService handlerService = (IHandlerService)PlatformUI.getWorkbench ().getService ( IHandlerService.class );

        final Command command = commandService.getCommand ( "org.eclipse.scada.ui.chart.view.commands.OpenParametersChartView" ); //$NON-NLS-1$

        final Parameterization[] parameterizations = new Parameterization[4];
        parameterizations[0] = new Parameterization ( command.getParameter ( "org.eclipse.scada.ui.chart.connectionId" ), this.connectionId ); //$NON-NLS-1$
        parameterizations[1] = new Parameterization ( command.getParameter ( "org.eclipse.scada.ui.chart.itemId" ), this.itemId ); //$NON-NLS-1$
        if ( this.queryString == null || this.queryString.isEmpty () )
        {
            parameterizations[2] = new Parameterization ( command.getParameter ( "org.eclipse.scada.ui.chart.queryTimespec" ), "2400000:600000" ); //$NON-NLS-1$ //$NON-NLS-2$
        }
        else
        {
            parameterizations[2] = new Parameterization ( command.getParameter ( "org.eclipse.scada.ui.chart.queryTimespec" ), this.queryString ); //$NON-NLS-1$ 
        }
        parameterizations[3] = new Parameterization ( command.getParameter ( "org.eclipse.scada.ui.chart.itemType" ), "hd" ); //$NON-NLS-1$ //$NON-NLS-2$

        final ParameterizedCommand parameterCommand = new ParameterizedCommand ( command, parameterizations );

        handlerService.executeCommand ( parameterCommand, null );
    }
    catch ( final Exception e )
    {
        logger.debug ( "Failed to open view", e );
        StatusManager.getManager ().handle ( new Status ( IStatus.ERROR, Activator.PLUGIN_ID, Messages.TrendControlImage_TrendError, e ), StatusManager.BLOCK );
    }
}
 
源代码29 项目: neoscada   文件: SymbolContext.java
/**
 * Execute an Eclipse command
 *
 * @param commandId
 *            the command to execute
 * @param eventData
 *            the parameter event data (depends on the command)
 */
public void executeCommand ( final String commandId, final Map<String, String> eventData )
{
    try
    {
        final ICommandService commandService = (ICommandService)PlatformUI.getWorkbench ().getService ( ICommandService.class );
        final IHandlerService handlerService = (IHandlerService)PlatformUI.getWorkbench ().getService ( IHandlerService.class );

        final Command command = commandService.getCommand ( commandId );

        final Parameterization[] parameterizations = new Parameterization[eventData.size ()];

        int i = 0;
        for ( final Map.Entry<String, String> entry : eventData.entrySet () )
        {
            parameterizations[i] = new Parameterization ( command.getParameter ( entry.getKey () ), entry.getValue () );
            i++;
        }
        final ParameterizedCommand parameterCommand = new ParameterizedCommand ( command, parameterizations );

        handlerService.executeCommand ( parameterCommand, null );
    }
    catch ( final Exception e )
    {
        logger.warn ( "Failed to execute command", e );
        StatusManager.getManager ().handle ( StatusHelper.convertStatus ( Activator.PLUGIN_ID, e ), StatusManager.BLOCK );
    }
}
 
源代码30 项目: workspacemechanic   文件: KeyboardBindingsTask.java
public KeyboardBindingsTask(KeyBindingsModel model, IResourceTaskReference taskRef) {
  this(
      MechanicLog.getDefault(),
      PlatformUI.getWorkbench(),
      (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class),
      (IBindingService) PlatformUI.getWorkbench().getService(IBindingService.class),
      model,
      String.format("%[email protected]%s", KeyboardBindingsTask.class.getName(), taskRef.getPath()));
}
 
 类所在包
 同包方法