com.denova.runtime
Class MacOS

java.lang.Object
  |
  +--com.denova.runtime.MacOS

public class MacOS
extends java.lang.Object

Manage Mac OS X "app" directories and desktop.

Author:
DeNova Copyright © 1997-2008 DeNova All rights reserved worldwide.

Field Summary
static java.lang.String ArrayTemplate
           
static java.lang.String ClasspathTemplate
           
static java.lang.String ContentsDirName
           
static java.lang.String DictTemplate
           
static java.lang.String EndArrayTemplate
           
static java.lang.String EndDictTemplate
           
static java.lang.String EndKeyTemplate
           
static java.lang.String EndStringTemplate
           
static java.lang.String InfoAppTemplateFilename
           
static java.lang.String InfoJavaTemplateFilename
           
static java.lang.String InfoPropertyFilename
           
static java.lang.String JavaDirName
           
static java.lang.String KeyTemplate
           
static java.lang.String LaunchScriptExtension
           
static java.lang.String MacAppDir
           
static java.lang.String MacAppDirExtension
           
static java.lang.String MacAppVariable
           
static java.lang.String MacOsDirName
           
static java.lang.String MacOSLogFilename
           
static java.lang.String PackageIconFilename
           
static java.lang.String PackageInfoFilename
           
static java.lang.String ResourcesDirName
           
static java.lang.String StringIndent
           
static java.lang.String StringTemplate
           
 
Constructor Summary
MacOS()
          Contructor must be called before accessing any MacOS methods.
MacOS(com.denova.io.Log parentsLog)
          Contructor must be called before accessing any MacOS methods.
 
Method Summary
 java.lang.String addLaunchScript()
          Add Unix style launch script with the command extension so it can be launched from Finder.
 java.lang.String addLaunchScript(boolean useJavaCommandPrefix, boolean useJavaConsole, java.lang.String javaCommandPrefix, boolean addDesktopIcon)
          Add Unix style launch script with the command extension so it can be launched from Finder.
 java.lang.String addMacLauncher(boolean useJavaCommandPrefix, boolean useJavaConsole, java.lang.String javaCommandPrefix, java.lang.String appVersion, java.lang.String classpath, java.lang.String extraJvmParameters, java.lang.String jvmVersion, java.lang.String appInfo, java.lang.String installedBy)
          Add a Unix style launch script, a desktop icon, or a Java app bundle if useJavaCommandPrefix is true.
 java.lang.String addMacLauncher(boolean useJavaCommandPrefix, boolean useJavaConsole, java.lang.String javaCommandPrefix, java.lang.String appVersion, java.lang.String classpath, java.lang.String extraJvmParameters, java.lang.String jvmVersion, java.lang.String appInfo, java.lang.String installedBy, boolean addDesktopIcon)
          Add a Unix style launch script or a Java app bundle if useJavaCommandPrefix is true.
 java.io.File buildAppDirTree(java.lang.String bundleName)
          Build the directory structure for an app bundle.
static void clearError()
          Clears the last error message from memory.
 java.lang.String createAppLauncher(java.lang.String executable, java.lang.String appVersion, java.lang.String appInfo, boolean addDesktopIcon)
          Create app launcher.
 java.lang.String createJavaAppLauncher(java.lang.String appVersion, java.lang.String classpath, java.lang.String extraJvmParameters, java.lang.String jvmVersion, java.lang.String appInfo, java.lang.String installedBy, boolean addDesktopIcon)
          Create Java app launcher.
 void deleteLaunchScript(java.lang.String scriptName)
          Delete launch script.
 java.util.List getCreatedDirs()
          Get the list of any newly created dirs while creating menu.
static java.lang.String getDesktopDirectory()
          Get the full path to the current user's desktop directory.
static java.lang.String getLastError()
          Get the last error message.
static java.lang.Exception getLastException()
          Returns the last exception detected.
static boolean isError()
          Returns true if there was an error during the last operation.
 void setCommandLineArguments(java.lang.String newCommandLineArguments)
          Set the command line arguments for the menu.
 void setExecutableFile(java.lang.String newExecutableFile)
          Set the executable file for the menu.
 void setIconFilename(java.lang.String newIconFilename)
          Set the icon filename for the menu.
 void setInstallDir(java.lang.String newInstallDir)
          Set the install directory for the menu.
 void setLaunchDirName(java.lang.String dirName)
          Set the directory where launch scripts are created.
 void setLongName(java.lang.String newLongName)
          Set the desktop name for the menu.
 void setShortName(java.lang.String newShortName)
          Set the launch script name for the menu.
 void setSubmenu(java.lang.String newSubmenu)
          Set the submenu name for the menu.
 void setWorkingDir(java.lang.String newWorkingDir)
          Set the workingDir for the menu.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MacAppDir

public static final java.lang.String MacAppDir
See Also:
Constant Field Values

MacOSLogFilename

public static final java.lang.String MacOSLogFilename
See Also:
Constant Field Values

LaunchScriptExtension

public static final java.lang.String LaunchScriptExtension
See Also:
Constant Field Values

MacAppDirExtension

public static final java.lang.String MacAppDirExtension
See Also:
Constant Field Values

MacAppVariable

public static final java.lang.String MacAppVariable
See Also:
Constant Field Values

ContentsDirName

public static final java.lang.String ContentsDirName
See Also:
Constant Field Values

MacOsDirName

public static final java.lang.String MacOsDirName
See Also:
Constant Field Values

ResourcesDirName

public static final java.lang.String ResourcesDirName
See Also:
Constant Field Values

JavaDirName

public static final java.lang.String JavaDirName
See Also:
Constant Field Values

InfoPropertyFilename

public static final java.lang.String InfoPropertyFilename
See Also:
Constant Field Values

PackageIconFilename

public static final java.lang.String PackageIconFilename
See Also:
Constant Field Values

InfoJavaTemplateFilename

public static final java.lang.String InfoJavaTemplateFilename
See Also:
Constant Field Values

InfoAppTemplateFilename

public static final java.lang.String InfoAppTemplateFilename
See Also:
Constant Field Values

PackageInfoFilename

public static final java.lang.String PackageInfoFilename
See Also:
Constant Field Values

ClasspathTemplate

public static final java.lang.String ClasspathTemplate
See Also:
Constant Field Values

KeyTemplate

public static final java.lang.String KeyTemplate
See Also:
Constant Field Values

EndKeyTemplate

public static final java.lang.String EndKeyTemplate
See Also:
Constant Field Values

ArrayTemplate

public static final java.lang.String ArrayTemplate
See Also:
Constant Field Values

EndArrayTemplate

public static final java.lang.String EndArrayTemplate
See Also:
Constant Field Values

StringTemplate

public static final java.lang.String StringTemplate
See Also:
Constant Field Values

EndStringTemplate

public static final java.lang.String EndStringTemplate
See Also:
Constant Field Values

DictTemplate

public static final java.lang.String DictTemplate
See Also:
Constant Field Values

EndDictTemplate

public static final java.lang.String EndDictTemplate
See Also:
Constant Field Values

StringIndent

public static final java.lang.String StringIndent
See Also:
Constant Field Values
Constructor Detail

MacOS

public MacOS()
Contructor must be called before accessing any MacOS methods.


MacOS

public MacOS(com.denova.io.Log parentsLog)
Contructor must be called before accessing any MacOS methods.

Parameters:
parentsLog -
Method Detail

getDesktopDirectory

public static java.lang.String getDesktopDirectory()
Get the full path to the current user's desktop directory.

Returns: the fullpath to the user's desktop directory

Returns:
desktop directory

isError

public static boolean isError()
Returns true if there was an error during the last operation.

Returns:
error

getLastException

public static java.lang.Exception getLastException()
Returns the last exception detected.

Returns:
last exception

getLastError

public static java.lang.String getLastError()
Get the last error message.

Returns:
text with the error message

clearError

public static void clearError()
Clears the last error message from memory.


setSubmenu

public void setSubmenu(java.lang.String newSubmenu)
Set the submenu name for the menu.

Parameters:
newSubmenu - the menu's folder

setInstallDir

public void setInstallDir(java.lang.String newInstallDir)
Set the install directory for the menu. The directory where the ".app" directory is. Usually the same as the workingDir, but it's not required to be.

Parameters:
newInstallDir - the directory where the executbable file is

setWorkingDir

public void setWorkingDir(java.lang.String newWorkingDir)
Set the workingDir for the menu. The directory where the program "runs" (i.e., the "user.dir" directory when the program is running). Usually this is the same as the installDir, but it doesn't have to be.

Parameters:
newWorkingDir - the working directory where the program runs.

setLaunchDirName

public void setLaunchDirName(java.lang.String dirName)
Set the directory where launch scripts are created. This is usually the install dir, but it can also be a subdirectory of the ".app" directory when creating a Mac style launcher.

Parameters:
dirName - directory where launch scripts are created

setLongName

public void setLongName(java.lang.String newLongName)
Set the desktop name for the menu.

Parameters:
newLongName - name for desktop

setShortName

public void setShortName(java.lang.String newShortName)
Set the launch script name for the menu. This needs to be set even if you only want a desktop icon because the name is used internally.

Parameters:
newShortName - name for the launch script

setExecutableFile

public void setExecutableFile(java.lang.String newExecutableFile)
Set the executable file for the menu.

Parameters:
newExecutableFile - command (without the path) to launch when itemName selected.

setCommandLineArguments

public void setCommandLineArguments(java.lang.String newCommandLineArguments)
Set the command line arguments for the menu.

Parameters:
newCommandLineArguments - any additional arguments needed for the executableFile

setIconFilename

public void setIconFilename(java.lang.String newIconFilename)
Set the icon filename for the menu.

Parameters:
newIconFilename - the full path to the icon

addLaunchScript

public java.lang.String addLaunchScript()
Add Unix style launch script with the command extension so it can be launched from Finder. Do not add a desktop icon for the launch script.

Returns:
Launch script's name.

addLaunchScript

public java.lang.String addLaunchScript(boolean useJavaCommandPrefix,
                                        boolean useJavaConsole,
                                        java.lang.String javaCommandPrefix,
                                        boolean addDesktopIcon)
Add Unix style launch script with the command extension so it can be launched from Finder.

returns name of the launch script

Parameters:
useJavaCommandPrefix - if true, then the javaCommandPrefix and the runtime classpath are prepended to the executableFile
useJavaConsole - if true, then use jre instead of jrew on Windows machines
javaCommandPrefix - prefix for the JVM
addDesktopIcon - true, if desktop icon should be added
Returns:
Launch script's name.

addMacLauncher

public java.lang.String addMacLauncher(boolean useJavaCommandPrefix,
                                       boolean useJavaConsole,
                                       java.lang.String javaCommandPrefix,
                                       java.lang.String appVersion,
                                       java.lang.String classpath,
                                       java.lang.String extraJvmParameters,
                                       java.lang.String jvmVersion,
                                       java.lang.String appInfo,
                                       java.lang.String installedBy)
Add a Unix style launch script, a desktop icon, or a Java app bundle if useJavaCommandPrefix is true.

Parameters:
useJavaCommandPrefix - if true, then the javaCommandPrefix and the runtime classpath are prepended to the executableFile
useJavaConsole - if true, then use jre instead of jrew on Windows machines
javaCommandPrefix - prefix for the JVM
appVersion - application's version number
classpath - classpath for the Java app; if null, classpath is set to $APP_PACKAGE
extraJvmParameters - switches for the JVM; if null, no extra JVM parameters set
jvmVersion - version of JVM app requires; must not include subversion, e.g., _01; include + if this is min version; include * if any variant of this major version is ok
appInfo - information about the application (e.g., name, copyright, etc.)
Returns:
Name of the launch script or app bundle.

addMacLauncher

public java.lang.String addMacLauncher(boolean useJavaCommandPrefix,
                                       boolean useJavaConsole,
                                       java.lang.String javaCommandPrefix,
                                       java.lang.String appVersion,
                                       java.lang.String classpath,
                                       java.lang.String extraJvmParameters,
                                       java.lang.String jvmVersion,
                                       java.lang.String appInfo,
                                       java.lang.String installedBy,
                                       boolean addDesktopIcon)
Add a Unix style launch script or a Java app bundle if useJavaCommandPrefix is true.

Parameters:
useJavaCommandPrefix - if true, then the javaCommandPrefix and the runtime classpath are prepended to the executableFile
useJavaConsole - if true, then use jre instead of jrew on Windows machines
javaCommandPrefix - prefix for the JVM
appVersion - application's version number
classpath - classpath for the Java app; if null, classpath is set to $APP_PACKAGE
extraJvmParameters - switches for the JVM; if null, no extra JVM parameters set
jvmVersion - version of JVM app requires; must not include subversion, e.g., _01; include + if this is min version; include * if any variant of this major version is ok
appInfo - information about the application (e.g., name, copyright, etc.)
addDesktopIcon - true, if desktop icon should be added
Returns:
Name of the launch script or app bundle.

createJavaAppLauncher

public java.lang.String createJavaAppLauncher(java.lang.String appVersion,
                                              java.lang.String classpath,
                                              java.lang.String extraJvmParameters,
                                              java.lang.String jvmVersion,
                                              java.lang.String appInfo,
                                              java.lang.String installedBy,
                                              boolean addDesktopIcon)
Create Java app launcher.

Parameters:
appVersion - application's version number
classpath - classpath for the Java app; if null, classpath is set to $APP_PACKAGE
extraJvmParameters - switches for the JVM; if null, no extra JVM parameters set
jvmVersion - version of JVM app requires; must not include subversion, e.g., _01; include + if this is min version; include * if any variant of this major version is ok
appInfo - information about the application (e.g., name, copyright, etc.)
installedBy - the program that installed the app.
addDesktopIcon - true, if desktop icon should be added
Returns:
Name of the app bundle or null if any errors detected.

createAppLauncher

public java.lang.String createAppLauncher(java.lang.String executable,
                                          java.lang.String appVersion,
                                          java.lang.String appInfo,
                                          boolean addDesktopIcon)
Create app launcher.

Parameters:
appVersion - application's version number
appInfo - information about the application (e.g., name, copyright, etc.)
addDesktopIcon - true, if desktop icon should be added
Returns:
Name of the app bundle or null if any errors detected.

buildAppDirTree

public java.io.File buildAppDirTree(java.lang.String bundleName)
Build the directory structure for an app bundle.

Parameters:
bundleName - name for the .app bundle
Returns:
contents directory or null if unsuccessful creating it.

deleteLaunchScript

public void deleteLaunchScript(java.lang.String scriptName)
Delete launch script.

Parameters:
scriptName - the fullpath to the launch script

getCreatedDirs

public java.util.List getCreatedDirs()
Get the list of any newly created dirs while creating menu.

Returns:
list of directories created by mkdirs or null if no dirs created.