com.izforge.izpack.util.os
Class Win_Shortcut

java.lang.Object
  extended by com.izforge.izpack.util.os.Shortcut
      extended by com.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
 
Fields inherited from class com.izforge.izpack.util.os.Shortcut
ALL_USERS, APPLICATIONS, CURRENT_USER, DESKTOP, HIDE, MAXIMIZED, MINIMIZED, NORMAL, START_MENU, START_UP, uninstaller
 
Constructor Summary
Win_Shortcut(Librarian librarian)
          Constructs a Win_Shortcut.
 
Method Summary
 String getBasePath()
          Returns the base path of the shortcut depending on type.
 String getFileName()
          Returns the fully qualified file name under which the link is saved on disk.
 int getHotkey()
          Gets the link hotKey
 String getIconLocation()
          returns icon Location
 int getLinkType()
          Gets the type of link types are:
Shortcut.DESKTOP Shortcut.APPLICATIONS Shortcut.START_MENU Shortcut.START_UP maps from ShellLink-types to Shortcut-types.
 List<String> getProgramGroups(int userType)
          Returns a list of currently existing program groups, based on the requested type.
 String getProgramsFolder(int current_user)
          Gets the Folders where to place the program-groups and their shortcuts, for the given usertype.
 boolean getRunAsAdministrator()
          Determines if the shortcut target should be run with administrator privileges.
 int getShowCommand()
           
 int getUserType()
          Gets the user type for the link
 String getWorkingDirectory()
          Gets the working directory for the link target.
 void initialize(int type, 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(String arguments)
          Sets the command line arguments that will be passed to the target when the link is activated.
 void setDescription(String description)
          Sets the description string that is used to identify the link in a menu or on the desktop.
 void setHotkey(int hotkey)
          Sets the link hotKey
 void setIconLocation(String path, int index)
          Sets the location of the icon that is shown for the shortcut on the desktop.
 void setLinkName(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(String groupName)
          Sets the name of the program group this ShellLinbk should be placed in.
 void setRunAsAdministrator(boolean runAsAdministrator)
          Determines if the shortcut target should be run with administrator privileges.
 void setShowCommand(int show)
          Sets the show command that is passed to the target application when the link is activated.
 void setTargetPath(String path)
          Sets the absolute path to the shortcut target.
 void setUserType(int type)
          Sets the user type for the link
 void setWorkingDirectory(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 com.izforge.izpack.util.os.Shortcut
cleanUp, execPostAction, getCreateForAll, setCategories, setCreateForAll, setEncoding, setKdeSubstUID, setKdeUserName, setMimetype, setTerminal, setTerminalOptions, setTryExec, setType, setUninstaller, setURL
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Win_Shortcut

public Win_Shortcut(Librarian librarian)
Constructs a Win_Shortcut.

Parameters:
librarian - the librarian
Method Detail

initialize

public void initialize(int type,
                       String name)
                throws 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.

Specified by:
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:
Exception

getBasePath

public String getBasePath()
                   throws Exception
Returns the base path of the shortcut depending on type. The base path is the directory that the short cut, (or its program group) will be created in. For instance, on Windows NT, a shortcut with user-type ALL_USERS, and link-type DESKTOP might have the base path "C:\Program Files\All Users\Desktop"

Overrides:
getBasePath in class Shortcut
Throws:
Exception
See Also:
setLinkType(int),

translates from ShellLink-UserTypes to Shortcut-UserTypes.


getProgramGroups

public List<String> 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 Start Menu\Programs menu would be returned.

Specified by:
getProgramGroups in class Shortcut
Parameters:
userType - the type of user for the program group set. (as Shortcut.utype)
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 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.

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

multipleUsers

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

Specified by:
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.

Specified by:
supported in class Shortcut
Returns:
always true

setArguments

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

Specified by:
setArguments in class Shortcut
Parameters:
arguments - the command line arguments

setDescription

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

Specified by:
setDescription in class Shortcut
Parameters:
description - the descriptiojn string

setIconLocation

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

Specified by:
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.

getIconLocation

public String getIconLocation()
returns icon Location

Specified by:
getIconLocation in class Shortcut
Returns:
iconLocation

setProgramGroup

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

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

setShowCommand

public void setShowCommand(int show)
                    throws 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.

Specified by:
setShowCommand in class Shortcut
Parameters:
show - the show command. Valid settings are:
Throws:
IllegalArgumentException
See Also:
internally maps from Shortcut. to ShellLink.

getShowCommand

public int getShowCommand()
Overrides:
getShowCommand in class Shortcut

setTargetPath

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

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

setWorkingDirectory

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

Specified by:
setWorkingDirectory in class Shortcut
Parameters:
dir - the working directory

getWorkingDirectory

public String getWorkingDirectory()
Gets the working directory for the link target.

Overrides:
getWorkingDirectory in class Shortcut
Returns:
the working directory.

setLinkName

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

Specified by:
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.

getLinkType

public int getLinkType()
Gets the type of link types are:
maps from ShellLink-types to Shortcut-types.

Specified by:
getLinkType in class Shortcut

setLinkType

public void setLinkType(int type)
                 throws IllegalArgumentException,
                        UnsupportedEncodingException
Sets the type of link

Specified by:
setLinkType in class Shortcut
Parameters:
type - The type of link desired. The following values can be set:
(note APPLICATION on Windows is 'Start Menu\Programs') APPLICATION is a Mac term.
Throws:
IllegalArgumentException - if an an invalid type is passed
UnsupportedEncodingException

getUserType

public int getUserType()
Gets the user type for the link

Specified by:
getUserType in class Shortcut
Returns:
userType
See Also:
Shortcut.CURRENT_USER, Shortcut.ALL_USERS

setUserType

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

Specified by:
setUserType in class Shortcut
Parameters:
type - the type of user for the link.
See Also:
Shortcut.CURRENT_USER,

if the linkPath for that type is empty, refuse to set.


setRunAsAdministrator

public void setRunAsAdministrator(boolean runAsAdministrator)
Determines if the shortcut target should be run with administrator privileges.

Overrides:
setRunAsAdministrator in class Shortcut
Parameters:
runAsAdministrator - if true, run the target with administrator privileges.

getRunAsAdministrator

public boolean getRunAsAdministrator()
Determines if the shortcut target should be run with administrator privileges.

Overrides:
getRunAsAdministrator in class Shortcut
Returns:
true, if the target will run with administrator privileges

save

public void save()
          throws Exception
Saves this link.

Specified by:
save in class Shortcut
Throws:
Exception - if problems are encountered

getHotkey

public int getHotkey()
Gets the link hotKey

Overrides:
getHotkey in class Shortcut
Returns:
int hotKey

setHotkey

public void setHotkey(int hotkey)
Sets the link hotKey

Overrides:
setHotkey in class Shortcut
Parameters:
hotkey - incoming 2 byte hotkey is: high byte modifier: SHIFT = 0x01 CONTROL= 0x02 ALT = 0x04 EXT = 0x08

lower byte contains ascii letter. ie 0x0278 represents CTRL+x 0x068a represents CTRL+ALT+z


getProgramsFolder

public String getProgramsFolder(int current_user)
Gets the Folders where to place the program-groups and their shortcuts, for the given usertype.

Specified by:
getProgramsFolder in class Shortcut
Parameters:
current_user - one of current or all
Returns:
The Foldername or null on unsupported platforms.
See Also:
Shortcut.getProgramsFolder(int)


Copyright © 2018. All rights reserved.