Changeset 1920
- Timestamp:
- 03/12/15 15:52:41 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-ui-swt/src/main/java/de/ugoe/cs/autoquest/ui/swt/ShowUsabilityEvaluationResultDialog.java
r1495 r1920 20 20 import java.util.Collection; 21 21 import java.util.HashMap; 22 import java.util.LinkedList; 22 23 import java.util.List; 23 24 import java.util.Map; … … 48 49 import de.ugoe.cs.autoquest.tasktrees.treeifc.IStructuringTemporalRelationship; 49 50 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 50 import de.ugoe.cs.autoquest.usability.Usability Defect;51 import de.ugoe.cs.autoquest.usability.Usability DefectSeverity;51 import de.ugoe.cs.autoquest.usability.UsabilitySmell; 52 import de.ugoe.cs.autoquest.usability.UsabilitySmellIntensity; 52 53 import de.ugoe.cs.autoquest.usability.UsabilityEvaluationResult; 53 54 … … 55 56 * <p> 56 57 * a dialog to inspect the results of a usability evaluation 58 * TODO update comments 57 59 * </p> 58 60 * … … 64 66 protected Shell shell; 65 67 66 /** the table containing all defects */67 private Tree defectList;68 69 /** the description label of a selected defect*/68 /** the table containing all smells */ 69 private Tree smellList; 70 71 /** the description label of a selected smell */ 70 72 private StyledText description; 71 73 … … 76 78 private Tree involvedTasks; 77 79 78 /** the displayed task model*/80 /** the displayed usability evaluation result */ 79 81 private UsabilityEvaluationResult usabilityEvalResult; 80 82 … … 101 103 showTaskTreeDialog = new ShowTaskTreeDialog 102 104 (super.getParent(), SWT.NONE, usabilityEvalResult.getTaskModel(), 103 "task details of usability defects");105 "task details of usability smells"); 104 106 105 107 createContents(); … … 140 142 mainSashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); 141 143 142 defectList = new Tree(mainSashForm, SWT.BORDER | SWT.SINGLE | SWT.VIRTUAL);143 defectList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));144 defectList.setHeaderVisible(true);145 defectList.setLinesVisible(true);146 147 TreeColumn treeColumn = new TreeColumn( defectList, SWT.NONE);144 smellList = new Tree(mainSashForm, SWT.BORDER | SWT.SINGLE | SWT.VIRTUAL); 145 smellList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); 146 smellList.setHeaderVisible(true); 147 smellList.setLinesVisible(true); 148 149 TreeColumn treeColumn = new TreeColumn(smellList, SWT.NONE); 148 150 treeColumn.setWidth(200); 149 treeColumn.setText(" defects");150 151 build DefectTree();152 153 defectList.addSelectionListener(new SelectionAdapter() {151 treeColumn.setText("smells"); 152 153 buildSmellTree(); 154 155 smellList.addSelectionListener(new SelectionAdapter() { 154 156 @Override 155 157 public void widgetSelected(SelectionEvent e) { 156 TreeItem[] selectedItems = defectList.getSelection();158 TreeItem[] selectedItems = smellList.getSelection(); 157 159 if ((selectedItems.length == 1) && 158 (selectedItems[0].getData() instanceof Usability Defect))160 (selectedItems[0].getData() instanceof UsabilitySmell)) 159 161 { 160 display DefectDetails((UsabilityDefect) selectedItems[0].getData());162 displaySmellDetails((UsabilitySmell) selectedItems[0].getData()); 161 163 } 162 164 else { 163 clear DefectDetails();165 clearSmellDetails(); 164 166 } 165 167 } … … 206 208 //severityColumn.pack(); 207 209 //descriptionColumn.pack(); 208 // defectList.pack();210 //smellList.pack(); 209 211 } 210 212 … … 212 214 * convenience method for creating the display of the instances 213 215 */ 214 private void buildDefectTree() { 215 List<UsabilityDefect> defects = usabilityEvalResult.getAllDefects(); 216 217 final Map<UsabilityDefectSeverity, Map<String, List<UsabilityDefect>>> sortedDefects = 218 new HashMap<UsabilityDefectSeverity, Map<String, List<UsabilityDefect>>>(); 219 sortedDefects.put(UsabilityDefectSeverity.HIGH, 220 new HashMap<String, List<UsabilityDefect>>()); 221 sortedDefects.put(UsabilityDefectSeverity.MEDIUM, 222 new HashMap<String, List<UsabilityDefect>>()); 223 sortedDefects.put(UsabilityDefectSeverity.LOW, 224 new HashMap<String, List<UsabilityDefect>>()); 225 sortedDefects.put(UsabilityDefectSeverity.INFO, 226 new HashMap<String, List<UsabilityDefect>>()); 227 228 for (UsabilityDefect defect : defects) { 229 Map<String, List<UsabilityDefect>> defectMap = sortedDefects.get(defect.getSeverity()); 230 231 List<UsabilityDefect> defectList = defectMap.get(defect.getBriefDescription()); 232 233 if (defectList == null) { 234 defectList = new ArrayList<UsabilityDefect>(); 235 defectMap.put(defect.getBriefDescription(), defectList); 236 } 237 238 defectList.add(defect); 239 } 240 241 if (defectList.getListeners(SWT.Expand).length == 0) { 242 defectList.addListener(SWT.Expand, new Listener() { 216 private void buildSmellTree() { 217 List<UsabilitySmell> smells = usabilityEvalResult.getAllSmells(); 218 219 int[] eventCoverageQuantileGroups = { 990, 975, 950, 0, -1 }; 220 int[] minEventCoverages = new int[eventCoverageQuantileGroups.length]; 221 int[] maxEventCoverages = new int[eventCoverageQuantileGroups.length]; 222 223 final List<Map<String, List<UsabilitySmell>>> sortedSmells = 224 new LinkedList<Map<String, List<UsabilitySmell>>>(); 225 226 for (int i = 0; i < eventCoverageQuantileGroups.length; i++) { 227 sortedSmells.add(new HashMap<String, List<UsabilitySmell>>()); 228 } 229 230 for (UsabilitySmell smell : smells) { 231 int eventCoverageQuantile = smell.getIntensity().getEventCoverageQuantile(); 232 233 for (int i = 0; i < eventCoverageQuantileGroups.length; i++) { 234 if (eventCoverageQuantile >= eventCoverageQuantileGroups[i]) { 235 Map<String, List<UsabilitySmell>> smellMap = sortedSmells.get(i); 236 237 List<UsabilitySmell> smellList = smellMap.get(smell.getBriefDescription()); 238 239 if (smellList == null) { 240 smellList = new ArrayList<UsabilitySmell>(); 241 smellMap.put(smell.getBriefDescription(), smellList); 242 } 243 244 int ratio = smell.getIntensity().getRatio(); 245 int eventCoverage = smell.getIntensity().getEventCoverage(); 246 int index = 0; 247 for (index = 0; index < smellList.size(); index++) { 248 UsabilitySmellIntensity candidate = smellList.get(index).getIntensity(); 249 if ((ratio == candidate.getRatio()) && 250 (eventCoverage > candidate.getEventCoverage())) 251 { 252 break; 253 } 254 else if (ratio > candidate.getRatio()) { 255 break; 256 } 257 } 258 259 smellList.add(index, smell); 260 261 if (minEventCoverages[i] == 0) { 262 minEventCoverages[i] = smell.getIntensity().getEventCoverage(); 263 maxEventCoverages[i] = smell.getIntensity().getEventCoverage(); 264 } 265 else { 266 minEventCoverages[i] = Math.min 267 (minEventCoverages[i], smell.getIntensity().getEventCoverage()); 268 maxEventCoverages[i] = Math.max 269 (maxEventCoverages[i], smell.getIntensity().getEventCoverage()); 270 } 271 272 break; 273 } 274 } 275 } 276 277 if (smellList.getListeners(SWT.Expand).length == 0) { 278 smellList.addListener(SWT.Expand, new Listener() { 243 279 public void handleEvent(final Event event) { 244 280 ensureChildren((TreeItem) event.item); … … 248 284 } 249 285 250 createRootItem("high", sortedDefects.get(UsabilityDefectSeverity.HIGH)); 251 createRootItem("medium", sortedDefects.get(UsabilityDefectSeverity.MEDIUM)); 252 createRootItem("low", sortedDefects.get(UsabilityDefectSeverity.LOW)); 253 createRootItem("info", sortedDefects.get(UsabilityDefectSeverity.INFO)); 286 double taskPercentages = 0; 287 double taskPercentagesCoveredByPreceedingGroups = 0; 288 289 for (int i = 0; i < eventCoverageQuantileGroups.length; i++) { 290 taskPercentages = ((1000 - eventCoverageQuantileGroups[i]) / 10.0) - 291 taskPercentagesCoveredByPreceedingGroups; 292 293 if (eventCoverageQuantileGroups[i] > -1) { 294 createRootItem("smells for " + taskPercentages + "% of tasks covering " + 295 minEventCoverages[i] + " to " + maxEventCoverages[i] + 296 " recorded events", sortedSmells.get(i)); 297 } 298 else { 299 createRootItem("other smells not related to specific tasks", sortedSmells.get(i)); 300 301 } 302 303 taskPercentagesCoveredByPreceedingGroups += taskPercentages; 304 } 305 254 306 } 255 307 … … 257 309 * 258 310 */ 259 private void createRootItem(String name, Map<String, List<Usability Defect>> defects) {260 TreeItem defectItem = new TreeItem(defectList, SWT.NULL);311 private void createRootItem(String name, Map<String, List<UsabilitySmell>> smells) { 312 TreeItem smellItem = new TreeItem(smellList, SWT.NULL); 261 313 262 314 int count = 0; 263 for (Map.Entry<String, List<Usability Defect>> entry : defects.entrySet()) {315 for (Map.Entry<String, List<UsabilitySmell>> entry : smells.entrySet()) { 264 316 count += entry.getValue().size(); 265 317 } 266 318 267 defectItem.setText(name + " severity (" + count + " defects)");268 defectItem.setData(defects);319 smellItem.setText(name + " (" + count + " smells)"); 320 smellItem.setData(smells); 269 321 270 322 if (count > 0) { 271 323 // simulate a child 272 new TreeItem( defectItem, SWT.NULL);324 new TreeItem(smellItem, SWT.NULL); 273 325 } 274 326 } … … 277 329 * 278 330 */ 279 private void clear DefectDetails() {331 private void clearSmellDetails() { 280 332 description.setText(""); 281 333 involvedTargetsTree.removeAll(); … … 286 338 * 287 339 */ 288 private void display DefectDetails(UsabilityDefect defect) {289 clear DefectDetails();340 private void displaySmellDetails(UsabilitySmell smell) { 341 clearSmellDetails(); 290 342 291 343 FontData data = description.getFont().getFontData()[0]; … … 297 349 (description.getDisplay(), data.getName(), height, data.getStyle() | SWT.BOLD); 298 350 299 for (Object fragment : defect.getDescriptionFragments()) {351 for (Object fragment : smell.getDescriptionFragments()) { 300 352 int color; 301 353 Font font; … … 310 362 } 311 363 312 StyleRange styleRange = new StyleRange 313 (description.getText().length(), fragment.toString().length(), 314 description.getDisplay().getSystemColor(color), null); 315 316 styleRange.font = font; 364 int initialLength = description.getText().length(); 317 365 318 366 if (fragment instanceof Collection<?>) { … … 328 376 description.append(fragment.toString()); 329 377 } 378 379 StyleRange styleRange = new StyleRange 380 (initialLength, description.getText().length() - initialLength, 381 description.getDisplay().getSystemColor(color), null); 382 383 styleRange.font = font; 384 330 385 description.setStyleRange(styleRange); 331 386 description.append(" "); … … 341 396 description.setStyleRange(styleRange); 342 397 343 List<ITask> involvedTaskList = getInvolvedTasks( defect);398 List<ITask> involvedTaskList = getInvolvedTasks(smell); 344 399 for (ITask involvedTask : involvedTaskList) { 345 400 VisualizationUtils.createTreeItemFor … … 347 402 } 348 403 349 List<IEventTarget> involvedTargets = getInvolvedTargets( defect);404 List<IEventTarget> involvedTargets = getInvolvedTargets(smell); 350 405 if (involvedTargets.size() <= 0) { 351 406 for (ITask involvedTask : involvedTaskList) { … … 380 435 if (parent.getData() instanceof Map<?, ?>) { 381 436 @SuppressWarnings("unchecked") 382 Map<String, List<Usability Defect>> map =383 (Map<String, List<Usability Defect>>) parent.getData();384 385 for (Map.Entry<String, List<Usability Defect>> entry : map.entrySet()) {437 Map<String, List<UsabilitySmell>> map = 438 (Map<String, List<UsabilitySmell>>) parent.getData(); 439 440 for (Map.Entry<String, List<UsabilitySmell>> entry : map.entrySet()) { 386 441 TreeItem child = new TreeItem(parent, SWT.NULL); 387 child.setText(entry.getKey() + " (" + entry.getValue().size() + " defects)");442 child.setText(entry.getKey() + " (" + entry.getValue().size() + " smells)"); 388 443 child.setData(entry); 389 444 … … 396 451 else if (parent.getData() instanceof Map.Entry<?, ?>) { 397 452 @SuppressWarnings("unchecked") 398 Map.Entry<String, List<Usability Defect>> entry =399 (Map.Entry<String, List<Usability Defect>>) parent.getData();453 Map.Entry<String, List<UsabilitySmell>> entry = 454 (Map.Entry<String, List<UsabilitySmell>>) parent.getData(); 400 455 401 456 int count = 0; 402 for (Usability Defect defect: entry.getValue()) {457 for (UsabilitySmell smell : entry.getValue()) { 403 458 TreeItem child = new TreeItem(parent, SWT.NULL); 404 child.setData(defect); 405 child.setText("defect " + ++count); 459 child.setData(smell); 460 child.setText(++count + ": ratio = " + smell.getIntensity().getRatio() + 461 ", covered events = " + smell.getIntensity().getEventCoverage()); 406 462 } 407 463 } … … 426 482 * 427 483 */ 428 private List<ITask> getInvolvedTasks(Usability Defect defect) {429 List<Object> fragments = defect.getDescriptionFragments();484 private List<ITask> getInvolvedTasks(UsabilitySmell smell) { 485 List<Object> fragments = smell.getDescriptionFragments(); 430 486 List<ITask> involvedTasks = new ArrayList<ITask>(); 431 487 … … 442 498 * 443 499 */ 444 private List<IEventTarget> getInvolvedTargets(Usability Defect defect) {445 List<Object> fragments = defect.getDescriptionFragments();500 private List<IEventTarget> getInvolvedTargets(UsabilitySmell smell) { 501 List<Object> fragments = smell.getDescriptionFragments(); 446 502 List<IEventTarget> involvedTargets = new ArrayList<IEventTarget>(); 447 503
Note: See TracChangeset
for help on using the changeset viewer.