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 @ 38420
History | View | Annotate | Download (3.43 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.swing.api.SwingInstallerLocator; |
43 |
import org.gvsig.installer.swing.api.SwingInstallerManager; |
44 |
import org.slf4j.Logger; |
45 |
import org.slf4j.LoggerFactory; |
46 |
|
47 |
/**
|
48 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</a>
|
49 |
*/
|
50 |
public class InstallPackageExtension extends Extension { |
51 |
|
52 |
private static final Logger LOG = LoggerFactory |
53 |
.getLogger(InstallPackageExtension.class); |
54 |
|
55 |
public void execute(String actionCommand) { |
56 |
PluginsManager manager = PluginsLocator.getManager(); |
57 |
try {
|
58 |
PluginServices.getMDIManager().addCentredWindow( |
59 |
new InstallPackageWindow(manager.getApplicationFolder(),
|
60 |
manager.getInstallFolder())); |
61 |
} catch (Error e) { |
62 |
LOG.error("Error creating the wizard to install a package ", e);
|
63 |
} catch (Exception e) { |
64 |
LOG.error("Error creating the wizard to install a package ", e);
|
65 |
} |
66 |
} |
67 |
|
68 |
public void initialize() { |
69 |
Version version = ApplicationLocator.getManager().getVersion(); |
70 |
|
71 |
try {
|
72 |
SwingInstallerManager manager = SwingInstallerLocator |
73 |
.getSwingInstallerManager(); |
74 |
InputStream is = this.getClass().getResourceAsStream( |
75 |
"/defaultDownloadsURLs");
|
76 |
BufferedReader in = new BufferedReader(new InputStreamReader(is)); |
77 |
String line = null; |
78 |
for (line = in.readLine(); line != null; line = in.readLine()) { |
79 |
line = line.replace("$version", version.getFormat());
|
80 |
line = line.replace("<%Version%>", version.getFormat());
|
81 |
line = line.replace("$build", version.getBuildId());
|
82 |
line = line.replace("<%Build%>", version.getBuildId());
|
83 |
try {
|
84 |
manager.addDefaultDownloadURL(new URL(line)); |
85 |
} catch (MalformedURLException e) { |
86 |
LOG.error( |
87 |
"Error creating the default packages download URL pointing to "
|
88 |
+ line, e); |
89 |
} |
90 |
} |
91 |
manager.getInstallerManager().setVersion(version.getFormat()); |
92 |
} catch (Throwable e) { |
93 |
LOG.error("Error reading the default packages download URL file "
|
94 |
+ "/defaultDownloadsURLs", e);
|
95 |
} |
96 |
} |
97 |
|
98 |
public boolean isEnabled() { |
99 |
return true; |
100 |
} |
101 |
|
102 |
public boolean isVisible() { |
103 |
return true; |
104 |
} |
105 |
|
106 |
} |