Search in sources :

Example 11 with ScriptID

use of net.sourceforge.processdash.process.ScriptID in project processdash by dtuma.

the class TeamProjectBrowser method reloadScripts.

/**
     * Reload the list of scripts based on the currently active task.
     */
private void reloadScripts(PropertyKey key) {
    scripts.clear();
    List<ScriptID> newScripts = null;
    if (key != null)
        newScripts = ScriptEnumerator.getScripts(ctx, key);
    if (newScripts == null || newScripts.size() == 0) {
        // if no scripts were found, create an appropriate default entry.
        newScripts = new ArrayList<ScriptID>();
        ScriptID defaultScript = createDefaultScript(key);
        newScripts.add(defaultScript);
        newScripts.add(defaultScript);
    }
    ScriptID defaultScript = newScripts.get(0);
    String dataPath = defaultScript.getDataPath();
    for (int i = 1; i < newScripts.size(); i++) {
        ScriptID script = newScripts.get(i);
        if (dataPath != null && !dataPath.equals(script.getDataPath()))
            break;
        scripts.addElement(script);
        dataPath = script.getDataPath();
        if (defaultScript.scriptEquals(script))
            scriptList.getSelectionModel().setLeadSelectionIndex(i - 1);
    }
    if (Settings.getBool("userPref.teamScripts.useWipe", true))
        scriptList.showScriptsWithWipe();
}
Also used : ScriptID(net.sourceforge.processdash.process.ScriptID)

Example 12 with ScriptID

use of net.sourceforge.processdash.process.ScriptID in project processdash by dtuma.

the class TeamProjectBrowser method createDefaultScript.

private ScriptID createDefaultScript(PropertyKey key) {
    if (isBrokenTeamProject(key.path())) {
        String templateID = ctx.getHierarchy().pget(key).getID();
        int slashPos = templateID.indexOf('/');
        String pid = (slashPos == -1 ? "" : templateID.substring(0, slashPos));
        return new ScriptID(BrokenDataFileHandler.SHARE_MCF_URL, "", resources.format("Missing_MCF.Title_FMT", pid));
    } else {
        if (filter != null) {
            String templateID = treeProps.getID(key);
            if (NO_PROJECT_TEMPLATE_ID.equals(templateID))
                return new ScriptID(SELECT_GROUP_FILTER_URI, "ignored", resources.getString("None_Matching.Title"));
        }
        if (canCreateProjects())
            return new ScriptID(getNewProjectCreationUri(), "", resources.getString("New.Title"));
        else
            return new ScriptID(null, "", resources.getString("Select_Project"));
    }
}
Also used : ScriptID(net.sourceforge.processdash.process.ScriptID)

Example 13 with ScriptID

use of net.sourceforge.processdash.process.ScriptID in project processdash by dtuma.

the class HierarchyNoteScriptSource method extractScriptsFromNote.

private void extractScriptsFromNote(List<ScriptID> result, String path, HierarchyNote note) {
    String html = note.getAsHTML();
    if (html == null || html.length() == 0)
        return;
    Matcher m = LINK_PATTERN.matcher(html);
    while (m.find()) {
        Map attrs = HTMLUtils.parseAttributes(m.group(1));
        String href = (String) attrs.get("href");
        if (!StringUtils.hasValue(href))
            href = (String) attrs.get("HREF");
        if (!StringUtils.hasValue(href))
            return;
        String text = HTMLUtils.unescapeEntities(m.group(2));
        if (text == null || text.trim().length() == 0 || text.startsWith("http"))
            text = null;
        ScriptID s = new ScriptID(href, path, text);
        result.add(s);
    }
}
Also used : Matcher(java.util.regex.Matcher) ScriptID(net.sourceforge.processdash.process.ScriptID) Map(java.util.Map)

Example 14 with ScriptID

use of net.sourceforge.processdash.process.ScriptID in project processdash by dtuma.

the class ScriptBrowserHTML method writeContents.

protected void writeContents() throws IOException {
    String prefix = getPrefix();
    if (prefix == null)
        prefix = "";
    DashHierarchy props = getPSPProperties();
    PropertyKey key = props.findExistingKey(prefix);
    out.write("<HTML><HEAD>");
    out.write("<link rel=stylesheet type='text/css' href='/style.css'>");
    out.write("<TITLE>Hierarchy");
    if (prefix.length() > 0) {
        out.write(" - ");
        out.write(prefix);
    }
    out.write("</TITLE></HEAD><BODY>");
    if (prefix.length() > 0) {
        out.write("<B>");
        out.write(prefix);
        out.write("</B><BR>");
    }
    for (int i = 0; i < props.getNumChildren(key); i++) writeNode(props, props.getChildKey(key, i));
    List<ScriptID> scripts = ScriptEnumerator.getScripts(getDashboardContext(), key);
    if (scripts != null && scripts.size() != 0) {
        out.write("<hr>");
        for (int i = 1; i < scripts.size(); i++) writeScript(scripts.get(i));
    }
    out.write("</BODY></HTML>");
}
Also used : DashHierarchy(net.sourceforge.processdash.hier.DashHierarchy) ScriptID(net.sourceforge.processdash.process.ScriptID) PropertyKey(net.sourceforge.processdash.hier.PropertyKey)

Example 15 with ScriptID

use of net.sourceforge.processdash.process.ScriptID in project processdash by dtuma.

the class ScriptButton method addMenuItems.

private void addMenuItems(JMenu destMenu, boolean showSeparatorLabels, List menuItems) {
    for (Object item : menuItems) {
        if (item instanceof String) {
            String dataPath = (String) item;
            if (showSeparatorLabels)
                destMenu.add(new ScriptMenuSeparator(dataPath));
            else if (destMenu.getMenuComponentCount() > 0)
                destMenu.addSeparator();
        } else if (item instanceof ScriptID) {
            ScriptID script = (ScriptID) item;
            destMenu.add(new ScriptMenuItem(script));
        } else if (item instanceof List) {
            JMenu submenu = new JMenu(resources.getDlgString("More"));
            destMenu.add(submenu);
            addMenuItems(submenu, showSeparatorLabels, (List) item);
        } else {
            System.out.println("Warning! Unrecognized menu item type " + item);
        }
    }
}
Also used : ScriptID(net.sourceforge.processdash.process.ScriptID) List(java.util.List) JMenu(javax.swing.JMenu)

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