use of org.eclipse.core.commands.Command in project gfm_viewer by satyagraha.
the class ViewerSupportDefault method isOnline.
@Override
public boolean isOnline() {
LOGGER.fine("");
Command command = commandService.getCommand(GFM_VIEWER_PLUGIN_ONLINE);
State state = command.getState(RegistryToggleState.STATE_ID);
return (Boolean) state.getValue();
}
use of org.eclipse.core.commands.Command in project azure-tools-for-java by Microsoft.
the class AzureAbstractHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final Map<String, String> properties = new HashMap<>();
try {
final Command cmd = event.getCommand();
String handlerName = this.getClass().getSimpleName();
final Collection<?> callingMenus = HandlerUtil.getActiveMenus(event);
boolean fromProjectMenu = callingMenus != null && callingMenus.contains("org.eclipse.ui.navigator.ProjectExplorer#PopupMenu");
properties.put("FromProjectMenu", String.valueOf(fromProjectMenu));
if (cmd != null) {
properties.put("CategoryId", cmd.getCategory().getId());
properties.put("Category", cmd.getCategory().getName());
properties.put("CommandId", cmd.getId());
properties.put("Text", cmd.getName());
if (null == handlerName || handlerName.isEmpty()) {
handlerName = cmd.getName();
}
}
AppInsightsClient.createByType(AppInsightsClient.EventType.Action, handlerName, null, properties);
} catch (NotDefinedException ignore) {
}
return onExecute(event);
}
use of org.eclipse.core.commands.Command in project eclipse.platform.text by eclipse.
the class ShowInSystemExplorerHyperlink method open.
@Override
public void open() {
ECommandService commandService = PlatformUI.getWorkbench().getService(ECommandService.class);
EHandlerService handlerService = PlatformUI.getWorkbench().getService(EHandlerService.class);
Command command = commandService.getCommand(ShowInSystemExplorerHandler.ID);
if (command.isDefined()) {
ParameterizedCommand parameterizedCommand = commandService.createCommand(ShowInSystemExplorerHandler.ID, Collections.singletonMap(ShowInSystemExplorerHandler.RESOURCE_PATH_PARAMETER, fileLocation));
if (handlerService.canExecute(parameterizedCommand)) {
handlerService.executeHandler(parameterizedCommand);
}
}
}
use of org.eclipse.core.commands.Command in project eclipse.platform.text by eclipse.
the class ToggleHighlight method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Command command = event.getCommand();
boolean oldValue = HandlerUtil.toggleCommandState(command);
IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(GenericEditorPlugin.BUNDLE_ID);
preferences.putBoolean(TOGGLE_HIGHLIGHT_PREFERENCE, !oldValue);
return null;
}
use of org.eclipse.core.commands.Command 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;
}
Aggregations