Ejemplo n.º 1
0
  public void writeExternal(Element macro) throws WriteExternalException {
    macro.setAttribute(ATTRIBUTE_NAME, myName);
    final ActionDescriptor[] actions = getActions();
    for (int i = 0; i < actions.length; i++) {
      ActionDescriptor action = actions[i];
      Element actionNode = null;
      if (action instanceof TypedDescriptor) {
        actionNode = new Element(ELEMENT_TYPING);
        TypedDescriptor typedDescriptor = (TypedDescriptor) action;
        final String t = typedDescriptor.getText();
        actionNode.setText(t);
        actionNode.setAttribute(
            ATTRIBUTE_KEY_CODES,
            unparseKeyCodes(
                new Pair<List<Integer>, List<Integer>>(
                    typedDescriptor.getKeyCodes(), typedDescriptor.getKeyModifiers())));
      } else if (action instanceof IdActionDescriptor) {
        actionNode = new Element(ELEMENT_ACTION);
        actionNode.setAttribute(ATTRIBUTE_ID, ((IdActionDescriptor) action).getActionId());
      } else if (action instanceof ShortcutActionDesciption) {
        actionNode = new Element(ELEMENT_SHORTCUT);
        actionNode.setAttribute(ATTRIBUTE_TEXT, ((ShortcutActionDesciption) action).getText());
      }

      assert actionNode != null : action;

      macro.addContent(actionNode);
    }
  }
Ejemplo n.º 2
0
 public void appendKeytyped(char c, int keyCode, int modifiers) {
   ActionDescriptor lastAction = myActions.size() > 0 ? myActions.get(myActions.size() - 1) : null;
   if (lastAction instanceof TypedDescriptor) {
     ((TypedDescriptor) lastAction).addChar(c, keyCode, modifiers);
   } else {
     myActions.add(new TypedDescriptor(c, keyCode, modifiers));
   }
 }