@Override public void onKeyDown(final KyPressedEvent evt) { final Accelerator acc = evt.getAccelerator(); if (acc.getKeyCode() == KeyCode.UNDEFINED) return; ModuleInfo moduleInfo = null; // look up the module corresponding to this key press moduleInfo = moduleService.getModuleForAccelerator(acc); // TODO: ask options service whether the default modifier should be forced final boolean addModifierAutomatically = true; if (moduleInfo == null && addModifierAutomatically) { // look up the module corresponding to this key press, plus control final KeyCode keyCode = acc.getKeyCode(); final InputModifiers modifiers = forceDefaultModifier(acc.getModifiers()); final Accelerator modAcc = new Accelerator(keyCode, modifiers); if (!acc.equals(modAcc)) { moduleInfo = moduleService.getModuleForAccelerator(modAcc); } } if (moduleInfo == null) return; // no matching module found // run via command service, so that preprocessors are run moduleService.run(moduleInfo, true, new Object[0]); // FIXME // consume event, so that nothing else tries to handle it evt.consume(); }
@Override public void initialize() { // add LUTs to the module index... only when needed! moduleService .getIndex() .addLater( new LazyObjects<ModuleInfo>() { @Override public Collection<ModuleInfo> get() { final Map<String, URL> luts = findLUTs(); final List<ModuleInfo> modules = new ArrayList<ModuleInfo>(); for (final String key : luts.keySet()) { modules.add(createInfo(key, luts.get(key))); } return modules; } }); }