Search in sources :

Example 16 with ScriptID

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;
}
Also used : ArrayList(java.util.ArrayList) ScriptID(net.sourceforge.processdash.process.ScriptID) List(java.util.List) ArrayList(java.util.ArrayList)

Example 17 with ScriptID

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;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ArrayList(java.util.ArrayList) ScriptID(net.sourceforge.processdash.process.ScriptID) DataRepository(net.sourceforge.processdash.data.repository.DataRepository) ListData(net.sourceforge.processdash.data.ListData)

Example 18 with ScriptID

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);
    }
}
Also used : ScriptID(net.sourceforge.processdash.process.ScriptID) ScriptMenuBuilder(net.sourceforge.processdash.process.ui.ScriptMenuBuilder) PropertyKey(net.sourceforge.processdash.hier.PropertyKey)

Example 19 with ScriptID

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);
        }
    }
}
Also used : ScriptID(net.sourceforge.processdash.process.ScriptID) List(java.util.List) Menu(java.awt.Menu) PopupMenu(java.awt.PopupMenu)

Aggregations

ScriptID (net.sourceforge.processdash.process.ScriptID)19 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Vector (java.util.Vector)3 PropertyKey (net.sourceforge.processdash.hier.PropertyKey)3 Matcher (java.util.regex.Matcher)2 Menu (java.awt.Menu)1 PopupMenu (java.awt.PopupMenu)1 Rectangle (java.awt.Rectangle)1 LinkedHashSet (java.util.LinkedHashSet)1 Map (java.util.Map)1 JMenu (javax.swing.JMenu)1 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1 DataContext (net.sourceforge.processdash.data.DataContext)1 ListData (net.sourceforge.processdash.data.ListData)1 DataRepository (net.sourceforge.processdash.data.repository.DataRepository)1 DashHierarchy (net.sourceforge.processdash.hier.DashHierarchy)1 ScriptMenuBuilder (net.sourceforge.processdash.process.ui.ScriptMenuBuilder)1 UserFilter (net.sourceforge.processdash.team.group.UserFilter)1 Element (org.w3c.dom.Element)1