Ignore:
Timestamp:
03/12/15 15:52:41 (10 years ago)
Author:
pharms
Message:
  • extension with further smell detections
  • may not fully work. But Hudson is more happy because compile errors should be gone
File:
1 edited

Legend:

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

    r1495 r1920  
    2020import java.util.Collection; 
    2121import java.util.HashMap; 
     22import java.util.LinkedList; 
    2223import java.util.List; 
    2324import java.util.Map; 
     
    4849import de.ugoe.cs.autoquest.tasktrees.treeifc.IStructuringTemporalRelationship; 
    4950import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
    50 import de.ugoe.cs.autoquest.usability.UsabilityDefect; 
    51 import de.ugoe.cs.autoquest.usability.UsabilityDefectSeverity; 
     51import de.ugoe.cs.autoquest.usability.UsabilitySmell; 
     52import de.ugoe.cs.autoquest.usability.UsabilitySmellIntensity; 
    5253import de.ugoe.cs.autoquest.usability.UsabilityEvaluationResult; 
    5354 
     
    5556 * <p> 
    5657 * a dialog to inspect the results of a usability evaluation 
     58 * TODO update comments 
    5759 * </p> 
    5860 *  
     
    6466    protected Shell shell; 
    6567 
    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 */ 
    7072    private StyledText description; 
    7173     
     
    7678    private Tree involvedTasks; 
    7779 
    78     /** the displayed task model */ 
     80    /** the displayed usability evaluation result */ 
    7981    private UsabilityEvaluationResult usabilityEvalResult; 
    8082     
     
    101103        showTaskTreeDialog = new ShowTaskTreeDialog 
    102104            (super.getParent(), SWT.NONE, usabilityEvalResult.getTaskModel(), 
    103              "task details of usability defects"); 
     105             "task details of usability smells"); 
    104106 
    105107        createContents(); 
     
    140142        mainSashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); 
    141143         
    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); 
    148150        treeColumn.setWidth(200); 
    149         treeColumn.setText("defects"); 
    150  
    151         buildDefectTree(); 
    152          
    153         defectList.addSelectionListener(new SelectionAdapter() { 
     151        treeColumn.setText("smells"); 
     152 
     153        buildSmellTree(); 
     154         
     155        smellList.addSelectionListener(new SelectionAdapter() { 
    154156            @Override 
    155157            public void widgetSelected(SelectionEvent e) { 
    156                 TreeItem[] selectedItems = defectList.getSelection(); 
     158                TreeItem[] selectedItems = smellList.getSelection(); 
    157159                if ((selectedItems.length == 1) && 
    158                     (selectedItems[0].getData() instanceof UsabilityDefect)) 
     160                    (selectedItems[0].getData() instanceof UsabilitySmell)) 
    159161                { 
    160                     displayDefectDetails((UsabilityDefect) selectedItems[0].getData()); 
     162                    displaySmellDetails((UsabilitySmell) selectedItems[0].getData()); 
    161163                } 
    162164                else { 
    163                     clearDefectDetails(); 
     165                    clearSmellDetails(); 
    164166                } 
    165167            } 
     
    206208        //severityColumn.pack(); 
    207209        //descriptionColumn.pack(); 
    208         //defectList.pack(); 
     210        //smellList.pack(); 
    209211    } 
    210212 
     
    212214     * convenience method for creating the display of the instances 
    213215     */ 
    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() { 
    243279               public void handleEvent(final Event event) { 
    244280                   ensureChildren((TreeItem) event.item); 
     
    248284        } 
    249285 
    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         
    254306    } 
    255307 
     
    257309     *  
    258310     */ 
    259     private void createRootItem(String name, Map<String, List<UsabilityDefect>> 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); 
    261313         
    262314        int count = 0; 
    263         for (Map.Entry<String, List<UsabilityDefect>> entry : defects.entrySet()) { 
     315        for (Map.Entry<String, List<UsabilitySmell>> entry : smells.entrySet()) { 
    264316            count += entry.getValue().size(); 
    265317        } 
    266318 
    267         defectItem.setText(name + " severity (" + count + " defects)"); 
    268         defectItem.setData(defects); 
     319        smellItem.setText(name + " (" + count + " smells)"); 
     320        smellItem.setData(smells); 
    269321         
    270322        if (count > 0) { 
    271323            // simulate a child 
    272             new TreeItem(defectItem, SWT.NULL); 
     324            new TreeItem(smellItem, SWT.NULL); 
    273325        } 
    274326    } 
     
    277329     * 
    278330     */ 
    279     private void clearDefectDetails() { 
     331    private void clearSmellDetails() { 
    280332        description.setText(""); 
    281333        involvedTargetsTree.removeAll(); 
     
    286338     * 
    287339     */ 
    288     private void displayDefectDetails(UsabilityDefect defect) { 
    289         clearDefectDetails(); 
     340    private void displaySmellDetails(UsabilitySmell smell) { 
     341        clearSmellDetails(); 
    290342         
    291343        FontData data = description.getFont().getFontData()[0]; 
     
    297349            (description.getDisplay(), data.getName(), height, data.getStyle() | SWT.BOLD); 
    298350         
    299         for (Object fragment : defect.getDescriptionFragments()) { 
     351        for (Object fragment : smell.getDescriptionFragments()) { 
    300352            int color; 
    301353            Font font; 
     
    310362            } 
    311363             
    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(); 
    317365             
    318366            if (fragment instanceof Collection<?>) { 
     
    328376                description.append(fragment.toString()); 
    329377            } 
     378             
     379            StyleRange styleRange = new StyleRange 
     380                (initialLength, description.getText().length() - initialLength, 
     381                 description.getDisplay().getSystemColor(color), null); 
     382 
     383            styleRange.font = font; 
     384                 
    330385            description.setStyleRange(styleRange); 
    331386            description.append(" "); 
     
    341396        description.setStyleRange(styleRange); 
    342397         
    343         List<ITask> involvedTaskList = getInvolvedTasks(defect); 
     398        List<ITask> involvedTaskList = getInvolvedTasks(smell); 
    344399        for (ITask involvedTask : involvedTaskList) { 
    345400            VisualizationUtils.createTreeItemFor 
     
    347402        } 
    348403         
    349         List<IEventTarget> involvedTargets = getInvolvedTargets(defect); 
     404        List<IEventTarget> involvedTargets = getInvolvedTargets(smell); 
    350405        if (involvedTargets.size() <= 0) { 
    351406            for (ITask involvedTask : involvedTaskList) { 
     
    380435        if (parent.getData() instanceof Map<?, ?>) { 
    381436            @SuppressWarnings("unchecked") 
    382             Map<String, List<UsabilityDefect>> map = 
    383                 (Map<String, List<UsabilityDefect>>) parent.getData(); 
    384              
    385             for (Map.Entry<String, List<UsabilityDefect>> 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()) { 
    386441                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)"); 
    388443                child.setData(entry); 
    389444                 
     
    396451        else if (parent.getData() instanceof Map.Entry<?, ?>) { 
    397452            @SuppressWarnings("unchecked") 
    398             Map.Entry<String, List<UsabilityDefect>> entry = 
    399                 (Map.Entry<String, List<UsabilityDefect>>) parent.getData(); 
     453            Map.Entry<String, List<UsabilitySmell>> entry = 
     454                (Map.Entry<String, List<UsabilitySmell>>) parent.getData(); 
    400455             
    401456            int count = 0; 
    402             for (UsabilityDefect defect : entry.getValue()) { 
     457            for (UsabilitySmell smell : entry.getValue()) { 
    403458                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()); 
    406462            } 
    407463        } 
     
    426482     * 
    427483     */ 
    428     private List<ITask> getInvolvedTasks(UsabilityDefect defect) { 
    429         List<Object> fragments = defect.getDescriptionFragments(); 
     484    private List<ITask> getInvolvedTasks(UsabilitySmell smell) { 
     485        List<Object> fragments = smell.getDescriptionFragments(); 
    430486        List<ITask> involvedTasks = new ArrayList<ITask>(); 
    431487         
     
    442498     * 
    443499     */ 
    444     private List<IEventTarget> getInvolvedTargets(UsabilityDefect defect) { 
    445         List<Object> fragments = defect.getDescriptionFragments(); 
     500    private List<IEventTarget> getInvolvedTargets(UsabilitySmell smell) { 
     501        List<Object> fragments = smell.getDescriptionFragments(); 
    446502        List<IEventTarget> involvedTargets = new ArrayList<IEventTarget>(); 
    447503         
Note: See TracChangeset for help on using the changeset viewer.