1 53 54 package org.swixml.converters; 55 56 import org.jdom.Attribute; 57 import org.swixml.Converter; 58 import org.swixml.Localizer; 59 import org.swixml.Parser; 60 61 import javax.swing.*; 62 63 80 public class KeyStrokeConverter implements Converter { 81 82 83 public static final Class TEMPLATE = KeyStroke.class; 84 85 92 public Object convert( final Class type, final Attribute attr, Localizer localizer ) { 93 return KeyStrokeConverter.conv( type, attr, localizer ); 94 } 95 96 129 public static Object conv( final Class type, final Attribute attr, Localizer localizer ) { 130 KeyStroke keyStroke = null; 131 if (attr != null) { 132 if (Parser.LOCALIZED_ATTRIBUTES.contains( attr.getName().toLowerCase() )) { 133 if (attr.getAttributeType() == Attribute.CDATA_TYPE) { 134 attr.setValue( localizer.getString( attr.getValue() ) ); 135 } 136 } 137 keyStroke = KeyStroke.getKeyStroke( attr.getValue() ); 138 } 139 return keyStroke; 140 } 141 142 147 public Class convertsTo() { 148 return TEMPLATE; 149 } 150 } 151 | Popular Tags |