List of usage examples for org.eclipse.jface.contexts IContextIds CONTEXT_ID_DIALOG
String CONTEXT_ID_DIALOG
To view the source code for org.eclipse.jface.contexts IContextIds CONTEXT_ID_DIALOG.
Click Source Link
From source file:org.eclipse.ui.tests.contexts.Bug84763Test.java
License:Open Source License
/** * <p>//from w ww . jav a 2s . com * Testst whether the binding manager will overwrite information in the * context manager. In particular, whether the list of previous enabled * context identifiers will be changed. * </p> * * @throws NotDefinedException * If the scheme we try to activate is not defined. * @throws ParseException * If "CTRL+F" cannot be parsed for some reason. */ public void testWindowChildWhenDialog() throws NotDefinedException, ParseException { // Define the contexts to use. final Context dialogAndWindowsContext = contextManager.getContext(IContextIds.CONTEXT_ID_DIALOG_AND_WINDOW); dialogAndWindowsContext.define("In Dialogs and Windows", null, null); final Context dialogContext = contextManager.getContext(IContextIds.CONTEXT_ID_DIALOG); dialogContext.define("In Dialogs", null, IContextIds.CONTEXT_ID_DIALOG_AND_WINDOW); final Context windowContext = contextManager.getContext(IContextIds.CONTEXT_ID_WINDOW); windowContext.define("In Windows", null, IContextIds.CONTEXT_ID_DIALOG_AND_WINDOW); final Context windowChildContext = contextManager.getContext("sibling"); windowChildContext.define("Sibling", null, IContextIds.CONTEXT_ID_WINDOW); // Force a binding computation. final Scheme scheme = bindingManager.getScheme("na"); scheme.define("name", null, null); bindingManager.setActiveScheme(scheme); final CommandManager commandManager = new CommandManager(); final Command command = commandManager.getCommand("commandId"); final ParameterizedCommand parameterizedCommand = new ParameterizedCommand(command, null); bindingManager.addBinding(new KeyBinding(KeySequence.getInstance("CTRL+F"), parameterizedCommand, scheme.getId(), windowChildContext.getId(), null, null, null, Binding.SYSTEM)); bindingManager.getActiveBindingsFor((ParameterizedCommand) null); // Activate the dialog context and the sibling. final Set activeContextIds = new HashSet(); activeContextIds.add(IContextIds.CONTEXT_ID_DIALOG); activeContextIds.add(IContextIds.CONTEXT_ID_DIALOG_AND_WINDOW); activeContextIds.add(windowChildContext.getId()); contextManager.setActiveContextIds(activeContextIds); // Force a binding computation. bindingManager.getActiveBindingsFor((ParameterizedCommand) null); // Active the window context. activeContextIds.remove(IContextIds.CONTEXT_ID_DIALOG); activeContextIds.add(IContextIds.CONTEXT_ID_WINDOW); contextManager.setActiveContextIds(activeContextIds); // Force a binding computation. bindingManager.getActiveBindingsFor((ParameterizedCommand) null); /* * Check to see what the listener got as the list of previously active * context identifiers. */ assertEquals("There should have been 3 context ids active previously", 3, previousContextIds.size()); assertTrue("The previous contexts should include the dialog context", previousContextIds.contains(IContextIds.CONTEXT_ID_DIALOG)); assertTrue("The previous contexts should include the dialog context", previousContextIds.contains(IContextIds.CONTEXT_ID_DIALOG_AND_WINDOW)); assertTrue("The previous contexts should include the dialog context", previousContextIds.contains(windowChildContext.getId())); System.out.println("testSiblingContext"); }