Java Code Examples for org.eclipse.core.commands.ExecutionEvent#getCommand()

The following examples show how to use org.eclipse.core.commands.ExecutionEvent#getCommand() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StatsShapeOptionHandler.java    From depan with Apache License 2.0 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
  ViewEditor viewer = getViewEditor(event);

  Command command = event.getCommand();
  String optionId = command.getId();

  // For now, simply flip this one state.
  String value = viewer.getOption(optionId);
  if (Strings.isNullOrEmpty(value)) {
    value = StatsViewExtension.SHAPE_DEGREE_MODE_ID.getLabel();
  } else {
    value = null;
  }

  viewer.setOption(optionId, value);
  return null;
}
 
Example 2
Source File: StatsRootOptionHandler.java    From depan with Apache License 2.0 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
  ViewEditor viewer = getViewEditor(event);

  Command command = event.getCommand();
  String optionId = command.getId();

  // For now, simply flip this one state.
  String value = viewer.getOption(optionId);
  if (Strings.isNullOrEmpty(value)) {
    value = StatsViewExtension.COLOR_ROOT_MODE_ID.getLabel();
  } else {
    value = null;
  }

  viewer.setOption(optionId, value);
  return null;
}
 
Example 3
Source File: StatsRatioOptionHandler.java    From depan with Apache License 2.0 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
  ViewEditor viewer = getViewEditor(event);

  Command command = event.getCommand();
  String optionId = command.getId();

  // For now, simply flip this one state.
  String value = viewer.getOption(optionId);
  if (Strings.isNullOrEmpty(value)) {
    value = StatsViewExtension.RATIO_DEGREE_MODE_ID.getLabel();
  } else {
    value = null;
  }

  viewer.setOption(optionId, value);
  return null;
}
 
Example 4
Source File: StatsSizeOptionHandler.java    From depan with Apache License 2.0 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
  ViewEditor viewer = getViewEditor(event);

  Command command = event.getCommand();
  String optionId = command.getId();

  // For now, simply flip this one state.
  String value = viewer.getOption(optionId);
  if (Strings.isNullOrEmpty(value)) {
    value = StatsViewExtension.SIZE_DEGREE_MODE_ID.getLabel();
  } else {
    value = null;
  }

  viewer.setOption(optionId, value);
  return null;
}
 
Example 5
Source File: IgnoreNamedImportSpecifierHandler.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	Command cmd = event.getCommand();
	boolean currentState = HandlerUtil.toggleCommandState(cmd);
	N4JSReferenceQueryExecutor.ignoreNamedImportSpecifier = !currentState;
	return null;
}
 
Example 6
Source File: ConsiderOverridenMembersHandler.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	Command cmd = event.getCommand();
	boolean currentState = HandlerUtil.toggleCommandState(cmd);
	N4JSReferenceQueryExecutor.considerOverridenMethods = !currentState;
	return null;
}
 
Example 7
Source File: ViewEditorOptionHandler.java    From depan with Apache License 2.0 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
  ViewEditor viewer = getViewEditor(event);

  Command command = event.getCommand();
  String optionId = command.getId();
  boolean value = viewer.isOptionChecked(optionId);
  viewer.setBooleanOption(optionId, !value);
  return null;
}
 
Example 8
Source File: ToggleTextNodesHandler.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException
{
	Command command = event.getCommand();
	boolean oldValue = HandlerUtil.toggleCommandState(command);
	HTMLPreferenceUtil.setShowTextNodesInOutline(!oldValue);

	IEditorPart editor = HandlerUtil.getActiveEditor(event);
	if (editor instanceof AbstractThemeableEditor)
	{
		CommonOutlinePage page = ((AbstractThemeableEditor) editor).getOutlinePage();
		page.refresh();
	}
	return null;
}
 
Example 9
Source File: EmacsHelpHandler.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

	EmacsPlusConsole console = EmacsPlusConsole.getInstance();
	console.clear();
	console.activate();
	IBindingService bindingService = (IBindingService) PlatformUI.getWorkbench().getService(IBindingService.class);
	String id = (event.getCommand() != null ? event.getCommand().getId() : null);
	if (id != null) {
		try {
			TriggerSequence trigger = bindingService.getBestActiveBindingFor(event.getCommand().getId());
			Trigger[] trigs = trigger.getTriggers();
			KeyStroke key = (KeyStroke)trigs[0];
			Collection<Binding> partials = EmacsPlusUtils.getPartialMatches(bindingService,KeySequence.getInstance(key)).values();

			for (Binding bind : partials) {
				ParameterizedCommand cmd = bind.getParameterizedCommand();
				if (cmd.getId().startsWith(EmacsPlusUtils.MULGASOFT)) {
					console.printBold(bind.getTriggerSequence().toString());
					console.print(SWT.TAB + cmd.getCommand().getName());
					String desc =  cmd.getCommand().getDescription();
					if (desc != null) {
						desc = desc.replaceAll(CR, EMPTY_STR);
						console.print(" - " + desc + CR);	//$NON-NLS-1$ 
					} else {
						console.print(CR);
					}
				}
			}
		} catch (Exception e) {}
		console.setFocus(true);
	}
	return null;
}
 
Example 10
Source File: StockSCSToggleArticleOutlay.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent executionEvent) throws ExecutionException{
	
	Command command = executionEvent.getCommand();
	HandlerUtil.toggleCommandState(command);
	
	ICommandService commandService =
		(ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
	commandService.refreshElements(executionEvent.getCommand().getId(), null);
	
	return null;
}