Search in sources :

Example 1 with DashHierarchy

use of net.sourceforge.processdash.hier.DashHierarchy in project processdash by dtuma.

the class FollowModeManager method updateHierarchy.

private void updateHierarchy() throws Exception {
    if (!hierarchyFile.isFile())
        return;
    long newTimestamp = hierarchyFile.lastModified();
    if (newTimestamp == 0 || newTimestamp == hierarchyTimestamp)
        return;
    // load the new data from the hierarchy file
    DashHierarchy newHier = new DashHierarchy(hierarchy.dataPath);
    newHier.loadXML(hierarchyFile.getPath(), templates);
    // alter our current hierarchy to match the new changes
    DashController.getHierarchyAlterer().mergeChangesFrom(newHier);
    // update the timestamp to indicate success
    hierarchyTimestamp = newTimestamp;
}
Also used : DashHierarchy(net.sourceforge.processdash.hier.DashHierarchy)

Example 2 with DashHierarchy

use of net.sourceforge.processdash.hier.DashHierarchy in project processdash by dtuma.

the class AddTaskDialog method validateInputsAndPerformTaskAddition.

private boolean validateInputsAndPerformTaskAddition() {
    // make certain they entered a task name. If not, display an error.
    String name = taskName.getText().trim();
    if (name.length() == 0) {
        displayError(resources.getString("Errors.Name_Missing"));
        return false;
    }
    // See if another task already exists with that name.
    PropertyKey newNode = new PropertyKey(targetParent, name);
    DashHierarchy hier = dash.getHierarchy();
    if (hier.containsKey(newNode)) {
        displayError(resources.format("Errors.Duplicate_Name_FMT", name, targetParent.path()));
        return false;
    }
    // produce a list of child names in our desired order, to indicate the
    // place where the new node should be inserted.
    List childOrder = new ArrayList();
    int numChildren = hier.getNumChildren(targetParent);
    for (int i = 0; i < numChildren; i++) {
        PropertyKey child = hier.getChildKey(targetParent, i);
        childOrder.add(child.name());
        if (child.equals(previousSibling))
            childOrder.add(name);
    }
    if (childOrder.size() == numChildren)
        childOrder = null;
    try {
        // add the new task.
        HierarchyAlterer alt = DashController.getHierarchyAlterer();
        String newTaskPath = newNode.path();
        if (taskType.templateID == null) {
            alt.addNode(newTaskPath);
        } else {
            alt.addTemplate(newTaskPath, taskType.templateID);
        }
        // the new task will initially be the last child of this parent.
        // proactively mark it as the selected child.
        hier.setSelectedChild(targetParent, numChildren);
        // is in the correct position
        if (childOrder != null)
            alt.reorderChildren(targetParent.path(), childOrder);
        // let the handler perform any follow-up work
        handler.finalizeAddedTask(newTaskPath, taskType);
        // set the new task as the active task.
        deferredSetActiveTask(newNode);
    } catch (HierarchyAlterationException e) {
        e.printStackTrace();
    }
    return true;
}
Also used : HierarchyAlterationException(net.sourceforge.processdash.hier.HierarchyAlterer.HierarchyAlterationException) HierarchyAlterer(net.sourceforge.processdash.hier.HierarchyAlterer) DashHierarchy(net.sourceforge.processdash.hier.DashHierarchy) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) PropertyKey(net.sourceforge.processdash.hier.PropertyKey)

Example 3 with DashHierarchy

use of net.sourceforge.processdash.hier.DashHierarchy in project processdash by dtuma.

the class HierarchyEditor method saveProperties.

public void saveProperties() {
    if (Settings.isReadOnly())
        return;
    dashboard.getHierarchy().fireHierarchyWillChange();
    // FIXME_TIMELOG: dashboard.releaseTimeLogEntry(null);
    // if the user is running their timer while they perform
    // renaming operations below, could bad things happen?
    oldProps = new DashHierarchy(useProps.dataPath);
    oldProps.copy(readProps);
    readProps.copy(useProps);
    setDirty(false);
    int tasksToPerform = 1;
    if (pendingVector != null)
        tasksToPerform += pendingVector.size();
    createProgressDialog(tasksToPerform);
    // do work in a different thread - otherwise we steal time from
    // the awt event pump and nothing gets redrawn.
    Thread t = new Thread() {

        public void run() {
            try {
                savePendingVector();
            } catch (Throwable t) {
                t.printStackTrace();
            }
            closeProgressDialog();
        }
    };
    t.start();
    // this call will block until complete.
    showProgressDialog();
}
Also used : DashHierarchy(net.sourceforge.processdash.hier.DashHierarchy)

Example 4 with DashHierarchy

use of net.sourceforge.processdash.hier.DashHierarchy in project processdash by dtuma.

the class EditSubprojectList method ensureMasterProject.

private void ensureMasterProject() throws TinyCGIException {
    DashHierarchy hierarchy = getPSPProperties();
    PropertyKey key = hierarchy.findExistingKey(getPrefix());
    String templateID = hierarchy.getID(key);
    if (templateID == null || !templateID.endsWith(MASTER_ROOT))
        throw new TinyCGIException(403, "Not a Master Project");
}
Also used : DashHierarchy(net.sourceforge.processdash.hier.DashHierarchy) PropertyKey(net.sourceforge.processdash.hier.PropertyKey) TinyCGIException(net.sourceforge.processdash.net.http.TinyCGIException)

Example 5 with DashHierarchy

use of net.sourceforge.processdash.hier.DashHierarchy in project processdash by dtuma.

the class TeamProjectBrowser method getHierarchyToDisplay.

private DashHierarchy getHierarchyToDisplay() {
    DashHierarchy result = new DashHierarchy("");
    result.copy(ctx.getHierarchy());
    pruneForDisplay(result, PropertyKey.ROOT);
    maybeCreateDefaultHierarchy(result);
    return result;
}
Also used : DashHierarchy(net.sourceforge.processdash.hier.DashHierarchy)

Aggregations

DashHierarchy (net.sourceforge.processdash.hier.DashHierarchy)56 PropertyKey (net.sourceforge.processdash.hier.PropertyKey)40 ArrayList (java.util.ArrayList)7 ListData (net.sourceforge.processdash.data.ListData)6 List (java.util.List)5 HashMap (java.util.HashMap)4 DataRepository (net.sourceforge.processdash.data.repository.DataRepository)4 Point (java.awt.Point)3 Iterator (java.util.Iterator)3 ProcessDashboard (net.sourceforge.processdash.ProcessDashboard)3 SimpleData (net.sourceforge.processdash.data.SimpleData)3 TinyCGIException (net.sourceforge.processdash.net.http.TinyCGIException)3 IOException (java.io.IOException)2 Enumeration (java.util.Enumeration)2 HashSet (java.util.HashSet)2 LinkedList (java.util.LinkedList)2 HierarchyAlterer (net.sourceforge.processdash.hier.HierarchyAlterer)2 Prop (net.sourceforge.processdash.hier.Prop)2 DefectLog (net.sourceforge.processdash.log.defects.DefectLog)2 DefectLogID (net.sourceforge.processdash.log.defects.DefectLogID)2