svn-gvsig-desktop / trunk / extensions / org.gvsig.installer.app.extension / src / main / java / org / gvsig / installer / app / extension / execution / InstallPackageExtension.java @ 38447
History | View | Annotate | Download (3.71 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.installer.app.extension.BackportrHelper.ApplicationLocator; |
37 |
import org.gvsig.installer.app.extension.BackportrHelper.PluginsLocator; |
38 |
import org.gvsig.installer.app.extension.BackportrHelper.PluginsManager; |
39 |
import org.gvsig.installer.swing.api.SwingInstallerLocator; |
40 |
import org.gvsig.installer.swing.api.SwingInstallerManager; |
41 |
import org.slf4j.Logger; |
42 |
import org.slf4j.LoggerFactory; |
43 |
|
44 |
import com.iver.andami.PluginServices; |
45 |
import com.iver.andami.plugins.Extension; |
46 |
import com.iver.cit.gvsig.Version; |
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 |
if ("tools-addonsmanager".equalsIgnoreCase(actionCommand)) { |
58 |
PluginsManager manager = PluginsLocator.getManager(); |
59 |
try {
|
60 |
PluginServices.getMDIManager().addCentredWindow( |
61 |
new InstallPackageWindow(
|
62 |
manager.getApplicationFolder(), manager |
63 |
.getInstallFolder())); |
64 |
} catch (Error e) { |
65 |
LOG.error("Error creating the wizard to install a package ", e);
|
66 |
} catch (Exception e) { |
67 |
LOG.error("Error creating the wizard to install a package ", e);
|
68 |
} |
69 |
} |
70 |
} |
71 |
|
72 |
public void initialize() { |
73 |
Version version = ApplicationLocator.getManager().getVersion(); |
74 |
|
75 |
try {
|
76 |
PluginsLocator.getIconThemeManager().getCurrent().registerDefault( |
77 |
"tools-addonsmanager",
|
78 |
this.getClass().getClassLoader().getResource("images/action/tools-addonsmanager.png") |
79 |
); |
80 |
|
81 |
SwingInstallerManager manager = SwingInstallerLocator |
82 |
.getSwingInstallerManager(); |
83 |
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 |
line = line.replace("$version", version.getFormat());
|
89 |
line = line.replace("<%Version%>", version.getFormat());
|
90 |
try {
|
91 |
manager.addDefaultDownloadURL(new URL(line)); |
92 |
} catch (MalformedURLException e) { |
93 |
LOG.error( |
94 |
"Error creating the default packages download URL pointing to "
|
95 |
+ line, e); |
96 |
} |
97 |
} |
98 |
manager.getInstallerManager().setVersion(version.getFormat()); |
99 |
} catch (Throwable e) { |
100 |
LOG.error("Error reading the default packages download URL file "
|
101 |
+ "/defaultDownloadsURLs", e);
|
102 |
} |
103 |
} |
104 |
|
105 |
public boolean isEnabled() { |
106 |
return true; |
107 |
} |
108 |
|
109 |
public boolean isVisible() { |
110 |
return true; |
111 |
} |
112 |
|
113 |
|
114 |
|
115 |
|
116 |
} |