Changeset 2044 for trunk/autoquest-plugin-jfc/src
- Timestamp:
- 10/20/15 10:13:39 (9 years ago)
- Location:
- trunk/autoquest-plugin-jfc/src/main/java/de/ugoe/cs/autoquest/plugin/jfc/guimodel
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-plugin-jfc/src/main/java/de/ugoe/cs/autoquest/plugin/jfc/guimodel/JFCDialog.java
r1876 r2044 16 16 17 17 import de.ugoe.cs.autoquest.eventcore.guimodel.IFrame; 18 import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIView;19 18 20 19 /** … … 26 25 * @author Patrick Harms 27 26 */ 28 public class JFCDialog extends JFCGUIElement implements IFrame , IGUIView{27 public class JFCDialog extends JFCGUIElement implements IFrame { 29 28 30 29 /** … … 60 59 } 61 60 62 /* (non-Javadoc)63 * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIView#isModal()64 */65 @Override66 public boolean isModal() {67 return true;68 }69 70 61 } -
trunk/autoquest-plugin-jfc/src/main/java/de/ugoe/cs/autoquest/plugin/jfc/guimodel/JFCFrame.java
r1876 r2044 16 16 17 17 import de.ugoe.cs.autoquest.eventcore.guimodel.IFrame; 18 import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIView;19 18 20 19 /** … … 26 25 * @author Patrick Harms 27 26 */ 28 public class JFCFrame extends JFCGUIElement implements IFrame , IGUIView{27 public class JFCFrame extends JFCGUIElement implements IFrame { 29 28 30 29 /** … … 60 59 } 61 60 62 /* (non-Javadoc)63 * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIView#isModal()64 */65 @Override66 public boolean isModal() {67 return false;68 }69 70 61 } -
trunk/autoquest-plugin-jfc/src/main/java/de/ugoe/cs/autoquest/plugin/jfc/guimodel/JFCGUIElement.java
r1876 r2044 39 39 /** 40 40 * <p> 41 * the default distance value for different applications 42 * </p> 43 */ 44 protected static final double DISTANCE_DISTINCT_APPLICATION = 1.0; 45 46 /** 47 * <p> 48 * the default distance value for same application but different views, i.e., dialogs, frames, 49 * or tabbed panes 50 * </p> 51 */ 52 protected static final double DISTANCE_SAME_APPLICATION = 0.75; 53 54 /** 55 * <p> 56 * the default distance value for same view but different panels 57 * </p> 58 */ 59 protected static final double DISTANCE_SAME_VIEW = 0.5; 60 61 /** 62 * <p> 63 * the default distance value for same parent panel but different GUI elements 64 * </p> 65 */ 66 protected static final double DISTANCE_SAME_PANEL = 0.2; 67 68 /** 69 * <p> 70 * the default distance value for identical GUI elements 71 * </p> 72 */ 73 protected static final double DISTANCE_NONE = 0.0; 74 75 /** 76 * <p> 41 77 * Specification of the GUI Element 42 78 * </p> … … 192 228 @Override 193 229 public IGUIView getView() { 194 IGUIElement element = this; 195 196 while ((element != null) && (!(element instanceof IGUIView))) { 230 JFCGUIElement element = this; 231 232 while ((element != null) && (!(element instanceof JFCFrame)) && 233 (!(element instanceof JFCDialog))) 234 { 197 235 if (!(element.getParent() instanceof JFCTabbedPane)) { 198 element = element.getParent();236 element = (JFCGUIElement) element.getParent(); 199 237 } 200 238 else { … … 204 242 } 205 243 206 return (IGUIView) element;244 return new JFCView(element); 207 245 } 208 246 … … 214 252 @Override 215 253 public double getDistanceTo(IGUIElement otherElement) { 216 throw new UnsupportedOperationException("not implemented yet"); 254 if (otherElement instanceof JFCGUIElement) { 255 if (equals(otherElement)) { 256 return DISTANCE_NONE; 257 } 258 259 if (!areInSameView(this, otherElement)) { 260 IGUIElement root1 = this; 261 262 while (root1.getParent() != null) { 263 root1 = root1.getParent(); 264 } 265 266 IGUIElement root2 = otherElement; 267 268 while (root2.getParent() != null) { 269 root2 = root2.getParent(); 270 } 271 272 if (!root1.equals(root2)) { 273 return DISTANCE_DISTINCT_APPLICATION; 274 } 275 else { 276 return DISTANCE_SAME_APPLICATION; 277 } 278 } 279 else { 280 // check if they have the same parent panel. If so, they are very close. 281 // If not, they may be structured completely differently 282 IGUIElement parentPanel1 = this; 283 284 while (parentPanel1 != null) { 285 if ((parentPanel1 instanceof JFCPanel) || 286 (parentPanel1 instanceof JFCFrame) || 287 (parentPanel1 instanceof JFCDialog) || 288 (parentPanel1 instanceof JFCCanvas) || 289 (parentPanel1 instanceof JFCMenu) || 290 (parentPanel1 instanceof JFCScrollPane) || 291 (parentPanel1 instanceof JFCSplitPane) || 292 (parentPanel1 instanceof JFCTabbedPane)) 293 { 294 break; 295 } 296 else { 297 parentPanel1 = parentPanel1.getParent(); 298 } 299 } 300 301 IGUIElement parentPanel2 = otherElement; 302 303 while (parentPanel2 != null) { 304 if ((parentPanel2 instanceof JFCPanel) || 305 (parentPanel2 instanceof JFCFrame) || 306 (parentPanel2 instanceof JFCDialog) || 307 (parentPanel2 instanceof JFCCanvas) || 308 (parentPanel2 instanceof JFCMenu) || 309 (parentPanel2 instanceof JFCScrollPane) || 310 (parentPanel2 instanceof JFCSplitPane) || 311 (parentPanel2 instanceof JFCTabbedPane)) 312 { 313 break; 314 } 315 else { 316 parentPanel2 = parentPanel2.getParent(); 317 } 318 } 319 320 // a check for the identity of the objects is sufficient. That they resist on the 321 // same document was checked beforehand. So even a condense of the GUI model should 322 // not cause an invalid result here. 323 if ((parentPanel1 == parentPanel2) || 324 ((parentPanel1 != null) && (parentPanel1.equals(parentPanel2)))) 325 { 326 return DISTANCE_SAME_PANEL; 327 } 328 else { 329 return DISTANCE_SAME_VIEW; 330 } 331 } 332 } 333 334 return DISTANCE_DISTINCT_APPLICATION; 217 335 } 218 336 … … 228 346 } 229 347 348 /** 349 * <p> 350 * convenience method to check if two GUI elements are in the same view. In contrast to other 351 * technologies, JFC GUI views may have other views as children. Hence, it is not sufficient to 352 * check, if the direct parent views are identical. 353 * </p> 354 */ 355 private boolean areInSameView(IGUIElement guiElement1, IGUIElement guiElement2) { 356 IGUIView view1 = guiElement1.getView(); 357 IGUIElement other = guiElement2; 358 359 while (other != null) { 360 if (view1.equals(other.getView())) { 361 return true; 362 } 363 364 other = other.getParent(); 365 } 366 367 // the parent views of the other gui element are checked. But not the ones of this. Hence, 368 // check also them. 369 if ((view1 instanceof JFCView) && (((JFCView) view1).getParent() != null)) { 370 return areInSameView(((JFCView) view1).getParent(), guiElement2); 371 } 372 else { 373 return false; 374 } 375 } 230 376 }
Note: See TracChangeset
for help on using the changeset viewer.