Bug 298326

Summary: [Commands] Toggle preference property tester
Product: [Eclipse Project] Platform Reporter: Philipp Kursawe <phil.kursawe>
Component: UIAssignee: Platform UI Triaged <platform-ui-triaged>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3 CC: prakash
Version: 3.6   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Philipp Kursawe CLA 2009-12-21 12:52:21 EST
I would like to contribute this property tester back to Eclipse. Its usage is explained here: http://philondev.blogspot.com/2009/12/toggle-commands-toggle-other.html


public class CommandsPropertyTester extends PropertyTester {
public static final String NAMESPACE = "org.eclipse.core.commands"; //$NON-NLS-1$
public static final String PROPERTY_BASE = NAMESPACE + '.';
public static final String TOGGLE_PROPERTY_NAME = "toggle"; //$NON-NLS-1$
public static final String TOGGLE_PROPERTY = PROPERTY_BASE + TOGGLE_PROPERTY_NAME;

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;
}
}


<propertytester
class="org.eclipse.core.commands.extender.internal.CommandsPropertyTester"
id="org.eclipse.core.expressions.testers.CommandsPropertyTester"
namespace="org.eclipse.core.commands"
properties="toggle"
type="org.eclipse.ui.services.IServiceLocator"/>
Comment 1 Eclipse Webmaster CLA 2019-09-06 16:07:26 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.