本文整理汇总了Java中org.omegat.core.Core类的典型用法代码示例。如果您正苦于以下问题:Java Core类的具体用法?Java Core怎么用?Java Core使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Core类属于org.omegat.core包,在下文中一共展示了Core类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addItems
import org.omegat.core.Core; //导入依赖的package包/类
public void addItems(JPopupMenu menu, JTextComponent comp, int mousepos,
boolean isInActiveEntry, boolean isInActiveTranslation, SegmentBuilder sb) {
final String selection = Core.getEditor().getSelectedText();
if (selection == null) {
return;
}
ExternalFinderItem.TARGET target;
if (ExternalFinderItem.isASCII(selection)) {
target = ExternalFinderItem.TARGET.ASCII_ONLY;
} else {
target = ExternalFinderItem.TARGET.NON_ASCII_ONLY;
}
IExternalFinderItemMenuGenerator generator = new ExternalFinderItemMenuGenerator(finderItems, target, true);
final List<Component> newMenuItems = generator.generate();
for (Component component : newMenuItems) {
menu.add(component);
}
}
开发者ID:hiohiohio,项目名称:omegat-plugin-externalfinder,代码行数:22,代码来源:ExternalFinderItemPopupMenuConstructor.java
示例2: generateIApplicationEventListener
import org.omegat.core.Core; //导入依赖的package包/类
private static IApplicationEventListener generateIApplicationEventListener(final List<ExternalFinderItem> finderItems) {
return new IApplicationEventListener() {
@Override
public void onApplicationStartup() {
int priority = DEFAULT_POPUP_PRIORITY;
// load user's xml file for priority of popup items
final String configDir = StaticUtils.getConfigDir();
final File userFile = new File(configDir, FINDER_FILE);
if (userFile.canRead()) {
final IExternalFinderItemLoader userItemLoader = new ExternalFinderXMLItemLoader(userFile);
priority = userItemLoader.loadPopupPriority(priority);
}
Core.getEditor().registerPopupMenuConstructors(priority, new ExternalFinderItemPopupMenuConstructor(finderItems));
}
@Override
public void onApplicationShutdown() {
}
};
}
示例3: getEditorTextArea
import org.omegat.core.Core; //导入依赖的package包/类
/**
* Method that returns the EditorTextArea3 object from <code>Core</code>.
* This method uses introspection to acces the private EditorTextArea3
* object in <code>Core</code> and return it. This should be idealy accessed
* in a different way (without introspection) but it is the only possibility
* by now.
*
* @return Returns the EditorTextArea3 object from <code>Core</code>
*/
public static EditorTextArea3 getEditorTextArea() {
if (editor_text_area == null) {
EditorController controller = (EditorController) Core.getEditor();
// Getting the field
Field editor;
try {
editor = EditorController.class.getDeclaredField("editor");
// Setting it accessible
editor.setAccessible(true);
try {
editor_text_area = (EditorTextArea3) editor.get(controller);
} catch (IllegalAccessException iae) {
iae.printStackTrace(System.err);
System.exit(-1);
}
} catch (NoSuchFieldException nsfe) {
nsfe.printStackTrace(System.err);
System.exit(-1);
}
}
return editor_text_area;
}
示例4: getActiveMatchIndex
import org.omegat.core.Core; //导入依赖的package包/类
/**
* Method that returns the index of the active match from
* <code>MatchesTextArea</code>. This method uses introspection to acces the
* private MatchesTextArea object in <code>Core</code> and returns the index
* of the active match. This should be idealy accessed in a different way
* (without introspection) but this is the only possibility by now.
*
* @return Returns the index of the active match from
* <code>MatchesTextArea</code>.
*/
public static int getActiveMatchIndex() {
int activeMatch = -1;
try {
Field actMatch = MatchesTextArea.class
.getDeclaredField("activeMatch");
actMatch.setAccessible(true);
try {
activeMatch = (Integer) actMatch.get(Core.getMatcher());
} catch (IllegalAccessException iae) {
iae.printStackTrace(System.err);
System.exit(-1);
}
} catch (NoSuchFieldException nsfe) {
nsfe.printStackTrace(System.err);
System.exit(-1);
}
return activeMatch;
}
示例5: getMatches
import org.omegat.core.Core; //导入依赖的package包/类
public static List<NearString> getMatches() {
List<NearString> matches = null;
try {
Field matchesField = MatchesTextArea.class.getDeclaredField("matches");
matchesField.setAccessible(true);
try {
matches = (List<NearString>) matchesField
.get((MatchesTextArea) Core.getMatcher());
} catch (IllegalAccessException iae) {
iae.printStackTrace(System.err);
System.exit(-1);
}
} catch (NoSuchFieldException nsfe) {
nsfe.printStackTrace(System.err);
System.exit(-1);
}
return matches;
}
示例6: getGlossaryEntries
import org.omegat.core.Core; //导入依赖的package包/类
public static List<GlossaryEntry> getGlossaryEntries() {
List<GlossaryEntry> nowEntries = null;
try {
Field nowEntriesField = GlossaryTextArea.class
.getDeclaredField("nowEntries");
nowEntriesField.setAccessible(true);
try {
nowEntries = (List<GlossaryEntry>) nowEntriesField
.get(Core.getGlossary());
} catch (IllegalAccessException iae) {
iae.printStackTrace(System.err);
System.exit(-1);
}
} catch (NoSuchFieldException nsfe) {
nsfe.printStackTrace(System.err);
System.exit(-1);
}
return nowEntries;
}
示例7: onEntryActivated
import org.omegat.core.Core; //导入依赖的package包/类
/**
* Method launched when an entry is activated.
*
* @param newEntry
* Entry which has been activated.
*/
@Override
public void onEntryActivated(SourceTextEntry newEntry) {
if (sessionlog.GetLog().GetCurrentSegmentNumber() != Core.getEditor()
.getCurrentEntry().entryNum()) {
/**
* Inject the listeners as late as possible. When the first project
* is loaded after OmegaT startup, OmDocument does not exist when
* InitLogging is called (subsequent project loads do not trigger
* this behaviour).
*/
if (!isInjected) {
injectListeners();
}
sessionlog.GetLog().CloseEntry();
sessionlog.BackupLogging();
sessionlog.GetLog().NewEntry(newEntry);
}
}
示例8: caretUpdate
import org.omegat.core.Core; //导入依赖的package包/类
/**
* Method launched when the caret is updated.
*
* @param e
* Caret update which triggers this event
*/
@Override
public void caretUpdate(CaretEvent e) {
Document3 doc = ((EditorTextArea3) e.getSource()).getOmDocument();
if (doc != null) {
// This is called since the method "isEditMode" in EditorController
// cannot be accessed
if (((EditorController) Core.getEditor())
.getCurrentTranslation() != null) {
int start_trans = doc.getTranslationStart();
int end_trans = start_trans
+ Core.getEditor().getCurrentTranslation().length();
if (e.getDot() >= start_trans && e.getDot() <= end_trans) {
sessionlog.GetLog().CaretUpdate(e.getMark() + 1,
e.getDot() + 1);
}
}
}
}
示例9: NewEntry
import org.omegat.core.Core; //导入依赖的package包/类
@Override
public void NewEntry(SourceTextEntry active_entry){
if(current_file_node!=null && active_entry!=null){
last_edited_text=Core.getEditor().getCurrentTranslation();
caretupdates_to_ignore=1;
sessionlog.GetMenu().setPauseTimestamp(0);
sessionlog.GetMenu().getPausetiming().setSelected(false);
Element element = NewElement("segment", true);
element.setAttribute("number", Integer.toString(
Core.getEditor().getCurrentEntry().entryNum()));
Element source_element = NewElement("source", false);
source_element.appendChild(log_document.createTextNode(
Core.getEditor().getCurrentEntry().getSrcText()));
element.appendChild(source_element);
Element target_element = NewElement("initialTarget", false);
target_element.appendChild(log_document.createTextNode(
Core.getEditor().getCurrentTranslation()));
element.appendChild(target_element);
current_entry_node = element;
current_file_node.appendChild(current_entry_node);
current_editions_node = NewElement("events", false);
chosen_entry_time = System.nanoTime();
current_segment_number=Core.getEditor().getCurrentEntry().entryNum();
}
}
示例10: NewEdition
import org.omegat.core.Core; //导入依赖的package包/类
private void NewEdition(int offset, String text, Element element){
//This is called since the method "isEditMode" in EditorController cannot be accessed
if(!IntrospectionTools.undoInProgress() &&
Core.getEditor().getCurrentTranslation()!=null){
caretupdates_to_ignore++;
StringBuilder sb=new StringBuilder("ID");
element.setAttribute("id", sb.append(
Integer.toString(edition_idx)).toString());
element.setAttribute("length", Integer.toString(text.length()));
element.setAttribute("offset", Integer.toString(offset));
element.appendChild(log_document.createTextNode(text));
current_editions_node.appendChild(element);
undomanager.getUndoableIdx().push(edition_idx);
edition_idx++;
}
}
示例11: ApertiumConsoleTranslate
import org.omegat.core.Core; //导入依赖的package包/类
public ApertiumConsoleTranslate() {
JMenuItem item = new JMenuItem("Apertium console settings...");
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new PreferencesDialog().setVisible(true);
}
});
Core.getMainWindow().getMainMenu().getOptionsMenu().add(item);
init();
}
示例12: generateIApplicationEventListener
import org.omegat.core.Core; //导入依赖的package包/类
private static IApplicationEventListener generateIApplicationEventListener() {
return new IApplicationEventListener() {
public void onApplicationStartup() {
// get NotesPane from Core object just after constructiong GUI
final INotes notes = Core.getNotes();
if (!(notes instanceof JTextPane)) {
// If this error happened, it would come from recent updates of OmegaT or Other plugins.
Log.log("NotesPane should be extened from JTextPane to use LinkBuilder plugin.");
return;
}
// get GlossaryPane
final GlossaryTextArea glossaryTextArea = Core.getGlossary();
if (!(glossaryTextArea instanceof JTextPane)) {
// If this error happened, it would come from recent updates of OmegaT or Other plugins.
Log.log("GlossaryPane should be extened from JTextPane to use LinkBuilder plugin.");
return;
}
// generate logger for OmegaT
ILogger logger = new ILogger() {
public void log(String s) {
Log.log(s);
}
};
// register for Notes
final IAttributeInserter notesURLInserter = new JTextPaneAttributeInserter((JTextPane) notes, logger);
notesURLInserter.register();
// register for Glossary
final IAttributeInserter glossaryURLInserter = new JTextPaneAttributeInserter((JTextPane) glossaryTextArea, logger);
glossaryURLInserter.register();
}
public void onApplicationShutdown() {
}
};
}
示例13: addSetingsMenu
import org.omegat.core.Core; //导入依赖的package包/类
private void addSetingsMenu() {
JMenuItem item = new JMenuItem("Precision Translation Settings");
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new SettingsDialog(null, true).setVisible(true);
}
});
Core.getMainWindow().getMainMenu().getOptionsMenu().add(item);
}
示例14: getMTEntriesSize
import org.omegat.core.Core; //导入依赖的package包/类
public static int getMTEntriesSize() {
try {
Field translatorsField = MachineTranslateTextArea.class
.getDeclaredField("translators");
translatorsField.setAccessible(true);
try {
IMachineTranslation[] translators = (IMachineTranslation[]) translatorsField
.get(Core.getMachineTranslatePane());
int counter = 0;
Field enabledField = BaseTranslate.class
.getDeclaredField("enabled");
enabledField.setAccessible(true);
for (IMachineTranslation mt : translators) {
boolean enabled = (Boolean) enabledField
.get((BaseTranslate) mt);
if (enabled)
counter++;
}
return counter;
} catch (IllegalAccessException iae) {
iae.printStackTrace(System.err);
System.exit(-1);
}
} catch (NoSuchFieldException nsfe) {
nsfe.printStackTrace(System.err);
System.exit(-1);
}
return -1;
}
示例15: InitLogging
import org.omegat.core.Core; //导入依赖的package包/类
/**
* Method that initialises the logger. This method initialises the logger by
* opening the log file in the root of the project. This method is called
* when a new project is selected.
*/
public void InitLogging() {
IntrospectionTools.replaceAutoComplete();
xmllog.Reset();
// Flushing the data about the last entry edited
File dir = new File(
Core.getProject().getProjectProperties().getProjectRoot()
+ "/session_logs");
dir.mkdir();
Date d = new Date();
SimpleDateFormat dt = new SimpleDateFormat("yyyyMMddHHmmssSS");
StringBuilder sb = new StringBuilder(dir.getAbsolutePath());
sb.append("/");
sb.append(dt.format(d));
sb.append("session.log");
File f = new File(sb.toString());
log_path = f.getAbsolutePath();
try {
xmllog.NewProject();
/**
* This method is called whenever a project is loaded. Whenever a
* new project is loaded, the document (getOmDocument) is changed.
* OmegaT signals this using 2 different events: · when a new
* project is loaded, InitLogging · when a new file inside a project
* is loaded, SegmentChangedListener.onNewFile To minimize code
* duplication, onNewFile() will have the responsibility of pointing
* the listeners to the correct OmDocument and to log the file
* creation.
*/
// xmllog.NewFile(Core.getEditor().getCurrentFile());
SegmentChangedListener.me
.onNewFile(Core.getEditor().getCurrentFile());
} catch (FileNotFoundException ex) {
ex.printStackTrace(System.err);
}
}