use of net.sourceforge.processdash.hier.PropertyKey in project processdash by dtuma.
the class HierarchyNoteEditorDialog method valueChanged.
public void valueChanged(TreeSelectionEvent e) {
// gets modified. As a side effect, a users can't deselect a node.
if (!changingSelectionProgrammatically && e.getNewLeadSelectionPath() == null && nodeCommentShowedByEditor != null) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
setSelectedNode(nodeCommentShowedByEditor);
}
});
return;
}
if (saveRevertOrCancel(false)) {
PropertyKey selectedNode = getSelectedNode();
showEditorFor(selectedNode);
updateButtons();
}
}
use of net.sourceforge.processdash.hier.PropertyKey in project processdash by dtuma.
the class HierarchyEditor method moveUpIsLegal.
private boolean moveUpIsLegal(PropertyKey key) {
Prop prop = useProps.pget(key);
if (!isMoveable(prop.getStatus()))
return false;
PropertyKey parentKey = key.getParent();
Prop parentProp = useProps.pget(parentKey);
int pos = -1;
for (int i = parentProp.getNumChildren(); i-- > 0; ) if (key.equals(parentProp.getChild(pos = i)))
break;
if (pos < 1)
return false;
PropertyKey siblingKey = parentProp.getChild(pos - 1);
Prop siblingProp = useProps.pget(siblingKey);
return isMoveable(siblingProp.getStatus());
}
use of net.sourceforge.processdash.hier.PropertyKey in project processdash by dtuma.
the class HierarchyEditor method isReservedChildName.
private boolean isReservedChildName(Prop parent, String newName) {
String status = parent.getStatus();
if (status == null)
return false;
int parseIndex = status.indexOf(ALLOWED_CHILD);
if (parseIndex == -1)
return false;
int lastChar = status.indexOf(REQUIRED_PARENT);
if (lastChar == -1)
lastChar = status.length();
if (lastChar <= parseIndex + 1)
return false;
status = status.substring(parseIndex + 1, lastChar);
StringTokenizer st = new StringTokenizer(status, String.valueOf(ALLOWED_CHILD));
while (st.hasMoreElements()) {
String childID = st.nextToken();
int endIndex = childID.indexOf("(");
if (endIndex != -1)
childID = childID.substring(0, endIndex);
PropertyKey childKey = templates.getByID(childID);
if (childKey == null)
continue;
if (!templateIsMalleable(childKey) && newName.equals(Prop.unqualifiedName(childKey.name())))
return true;
}
return false;
}
use of net.sourceforge.processdash.hier.PropertyKey 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.hier.PropertyKey in project processdash by dtuma.
the class OldStyleTimeLogReader method parseOldStyleEntry.
static TimeLogEntryVO parseOldStyleEntry(long entryID, String s) {
int startPosition = 0;
int endPosition = s.indexOf(TAB, startPosition);
String path = null;
if (startPosition < endPosition) {
PropertyKey key = PropertyKey.valueOf(s.substring(startPosition, endPosition));
if (key == null)
key = PropertyKey.fromKey(s.substring(startPosition, endPosition));
if (key != null)
path = key.path();
}
if (path == null)
throw new IllegalArgumentException("Invalid Key");
startPosition = s.indexOf(START, endPosition) + START.length();
endPosition = s.indexOf(TAB, startPosition);
Date startTime = FormatUtil.parseDateTime(s.substring(startPosition, endPosition));
if (startTime == null)
throw new IllegalArgumentException("Invalid Start Time");
startPosition = s.indexOf(ELAPSED, endPosition) + ELAPSED.length();
endPosition = s.indexOf(TAB, startPosition);
long minutesElapsed = 0;
try {
minutesElapsed = Long.valueOf(s.substring(startPosition, endPosition)).longValue();
} catch (Exception e) {
throw new IllegalArgumentException("Invalid Elapsed Time");
}
startPosition = s.indexOf(INTERRUPT, endPosition) + INTERRUPT.length();
endPosition = s.indexOf(TAB, startPosition);
long minutesInterrupt = 0;
try {
String minInterrupt;
if (endPosition == -1)
minInterrupt = s.substring(startPosition);
else
minInterrupt = s.substring(startPosition, endPosition);
minutesInterrupt = Long.parseLong(minInterrupt);
} catch (Exception e) {
throw new IllegalArgumentException("Invalid Interrupt Time");
}
String comment = null;
if (endPosition != -1)
comment = s.substring(endPosition + 1).replace('', '\n');
return new TimeLogEntryVO(entryID, path, startTime, minutesElapsed, minutesInterrupt, comment);
}
Aggregations