Search in sources :

Example 1 with IEntryEventListener

use of org.omegat.core.events.IEntryEventListener in project omegat by omegat-org.

the class ScriptsMonitor method hookEntryEvent.

private void hookEntryEvent() {
    if (m_entryEventListener != null) {
        CoreEvents.unregisterEntryEventListener(m_entryEventListener);
    }
    addEventScripts(EventType.ENTRY_ACTIVATED);
    addEventScripts(EventType.NEW_FILE);
    m_entryEventListener = new IEntryEventListener() {

        @Override
        public void onNewFile(String activeFileName) {
            HashMap<String, Object> binding = new HashMap<String, Object>();
            binding.put("activeFileName", activeFileName);
            for (ScriptItem si : m_eventsScript.get(EventType.NEW_FILE)) {
                m_scriptingWindow.executeScriptFile(si, binding);
            }
        }

        @Override
        public void onEntryActivated(SourceTextEntry newEntry) {
            HashMap<String, Object> binding = new HashMap<String, Object>();
            binding.put("newEntry", newEntry);
            for (ScriptItem si : m_eventsScript.get(EventType.ENTRY_ACTIVATED)) {
                m_scriptingWindow.executeScriptFile(si, binding);
            }
        }
    };
    CoreEvents.registerEntryEventListener(m_entryEventListener);
}
Also used : HashMap(java.util.HashMap) SourceTextEntry(org.omegat.core.data.SourceTextEntry) IEntryEventListener(org.omegat.core.events.IEntryEventListener)

Aggregations

HashMap (java.util.HashMap)1 SourceTextEntry (org.omegat.core.data.SourceTextEntry)1 IEntryEventListener (org.omegat.core.events.IEntryEventListener)1