use of org.eclipse.ui.commands.ICommandService in project xtext-xtend by eclipse.
the class ShowHierarchyTest method invokeTestingHandler.
@SuppressWarnings("cast")
private TestingTypeHierarchyHandler invokeTestingHandler(XtextEditor xtextEditor, String commandID) throws Exception {
IHandlerService handlerService = (IHandlerService) xtextEditor.getSite().getService(IHandlerService.class);
final ICommandService commandService = (ICommandService) xtextEditor.getSite().getService(ICommandService.class);
Command command = commandService.getCommand("org.eclipse.xtext.xbase.ui.hierarchy.OpenTypeHierarchy");
TestingTypeHierarchyHandler testingHandler = new TestingTypeHierarchyHandler();
getInjector().injectMembers(testingHandler);
IHandler originalHandler = command.getHandler();
command.setHandler(testingHandler);
final ExecutionEvent event = new ExecutionEvent(command, Collections.EMPTY_MAP, null, handlerService.getCurrentState());
command.executeWithChecks(event);
command.setHandler(originalHandler);
return testingHandler;
}
use of org.eclipse.ui.commands.ICommandService in project linuxtools by eclipse.
the class DockerContainersView method createPartControl.
@Override
public void createPartControl(final Composite parent) {
final FormToolkit toolkit = new FormToolkit(parent.getDisplay());
form = toolkit.createForm(parent);
form.setText(DVMessages.getString(NoConnectionSelected));
final Composite container = form.getBody();
GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).applyTo(container);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(container);
createTableViewer(container);
getSite().registerContextMenu(new MenuManager(), null);
// track selection changes in the Docker Explorer view (only)
getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(DockerExplorerView.VIEW_ID, this);
hookContextMenu();
hookToolBarItems();
// Look at stored preference to determine if all containers should be
// shown or just running/paused containers. By default, only show
// running/paused containers
IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
boolean showAll = preferences.getBoolean(SHOW_ALL_CONTAINERS_PREFERENCE, true);
showAllContainers(showAll);
final ICommandService service = getViewSite().getWorkbenchWindow().getService(ICommandService.class);
service.getCommand(SHOW_ALL_CONTAINERS_COMMAND_ID).getState(TOGGLE_STATE).setValue(showAll);
service.refreshElements(SHOW_ALL_CONTAINERS_COMMAND_ID, null);
boolean filterByLabels = preferences.getBoolean(FILTER_WITH_LABELS_PREFERENCE, false);
showContainersWithLabels(filterByLabels);
service.getCommand(FILTER_CONTAINERS_COMMAND_ID).getState(TOGGLE_STATE).setValue(filterByLabels);
service.refreshElements(FILTER_CONTAINERS_COMMAND_ID, null);
DockerConnectionManager.getInstance().addConnectionManagerListener(this);
// On startup, this view might get set up after the Docker Explorer View
// and so we won't get the notification when it chooses the connection.
// Find out if it has a selection and set our connection appropriately.
ISelection selection = getSite().getWorkbenchWindow().getSelectionService().getSelection(DockerExplorerView.VIEW_ID);
if (selection != null) {
selectionChanged(null, selection);
// also notify DockerConnectionWatcher
DockerConnectionWatcher.getInstance().selectionChanged(null, selection);
}
}
use of org.eclipse.ui.commands.ICommandService 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.ui.commands.ICommandService 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.ui.commands.ICommandService 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);
}
}
Aggregations