Package net.sourceforge.processdash.hier

Examples of net.sourceforge.processdash.hier.PropertyKey


              String.valueOf (ALLOWED_CHILD));
      while (st.hasMoreElements()) {
          String childID = st.nextToken();
          int endIndex = childID.indexOf ("(");
          if (endIndex != -1) childID = childID.substring(0, endIndex);
          PropertyKey childKey = templates.getByID(childID);
          if (childKey == null) continue;
          if (!templateIsMalleable(childKey)
                  && newName.equals(Prop.unqualifiedName(childKey.name())))
              return true;
      }
     
      return false;
  }
View Full Code Here


    // debug ("treeNodesInserted:"+e.toString());
    Object [] path = e.getPath();
    int [] indices = e.getChildIndices();
    Object [] children = e.getChildren();

    PropertyKey parent = treeModel.getPropKey (useProps, path);
    debug (((path == null) ? "null" : path.toString()) + "=>" +
           ((parent == null) ? "null" : parent.toString()));
    for (int nodeIdx = 0; nodeIdx < indices.length; nodeIdx++) {
      useProps.addChildKey (parent,
                            children [nodeIdx].toString(),
                            indices[nodeIdx]);
    }
View Full Code Here

  }

  public void treeNodesRemoved (TreeModelEvent e) {
    Object [] path = e.getPath();
    int [] indices = e.getChildIndices();
    PropertyKey parent = treeModel.getPropKey (useProps, path);

                                // does not yet deal WELL with mult nodes
                                // (haven't seen mult nodes yet, either...)
    for (int nodeIdx = 0; nodeIdx < indices.length; nodeIdx++) {
      useProps.removeChildKey (parent, indices [nodeIdx]);
View Full Code Here


  public TreeNode copyTemplate(DefaultMutableTreeNode destParent,
                               String                 templateName) {
    //recursive copy of node, children and properties
    PropertyKey parent = treeModel.getPropKey (useProps,
                                               destParent.getPath ());
    PropertyKey templateKey = templates.getRootChildByName(templateName);
    int newIndex = useProps.getNumChildren (parent);

                                // See if should be adding at other index...

                                // if parent specifies allowed children
View Full Code Here

  }
  private boolean moveUpIsLegal(PropertyKey key) {
    Prop prop = useProps.pget(key);
    if (!isMoveable(prop.getStatus())) return false;

    PropertyKey parentKey = key.getParent();
    Prop parentProp = useProps.pget(parentKey);
    int pos = -1;
    for (int i=parentProp.getNumChildren();  i-- > 0; )
      if (key.equals(parentProp.getChild(pos=i))) break;
    if (pos < 1) return false;

    PropertyKey siblingKey = parentProp.getChild(pos-1);
    Prop siblingProp = useProps.pget(siblingKey);
    return isMoveable(siblingProp.getStatus());
  }
View Full Code Here

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

                           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) ||
            // disallow pasting a node into one of its descendants (would
            // create an illegal recursive tree.
        parentPath.startsWith(cutPath+"/") ||
            // disallow pasting a node into its current parent (it
            // 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 */
 
View Full Code Here

    public void actionPerformed(ActionEvent e) {
        DefaultMutableTreeNode nodeToRemove = getSelectedNode();
        if (nodeToRemove == null || nodeToRemove == treeModel.getRoot())
            return;

        PropertyKey key = treeModel.getPropKey(useProps, nodeToRemove.getPath());
        if (key == null)
            return;
        String path = key.path();

        String title = resource.getString("HierarchyDeleteWarningTitle");
        String[] message = resource.format("HierarchyDeleteWarning_FMT",
                path).split("\n");
        int userChoice = JOptionPane.showConfirmDialog(frame, message,
View Full Code Here

      DefaultMutableTreeNode node = getSelectedNode();
      if (node == null) return;

      // get the default index for adding
      PropertyKey parentPKey = treeModel.getPropKey (useProps, node.getPath ());
      Prop val = useProps.pget (parentPKey);
      int newIndex = useProps.getNumChildren (parentPKey);

                                // See if should be adding at other index...

                                // if parent specifies allowed children
      String status, allowedChild;
      PropertyKey cutKey = treeModel.getPropKey (useProps, cutNode.getPath());
      Prop cutProp = useProps.pget(cutKey);
      String cutID = cutProp.getID();
      if ((val != null) && ((status = val.getStatus()) != null)) {
        int idx1 = status.indexOf (ALLOWED_CHILD);
        int idx2 = status.indexOf (REQUIRED_PARENT);
        if (idx1 >= 0) {
          if (idx2 < 0)
            idx2 = status.length();
          StringTokenizer st = new StringTokenizer
            (status.substring (idx1 + 1, idx2), String.valueOf (ALLOWED_CHILD));
          while (st.hasMoreTokens()) {
            allowedChild = st.nextToken();
                                // if parent specifies THIS child
            if (allowedChild.startsWith (cutID)) {
              idx1 = allowedChild.indexOf("(");
              idx2 = allowedChild.indexOf(")");
                                // if parent specifies index
              if (idx1 >= 0 && idx2 >= 0) {
                                // change index
                idx1 = Integer.valueOf (allowedChild.substring
                                        (idx1 + 1, idx2)).intValue();
                newIndex = ((idx1 < 0) ? (newIndex + idx1) : idx1);
              }
              break;              // exit while loop
            }
          }
        }
      }

      // Create an appropriately named node (original + made unique(if needed))
      String newChildName =
        useProps.pget(parentPKey).uniqueChildName(cutKey.name());
      useProps.addChildKey
        (parentPKey,
         useProps.pget(parentPKey).uniqueChildName(newChildName),
         newIndex);
View Full Code Here

        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;
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.