Advertisement
KosIvantsov

open_folder.groovy

May 25th, 2013
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 0.84 KB | None | 0 0
  1. /*
  2.  *  Open project folder
  3.  *
  4.  * @author  Yu Tang
  5.  * @date    2013-05-23
  6.  * @version 0.2
  7.  */
  8.  
  9. import static javax.swing.JOptionPane.*
  10. import static org.omegat.util.Platform.*
  11.  
  12. // abort if a project is not opened yet
  13. def prop = project.projectProperties
  14. if (!prop) {
  15.   final def title = 'open project folder'
  16.   final def msg   = 'Please try again after you open a project.'
  17.   showMessageDialog null, msg, title, INFORMATION_MESSAGE
  18.   return
  19. }
  20.  
  21. // get command GString to open a folder
  22. def folder = prop.projectRoot
  23. def command
  24. switch (osType) {
  25.   case [OsType.WIN64, OsType.WIN32]:
  26.     command = "explorer.exe \"$folder\""
  27.     break
  28.   case [OsType.MAC64, OsType.MAC32]:
  29.     command = "open \"$folder\""
  30.     break
  31.   default:  // for Linux or others
  32.     command = ['xdg-open', folder]
  33.     break
  34. }
  35.  
  36. // open it
  37. command.execute()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement