Search in sources :

Example 1 with EntryMarks

use of org.omegat.gui.editor.mark.EntryMarks in project omegat by omegat-org.

the class EditorController method markActiveEntrySource.

/**
 * {@inheritDoc}
 */
public void markActiveEntrySource(final SourceTextEntry requiredActiveEntry, final List<Mark> marks, final String markerClassName) {
    UIThreadsUtil.mustBeSwingThread();
    for (Mark m : marks) {
        if (m.entryPart != Mark.ENTRY_PART.SOURCE) {
            throw new RuntimeException("Mark must be for source only");
        }
    }
    SourceTextEntry realActive = m_docSegList[displayedEntryIndex].ste;
    if (realActive != requiredActiveEntry) {
        return;
    }
    int mi = markerController.getMarkerIndex(markerClassName);
    EntryMarks ev = new EntryMarks(m_docSegList[displayedEntryIndex], m_docSegList[displayedEntryIndex].getDisplayVersion(), mi);
    ev.result = marks;
    markerController.queueMarksOutput(ev);
}
Also used : EntryMarks(org.omegat.gui.editor.mark.EntryMarks) SourceTextEntry(org.omegat.core.data.SourceTextEntry) Mark(org.omegat.gui.editor.mark.Mark) Point(java.awt.Point)

Example 2 with EntryMarks

use of org.omegat.gui.editor.mark.EntryMarks in project omegat by omegat-org.

the class MarkerController method reprocessImmediately.

/**
 * Reprocess one entry immediately, in current thread. Usually used for
 * active entry.
 */
public void reprocessImmediately(SegmentBuilder entryBuilder) {
    UIThreadsUtil.mustBeSwingThread();
    entryBuilder.resetTextAttributes();
    List<EntryMarks> evs = new ArrayList<EntryMarks>();
    for (int i = 0; i < markerNames.length; i++) {
        remove(entryBuilder, i);
        try {
            EntryMarks ev = new EntryMarks(entryBuilder, entryBuilder.getDisplayVersion(), i);
            ev.result = markerThreads[i].marker.getMarksForEntry(ev.ste, ev.sourceText, ev.translationText, ev.isActive);
            if (ev.result != null) {
                evs.add(ev);
            }
        } catch (Throwable ex) {
            Log.log(ex);
        }
    }
    marksOutput(evs);
}
Also used : EntryMarks(org.omegat.gui.editor.mark.EntryMarks) ArrayList(java.util.ArrayList)

Example 3 with EntryMarks

use of org.omegat.gui.editor.mark.EntryMarks in project omegat by omegat-org.

the class MarkerController method marksOutput.

/**
 * Output marks.
 */
private void marksOutput(List<EntryMarks> evs) {
    UIThreadsUtil.mustBeSwingThread();
    if (evs.isEmpty()) {
        return;
    }
    Document3 doc = ec.editor.getOmDocument();
    doc.trustedChangesInProgress = true;
    try {
        for (int i = 0; i < evs.size(); i++) {
            EntryMarks ev = evs.get(i);
            if (!ev.isSegmentChanged()) {
                remove(ev.builder, ev.markerIndex);
                try {
                    if (ev.builder.marks == null) {
                        ev.builder.marks = new MarkInfo[markerNames.length][];
                    }
                    ev.builder.marks[ev.markerIndex] = new MarkInfo[ev.result.size()];
                    for (int j = 0; j < ev.result.size(); j++) {
                        MarkInfo nm = new MarkInfo(ev.result.get(j), ev.builder, doc, highlighter);
                        ev.builder.marks[ev.markerIndex][j] = nm;
                    }
                } catch (BadLocationException ex) {
                }
            }
        }
    } finally {
        doc.trustedChangesInProgress = false;
    }
}
Also used : EntryMarks(org.omegat.gui.editor.mark.EntryMarks) BadLocationException(javax.swing.text.BadLocationException)

Aggregations

EntryMarks (org.omegat.gui.editor.mark.EntryMarks)3 Point (java.awt.Point)1 ArrayList (java.util.ArrayList)1 BadLocationException (javax.swing.text.BadLocationException)1 SourceTextEntry (org.omegat.core.data.SourceTextEntry)1 Mark (org.omegat.gui.editor.mark.Mark)1