Package net.sourceforge.processdash.hier

Examples of net.sourceforge.processdash.hier.Prop


      (DefaultMutableTreeNode)tp.getLastPathComponent();
    moveUpAction.setEnabled(moveUpIsLegal(node));
    moveDownAction.setEnabled(moveDownIsLegal(node));

    // Place code to update selection-sensitive field(s) here.
    Prop val = useProps.pget (key);

    String status = val.getStatus();
    if (status == null)
      status = "";

    int     parseIndex      = 0;
    boolean moveable        = true;
    boolean editable        = true;
    boolean deletable       = true;
    boolean allowsSiblings  = true;
    boolean allowsChildren  = true;
    Vector  allowedChildren = null;

    if ((status.length() > 0) && (status.charAt (0) == NO_MOVE_CHAR)) {
      moveable = false;
      parseIndex++;
      if ((status.length() > 1) && (status.charAt (1) == NO_EDIT_CHAR)) {
        editable = false;
        parseIndex++;
      }
    } else if ((status.length() > 0) && (status.charAt (0) == NO_EDIT_CHAR)) {
      editable = false;
      parseIndex++;
    }

    if (path.length <= 1)       // top two levels (root & 1st sub) static
      deletable = false;
    else if (!editable && !moveable)
      deletable =
        status.startsWith("" + NO_MOVE_CHAR + NO_EDIT_CHAR + DELETE_OK_CHAR);
    deleteMenuItem.setEnabled (deletable);
    cutAction.setEnabled (deletable);

    String pStatus = useProps.pget(key.getParent()).getStatus();
    if ((pStatus != null) && (pStatus.indexOf(ALLOWED_CHILD) >= 0))
      allowsSiblings = false;
    if ((parseIndex = status.indexOf (ALLOWED_CHILD)) >= 0) {
      allowsChildren = false;   // can only add specified templates
      allowedChildren = new Vector(); // non-null implies REQUIRED match

      int lastChar = status.indexOf (REQUIRED_PARENT);
      if (lastChar < 0)
        lastChar = status.length();
      if (lastChar > parseIndex + 1) {
                                // at least one allowed, make list...
        StringTokenizer st = new StringTokenizer
          (status.substring (parseIndex + 1, lastChar),
           String.valueOf (ALLOWED_CHILD));
        String sDebug, childID;
        int endIndex;
        while (st.hasMoreElements()) {
          sDebug = st.nextToken();
          endIndex = sDebug.indexOf ("(");
          if (endIndex < 0)
            endIndex = sDebug.length();
          childID = sDebug.substring (0, endIndex);
          PropertyKey childKey = templates.getByID(childID);
                               // if there isn't already a child with this name
                               // or if the given template is rename-able,
          if (childKey == null ||
              (val.isUniqueChildName(Prop.unqualifiedName(childKey.name())) ||
               templateIsMalleable(childKey)))
                               // then it's okay to allow adding this template.
            allowedChildren.addElement (childID);
//        System.out.println("Allowing Template " +
//                           sDebug.substring (0, endIndex));
        }
      }
    }
    String valID = val.getID();
    if (valID == null) valID = "";
    adjustMenu (allowsSiblings, allowsChildren, editable,
                allowedChildren, valID, key.path());
  }
View Full Code Here


      return true;
  }

  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;

    addTemplateMenu.removeAll(); // clear the JMenu

//    System.out.println("Update:" + id);
    for (int ii = 0; ii < templates.getNumChildren (tKey); ii++) {
      p = templates.pget (templates.getChildKey (tKey, ii));
                                // ensure tList includes the current ID
                                // (current template is an allowed child)
//      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;
View Full Code Here

//    System.out.println (e.toString());
  }


  public void setStatusRecursive (PropertyKey key, String status) {
    Prop val = useProps.pget (key);
    val.setStatus (status);
    useProps.put (key, val);
    for (int ii = 0; ii < val.getNumChildren(); ii++)
      setStatusRecursive (val.getChild (ii), status);
  }
View Full Code Here

    int newIndex = useProps.getNumChildren (parent);

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

                                // if parent specifies allowed children
    Prop val = useProps.pget (parent);
    String status, allowedChild;
    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();
View Full Code Here

      return false;

    return moveUpIsLegal(treeModel.getPropKey (useProps, node.getPath()));
  }
  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

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

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

TOP

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

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.