Search in sources :

Example 1 with ScriptID

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

the class ScriptBrowser method applyFilter.

private void applyFilter() {
    list.getSelectionModel().clearSelection();
    scriptList.clear();
    DefaultMutableTreeNode selected = getSelectedNode();
    if (selected == null)
        return;
    PropertyKey key = treeModel.getPropKey(useProps, selected.getPath());
    if (key == null)
        return;
    List<ScriptID> scripts = ScriptEnumerator.getScripts(dashboard, key);
    if (scripts == null || scripts.size() == 0)
        return;
    ScriptID script, defaultScript = scripts.get(0);
    String dataPath = defaultScript.getDataPath();
    for (int i = 1; i < scripts.size(); i++) {
        script = scripts.get(i);
        if (dataPath != null && !dataPath.equals(script.getDataPath()))
            break;
        scriptList.addElement(script);
        dataPath = script.getDataPath();
        if (defaultScript.scriptEquals(script))
            list.getSelectionModel().addSelectionInterval(i - 1, i - 1);
    }
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) ScriptID(net.sourceforge.processdash.process.ScriptID) PropertyKey(net.sourceforge.processdash.hier.PropertyKey)

Example 2 with ScriptID

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

the class ScriptBrowser method showSelectedScript.

protected void showSelectedScript() {
    int selectedIndex = list.getMinSelectionIndex();
    if (selectedIndex == -1)
        return;
    ScriptID id = (ScriptID) scriptList.elementAt(selectedIndex);
    id.display();
    if (!keepDialogOpen)
        dispose();
}
Also used : ScriptID(net.sourceforge.processdash.process.ScriptID)

Example 3 with ScriptID

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

the class TeamProjectBrowser method showSelectedScript.

/**
     * Display the script that is currently selected
     * 
     * @param clearSelection
     *            if true, clear the selection after displaying the script
     * @param evt
     *            the mouse click event that triggered this action; can be null
     */
private void showSelectedScript(boolean clearSelection, MouseEvent evt) {
    // find out which item is currently selected
    int selectedIndex = scriptList.getMinSelectionIndex();
    if (selectedIndex == -1)
        return;
    // somewhere within the empty space of the JList.
    if (evt != null && evt.getPoint() != null) {
        Rectangle selectedCellBounds = scriptList.getCellBounds(selectedIndex, selectedIndex);
        if (selectedCellBounds != null && !selectedCellBounds.contains(evt.getPoint()))
            return;
    }
    ScriptID id = (ScriptID) scripts.elementAt(selectedIndex);
    if (id.getScript() == null)
        return;
    UserFilter f = UserGroupManager.getInstance().getGlobalFilter();
    UserGroupManagerDash.getInstance().setLocalFilter(id.getDataPath(), f);
    id.display();
    if (clearSelection)
        scriptList.clearSelection();
}
Also used : Rectangle(java.awt.Rectangle) UserFilter(net.sourceforge.processdash.team.group.UserFilter) ScriptID(net.sourceforge.processdash.process.ScriptID)

Example 4 with ScriptID

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

the class WorkflowScriptSource method addScriptsFromUrlSpec.

/**
     * Parse a URL specification, construct ScriptIDs, and add them to a list.
     * 
     * @param result the list that ScriptID objects should be added to
     * @param dataPath the dashboard hierarchy path that should be used when
     *     creating the ScriptID objects
     * @param oneUrlSpec a String of the format
     *     <code>(http...[ display name])+</code>.  That is, a
     *     whitespace-separated list of HTTP URLs, each one optionally
     *     followed by whitespace and a free text display name.
     */
private void addScriptsFromUrlSpec(Set<ScriptID> result, String dataPath, String oneUrlSpec) {
    while (oneUrlSpec.length() > 0) {
        int pos = oneUrlSpec.lastIndexOf("http");
        if (pos == -1)
            break;
        String oneUrl = oneUrlSpec.substring(pos).trim();
        String oneDisplayName = null;
        Matcher m = WHITESPACE_PAT.matcher(oneUrl);
        if (m.find()) {
            oneDisplayName = oneUrl.substring(m.end());
            oneUrl = oneUrl.substring(0, m.start());
        }
        result.add(new ScriptID(oneUrl, dataPath, oneDisplayName));
        oneUrlSpec = oneUrlSpec.substring(0, pos);
    }
}
Also used : Matcher(java.util.regex.Matcher) ScriptID(net.sourceforge.processdash.process.ScriptID)

Example 5 with ScriptID

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

the class TemplateLoader method generateDefaultScriptMaps.

private static void generateDefaultScriptMaps(Element e) {
    NodeList templates = e.getElementsByTagName(TEMPLATE_NODE_NAME);
    int len = templates.getLength();
    for (int i = 0; i < len; i++) try {
        Element template = (Element) templates.item(i);
        String ID = template.getAttribute(ID_ATTR);
        if (!hasValue(ID))
            continue;
        if (hasValue(template.getAttribute(HTML_HREF_ATTR)))
            continue;
        // if there is no script ID for this element, and it
        // hasn't specifically requested otherwise, give it a
        // default href.
        Vector v = (Vector) scriptMaps.get(ID);
        if (v == null)
            scriptMaps.put(ID, (v = new Vector()));
        if (v.size() == 0) {
            String planSummaryName = Resources.getDashBundle("Templates").format("Plan_Summary_Name_FMT", ID);
            v.addElement(new ScriptID("dash/summary.shtm", null, planSummaryName));
            debug("adding default HTML form for " + ID);
        }
    } catch (ClassCastException cce) {
    }
}
Also used : NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) ScriptID(net.sourceforge.processdash.process.ScriptID) Vector(java.util.Vector)

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