View Javadoc

1   /*
2    *  XNap - A P2P framework and client.
3    *
4    *  See the file AUTHORS for copyright information.
5    *
6    *  This program is free software; you can redistribute it and/or modify
7    *  it under the terms of the GNU General Public License as published by
8    *  the Free Software Foundation.
9    *
10   *  This program is distributed in the hope that it will be useful,
11   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   *  GNU General Public License for more details.
14   *
15   *  You should have received a copy of the GNU General Public License
16   *  along with this program; if not, write to the Free Software
17   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18   */
19  
20  package org.xnap.util.launcher;
21  
22  import java.io.File;
23  import java.io.IOException;
24  import java.net.URL;
25  
26  import org.xnap.XNap;
27  import org.xnap.util.SystemHelper;
28  
29  import ziga.util.WindowsFileLauncher;
30  
31  /***
32   * Provides a Windows launcher based on ziga.dll.
33   */
34  public class WindowsLauncher extends DefaultLauncher {
35  
36      //--- Constant(s) ---
37  
38      //--- Data field(s) ---
39  
40      //--- Constructor(s) ---
41  
42      public WindowsLauncher()
43      {
44  		super("ziga.dll", XNap.tr("Windows (requires ziga.dll)"), "");
45      }
46  
47      //--- Method(s) ---
48  
49      /***
50       * Returns false.
51       */
52      public boolean isEditable()
53      {
54  		return false;
55      }
56  
57      /***
58       * Returns true, if ziga.dll is loaded.
59       */
60      public boolean isEnabled()
61      {
62  		return SystemHelper.isZigaDllLoaded;
63      }
64  
65      /***
66       * Launches <code>file</code>.
67       */
68      public void open(File file) throws IOException
69      {
70  		try {
71  			WindowsFileLauncher.open(file.getAbsolutePath());
72  		}
73  		catch (UnsatisfiedLinkError e) {
74  			throw new IOException("ziga.dll not loaded");
75  		}
76      }
77  
78  	public void open(URL url) throws IOException
79      {
80  		try {
81  			WindowsFileLauncher.open(url.toExternalForm());
82  		}
83  		catch (UnsatisfiedLinkError e) {
84  			throw new IOException("ziga.dll not loaded");
85  		}
86      }
87  
88  }