Search in sources :

Example 16 with PropertyKey

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

the class HierarchyEditor method canPaste.

private boolean canPaste(String parentID, String parentPath, Vector templateChildren, DefaultMutableTreeNode cutNode) {
    if (parentID == null || parentPath == null || cutNode == null || (templateChildren != null && templateChildren.size() == 0))
        return false;
    PropertyKey cutKey = treeModel.getPropKey(useProps, cutNode.getPath());
    String cutPath = cutKey.path();
    // disallow pasting a node into itself.
    if (cutPath.equals(parentPath) || // create an illegal recursive tree.
    parentPath.startsWith(cutPath + "/") || // already lives there!)
    parentPath.equals(cutKey.getParent().path()))
        return false;
    Prop cutProp = useProps.pget(cutKey);
    String cutID = cutProp.getID();
    /* match child with parent's allowed child list, if any */
    if (templateChildren != null && !templateChildren.contains(cutID))
        return false;
    /* match parent with child's required parent list, if any */
    String cutStatus = cutProp.getStatus();
    if (cutStatus == null)
        return true;
    /* no required parent */
    int idx = cutStatus.indexOf(REQUIRED_PARENT);
    if (idx == -1)
        return true;
    /* no required parent */
    StringTokenizer st = new StringTokenizer(cutStatus.substring(idx + 1), String.valueOf(REQUIRED_PARENT));
    while (st.hasMoreElements()) /* matches required parent */
    if (parentID.equals(st.nextElement()))
        return true;
    // moved under arbitrary plain nodes
    if ((cutID.endsWith("/IndivRoot") || cutID.endsWith("/Indiv2Root")) && "".equals(parentID))
        return true;
    return false;
}
Also used : StringTokenizer(java.util.StringTokenizer) Prop(net.sourceforge.processdash.hier.Prop) PropertyKey(net.sourceforge.processdash.hier.PropertyKey)

Example 17 with PropertyKey

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

the class HierarchyEditor method treeNodesRemoved.

public void treeNodesRemoved(TreeModelEvent e) {
    Object[] path = e.getPath();
    int[] indices = e.getChildIndices();
    PropertyKey parent = treeModel.getPropKey(useProps, path);
    // (haven't seen mult nodes yet, either...)
    for (int nodeIdx = 0; nodeIdx < indices.length; nodeIdx++) {
        useProps.removeChildKey(parent, indices[nodeIdx]);
    }
    setDirty(true);
}
Also used : PropertyKey(net.sourceforge.processdash.hier.PropertyKey)

Example 18 with PropertyKey

use of net.sourceforge.processdash.hier.PropertyKey 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");
}
Also used : DashHierarchy(net.sourceforge.processdash.hier.DashHierarchy) PropertyKey(net.sourceforge.processdash.hier.PropertyKey) TinyCGIException(net.sourceforge.processdash.net.http.TinyCGIException)

Example 19 with PropertyKey

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

the class TeamProjectBrowser method maybeRenameSelectedProject.

private void maybeRenameSelectedProject() {
    // determine which team project is selected. If none, abort.
    PropertyKey projectNode = getSelectedTreeNode();
    String projectPath = projectNode.path();
    String templateID = ctx.getHierarchy().getID(projectNode);
    if (!StringUtils.hasValue(templateID))
        return;
    // Create objects we will use in a dialog
    String title = resources.getString("Rename.Title");
    JTextField newPathField = new JTextField(projectPath);
    Object message = resources.formatStrings("Rename.Message_Header_FMT", projectPath);
    message = new Object[] { message, " ", newPathField, new JOptionPaneTweaker.GrabFocus(newPathField) };
    while (true) {
        // Show the user a dialog asking for the new path and name.
        int userChoice = JOptionPane.showConfirmDialog(this, message, title, JOptionPane.OK_CANCEL_OPTION);
        // if the user didn't press the OK button, abort.
        if (userChoice != JOptionPane.OK_OPTION)
            return;
        // get the new path in canonical form. If it was not absolute,
        // interpret it relative to the current parent of the project.
        String newPath = newPathField.getText().trim();
        if (newPath.indexOf('/') == -1)
            newPath = projectNode.getParent().path() + "/" + newPath;
        newPath = DashHierarchy.scrubPath(newPath);
        newPathField.setText(newPath);
        // if the user didn't change the name, abort.
        if (newPath.length() < 2 || newPath.equals(projectPath))
            return;
        // check for various error conditions.
        if (projectAlreadyExists(newPath)) {
            showInvalidRenameMessage("Rename.Duplicate_Name");
        } else if (projectParentIsInvalid(newPath)) {
            showInvalidRenameMessage("Rename.Invalid_Parent");
        } else {
            try {
                // try performing the renaming operation.
                HierarchyAlterer hierarchyAlterer = DashController.getHierarchyAlterer();
                hierarchyAlterer.renameNode(projectPath, newPath);
                // if this caused the old parent of the project to become
                // childless, delete that parent (and grandparent, etc)
                PropertyKey oldParent = projectNode.getParent();
                while (ctx.getHierarchy().getNumChildren(oldParent) == 0) {
                    hierarchyAlterer.deleteNode(oldParent.path());
                    oldParent = oldParent.getParent();
                }
                // point the "active task" at the renamed project.
                PropertyKey newNode = ctx.getHierarchy().findExistingKey(newPath);
                if (newNode != null)
                    taskModel.setNode(newNode);
            } catch (HierarchyAlterationException e) {
                e.printStackTrace();
            }
            return;
        }
    }
}
Also used : JOptionPaneTweaker(net.sourceforge.processdash.ui.lib.JOptionPaneTweaker) HierarchyAlterationException(net.sourceforge.processdash.hier.HierarchyAlterer.HierarchyAlterationException) HierarchyAlterer(net.sourceforge.processdash.hier.HierarchyAlterer) JTextField(javax.swing.JTextField) PropertyKey(net.sourceforge.processdash.hier.PropertyKey)

Example 20 with PropertyKey

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

the class TeamProjectBrowser method updateTreeSelectionFromActiveTask.

private void updateTreeSelectionFromActiveTask() {
    PropertyKey activeTask = taskModel.getNode();
    setSelectedTreeNode(activeTask);
}
Also used : 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