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 | 32448 | jpiera | /* gvSIG. Geographic Information System of the Valencian Government
|
---|---|---|---|
2 | 33730 | cordinyana | *
|
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 | 32448 | jpiera | |
23 | /*
|
||
24 | 33730 | cordinyana | * AUTHORS (In addition to CIT):
|
25 | * 2010 {Prodevelop} {Task}
|
||
26 | */
|
||
27 | |||
28 | 32448 | jpiera | package org.gvsig.installer.app.extension.execution; |
29 | |||
30 | 37417 | fdiaz | import java.io.BufferedReader; |
31 | import java.io.InputStream; |
||
32 | import java.io.InputStreamReader; |
||
33 | 34003 | cordinyana | import java.net.MalformedURLException; |
34 | import java.net.URL; |
||
35 | |||
36 | 32603 | jpiera | import org.gvsig.andami.PluginServices; |
37 | 34484 | cordinyana | import org.gvsig.andami.PluginsLocator; |
38 | import org.gvsig.andami.PluginsManager; |
||
39 | 32448 | jpiera | import org.gvsig.andami.plugins.Extension; |
40 | 34486 | cordinyana | import org.gvsig.app.ApplicationLocator; |
41 | import org.gvsig.app.extension.Version; |
||
42 | 34003 | cordinyana | import org.gvsig.installer.swing.api.SwingInstallerLocator; |
43 | 37417 | fdiaz | import org.gvsig.installer.swing.api.SwingInstallerManager; |
44 | import org.slf4j.Logger; |
||
45 | import org.slf4j.LoggerFactory; |
||
46 | 32448 | jpiera | |
47 | /**
|
||
48 | * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</a>
|
||
49 | */
|
||
50 | 32603 | jpiera | public class InstallPackageExtension extends Extension { |
51 | 32448 | jpiera | |
52 | 37417 | fdiaz | private static final Logger LOG = LoggerFactory |
53 | .getLogger(InstallPackageExtension.class); |
||
54 | 32448 | jpiera | |
55 | 37417 | fdiaz | 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 | 32448 | jpiera | |
68 | 37417 | fdiaz | public void initialize() { |
69 | Version version = ApplicationLocator.getManager().getVersion(); |
||
70 | 32448 | jpiera | |
71 | 37417 | fdiaz | 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 | 38420 | cordinyana | line = line.replace("$build", version.getBuildId());
|
82 | line = line.replace("<%Build%>", version.getBuildId());
|
||
83 | 37417 | fdiaz | 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 | 37489 | nfrancisco | manager.getInstallerManager().setVersion(version.getFormat()); |
92 | 37417 | fdiaz | } catch (Throwable e) { |
93 | LOG.error("Error reading the default packages download URL file "
|
||
94 | + "/defaultDownloadsURLs", e);
|
||
95 | } |
||
96 | } |
||
97 | 34003 | cordinyana | |
98 | 37417 | fdiaz | public boolean isEnabled() { |
99 | return true; |
||
100 | } |
||
101 | 33730 | cordinyana | |
102 | 37417 | fdiaz | public boolean isVisible() { |
103 | return true; |
||
104 | } |
||
105 | 33730 | cordinyana | |
106 | 32448 | jpiera | } |