Search in sources :

Example 1 with DefectPhase

use of net.sourceforge.processdash.log.defects.DefectPhase in project processdash by dtuma.

the class BoundDefectData method bindMappers.

private void bindMappers() {
    // configure objects that translate values in various defect fields
    PropertyChangeListener l = new PropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent evt) {
            updateMapper(evt);
        }
    };
    mapperIDs = new String[ATTRS.length];
    for (int i = 0; i < mapperIDs.length; i++) {
        String mapperId = getMapperId(i);
        mapperIDs[i] = mapperId;
        form.addPropertyChangeListener(mapperId, l);
        setStringMapper(i, (StringMapper) form.get(mapperId));
    }
    // configure the object that translates strings to phases
    setPhaseLookup((PhaseLookup) form.get(DefectPhaseMapper.PHASE_LOOKUP_ID));
    // register the default injection phase, and follow future changes
    l = new PropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent evt) {
            Object phase = form.get(DefaultPhaseSelector.INJ_PHASE_ID);
            setDefaultInjectedPhase((DefectPhase) phase);
        }
    };
    form.addPropertyChangeListener(DefaultPhaseSelector.INJ_PHASE_ID, l);
    l.propertyChange(null);
    // register the default removal phase, and follow future changes
    l = new PropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent evt) {
            Object phase = form.get(DefaultPhaseSelector.REM_PHASE_ID);
            setDefaultRemovedPhase((DefectPhase) phase);
        }
    };
    form.addPropertyChangeListener(DefaultPhaseSelector.REM_PHASE_ID, l);
    l.propertyChange(null);
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) DefectPhase(net.sourceforge.processdash.log.defects.DefectPhase)

Example 2 with DefectPhase

use of net.sourceforge.processdash.log.defects.DefectPhase in project processdash by dtuma.

the class DefectDialog method phaseComboSelect.

public static void phaseComboSelect(JComboBox cb, DefectPhase target) {
    if (target == null)
        return;
    if (target.phaseID != null) {
        // try to match the phase by exact ID
        for (int i = cb.getItemCount(); i-- > 0; ) {
            DefectPhase onePhase = (DefectPhase) cb.getItemAt(i);
            if (onePhase.phaseID != null && onePhase.phaseID.equals(target.phaseID)) {
                cb.setSelectedIndex(i);
                return;
            }
        }
        // next try to match the phase by trailing ID
        for (int i = cb.getItemCount(); i-- > 0; ) {
            DefectPhase onePhase = (DefectPhase) cb.getItemAt(i);
            if (onePhase.phaseID != null && onePhase.phaseID.endsWith(target.phaseID)) {
                cb.setSelectedIndex(i);
                return;
            }
        }
        // next try to match by workflow and phase name
        for (int i = cb.getItemCount(); i-- > 0; ) {
            DefectPhase onePhase = (DefectPhase) cb.getItemAt(i);
            if (onePhase.phaseID != null && onePhase.processName != null && onePhase.phaseName != null && onePhase.processName.equals(target.processName) && onePhase.phaseName.equals(target.phaseName)) {
                cb.setSelectedIndex(i);
                return;
            }
        }
    } else {
        // try to match by legacy phase
        for (int i = cb.getItemCount(); i-- > 0; ) {
            DefectPhase onePhase = (DefectPhase) cb.getItemAt(i);
            if (onePhase.phaseID == null && onePhase.legacyPhase.equals(target.legacyPhase)) {
                cb.setSelectedIndex(i);
                return;
            }
        }
    }
    // fallback: add the item to the list and select it.
    int insPos = 0;
    if (cb.getItemCount() > 0)
        if (cb.getItemAt(0) == BEFORE_DEVELOPMENT || cb.getItemAt(0) == Defect.UNSPECIFIED_PHASE)
            insPos = 1;
    cb.insertItemAt(target, insPos);
    cb.setSelectedItem(target);
}
Also used : DefectPhase(net.sourceforge.processdash.log.defects.DefectPhase)

Example 3 with DefectPhase

use of net.sourceforge.processdash.log.defects.DefectPhase in project processdash by dtuma.

the class DefectDialog method checkSequence.

/** Check to see if the removal phase is before the injection phase.
     *
     * If they are out of order, display an error message to the user and
     * return false; otherwise return true.
     */
private boolean checkSequence() {
    if ("false".equalsIgnoreCase(Settings.getVal("defectDialog.restrictSequence")))
        return true;
    // retrieve the phases the defect was injected and removed.
    DefectPhase injected = (DefectPhase) phase_injected.getSelectedItem();
    DefectPhase removed = (DefectPhase) phase_removed.getSelectedItem();
    if (injected == removed)
        return true;
    // in any meaningful way.
    if (!NullSafeObjectUtils.EQ(injected.processName, removed.processName))
        return true;
    if (injected.phaseID != null) {
        // if the phases came from a workflow, retrieve the rich phase data
        // from the WorkflowInfo object.
        Phase injPhase = getWorkflowInfoPhase(injected);
        Phase remPhase = getWorkflowInfoPhase(removed);
        if (injPhase == null || remPhase == null)
            return true;
        // compare the positions of the phases within the workflow
        List<Phase> phases = injPhase.getWorkflow().getPhases();
        int injPos = phases.indexOf(injPhase);
        int remPos = phases.indexOf(remPhase);
        // after all, and we can't compare them in any meaningful way.
        if (injPos == -1 || remPos == -1)
            return true;
        // if the injection phase precedes the removal phase, it's good
        if (injPos <= remPos)
            return true;
        // case by comparing the legacy process phases.
        if (!injPhase.isPspPhase() && remPhase.isPspPhase()) {
            injPos = getLegacyPhasePos(injPhase);
            remPos = getLegacyPhasePos(remPhase);
            if (injPos <= remPos || injPos == -1 || remPos == -1)
                return true;
        }
    } else {
        // if the phases are legacy process phases, compare their positions
        // within the process.
        int injPos = processPhases.indexOf(injected);
        int remPos = processPhases.indexOf(removed);
        if (injPos == -1 || remPos == -1)
            return true;
        // if the injection phase precedes the removal phase, it's good
        if (injPos <= remPos)
            return true;
    }
    JOptionPane.showMessageDialog(this, resources.getStrings("Sequence_Error_Message"), resources.getString("Sequence_Error_Title"), JOptionPane.ERROR_MESSAGE);
    return false;
}
Also used : DefectPhase(net.sourceforge.processdash.log.defects.DefectPhase) Phase(net.sourceforge.processdash.process.WorkflowInfo.Phase) DefectPhase(net.sourceforge.processdash.log.defects.DefectPhase)

Example 4 with DefectPhase

use of net.sourceforge.processdash.log.defects.DefectPhase in project processdash by dtuma.

the class MorePhaseOptionsHandler method showMorePhasesDialog.

private DefectPhase showMorePhasesDialog(JComboBox cb) {
    if (phaseOptionsTree == null)
        phaseOptionsTree = buildTree();
    // display a dialog to the user prompting for a phase selection
    String title = resources.getString("More_Options.Window_Title");
    String prompt = resources.getString("More_Options." + (isInjected ? "Injected" : "Removed") + "_Prompt");
    Object[] message = new Object[] { prompt, new JScrollPane(phaseOptionsTree), new JOptionPaneTweaker.GrabFocus(phaseOptionsTree) };
    setSelectedPhase();
    int userChoice = JOptionPane.showConfirmDialog(SwingUtilities.getWindowAncestor(cb), message, title, JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null);
    if (userChoice != JOptionPane.OK_OPTION)
        return null;
    // Return the phase object selected by the user
    TreePath selPath = phaseOptionsTree.getSelectionPath();
    if (selPath == null)
        return null;
    DefaultMutableTreeNode selNode = (DefaultMutableTreeNode) selPath.getLastPathComponent();
    Object selItem = selNode.getUserObject();
    if (selItem instanceof DefectPhase)
        return (DefectPhase) selItem;
    else
        return null;
}
Also used : JScrollPane(javax.swing.JScrollPane) TreePath(javax.swing.tree.TreePath) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) DefectPhase(net.sourceforge.processdash.log.defects.DefectPhase)

Example 5 with DefectPhase

use of net.sourceforge.processdash.log.defects.DefectPhase in project processdash by dtuma.

the class DefectDialog method openFixDefectDialog.

private void openFixDefectDialog() {
    if (defectNumber == null) {
        save();
        setDirty(true);
        saveDialogInCache();
        autoCreated = true;
    }
    DefectDialog d = new DefectDialog(parent, defectFilename, defectPath, taskPath);
    d.fix_defect.setText(defectNumber);
    DefectPhase p = (DefectPhase) phase_removed.getSelectedItem();
    phaseComboSelect(d.phase_injected, p);
    phaseComboSelect(d.phase_removed, p);
    d.setDirty(false);
}
Also used : DefectPhase(net.sourceforge.processdash.log.defects.DefectPhase)

Aggregations

DefectPhase (net.sourceforge.processdash.log.defects.DefectPhase)11 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)3 JComboBox (javax.swing.JComboBox)2 Phase (net.sourceforge.processdash.process.WorkflowInfo.Phase)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 JScrollPane (javax.swing.JScrollPane)1 JTree (javax.swing.JTree)1 TreeNode (javax.swing.tree.TreeNode)1 TreePath (javax.swing.tree.TreePath)1 Workflow (net.sourceforge.processdash.process.WorkflowInfo.Workflow)1 JOptionPaneClickHandler (net.sourceforge.processdash.ui.lib.JOptionPaneClickHandler)1