Search in sources :

Example 26 with PropertyKey

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);
    }
}
Also used : PropertyKey(net.sourceforge.processdash.hier.PropertyKey)

Example 27 with PropertyKey

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;
}
Also used : PropertyKey(net.sourceforge.processdash.hier.PropertyKey)

Example 28 with PropertyKey

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;
    }
}
Also used : DashHierarchy(net.sourceforge.processdash.hier.DashHierarchy) PropertyKey(net.sourceforge.processdash.hier.PropertyKey) ListData(net.sourceforge.processdash.data.ListData)

Example 29 with PropertyKey

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);
        }
    }
}
Also used : PropertyKey(net.sourceforge.processdash.hier.PropertyKey)

Example 30 with PropertyKey

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;
}
Also used : TimeLogEntry(net.sourceforge.processdash.log.time.TimeLogEntry) ChangeFlaggedTimeLogEntry(net.sourceforge.processdash.log.time.ChangeFlaggedTimeLogEntry) EnumerIterator(net.sourceforge.processdash.util.EnumerIterator) Iterator(java.util.Iterator) EventObject(java.util.EventObject) Map(java.util.Map) SortedMap(java.util.SortedMap) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) PropertyKey(net.sourceforge.processdash.hier.PropertyKey)

Aggregations

PropertyKey (net.sourceforge.processdash.hier.PropertyKey)125 DashHierarchy (net.sourceforge.processdash.hier.DashHierarchy)40 Prop (net.sourceforge.processdash.hier.Prop)16 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)10 SimpleData (net.sourceforge.processdash.data.SimpleData)7 ArrayList (java.util.ArrayList)6 Enumeration (java.util.Enumeration)6 IOException (java.io.IOException)5 Iterator (java.util.Iterator)5 StringTokenizer (java.util.StringTokenizer)5 TreePath (javax.swing.tree.TreePath)5 ListData (net.sourceforge.processdash.data.ListData)5 DefectLog (net.sourceforge.processdash.log.defects.DefectLog)5 List (java.util.List)4 ProcessDashboard (net.sourceforge.processdash.ProcessDashboard)4 HierarchyAlterer (net.sourceforge.processdash.hier.HierarchyAlterer)4 HierarchyAlterationException (net.sourceforge.processdash.hier.HierarchyAlterer.HierarchyAlterationException)4 DefectLogID (net.sourceforge.processdash.log.defects.DefectLogID)4 TinyCGIException (net.sourceforge.processdash.net.http.TinyCGIException)4 Point (java.awt.Point)3