Package net.sourceforge.processdash.hier

Examples of net.sourceforge.processdash.hier.PropertyKey


        }
    }

    private PropertyKey addHierChild(DashHierarchy hier, PropertyKey parent,
            String childName) {
        PropertyKey child = new PropertyKey(parent, childName);
        getOrCreateProp(hier, parent).addChild(child, 0);
        return child;
    }
View Full Code Here


        return prop;
    }


    private void updateTreeSelectionFromActiveTask() {
        PropertyKey activeTask = taskModel.getNode();
        setSelectedTreeNode(activeTask);
    }
View Full Code Here

        PropertyKey activeTask = taskModel.getNode();
        setSelectedTreeNode(activeTask);
    }

    private void setSelectedTreeNode(PropertyKey newNode) {
        PropertyKey nodeToSelect = treeProps.findClosestKey(newNode.path());
        PropertyKey currentlySelectedNode = getSelectedTreeNode();
        if (!nodeToSelect.equals(currentlySelectedNode)) {
            Object[] path = treeModel.getPathToKey(treeProps, nodeToSelect);
            handler.changeTreeSelection(path);
        }
    }
View Full Code Here

            handler.changeTreeSelection(path);
        }
    }

    private PropertyKey getSelectedTreeNode() {
        PropertyKey selectedNode = null;

        TreePath tp = tree.getSelectionPath();
        if (tp != null) {
            Object[] path = tp.getPath();
            selectedNode = treeModel.getPropKey(treeProps, path);
View Full Code Here

        return uri;
    }

    private String getNewProjectTargetParent() {
        PropertyKey node = getSelectedTreeNode();
       
        // When no tree node is selected, the root node is reported as the
        // "effective selection." In this case, return null to indicate that
        // we don't have a target parent.
        if (PropertyKey.ROOT.equals(node))
            return null;

        // Find the first at or above the selection which has no template ID.
        // that is our target parent.
        while (node != null) {
            String templateID = treeProps.getID(node);
            if (StringUtils.hasValue(templateID))
                node = node.getParent();
            else if (PropertyKey.ROOT.equals(node))
                return "/";
            else
                return node.path();
        }
        return null;
    }
View Full Code Here

    }


    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) {
View Full Code Here

            }
        }
    }

    private boolean projectAlreadyExists(String path) {
        PropertyKey key = ctx.getHierarchy().findExistingKey(path);
        return (key != null);
    }
View Full Code Here

        PropertyKey key = ctx.getHierarchy().findExistingKey(path);
        return (key != null);
    }

    private boolean projectParentIsInvalid(String path) {
        PropertyKey key = ctx.getHierarchy().findClosestKey(path);
        while (key != null) {
            String templateID = ctx.getHierarchy().getID(key);
            if (StringUtils.hasValue(templateID))
                return true;
            key = key.getParent();
        }
        return false;
    }
View Full Code Here

    }



    private void maybeDeleteSelectedProject() {
        PropertyKey selectedNode = getSelectedTreeNode();
        String projectPath = selectedNode.path();
        String templateID = ctx.getHierarchy().getID(selectedNode);
        if (okToDeleteProject(projectPath, templateID)) {
            try {
                DashController.getHierarchyAlterer().deleteNode(projectPath);
            } catch (HierarchyAlterationException e) {
View Full Code Here

    private static final String ACTIVE_TASK_SETTING = "userPref.dataset.activeTask";

    private void initActiveTaskFromPreferences() {
        String activeTask = Settings.getVal(ACTIVE_TASK_SETTING);
        PropertyKey key = ctx.getHierarchy().findExistingKey(activeTask);
        if (key != null && ctx.getHierarchy().getNumChildren(key) == 0)
            taskModel.setNode(key);
    }
View Full Code Here

TOP

Related Classes of net.sourceforge.processdash.hier.PropertyKey

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.