org.csstudio.opibuilder.scriptUtil

## Class ScriptUtil

- java.lang.Object
- - org.csstudio.opibuilder.scriptUtil.ScriptUtil

-     public class ScriptUtil
      extends java.lang.Object

  The utility class to facilitate BOY script programming.
  Author:
    Xihui Chen

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ScriptUtil()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `closeCurrentOPI()` Close current active OPI.
    `static void` | `execInUI(java.lang.Runnable runnable, org.csstudio.opibuilder.editparts.AbstractBaseEditPart widget)` Execute a runnable in UI thread.
    `static void` | `executeEclipseCommand(java.lang.String commandId)` Execute an Eclipse command.
    `static void` | `executeSystemCommand(java.lang.String command, int wait)` Executing a system or shell command.
    `static org.osgi.framework.Version` | `getBOYVersion()`
    `static boolean` | `isMobile()` If the current OPI is running on Mobile device.
    `static boolean` | `isMobile(org.csstudio.opibuilder.editparts.AbstractBaseEditPart widget)` If the current OPI is running on Mobile device.
    `static boolean` | `isWebOPI()`
    `static void` | `makeElogEntry(java.lang.String filePath)` `Deprecated` see `makeLogbookEntry(String, String)`
    `static void` | `makeLogbookEntry(java.lang.String text, java.lang.String filePath)` Pop up a logbook dialog to make a logbook entry.
    `static void` | `openOPI(org.csstudio.opibuilder.editparts.AbstractBaseEditPart widget, java.lang.String opiPath, int target, org.csstudio.opibuilder.util.MacrosInput macrosInput)` Open an OPI.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ScriptUtil

          public ScriptUtil()

  - ### Method Detail

    - #### openOPI

          public static final void openOPI(org.csstudio.opibuilder.editparts.AbstractBaseEditPart widget,
                     java.lang.String opiPath,
                     int target,
                     org.csstudio.opibuilder.util.MacrosInput macrosInput)

      Open an OPI.
      Parameters:
        `widget` - the widget to which the script is attached.
        `opiPath` - the path of the OPI. It can be either an absolute path or a relative path to the Display file of the widget.
        `target` - target place of the new OPI. 0: new tab; 1: replace current one; 2: new window; 3: view on left; 4: view on right; 5: view on top; 6: view on bottom; 7: detached view
        `macrosInput` - the macrosInput. null if no macros needed.

    - #### closeCurrentOPI

          public static void closeCurrentOPI()

      Close current active OPI.

    - #### makeElogEntry

          public static final void makeElogEntry(java.lang.String filePath)

      `Deprecated` see `makeLogbookEntry(String, String)`
      Parameters:
        `filePath` -

    - #### makeLogbookEntry

          public static final void makeLogbookEntry(java.lang.String text,
                              java.lang.String filePath)

      Pop up a logbook dialog to make a logbook entry.
      Parameters:
        `text` - text of the log entry.
        `filePath` - path of a file to attach or null. It could be either a local file system file path or a workspace file path. File types that the logbook support depend on implementation but should include *.gif, *.jpg: File will be attached as image.

    - #### executeEclipseCommand

          public static final void executeEclipseCommand(java.lang.String commandId)

      Execute an Eclipse command.
      Parameters:
        `commandId` - the command id.

    - #### executeSystemCommand

          public static final void executeSystemCommand(java.lang.String command,
                                  int wait)

      Executing a system or shell command. On Unix, that could be anything in the PATH.

      Several things can happen:

      - Command finishes OK right away
      - Command gives error right away
      - Command runs for a long time, eventually giving error or OK.
      The command executor waits a little time to see if the command finishes, and calls back in case of an error. When the command finishes right away OK or runs longer, we leave it be. Command output will be printed on BOY console.
      Parameters:
        `command` - Command to run. Format depends on OS.
        `wait` - Time to wait for completion in seconds

    - #### execInUI

          public static final void execInUI(java.lang.Runnable runnable,
                      org.csstudio.opibuilder.editparts.AbstractBaseEditPart widget)

      Execute a runnable in UI thread.
      Parameters:
        `runnable` - the runnable to be executed.
        `widget` - any widget. It is referred to get the UI thread.

    - #### isWebOPI

          public static final boolean isWebOPI()

      Returns:
        true if it the OPI is running in WebOPI.

    - #### isMobile

          public static final boolean isMobile()

      If the current OPI is running on Mobile device. This method can only be called in UI thread.
      Returns:
        true if it the OPI is running in mobile device such as Android, iphone, iPad, iPod and blackberry.

    - #### isMobile

          public static final boolean isMobile(org.csstudio.opibuilder.editparts.AbstractBaseEditPart widget)

      If the current OPI is running on Mobile device. This method can be called in non-UI thread.
      Parameters:
        `widget` - the widget on which the script is attached to.
      Returns:
        true if it the OPI is running in mobile device such as Android, iphone, iPad, iPod and blackberry.

    - #### getBOYVersion

          public static final org.osgi.framework.Version getBOYVersion()