Changeset 2168 for trunk/autoquest-ui-swt/src/main/java/de/ugoe/cs/autoquest/ui/swt/ShowUsabilityEvaluationResultDialog.java
- Timestamp:
- 09/07/17 16:26:46 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-ui-swt/src/main/java/de/ugoe/cs/autoquest/ui/swt/ShowUsabilityEvaluationResultDialog.java
r2047 r2168 19 19 import java.util.ArrayList; 20 20 import java.util.Collection; 21 import java.util.Collections; 21 22 import java.util.HashMap; 22 23 import java.util.LinkedList; … … 37 38 import org.eclipse.swt.layout.GridData; 38 39 import org.eclipse.swt.layout.GridLayout; 40 import org.eclipse.swt.layout.RowLayout; 41 import org.eclipse.swt.widgets.Button; 42 import org.eclipse.swt.widgets.Composite; 43 import org.eclipse.swt.widgets.Control; 39 44 import org.eclipse.swt.widgets.Dialog; 40 45 import org.eclipse.swt.widgets.Display; 41 46 import org.eclipse.swt.widgets.Event; 47 import org.eclipse.swt.widgets.Group; 48 import org.eclipse.swt.widgets.Label; 42 49 import org.eclipse.swt.widgets.Listener; 43 50 import org.eclipse.swt.widgets.Shell; 51 import org.eclipse.swt.widgets.Text; 44 52 import org.eclipse.swt.widgets.Tree; 45 53 import org.eclipse.swt.widgets.TreeColumn; … … 51 59 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 52 60 import de.ugoe.cs.autoquest.usability.UsabilitySmell; 61 import de.ugoe.cs.autoquest.usability.UsabilitySmell.ManualLabel; 53 62 import de.ugoe.cs.autoquest.usability.UsabilitySmellIntensity; 54 63 import de.ugoe.cs.autoquest.usability.UsabilityEvaluationResult; … … 73 82 private StyledText description; 74 83 75 /** the tree of involved GUI elements of a specific task on the right bottom*/84 /** the tree of involved GUI elements of a specific smell on the right */ 76 85 private Tree involvedTargetsTree; 77 86 78 /** the table containing the parents tasks of a displayed task*/87 /** the table containing the involved tasks of a displayed smell */ 79 88 private Tree involvedTasks; 89 90 /** the radio button group for assessing if a smell is true positive or not */ 91 private Group assessmentRadioButtons; 92 93 /** the list of all different tags given for smells */ 94 private List<String> existingTags = new LinkedList<>(); 95 96 /** the parent of all check boxes for tag representation */ 97 private Composite tagCheckBoxParent; 80 98 81 99 /** the displayed usability evaluation result */ … … 96 114 setText("Usability Evaluation Result " + dataSetName); 97 115 this.usabilityEvalResult = usabilityEvalResult; 116 117 for (UsabilitySmell smell : usabilityEvalResult.getAllSmells()) { 118 for (String tag : smell.getTags()) { 119 if (!existingTags.contains(tag)) { 120 existingTags.add(tag); 121 } 122 } 123 } 124 125 Collections.sort(existingTags); 98 126 } 99 127 … … 168 196 } 169 197 }); 170 198 171 199 SashForm detailsSashForm = new SashForm(mainSashForm, SWT.VERTICAL); 172 200 detailsSashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); 173 201 174 description = new StyledText(detailsSashForm, SWT.READ_ONLY | SWT.BORDER | SWT.WRAP); 202 Composite descriptionComposite = new Composite(detailsSashForm, SWT.NONE); 203 descriptionComposite.setLayout(new GridLayout()); 204 205 description = new StyledText(descriptionComposite, SWT.READ_ONLY | SWT.BORDER | SWT.WRAP); 175 206 description.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); 176 207 177 SashForm details BottomSashForm = new SashForm(detailsSashForm, SWT.HORIZONTAL);178 details BottomSashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));208 SashForm detailsTreesSashForm = new SashForm(detailsSashForm, SWT.HORIZONTAL); 209 detailsTreesSashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); 179 210 180 211 involvedTasks = VisualizationUtils.createTaskDetailsTree 181 (details BottomSashForm, "involved tasks", usabilityEvalResult.getTaskModel());212 (detailsTreesSashForm, "involved tasks", usabilityEvalResult.getTaskModel()); 182 213 183 214 VisualizationUtils.addItemSpecificContextMenu … … 198 229 199 230 involvedTargetsTree = 200 VisualizationUtils.createTargetsTree(details BottomSashForm, "involved GUI elements");231 VisualizationUtils.createTargetsTree(detailsTreesSashForm, "involved GUI elements"); 201 232 202 233 VisualizationUtils.addInvolvedTargetsHighlighting(involvedTasks, involvedTargetsTree); 203 234 204 detailsBottomSashForm.setWeights(new int[] { 1, 1 }); 235 final Composite detailsAssessmentComposite = new Composite(descriptionComposite, SWT.NONE); 236 detailsAssessmentComposite.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false, 1, 1)); 237 detailsAssessmentComposite.setLayout(new GridLayout(5, false)); 238 239 assessmentRadioButtons = new Group(detailsAssessmentComposite, SWT.NONE); 240 assessmentRadioButtons.setLayout(new RowLayout(SWT.HORIZONTAL)); 241 242 final Button unassessedRadioButton = new Button(assessmentRadioButtons, SWT.RADIO); 243 unassessedRadioButton.setText("unassessed"); 244 unassessedRadioButton.addSelectionListener(new SelectionAdapter() { 245 @Override 246 public void widgetSelected(SelectionEvent event) { 247 TreeItem[] selectedItems = smellList.getSelection(); 248 if ((selectedItems.length == 1) && 249 (selectedItems[0].getData() instanceof UsabilitySmell)) 250 { 251 UsabilitySmell smell = (UsabilitySmell) selectedItems[0].getData(); 252 if (unassessedRadioButton.getSelection()) { 253 smell.setManualLabel(ManualLabel.UNCHECKED); 254 } 255 } 256 } 257 }); 258 259 final Button falsePositiveRadioButton = new Button(assessmentRadioButtons, SWT.RADIO); 260 falsePositiveRadioButton.setText("false positive"); 261 falsePositiveRadioButton.addSelectionListener(new SelectionAdapter() { 262 @Override 263 public void widgetSelected(SelectionEvent event) { 264 TreeItem[] selectedItems = smellList.getSelection(); 265 if ((selectedItems.length == 1) && 266 (selectedItems[0].getData() instanceof UsabilitySmell)) 267 { 268 UsabilitySmell smell = (UsabilitySmell) selectedItems[0].getData(); 269 if (falsePositiveRadioButton.getSelection()) { 270 smell.setManualLabel(ManualLabel.FALSE_POSITIVE); 271 } 272 } 273 } 274 }); 275 276 final Button truePositiveRadioButton = new Button(assessmentRadioButtons, SWT.RADIO); 277 truePositiveRadioButton.setText("true positive"); 278 truePositiveRadioButton.addSelectionListener(new SelectionAdapter() { 279 @Override 280 public void widgetSelected(SelectionEvent event) { 281 TreeItem[] selectedItems = smellList.getSelection(); 282 if ((selectedItems.length == 1) && 283 (selectedItems[0].getData() instanceof UsabilitySmell)) 284 { 285 UsabilitySmell smell = (UsabilitySmell) selectedItems[0].getData(); 286 if (truePositiveRadioButton.getSelection()) { 287 smell.setManualLabel(ManualLabel.TRUE_POSITIVE); 288 } 289 } 290 } 291 }); 292 293 new Label(detailsAssessmentComposite, SWT.NONE).setText("Tags:"); 294 295 tagCheckBoxParent = new Composite(detailsAssessmentComposite, SWT.NONE); 296 tagCheckBoxParent.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); 297 tagCheckBoxParent.setLayout(new RowLayout()); 298 299 recreateTagsSashForm(); 300 301 final Text addTagField = new Text(detailsAssessmentComposite, SWT.BORDER); 302 addTagField.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); 303 addTagField.setSize(addTagField.computeSize(100, 50)); 304 305 final Button addTagButton = new Button(detailsAssessmentComposite, SWT.NONE); 306 addTagButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); 307 addTagButton.addSelectionListener(new SelectionAdapter() { 308 @Override 309 public void widgetSelected(SelectionEvent e) { 310 String tagName = addTagField.getText(); 311 if ((tagName != null) && (!"".equals(tagName)) && (!existingTags.contains(tagName))) { 312 existingTags.add(tagName); 313 recreateTagsSashForm(); 314 } 315 } 316 }); 317 addTagButton.setText("add tag"); 318 319 detailsTreesSashForm.setWeights(new int[] { 1, 1 }); 205 320 detailsSashForm.setWeights(new int[] { 1, 3 }); 206 321 mainSashForm.setWeights(new int[] { 1, 3 }); … … 210 325 //descriptionColumn.pack(); 211 326 //smellList.pack(); 327 } 328 329 /** 330 * <p> 331 * TODO: comment 332 * </p> 333 * 334 */ 335 private void recreateTagsSashForm() { 336 for (Control child : tagCheckBoxParent.getChildren()) { 337 child.dispose(); 338 } 339 340 if (existingTags.size() > 0) { 341 TreeItem[] selectedItems = smellList.getSelection(); 342 boolean enabled = (selectedItems.length == 1) && 343 (selectedItems[0].getData() instanceof UsabilitySmell); 344 345 for (String existingTag : existingTags) { 346 Button checkBox = new Button(tagCheckBoxParent, SWT.CHECK); 347 checkBox.setText(existingTag); 348 checkBox.addSelectionListener(new SelectionAdapter() { 349 @Override 350 public void widgetSelected(SelectionEvent event) { 351 Button btn = (Button) event.getSource(); 352 353 TreeItem[] selectedItems = smellList.getSelection(); 354 if ((selectedItems.length == 1) && 355 (selectedItems[0].getData() instanceof UsabilitySmell)) 356 { 357 UsabilitySmell smell = (UsabilitySmell) selectedItems[0].getData(); 358 359 if (btn.getSelection()) { 360 smell.addTag(btn.getText()); 361 } 362 else { 363 smell.removeTag(btn.getText()); 364 } 365 } 366 } 367 }); 368 369 checkBox.setEnabled(enabled); 370 if (enabled) { 371 checkBox.setSelection 372 (((UsabilitySmell) selectedItems[0].getData()).getTags().contains(existingTag)); 373 } 374 } 375 } 376 else { 377 new Label(tagCheckBoxParent, SWT.NONE).setText 378 ("no tags added yet --> add using the text field and the button on the right"); 379 } 380 381 tagCheckBoxParent.layout(); 382 tagCheckBoxParent.redraw(); 212 383 } 213 384 … … 247 418 if (!added) { 248 419 smellList.add(smell); 420 } 421 422 // extract the intial list of tags of the smells 423 for (String tag : smell.getTags()) { 424 if (!existingTags.contains(tag)) { 425 existingTags.add(tag); 426 } 249 427 } 250 428 } … … 432 610 involvedTargetsTree.removeAll(); 433 611 involvedTasks.removeAll(); 612 613 for (Control child : assessmentRadioButtons.getChildren()) { 614 if (child instanceof Button) { 615 child.setEnabled(false); 616 ((Button) child).setSelection(false); 617 } 618 } 619 620 for (Control child : tagCheckBoxParent.getChildren()) { 621 if (child instanceof Button) { 622 child.setEnabled(false); 623 ((Button) child).setSelection(false); 624 } 625 } 434 626 } 435 627 … … 494 686 styleRange.font = new Font(description.getDisplay(), "Courier", 12, SWT.NORMAL); 495 687 description.setStyleRange(styleRange); 688 689 assessmentRadioButtons.getChildren()[0].setEnabled(true); 690 ((Button) assessmentRadioButtons.getChildren()[0]).setSelection 691 (smell.getManualLabel() == ManualLabel.UNCHECKED); 692 693 assessmentRadioButtons.getChildren()[1].setEnabled(true); 694 ((Button) assessmentRadioButtons.getChildren()[1]).setSelection 695 (smell.getManualLabel() == ManualLabel.FALSE_POSITIVE); 696 697 assessmentRadioButtons.getChildren()[2].setEnabled(true); 698 ((Button) assessmentRadioButtons.getChildren()[2]).setSelection 699 (smell.getManualLabel() == ManualLabel.TRUE_POSITIVE); 700 701 for (Control child : tagCheckBoxParent.getChildren()) { 702 if (child instanceof Button) { 703 child.setEnabled(true); 704 ((Button) child).setSelection(smell.getTags().contains(((Button) child).getText())); 705 } 706 } 496 707 497 708 List<ITask> involvedTaskList = getInvolvedTasks(smell);
Note: See TracChangeset
for help on using the changeset viewer.