private void writeKeyMap(Map<String, KeyStroke[]> actionMap) throws IOException { try { writer.writeCommentLine( "See http://trac.mucommander.com/wiki/ActionKeyMap for information on how to customize this file"); XmlAttributes rootElementAttributes = new XmlAttributes(); rootElementAttributes.add(VERSION_ATTRIBUTE, RuntimeConstants.VERSION); writer.startElement(ROOT_ELEMENT, rootElementAttributes, true); if (actionMap != null) { for (String actionId : actionMap.keySet()) addMapping(actionId, actionMap.get(actionId)); } } finally { writer.endElement(ROOT_ELEMENT); } }
private void addMapping(String actionId, KeyStroke[] keyStrokes) throws IOException { XmlAttributes attributes = new XmlAttributes(); attributes.add(ID_ATTRIBUTE, actionId); LOGGER.trace( " Writing mapping of " + actionId + " to " + keyStrokes[0] + " and " + keyStrokes[1]); if (keyStrokes[0] != null) attributes.add( PRIMARY_KEYSTROKE_ATTRIBUTE, KeyStrokeUtils.getKeyStrokeRepresentation(keyStrokes[0])); if (keyStrokes[1] != null) attributes.add( ALTERNATE_KEYSTROKE_ATTRIBUTE, KeyStrokeUtils.getKeyStrokeRepresentation(keyStrokes[1])); writer.writeStandAloneElement(ACTION_ELEMENT, attributes); }