use of org.eclipse.e4.ui.bindings.EBindingService in project eclipse.platform.ui by eclipse-platform.
the class BindingLookupTest method testFindBinding.
@Test
public void testFindBinding() {
ECommandService cs = workbenchContext.get(ECommandService.class);
ParameterizedCommand cmd = cs.createCommand(TEST_ID1, null);
EBindingService bs = workbenchContext.get(EBindingService.class);
TriggerSequence seq = bs.createSequence("CTRL+5 T");
Binding db = createDefaultBinding(bs, seq, cmd, ID_DIALOG_AND_WINDOW);
bs.activateBinding(db);
Binding perfectMatch = bs.getPerfectMatch(seq);
assertEquals(cmd, perfectMatch.getParameterizedCommand());
bs.deactivateBinding(db);
assertNull(bs.getPerfectMatch(seq));
bs.activateBinding(db);
assertEquals(cmd, bs.getPerfectMatch(seq).getParameterizedCommand());
}
use of org.eclipse.e4.ui.bindings.EBindingService in project eclipse.platform.ui by eclipse-platform.
the class BindingLookupTest method testLookupAllShortcutsWithChild.
@Test
public void testLookupAllShortcutsWithChild() {
ECommandService cs = workbenchContext.get(ECommandService.class);
ParameterizedCommand cmd = cs.createCommand(TEST_ID1, null);
EBindingService wBS = workbenchContext.get(EBindingService.class);
TriggerSequence seq2 = wBS.createSequence("ALT+5 X");
Binding db2 = createDefaultBinding(wBS, seq2, cmd, ID_DIALOG_AND_WINDOW);
wBS.activateBinding(db2);
IEclipseContext c1 = workbenchContext.createChild("c1");
c1.activate();
EContextService es = c1.get(EContextService.class);
es.activateContext(ID_WINDOW);
EBindingService bs1 = c1.get(EBindingService.class);
TriggerSequence seq = bs1.createSequence("CTRL+5 T");
Binding db = createDefaultBinding(wBS, seq, cmd, ID_WINDOW);
bs1.activateBinding(db);
// the list will always be ordered
ArrayList<TriggerSequence> list = new ArrayList<>();
list.add(seq);
list.add(seq2);
assertEquals(list, wBS.getSequencesFor(cmd));
}
use of org.eclipse.e4.ui.bindings.EBindingService in project eclipse.platform.ui by eclipse-platform.
the class BindingLookupTest method testGetPartialMatches.
@Test
public void testGetPartialMatches() {
ECommandService cs = workbenchContext.get(ECommandService.class);
ParameterizedCommand cmd = cs.createCommand(TEST_ID1, null);
ParameterizedCommand cmd2 = cs.createCommand(TEST_ID2, null);
EBindingService wBS = workbenchContext.get(EBindingService.class);
TriggerSequence seq2 = wBS.createSequence("ALT+5 X");
Binding wbBind = createDefaultBinding(wBS, seq2, cmd, ID_DIALOG_AND_WINDOW);
wBS.activateBinding(wbBind);
IEclipseContext c1 = workbenchContext.createChild("c1");
c1.activate();
EBindingService bs1 = c1.get(EBindingService.class);
TriggerSequence seq = bs1.createSequence("CTRL+5 T");
Binding b1 = createDefaultBinding(wBS, seq, cmd, ID_DIALOG_AND_WINDOW);
bs1.activateBinding(b1);
TriggerSequence sseq = bs1.createSequence("CTRL+5 Y");
Binding b2 = createDefaultBinding(bs1, sseq, cmd2, ID_DIALOG_AND_WINDOW);
bs1.activateBinding(b2);
ArrayList<Binding> commandMatches = new ArrayList<>();
commandMatches.add(b1);
commandMatches.add(b2);
TriggerSequence partialMatch = bs1.createSequence("CTRL+5");
TriggerSequence partialNoMatch = bs1.createSequence("CTRL+8");
assertFalse(bs1.isPartialMatch(partialNoMatch));
assertTrue(bs1.isPartialMatch(partialMatch));
Collection<Binding> matches = bs1.getPartialMatches(partialMatch);
assertEquals(commandMatches, matches);
}
use of org.eclipse.e4.ui.bindings.EBindingService in project eclipse.platform.ui by eclipse-platform.
the class BindingLookupTest method testLookupChildBinding.
@Test
public void testLookupChildBinding() {
ECommandService cs = workbenchContext.get(ECommandService.class);
ParameterizedCommand cmd = cs.createCommand(TEST_ID1, null);
IEclipseContext c1 = workbenchContext.createChild("c1");
c1.activate();
EBindingService bs1 = c1.get(EBindingService.class);
TriggerSequence seq = bs1.createSequence("CTRL+5 T");
Binding db = createDefaultBinding(bs1, seq, cmd, ID_DIALOG_AND_WINDOW);
bs1.activateBinding(db);
EBindingService wBS = workbenchContext.get(EBindingService.class);
assertEquals(cmd, wBS.getPerfectMatch(seq).getParameterizedCommand());
assertEquals(cmd, bs1.getPerfectMatch(seq).getParameterizedCommand());
bs1.deactivateBinding(db);
assertNull(wBS.getPerfectMatch(seq));
assertNull(bs1.getPerfectMatch(seq));
}
use of org.eclipse.e4.ui.bindings.EBindingService in project eclipse.platform.ui by eclipse-platform.
the class BindingLookupTest method testLookupShortcutsTwoChildren.
@Test
public void testLookupShortcutsTwoChildren() {
ECommandService cs = workbenchContext.get(ECommandService.class);
ParameterizedCommand cmd1 = cs.createCommand(TEST_ID1, null);
ParameterizedCommand cmd2 = cs.createCommand(TEST_ID2, null);
EBindingService wBS = workbenchContext.get(EBindingService.class);
TriggerSequence seq = wBS.createSequence("CTRL+5 T");
IEclipseContext c1 = workbenchContext.createChild("c1");
c1.activate();
EContextService es = c1.get(EContextService.class);
es.activateContext(ID_WINDOW);
EBindingService bs1 = c1.get(EBindingService.class);
Binding db = createDefaultBinding(bs1, seq, cmd1, ID_WINDOW);
bs1.activateBinding(db);
IEclipseContext c2 = workbenchContext.createChild("c2");
EContextService es2 = c2.get(EContextService.class);
es2.activateContext(ID_DIALOG);
EBindingService bs2 = c2.get(EBindingService.class);
Binding db2 = createDefaultBinding(bs2, seq, cmd2, ID_DIALOG);
bs2.activateBinding(db2);
assertEquals(seq, wBS.getBestSequenceFor(cmd1));
assertNull(wBS.getBestSequenceFor(cmd2));
assertEquals(seq, bs1.getBestSequenceFor(cmd1));
assertNull(bs1.getBestSequenceFor(cmd2));
assertEquals(seq, bs2.getBestSequenceFor(cmd2));
assertNull(bs2.getBestSequenceFor(cmd1));
}
Aggregations