• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Core类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.omegat.core.Core的典型用法代码示例。如果您正苦于以下问题:Java Core类的具体用法?Java Core怎么用?Java Core使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Core类属于org.omegat.core包,在下文中一共展示了Core类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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() {
        }
    };
}
 
开发者ID:hiohiohio,项目名称:omegat-plugin-externalfinder,代码行数:24,代码来源:ExternalFinder.java


示例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;
}
 
开发者ID:mespla,项目名称:OmegaT-SessionLog,代码行数:34,代码来源:IntrospectionTools.java


示例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;
}
 
开发者ID:mespla,项目名称:OmegaT-SessionLog,代码行数:30,代码来源:IntrospectionTools.java


示例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;
}
 
开发者ID:mespla,项目名称:OmegaT-SessionLog,代码行数:20,代码来源:IntrospectionTools.java


示例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;
}
 
开发者ID:mespla,项目名称:OmegaT-SessionLog,代码行数:21,代码来源:IntrospectionTools.java


示例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);
	}
}
 
开发者ID:mespla,项目名称:OmegaT-SessionLog,代码行数:27,代码来源:SegmentChangedListener.java


示例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);
			}
		}
	}
}
 
开发者ID:mespla,项目名称:OmegaT-SessionLog,代码行数:25,代码来源:CaretUpdateListener.java


示例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();
    }
}
 
开发者ID:mespla,项目名称:OmegaT-SessionLog,代码行数:26,代码来源:XMLLogger.java


示例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++;
    }
}
 
开发者ID:mespla,项目名称:OmegaT-SessionLog,代码行数:18,代码来源:XMLLogger.java


示例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();
}
 
开发者ID:transducens,项目名称:apertium-cli-omegat,代码行数:12,代码来源:ApertiumConsoleTranslate.java


示例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() {
        }
    };
}
 
开发者ID:hiohiohio,项目名称:omegat-plugin-linkbuilder,代码行数:41,代码来源:LinkBuilder.java


示例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);
}
 
开发者ID:omongo,项目名称:pt-omegat,代码行数:11,代码来源:PrecisionTranslation.java


示例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;
}
 
开发者ID:mespla,项目名称:OmegaT-SessionLog,代码行数:31,代码来源:IntrospectionTools.java


示例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);
	}
}
 
开发者ID:mespla,项目名称:OmegaT-SessionLog,代码行数:45,代码来源:SessionLogPlugin.java


示例16: SessionLogMenu

import org.omegat.core.Core; //导入依赖的package包/类
/**
 * Constructor of the class, which adds the option to the menu.
 * 
 * @param sessionlog
 *            Object that controls the coloring in the matcher.
 */
public SessionLogMenu(SessionLogPlugin sessionlog) {
	this.sessionlog = sessionlog;
	this.pause_timestamp = 0;

	this.pausetiming = new JCheckBoxMenuItem("Pause timing in SessionLog");
	this.pausetiming.addActionListener(pausetimingMenuItemActionListener);
	this.pausetiming.setSelected(false);
	this.pausetiming.setEnabled(false);

	this.enable_logging = new JCheckBoxMenuItem("Enable SessionLog");
	this.enable_logging
			.addActionListener(enableloggerMenuItemActionListener);
	this.enable_logging.setName("dump_log");
	this.enable_logging.setSelected(true);
	this.enable_logging.setEnabled(false);

	CoreEvents.registerApplicationEventListener(
			new IApplicationEventListener() {
				@Override
				public void onApplicationStartup() {
					Core.getMainWindow().getMainMenu().getOptionsMenu()
							.add(pausetiming);
					Core.getMainWindow().getMainMenu().getOptionsMenu()
							.add(enable_logging);
				}

				@Override
				public void onApplicationShutdown() {
				}
			});
}
 
开发者ID:mespla,项目名称:OmegaT-SessionLog,代码行数:38,代码来源:SessionLogMenu.java


示例17: pauseTimingSelected

import org.omegat.core.Core; //导入依赖的package包/类
/**
 * Method applied when a pause is started. This method records the current
 * timestamp and makes the different panels and text areas invisible.
 */
public void pauseTimingSelected() {
	pause_timestamp = System.nanoTime();
	IntrospectionTools.getEditorTextArea().setVisible(false);
	((MatchesTextArea) Core.getMatcher()).setVisible(false);
	Core.getGlossary().setVisible(false);
	Core.getMachineTranslatePane().setVisible(false);
}
 
开发者ID:mespla,项目名称:OmegaT-SessionLog,代码行数:12,代码来源:SessionLogMenu.java


示例18: resumeTimingSelected

import org.omegat.core.Core; //导入依赖的package包/类
/**
 * Method applied when the work is resumed after a pause. This method is
 * used when a pause is resumed, and registers the pause event in the log,
 * counting the time consumed in the pause, and makes the different panels
 * and text areas visible again.
 */
public void resumeTimingSelected() {
	sessionlog.GetLog().SetPause(System.nanoTime() - pause_timestamp);
	IntrospectionTools.getEditorTextArea().setVisible(true);
	((MatchesTextArea) Core.getMatcher()).setVisible(true);
	Core.getGlossary().setVisible(true);
	Core.getMachineTranslatePane().setVisible(true);
}
 
开发者ID:mespla,项目名称:OmegaT-SessionLog,代码行数:14,代码来源:SessionLogMenu.java


示例19: NewProject

import org.omegat.core.Core; //导入依赖的package包/类
@Override
public void NewProject() throws FileNotFoundException{
    emtpy_mt_proposals=true;
    emtpy_glossary_proposals=true;
    current_tm_proposal=1;
    emtpy_tm_proposals=true;
    caretupdates_to_ignore=0;
    edition_idx=0;
    chosen_entry_time = -1;
    edition_idx=0;
    undomanager=new BaseLogger.UndoManager();

    //Starting the root node
    Element rootElement = log_document.createElement("project");
    rootElement.setAttribute("name", 
            Core.getProject().getProjectProperties().getProjectName());
    rootElement.setAttribute("sl", 
            Core.getProject().getProjectProperties().getSourceLanguage(
            ).getLanguageCode());
    rootElement.setAttribute("tl", 
            Core.getProject().getProjectProperties().getTargetLanguage(
            ).getLanguageCode());

    root_node.appendChild(rootElement);
    current_project_node=rootElement;
    current_file_node=null;
    current_entry_node=null;
    current_editions_node=null;
}
 
开发者ID:mespla,项目名称:OmegaT-SessionLog,代码行数:30,代码来源:XMLLogger.java


示例20: onApplicationShutdown

import org.omegat.core.Core; //导入依赖的package包/类
/**
 * Method lanuched when the application is shuten down. This method stops
 * logging.
 */
@Override
public void onApplicationShutdown() {
	sessionlog.GetLog().CloseEntry();
	if (!(Core.getProject() instanceof NotLoadedProject))
		sessionlog.StopLogging();
}
 
开发者ID:mespla,项目名称:OmegaT-SessionLog,代码行数:11,代码来源:ApplicationEventListenerSessionLog.java



注:本文中的org.omegat.core.Core类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Accumulators类代码示例发布时间:2022-05-22
下一篇:
Java Sequential类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap