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);
}
Aggregations