Search in sources :

Example 26 with SimpleData

use of net.sourceforge.processdash.data.SimpleData in project processdash by dtuma.

the class ResultSet method format.

/** Format an object from the result set for display.
     * Data rows and columns are numbered starting with 1 and ending with
     * numRows() or numCols(), respectively. Row 0 and column 0 contain
     * header information. Null values in the ResultSet will be formatted as
     * the empty string. */
public String format(int row, int col) {
    // row and column headers are strings
    if (row == 0)
        return getColName(col);
    if (col == 0)
        return getRowName(row);
    SimpleData d = getData(row, col);
    if (d == null || !d.isDefined())
        return "";
    String result = d.format();
    if (result.startsWith("#") || result.startsWith("ERR"))
        return result;
    int fmt = useRowFormats ? row : col;
    return prefix[fmt] + result + suffix[fmt];
}
Also used : SimpleData(net.sourceforge.processdash.data.SimpleData) LocalizedString(net.sourceforge.processdash.util.LocalizedString)

Example 27 with SimpleData

use of net.sourceforge.processdash.data.SimpleData in project processdash by dtuma.

the class HierarchicalCompletionStatusCalculator method handleEvent.

private boolean handleEvent(DataEvent e) {
    String dataName = e.getName();
    if (dataName.endsWith(COMPLETED)) {
        String path = dataName.substring(0, dataName.length() - COMPLETED.length());
        SimpleData dataValue = e.getValue();
        Date newValue = null;
        if (dataValue instanceof DateData && dataValue.test())
            newValue = ((DateData) dataValue).getValue();
        Date oldValue = statusIn.put(path, newValue);
        if (NullSafeObjectUtils.EQ(oldValue, newValue) == false)
            return true;
    }
    return false;
}
Also used : DateData(net.sourceforge.processdash.data.DateData) SimpleData(net.sourceforge.processdash.data.SimpleData) Date(java.util.Date)

Example 28 with SimpleData

use of net.sourceforge.processdash.data.SimpleData in project processdash by dtuma.

the class EditSubprojectList method getSimpleValue.

/** Get a value from the data repository. */
protected SimpleData getSimpleValue(String name) {
    DataRepository data = getDataRepository();
    String prefix = getPrefix();
    if (prefix == null)
        prefix = "";
    String dataName = DataRepository.createDataName(prefix, name);
    SimpleData d = data.getSimpleValue(dataName);
    return d;
}
Also used : DataRepository(net.sourceforge.processdash.data.repository.DataRepository) SimpleData(net.sourceforge.processdash.data.SimpleData)

Example 29 with SimpleData

use of net.sourceforge.processdash.data.SimpleData in project processdash by dtuma.

the class EditSubprojectList method updateEVSchedule.

private void updateEVSchedule(Map subprojects) {
    String teamScheduleName = getValue("Project_Schedule_Name");
    logger.log(Level.FINE, "Master project {0} updating master schedule \"{1}\"", new Object[] { getPrefix(), teamScheduleName });
    // open the master schedule
    EVTaskList schedule = EVTaskList.openExisting(teamScheduleName, getDataRepository(), getPSPProperties(), getObjectCache(), false);
    if (!(schedule instanceof EVTaskListRollup)) {
        logger.log(Level.WARNING, "could not find a rollup schedule named \"{0}\"", teamScheduleName);
        return;
    }
    // empty all the children from the current master schedule.
    EVTaskListRollup master = (EVTaskListRollup) schedule;
    for (int i = master.getChildCount(master.getRoot()); i-- > 0; ) {
        EVTask task = (EVTask) master.getChild(master.getRoot(), i);
        master.removeTask(new TreePath(task.getPath()));
    }
    // now add the schedules of all the subprojects.
    for (Iterator i = subprojects.values().iterator(); i.hasNext(); ) {
        Subproject proj = (Subproject) i.next();
        String dataName = DataRepository.createDataName(proj.path, "Project_Schedule_Name");
        SimpleData d = getDataRepository().getSimpleValue(dataName);
        if (d == null) {
            logger.warning("Could not find schedule for subproject " + proj.path);
            continue;
        }
        String subscheduleName = d.format();
        if (!master.addTask(subscheduleName, getDataRepository(), getPSPProperties(), getObjectCache(), false)) {
            logger.warning("Could not add schedule for subproject " + proj.path);
        }
    }
    master.save();
    logger.fine("saved changed task list");
}
Also used : TreePath(javax.swing.tree.TreePath) EVTaskListRollup(net.sourceforge.processdash.ev.EVTaskListRollup) EVTask(net.sourceforge.processdash.ev.EVTask) Iterator(java.util.Iterator) EVTaskList(net.sourceforge.processdash.ev.EVTaskList) SimpleData(net.sourceforge.processdash.data.SimpleData)

Example 30 with SimpleData

use of net.sourceforge.processdash.data.SimpleData in project processdash by dtuma.

the class PercentSpentIndicator method showEditEstimateDialog.

private void showEditEstimateDialog() {
    if (currentTaskPath == null || estTimeDataName == null || estTimeEditable == false)
        return;
    ToolTipManager.sharedInstance().mouseExited(new MouseEvent(this, MouseEvent.MOUSE_EXITED, System.currentTimeMillis(), 0, 0, -1, 0, false));
    final JTextField estimate = new JTextField();
    if (estTime > 0 && !Double.isInfinite(estTime))
        estimate.setText(FormatUtil.formatTime(estTime));
    String prompt = resources.format("Edit_Dialog.Prompt_FMT", currentTaskPath);
    JPanel p = new JPanel(new GridLayout(2, 2, 10, 2));
    p.add(new JLabel(resources.getString("Actual_Time_Label"), JLabel.TRAILING));
    p.add(new JLabel(FormatUtil.formatTime(actTime)));
    p.add(new JLabel(resources.getString("Estimated_Time_Label"), JLabel.TRAILING));
    p.add(estimate);
    String title = resources.getString("Edit_Dialog.Title");
    Object message = new Object[] { prompt, p, new JOptionPaneTweaker.GrabFocus(estimate) };
    while (true) {
        if (JOptionPane.showConfirmDialog(this, message, title, JOptionPane.OK_CANCEL_OPTION) != JOptionPane.OK_OPTION)
            return;
        SimpleData newEstimate;
        String userInput = estimate.getText();
        if (userInput == null || userInput.trim().length() == 0) {
            newEstimate = null;
        } else {
            long l = FormatUtil.parseTime(userInput.trim());
            if (l < 0) {
                estimate.setBackground(new Color(255, 200, 200));
                estimate.setToolTipText(resources.getString("Edit_Dialog.Invalid_Time"));
                continue;
            }
            newEstimate = new DoubleData(l, true);
        }
        dashCtx.getData().userPutValue(estTimeDataName, newEstimate);
        EST_TIME_JANITOR.cleanup(dashCtx);
        return;
    }
}
Also used : JPanel(javax.swing.JPanel) GridLayout(java.awt.GridLayout) MouseEvent(java.awt.event.MouseEvent) Color(java.awt.Color) JLabel(javax.swing.JLabel) SimpleData(net.sourceforge.processdash.data.SimpleData) JTextField(javax.swing.JTextField) DoubleData(net.sourceforge.processdash.data.DoubleData)

Aggregations

SimpleData (net.sourceforge.processdash.data.SimpleData)164 ListData (net.sourceforge.processdash.data.ListData)20 DoubleData (net.sourceforge.processdash.data.DoubleData)15 SaveableData (net.sourceforge.processdash.data.SaveableData)14 StringData (net.sourceforge.processdash.data.StringData)13 IOException (java.io.IOException)11 DataRepository (net.sourceforge.processdash.data.repository.DataRepository)11 DateData (net.sourceforge.processdash.data.DateData)10 Iterator (java.util.Iterator)9 List (java.util.List)7 PropertyKey (net.sourceforge.processdash.hier.PropertyKey)7 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 ImmutableDoubleData (net.sourceforge.processdash.data.ImmutableDoubleData)6 NumberData (net.sourceforge.processdash.data.NumberData)6 Element (org.w3c.dom.Element)6 Map (java.util.Map)5 DataContext (net.sourceforge.processdash.data.DataContext)5 EscapeString (net.sourceforge.processdash.util.EscapeString)5 File (java.io.File)4