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); } }
public void writeExternal(Element macro) { macro.setAttribute(ATTRIBUTE_NAME, myName); final ActionDescriptor[] actions = getActions(); for (ActionDescriptor action : actions) { Element actionNode = null; if (action instanceof TypedDescriptor) { actionNode = new Element(ELEMENT_TYPING); TypedDescriptor typedDescriptor = (TypedDescriptor) action; actionNode.setText(typedDescriptor.getText().replaceAll(" ", " ")); actionNode.setAttribute( ATTRIBUTE_KEY_CODES, unparseKeyCodes( Couple.of(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); } }