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();
}
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"));
}
}
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);
}
}
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>");
}
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);
}
}
}
Aggregations