root / branches / v2_0_0_prep / extensions / org.gvsig.installer.app / org.gvsig.installer.app.extension / src / main / java / org / gvsig / installer / app / extension / execution / InstallPackageExtension.java @ 38438
History | View | Annotate | Download (3.35 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
|
23 |
/*
|
24 |
* AUTHORS (In addition to CIT):
|
25 |
* 2010 {Prodevelop} {Task}
|
26 |
*/
|
27 |
|
28 |
package org.gvsig.installer.app.extension.execution; |
29 |
|
30 |
import java.io.BufferedReader; |
31 |
import java.io.InputStream; |
32 |
import java.io.InputStreamReader; |
33 |
import java.net.MalformedURLException; |
34 |
import java.net.URL; |
35 |
|
36 |
import org.gvsig.andami.PluginServices; |
37 |
import org.gvsig.andami.PluginsLocator; |
38 |
import org.gvsig.andami.PluginsManager; |
39 |
import org.gvsig.andami.plugins.Extension; |
40 |
import org.gvsig.app.ApplicationLocator; |
41 |
import org.gvsig.app.extension.Version; |
42 |
import org.gvsig.installer.lib.api.InstallerLocator; |
43 |
import org.gvsig.installer.swing.api.SwingInstallerLocator; |
44 |
import org.gvsig.installer.swing.api.SwingInstallerManager; |
45 |
import org.slf4j.Logger; |
46 |
import org.slf4j.LoggerFactory; |
47 |
|
48 |
/**
|
49 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</a>
|
50 |
*/
|
51 |
public class InstallPackageExtension extends Extension { |
52 |
|
53 |
private static final Logger LOG = LoggerFactory |
54 |
.getLogger(InstallPackageExtension.class); |
55 |
|
56 |
public void execute(String actionCommand) { |
57 |
PluginsManager manager = PluginsLocator.getManager(); |
58 |
try {
|
59 |
PluginServices.getMDIManager().addCentredWindow( |
60 |
new InstallPackageWindow(manager.getApplicationFolder(),
|
61 |
manager.getInstallFolder())); |
62 |
} catch (Error e) { |
63 |
LOG.error("Error creating the wizard to install a package ", e);
|
64 |
} catch (Exception e) { |
65 |
LOG.error("Error creating the wizard to install a package ", e);
|
66 |
} |
67 |
} |
68 |
|
69 |
public void initialize() { |
70 |
Version version = ApplicationLocator.getManager().getVersion(); |
71 |
InstallerLocator.getInstallerManager().setVersion( |
72 |
version.getFormat() + "-" + version.getBuildId());
|
73 |
try {
|
74 |
SwingInstallerManager manager = SwingInstallerLocator |
75 |
.getSwingInstallerManager(); |
76 |
|
77 |
InputStream is = this.getClass().getResourceAsStream( |
78 |
"/defaultDownloadsURLs");
|
79 |
BufferedReader in = new BufferedReader(new InputStreamReader(is)); |
80 |
String line = null; |
81 |
for (line = in.readLine(); line != null; line = in.readLine()) { |
82 |
try {
|
83 |
manager.addDefaultDownloadURL(line); |
84 |
} catch (MalformedURLException e) { |
85 |
LOG.error( |
86 |
"Error creating the default packages download URL pointing to "
|
87 |
+ line, e); |
88 |
} |
89 |
} |
90 |
manager.getInstallerManager().setVersion(version.getFormat()); |
91 |
} catch (Throwable e) { |
92 |
LOG.error("Error reading the default packages download URL file "
|
93 |
+ "/defaultDownloadsURLs", e);
|
94 |
} |
95 |
} |
96 |
|
97 |
public boolean isEnabled() { |
98 |
return true; |
99 |
} |
100 |
|
101 |
public boolean isVisible() { |
102 |
return true; |
103 |
} |
104 |
|
105 |
} |