Changeset 585
- Timestamp:
- 08/22/12 15:53:43 (12 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 1 deleted
- 5 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 /** */ -
trunk/quest-plugin-jfc/pom.xml
r573 r585 36 36 </configuration> 37 37 </plugin> 38 <plugin> 39 <artifactId>maven-assembly-plugin</artifactId> 40 <version>2.2-beta-2</version> 41 <configuration> 42 <descriptors> 43 <descriptor>src/main/assembly/config.xml</descriptor> 44 </descriptors> 45 </configuration> 46 <executions> 47 <execution> 48 <id>make-assembly</id> 49 <phase>package</phase> 50 <goals> 51 <goal>single</goal> 52 </goals> 53 </execution> 54 </executions> 55 </plugin> 38 56 </plugins> 39 57 </build> -
trunk/quest-plugin-jfc/src/main/java/de/ugoe/cs/quest/plugin/jfc/JFCLogParser.java
r573 r585 40 40 import de.ugoe.cs.quest.eventcore.gui.MouseButtonUp; 41 41 import de.ugoe.cs.quest.eventcore.gui.MouseClick; 42 import de.ugoe.cs.quest.eventcore.guimodel.AbstractDefaultGUIElementFactory; 42 43 import de.ugoe.cs.quest.eventcore.guimodel.GUIModel; 43 44 import de.ugoe.cs.quest.eventcore.guimodel.GUIModelException; … … 45 46 import de.ugoe.cs.quest.plugin.jfc.eventcore.JFCEvent; 46 47 import de.ugoe.cs.quest.plugin.jfc.eventcore.JFCEventId; 47 import de.ugoe.cs.quest.plugin.jfc.guimodel.JFCGUIElementFactory;48 48 import de.ugoe.cs.quest.plugin.jfc.guimodel.JFCGUIElementSpec; 49 49 import de.ugoe.cs.tasktree.keyboardmaps.VirtualKey; … … 394 394 IGUIElement currentGUIElement; 395 395 try { 396 // TODO right now, there is null pointer exception possible, if the factory cannot create a the GUIElement. We need to devise where and how this should be handled best 396 397 currentGUIElement = guiModel.integratePath 397 (currentGuiElementPath, JFCGUIElementFactory.getInstance());398 (currentGuiElementPath, AbstractDefaultGUIElementFactory.getInstance()); 398 399 } 399 400 catch (GUIModelException e) { -
trunk/quest-runner/pom.xml
r584 r585 152 152 </execution> 153 153 <execution> 154 <id>get-jfc-plugin-config</id> 155 <phase>process-classes</phase> 156 <goals> 157 <goal>unpack</goal> 158 </goals> 159 <configuration> 160 <artifactItems> 161 <artifactItem> 162 <groupId>de.ugoe.cs.quest</groupId> 163 <artifactId>quest-plugin-jfc</artifactId> 164 <version>0.0.1-SNAPSHOT</version> 165 <classifier>config</classifier> 166 <type>zip</type> 167 <outputDirectory>${project.build.directory}/data</outputDirectory> 168 </artifactItem> 169 </artifactItems> 170 </configuration> 171 </execution> 172 <execution> 154 173 <id>get-mfc-plugin-config</id> 155 174 <phase>process-classes</phase>
Note: See TracChangeset
for help on using the changeset viewer.