jwrapper.jwutils
Class JWMacOS

java.lang.Object
  extended by jwrapper.jwutils.JWGenericOS
      extended by jwrapper.jwutils.JWMacOS

public class JWMacOS
extends JWGenericOS

Utility APIs for MacOS


Nested Class Summary
static class JWMacOS.IgnoreInputStream
           
 
Constructor Summary
JWMacOS()
           
 
Method Summary
static boolean canRunLauncher64()
          Returns true if JWrapper will use the native launcher on this version of OS X.
 java.lang.String[] getAllConsoleUsers()
          Get a list of all users logged in to the console (logged in to a graphical session)
static java.io.File getDotAppLauncher()
          Returns a File referencing the .app used to launch this application.
 java.lang.String getHostname()
           
static java.lang.String getJvmUserAccount()
          Get the username that is running this JVM
static JWMacOS getMacOSInstance()
           
static java.io.File getNativeLauncherForDotApp(java.io.File dotApp)
          Given a .app folder on OS X, return the native binary used to launch the application.
static java.io.File getParameterisationFile(java.io.File dotApp)
          OS X dynamic parameters are written to a file in the app bundle.
static java.lang.String getRequestedURL()
          Returns the requested URL if this application was launched using a URL handler
 boolean killProcess(int pid)
          Kill the process with the given PID
static boolean registerAppAsURLHandler(java.lang.String scheme, java.lang.String bundleID)
          Register a .app's bundleID to handle a particular URL scheme.
static void registerURLSchemeForVirtualApp(java.lang.String schemeProtocol, java.lang.String virtualApp)
           
static void requestUserAttention(boolean isCritical)
          Request the user's attention.
static void setMyOSXAppBadge(java.lang.String text)
          Set the badge for this app (the red decorator text that appears on the apps icon in the OSX dock)
static void setMyOSXAppName(java.lang.String name)
          Set the name of this app as it appears in the menu bar in OSX
static void setOSXEventListener(JWOSXEventListener listener)
          Register an OSX Event Listener to receive notifications of Apple events.
 
Methods inherited from class jwrapper.jwutils.JWGenericOS
getCurrentProcessID, getInstance, getOSName, getOSNameWithBitness, getOSVersion, setCurrentDirectory, setReadableForAllUsers, setReadableForAllUsersAndWait, setWritableForAllUsers, setWritableForAllUsersAndWait, terminateProcess
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JWMacOS

public JWMacOS()
Method Detail

canRunLauncher64

public static boolean canRunLauncher64()
Returns true if JWrapper will use the native launcher on this version of OS X. Returns true if the OS is 64bit, and if the version is 10.7.3 or later.


getAllConsoleUsers

public java.lang.String[] getAllConsoleUsers()
Get a list of all users logged in to the console (logged in to a graphical session)

Specified by:
getAllConsoleUsers in class JWGenericOS
Returns:

getDotAppLauncher

public static java.io.File getDotAppLauncher()
Returns a File referencing the .app used to launch this application. Returns null if no .app was used.


getHostname

public java.lang.String getHostname()
Overrides:
getHostname in class JWGenericOS

getJvmUserAccount

public static java.lang.String getJvmUserAccount()
Get the username that is running this JVM

Returns:

getMacOSInstance

public static JWMacOS getMacOSInstance()

getNativeLauncherForDotApp

public static java.io.File getNativeLauncherForDotApp(java.io.File dotApp)
Given a .app folder on OS X, return the native binary used to launch the application. Note that the Info.plist is not consulted, so if there are multiple native executables in MacOS the one returned will be arbitrary.

Parameters:
dotApp - the application folder
Returns:
the native executable file, or null if none exists.

getParameterisationFile

public static java.io.File getParameterisationFile(java.io.File dotApp)
OS X dynamic parameters are written to a file in the app bundle. This returns the parameters file given the dotApp bundle.


getRequestedURL

public static java.lang.String getRequestedURL()
Returns the requested URL if this application was launched using a URL handler

Returns:
the request URL or null if none exists.

killProcess

public boolean killProcess(int pid)
Kill the process with the given PID


registerAppAsURLHandler

public static boolean registerAppAsURLHandler(java.lang.String scheme,
                                              java.lang.String bundleID)
Register a .app's bundleID to handle a particular URL scheme.

Returns:
true if the call was succesful.

registerURLSchemeForVirtualApp

public static void registerURLSchemeForVirtualApp(java.lang.String schemeProtocol,
                                                  java.lang.String virtualApp)
                                           throws java.io.IOException,
                                                  java.lang.InterruptedException
Throws:
java.io.IOException
java.lang.InterruptedException

requestUserAttention

public static void requestUserAttention(boolean isCritical)
Request the user's attention. Typically this makes the app icon bounce in the dock.

Parameters:
isCritical - whether this request is critical, if it is then (think?) the icon will bounce forever rather than a finite number of times

setMyOSXAppBadge

public static void setMyOSXAppBadge(java.lang.String text)
Set the badge for this app (the red decorator text that appears on the apps icon in the OSX dock)

Parameters:
text -

setMyOSXAppName

public static void setMyOSXAppName(java.lang.String name)
Set the name of this app as it appears in the menu bar in OSX

Parameters:
name -

setOSXEventListener

public static void setOSXEventListener(JWOSXEventListener listener)
Register an OSX Event Listener to receive notifications of Apple events. Currently supports getURL URL handling calls.