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;
}
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;
}
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();
}
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");
}
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;
}
Aggregations