Skip to content

Instantly share code, notes, and snippets.

Last active December 27, 2015 02:01
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save yu-tang/38d54daf58a34d7b9f8c to your computer and use it in GitHub Desktop.
Execute External Command and Reload
/* :name=Execute External Command and Reload :description=Execute External Command and Reload Current Project
* @author Yu Tang
* @date 2015-12-27
* @version 0.2
def command = /C:\Program Files (x86)\microsoft office\OFFICE11\WINWORD.EXE/
import javax.swing.SwingUtilities
import static javax.swing.JOptionPane.*
import org.omegat.core.CoreEvents
import static
import static org.omegat.gui.main.ProjectUICommands.projectClose
import static org.omegat.util.Platform.*
// abort if a project is not opened yet
def prop = project.projectProperties
if (!prop) {
final def title = 'Execute External Command and Reload'
final def msg = 'Please try again after you open a project.'
showMessageDialog null, msg, title, INFORMATION_MESSAGE
// In order to avoid any changes by following external command will be lost, close the project in first
def doRun
doRun = { PROJECT_CHANGE_TYPE eventType ->
def p = command.execute()
console.println "exitValue: " + p.exitValue()
SwingUtilities.invokeLater {
} as Runnable
} as IProjectEventListener
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment