Search in sources :

Example 1 with ModelType

use of teamdash.merge.ModelType in project processdash by dtuma.

the class WBSModelMergeConflictNotificationFactory method refineAttributeNotification.

private static boolean refineAttributeNotification(MergeConflictNotification mcn, DataModelSource dms) {
    if (!(mcn.getMergeWarning() instanceof AttributeMergeWarning))
        return false;
    ModelType modelType = mcn.getModelType();
    AttributeMergeWarning amw = (AttributeMergeWarning) mcn.getMergeWarning();
    DataTableModel dataModel = dms.getDataModel(modelType);
    ConflictCapableDataColumn column = findColumnForAttribute(dataModel, amw.getAttributeName());
    if (column == null)
        return false;
    String columnId = column.getColumnID().replace(' ', '_');
    mcn.putAttribute(COLUMN_ID, columnId);
    mcn.putAttribute(COLUMN_NAME, column.getColumnName());
    String explicitMessageKey = modelType.name() + ".Attribute." + columnId;
    String nullDisplay;
    try {
        nullDisplay = resources.getHTML(explicitMessageKey + ".Blank");
    } catch (MissingResourceException mre) {
        nullDisplay = resources.getHTML("WBSNode_Attribute.Blank");
    }
    WBSNode baseNode = mcn.getAttribute(MergeConflictNotification.BASE_NODE);
    String baseValue = (String) amw.getBaseValue();
    Object baseDisp = (//
    baseNode == null ? //
    baseValue : column.getConflictDisplayValue(baseValue, baseNode));
    if (baseDisp == null)
        baseDisp = nullDisplay;
    WBSNode mainNode = mcn.getAttribute(MergeConflictNotification.MAIN_NODE);
    String mainValue = (String) amw.getMainValue();
    Object mainDisp = (//
    mainNode == null ? //
    mainValue : column.getConflictDisplayValue(mainValue, mainNode));
    if (mainDisp == null)
        mainDisp = nullDisplay;
    WBSNode incNode = mcn.getAttribute(MergeConflictNotification.INCOMING_NODE);
    String incValue = (String) amw.getIncomingValue();
    Object incDisp = (//
    incNode == null ? //
    incValue : column.getConflictDisplayValue(incValue, incNode));
    if (incDisp == null)
        incDisp = nullDisplay;
    mcn.putValueAttributes(baseDisp, mainDisp, incDisp);
    boolean supportsOverride;
    if (MergeConflictNotification.definesDescription(explicitMessageKey)) {
        // this column has explicitly defined a message it wants to
        // display, so we will use that message.
        mcn.setMessageKey(explicitMessageKey);
        // see if this column has defined a message for the
        // 'override' option.
        supportsOverride = mcn.definesMessageForUserOption(MergeConflictNotification.OVERRIDE);
    } else {
        // use a generic message.
        mcn.setMessageKey("WBSNode_Attribute");
        supportsOverride = true;
    }
    // Add "accept" as an option that is always present
    mcn.addUserOption(MergeConflictNotification.ACCEPT, null);
    // Add an "alter" option if it is supported
    if (supportsOverride)
        mcn.addUserOption(MergeConflictNotification.OVERRIDE, new WbsNodeAttributeHandler(dataModel, column));
    // give the column a final chance to tweak the configuration
    column.adjustConflictNotification(mcn);
    return true;
}
Also used : MissingResourceException(java.util.MissingResourceException) ModelType(teamdash.merge.ModelType) AttributeMergeWarning(teamdash.merge.AttributeMergeWarning)

Example 2 with ModelType

use of teamdash.merge.ModelType in project processdash by dtuma.

the class WBSModelMergeConflictNotificationFactory method createAll.

public static List<MergeConflictNotification> createAll(AbstractWBSModelMerger<? extends WBSModel> merger) {
    List<MergeConflictNotification> result = new ArrayList();
    ModelType modelType = merger.getModelType();
    Map<Integer, WBSNode> baseNodeMap = merger.base.getNodeMap();
    Map<Integer, WBSNode> mainNodeMap = merger.main.getNodeMap();
    Map<Integer, WBSNode> incomingNodeMap = merger.incoming.getNodeMap();
    for (MergeWarning<Integer> warning : merger.getMergeWarnings()) {
        MergeConflictNotification notification = create(merger, modelType, baseNodeMap, mainNodeMap, incomingNodeMap, warning);
        if (notification != null)
            result.add(notification);
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) MergeConflictNotification(teamdash.merge.ui.MergeConflictNotification) ModelType(teamdash.merge.ModelType)

Example 3 with ModelType

use of teamdash.merge.ModelType in project processdash by dtuma.

the class BlameModelData method findNextAnnotation.

public BlameCaretPos findNextAnnotation(List<WBSNode> wbsNodes, List<String> columns, BlameCaretPos currentCaret, boolean searchForward, boolean searchByColumns) {
    if (isEmpty())
        return null;
    int nodePos = findNodePos(wbsNodes, currentCaret, searchForward, searchByColumns);
    int columnPos = findColumnPos(columns, currentCaret, searchForward, searchByColumns);
    int increment = searchForward ? +1 : -1;
    while (true) {
        if (searchByColumns) {
            // search forward/backward for the next node.
            nodePos += increment;
            // to another column.
            if (outOfRange(wbsNodes, nodePos)) {
                nodePos = wrapPos(wbsNodes, nodePos);
                columnPos += increment;
                // If we run off the end of the column list, return null.
                if (outOfRange(columns, columnPos))
                    return null;
            }
        } else {
            // search forward/backward for the next column.
            columnPos += increment;
            // to another node.
            if (outOfRange(columns, columnPos)) {
                columnPos = wrapPos(columns, columnPos);
                nodePos += increment;
                // if we run off the end of the node list, return null.
                if (outOfRange(wbsNodes, nodePos))
                    return null;
            }
        }
        String columnID = columns.get(columnPos);
        int nodeID = wbsNodes.get(nodePos).getTreeNodeID();
        BlameNodeData nodeData = get(nodeID);
        if (nodeData != null && nodeData.isColumnAffected(columnID)) {
            ModelType type = wbsNodes.get(0).getWbsModel().getModelType();
            return new BlameCaretPos(type, Collections.singletonList(nodeID), Collections.singletonList(columnID));
        }
    }
}
Also used : ModelType(teamdash.merge.ModelType)

Example 4 with ModelType

use of teamdash.merge.ModelType in project processdash by dtuma.

the class BlameHistoryDialog method setBlameComments.

private boolean setBlameComments(BlameCaretPos caretPos) {
    breadcrumb.clear();
    blameChanges.clearRows();
    dataProblems.setCurrentNode(null);
    rejectAction.setEnabled(false);
    if (caretPos == null || blameData == null)
        return false;
    if (!caretPos.isSingleCell()) {
        int numChanges = blameData.countAnnotations(caretPos);
        String message = resources.format("Message.Multiple_FMT", numChanges);
        blameChanges.showMessage(message);
        return numChanges > 0;
    }
    ModelType modelType = caretPos.getModelType();
    BlameModelData modelData = blameData.get(modelType);
    if (modelData == null)
        return false;
    Integer nodeID = caretPos.getSingleNode();
    BlameNodeData nodeData = modelData.get(nodeID);
    if (nodeData == null)
        return false;
    WBSNode node = wbsDataModel.getWBSModel().getNodeMap().get(nodeID);
    String nodePath = (node == null ? null : node.getFullName());
    String columnID = caretPos.getSingleColumn();
    if (WBSNodeColumn.COLUMN_ID.equals(columnID)) {
        breadcrumb.setPath(nodePath, null);
        blameChanges.setBlameNodeStructure(nodeData);
        dataProblems.setCurrentNode(nodeID);
        rejectAction.setEnabled(true);
        return nodeData.hasStructuralChange();
    }
    if (nodeData.getAttributes() == null)
        return false;
    for (BlameValueList val : nodeData.getAttributes().values()) {
        if (val.columnMatches(columnID)) {
            int col = wbsDataModel.findColumn(columnID);
            String columnName = wbsDataModel.getColumnName(col);
            breadcrumb.setPath(nodePath, columnName);
            blameChanges.setBlameValueList(val);
            dataProblems.setCurrentNode(nodeID);
            rejectAction.setEnabled(true);
            return true;
        }
    }
    return false;
}
Also used : BlameNodeData(teamdash.hist.BlameNodeData) BlameModelData(teamdash.hist.BlameModelData) BlameValueList(teamdash.hist.BlameValueList) ModelType(teamdash.merge.ModelType) WBSNode(teamdash.wbs.WBSNode)

Aggregations

ModelType (teamdash.merge.ModelType)4 ArrayList (java.util.ArrayList)1 MissingResourceException (java.util.MissingResourceException)1 BlameModelData (teamdash.hist.BlameModelData)1 BlameNodeData (teamdash.hist.BlameNodeData)1 BlameValueList (teamdash.hist.BlameValueList)1 AttributeMergeWarning (teamdash.merge.AttributeMergeWarning)1 MergeConflictNotification (teamdash.merge.ui.MergeConflictNotification)1 WBSNode (teamdash.wbs.WBSNode)1