Search in sources :

Example 1 with NumericDataValue

use of teamdash.wbs.NumericDataValue in project processdash by dtuma.

the class EditableSizeColumn method getValueAt.

public Object getValueAt(WBSNode node) {
    NumericDataValue value = (NumericDataValue) dataModel.getValueAt(node, newChangedColumn);
    if (value != null && value.isEditable)
        return value;
    if (SizeTypeColumn.getWorkProductSizeMetric(node, sizeMetricsMap) != null)
        return value;
    double number = node.getNumericAttribute(ATTR_NAME);
    if (!Double.isNaN(number))
        return new NumericDataValue(number);
    else
        return new NumericDataValue(0, true, true, null);
}
Also used : NumericDataValue(teamdash.wbs.NumericDataValue)

Example 2 with NumericDataValue

use of teamdash.wbs.NumericDataValue in project processdash by dtuma.

the class WorkflowTableCellRenderer method getTableCellRendererComponent.

@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    if (value instanceof NumericDataValue)
        value = tweakNumericValue((NumericDataValue) value, table, row);
    Component result;
    if (delegate == null)
        result = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
    else
        result = delegate.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
    if (!table.isCellEditable(row, column))
        result.setBackground(isSelected ? UNEDITABLE_SELECTED : UNEDITABLE);
    else if (isSelected)
        result.setBackground(table.getSelectionBackground());
    else
        result.setBackground(table.getBackground());
    return result;
}
Also used : NumericDataValue(teamdash.wbs.NumericDataValue) Component(java.awt.Component)

Example 3 with NumericDataValue

use of teamdash.wbs.NumericDataValue in project processdash by dtuma.

the class TaskSizeColumn method getValueAt.

public Object getValueAt(WBSNode node) {
    if (isCustomTaskSize(node)) {
        double miscSize = node.getNumericAttribute(ATTR_NAME);
        if (Double.isNaN(miscSize))
            return null;
        else
            return new NumericDataValue(miscSize);
    }
    Object result = super.getValueAt(node);
    if (result instanceof NumericDataValue && result != BLANK) {
        NumericDataValue ndv = (NumericDataValue) result;
        boolean editable = ndv.isEditable || canEditTaskSizeUnits(node);
        String error = ndv.errorMessage;
        if (error == null && editable && !ndv.isEditable)
            error = INHERITED_SIZE_MESSAGE;
        result = new NumericDataValue(ndv.value, editable, false, error, ndv.expectedValue);
    }
    return result;
}
Also used : NumericDataValue(teamdash.wbs.NumericDataValue)

Example 4 with NumericDataValue

use of teamdash.wbs.NumericDataValue in project processdash by dtuma.

the class WBSExcelWriter method copyCellData.

private void copyCellData(HSSFCell cell, TableCellRenderer rend, Component comp, Object value) {
    StyleKey style = new StyleKey();
    String text = null;
    if (comp instanceof JLabel) {
        JLabel label = (JLabel) comp;
        text = label.getText();
        text = stripHtml(text);
    }
    Object unwrapped = WrappedValue.unwrap(value);
    if (unwrapped instanceof Date) {
        // POI-exported dates seem to freak Excel out for some reason.
        // to workaround, we export a string.
        Date date = (Date) unwrapped;
        text = DATE_FORMATTER.format(date);
        cell.setCellValue(new HSSFRichTextString(text));
    } else if (unwrapped instanceof NumericDataValue) {
        NumericDataValue ndv = (NumericDataValue) unwrapped;
        cell.setCellValue(ndv.value);
        if (text == null || text.trim().length() == 0) {
            style.setColor(Color.WHITE);
        } else if (text.indexOf('%') != -1) {
            style.format = PERCENT_FORMAT;
        }
    } else if (text == null || text.trim().length() == 0) {
        return;
    } else {
        cell.setCellValue(new HSSFRichTextString(text));
    }
    style.loadFrom(comp);
    styleCache.applyStyle(cell, style);
}
Also used : NumericDataValue(teamdash.wbs.NumericDataValue) HSSFRichTextString(org.apache.poi.hssf.usermodel.HSSFRichTextString) JLabel(javax.swing.JLabel) HSSFRichTextString(org.apache.poi.hssf.usermodel.HSSFRichTextString) Date(java.util.Date)

Example 5 with NumericDataValue

use of teamdash.wbs.NumericDataValue in project processdash by dtuma.

the class ProxyTimeColumn method getTimeValueAt.

public static NumericDataValue getTimeValueAt(WBSNode node) {
    if (!ProxyWBSModel.isBucket(node))
        return null;
    double value = node.getNumericAttribute(ATTR_NAME);
    if (value > 0)
        return new NumericDataValue(value);
    value = node.getNumericAttribute(RATE_CALC_ATTR_NAME);
    if (value > 0)
        return new NumericDataValue(value);
    value = node.getNumericAttribute(EXTRAPOLATED_ATTR_NAME);
    if (value > 0)
        return new NumericDataValue(value, true, false, EXTRAPOLATED_TOOLTIP);
    return null;
}
Also used : NumericDataValue(teamdash.wbs.NumericDataValue)

Aggregations

NumericDataValue (teamdash.wbs.NumericDataValue)13 WBSNode (teamdash.wbs.WBSNode)2 Component (java.awt.Component)1 Date (java.util.Date)1 JLabel (javax.swing.JLabel)1 HSSFRichTextString (org.apache.poi.hssf.usermodel.HSSFRichTextString)1 TeamMemberTime (teamdash.wbs.TeamMemberTime)1