Package org.omegat.gui.editor
Class EditorController
java.lang.Object
org.omegat.gui.editor.EditorController
- All Implemented Interfaces:
IEditor
Class for control all editor operations.
You can find good description of java text editor working at Using the Swing Text Package * that was originally found at http://java.sun.com/products/jfc/tsc/articles/text/overview/
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.omegat.gui.editor.IEditor
IEditor.CaretPosition, IEditor.CHANGE_CASE_TO -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidActivate entry for edit.voidActivates the current entry (if available) by displaying source text and embedding displayed text in markers.voidactivateEntryAndGotoOffset(int offset) voidchangeCase(IEditor.CHANGE_CASE_TO toWhat) Change case of the selected text or if none is selected, of the current word.voidCommits the translation.voidCommits the translation and leave entry activated.Access the AutoCompleter@Nullable SourceTextEntryGet current active entry.intGet current active entry number.@Nullable StringGet relative path (undersource) of the source file currently open in the editor.intReturns current caret position in the editable translation.Get the current position in the entity translation in the editor@Nullable SegmentBuilder@Nullable StringGet the relative path (undertarget) of the target file corresponding to the current source file (perIEditor.getCurrentFile()).Returns current translation or null.Gets a filter for this editor, or null if filter doesn't applied.intgetPositionInEntryTranslation(int pos) Returns the relative caret position in the editable translation for a given absolute index into the overall editor document.Get currently selected text.Get settings instance.voidgotoEntry(int entryNum) Goto entry with specified number.voidgotoEntry(int entryNum, IEditor.CaretPosition pos) Goto entry with specified number, and restore caret to specified position.voidGoto entry based on a string and entry key.voidgotoEntryAfterFix(int entryNum, String fixedSource) Goto entry with specified number while avoiding clobbering the tag fixes.voidgotoFile(int fileIndex) Goto first entry in specified file.voidGo to previous segment from history.voidGo to next segment from history.voidInserts tag at the cursor position, probably with adding bidi control chars.voidinsertText(String text) Inserts text at the cursor position.voidinsertTextAndMark(String text) Inserts text at the cursor position and mark as to be changed by the translator, i.e, background of segment should be marked Must be called only from UI thread.booleanThe orientation of the document is all LtR.voidmarkActiveEntrySource(SourceTextEntry requiredActiveEntry, List<Mark> marks, String markerClassName) All plugins can call this method for mark something in active entry.voidMove to next entry.voidFinds the next entry with a non-empty note.voidFinds the next translated entry in the document.voidFind the next unique entry.voidFinds the next untranslated entry in the document.voidFinds the next/previous x-auto translated entryvoidFinds the next/previous x-enforced translated entryvoidMove to previous entry.voidFinds the previous entry with a non-empty note.voidMove to previous x-auto translated entry.voidMove to previous x-enforced translated entry.voidredo()Redo editing.voidrefreshEntries(Set<Integer> entryNumbers) Refresh some entries.voidrefreshView(boolean doCommit) voidrefreshViewAfterFix(@Nullable List<Integer> fixedEntries) Refresh the current editor view while avoiding clobbering any tag fixes.voidRegister as empty.voidRegister translation to be identical to source.voidregisterPopupMenuConstructors(int priority, IPopupMenuConstructor constructor) Register constructor of popup menu.voidRegister untranslated.voidremarkOneMarker(String markerClassName) Calls specified marker for reprocess all entries.voidRemoves the current filter.voidreplaceEditText(String text) Replaces the entire edit area with a given text.voidreplaceEditText(String text, String origin) Replaces the entire edit area with a given text which origin is origin.voidreplaceEditTextAndMark(String text) Inserts text at the cursor position and mark as to be changed by the translator, i.e, background of segment should be marked Must be called only from UI thread.voidreplaceEditTextAndMark(String text, String origin) Replace text and mark as to be changed by the translator from origin, i.e, background of segment should be marked Must be called only from UI thread.voidreplacePartOfText(String text, int start, int end) voidSet current focus to editor.voidSelect the source text of the current segment.voidsetAlternateTranslationForCurrentEntry(boolean alternate) Set default/alternate translation for current entry.voidvoidsetFilter(IEditorFilter filter) Sets a filter to this editor.voidshowStat()Calculate statistic for file, request statistic for project and display in status bar.voidundo()Undo editing.voidPerform any necessary actions for window deactivation.
-
Constructor Details
-
EditorController
-
-
Method Details
-
isOrientationAllLtr
public boolean isOrientationAllLtr()The orientation of the document is all LtR.- Specified by:
isOrientationAllLtrin interfaceIEditor- Returns:
- true when the orientation is all RtL. otherwise false.
-
requestFocus
public void requestFocus()Description copied from interface:IEditorSet current focus to editor.- Specified by:
requestFocusin interfaceIEditor
-
getCurrentEntry
Description copied from interface:IEditorGet current active entry. Can be called from any thread.- Specified by:
getCurrentEntryin interfaceIEditor
-
getCurrentSegmentBuilder
-
getCurrentFile
Description copied from interface:IEditorGet relative path (undersource) of the source file currently open in the editor.Can be called from any thread.
- Specified by:
getCurrentFilein interfaceIEditor
-
getCurrentTargetFile
Description copied from interface:IEditorGet the relative path (undertarget) of the target file corresponding to the current source file (perIEditor.getCurrentFile()). This file is what is created upon doing Create Target Documents, but it may not exist yet.Can be called from any thread.
- Specified by:
getCurrentTargetFilein interfaceIEditor
-
activateEntry
public void activateEntry()Description copied from interface:IEditorActivate entry for edit. Must be called only from UI thread. Will position cursor at the start of segment- Specified by:
activateEntryin interfaceIEditor
-
activateEntryAndGotoOffset
public void activateEntryAndGotoOffset(int offset) -
activateEntry
Activates the current entry (if available) by displaying source text and embedding displayed text in markers.Also moves document focus to the current entry and makes sure fuzzy info displayed if available.
-
showStat
public void showStat()Calculate statistic for file, request statistic for project and display in status bar. -
refreshEntries
Refresh some entries. Usually after external translation changes replacement. -
commitAndDeactivate
public void commitAndDeactivate()Commits the translation. Reads current entry text and commit it to memory if it's changed. Also clears out segment markers while we're at it.Since 1.6: Translation equal to source may be validated as OK translation if appropriate option is set in Workflow options dialog.
All displayed segments with the same source text updated also.
- Specified by:
commitAndDeactivatein interfaceIEditor
-
commitAndLeave
public void commitAndLeave()Description copied from interface:IEditorCommits the translation and leave entry activated. Translation will be saved. Must be called only from UI thread.- Specified by:
commitAndLeavein interfaceIEditor
-
nextEntry
public void nextEntry()Description copied from interface:IEditorMove to next entry. Must be called only from UI thread. -
prevEntry
public void prevEntry()Description copied from interface:IEditorMove to previous entry. Must be called only from UI thread. -
nextUntranslatedEntry
public void nextUntranslatedEntry()Finds the next untranslated entry in the document.- Specified by:
nextUntranslatedEntryin interfaceIEditor
-
nextTranslatedEntry
public void nextTranslatedEntry()Finds the next translated entry in the document.- Specified by:
nextTranslatedEntryin interfaceIEditor
-
nextXAutoEntry
public void nextXAutoEntry()Finds the next/previous x-auto translated entry- Specified by:
nextXAutoEntryin interfaceIEditor
-
prevXAutoEntry
public void prevXAutoEntry()Description copied from interface:IEditorMove to previous x-auto translated entry. Must be called only from UI thread.- Specified by:
prevXAutoEntryin interfaceIEditor
-
nextXEnforcedEntry
public void nextXEnforcedEntry()Finds the next/previous x-enforced translated entry- Specified by:
nextXEnforcedEntryin interfaceIEditor
-
prevXEnforcedEntry
public void prevXEnforcedEntry()Description copied from interface:IEditorMove to previous x-enforced translated entry. Must be called only from UI thread.- Specified by:
prevXEnforcedEntryin interfaceIEditor
-
nextEntryWithNote
public void nextEntryWithNote()Finds the next entry with a non-empty note.- Specified by:
nextEntryWithNotein interfaceIEditor
-
prevEntryWithNote
public void prevEntryWithNote()Finds the previous entry with a non-empty note.- Specified by:
prevEntryWithNotein interfaceIEditor
-
nextUniqueEntry
public void nextUniqueEntry()Find the next unique entry.- Specified by:
nextUniqueEntryin interfaceIEditor
-
getCurrentEntryNumber
public int getCurrentEntryNumber()Description copied from interface:IEditorGet current active entry number. Can be called from any thread.- Specified by:
getCurrentEntryNumberin interfaceIEditor
-
gotoFile
public void gotoFile(int fileIndex) Description copied from interface:IEditorGoto first entry in specified file. -
gotoEntry
public void gotoEntry(int entryNum) Description copied from interface:IEditorGoto entry with specified number. Convenience method forIEditor.gotoEntry(int, CaretPosition)where the caret position will be the start of the entry. -
gotoEntry
Description copied from interface:IEditorGoto entry with specified number, and restore caret to specified position. -
gotoEntry
Description copied from interface:IEditorGoto entry based on a string and entry key. -
gotoEntryAfterFix
Description copied from interface:IEditorGoto entry with specified number while avoiding clobbering the tag fixes.- Specified by:
gotoEntryAfterFixin interfaceIEditor- Parameters:
entryNum- entry number, starts from 1fixedSource- The source of the entry that was fixed Must be called only from UI thread.
-
refreshViewAfterFix
Description copied from interface:IEditorRefresh the current editor view while avoiding clobbering any tag fixes.- Specified by:
refreshViewAfterFixin interfaceIEditor- Parameters:
fixedEntries- A list of all entries that were altered Must be called only from UI thread.
-
refreshView
public void refreshView(boolean doCommit) - Specified by:
refreshViewin interfaceIEditor
-
changeCase
Change case of the selected text or if none is selected, of the current word.- Specified by:
changeCasein interfaceIEditor- Parameters:
toWhat- : lower, title, upper, or cycle
-
replaceEditText
Description copied from interface:IEditorReplaces the entire edit area with a given text. Must be called only from UI thread.- Specified by:
replaceEditTextin interfaceIEditor
-
replaceEditText
Description copied from interface:IEditorReplaces the entire edit area with a given text which origin is origin.when manual edit and origin is unknown, origin will be null. Must be called only from UI thread.
- Specified by:
replaceEditTextin interfaceIEditor
-
replacePartOfText
-
replaceEditTextAndMark
Description copied from interface:IEditorReplace text and mark as to be changed by the translator from origin, i.e, background of segment should be marked Must be called only from UI thread.- Specified by:
replaceEditTextAndMarkin interfaceIEditor
-
replaceEditTextAndMark
Description copied from interface:IEditorInserts text at the cursor position and mark as to be changed by the translator, i.e, background of segment should be marked Must be called only from UI thread.- Specified by:
replaceEditTextAndMarkin interfaceIEditor
-
getCurrentTranslation
Description copied from interface:IEditorReturns current translation or null.- Specified by:
getCurrentTranslationin interfaceIEditor
-
getCurrentPositionInEntryTranslation
public int getCurrentPositionInEntryTranslation()Returns current caret position in the editable translation. -
getPositionInEntryTranslation
public int getPositionInEntryTranslation(int pos) Returns the relative caret position in the editable translation for a given absolute index into the overall editor document. -
setCaretPosition
-
insertText
Description copied from interface:IEditorInserts text at the cursor position. Must be called only from UI thread.- Specified by:
insertTextin interfaceIEditor
-
insertTextAndMark
Description copied from interface:IEditorInserts text at the cursor position and mark as to be changed by the translator, i.e, background of segment should be marked Must be called only from UI thread.- Specified by:
insertTextAndMarkin interfaceIEditor- Parameters:
text- The text to insert
-
insertTag
Description copied from interface:IEditorInserts tag at the cursor position, probably with adding bidi control chars. Must be called only from UI thread. -
selectSourceText
public void selectSourceText()Description copied from interface:IEditorSelect the source text of the current segment.- Specified by:
selectSourceTextin interfaceIEditor
-
gotoHistoryBack
public void gotoHistoryBack()Description copied from interface:IEditorGo to previous segment from history. Must be called only from UI thread.- Specified by:
gotoHistoryBackin interfaceIEditor
-
gotoHistoryForward
public void gotoHistoryForward()Description copied from interface:IEditorGo to next segment from history. Must be called only from UI thread.- Specified by:
gotoHistoryForwardin interfaceIEditor
-
getSettings
Description copied from interface:IEditorGet settings instance.- Specified by:
getSettingsin interfaceIEditor- Returns:
- interface for read and change editor settings Can be called from any thread.
-
undo
public void undo()Description copied from interface:IEditorUndo editing. Must be called only from UI thread. -
redo
public void redo()Description copied from interface:IEditorRedo editing. Must be called only from UI thread. -
getSelectedText
Description copied from interface:IEditorGet currently selected text.- Specified by:
getSelectedTextin interfaceIEditor- Returns:
- selected text Must be called only from UI thread.
-
remarkOneMarker
Description copied from interface:IEditorCalls specified marker for reprocess all entries.- Specified by:
remarkOneMarkerin interfaceIEditor
-
markActiveEntrySource
public void markActiveEntrySource(SourceTextEntry requiredActiveEntry, List<Mark> marks, String markerClassName) Description copied from interface:IEditorAll plugins can call this method for mark something in active entry.- Specified by:
markActiveEntrySourcein interfaceIEditor- Parameters:
requiredActiveEntry- entry which should be active. If user moved to other entry, then marks will be skippedmarks- list of marksmarkerClassName- marker's class name
-
registerPopupMenuConstructors
Description copied from interface:IEditorRegister constructor of popup menu.- Specified by:
registerPopupMenuConstructorsin interfaceIEditor- Parameters:
priority- priority of process orderconstructor- constructor instance
-
getFilter
Description copied from interface:IEditorGets a filter for this editor, or null if filter doesn't applied. -
setFilter
Sets a filter to this editor. The filter causes only the selected entries to be shown in the editor. Document is reloaded to immediately have the filter being effective. -
removeFilter
public void removeFilter()Removes the current filter. Document is reloaded if appropriate to immediately remove the filter;- Specified by:
removeFilterin interfaceIEditor
-
setAlternateTranslationForCurrentEntry
public void setAlternateTranslationForCurrentEntry(boolean alternate) Description copied from interface:IEditorSet default/alternate translation for current entry.- Specified by:
setAlternateTranslationForCurrentEntryin interfaceIEditor
-
registerUntranslated
public void registerUntranslated()Description copied from interface:IEditorRegister untranslated.- Specified by:
registerUntranslatedin interfaceIEditor
-
registerEmptyTranslation
public void registerEmptyTranslation()Description copied from interface:IEditorRegister as empty.- Specified by:
registerEmptyTranslationin interfaceIEditor
-
registerIdenticalTranslation
public void registerIdenticalTranslation()Description copied from interface:IEditorRegister translation to be identical to source.- Specified by:
registerIdenticalTranslationin interfaceIEditor
-
windowDeactivated
public void windowDeactivated()Description copied from interface:IEditorPerform any necessary actions for window deactivation.- Specified by:
windowDeactivatedin interfaceIEditor
-
getCurrentPositionInEntryTranslationInEditor
Description copied from interface:IEditorGet the current position in the entity translation in the editor- Specified by:
getCurrentPositionInEntryTranslationInEditorin interfaceIEditor- Returns:
- caret position.
-
getAlphabeticalMarkers
-
getAutoCompleter
Description copied from interface:IEditorAccess the AutoCompleter- Specified by:
getAutoCompleterin interfaceIEditor
-