Changeset 589 for trunk/quest-plugin-jfc/src
- Timestamp:
- 08/23/12 10:42:41 (12 years ago)
- Location:
- trunk/quest-plugin-jfc/src/main/java/de/ugoe/cs/quest/plugin/jfc/guimodel
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/quest-plugin-jfc/src/main/java/de/ugoe/cs/quest/plugin/jfc/guimodel/JFCGUIElement.java
r588 r589 8 8 9 9 import de.ugoe.cs.quest.eventcore.guimodel.AbstractDefaultGUIElement; 10 import de.ugoe.cs.quest.eventcore.guimodel.IGUIElementSpec; 10 11 11 12 /** … … 79 80 } 80 81 82 @Override 83 public void updateSpecification(IGUIElementSpec updateSpecification) { 84 if( updateSpecification instanceof JFCGUIElementSpec ) { 85 specification.setName(((JFCGUIElementSpec) updateSpecification).getName()); 86 specification.setElementHash(((JFCGUIElementSpec) updateSpecification).getElementHash()); 87 } 88 } 89 81 90 } -
trunk/quest-plugin-jfc/src/main/java/de/ugoe/cs/quest/plugin/jfc/guimodel/JFCGUIElementSpec.java
r588 r589 5 5 // Copyright : Patrick Harms, 2012 6 6 package de.ugoe.cs.quest.plugin.jfc.guimodel; 7 8 import java.util.LinkedList; 9 import java.util.List; 10 11 import org.apache.commons.collections15.CollectionUtils; 7 12 8 13 import de.ugoe.cs.quest.eventcore.guimodel.IGUIElementSpec; … … 19 24 20 25 /** */ 21 private String name = null;26 private List<String> name = new LinkedList<String>(); 22 27 23 28 /** */ … … 31 36 32 37 /** */ 33 private String elementHash = null;38 private List<String> elementHash = new LinkedList<String>(); 34 39 35 40 /* (non-Javadoc) … … 37 42 */ 38 43 @Override 39 public intgetSimilarity(IGUIElementSpec other) {44 public boolean getSimilarity(IGUIElementSpec other) { 40 45 if (this == other) 41 46 { 42 return 100;47 return true; 43 48 } 44 49 45 50 if (!(other instanceof JFCGUIElementSpec)) 46 51 { 47 return 0;52 return false; 48 53 } 49 54 50 55 JFCGUIElementSpec otherSpec = (JFCGUIElementSpec) other; 51 int result = 0; 52 53 if ((type == otherSpec.type) || ((type != null) && (type.equals(otherSpec.type)))) { 54 result += 50; 55 } 56 57 if ((icon == otherSpec.icon) || ((icon != null) && (icon.equals(otherSpec.icon)))) { 58 result += 10; 59 } 60 61 if (index == otherSpec.index) { 62 result += 10; 63 } 64 65 if ((name == otherSpec.name) || ((name != null) && (name.equals(otherSpec.name)))) { 66 result += 15; 67 } 68 69 if (elementHash == otherSpec.elementHash || ((elementHash!=null) && elementHash.equals(otherSpec.elementHash))) { 70 result += 15; 56 57 boolean retVal = false; 58 59 boolean titleEqual = CollectionUtils.containsAny(name, otherSpec.name); 60 boolean hashEqual = CollectionUtils.containsAny(elementHash, otherSpec.elementHash); 61 62 if( type.equals("Class") ) { 63 retVal = type.equals(otherSpec.type) && (titleEqual || hashEqual); 64 } else { 65 retVal = type.equals(otherSpec.type) && index==otherSpec.index && (titleEqual || hashEqual); 71 66 } 72 67 73 return re sult;68 return retVal; 74 69 } 75 70 … … 102 97 */ 103 98 public String getName() { 104 return name; 99 // TODO for now always returns first matched name 100 if( name.isEmpty() ) { 101 return null; 102 } 103 return name.get(0); 105 104 } 106 105 … … 130 129 */ 131 130 public String getElementHash() { 132 return elementHash; 131 // TODO for now always returns the first hash value 132 if( elementHash.isEmpty() ) { 133 return null; 134 } 135 return elementHash.get(0); 133 136 } 134 137 … … 137 140 */ 138 141 public void setName(String name) { 139 this.name = name; 142 if( !this.name.contains(name) && name!=null ) { 143 this.name.add(name); 144 } 140 145 } 141 146 … … 165 170 */ 166 171 public void setElementHash(String elementHash) { 167 this.elementHash = elementHash; 172 if( !this.elementHash.contains(elementHash) ) { 173 this.elementHash.add(elementHash); 174 } 168 175 } 169 176
Note: See TracChangeset
for help on using the changeset viewer.