use of org.eclipse.core.commands.Command in project linuxtools by eclipse.
the class PerfStatsQuickDiffHandler method execute.
@Override
public Object execute(ExecutionEvent event) {
// get default files
PerfPlugin plugin = PerfPlugin.getDefault();
IPath curStatData = plugin.getPerfFile(PerfPlugin.PERF_DEFAULT_STAT);
IPath prevStatData = plugin.getPerfFile(PerfPlugin.PERF_DEAFULT_OLD_STAT);
IResource curStatFile = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(curStatData);
IResource prevStatFile = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(prevStatData);
// Inject our own selections into the context
IEvaluationContext ctx = (IEvaluationContext) event.getApplicationContext();
ctx.addVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME, new StructuredSelection(new IResource[] { prevStatFile, curStatFile }));
ICommandService cmdService = PlatformUI.getWorkbench().getService(ICommandService.class);
// $NON-NLS-1$
Command cmd = cmdService.getCommand("org.eclipse.linuxtools.perf.CompareAction");
try {
cmd.executeWithChecks(event);
} catch (Exception e) {
}
return null;
}
use of org.eclipse.core.commands.Command in project yamcs-studio by yamcs.
the class SwitchProcessorCompoundContributionItem method updateSelection.
private void updateSelection() {
IWorkbench workbench = PlatformUI.getWorkbench();
ICommandService commandService = (ICommandService) workbench.getService(ICommandService.class);
Command command = commandService.getCommand(SWITCH_PROCESSOR_COMMAND);
try {
ProcessorInfo currentProcessor = ManagementCatalogue.getInstance().getCurrentProcessorInfo();
HandlerUtil.updateRadioState(command, currentProcessor.getName());
} catch (ExecutionException e) {
log.log(Level.SEVERE, "Could not update radio state", e);
}
}
use of org.eclipse.core.commands.Command in project yamcs-studio by yamcs.
the class SwitchProcessorHandler method updateElement.
/*
* Workaround to allow checking radio items in a dynamic contribution
*
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=398647
*/
@Override
public void updateElement(UIElement element, @SuppressWarnings("rawtypes") Map parameters) {
ICommandService service = (ICommandService) element.getServiceLocator().getService(ICommandService.class);
String state = (String) parameters.get(RadioState.PARAMETER_ID);
Command command = service.getCommand(SwitchProcessorCompoundContributionItem.SWITCH_PROCESSOR_COMMAND);
State commandState = command.getState(RadioState.STATE_ID);
if (commandState.getValue().equals(state)) {
element.setChecked(true);
}
}
use of org.eclipse.core.commands.Command in project yamcs-studio by yamcs.
the class RCPUtils method runCommand.
public static void runCommand(String commandId) {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
ICommandService commandService = (ICommandService) window.getService(ICommandService.class);
IEvaluationService evaluationService = (IEvaluationService) window.getService(IEvaluationService.class);
try {
Command cmd = commandService.getCommand(commandId);
cmd.executeWithChecks(new ExecutionEvent(cmd, new HashMap<String, String>(), null, evaluationService.getCurrentState()));
} catch (Exception exception) {
log.log(Level.SEVERE, "Could not execute command " + commandId, exception);
}
}
use of org.eclipse.core.commands.Command in project yamcs-studio by yamcs.
the class EventLog method updateState.
private void updateState() {
ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
Command command = service.getCommand(EventLog.CMD_SCROLL_LOCK);
State state = command.getState(EventLog.STATE_SCROLL_LOCK);
enableScrollLock((Boolean) state.getValue());
}
Aggregations