use of net.sourceforge.processdash.hier.Prop in project processdash by dtuma.
the class ProcessDashboard method inferDatasetMode.
private String inferDatasetMode() {
// Look through the hierarchy for existing team/personal projects
boolean containsTeamProject = false;
boolean containsPersonalProject = false;
for (Iterator i = props.values().iterator(); i.hasNext(); ) {
Prop p = (Prop) i.next();
String templateId = (p == null ? null : p.getID());
if (templateId == null)
;
else if (templateId.endsWith("/TeamRoot") || templateId.endsWith("/MasterRoot"))
containsTeamProject = true;
else if (templateId.endsWith("/IndivRoot") || templateId.endsWith("/Indiv2Root") || templateId.startsWith("PSP"))
containsPersonalProject = true;
}
// if we found team/personal projects, infer the mode from their type
if (containsTeamProject && containsPersonalProject)
return Settings.DATASET_MODE_HYBRID;
else if (containsTeamProject)
return Settings.DATASET_MODE_TEAM;
else if (containsPersonalProject)
return Settings.DATASET_MODE_PERSONAL;
// no team projects were found. Make our next best guess based on
// whether a non-default HTTP port has been configured.
int httpPort = Settings.getInt(HTTP_PORT_SETTING, DEFAULT_WEB_PORT);
if (httpPort == DEFAULT_WEB_PORT)
return Settings.DATASET_MODE_PERSONAL;
else
return Settings.DATASET_MODE_TEAM;
}
use of net.sourceforge.processdash.hier.Prop in project processdash by dtuma.
the class LegacySupport method fixupV13ScriptIDs.
public static void fixupV13ScriptIDs(DashHierarchy hierarchy) {
Hashtable brokenIDs = new Hashtable();
brokenIDs.put("pspForEng/2A/script.htm", "PSP0.1-PFE-2A");
brokenIDs.put("pspForEng/4A/script.htm", "PSP1-PFE-4A");
brokenIDs.put("pspForEng/5A/script.htm", "PSP1.1-PFE-5A");
brokenIDs.put("pspForEng/7A/script.htm", "PSP2-PFE-7A");
brokenIDs.put("pspForEng/8A/script.htm", "PSP2.1-PFE-8A");
brokenIDs.put("pspForMSE/2A/script.htm", "PSP0.1-MSE-2A");
brokenIDs.put("pspForMSE/3B/script.htm", "PSP1-MSE-3B");
brokenIDs.put("pspForMSE/4B/script.htm", "PSP1.0.1-MSE-4B");
Prop value;
String s;
for (Iterator i = hierarchy.entrySet().iterator(); i.hasNext(); ) {
Map.Entry e = (Map.Entry) i.next();
value = (Prop) e.getValue();
if (!Prop.hasValue(value.getID()))
continue;
if (!Prop.hasValue(s = value.getScriptFile()))
continue;
s = (String) brokenIDs.get(s);
if (s != null)
value.setID(s);
}
}
use of net.sourceforge.processdash.hier.Prop in project processdash by dtuma.
the class HierarchyEditor method copyTemplate.
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
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();
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(templateName)) {
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);
}
// exit while loop
break;
}
}
}
}
// now add it
useProps.addChildKey(parent, useProps.pget(parent).uniqueChildName(templateName), newIndex);
useProps.copyFrom(templates, templateKey, useProps.getChildKey(parent, newIndex));
// clear and reload the tree (NEEDS WORK)
treeModel.useTreeModelListener(false);
treeModel.reload(useProps);
expandRoot();
treeModel.useTreeModelListener(true);
treeModel.nodeStructureChanged(destParent);
return (TreeNode) treeModel.getChild(destParent, newIndex);
}
use of net.sourceforge.processdash.hier.Prop in project processdash by dtuma.
the class HierarchyEditor method valueChanged.
/**
* The next method implement the TreeSelectionListener interface
* to deal with changes to the tree selection.
*/
public void valueChanged(TreeSelectionEvent e) {
TreePath tp = (e == null ? tree.getSelectionPath() : e.getNewLeadSelectionPath());
if (tp == null) {
// deselection
deleteMenuItem.setEnabled(false);
moveUpAction.setEnabled(false);
moveDownAction.setEnabled(false);
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 (// top two levels (root & 1st sub) static
path.length <= 1)
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) {
// can only add specified templates
allowsChildren = false;
// non-null implies REQUIRED match
allowedChildren = new Vector();
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);
// 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());
}
use of net.sourceforge.processdash.hier.Prop in project processdash by dtuma.
the class HierarchyEditor method setStatusRecursive.
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);
}
Aggregations