adjustMenu (false, true, false, null, null, null);
addTemplateMenu.setEnabled (false);
return;
}
Object [] path = tp.getPath();
PropertyKey key = treeModel.getPropKey (useProps, path);
DefaultMutableTreeNode node =
(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));