use of net.sourceforge.processdash.process.ScriptID in project processdash by dtuma.
the class ScriptMenuBuilder method groupScriptsByDataPath.
private List<List<ScriptID>> groupScriptsByDataPath(List<ScriptID> scripts) {
List<List<ScriptID>> result = new ArrayList<List<ScriptID>>();
String currentPath = null;
List<ScriptID> currentScripts = null;
for (ScriptID s : scripts) {
String newDataPath = s.getDataPath();
if (newDataPath == null)
continue;
if (!newDataPath.equals(currentPath)) {
if (currentScripts != null)
result.add(currentScripts);
currentScripts = new ArrayList<ScriptID>();
}
currentPath = newDataPath;
currentScripts.add(s);
}
if (currentScripts != null)
result.add(currentScripts);
return result;
}
use of net.sourceforge.processdash.process.ScriptID in project processdash by dtuma.
the class WorkflowScriptSource method getScripts.
public List<ScriptID> getScripts(String path) {
// Get the list of workflow URL specs for the enclosing team project.
DataRepository data = context.getData();
StringBuffer projectPathBuf = new StringBuffer(path);
ListData urlSpecList = ListData.asListData(data.getInheritableValue(projectPathBuf, dataName));
// this team project doesn't have any associated workflow URLs.
if (urlSpecList == null || urlSpecList.test() == false)
return null;
// construct a list of path segments we should examine. The first
// segment is the path to the team project itself. Then we include
// the name of each nested component or subtask within the project
// on the path to the currently active task.
String projectPath = projectPathBuf.toString();
List<String> pathSegments = new ArrayList<String>();
pathSegments.add(projectPath);
if (path.length() > projectPath.length() + 1) {
String relSubpath = path.substring(projectPath.length() + 1);
pathSegments.addAll(Arrays.asList(relSubpath.split("/")));
}
// find the list of workflow scripts that are associated with the
// currently active task and its ancestors.
LinkedHashSet result = collectScripts(data, urlSpecList, pathSegments);
if (result.isEmpty())
return null;
// for efficiency purposes, we built the list in backwards order.
// reverse it so the URLs appear in the order the user wrote them.
ArrayList<ScriptID> listResult = new ArrayList<ScriptID>(result);
Collections.reverse(listResult);
return listResult;
}
use of net.sourceforge.processdash.process.ScriptID 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.process.ScriptID in project processdash by dtuma.
the class ScriptMenuReplicator method addMenuItems.
private void addMenuItems(Menu destMenu, List menuItems, int pos) {
for (Object item : menuItems) {
if (item instanceof String) {
String dataPath = (String) item;
destMenu.insert(new ScriptMenuSeparator(), ++pos);
destMenu.insert(new ScriptMenuHeader(dataPath), ++pos);
} else if (item instanceof ScriptID) {
ScriptID script = (ScriptID) item;
destMenu.insert(new ScriptMenuItem(script), ++pos);
} else if (item instanceof List) {
Menu submenu = new ScriptMenuSubmenu();
destMenu.insert(submenu, ++pos);
addMenuItems(submenu, (List) item, -1);
} else {
System.out.println("Warning! Unrecognized menu item type " + item);
}
}
}
Aggregations