Ejemplo n.º 1
0
 @Override
 public boolean onKeyboardEvent(KeyboardEvent event) {
   if (event == null) throw new NullPointerException("event may not be null");
   if (!event.isSpecial() || event.isModified()) return false;
   switch (event.getSpecial()) {
     case ARROW_DOWN:
       return onArrowDown(event, false);
     case ARROW_UP:
       return onArrowUp(event, false);
     case ARROW_RIGHT:
       return onArrowRight(event);
     case ARROW_LEFT:
       return onArrowLeft(event);
     case ALTERNATIVE_ARROW_DOWN:
       return onArrowDown(event, true);
     case ALTERNATIVE_ARROW_UP:
       return onArrowUp(event, true);
       // FIXME:case KeyboardEvent.ALTERNATIVE_ARROW_RIGHT:
       // FIXME:case KeyboardEvent.ALTERNATIVE_ARROW_LEFT:
     case HOME:
       return onHome(event);
     case END:
       return onEnd(event);
     case ALTERNATIVE_HOME:
       return onLineHome(event);
     case ALTERNATIVE_END:
       return onLineEnd(event);
     case PAGE_DOWN:
       return onPageDown(event, false);
     case PAGE_UP:
       return onPageUp(event, false);
     case ALTERNATIVE_PAGE_DOWN:
       return onPageDown(event, true);
     case ALTERNATIVE_PAGE_UP:
       return onPageUp(event, true);
     case ENTER:
       if (noProperContent()
           || clickHandler == null
           || hotPointY < 0
           || hotPointY >= model.getRowCount()
           || getColUnderPos(hotPointX) < 0) return false;
       return clickHandler.onClick(
           model,
           getColUnderPos(hotPointX),
           hotPointY,
           model.getCell(getColUnderPos(hotPointX), hotPointY));
     default:
       return false;
   }
 }
Ejemplo n.º 2
0
 private KeyboardEvent getKeyboardEventFromRegistry(String path) {
   NullCheck.notNull(path, "path");
   final Settings.HotKey proxy = Settings.createHotKey(registry, path);
   KeyboardEvent.Special special = null;
   char c = ' ';
   final String specialStr = proxy.getSpecial("");
   if (!specialStr.trim().isEmpty()) {
     special = KeyboardEvent.translateSpecial(specialStr);
     if (special == null) {
       Log.error(
           "core",
           "registry path "
               + path
               + " tries to use an unknown special keyboard code \'"
               + specialStr
               + "\'");
       return null;
     }
   } else {
     final String charStr = proxy.getCharacter("");
     if (charStr.isEmpty()) {
       Log.error(
           "core",
           "registry path "
               + path
               + " does not contain neither \'special\' nor \'character\' values");
       return null;
     }
     c = charStr.charAt(0);
   }
   final boolean withControl = proxy.getWithControl(false);
   final boolean withShift = proxy.getWithShift(false);
   final boolean withAlt = proxy.getWithAlt(false);
   return new KeyboardEvent(special != null, special, c, withShift, withControl, withAlt);
 }
Ejemplo n.º 3
0
 @Override
 public boolean onKeyboardEvent(KeyboardEvent event) {
   NullCheck.notNull(event, "event");
   System.out.println(event.toString());
   if (closing.onKeyboardEvent(event)) return true;
   return super.onKeyboardEvent(event);
 }
Ejemplo n.º 4
0
 protected boolean onChar(KeyboardEvent event) {
   if (noContent()) return true;
   final int count = model.getItemCount();
   final char c = event.getChar();
   final String beginning;
   if (selected() != null) {
     if (hotPointX >= appearance.getObservableRightBound(selected())) return false;
     final String name = getObservableSubstr(selected());
     final int pos =
         Math.min(hotPointX - appearance.getObservableLeftBound(selected()), name.length());
     if (pos < 0) return false;
     beginning = name.substring(0, pos);
   } else beginning = "";
   Log.debug("list", "beginning:" + beginning);
   final String mustBegin = beginning + c;
   for (int i = 0; i < count; ++i) {
     Log.debug("list", "checking:" + i);
     final String name = getObservableSubstr(model.getItem(i));
     Log.debug("list", "name:" + name);
     if (!name.startsWith(mustBegin)) continue;
     hotPointY = getLineIndexByItemIndex(i);
     Log.debug("list", "hotPointY:" + hotPointY);
     ++hotPointX;
     appearance.announceItem(model.getItem(hotPointY), NONE_APPEARANCE_FLAGS);
     environment.onAreaNewHotPoint(this);
     return true;
   }
   return false;
 }
Ejemplo n.º 5
0
 @Override
 public boolean onKeyboardEvent(KeyboardEvent event) {
   NullCheck.notNull(event, "event");
   if (!event.isSpecial() && (!event.isModified() || event.withShiftOnly())) return onChar(event);
   if (!event.isSpecial() || event.isModified()) return false;
   switch (event.getSpecial()) {
     case ARROW_DOWN:
       return onArrowDown(event, false);
     case ARROW_UP:
       return onArrowUp(event, false);
     case ARROW_RIGHT:
       return onArrowRight(event);
     case ARROW_LEFT:
       return onArrowLeft(event);
     case ALTERNATIVE_ARROW_DOWN:
       return onArrowDown(event, true);
     case ALTERNATIVE_ARROW_UP:
       return onArrowUp(event, true);
     case ALTERNATIVE_ARROW_RIGHT:
       return onAltRight(event);
     case ALTERNATIVE_ARROW_LEFT:
       return onAltLeft(event);
     case HOME:
       return onHome(event);
     case END:
       return onEnd(event);
     case ALTERNATIVE_HOME:
       return onAltHome(event);
     case ALTERNATIVE_END:
       return onAltEnd(event);
     case PAGE_DOWN:
       return onPageDown(event, false);
     case PAGE_UP:
       return onPageUp(event, false);
     case ALTERNATIVE_PAGE_DOWN:
       return onPageDown(event, true);
     case ALTERNATIVE_PAGE_UP:
       return onPageUp(event, true);
     case INSERT:
       return onInsert(event);
     case ENTER:
       return onEnter(event);
     default:
       return false;
   }
 }
Ejemplo n.º 6
0
 @Override
 public boolean onKeyboardEvent(KeyboardEvent event) {
   if (event == null) throw new NullPointerException("event may not be null");
   if (closing.onKeyboardEvent(event)) return true;
   if (event.isModified() || !event.isSpecial()) return false;
   switch (event.getSpecial()) {
     case ENTER:
       return closing.doOk();
     case ARROW_DOWN:
       return onArrowDown(event, false);
     case ARROW_UP:
       return onArrowUp(event, false);
     case ALTERNATIVE_ARROW_DOWN:
       return onArrowDown(event, true);
     case ALTERNATIVE_ARROW_UP:
       return onArrowUp(event, true);
     case ARROW_LEFT:
       return onArrowLeft(event);
     case ARROW_RIGHT:
       return onArrowRight(event);
     case ALTERNATIVE_ARROW_LEFT:
       return onAltLeft(event);
     case ALTERNATIVE_ARROW_RIGHT:
       return onAltRight(event);
     case PAGE_DOWN:
       return onPageDown(event, false);
     case PAGE_UP:
       return onPageUp(event, false);
     case ALTERNATIVE_PAGE_DOWN:
       return onPageDown(event, true);
     case ALTERNATIVE_PAGE_UP:
       return onPageUp(event, true);
     case HOME:
       return onHome(event);
     case END:
       return onEnd(event);
     case ALTERNATIVE_HOME:
       return onAltHome(event);
     case ALTERNATIVE_END:
       return onAltEnd(event);
     case INSERT:
       return onInsert(event);
     default:
       return false;
   }
 }