root / import / ext3D / trunk / install-extension3d / IzPack / src / lib / com / izforge / izpack / util / os / Shortcut.java @ 15280
History | View | Annotate | Download (14.4 KB)
1 |
/*
|
---|---|
2 |
* $Id: Shortcut.java,v 1.1 2006/06/14 07:29:07 cesar Exp $
|
3 |
* IzPack
|
4 |
* Copyright (C) 2002 by Elmar Grom
|
5 |
*
|
6 |
* File : Shortcut.java
|
7 |
* Description : mapping class for the shortcut API
|
8 |
* Author's email : elmar@grom.net
|
9 |
* Website : http://www.izforge.com
|
10 |
*
|
11 |
* This program is free software; you can redistribute it and/or
|
12 |
* modify it under the terms of the GNU General Public License
|
13 |
* as published by the Free Software Foundation; either version 2
|
14 |
* of the License, or any later version.
|
15 |
*
|
16 |
* This program is distributed in the hope that it will be useful,
|
17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19 |
* GNU General Public License for more details.
|
20 |
*
|
21 |
* You should have received a copy of the GNU General Public License
|
22 |
* along with this program; if not, write to the Free Software
|
23 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
24 |
*/
|
25 |
|
26 |
package com.izforge.izpack.util.os; |
27 |
|
28 |
import java.util.Vector; |
29 |
|
30 |
/*---------------------------------------------------------------------------*/
|
31 |
/**
|
32 |
* This class represents a shortcut in a operating system independent way.
|
33 |
* OS specific subclasses are used to implement the necessary mapping from
|
34 |
* this generic API to the classes that reflect the system dependent AIP.
|
35 |
*
|
36 |
* @see com.izforge.izpack.util.TargetFactory
|
37 |
*
|
38 |
* @version 0.0.1 / 3/4/02
|
39 |
* @author Elmar Grom
|
40 |
*/
|
41 |
public class Shortcut |
42 |
{ |
43 |
// ------------------------------------------------------------------------
|
44 |
// Constant Definitions
|
45 |
// ------------------------------------------------------------------------
|
46 |
public static final int APPLICATIONS = 1; |
47 |
public static final int START_MENU = 2; |
48 |
public static final int DESKTOP = 3; |
49 |
public static final int START_UP = 4; |
50 |
|
51 |
/** Hide the window when starting.*/
|
52 |
public static final int HIDE = 0; |
53 |
/** Show the window 'normal' when starting. Usually restores the window
|
54 |
properties at the last shut-down. */
|
55 |
public static final int NORMAL = 1; |
56 |
public static final int MINIMIZED = 2; |
57 |
/** Show the window maximized when starting. */
|
58 |
public static final int MAXIMIZED = 3; |
59 |
|
60 |
/** identifies the user type as the current user */
|
61 |
public static final int CURRENT_USER = 1; |
62 |
/** identifies the user type as valid for all users */
|
63 |
public static final int ALL_USERS = 2; |
64 |
|
65 |
/*--------------------------------------------------------------------------*/
|
66 |
/**
|
67 |
* This method initializes the object. It is used as a replacement for the
|
68 |
* contructor because of the way it is instantiated through the
|
69 |
* <code>TargetFactory</code>.
|
70 |
*
|
71 |
* @param type the type or classification of the program group in which
|
72 |
* the link should exist.
|
73 |
* @param name the name of the shortcut.
|
74 |
*/
|
75 |
public void initialize (int type, |
76 |
String name) throws Exception |
77 |
{ |
78 |
} |
79 |
|
80 |
/*--------------------------------------------------------------------------*/
|
81 |
/**
|
82 |
* Returns the base path of the shortcut depending on type. The base path is
|
83 |
* the directory that the short cut, (or its program group) will be created
|
84 |
* in. For instance, on Windows NT, a shortcut with user-type ALL_USERS, and
|
85 |
* link-type DESKTOP might have the base path
|
86 |
* "C:\Program Files\All Users\Desktop"
|
87 |
*
|
88 |
* @see #setLinkType(int)
|
89 |
* @see #setUserType(int)
|
90 |
*/
|
91 |
public String getBasePath () throws Exception |
92 |
{ |
93 |
return (""); |
94 |
} |
95 |
|
96 |
/*--------------------------------------------------------------------------*/
|
97 |
/**
|
98 |
* Returns a list of currently existing program groups, based on the
|
99 |
* requested type. For example if the type is <code>APPLICATIONS</code> then
|
100 |
* all the names of the program groups in the Start Menu\Programs menu would be
|
101 |
* returned.
|
102 |
*
|
103 |
* @param userType the type of user for the program group set.
|
104 |
*
|
105 |
* @return a <code>Vector</code> of <code>String</code> objects that
|
106 |
* represent the names of the existing program groups. It is
|
107 |
* theoretically possible that this list is empty.
|
108 |
*
|
109 |
* @see #APPLICATIONS
|
110 |
* @see #START_MENU
|
111 |
*/
|
112 |
public Vector getProgramGroups (int userType) |
113 |
{ |
114 |
return (null); |
115 |
} |
116 |
|
117 |
/*--------------------------------------------------------------------------*/
|
118 |
/**
|
119 |
* Subclass implementations return the fully qualified file name under which
|
120 |
* the link is saved on disk. <b>Note:</b> this method returns valid results
|
121 |
* only if the instance was created from a file on disk or after a successful
|
122 |
* save operation. An instance of this class returns an empty string.
|
123 |
*
|
124 |
* @return an empty <code>String</code>
|
125 |
*/
|
126 |
public String getFileName () |
127 |
{ |
128 |
return (""); |
129 |
} |
130 |
|
131 |
/*--------------------------------------------------------------------------*/
|
132 |
/**
|
133 |
* Subclass implementations return the path of the directory where the link
|
134 |
* file is stored, if it was necessary during the previous save operation to
|
135 |
* create the directory. This method returns <code>null</code> if no save
|
136 |
* operation was carried out or there was no need to create a directory
|
137 |
* during the previous save operation.
|
138 |
*
|
139 |
* @return this implementation returns always <code>null</code>.
|
140 |
*/
|
141 |
public String getDirectoryCreated () |
142 |
{ |
143 |
return (null); |
144 |
} |
145 |
|
146 |
/*--------------------------------------------------------------------------*/
|
147 |
/**
|
148 |
* Returns <code>true</code> if the target OS supports current user and
|
149 |
* all users.
|
150 |
*
|
151 |
* @return <code>true</code> if the target OS supports current and all users.
|
152 |
*/
|
153 |
public boolean multipleUsers () |
154 |
{ |
155 |
return (false); |
156 |
} |
157 |
|
158 |
/*--------------------------------------------------------------------------*/
|
159 |
/**
|
160 |
* Determines if a specific instance of this class supports the creation of
|
161 |
* shortcuts. The use of this method might seem odd, since one would not
|
162 |
* implement a flavor of this class that does not actually support the creation
|
163 |
* of shortcuts. In other words all flavors will in all probability return true.
|
164 |
* The only version that can be expected to return false is this class itself,
|
165 |
* since it has no actual implementation for shortcut creation. This is left
|
166 |
* to OS specific flavors. If the installer is launched on a unsupported OS
|
167 |
* there will be no appropriate flavor of this class, which will cause this
|
168 |
* class itself to be instantiated. The client code can now determine by
|
169 |
* calling this method if the active OS is supported and take appropriate action.
|
170 |
*
|
171 |
* @return <code>true</code> if the creation of shortcuts is supported,
|
172 |
* <code>flase</code> if this is not supported.
|
173 |
*/
|
174 |
public boolean supported () |
175 |
{ |
176 |
return (false); |
177 |
} |
178 |
|
179 |
/*--------------------------------------------------------------------------*/
|
180 |
/**
|
181 |
* Sets the command line arguments that will be passed to the target when
|
182 |
* the link is activated.
|
183 |
*
|
184 |
* @param arguments the command line arguments
|
185 |
*/
|
186 |
public void setArguments (String arguments) |
187 |
{ |
188 |
} |
189 |
|
190 |
/*--------------------------------------------------------------------------*/
|
191 |
/**
|
192 |
* Sets the description string that is used to identify the link in a menu
|
193 |
* or on the desktop.
|
194 |
*
|
195 |
* @param description the descriptiojn string
|
196 |
*/
|
197 |
public void setDescription (String description) |
198 |
{ |
199 |
} |
200 |
|
201 |
/*--------------------------------------------------------------------------*/
|
202 |
/**
|
203 |
* Sets the location of the icon that is shown for the shortcut on the
|
204 |
* desktop.
|
205 |
*
|
206 |
* @param path a fully qualified file name of a file that contains
|
207 |
* the icon.
|
208 |
* @param index the index of the specific icon to use in the file.
|
209 |
* If there is only one icon in the file, use an index
|
210 |
* of 0.
|
211 |
*/
|
212 |
public void setIconLocation (String path, |
213 |
int index)
|
214 |
{ |
215 |
} |
216 |
|
217 |
/*--------------------------------------------------------------------------*/
|
218 |
/**
|
219 |
* returns icon Location
|
220 |
*
|
221 |
* @return iconLocation
|
222 |
*/
|
223 |
public String getIconLocation() |
224 |
{ |
225 |
return ""; |
226 |
} |
227 |
|
228 |
/*--------------------------------------------------------------------------*/
|
229 |
/**
|
230 |
* Sets the name of the program group this ShellLinbk should be placed in.
|
231 |
*
|
232 |
* @param groupName the name of the program group
|
233 |
*/
|
234 |
public void setProgramGroup (String groupName) |
235 |
{ |
236 |
} |
237 |
|
238 |
/*--------------------------------------------------------------------------*/
|
239 |
/**
|
240 |
* Sets the show command that is passed to the target application when the
|
241 |
* link is activated. The show command determines if the the window will be
|
242 |
* restored to the previous size, minimized, maximized or visible at all.
|
243 |
* <br><br>
|
244 |
* <b>Note:</b><br>
|
245 |
* Using <code>HIDE</code> will cause the target window not to show at
|
246 |
* all. There is not even a button on the taskbar. This is a very useful
|
247 |
* setting when batch files are used to launch a Java application as it
|
248 |
* will then appear to run just like any native Windows application.<br>
|
249 |
*
|
250 |
* @param show the show command. Valid settings are: <br>
|
251 |
* <ul>
|
252 |
* <li>{@link com.izforge.izpack.util.os.Shortcut#HIDE}
|
253 |
* <li>{@link com.izforge.izpack.util.os.Shortcut#NORMAL}
|
254 |
* <li>{@link com.izforge.izpack.util.os.Shortcut#MINIMIZED}
|
255 |
* <li>{@link com.izforge.izpack.util.os.Shortcut#MAXIMIZED}
|
256 |
* </ul>
|
257 |
*
|
258 |
* @see #getShowCommand
|
259 |
*/
|
260 |
public void setShowCommand (int show) |
261 |
{ |
262 |
} |
263 |
|
264 |
/* retrieves showCommand from the OS. Translates it into Shortcut.XXX terms.
|
265 |
*/
|
266 |
public int getShowCommand() |
267 |
{ |
268 |
return Shortcut.NORMAL;
|
269 |
} |
270 |
|
271 |
/*--------------------------------------------------------------------------*/
|
272 |
/**
|
273 |
* Sets the absolute path to the shortcut target.
|
274 |
*
|
275 |
* @param path the fully qualified file name of the target
|
276 |
*/
|
277 |
public void setTargetPath (String path) |
278 |
{ |
279 |
} |
280 |
|
281 |
/*--------------------------------------------------------------------------*/
|
282 |
/**
|
283 |
* Sets the working directory for the link target.
|
284 |
*
|
285 |
* @param dir the working directory
|
286 |
*/
|
287 |
public void setWorkingDirectory (String dir) |
288 |
{ |
289 |
} |
290 |
|
291 |
/*--------------------------------------------------------------------------*/
|
292 |
/**
|
293 |
* Gets the working directory for the link target.
|
294 |
*
|
295 |
* @return the working directory.
|
296 |
*/
|
297 |
public String getWorkingDirectory () |
298 |
{ |
299 |
return ""; |
300 |
} |
301 |
|
302 |
/*--------------------------------------------------------------------------*/
|
303 |
/**
|
304 |
* Sets the name shown in a menu or on the desktop for the link.
|
305 |
*
|
306 |
* @param name The name that the link should display on a menu or on
|
307 |
* the desktop. Do not include a file extension.
|
308 |
*/
|
309 |
public void setLinkName (String name) |
310 |
{ |
311 |
} |
312 |
|
313 |
/*--------------------------------------------------------------------------*/
|
314 |
/**
|
315 |
* Gets the type of link
|
316 |
* types are: <br>
|
317 |
* <ul>
|
318 |
* <li>{@link com.izforge.izpack.util.os.Shortcut#DESKTOP}
|
319 |
* <li>{@link com.izforge.izpack.util.os.Shortcut#APPLICATIONS}
|
320 |
* <li>{@link com.izforge.izpack.util.os.Shortcut#START_MENU}
|
321 |
* <li>{@link com.izforge.izpack.util.os.Shortcut#START_UP}
|
322 |
* </ul>
|
323 |
*/
|
324 |
public int getLinkType() |
325 |
{ |
326 |
// fake default.
|
327 |
return Shortcut.DESKTOP;
|
328 |
} |
329 |
|
330 |
/*--------------------------------------------------------------------------*/
|
331 |
/**
|
332 |
* Sets the type of link
|
333 |
*
|
334 |
* @param type The type of link desired. The following values can be set:<br>
|
335 |
* <ul>
|
336 |
* <li>{@link com.izforge.izpack.util.os.Shortcut#DESKTOP}
|
337 |
* <li>{@link com.izforge.izpack.util.os.Shortcut#APPLICATIONS}
|
338 |
* <li>{@link com.izforge.izpack.util.os.Shortcut#START_MENU}
|
339 |
* <li>{@link com.izforge.izpack.util.os.Shortcut#START_UP}
|
340 |
* </ul>
|
341 |
*
|
342 |
* @exception IllegalArgumentException if an an invalid type is passed
|
343 |
*/
|
344 |
public void setLinkType (int type) throws IllegalArgumentException |
345 |
{ |
346 |
} |
347 |
|
348 |
/*--------------------------------------------------------------------------*/
|
349 |
/**
|
350 |
* Sets the user type for the link
|
351 |
*
|
352 |
* @param type the type of user for the link.
|
353 |
*
|
354 |
* @see #CURRENT_USER
|
355 |
* @see #ALL_USERS
|
356 |
*/
|
357 |
public void setUserType (int type) |
358 |
{ |
359 |
} |
360 |
|
361 |
/*--------------------------------------------------------------------------*/
|
362 |
/**
|
363 |
* Gets the user type for the link
|
364 |
*
|
365 |
* @return userType
|
366 |
* @see #CURRENT_USER
|
367 |
* @see #ALL_USERS
|
368 |
*/
|
369 |
public int getUserType() |
370 |
{ |
371 |
return CURRENT_USER;
|
372 |
} |
373 |
|
374 |
/*--------------------------------------------------------------------------*/
|
375 |
/**
|
376 |
* Saves this link.
|
377 |
*
|
378 |
* @exception Exception if problems are encountered
|
379 |
*/
|
380 |
public void save () throws Exception |
381 |
{ |
382 |
} |
383 |
|
384 |
/*--------------------------------------------------------------------------*/
|
385 |
/**
|
386 |
* Gets the link hotKey
|
387 |
*
|
388 |
* @return int hotKey
|
389 |
*/
|
390 |
public int getHotkey() |
391 |
{ |
392 |
return 0; |
393 |
} |
394 |
|
395 |
/*--------------------------------------------------------------------------*/
|
396 |
/**
|
397 |
* Sets the link hotKey
|
398 |
*
|
399 |
* @param hotkey
|
400 |
*/
|
401 |
public void setHotkey(int hotkey) |
402 |
{ |
403 |
} |
404 |
|
405 |
/**
|
406 |
* Sets the Encoding
|
407 |
* @param string
|
408 |
**/
|
409 |
public void setEncoding(String string) |
410 |
{ |
411 |
} |
412 |
|
413 |
/**
|
414 |
* This sets the Mimetype
|
415 |
* @param string
|
416 |
**/
|
417 |
public void setMimetype(String string) |
418 |
{ |
419 |
} |
420 |
|
421 |
/**
|
422 |
* Sets the terminal
|
423 |
* @param string
|
424 |
**/
|
425 |
public void setTerminal(String string) |
426 |
{ |
427 |
} |
428 |
|
429 |
/**
|
430 |
* This sets the terminals-options
|
431 |
* @param string
|
432 |
**/
|
433 |
public void setTerminalOptions(String string) |
434 |
{ |
435 |
} |
436 |
|
437 |
/**
|
438 |
* This sets the shortcut type
|
439 |
* @param string
|
440 |
**/
|
441 |
public void setType(String string) |
442 |
{ |
443 |
} |
444 |
|
445 |
/**
|
446 |
* This sets the KdeSubstUID
|
447 |
* @param string
|
448 |
**/
|
449 |
public void setKdeSubstUID(String string) |
450 |
{ |
451 |
} |
452 |
|
453 |
/**
|
454 |
* This sets the URL
|
455 |
* @param string
|
456 |
**/
|
457 |
public void setURL(String string) |
458 |
{ |
459 |
} |
460 |
|
461 |
|
462 |
} |
463 |
/*---------------------------------------------------------------------------*/
|
464 |
|