Ignore:
Timestamp:
09/07/17 16:26:46 (7 years ago)
Author:
pharms
Message:
  • changes for first VR oriented usability evaluation
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-ui-swt/src/main/java/de/ugoe/cs/autoquest/ui/swt/ShowUsabilityEvaluationResultDialog.java

    r2047 r2168  
    1919import java.util.ArrayList; 
    2020import java.util.Collection; 
     21import java.util.Collections; 
    2122import java.util.HashMap; 
    2223import java.util.LinkedList; 
     
    3738import org.eclipse.swt.layout.GridData; 
    3839import org.eclipse.swt.layout.GridLayout; 
     40import org.eclipse.swt.layout.RowLayout; 
     41import org.eclipse.swt.widgets.Button; 
     42import org.eclipse.swt.widgets.Composite; 
     43import org.eclipse.swt.widgets.Control; 
    3944import org.eclipse.swt.widgets.Dialog; 
    4045import org.eclipse.swt.widgets.Display; 
    4146import org.eclipse.swt.widgets.Event; 
     47import org.eclipse.swt.widgets.Group; 
     48import org.eclipse.swt.widgets.Label; 
    4249import org.eclipse.swt.widgets.Listener; 
    4350import org.eclipse.swt.widgets.Shell; 
     51import org.eclipse.swt.widgets.Text; 
    4452import org.eclipse.swt.widgets.Tree; 
    4553import org.eclipse.swt.widgets.TreeColumn; 
     
    5159import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
    5260import de.ugoe.cs.autoquest.usability.UsabilitySmell; 
     61import de.ugoe.cs.autoquest.usability.UsabilitySmell.ManualLabel; 
    5362import de.ugoe.cs.autoquest.usability.UsabilitySmellIntensity; 
    5463import de.ugoe.cs.autoquest.usability.UsabilityEvaluationResult; 
     
    7382    private StyledText description; 
    7483     
    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 */ 
    7685    private Tree involvedTargetsTree; 
    7786 
    78     /** the table containing the parents tasks of a displayed task */ 
     87    /** the table containing the involved tasks of a displayed smell */ 
    7988    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; 
    8098 
    8199    /** the displayed usability evaluation result */ 
     
    96114        setText("Usability Evaluation Result " + dataSetName); 
    97115        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); 
    98126    } 
    99127 
     
    168196            } 
    169197        }); 
    170  
     198         
    171199        SashForm detailsSashForm = new SashForm(mainSashForm, SWT.VERTICAL); 
    172200        detailsSashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); 
    173201         
    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); 
    175206        description.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); 
    176207 
    177         SashForm detailsBottomSashForm = new SashForm(detailsSashForm, SWT.HORIZONTAL); 
    178         detailsBottomSashForm.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)); 
    179210         
    180211        involvedTasks = VisualizationUtils.createTaskDetailsTree 
    181             (detailsBottomSashForm, "involved tasks", usabilityEvalResult.getTaskModel()); 
     212            (detailsTreesSashForm, "involved tasks", usabilityEvalResult.getTaskModel()); 
    182213         
    183214        VisualizationUtils.addItemSpecificContextMenu 
     
    198229         
    199230        involvedTargetsTree = 
    200             VisualizationUtils.createTargetsTree(detailsBottomSashForm, "involved GUI elements"); 
     231            VisualizationUtils.createTargetsTree(detailsTreesSashForm, "involved GUI elements"); 
    201232         
    202233        VisualizationUtils.addInvolvedTargetsHighlighting(involvedTasks, involvedTargetsTree); 
    203234         
    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 }); 
    205320        detailsSashForm.setWeights(new int[] { 1, 3 }); 
    206321        mainSashForm.setWeights(new int[] { 1, 3 }); 
     
    210325        //descriptionColumn.pack(); 
    211326        //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(); 
    212383    } 
    213384 
     
    247418            if (!added) { 
    248419                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                } 
    249427            } 
    250428        } 
     
    432610        involvedTargetsTree.removeAll(); 
    433611        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        } 
    434626    } 
    435627 
     
    494686        styleRange.font = new Font(description.getDisplay(), "Courier", 12, SWT.NORMAL); 
    495687        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        } 
    496707         
    497708        List<ITask> involvedTaskList = getInvolvedTasks(smell); 
Note: See TracChangeset for help on using the changeset viewer.