Package org.omegat.gui.scripting
Class ConsoleBindings
- java.lang.Object
-
- org.omegat.gui.scripting.ConsoleBindings
-
- All Implemented Interfaces:
IEditor
,IGlossaries
,IScriptLogger
public class ConsoleBindings extends java.lang.Object implements IGlossaries, IEditor, IScriptLogger
Class mocking the GUI elements when scripts are executed in console mode.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.omegat.gui.editor.IEditor
IEditor.CaretPosition, IEditor.CHANGE_CASE_TO
-
-
Constructor Summary
Constructors Constructor Description ConsoleBindings()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
activateEntry()
Activate entry for edit.void
changeCase(IEditor.CHANGE_CASE_TO newCase)
Change case of the selected text or if none is selected, of the current word.void
clear()
void
commitAndDeactivate()
Commits the translation and deactivate entry.void
commitAndLeave()
Commits the translation and leave entry activated.IAutoCompleter
getAutoCompleter()
Access the AutoCompleterSourceTextEntry
getCurrentEntry()
Get current active entry.int
getCurrentEntryNumber()
Get current active entry number.java.lang.String
getCurrentFile()
Get relative path (undersource
) of the source file currently open in the editor.java.lang.String
getCurrentTargetFile()
Get the relative path (undertarget
) of the target file corresponding to the current source file (perIEditor.getCurrentFile()
).java.lang.String
getCurrentTranslation()
Returns current translation or null.java.util.List<GlossaryEntry>
getDisplayedEntries()
IEditorFilter
getFilter()
Gets a filter for this editor, or null if filter doesn't applied.java.lang.String
getSelectedText()
Get currently selected text.IEditorSettings
getSettings()
Get settings instance.void
gotoEntry(int entryNum)
Goto entry with specified number.void
gotoEntry(int entryNum, IEditor.CaretPosition pos)
Goto entry with specified number, and restore caret to specified position.void
gotoEntry(java.lang.String srcString, EntryKey key)
Goto entry based on a string and entry key.void
gotoEntryAfterFix(int fixedEntry, java.lang.String fixedSource)
Goto entry with specified number while avoiding clobbering the tag fixes.void
gotoFile(int fileIndex)
Goto first entry in specified file.void
gotoHistoryBack()
Go to previous segment from history.void
gotoHistoryForward()
Go to next segment from history.void
insertTag(java.lang.String tag)
Inserts tag at the cursor position, probably with adding bidi control chars.void
insertText(java.lang.String text)
Inserts text at the cursor position.void
insertTextAndMark(java.lang.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.void
markActiveEntrySource(SourceTextEntry requiredActiveEntry, java.util.List<Mark> marks, java.lang.String markerClassName)
All plugins can call this method for mark something in active entry.void
nextEntry()
Move to next entry.void
nextEntryWithNote()
Move to next entry with a note.void
nextTranslatedEntry()
Move to next translated entry.void
nextUniqueEntry()
Move to the first non-unique entry.void
nextUntranslatedEntry()
Move to next untranslated entry.void
nextXAutoEntry()
Move to next x-auto translated entry.void
nextXEnforcedEntry()
Move to next x-enforced translated entry.void
prevEntry()
Move to previous entry.void
prevEntryWithNote()
Move to previous entry with a note.void
prevXAutoEntry()
Move to previous x-auto translated entry.void
prevXEnforcedEntry()
Move to previous x-enforced translated entry.void
print(java.lang.Object o)
void
println(java.lang.Object o)
void
redo()
Redo editing.void
refreshView(boolean doCommit)
void
refreshViewAfterFix(java.util.List<java.lang.Integer> fixedEntries)
Refresh the current editor view while avoiding clobbering any tag fixes.void
registerEmptyTranslation()
Register as empty.void
registerIdenticalTranslation()
Register translation to be identical to source.void
registerPopupMenuConstructors(int priority, IPopupMenuConstructor constructor)
Register constructor of popup menu.void
registerUntranslated()
Register untranslated.void
remarkOneMarker(java.lang.String markerClassName)
Calls specified marker for reprocess all entries.void
removeFilter()
Removes the current filter.void
replaceEditText(java.lang.String text)
Replaces the entire edit area with a given text.void
replaceEditText(java.lang.String text, java.lang.String origin)
Replaces the entire edit area with a given text which origin is origin.void
replaceEditTextAndMark(java.lang.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.void
replaceEditTextAndMark(java.lang.String text, java.lang.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.void
requestFocus()
Set current focus to editor.void
selectSourceText()
Select the source text of the current segment.void
setAlternateTranslationForCurrentEntry(boolean alternate)
Set default/alternate translation for current entry.void
setFilter(IEditorFilter filter)
Sets a filter to this editor.void
showCreateGlossaryEntryDialog(java.awt.Frame parent)
void
undo()
Undo editing.void
windowDeactivated()
Perform any necessary actions for window deactivation.
-
-
-
Method Detail
-
print
public final void print(java.lang.Object o)
- Specified by:
print
in interfaceIScriptLogger
-
println
public final void println(java.lang.Object o)
- Specified by:
println
in interfaceIScriptLogger
-
clear
public void clear()
- Specified by:
clear
in interfaceIScriptLogger
-
getCurrentFile
public final java.lang.String getCurrentFile()
Description copied from interface:IEditor
Get relative path (undersource
) of the source file currently open in the editor.Can be called from any thread.
- Specified by:
getCurrentFile
in interfaceIEditor
-
getCurrentTargetFile
public final java.lang.String getCurrentTargetFile()
Description copied from interface:IEditor
Get 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:
getCurrentTargetFile
in interfaceIEditor
-
getCurrentEntry
public SourceTextEntry getCurrentEntry()
Description copied from interface:IEditor
Get current active entry. Can be called from any thread.- Specified by:
getCurrentEntry
in interfaceIEditor
-
getCurrentEntryNumber
public final int getCurrentEntryNumber()
Description copied from interface:IEditor
Get current active entry number. Can be called from any thread.- Specified by:
getCurrentEntryNumber
in interfaceIEditor
-
activateEntry
public void activateEntry()
Description copied from interface:IEditor
Activate entry for edit. Must be called only from UI thread. Will position cursor at the start of segment- Specified by:
activateEntry
in interfaceIEditor
-
commitAndDeactivate
public void commitAndDeactivate()
Description copied from interface:IEditor
Commits the translation and deactivate entry. Translation will be saved. Must be called only from UI thread.- Specified by:
commitAndDeactivate
in interfaceIEditor
-
commitAndLeave
public void commitAndLeave()
Description copied from interface:IEditor
Commits the translation and leave entry activated. Translation will be saved. Must be called only from UI thread.- Specified by:
commitAndLeave
in interfaceIEditor
-
nextEntry
public void nextEntry()
Description copied from interface:IEditor
Move to next entry. Must be called only from UI thread.
-
prevEntry
public void prevEntry()
Description copied from interface:IEditor
Move to previous entry. Must be called only from UI thread.
-
nextXAutoEntry
public void nextXAutoEntry()
Description copied from interface:IEditor
Move to next x-auto translated entry. Must be called only from UI thread.- Specified by:
nextXAutoEntry
in interfaceIEditor
-
prevXAutoEntry
public void prevXAutoEntry()
Description copied from interface:IEditor
Move to previous x-auto translated entry. Must be called only from UI thread.- Specified by:
prevXAutoEntry
in interfaceIEditor
-
nextXEnforcedEntry
public void nextXEnforcedEntry()
Description copied from interface:IEditor
Move to next x-enforced translated entry. Must be called only from UI thread.- Specified by:
nextXEnforcedEntry
in interfaceIEditor
-
prevXEnforcedEntry
public void prevXEnforcedEntry()
Description copied from interface:IEditor
Move to previous x-enforced translated entry. Must be called only from UI thread.- Specified by:
prevXEnforcedEntry
in interfaceIEditor
-
nextEntryWithNote
public void nextEntryWithNote()
Description copied from interface:IEditor
Move to next entry with a note. Must be called only from UI thread.- Specified by:
nextEntryWithNote
in interfaceIEditor
-
prevEntryWithNote
public void prevEntryWithNote()
Description copied from interface:IEditor
Move to previous entry with a note. Must be called only from UI thread.- Specified by:
prevEntryWithNote
in interfaceIEditor
-
nextUntranslatedEntry
public void nextUntranslatedEntry()
Description copied from interface:IEditor
Move to next untranslated entry. Must be called only from UI thread.- Specified by:
nextUntranslatedEntry
in interfaceIEditor
-
nextTranslatedEntry
public void nextTranslatedEntry()
Description copied from interface:IEditor
Move to next translated entry. Must be called only from UI thread.- Specified by:
nextTranslatedEntry
in interfaceIEditor
-
nextUniqueEntry
public void nextUniqueEntry()
Description copied from interface:IEditor
Move to the first non-unique entry. Must be called from UI thread.- Specified by:
nextUniqueEntry
in interfaceIEditor
-
gotoFile
public void gotoFile(int fileIndex) throws java.lang.IndexOutOfBoundsException
Description copied from interface:IEditor
Goto first entry in specified file.
-
gotoEntry
public void gotoEntry(int entryNum)
Description copied from interface:IEditor
Goto entry with specified number. Convenience method forIEditor.gotoEntry(int, CaretPosition)
where the caret position will be the start of the entry.
-
gotoEntry
public void gotoEntry(int entryNum, IEditor.CaretPosition pos)
Description copied from interface:IEditor
Goto entry with specified number, and restore caret to specified position.
-
gotoEntry
public void gotoEntry(java.lang.String srcString, EntryKey key)
Description copied from interface:IEditor
Goto entry based on a string and entry key.
-
gotoEntryAfterFix
public void gotoEntryAfterFix(int fixedEntry, java.lang.String fixedSource)
Description copied from interface:IEditor
Goto entry with specified number while avoiding clobbering the tag fixes.- Specified by:
gotoEntryAfterFix
in interfaceIEditor
- Parameters:
fixedEntry
- entry number, starts from 1fixedSource
- The source of the entry that was fixed Must be called only from UI thread.
-
refreshViewAfterFix
public void refreshViewAfterFix(java.util.List<java.lang.Integer> fixedEntries)
Description copied from interface:IEditor
Refresh the current editor view while avoiding clobbering any tag fixes.- Specified by:
refreshViewAfterFix
in 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:
refreshView
in interfaceIEditor
-
requestFocus
public void requestFocus()
Description copied from interface:IEditor
Set current focus to editor.- Specified by:
requestFocus
in interfaceIEditor
-
changeCase
public void changeCase(IEditor.CHANGE_CASE_TO newCase)
Description copied from interface:IEditor
Change case of the selected text or if none is selected, of the current word.- Specified by:
changeCase
in interfaceIEditor
- Parameters:
newCase
- : lower, title, upper or cycle Must be called only from UI thread.
-
replaceEditText
public void replaceEditText(java.lang.String text, java.lang.String origin)
Description copied from interface:IEditor
Replaces 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:
replaceEditText
in interfaceIEditor
-
replaceEditText
public void replaceEditText(java.lang.String text)
Description copied from interface:IEditor
Replaces the entire edit area with a given text. Must be called only from UI thread.- Specified by:
replaceEditText
in interfaceIEditor
-
replaceEditTextAndMark
public void replaceEditTextAndMark(java.lang.String text, java.lang.String origin)
Description copied from interface:IEditor
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.- Specified by:
replaceEditTextAndMark
in interfaceIEditor
-
replaceEditTextAndMark
public void replaceEditTextAndMark(java.lang.String text)
Description copied from interface:IEditor
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.- Specified by:
replaceEditTextAndMark
in interfaceIEditor
-
insertText
public void insertText(java.lang.String text)
Description copied from interface:IEditor
Inserts text at the cursor position. Must be called only from UI thread.- Specified by:
insertText
in interfaceIEditor
-
insertTextAndMark
public void insertTextAndMark(java.lang.String text)
Description copied from interface:IEditor
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.- Specified by:
insertTextAndMark
in interfaceIEditor
- Parameters:
text
- The text to insert
-
insertTag
public void insertTag(java.lang.String tag)
Description copied from interface:IEditor
Inserts tag at the cursor position, probably with adding bidi control chars. Must be called only from UI thread.
-
gotoHistoryForward
public void gotoHistoryForward()
Description copied from interface:IEditor
Go to next segment from history. Must be called only from UI thread.- Specified by:
gotoHistoryForward
in interfaceIEditor
-
gotoHistoryBack
public void gotoHistoryBack()
Description copied from interface:IEditor
Go to previous segment from history. Must be called only from UI thread.- Specified by:
gotoHistoryBack
in interfaceIEditor
-
getSettings
public final IEditorSettings getSettings()
Description copied from interface:IEditor
Get settings instance.- Specified by:
getSettings
in interfaceIEditor
- Returns:
- interface for read and change editor settings Can be called from any thread.
-
undo
public void undo()
Description copied from interface:IEditor
Undo editing. Must be called only from UI thread.
-
redo
public void redo()
Description copied from interface:IEditor
Redo editing. Must be called only from UI thread.
-
getSelectedText
public final java.lang.String getSelectedText()
Description copied from interface:IEditor
Get currently selected text.- Specified by:
getSelectedText
in interfaceIEditor
- Returns:
- selected text Must be called only from UI thread.
-
selectSourceText
public void selectSourceText()
Description copied from interface:IEditor
Select the source text of the current segment.- Specified by:
selectSourceText
in interfaceIEditor
-
setAlternateTranslationForCurrentEntry
public void setAlternateTranslationForCurrentEntry(boolean alternate)
Description copied from interface:IEditor
Set default/alternate translation for current entry.- Specified by:
setAlternateTranslationForCurrentEntry
in interfaceIEditor
-
markActiveEntrySource
public void markActiveEntrySource(SourceTextEntry requiredActiveEntry, java.util.List<Mark> marks, java.lang.String markerClassName)
Description copied from interface:IEditor
All plugins can call this method for mark something in active entry.- Specified by:
markActiveEntrySource
in 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
public void registerPopupMenuConstructors(int priority, IPopupMenuConstructor constructor)
Description copied from interface:IEditor
Register constructor of popup menu.- Specified by:
registerPopupMenuConstructors
in interfaceIEditor
- Parameters:
priority
- priority of process orderconstructor
- constructor instance
-
remarkOneMarker
public void remarkOneMarker(java.lang.String markerClassName)
Description copied from interface:IEditor
Calls specified marker for reprocess all entries.- Specified by:
remarkOneMarker
in interfaceIEditor
-
getFilter
public final IEditorFilter getFilter()
Description copied from interface:IEditor
Gets a filter for this editor, or null if filter doesn't applied.
-
setFilter
public void setFilter(IEditorFilter filter)
Description copied from interface:IEditor
Sets a filter to this editor. The filter causes only the selected entries to be shown in the editor.
-
removeFilter
public void removeFilter()
Description copied from interface:IEditor
Removes the current filter.- Specified by:
removeFilter
in interfaceIEditor
-
getCurrentTranslation
public final java.lang.String getCurrentTranslation()
Description copied from interface:IEditor
Returns current translation or null.- Specified by:
getCurrentTranslation
in interfaceIEditor
-
windowDeactivated
public void windowDeactivated()
Description copied from interface:IEditor
Perform any necessary actions for window deactivation.- Specified by:
windowDeactivated
in interfaceIEditor
-
registerUntranslated
public void registerUntranslated()
Description copied from interface:IEditor
Register untranslated.- Specified by:
registerUntranslated
in interfaceIEditor
-
registerEmptyTranslation
public void registerEmptyTranslation()
Description copied from interface:IEditor
Register as empty.- Specified by:
registerEmptyTranslation
in interfaceIEditor
-
registerIdenticalTranslation
public void registerIdenticalTranslation()
Description copied from interface:IEditor
Register translation to be identical to source.- Specified by:
registerIdenticalTranslation
in interfaceIEditor
-
getAutoCompleter
public final IAutoCompleter getAutoCompleter()
Description copied from interface:IEditor
Access the AutoCompleter- Specified by:
getAutoCompleter
in interfaceIEditor
-
getDisplayedEntries
public final java.util.List<GlossaryEntry> getDisplayedEntries()
- Specified by:
getDisplayedEntries
in interfaceIGlossaries
-
showCreateGlossaryEntryDialog
public void showCreateGlossaryEntryDialog(java.awt.Frame parent)
- Specified by:
showCreateGlossaryEntryDialog
in interfaceIGlossaries
-
-