com.denova.runtime
Class UnixMenu

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

public class UnixMenu
extends java.lang.Object

Manage unix launch script, including KDE menu.

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

Field Summary
static java.lang.String MenuExtension
           
static java.lang.String UnixMenuLogFilename
           
 
Constructor Summary
UnixMenu()
          Contructor must be called before accessing any UnixOS methods.
UnixMenu(com.denova.io.Log parentsLog)
          Contructor must be called before accessing any UnixOS methods.
 
Method Summary
 void addLaunchScript()
          Add launch script and KDE/gnmoe menus, if KDE/gnome present on target.
 void addLaunchScript(boolean useJavaCommandPrefix, boolean useJavaConsole, java.lang.String javaCommandPrefix)
          Add launch script and KDE/gnome menu, if KDE/gnome present on target.
 void addLaunchScript(boolean useJavaCommandPrefix, boolean useJavaConsole, java.lang.String javaCommandPrefix, boolean addKdeMenu, boolean addGnomeMenu)
          Add launch script and KDE/gnome menu, if KDE/gnome present on target.
 void addLaunchScript(boolean useJavaCommandPrefix, boolean useJavaConsole, java.lang.String javaCommandPrefix, boolean addKdeMenu, boolean addGnomeMenu, java.lang.String echoMessage)
          Add launch script.
static void clearError()
          Clear the last error info.
 boolean createGnomeMenu(java.lang.String startCommand, boolean useConsole)
          Create a Gnome menu, if Gnome's desktop is present on target.
 boolean createKdeMenu(java.lang.String startCommand, boolean useConsole)
          Create a KDE menu, if KDE present on target.
 void deleteGnomeMenu(java.lang.String submenu, java.lang.String menuName)
          Delete a Gnome menu.
 void deleteKdeMenu(java.lang.String submenu, java.lang.String menuName)
          Delete a KDE menu.
 void deleteLaunchScript(java.lang.String scriptName)
          Delete launch script and KDE menu, if menuName defined and KDE present.
 void deleteLaunchScript(java.lang.String scriptName, java.lang.String submenu, java.lang.String longName)
          Delete launch script and KDE menu, if menuName defined and KDE present.
 java.util.List getCreatedDirs()
          Get the list of any newly created dirs while creating menu.
static java.lang.String getGnomeMenuDir()
          Return the main Gnome menu directory.
 java.lang.String getKdeAutostartDir()
          Return the KDE autostart directory.
static java.lang.String getKdeMenuDir()
          Return the main KDE menu directory.
static java.lang.String getKdeMenuName(java.lang.String longName, java.lang.String shortName)
          Gets the kde menu name.
 java.lang.String getKdeMenuName(java.lang.String submenu, java.lang.String longName, java.lang.String shortName)
          Get the KDE menu filename.
static java.lang.String getLastError()
          Gets the last error.
static java.lang.Exception getLastException()
          Returns the last exception detected.
static java.lang.String getMenuName(java.lang.String longName, java.lang.String shortName)
          Gets the menu name.
static java.lang.String getSubmenuDir(java.lang.String menuDirname, java.lang.String submenu)
          Get the submenu dir for KDE/Gnome.
static boolean gnomeMenusInstalled()
          Determine if the gnome menus are installed.
static boolean isError()
          Returns true if there was an error during the last operation.
static boolean kdeMenusInstalled()
          Determine if KDE menus are installed.
 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

UnixMenuLogFilename

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

MenuExtension

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

UnixMenu

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


UnixMenu

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

Parameters:
parentsLog - parent class' log.
Method Detail

isError

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

Returns:
true if there was an error during the last operation.

getLastException

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

Returns:
The last exception detected.

getLastError

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

Returns:
last error

clearError

public static void clearError()
Clear the last error info.


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.

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

kdeMenusInstalled

public static boolean kdeMenusInstalled()
Determine if KDE menus are installed.

Returns:
true if KDE menus installed.

gnomeMenusInstalled

public static boolean gnomeMenusInstalled()
Determine if the gnome menus are installed.

Returns:
true if the gnome menus installed.

getKdeMenuDir

public static java.lang.String getKdeMenuDir()
Return the main KDE menu directory.

Returns:
The kdeMenuDir value

getSubmenuDir

public static java.lang.String getSubmenuDir(java.lang.String menuDirname,
                                             java.lang.String submenu)
Get the submenu dir for KDE/Gnome. KDE won't let users simply add menus to the top level. All entries must be added to a predefined folder. If the submenu passed to this routine is not a standard KDE folder or there is no submenu, then the menu item/submenu is added to the Utilities folder. If you want a menu added to a different standard KDE folder, then define the submenu to start with the KDE folder name separated by a forward slash and then your submenu (e.g., Development/MyCompany). The standard known KDE folder names are: Development, Internet, Utilities, Graphics, Edutainment, Games, Office, Settings, System.

Parameters:
menuDirname - name of directory for menus
submenu - name of folder for the menu items or blank.

getGnomeMenuDir

public static java.lang.String getGnomeMenuDir()
Return the main Gnome menu directory.

Returns:
The gnomeMenuDir value

getMenuName

public static java.lang.String getMenuName(java.lang.String longName,
                                           java.lang.String shortName)
Gets the menu name. Use the long name if there is one; otherwise, use the short name.

Parameters:
longName -
shortName -
Returns:
menu name

addLaunchScript

public void addLaunchScript()
Add launch script and KDE/gnmoe menus, if KDE/gnome present on target.


addLaunchScript

public void addLaunchScript(boolean useJavaCommandPrefix,
                            boolean useJavaConsole,
                            java.lang.String javaCommandPrefix)
Add launch script and KDE/gnome menu, if KDE/gnome present on target.

Parameters:
useJavaCommandPrefix - add java command prefix to executable file.
useJavaConsole - use the java console if true
javaCommandPrefix - java command prefix, if this is a java command.

addLaunchScript

public void addLaunchScript(boolean useJavaCommandPrefix,
                            boolean useJavaConsole,
                            java.lang.String javaCommandPrefix,
                            boolean addKdeMenu,
                            boolean addGnomeMenu)
Add launch script and KDE/gnome menu, if KDE/gnome present on target.

Parameters:
useJavaCommandPrefix - add java command prefix to executable file.
useJavaConsole - use the java console if true
javaCommandPrefix - java command prefix, if this is a java command.
addKdeMenu - true if kde menu should be created, if kde is installed.
addGnomeMenu - true if gnome menu should be created, if gnome is installed.

addLaunchScript

public void addLaunchScript(boolean useJavaCommandPrefix,
                            boolean useJavaConsole,
                            java.lang.String javaCommandPrefix,
                            boolean addKdeMenu,
                            boolean addGnomeMenu,
                            java.lang.String echoMessage)
Add launch script.

Parameters:
useJavaCommandPrefix - add java command prefix to executable file.
useJavaConsole - use the java console if true
javaCommandPrefix - java command prefix, if this is a java command.
addKdeMenu - true if kde menu should be created, if kde is installed.
addGnomeMenu - true if gnome menu should be created, if gnome is installed.
echoMessage - message to echo to console when script runs

deleteLaunchScript

public void deleteLaunchScript(java.lang.String scriptName)
Delete launch script and KDE menu, if menuName defined and KDE present.

Parameters:
scriptName -

deleteLaunchScript

public void deleteLaunchScript(java.lang.String scriptName,
                               java.lang.String submenu,
                               java.lang.String longName)
Delete launch script and KDE menu, if menuName defined and KDE present.

Parameters:
scriptName -
submenu -
longName -

createKdeMenu

public boolean createKdeMenu(java.lang.String startCommand,
                             boolean useConsole)
Create a KDE menu, if KDE present on target.

Parameters:
startCommand -
useConsole -
Returns:
true if successful creating menu.

deleteKdeMenu

public void deleteKdeMenu(java.lang.String submenu,
                          java.lang.String menuName)
Delete a KDE menu.

Parameters:
submenu -
menuName -

getKdeMenuName

public static java.lang.String getKdeMenuName(java.lang.String longName,
                                              java.lang.String shortName)
Gets the kde menu name. Use the long name if there is one; otherwise, use the short name. Remove any spaces from the name.

Parameters:
longName -
shortName -
Returns:
kde menu name

getKdeMenuName

public java.lang.String getKdeMenuName(java.lang.String submenu,
                                       java.lang.String longName,
                                       java.lang.String shortName)
Get the KDE menu filename.

Parameters:
submenu -
longName -
shortName -
Returns:
The kdeMenuName value

getKdeAutostartDir

public java.lang.String getKdeAutostartDir()
Return the KDE autostart directory.

Returns:
The kdeAutostartDir value

createGnomeMenu

public boolean createGnomeMenu(java.lang.String startCommand,
                               boolean useConsole)
Create a Gnome menu, if Gnome's desktop is present on target.

Parameters:
startCommand -
useConsole -
Returns:
true if successful creating gnome menu.

deleteGnomeMenu

public void deleteGnomeMenu(java.lang.String submenu,
                            java.lang.String menuName)
Delete a Gnome menu.

Parameters:
submenu -
menuName -

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.