use of net.sourceforge.processdash.hier.PropertyKey in project processdash by dtuma.
the class MoveTeamDirMessageHandler method findProject.
private String findProject(PropertyKey node, String id) {
String templateID = ctx.getHierarchy().getID(node);
if (indivRootTemplateIDs.contains(templateID)) {
String path = node.path();
String idDataName = DataRepository.createDataName(path, TeamDataConstants.PROJECT_ID);
SimpleData idValue = ctx.getData().getSimpleValue(idDataName);
if (idValue != null && id.equals(idValue.format()))
return path;
else
return null;
}
for (int i = ctx.getHierarchy().getNumChildren(node); i-- > 0; ) {
PropertyKey child = ctx.getHierarchy().getChildKey(node, i);
String result = findProject(child, id);
if (result != null)
return result;
}
return null;
}
use of net.sourceforge.processdash.hier.PropertyKey in project processdash by dtuma.
the class ScriptMenuReplicator method updateScriptMenuItems.
public void updateScriptMenuItems() {
// look for the last "script menu separator" item to determine where
// the script menu entries appear in our popup menu.
int pos = popupMenu.getItemCount() - 1;
while (!(popupMenu.getItem(pos) instanceof ScriptMenuSeparator)) {
pos--;
}
// now, discard any script menu items that are currently present.
while (pos-- > 0) {
if (popupMenu.getItem(pos) instanceof ScriptItemTag)
popupMenu.remove(pos);
else
break;
}
// retrieve the current list of script menu items from the dashboard
PropertyKey currentPhase = activeTaskModel.getNode();
currentPath = (currentPhase == null ? null : currentPhase.path());
List<ScriptID> scriptItems = ScriptEnumerator.getScripts(ctx, currentPhase);
if (scriptItems != null && scriptItems.size() > 1) {
ScriptMenuBuilder b = new ScriptMenuBuilder(scriptItems);
addMenuItems(popupMenu, b.getMenuItems(), pos);
}
}
use of net.sourceforge.processdash.hier.PropertyKey in project processdash by dtuma.
the class HierarchyNoteEditorDialog method getSelectedNode.
private PropertyKey getSelectedNode() {
TreePath selection = tree.getSelectionPath();
PropertyKey selectedNode = null;
if (selection != null)
selectedNode = treeModel.getKeyForNode(selection.getLastPathComponent());
return selectedNode;
}
use of net.sourceforge.processdash.hier.PropertyKey in project processdash by dtuma.
the class HierarchyEditor method moveUp.
private void moveUp(DefaultMutableTreeNode node) {
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);
parentNode.insert(node, index - 1);
treeModel.useTreeModelListener(true);
treeModel.nodeStructureChanged(parentNode);
setDirty(true);
}
use of net.sourceforge.processdash.hier.PropertyKey in project processdash by dtuma.
the class HierarchyEditor method updateTemplateMenu.
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;
// clear the JMenu
addTemplateMenu.removeAll();
// System.out.println("Update:" + id);
for (int ii = 0; ii < templates.getNumChildren(tKey); ii++) {
p = templates.pget(templates.getChildKey(tKey, ii));
// 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;
StringTokenizer st = new StringTokenizer(val.substring(idx + 1), String.valueOf(REQUIRED_PARENT));
while (st.hasMoreElements() && !found) found = id.equals(st.nextElement());
if (!found)
continue;
}
val = templates.getChildName(tKey, ii);
String display = Prop.unqualifiedName(val);
// System.out.println("Update: passed " + val);
enableMenu = true;
if (addTemplateMenu.getItemCount() > 18)
addTemplateMenu = (JMenu) addTemplateMenu.add(new JMenu(resource.getDlgString("More")), 0);
menuItem = addTemplateMenu.add(new JMenuItem(display));
menuItem.addActionListener(new AddTemplateAction(val));
}
this.addTemplateMenu.setEnabled(enableMenu);
}
Aggregations