Search in sources :

Example 1 with Word

use of net.sourceforge.processdash.ui.lib.autocomplete.AssignedToDocument.Word in project processdash by dtuma.

the class AssignedToComboBoxAdaptor method markCurrentWord.

public void markCurrentWord() {
    JTextComponent text = getTextComponent();
    AssignedToDocument doc = (AssignedToDocument) text.getDocument();
    int caretPos = text.getCaretPosition();
    Word w = doc.getWord(caretPos);
    if (w != null) {
        markWord(w);
        if (w.isNumber())
            w = w.prev;
        if (w != null && w.isLetters()) {
            String val = doc.getWordText(w);
            if (!val.equals(getSelectedItemAsString()))
                doc.setSelectedItem(val);
        }
    }
}
Also used : Word(net.sourceforge.processdash.ui.lib.autocomplete.AssignedToDocument.Word) JTextComponent(javax.swing.text.JTextComponent)

Example 2 with Word

use of net.sourceforge.processdash.ui.lib.autocomplete.AssignedToDocument.Word in project processdash by dtuma.

the class AssignedToComboBox method getTrackedChanges.

public AssignedToEditList getTrackedChanges() {
    if (initialTrackedState == null)
        throw new IllegalStateException("No tracked changes");
    AssignedToEditList result = new AssignedToEditList();
    List<Word> words = document.getWords();
    Word w = (words.isEmpty() ? null : words.get(0));
    for (TrackableItem item : initialTrackedState) {
        // create a change representing this original tracked item
        AssignedToEditList.Change change = new AssignedToEditList.Change();
        change.origInitials = item.origInitials;
        change.origTime = item.origTime;
        result.add(change);
        if (w != null && w.end <= item.end.getOffset()) {
            // if a matching set of initials is present in the document,
            // store those as the new initials for this change
            change.newInitials = document.getWordText(w);
            w = w.next;
            // our tracked change too
            if (w != null && w.isNumber()) {
                change.newTime = document.getWordText(w);
                w = w.next;
            }
        }
    }
    // if any words are left in the document, they represent additions
    while (w != null) {
        AssignedToEditList.Change change = new AssignedToEditList.Change();
        change.newInitials = document.getWordText(w);
        result.add(change);
        w = w.next;
        // our tracked change too
        if (w != null && w.isNumber()) {
            change.newTime = document.getWordText(w);
            w = w.next;
        }
    }
    return result;
}
Also used : Word(net.sourceforge.processdash.ui.lib.autocomplete.AssignedToDocument.Word)

Example 3 with Word

use of net.sourceforge.processdash.ui.lib.autocomplete.AssignedToDocument.Word in project processdash by dtuma.

the class AssignedToComboBox method startTrackingChanges.

public void startTrackingChanges() {
    initialTrackedState = new ArrayList();
    List<Word> words = document.getWords();
    Word w = (words.isEmpty() ? null : words.get(0));
    while (w != null) {
        // build trackable items for each set of initials
        TrackableItem item = new TrackableItem();
        item.origInitials = document.getWordText(w);
        int itemEndPos = w.end;
        w = w.next;
        // if the initials are followed by a number, add it to our item info
        if (w != null && w.isNumber()) {
            item.origTime = document.getWordText(w);
            itemEndPos = w.end + 1;
            w = w.next;
        }
        // create a document Position to track the end of this item
        try {
            item.end = document.createPosition(itemEndPos);
            initialTrackedState.add(item);
        } catch (BadLocationException ble) {
        }
    }
}
Also used : Word(net.sourceforge.processdash.ui.lib.autocomplete.AssignedToDocument.Word) ArrayList(java.util.ArrayList) BadLocationException(javax.swing.text.BadLocationException)

Aggregations

Word (net.sourceforge.processdash.ui.lib.autocomplete.AssignedToDocument.Word)3 ArrayList (java.util.ArrayList)1 BadLocationException (javax.swing.text.BadLocationException)1 JTextComponent (javax.swing.text.JTextComponent)1