Search in sources :

Example 81 with PropertyKey

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

the class MoveTeamDirMessageHandler method findProject.

private String findProject(PropertyKey node, String id) {
    String templateID = ctx.getHierarchy().getID(node);
    if (indivRootTemplateIDs.contains(templateID)) {
        String path = node.path();
        String idDataName = DataRepository.createDataName(path, TeamDataConstants.PROJECT_ID);
        SimpleData idValue = ctx.getData().getSimpleValue(idDataName);
        if (idValue != null && id.equals(idValue.format()))
            return path;
        else
            return null;
    }
    for (int i = ctx.getHierarchy().getNumChildren(node); i-- > 0; ) {
        PropertyKey child = ctx.getHierarchy().getChildKey(node, i);
        String result = findProject(child, id);
        if (result != null)
            return result;
    }
    return null;
}
Also used : SimpleData(net.sourceforge.processdash.data.SimpleData) PropertyKey(net.sourceforge.processdash.hier.PropertyKey)

Example 82 with PropertyKey

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

the class ScriptMenuReplicator method updateScriptMenuItems.

public void updateScriptMenuItems() {
    // look for the last "script menu separator" item to determine where
    // the script menu entries appear in our popup menu.
    int pos = popupMenu.getItemCount() - 1;
    while (!(popupMenu.getItem(pos) instanceof ScriptMenuSeparator)) {
        pos--;
    }
    // now, discard any script menu items that are currently present.
    while (pos-- > 0) {
        if (popupMenu.getItem(pos) instanceof ScriptItemTag)
            popupMenu.remove(pos);
        else
            break;
    }
    // retrieve the current list of script menu items from the dashboard
    PropertyKey currentPhase = activeTaskModel.getNode();
    currentPath = (currentPhase == null ? null : currentPhase.path());
    List<ScriptID> scriptItems = ScriptEnumerator.getScripts(ctx, currentPhase);
    if (scriptItems != null && scriptItems.size() > 1) {
        ScriptMenuBuilder b = new ScriptMenuBuilder(scriptItems);
        addMenuItems(popupMenu, b.getMenuItems(), pos);
    }
}
Also used : ScriptID(net.sourceforge.processdash.process.ScriptID) ScriptMenuBuilder(net.sourceforge.processdash.process.ui.ScriptMenuBuilder) PropertyKey(net.sourceforge.processdash.hier.PropertyKey)

Example 83 with PropertyKey

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

the class HierarchyNoteEditorDialog method getSelectedNode.

private PropertyKey getSelectedNode() {
    TreePath selection = tree.getSelectionPath();
    PropertyKey selectedNode = null;
    if (selection != null)
        selectedNode = treeModel.getKeyForNode(selection.getLastPathComponent());
    return selectedNode;
}
Also used : TreePath(javax.swing.tree.TreePath) PropertyKey(net.sourceforge.processdash.hier.PropertyKey)

Example 84 with PropertyKey

use of net.sourceforge.processdash.hier.PropertyKey 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 85 with PropertyKey

use of net.sourceforge.processdash.hier.PropertyKey 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)

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