File: open_tm_folder.groovy

package info (click to toggle)
omegat 3.6.0.10%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 63,728 kB
  • sloc: xml: 114,044; java: 74,758; sh: 174; javascript: 108; makefile: 22
file content (38 lines) | stat: -rw-r--r-- 869 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* :name=Open TM Folder :description=Open the /tm folder
 * 
 *  Open the /tm folder
 *
 * @author  Yu Tang
 * @date    2013-06-05
 * @version 0.3
 */

import static javax.swing.JOptionPane.*
import static org.omegat.util.Platform.*

// abort if a project is not opened yet
def prop = project.projectProperties
if (!prop) {
  final def title = 'open TM folder'
  final def msg   = 'Please try again after you open a project.'
  showMessageDialog null, msg, title, INFORMATION_MESSAGE
  return
}

// get command GString to open a folder
def folder = prop.TMRoot
def command
switch (osType) {
  case [OsType.WIN64, OsType.WIN32]:
    command = "explorer.exe \"$folder\""
    break
  case [OsType.MAC64, OsType.MAC32]:
    command = ['open', folder]
    break
  default:  // for Linux or others
    command = ['xdg-open', folder]
    break
}

// open it
command.execute()