Search in sources :

Example 16 with Prop

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

the class OpenTimeLogEditor method augmentHierarchy.

private void augmentHierarchy(DashHierarchy hier, PropertyKey parentNode, Element parentXml) {
    Prop parentProp = (Prop) hier.get(parentNode);
    if (parentProp == null)
        return;
    for (Element childXml : XMLUtils.getChildElements(parentXml)) {
        String childName = childXml.getAttribute("name");
        PropertyKey childNode = new PropertyKey(parentNode, childName);
        parentProp.addChild(childNode, -1);
        hier.put(childNode, new Prop());
        augmentHierarchy(hier, childNode, childXml);
    }
}
Also used : Prop(net.sourceforge.processdash.hier.Prop) Element(org.w3c.dom.Element) PropertyKey(net.sourceforge.processdash.hier.PropertyKey)

Example 17 with Prop

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

the class DataExtractionScaffold method openDataFiles.

private void openDataFiles(String property_directory, PropertyKey key) throws FileNotFoundException, IOException, InvalidDatafileFormat {
    Prop val = hierarchy.pget(key);
    String id = val.getID();
    String dataFile = val.getDataFile();
    if (shouldLoadDataFile(id, dataFile)) {
        // System.out.println("opening datafile for " + key.path());
        data.openDatafile(key.path(), property_directory + dataFile);
    }
    if (!shouldPruneDataLoad(id)) {
        for (int i = 0; i < hierarchy.getNumChildren(key); i++) {
            openDataFiles(property_directory, hierarchy.getChildKey(key, i));
        }
    }
}
Also used : Prop(net.sourceforge.processdash.hier.Prop)

Example 18 with Prop

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

the class HierarchyEditor method moveUp.

private void moveUp(DefaultMutableTreeNode node) {
    if (node == null || node == (DefaultMutableTreeNode) treeModel.getRoot())
        return;
    // Check to make certain that the move is legal.
    Object[] path = node.getPath();
    PropertyKey key = treeModel.getPropKey(useProps, path);
    if (!moveUpIsLegal(key))
        return;
    // First, make the change in the properties object.
    DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) node.getParent();
    int index = parentNode.getIndex(node);
    PropertyKey parentKey = key.getParent();
    Prop parentProp = useProps.pget(parentKey);
    parentProp.moveChildUp(index);
    // Next, make the change in the tree model.
    treeModel.useTreeModelListener(false);
    parentNode.insert(node, index - 1);
    treeModel.useTreeModelListener(true);
    treeModel.nodeStructureChanged(parentNode);
    setDirty(true);
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) Prop(net.sourceforge.processdash.hier.Prop) PropertyKey(net.sourceforge.processdash.hier.PropertyKey)

Example 19 with Prop

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

the class HierarchyEditor method updateTemplateMenu.

public void updateTemplateMenu(Vector tList, String id) {
    Prop p;
    int idx;
    JMenu addTemplateMenu = this.addTemplateMenu;
    JMenuItem menuItem;
    String val;
    PropertyKey tKey = PropertyKey.ROOT;
    boolean enableMenu = false;
    // clear the JMenu
    addTemplateMenu.removeAll();
    //    System.out.println("Update:" + id);
    for (int ii = 0; ii < templates.getNumChildren(tKey); ii++) {
        p = templates.pget(templates.getChildKey(tKey, ii));
        //      System.out.println("Update: testing " +p.getID());
        if ((tList != null) && (!tList.contains(p.getID())))
            continue;
        //      System.out.println("Update:  test2 " +p.getStatus());
        val = p.getStatus();
        if ((val != null) && ((idx = val.indexOf(REQUIRED_PARENT)) >= 0)) {
            //check for reqd parent
            if (id == null)
                continue;
            boolean found = false;
            StringTokenizer st = new StringTokenizer(val.substring(idx + 1), String.valueOf(REQUIRED_PARENT));
            while (st.hasMoreElements() && !found) found = id.equals(st.nextElement());
            if (!found)
                continue;
        }
        val = templates.getChildName(tKey, ii);
        String display = Prop.unqualifiedName(val);
        //      System.out.println("Update: passed " + val);
        enableMenu = true;
        if (addTemplateMenu.getItemCount() > 18)
            addTemplateMenu = (JMenu) addTemplateMenu.add(new JMenu(resource.getDlgString("More")), 0);
        menuItem = addTemplateMenu.add(new JMenuItem(display));
        menuItem.addActionListener(new AddTemplateAction(val));
    }
    this.addTemplateMenu.setEnabled(enableMenu);
}
Also used : StringTokenizer(java.util.StringTokenizer) Prop(net.sourceforge.processdash.hier.Prop) JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu) PropertyKey(net.sourceforge.processdash.hier.PropertyKey)

Example 20 with Prop

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

the class PropTreeModel method reload.

private void reload(DashHierarchy props, DefaultMutableTreeNode node, PropertyKey key) {
    DefaultMutableTreeNode child;
    int childIndex = 0;
    //set the current node name
    Prop value = props.pget(key);
    if (!key.name().equals(node.getUserObject())) {
        node.setUserObject(key.name());
        nodeChanged(node);
    }
    int numPropChildren = value.getNumChildren();
    while (numPropChildren > childIndex) {
        if (getChildCount(node) <= childIndex) {
            child = new DefaultMutableTreeNode("changeMeLater");
            insertNodeInto(child, node, childIndex);
        } else
            child = (DefaultMutableTreeNode) getChild(node, childIndex);
        reload(props, child, props.getChildKey(key, childIndex));
        childIndex++;
    }
    while (getChildCount(node) > numPropChildren) removeNodeFromParent((MutableTreeNode) getChild(node, getChildCount(node) - 1));
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) Prop(net.sourceforge.processdash.hier.Prop) MutableTreeNode(javax.swing.tree.MutableTreeNode) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode)

Aggregations

Prop (net.sourceforge.processdash.hier.Prop)30 PropertyKey (net.sourceforge.processdash.hier.PropertyKey)16 Iterator (java.util.Iterator)4 StringTokenizer (java.util.StringTokenizer)4 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)4 Map (java.util.Map)3 Vector (java.util.Vector)3 Enumeration (java.util.Enumeration)2 DashHierarchy (net.sourceforge.processdash.hier.DashHierarchy)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Hashtable (java.util.Hashtable)1 TreeMap (java.util.TreeMap)1 JMenu (javax.swing.JMenu)1 JMenuItem (javax.swing.JMenuItem)1 MutableTreeNode (javax.swing.tree.MutableTreeNode)1 TreeNode (javax.swing.tree.TreeNode)1 TreePath (javax.swing.tree.TreePath)1