Changeset 585 for trunk/quest-core-events/src/main
- Timestamp:
- 08/22/12 15:53:43 (12 years ago)
- Location:
- trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/guimodel
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/guimodel/AbstractDefaultGUIElementFactory.java
r576 r585 7 7 package de.ugoe.cs.quest.eventcore.guimodel; 8 8 9 import java.io.File; 10 import java.io.FileInputStream; 11 import java.io.FileNotFoundException; 9 12 import java.io.IOException; 10 13 import java.io.InputStream; … … 14 17 import java.util.logging.Logger; 15 18 19 import de.ugoe.cs.util.console.Console; 20 16 21 /** 17 22 * TODO comment 23 * 24 * TODO rename class to GUIElementFactory 18 25 * 19 26 * @version $Revision: $ $Date: 13.05.2012$ 20 27 * @author 2012, last modified by $Author: patrick$ 21 28 */ 22 public abstract class AbstractDefaultGUIElementFactory implements IGUIElementFactory { 29 public class AbstractDefaultGUIElementFactory implements IGUIElementFactory { 30 31 /** */ 32 private static AbstractDefaultGUIElementFactory instance = new AbstractDefaultGUIElementFactory(); 33 34 /** 35 * TODO: comment 36 * 37 */ 38 private AbstractDefaultGUIElementFactory() { 39 } 40 41 /** 42 * TODO: comment 43 * 44 * @return 45 */ 46 public static synchronized AbstractDefaultGUIElementFactory getInstance() { 47 return instance; 48 } 49 23 50 24 51 /** */ … … 53 80 * @throws GUIModelConfigurationException 54 81 */ 55 protected IGUIElement instantiateGUIElementFromConfiguredMappings(IGUIElementSpec specification) 56 throws GUIModelConfigurationException 57 { 82 @Override 83 public IGUIElement instantiateGUIElement(IGUIElementSpec specification) { 58 84 Properties mappings = getMappingsFromConfiguration(); 85 IGUIElement guiElement = null; 59 86 60 87 String className = mappings.getProperty(specification.getType()); … … 74 101 parameterTypes[0] = specification.getClass(); 75 102 76 IGUIElementguiElement =103 guiElement = 77 104 (IGUIElement) clazz.getConstructor(parameterTypes).newInstance(specification); 78 105 … … 136 163 } 137 164 } 138 139 return null; 165 if( guiElement==null ) { 166 Console.printerrln("could not find GUI element representing class " + specification.getType()); 167 } 168 169 return guiElement; 140 170 } 141 171 … … 151 181 else { 152 182 mappingsFromConfiguration = new Properties(); 153 154 InputStream inStream = 155 this.getClass().getClassLoader().getResourceAsStream("GUIElementMapping.txt"); 156 157 if (inStream != null) { 158 try { 159 mappingsFromConfiguration.load(inStream); 183 184 File mappingsFolder = new File("data/guimappings"); 185 for( File mappingsFile : mappingsFolder.listFiles()) { 186 if(!mappingsFile.isDirectory() && mappingsFile.getName().startsWith("guimapping") && mappingsFile.getName().endsWith(".txt")) { 187 InputStream inStream; 188 try { 189 inStream = new FileInputStream(mappingsFile); 190 mappingsFromConfiguration.load(inStream); 191 } 192 catch (FileNotFoundException e1) { 193 // TODO Auto-generated catch block 194 e1.printStackTrace(); 195 } 196 catch (IOException e) { 197 Logger.getLogger(this.getClass().getName()).warning 198 ("invalid GUI mappings files " + mappingsFile.getName()); 199 } 160 200 } 161 catch (IOException e) {162 Logger.getLogger(this.getClass().getName()).warning163 ("could not load GUIElementMapping.txt from classpath, but this may be " +164 "intended");165 }166 201 } 167 202 -
trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/guimodel/GUIModelException.java
r545 r585 12 12 * @author 2012, last modified by $Author: pharms$ 13 13 */ 14 public class GUIModelException extends Exception {14 public class GUIModelException extends RuntimeException { 15 15 16 16 /** */
Note: See TracChangeset
for help on using the changeset viewer.