SUGGESTION: It would be good to isolate the JFrame GUI from the underlying translation functions. This provides a GUI for creating and editing string resources associated with a class. Resources are stored in properties files with the same name and located in the same folder as the class. @author
| 75 | * @version 1.0 |
| 76 | */ |
| 77 | @SuppressWarnings("serial") |
| 78 | public class TranslatorTool extends JFrame implements Tool, Hidable, Translator { |
| 79 | |
| 80 | /** |
| 81 | * The singleton shared translator tool. |
| 82 | */ |
| 83 | private static TranslatorTool TOOL; |
| 84 | |
| 85 | /** |
| 86 | * Gets the shared TranslatorTool. |
| 87 | * |
| 88 | * @return the shared TranslatorTool |
| 89 | */ |
| 90 | public static TranslatorTool getTool() { |
| 91 | return (TOOL == null ? (TOOL = new TranslatorTool()) : TOOL); |
| 92 | } |
| 93 | |
| 94 | |
| 95 | // static fields |
| 96 | |
| 97 | /** |
| 98 | * maps class to default properties map (name->value translations) |
| 99 | */ |
| 100 | private static Map<Class<?>, Map<String, String>> defaultProps = new HashMap<Class<?>, Map<String, String>>(); |
| 101 | /** |
| 102 | * maps class to map of language->properties |
| 103 | */ |
| 104 | private static Map<Class<?>, Map<String, Map<String, String>>> classes = new HashMap<Class<?>, Map<String, Map<String, String>>>(); |
| 105 | /** |
| 106 | * maps object to class |
| 107 | */ |
| 108 | private static Map<Object, Class<?>> associates = new HashMap<Object, Class<?>>(); |
| 109 | |
| 110 | /** |
| 111 | * contains properties with unsaved changes |
| 112 | */ |
| 113 | private static Set<Map<String, String>> changed = new HashSet<Map<String, String>>(); |
| 114 | private static Locale locale = Locale.getDefault(); |
| 115 | /** |
| 116 | * classes searched for translations |
| 117 | */ |
| 118 | private static Set<Class<?>> searched = new HashSet<Class<?>>(); |
| 119 | private static Map<Class<?>, String> paths = new HashMap<Class<?>, String>(); // property file directory paths |
| 120 | private static Class<?> classType; |
| 121 | |
| 122 | |
| 123 | // GUI |
| 124 | |
| 125 | private static boolean haveGUI; |
| 126 | |
| 127 | // instance fields |
| 128 | |
| 129 | private boolean keepHidden = false; |
| 130 | private XMLControl control = new XMLControlElement(); |
| 131 | private XMLTable table; |
| 132 | private Dimension dim = new Dimension(320, 240); |
| 133 | private String helpURL = "https://www.compadre.org/online_help/tools/translator_tool_help.html"; //$NON-NLS-1$ |
| 134 | private String fileExtension; |
nothing calls this directly
no test coverage detected