Changeset 603 for trunk/quest-core-events/src/main/java/de/ugoe/cs
- Timestamp:
- 08/23/12 14:07:41 (12 years ago)
- Location:
- trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/guimodel
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/guimodel/AbstractDefaultGUIElement.java
r576 r603 21 21 private IGUIElementSpec specification; 22 22 23 /** the reference to the parent element */ 24 private IGUIElement parent; 25 23 26 /** 24 27 * <p> … … 28 31 * @param specification 29 32 */ 30 public AbstractDefaultGUIElement(IGUIElementSpec specification ) {33 public AbstractDefaultGUIElement(IGUIElementSpec specification, IGUIElement parent) { 31 34 this.specification = specification; 35 this.parent = parent; 32 36 } 33 37 … … 42 46 } 43 47 48 /* (non-Javadoc) 49 * @see de.ugoe.cs.quest.eventcore.guimodel.IGUIElement#getParent() 50 */ 51 @Override 52 public IGUIElement getParent() { 53 return parent; 54 } 55 44 56 /* 45 57 * (non-Javadoc) … … 47 59 * @see GUIElement#equals(GUIElement) 48 60 */ 49 public boolean equals(IGUIElement other) { 50 if (this == other) 51 { 52 return true; 53 } 54 55 if (!this.getClass().isInstance(other)) { 56 return false; 57 } 58 59 AbstractDefaultGUIElement otherElem = (AbstractDefaultGUIElement) other; 60 61 return 62 ((otherElem.specification == specification) || 63 ((specification != null) && specification.equals(otherElem.specification))); 61 public final boolean equals(Object other) { 62 // implement final, as GUI elments are all singletons and the equal only if they are the 63 // same object 64 return super.equals(other); 65 } 66 67 /* (non-Javadoc) 68 * @see java.lang.Object#hashCode() 69 */ 70 @Override 71 public final int hashCode() { 72 // implement final, as GUI elments are all singletons and the equal only if they are the 73 // same object 74 return super.hashCode(); 64 75 } 65 76 -
trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/guimodel/GUIElementFactory.java
r592 r603 81 81 */ 82 82 @Override 83 public IGUIElement instantiateGUIElement(IGUIElementSpec specification )83 public IGUIElement instantiateGUIElement(IGUIElementSpec specification, IGUIElement parent) 84 84 throws GUIModelConfigurationException 85 85 { … … 100 100 } 101 101 102 Class<?>[] parameterTypes = new Class<?>[ 1];102 Class<?>[] parameterTypes = new Class<?>[2]; 103 103 parameterTypes[0] = specification.getClass(); 104 105 guiElement = 106 (IGUIElement) clazz.getConstructor(parameterTypes).newInstance(specification); 104 parameterTypes[1] = parent.getClass(); 105 106 guiElement = (IGUIElement) clazz.getConstructor(parameterTypes).newInstance 107 (specification, parent); 107 108 108 109 return guiElement; … … 177 178 * @return 178 179 */ 179 private synchronized Properties getMappingsFromConfiguration() { 180 private synchronized Properties getMappingsFromConfiguration() 181 throws GUIModelConfigurationException 182 { 180 183 if (mappingsFromConfiguration != null) { 181 184 return mappingsFromConfiguration; … … 185 188 186 189 File mappingsFolder = new File("data/guimappings"); 187 for( File mappingsFile : mappingsFolder.listFiles()) { 188 if(!mappingsFile.isDirectory() && mappingsFile.getName().startsWith("guimapping") && mappingsFile.getName().endsWith(".txt")) { 189 InputStream inStream; 190 try { 191 inStream = new FileInputStream(mappingsFile); 192 mappingsFromConfiguration.load(inStream); 193 inStream.close(); 194 } 195 catch (FileNotFoundException e1) { 196 // TODO Auto-generated catch block 197 e1.printStackTrace(); 198 } 199 catch (IOException e) { 200 Logger.getLogger(this.getClass().getName()).warning 201 ("invalid GUI mappings files " + mappingsFile.getName()); 190 File[] children = mappingsFolder.listFiles(); 191 192 if (children != null) { 193 for (File mappingsFile : children) { 194 if (!mappingsFile.isDirectory() && 195 mappingsFile.getName().startsWith("guimapping") && 196 mappingsFile.getName().endsWith(".txt")) 197 { 198 InputStream inStream; 199 try { 200 inStream = new FileInputStream(mappingsFile); 201 mappingsFromConfiguration.load(inStream); 202 inStream.close(); 203 } 204 catch (FileNotFoundException e) { 205 throw new GUIModelConfigurationException 206 ("could not read mapping configuration file " + mappingsFile, e); 207 } 208 catch (IOException e) { 209 throw new GUIModelConfigurationException 210 ("could not read mapping configuration file " + mappingsFile, e); 211 } 202 212 } 203 213 } 204 214 } 215 else { 216 throw new GUIModelConfigurationException 217 ("no GUI mappings file provided in folder " + mappingsFolder); 218 } 205 219 206 220 return mappingsFromConfiguration; -
trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/guimodel/GUIModel.java
r593 r603 8 8 9 9 import java.util.ArrayList; 10 import java.util.LinkedList; 10 11 import java.util.List; 11 12 … … 41 42 throws GUIModelException 42 43 { 43 List<IGUIElementSpec> remainingPath = new ArrayList<IGUIElementSpec>();44 List<IGUIElementSpec> remainingPath = new LinkedList<IGUIElementSpec>(); 44 45 45 46 for (IGUIElementSpec spec : guiElementPath) … … 138 139 // if we get here, the corresponding path does not exist yet. So create it 139 140 if (matchingChildren.size() == 0) { 140 matchingChildren.add 141 (parentNode.addChild 142 (guiElementFactory.instantiateGUIElement(specToIntegrateElementFor))); 141 IGUIElement newElement = guiElementFactory.instantiateGUIElement 142 (specToIntegrateElementFor, parentNode.guiElement); 143 144 matchingChildren.add(parentNode.addChild(newElement)); 143 145 } 144 146 else if (matchingChildren.size() > 1) { -
trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/guimodel/IGUIElement.java
r595 r603 30 30 * TODO comment 31 31 * </p> 32 */ 33 public IGUIElement getParent(); 34 35 /** 36 * <p> 37 * TODO comment 38 * </p> 32 39 * 33 40 * @param other 34 41 * @return 35 42 */ 36 public boolean equals( IGUIElement other);43 public boolean equals(Object other); 37 44 38 45 /** -
trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/guimodel/IGUIElementFactory.java
r596 r603 24 24 * @return 25 25 */ 26 public IGUIElement instantiateGUIElement(IGUIElementSpec specification )26 public IGUIElement instantiateGUIElement(IGUIElementSpec specification, IGUIElement parent) 27 27 throws GUIModelConfigurationException; 28 28
Note: See TracChangeset
for help on using the changeset viewer.