Search in sources :

Example 86 with PropertyKey

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

Example 87 with PropertyKey

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

Example 88 with PropertyKey

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;
}
Also used : StringTokenizer(java.util.StringTokenizer) PropertyKey(net.sourceforge.processdash.hier.PropertyKey)

Example 89 with PropertyKey

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

Example 90 with PropertyKey

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);
}
Also used : PropertyKey(net.sourceforge.processdash.hier.PropertyKey) Date(java.util.Date) IOException(java.io.IOException) NoSuchElementException(java.util.NoSuchElementException)

Aggregations

PropertyKey (net.sourceforge.processdash.hier.PropertyKey)125 DashHierarchy (net.sourceforge.processdash.hier.DashHierarchy)40 Prop (net.sourceforge.processdash.hier.Prop)16 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)10 SimpleData (net.sourceforge.processdash.data.SimpleData)7 ArrayList (java.util.ArrayList)6 Enumeration (java.util.Enumeration)6 IOException (java.io.IOException)5 Iterator (java.util.Iterator)5 StringTokenizer (java.util.StringTokenizer)5 TreePath (javax.swing.tree.TreePath)5 ListData (net.sourceforge.processdash.data.ListData)5 DefectLog (net.sourceforge.processdash.log.defects.DefectLog)5 List (java.util.List)4 ProcessDashboard (net.sourceforge.processdash.ProcessDashboard)4 HierarchyAlterer (net.sourceforge.processdash.hier.HierarchyAlterer)4 HierarchyAlterationException (net.sourceforge.processdash.hier.HierarchyAlterer.HierarchyAlterationException)4 DefectLogID (net.sourceforge.processdash.log.defects.DefectLogID)4 TinyCGIException (net.sourceforge.processdash.net.http.TinyCGIException)4 Point (java.awt.Point)3