use of net.sourceforge.processdash.hier.PropertyKey in project processdash by dtuma.
the class TeamProjectBrowser method setSelectedTreeNode.
private void setSelectedTreeNode(PropertyKey newNode) {
PropertyKey nodeToSelect = treeProps.findExistingKey(newNode.path());
if (nodeToSelect == null)
nodeToSelect = getBestNodeToSelect(newNode);
PropertyKey currentlySelectedNode = getSelectedTreeNode();
if (!nodeToSelect.equals(currentlySelectedNode)) {
Object[] path = treeModel.getPathToKey(treeProps, nodeToSelect);
handler.changeTreeSelection(path);
}
}
use of net.sourceforge.processdash.hier.PropertyKey in project processdash by dtuma.
the class TeamProjectBrowser method addHierChild.
private PropertyKey addHierChild(DashHierarchy hier, PropertyKey parent, String childName) {
PropertyKey child = new PropertyKey(parent, childName);
getOrCreateProp(hier, parent).addChild(child, 0);
return child;
}
use of net.sourceforge.processdash.hier.PropertyKey in project processdash by dtuma.
the class Hierleaves method call.
/** Perform a procedure call.
*
* This method <b>must</b> be thread-safe.
*/
public Object call(List arguments, ExpressionContext context) {
String prefix;
if (!arguments.isEmpty())
prefix = asStringVal(getArg(arguments, 0));
else
prefix = context.get(ExpressionContext.PREFIXVAR_NAME).format();
if (prefix == null)
return null;
try {
ListData hierItem = (ListData) context.get(DashHierarchy.DATA_REPOSITORY_NAME);
DashHierarchy hier = (DashHierarchy) hierItem.get(0);
PropertyKey key = hier.findExistingKey(prefix);
if (key == null)
return null;
ListData result = new ListData();
collect(result, hier, key);
return result;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
use of net.sourceforge.processdash.hier.PropertyKey in project processdash by dtuma.
the class Hierleaves method collect.
private void collect(ListData result, DashHierarchy hier, PropertyKey key) {
int numChildren = hier.getNumChildren(key);
if (numChildren == 0) {
result.add(key.path());
} else {
for (int i = 0; i < numChildren; i++) {
PropertyKey child = hier.getChildKey(key, i);
collect(result, hier, child);
}
}
}
use of net.sourceforge.processdash.hier.PropertyKey in project processdash by dtuma.
the class TimeLogEditor method collectTime.
private long collectTime(Object node, SortedMap timesIn, Map timesOut) {
// time for this node
long t = 0;
// child and add total time for this node.
for (int i = 0; i < treeModel.getChildCount(node); i++) {
t += collectTime(treeModel.getChild(node, i), timesIn, timesOut);
}
// fetch and add time spent in this node
Object[] treePath = treeModel.getPathToRoot((TreeNode) node);
PropertyKey key = treeModel.getPropKey(useProps, treePath);
if (key != null) {
String pathPrefix = key.path();
// For efficiency, we only search through the portion of the
// SortedMap which could contain paths matching our prefix.
// "Matching our prefix" means that it exactly equals our
// prefix, or it begins with our prefix followed by a slash.
// The character after the slash character is the zero '0'.
// So any string that is greater than that prefix can't match.
String endPrefix = pathPrefix + '0';
for (Iterator i = timesIn.subMap(pathPrefix, endPrefix).entrySet().iterator(); i.hasNext(); ) {
Map.Entry e = (Map.Entry) i.next();
String onePath = (String) e.getKey();
if (Filter.pathMatches(onePath, pathPrefix)) {
long[] l = (long[]) e.getValue();
if (l != null)
t += l[0];
i.remove();
}
}
}
timesOut.put(node, new Long(t));
return t;
}
Aggregations