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