com.izforge.izpack.util.os
Class Win_Shortcut

java.lang.Object
  extended bycom.izforge.izpack.util.os.Shortcut
      extended bycom.izforge.izpack.util.os.Win_Shortcut

public class Win_Shortcut
extends Shortcut

This is the Microsoft Windows specific implementation of Shortcut.

Version:
0.0.1 / 3/4/02
Author:
Elmar Grom

Field Summary
private  ShellLink shortcut
           
 
Fields inherited from class com.izforge.izpack.util.os.Shortcut
ALL_USERS, APPLICATIONS, CURRENT_USER, DESKTOP, HIDE, MAXIMIZED, MINIMIZED, NORMAL, START_MENU, START_UP
 
Constructor Summary
Win_Shortcut()
           
 
Method Summary
 java.lang.String getDirectoryCreated()
          Returns the path of the directory where the link file is stored, if it was necessary during the previous save operation to create the directory.
 java.lang.String getFileName()
          Returns the fully qualified file name under which the link is saved on disk.
 java.util.Vector getProgramGroups(int userType)
          Returns a list of currently existing program groups, based on the requested type.
 void initialize(int type, java.lang.String name)
          This method initializes the object.
 boolean multipleUsers()
          Returns true if the target OS supports current user and all users.
 void save()
          Saves this link.
 void setArguments(java.lang.String arguments)
          Sets the command line arguments that will be passed to the target when the link is activated.
 void setDescription(java.lang.String description)
          Sets the description string that is used to identify the link in a menu or on the desktop.
 void setIconLocation(java.lang.String path, int index)
          Sets the location of the icon that is shown for the shortcut on the desktop.
 void setLinkName(java.lang.String name)
          Sets the name shown in a menu or on the desktop for the link.
 void setLinkType(int type)
          Sets the type of link
 void setProgramGroup(java.lang.String groupName)
          Sets the name of the program group this ShellLinbk should be placed in.
 void setShowCommand(int show)
          Sets the show command that is passed to the target application when the link is activated.
 void setTargetPath(java.lang.String path)
          Sets the absolute path to the shortcut target.
 void setUserType(int type)
          Sets the user type for the link
 void setWorkingDirectory(java.lang.String dir)
          Sets the working directory for the link target.
 boolean supported()
          Signals that this flavor of Shortcut supports the creation of shortcuts.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

shortcut

private ShellLink shortcut
Constructor Detail

Win_Shortcut

public Win_Shortcut()
Method Detail

initialize

public void initialize(int type,
                       java.lang.String name)
                throws java.lang.Exception
This method initializes the object. It is used as a replacement for the constructor because of the way it is instantiated through the TargetFactory.

Overrides:
initialize in class Shortcut
Parameters:
type - the type or classification of the program group in which the link should exist. The following types are recognized:
name - the name of the shortcut.
Throws:
java.lang.Exception

getProgramGroups

public java.util.Vector getProgramGroups(int userType)
Returns a list of currently existing program groups, based on the requested type. For example if the type is APPLICATIONS then all the names of the program groups in the applications menu would be returned.

Overrides:
getProgramGroups in class Shortcut
Parameters:
userType - the type of user for the program group set.
Returns:
a Vector of String objects that represent the names of the existing program groups. It is theoretically possible that this list is empty.
See Also:
Shortcut.APPLICATIONS, Shortcut.START_MENU

getFileName

public java.lang.String getFileName()
Returns the fully qualified file name under which the link is saved on disk. Note: this method returns valid results only if the instance was created from a file on disk or after a successful save operation.

Overrides:
getFileName in class Shortcut
Returns:
the fully qualified file name for the shell link

getDirectoryCreated

public java.lang.String getDirectoryCreated()
Returns the path of the directory where the link file is stored, if it was necessary during the previous save operation to create the directory. This method returns null if no save operation was carried out or there was no need to create a directory during the previous save operation.

Overrides:
getDirectoryCreated in class Shortcut
Returns:
the path of the directory where the link file is stored or null if no save operation was carried out or there was no need to create a directory during the previous save operation.

multipleUsers

public boolean multipleUsers()
Returns true if the target OS supports current user and all users.

Overrides:
multipleUsers in class Shortcut
Returns:
true if the target OS supports current and all users.

supported

public boolean supported()
Signals that this flavor of Shortcut supports the creation of shortcuts.

Overrides:
supported in class Shortcut
Returns:
always true

setArguments

public void setArguments(java.lang.String arguments)
Sets the command line arguments that will be passed to the target when the link is activated.

Overrides:
setArguments in class Shortcut
Parameters:
arguments - the command line arguments

setDescription

public void setDescription(java.lang.String description)
Sets the description string that is used to identify the link in a menu or on the desktop.

Overrides:
setDescription in class Shortcut
Parameters:
description - the descriptiojn string

setIconLocation

public void setIconLocation(java.lang.String path,
                            int index)
Sets the location of the icon that is shown for the shortcut on the desktop.

Overrides:
setIconLocation in class Shortcut
Parameters:
path - a fully qualified file name of a file that contains the icon.
index - the index of the specific icon to use in the file. If there is only one icon in the file, use an index of 0.

setProgramGroup

public void setProgramGroup(java.lang.String groupName)
Sets the name of the program group this ShellLinbk should be placed in.

Overrides:
setProgramGroup in class Shortcut
Parameters:
groupName - the name of the program group

setShowCommand

public void setShowCommand(int show)
                    throws java.lang.IllegalArgumentException
Sets the show command that is passed to the target application when the link is activated. The show command determines if the the window will be restored to the previous size, minimized, maximized or visible at all.

Note:
Using HIDE will cause the target window not to show at all. There is not even a button on the taskbar. This is a very useful setting when batch files are used to launch a Java application as it will then appear to run just like any native Windows application.

Overrides:
setShowCommand in class Shortcut
Parameters:
show - the show command. Valid settings are:
Throws:
java.lang.IllegalArgumentException
See Also:
#getShowCommand

setTargetPath

public void setTargetPath(java.lang.String path)
Sets the absolute path to the shortcut target.

Overrides:
setTargetPath in class Shortcut
Parameters:
path - the fully qualified file name of the target

setWorkingDirectory

public void setWorkingDirectory(java.lang.String dir)
Sets the working directory for the link target.

Overrides:
setWorkingDirectory in class Shortcut
Parameters:
dir - the working directory

setLinkName

public void setLinkName(java.lang.String name)
Sets the name shown in a menu or on the desktop for the link.

Overrides:
setLinkName in class Shortcut
Parameters:
name - The name that the link should display on a menu or on the desktop. Do not include a file extension.

setLinkType

public void setLinkType(int type)
                 throws java.lang.IllegalArgumentException
Sets the type of link

Overrides:
setLinkType in class Shortcut
Parameters:
type - The type of link desired. The following values can be set:
Throws:
java.lang.IllegalArgumentException - if an an invalid type is passed

setUserType

public void setUserType(int type)
Sets the user type for the link

Overrides:
setUserType in class Shortcut
See Also:
Shortcut.CURRENT_USER, Shortcut.ALL_USERS

save

public void save()
          throws java.lang.Exception
Saves this link.

Overrides:
save in class Shortcut
Throws:
java.lang.Exception - if problems are encountered