Пример #1
0
  public AbsPage zKeyboardShortcut(Shortcut shortcut) throws HarnessException {
    logger.info(myPageName() + " zKeyboardShortcut(" + shortcut + ")");

    if (shortcut == null) throw new HarnessException("Shortcut cannot be null");

    tracer.trace("Using the keyboard, press the " + shortcut.getKeys() + " keyboard shortcut");

    AbsPage page = null;

    if (shortcut == Shortcut.S_ESCAPE) {

      // Close the window
      zKeyDown("27");
      return page;
    }

    zTypeCharacters(shortcut.getKeys());

    return (page);
  }
  /** @return true if action is added and has second stroke */
  private boolean addAction(AnAction action, Shortcut sc) {
    boolean hasSecondStroke = false;

    Shortcut[] shortcuts = action.getShortcutSet().getShortcuts();
    for (Shortcut each : shortcuts) {
      if (!each.isKeyboard()) continue;

      if (each.startsWith(sc)) {
        if (!myContext.getActions().contains(action)) {
          myContext.getActions().add(action);
        }

        if (each instanceof KeyboardShortcut) {
          hasSecondStroke |= ((KeyboardShortcut) each).getSecondKeyStroke() != null;
        }
      }
    }

    return hasSecondStroke;
  }
    @Override
    public void foundShortcut(
        int u_fromNode,
        int w_toNode,
        double existingDirectWeight,
        EdgeIterator outgoingEdges,
        int skippedEdge1,
        int incomingEdgeOrigCount) {
      // FOUND shortcut
      // but be sure that it is the only shortcut in the collection
      // and also in the graph for u->w. If existing AND identical weight => update setProperties.
      // Hint: shortcuts are always one-way due to distinct level of every node but we don't
      // know yet the levels so we need to determine the correct direction or if both directions
      // minor improvement: if (shortcuts.containsKey(sc)
      // then two shortcuts with the same nodes (u<->n.endNode) exists => check current shortcut
      // against both
      Shortcut sc = new Shortcut(u_fromNode, w_toNode, existingDirectWeight);
      if (shortcuts.containsKey(sc)) {
        return;
      } else {
        Shortcut tmpSc = new Shortcut(w_toNode, u_fromNode, existingDirectWeight);
        Shortcut tmpRetSc = shortcuts.get(tmpSc);
        if (tmpRetSc != null) {
          tmpRetSc.flags = scBothDir;
          return;
        }
      }

      shortcuts.put(sc, sc);
      sc.skippedEdge1 = skippedEdge1;
      sc.skippedEdge2 = outgoingEdges.getEdge();
      sc.originalEdges = incomingEdgeOrigCount + getOrigEdgeCount(outgoingEdges.getEdge());
    }