Revision 37290
tags/v2_0_0_Build_2040/extensions/org.gvsig.symbology.app/org.gvsig.symbology.app.importsymbols/src/main/java/org/gvsig/symbology/app/importsymbols/ImportSymbolsExtension.java | ||
---|---|---|
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 |
package org.gvsig.symbology.app.importsymbols; |
|
24 |
|
|
25 |
import java.awt.Component; |
|
26 |
import java.io.File; |
|
27 |
import java.io.FileInputStream; |
|
28 |
import java.io.FileOutputStream; |
|
29 |
import java.io.IOException; |
|
30 |
import java.net.URL; |
|
31 |
import java.text.MessageFormat; |
|
32 |
import java.util.HashSet; |
|
33 |
import java.util.Set; |
|
34 |
|
|
35 |
import javax.swing.JFileChooser; |
|
36 |
import javax.swing.JOptionPane; |
|
37 |
import javax.swing.filechooser.FileFilter; |
|
38 |
|
|
39 |
import org.slf4j.Logger; |
|
40 |
import org.slf4j.LoggerFactory; |
|
41 |
|
|
42 |
import org.gvsig.andami.plugins.Extension; |
|
43 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
|
44 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolManager; |
|
45 |
import org.gvsig.symbology.SymbologyLocator; |
|
46 |
import org.gvsig.symbology.SymbologyManager; |
|
47 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.IPictureMarkerSymbol; |
|
48 |
import org.gvsig.tools.ToolsLocator; |
|
49 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
50 |
import org.gvsig.tools.persistence.PersistentState; |
|
51 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
52 |
import org.gvsig.tools.persistence.exception.PersistenceValidateExceptions; |
|
53 |
|
|
54 |
public class ImportSymbolsExtension extends Extension { |
|
55 |
|
|
56 |
private static Logger LOG = |
|
57 |
LoggerFactory.getLogger(ImportSymbolsExtension.class); |
|
58 |
|
|
59 |
private static final Set<String> imageExtensionsAllowed; |
|
60 |
|
|
61 |
static { |
|
62 |
imageExtensionsAllowed = new HashSet<String>(); |
|
63 |
imageExtensionsAllowed.add("png"); |
|
64 |
imageExtensionsAllowed.add("jpg"); |
|
65 |
imageExtensionsAllowed.add("jpeg"); |
|
66 |
imageExtensionsAllowed.add("gif"); |
|
67 |
imageExtensionsAllowed.add("bmp"); |
|
68 |
imageExtensionsAllowed.add("svg"); |
|
69 |
} |
|
70 |
|
|
71 |
// returns the output folder (/home/user/gvSIG/Symbols) |
|
72 |
private File getOutputFolderPath() { |
|
73 |
|
|
74 |
SymbolManager manager = MapContextLocator.getSymbolManager(); |
|
75 |
return new File(manager.getSymbolPreferences().getSymbolLibraryPath()); |
|
76 |
} |
|
77 |
|
|
78 |
private String deleteExtension(File file) { |
|
79 |
String outFileName = |
|
80 |
file.getPath().substring(0, file.getPath().lastIndexOf(".")); |
|
81 |
return outFileName; |
|
82 |
|
|
83 |
} |
|
84 |
|
|
85 |
// gets the selection image (from filename.png it returns filenamesel.png, |
|
86 |
// for example) |
|
87 |
private File getSelImage(File imageIn) { |
|
88 |
|
|
89 |
String cadena = deleteExtension(imageIn); |
|
90 |
String extension = |
|
91 |
imageIn.getPath().substring(imageIn.getPath().lastIndexOf("."), |
|
92 |
imageIn.getPath().length()); |
|
93 |
|
|
94 |
String selPath = cadena + "sel" + extension; |
|
95 |
File imageOut = new File(selPath); |
|
96 |
|
|
97 |
return imageOut; |
|
98 |
|
|
99 |
} |
|
100 |
|
|
101 |
// Copies File imageIn to imageOut |
|
102 |
private void copy(File imageIn, File imageOut) throws IOException { |
|
103 |
|
|
104 |
FileInputStream from = null; |
|
105 |
FileOutputStream to = null; |
|
106 |
|
|
107 |
from = new FileInputStream(imageIn.getPath()); |
|
108 |
to = new FileOutputStream(imageOut.getPath()); |
|
109 |
|
|
110 |
try { |
|
111 |
|
|
112 |
byte[] buffer = new byte[4096]; |
|
113 |
int bytesRead; |
|
114 |
|
|
115 |
while ((bytesRead = from.read(buffer)) != -1) { |
|
116 |
to.write(buffer, 0, bytesRead); // write |
|
117 |
} |
|
118 |
|
|
119 |
} finally { |
|
120 |
if (from != null) { |
|
121 |
try { |
|
122 |
from.close(); |
|
123 |
} catch (IOException e) { |
|
124 |
; |
|
125 |
} |
|
126 |
} |
|
127 |
if (to != null) { |
|
128 |
try { |
|
129 |
to.close(); |
|
130 |
} catch (IOException e) { |
|
131 |
; |
|
132 |
} |
|
133 |
} |
|
134 |
} |
|
135 |
|
|
136 |
} |
|
137 |
|
|
138 |
private void addImageSymbol(File image) throws IOException { |
|
139 |
|
|
140 |
int option; |
|
141 |
boolean sobreescribir = true; |
|
142 |
File selImage = getSelImage(image); |
|
143 |
|
|
144 |
// if home/gvSIG/Symbols does not exist, it is created. |
|
145 |
if (!getOutputFolderPath().exists()) { |
|
146 |
getOutputFolderPath().mkdir(); |
|
147 |
} |
|
148 |
|
|
149 |
File imageOut = new File(getOutputFolderPath() + "/" + image.getName()); |
|
150 |
File selImageOut = |
|
151 |
new File(getOutputFolderPath() + "/" + selImage.getName()); |
|
152 |
|
|
153 |
// Overwrite or not |
|
154 |
if (imageOut.exists()) { |
|
155 |
Object[] options = { getText("_Overwrite"), getText("_Cancel") }; |
|
156 |
|
|
157 |
option = |
|
158 |
JOptionPane |
|
159 |
.showOptionDialog( |
|
160 |
null, |
|
161 |
MessageFormat |
|
162 |
.format( |
|
163 |
getText("The file_{0}_already_exists.\n\n_Do_you_want_to_overwrite_it?"), |
|
164 |
imageOut.getPath()), |
|
165 |
getText("_Import_symbols"), JOptionPane.DEFAULT_OPTION, |
|
166 |
JOptionPane.INFORMATION_MESSAGE, null, options, |
|
167 |
options[0]); |
|
168 |
|
|
169 |
if (option == 1) { |
|
170 |
sobreescribir = false; |
|
171 |
} |
|
172 |
} |
|
173 |
|
|
174 |
SymbologyManager manager = SymbologyLocator.getSymbologyManager(); |
|
175 |
SymbolManager symbolManager = MapContextLocator.getSymbolManager(); |
|
176 |
|
|
177 |
if (sobreescribir) { |
|
178 |
try { |
|
179 |
|
|
180 |
// Copies the image to the output folder |
|
181 |
copy(image, imageOut); |
|
182 |
|
|
183 |
URL imageURL = imageOut.toURI().toURL(); |
|
184 |
URL selImageURL = null; |
|
185 |
|
|
186 |
// tries to copy the selection image |
|
187 |
if (selImage.exists()) { |
|
188 |
copy(selImage, selImageOut); |
|
189 |
selImageURL = selImageOut.toURI().toURL(); |
|
190 |
} |
|
191 |
|
|
192 |
IPictureMarkerSymbol symbol = |
|
193 |
manager.createPictureMarkerSymbol(imageURL, selImageURL); |
|
194 |
|
|
195 |
PersistenceManager persistenceManager = |
|
196 |
ToolsLocator.getPersistenceManager(); |
|
197 |
|
|
198 |
PersistentState state = persistenceManager.getState(symbol); |
|
199 |
|
|
200 |
// change file extension |
|
201 |
String outFileName = |
|
202 |
deleteExtension(imageOut) |
|
203 |
+ symbolManager.getSymbolPreferences() |
|
204 |
.getSymbolFileExtension(); |
|
205 |
|
|
206 |
FileOutputStream out = new FileOutputStream(outFileName); |
|
207 |
persistenceManager.saveState(state, out); |
|
208 |
|
|
209 |
} catch (PersistenceValidateExceptions e) { |
|
210 |
IOException ioex = new IOException(); |
|
211 |
ioex.initCause(e); |
|
212 |
throw ioex; |
|
213 |
} catch (PersistenceException e) { |
|
214 |
IOException ioex = new IOException(); |
|
215 |
ioex.initCause(e); |
|
216 |
throw ioex; |
|
217 |
} |
|
218 |
} else { |
|
219 |
|
|
220 |
} |
|
221 |
} |
|
222 |
|
|
223 |
public void execute(String actionCommand) { |
|
224 |
if (actionCommand.equalsIgnoreCase("Import_symbols")) { |
|
225 |
|
|
226 |
// Create a file chooser |
|
227 |
final JFileChooser fc = new JFileChooser(); |
|
228 |
|
|
229 |
Component parent = null; |
|
230 |
|
|
231 |
// the fileChooser will only accept jpg, gif, png, jpeg, bmp and svg |
|
232 |
// image formats |
|
233 |
fc.setFileFilter(new FileFilter() { |
|
234 |
|
|
235 |
/* |
|
236 |
* Get the extension of a file. |
|
237 |
*/ |
|
238 |
public String getExtension(File f) { |
|
239 |
String ext = null; |
|
240 |
String s = f.getName(); |
|
241 |
int i = s.lastIndexOf('.'); |
|
242 |
|
|
243 |
if (i > 0 && i < s.length() - 1) { |
|
244 |
ext = s.substring(i + 1).toLowerCase(); |
|
245 |
} |
|
246 |
return ext; |
|
247 |
} |
|
248 |
|
|
249 |
@Override |
|
250 |
public String getDescription() { |
|
251 |
return "JPG, GIF, PNG, JPEG, BMP & SVG Images"; |
|
252 |
} |
|
253 |
|
|
254 |
@Override |
|
255 |
public boolean accept(File f) { |
|
256 |
if (f.isDirectory()) { |
|
257 |
return true; |
|
258 |
} |
|
259 |
|
|
260 |
String extension = getExtension(f); |
|
261 |
return extension != null |
|
262 |
&& imageExtensionsAllowed.contains(extension); |
|
263 |
} |
|
264 |
}); |
|
265 |
|
|
266 |
fc.setMultiSelectionEnabled(true); |
|
267 |
|
|
268 |
fc.showDialog(parent, getText("_Import_symbols")); |
|
269 |
|
|
270 |
// for every selected file, a symbol is created |
|
271 |
for (int i = 0; i < fc.getSelectedFiles().length; i++) { |
|
272 |
File image = fc.getSelectedFiles()[i]; |
|
273 |
try { |
|
274 |
addImageSymbol(image); |
|
275 |
} catch (IOException e) { |
|
276 |
LOG.error(MessageFormat.format( |
|
277 |
getText("_An error_ocurred_creating_the_symbol_related_to_{0}"), |
|
278 |
image.getAbsolutePath()), e); |
|
279 |
|
|
280 |
// Error message, the symbol may not have been imported. |
|
281 |
JOptionPane |
|
282 |
.showMessageDialog( |
|
283 |
null, |
|
284 |
MessageFormat |
|
285 |
.format( |
|
286 |
getText("_An_error_ocurred_creating_the_simbol_related_to_{0}"), |
|
287 |
image.getAbsolutePath()), |
|
288 |
"_Import_symbols", JOptionPane.ERROR_MESSAGE); |
|
289 |
} |
|
290 |
} |
|
291 |
// Message that the import has finished, with or without errors. |
|
292 |
JOptionPane.showMessageDialog(null, |
|
293 |
getText("_Importing_symbols_has_finished."), |
|
294 |
"_Import_symbols", JOptionPane.INFORMATION_MESSAGE); |
|
295 |
|
|
296 |
} |
|
297 |
} |
|
298 |
|
|
299 |
public void initialize() { |
|
300 |
|
|
301 |
} |
|
302 |
|
|
303 |
@Override |
|
304 |
public void postInitialize() { |
|
305 |
|
|
306 |
} |
|
307 |
|
|
308 |
public boolean isEnabled() { |
|
309 |
return true; |
|
310 |
} |
|
311 |
|
|
312 |
public boolean isVisible() { |
|
313 |
return true; |
|
314 |
} |
|
315 |
|
|
316 |
} |
|
0 | 317 |
tags/v2_0_0_Build_2040/extensions/org.gvsig.symbology.app/org.gvsig.symbology.app.importsymbols/src/main/resources/config/config.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<plugin-config> |
|
3 |
<libraries library-dir="lib"/> |
|
4 |
<depends plugin-name="org.gvsig.app"/> |
|
5 |
<resourceBundle name="text"/> |
|
6 |
<extensions> |
|
7 |
<extension class-name="org.gvsig.symbology.app.importsymbols.ImportSymbolsExtension" |
|
8 |
description="" |
|
9 |
active="true"> |
|
10 |
<menu text="tools/Symbols/Import symbols" |
|
11 |
tooltip="Punctual symbol importer from images that exist in a folder" |
|
12 |
action-command="Import_symbols" /> |
|
13 |
</extension> |
|
14 |
</extensions> |
|
15 |
</plugin-config> |
|
0 | 16 |
tags/v2_0_0_Build_2040/extensions/org.gvsig.symbology.app/org.gvsig.symbology.app.importsymbols/src/main/resources/locale/text.properties | ||
---|---|---|
1 |
make_plugin_package=Crear paquete instalaci?n de plugin |
|
2 |
make_plugin_package_description=Crea un paquete de instalaci?n de un plugin instalado |
|
3 |
install_package=Instalar un nuevo paquete |
|
4 |
install_package_description=instala un nuevo paquete (plugin, traducciones, tema, etc.) en gvSIG |
|
5 |
install_package_extension_warning=Herramienta en desarrollo no exenta de fallos. ?Desea continuar? |
|
6 |
select_an_option=Seleccione una opci?n |
|
0 | 7 |
tags/v2_0_0_Build_2040/extensions/org.gvsig.symbology.app/org.gvsig.symbology.app.importsymbols/src/main/resources/locale/text_en.properties | ||
---|---|---|
1 |
make_plugin_package=Create plugin installation package |
|
2 |
make_plugin_package_description=Create an installation package from an already installed plugin |
|
3 |
install_package=Install a new package |
|
4 |
install_package_description=Installs a new package (plugin, translations, theme, etc.) in gvSIG |
|
5 |
install_package_extension_warning=Tool under development. It may contain errors. Continue anyway? |
|
6 |
select_an_option=Select an Option |
|
0 | 7 |
tags/v2_0_0_Build_2040/extensions/org.gvsig.symbology.app/org.gvsig.symbology.app.importsymbols/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
|
|
3 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|
4 |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> |
|
5 |
<modelVersion>4.0.0</modelVersion> |
|
6 |
<artifactId>org.gvsig.symbology.app.importsymbols</artifactId> |
|
7 |
<packaging>jar</packaging> |
|
8 |
<name>Tools: Import marker symbols tool</name> |
|
9 |
<description>Importador de simbolos puntuales a partir de las imagenes que existan en una carpeta</description> |
|
10 |
<parent> |
|
11 |
<groupId>org.gvsig</groupId> |
|
12 |
<artifactId>org.gvsig.symbology.app</artifactId> |
|
13 |
<version>2.0.0-SNAPSHOT</version> |
|
14 |
</parent> |
|
15 |
<profiles> |
|
16 |
<profile> |
|
17 |
<id>gvsig-install</id> |
|
18 |
<activation> |
|
19 |
<activeByDefault>true</activeByDefault> |
|
20 |
</activation> |
|
21 |
<properties> |
|
22 |
<!-- gvSIG installation folder --> |
|
23 |
<gvsig.install.dir>${basedir}/../../build/product</gvsig.install.dir> |
|
24 |
</properties> |
|
25 |
</profile> |
|
26 |
</profiles> |
|
27 |
<dependencies> |
|
28 |
<dependency> |
|
29 |
<groupId>org.gvsig</groupId> |
|
30 |
<artifactId>org.gvsig.app</artifactId> |
|
31 |
<scope>compile</scope> |
|
32 |
</dependency> |
|
33 |
<dependency> |
|
34 |
<groupId>org.gvsig</groupId> |
|
35 |
<artifactId>org.gvsig.andami</artifactId> |
|
36 |
<scope>compile</scope> |
|
37 |
</dependency> |
|
38 |
<dependency> |
|
39 |
<groupId>org.gvsig</groupId> |
|
40 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
41 |
<scope>compile</scope> |
|
42 |
</dependency> |
|
43 |
<dependency> |
|
44 |
<groupId>org.gvsig</groupId> |
|
45 |
<artifactId>org.gvsig.i18n</artifactId> |
|
46 |
<scope>compile</scope> |
|
47 |
</dependency> |
|
48 |
<dependency> |
|
49 |
<groupId>org.gvsig</groupId> |
|
50 |
<artifactId>org.gvsig.symbology.lib.api</artifactId> |
|
51 |
<scope>compile</scope> |
|
52 |
</dependency> |
|
53 |
|
|
54 |
<dependency> |
|
55 |
<groupId>org.slf4j</groupId> |
|
56 |
<artifactId>slf4j-api</artifactId> |
|
57 |
<scope>compile</scope> |
|
58 |
</dependency> |
|
59 |
|
|
60 |
<dependency> |
|
61 |
<groupId>org.gvsig</groupId> |
|
62 |
<artifactId>org.gvsig.fmap.mapcontext</artifactId> |
|
63 |
<scope>compile</scope> |
|
64 |
</dependency> |
|
65 |
|
|
66 |
</dependencies> |
|
67 |
<properties> |
|
68 |
<build-dir>${basedir}/../../build</build-dir> |
|
69 |
<package.info.dependencies>required: org.gvsig.app -ge 2</package.info.dependencies> |
|
70 |
</properties> |
|
71 |
</project> |
|
0 | 72 |
tags/v2_0_0_Build_2040/extensions/org.gvsig.symbology.app/org.gvsig.symbology.app.importsymbols/distribution/distribution.xml | ||
---|---|---|
1 |
<assembly> |
|
2 |
<id>distribution</id> |
|
3 |
<formats> |
|
4 |
<format>dir</format> |
|
5 |
</formats> |
|
6 |
<fileSets> |
|
7 |
<fileSet> |
|
8 |
<directory>src/main/resources/config</directory> |
|
9 |
<outputDirectory>${extension.install.dir.name} |
|
10 |
</outputDirectory> |
|
11 |
</fileSet> |
|
12 |
<fileSet> |
|
13 |
<directory>src/main/resources/images</directory> |
|
14 |
<outputDirectory>${extension.install.dir.name}/images |
|
15 |
</outputDirectory> |
|
16 |
</fileSet> |
|
17 |
<fileSet> |
|
18 |
<directory>src/main/resources/about</directory> |
|
19 |
<outputDirectory>${extension.install.dir.name} |
|
20 |
</outputDirectory> |
|
21 |
</fileSet> |
|
22 |
<fileSet> |
|
23 |
<directory>src/main/resources/locale</directory> |
|
24 |
<outputDirectory>${extension.install.dir.name} |
|
25 |
</outputDirectory> |
|
26 |
</fileSet> |
|
27 |
</fileSets> |
|
28 |
<files> |
|
29 |
<file> |
|
30 |
<source>package.info</source> |
|
31 |
<outputDirectory>${extension.install.dir.name} |
|
32 |
</outputDirectory> |
|
33 |
</file> |
|
34 |
</files> |
|
35 |
<dependencySets> |
|
36 |
<dependencySet> |
|
37 |
<outputDirectory>${extension.install.dir.name}/${library-dir} |
|
38 |
</outputDirectory> |
|
39 |
<includes> |
|
40 |
<include>org.gvsig:org.gvsig.symbology.app.importsymbols:jar</include> |
|
41 |
</includes> |
|
42 |
</dependencySet> |
|
43 |
</dependencySets> |
|
44 |
</assembly> |
|
0 | 45 |
tags/v2_0_0_Build_2040/extensions/org.gvsig.symbology.app/org.gvsig.symbology.app.importsymbols/buildNumber.properties | ||
---|---|---|
1 |
#maven.buildNumber.plugin properties file |
|
2 |
#Thu Nov 10 13:08:06 CET 2011 |
|
3 |
buildNumber=2040 |
|
0 | 4 |
tags/v2_0_0_Build_2040/extensions/org.gvsig.symbology.app/org.gvsig.symbology.app.symbolinstaller/buildNumber.properties | ||
---|---|---|
1 |
#maven.buildNumber.plugin properties file |
|
2 |
#Thu Nov 10 13:08:09 CET 2011 |
|
3 |
buildNumber=2038 |
|
0 | 4 |
tags/v2_0_0_Build_2040/extensions/org.gvsig.symbology.app/org.gvsig.symbology.app.symbolinstaller/src/main/java/org/gvsig/symbology/app/symbolinstaller/SymbolInstallerProviderLibrary.java | ||
---|---|---|
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 |
package org.gvsig.symbology.app.symbolinstaller; |
|
24 |
|
|
25 |
import org.gvsig.installer.lib.api.InstallerLibrary; |
|
26 |
import org.gvsig.installer.lib.spi.InstallerProviderLocator; |
|
27 |
import org.gvsig.symbology.app.symbolinstaller.execution.SymbolInstallerExecutionProviderFactory; |
|
28 |
import org.gvsig.tools.library.AbstractLibrary; |
|
29 |
import org.gvsig.tools.library.LibraryException; |
|
30 |
import org.gvsig.tools.service.spi.ProviderManager; |
|
31 |
|
|
32 |
public class SymbolInstallerProviderLibrary extends AbstractLibrary { |
|
33 |
|
|
34 |
@Override |
|
35 |
public void doRegistration() { |
|
36 |
registerAsServiceOf(InstallerLibrary.class); |
|
37 |
} |
|
38 |
|
|
39 |
@Override |
|
40 |
protected void doInitialize() throws LibraryException { |
|
41 |
} |
|
42 |
|
|
43 |
@Override |
|
44 |
protected void doPostInitialize() throws LibraryException { |
|
45 |
ProviderManager providerManager = |
|
46 |
InstallerProviderLocator.getProviderManager(); |
|
47 |
|
|
48 |
providerManager |
|
49 |
.addProviderFactory(new SymbolInstallerExecutionProviderFactory()); |
|
50 |
} |
|
51 |
} |
|
0 | 52 |
tags/v2_0_0_Build_2040/extensions/org.gvsig.symbology.app/org.gvsig.symbology.app.symbolinstaller/src/main/java/org/gvsig/symbology/app/symbolinstaller/execution/SymbolInstallerExecutionProviderFactory.java | ||
---|---|---|
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 |
package org.gvsig.symbology.app.symbolinstaller.execution; |
|
24 |
|
|
25 |
import org.gvsig.tools.ToolsLocator; |
|
26 |
import org.gvsig.tools.dynobject.DynClass; |
|
27 |
import org.gvsig.tools.dynobject.DynObject; |
|
28 |
import org.gvsig.tools.dynobject.DynObjectManager; |
|
29 |
import org.gvsig.tools.service.spi.AbstractProviderFactory; |
|
30 |
import org.gvsig.tools.service.spi.Provider; |
|
31 |
import org.gvsig.tools.service.spi.ProviderServices; |
|
32 |
|
|
33 |
public class SymbolInstallerExecutionProviderFactory extends |
|
34 |
AbstractProviderFactory { |
|
35 |
|
|
36 |
public static final String PROVIDER_NAME = "symbol_installer_provider"; |
|
37 |
public static final String PROVIDER_DESCRIPTION = ""; |
|
38 |
|
|
39 |
private DynClass dynclass; |
|
40 |
|
|
41 |
@Override |
|
42 |
protected DynClass createParametersDynClass() { |
|
43 |
if (dynclass == null) { |
|
44 |
initialize(); |
|
45 |
} |
|
46 |
return dynclass; |
|
47 |
} |
|
48 |
|
|
49 |
@Override |
|
50 |
protected Provider doCreate(DynObject parameters, ProviderServices services) { |
|
51 |
return new SymbolInstallerExecutionProvider(services); |
|
52 |
} |
|
53 |
|
|
54 |
public void initialize() { |
|
55 |
if (dynclass == null) { |
|
56 |
DynObjectManager dynObjectManager = |
|
57 |
ToolsLocator.getDynObjectManager(); |
|
58 |
dynclass = |
|
59 |
dynObjectManager.createDynClass(PROVIDER_NAME, |
|
60 |
PROVIDER_DESCRIPTION); |
|
61 |
dynObjectManager.add(dynclass); |
|
62 |
} |
|
63 |
} |
|
64 |
|
|
65 |
} |
|
0 | 66 |
tags/v2_0_0_Build_2040/extensions/org.gvsig.symbology.app/org.gvsig.symbology.app.symbolinstaller/src/main/java/org/gvsig/symbology/app/symbolinstaller/execution/SymbolInstallerExtension.java | ||
---|---|---|
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 |
package org.gvsig.symbology.app.symbolinstaller.execution; |
|
24 |
|
|
25 |
import org.gvsig.andami.plugins.Extension; |
|
26 |
import org.gvsig.andami.ui.ToolsWindowManager; |
|
27 |
import org.gvsig.symbology.app.symbolinstaller.creation.DefaultMakeSymbolPackageWizard; |
|
28 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
|
29 |
|
|
30 |
public class SymbolInstallerExtension extends Extension { |
|
31 |
|
|
32 |
public void initialize() { |
|
33 |
} |
|
34 |
|
|
35 |
@Override |
|
36 |
public void postInitialize() { |
|
37 |
|
|
38 |
} |
|
39 |
|
|
40 |
public boolean isEnabled() { |
|
41 |
return true; |
|
42 |
} |
|
43 |
|
|
44 |
public boolean isVisible() { |
|
45 |
return true; |
|
46 |
} |
|
47 |
|
|
48 |
public void execute(String actionCommand) { |
|
49 |
System.out.println("installer starts! \n\n actioncommand: " |
|
50 |
+ actionCommand); |
|
51 |
|
|
52 |
if (actionCommand.equals("Create_Package")) { |
|
53 |
|
|
54 |
DefaultMakeSymbolPackageWizard wizard = |
|
55 |
new DefaultMakeSymbolPackageWizard(); |
|
56 |
// wizard.getWizardPanelActionListener(); |
|
57 |
|
|
58 |
// ApplicationManager application = ApplicationLocator.getManager(); |
|
59 |
|
|
60 |
// WizardPanel wizardPanel = (WizardPanel) wizard; |
|
61 |
WindowManager windowManager = new ToolsWindowManager(); |
|
62 |
windowManager.showWindow(wizard, "_Symbols_Wizard", |
|
63 |
WindowManager.MODE.DIALOG); |
|
64 |
|
|
65 |
// try { |
|
66 |
// System.out.println("class: " + |
|
67 |
// application.getWizardPanels().getClass()); |
|
68 |
// } catch (Exception e) { |
|
69 |
// // TODO Auto-generated catch block |
|
70 |
// e.printStackTrace(); |
|
71 |
// } |
|
72 |
|
|
73 |
// ToolsWindowManager windowManager = new ToolsWindowManager(); |
|
74 |
// |
|
75 |
// windowManager.showWindow(wizard, "_Symbols_Wizard", |
|
76 |
// WindowManager.MODE.WINDOW, GridBagConstraints.CENTER); |
|
77 |
|
|
78 |
// AbstractInstallPackageWizard installPackageWizard = |
|
79 |
// SwingInstallerLocator.getSwingInstallerManager() |
|
80 |
// .createInstallPackageWizard(applicationFolder, pluginsFolder, |
|
81 |
// installFolder); |
|
82 |
// installPackageWizard |
|
83 |
// .setWizardActionListener(new WindowInstallerListener(this)); |
|
84 |
// this.setLayout(new BorderLayout()); |
|
85 |
// add(installPackageWizard, BorderLayout.CENTER); |
|
86 |
|
|
87 |
// PluginServices. |
|
88 |
// .addWindow( |
|
89 |
// manager.createWizard().getWindow()); |
|
90 |
|
|
91 |
// PluginServices.getMDIManager().addCentredWindow( |
|
92 |
|
|
93 |
} |
|
94 |
|
|
95 |
System.out.println("\ninstaller ends!\n"); |
|
96 |
} |
|
97 |
} |
|
0 | 98 |
tags/v2_0_0_Build_2040/extensions/org.gvsig.symbology.app/org.gvsig.symbology.app.symbolinstaller/src/main/java/org/gvsig/symbology/app/symbolinstaller/execution/SymbolInstallerExecutionProvider.java | ||
---|---|---|
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 |
package org.gvsig.symbology.app.symbolinstaller.execution; |
|
24 |
|
|
25 |
import java.io.File; |
|
26 |
import java.io.IOException; |
|
27 |
import java.io.InputStream; |
|
28 |
|
|
29 |
import org.gvsig.andami.PluginsLocator; |
|
30 |
import org.gvsig.andami.PluginsManager; |
|
31 |
import org.gvsig.installer.lib.api.PackageInfo; |
|
32 |
import org.gvsig.installer.lib.api.execution.InstallPackageServiceException; |
|
33 |
import org.gvsig.installer.lib.spi.InstallPackageProviderServices; |
|
34 |
import org.gvsig.installer.lib.spi.InstallerProviderLocator; |
|
35 |
import org.gvsig.installer.lib.spi.InstallerProviderManager; |
|
36 |
import org.gvsig.installer.lib.spi.execution.InstallPackageProvider; |
|
37 |
import org.gvsig.tools.service.spi.AbstractProvider; |
|
38 |
import org.gvsig.tools.service.spi.ProviderServices; |
|
39 |
|
|
40 |
public class SymbolInstallerExecutionProvider extends AbstractProvider |
|
41 |
implements InstallPackageProvider { |
|
42 |
|
|
43 |
private static final long serialVersionUID = 1L; |
|
44 |
|
|
45 |
public SymbolInstallerExecutionProvider(ProviderServices providerServices) { |
|
46 |
super(providerServices); |
|
47 |
} |
|
48 |
|
|
49 |
public class InstallerSymbolsDirectoryNotFoundException extends |
|
50 |
InstallPackageServiceException { |
|
51 |
|
|
52 |
private static final long serialVersionUID = 4416143986837955880L; |
|
53 |
private static final String message = "Symbols directory not found"; |
|
54 |
private static final String KEY = "symbols_directory_not_found"; |
|
55 |
|
|
56 |
public InstallerSymbolsDirectoryNotFoundException() { |
|
57 |
super(message, KEY, serialVersionUID); |
|
58 |
} |
|
59 |
} |
|
60 |
|
|
61 |
public void install(File applicationDirectory, InputStream inputStream, |
|
62 |
PackageInfo packageInfo) throws InstallPackageServiceException { |
|
63 |
|
|
64 |
PluginsManager pluginManager = PluginsLocator.getManager(); |
|
65 |
|
|
66 |
File symbolsDirectory = |
|
67 |
new File(pluginManager.getApplicationHomeFolder() + File.separator |
|
68 |
+ "Symbols"); |
|
69 |
|
|
70 |
try { |
|
71 |
if (!symbolsDirectory.exists()) { |
|
72 |
throw new InstallerSymbolsDirectoryNotFoundException(); |
|
73 |
} |
|
74 |
InstallerProviderManager installerProviderManager = |
|
75 |
InstallerProviderLocator.getProviderManager(); |
|
76 |
InstallPackageProviderServices installerProviderServices = |
|
77 |
installerProviderManager.createInstallerProviderServices(); |
|
78 |
|
|
79 |
installerProviderServices.decompress(inputStream, symbolsDirectory); |
|
80 |
|
|
81 |
} catch (Exception e) { |
|
82 |
throw new InstallPackageServiceException(e); |
|
83 |
} |
|
84 |
} |
|
85 |
|
|
86 |
public void installLater(File applicationDirectory, |
|
87 |
InputStream inputStream, PackageInfo packageInfo) |
|
88 |
throws InstallPackageServiceException, IOException { |
|
89 |
// TODO Auto-generated method stub |
|
90 |
|
|
91 |
} |
|
92 |
} |
|
0 | 93 |
tags/v2_0_0_Build_2040/extensions/org.gvsig.symbology.app/org.gvsig.symbology.app.symbolinstaller/src/main/java/org/gvsig/symbology/app/symbolinstaller/creation/DefaultMakeSymbolPackageWizard.java | ||
---|---|---|
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.symbology.app.symbolinstaller.creation; |
|
29 |
|
|
30 |
import java.awt.BorderLayout; |
|
31 |
import java.io.File; |
|
32 |
import java.net.URL; |
|
33 |
|
|
34 |
import javax.swing.ImageIcon; |
|
35 |
import javax.swing.JPanel; |
|
36 |
|
|
37 |
import org.gvsig.gui.beans.wizard.WizardPanel; |
|
38 |
import org.gvsig.gui.beans.wizard.WizardPanelActionListener; |
|
39 |
import org.gvsig.gui.beans.wizard.WizardPanelWithLogo; |
|
40 |
import org.gvsig.installer.lib.api.InstallerLocator; |
|
41 |
import org.gvsig.installer.lib.api.PackageInfo; |
|
42 |
import org.gvsig.installer.swing.api.creation.JOutputPanel; |
|
43 |
import org.gvsig.symbology.app.symbolinstaller.creation.wizard.OutputWizard; |
|
44 |
import org.gvsig.symbology.app.symbolinstaller.creation.wizard.PackageInfoWizard; |
|
45 |
import org.gvsig.symbology.app.symbolinstaller.creation.wizard.ProgressWizard; |
|
46 |
import org.gvsig.symbology.app.symbolinstaller.creation.wizard.SelectSymbolsFolderInstallWizard; |
|
47 |
import org.gvsig.symbology.app.symbolinstaller.execution.SymbolInstallerExecutionProviderFactory; |
|
48 |
import org.gvsig.tools.locator.LocatorException; |
|
49 |
|
|
50 |
public class DefaultMakeSymbolPackageWizard extends JPanel implements |
|
51 |
WizardPanel { |
|
52 |
|
|
53 |
private static final long serialVersionUID = 9205891710214122265L; |
|
54 |
private WizardPanelWithLogo wizardPanelWithLogo = null; |
|
55 |
|
|
56 |
// Wizards |
|
57 |
private PackageInfoWizard packageInfoWizard = null; |
|
58 |
private ProgressWizard progressWizard = null; |
|
59 |
private OutputWizard outputWizard = null; |
|
60 |
private SelectSymbolsFolderInstallWizard selectSymbolsFolderInstallWizard = |
|
61 |
null; |
|
62 |
private PackageInfo packageInfo = null; |
|
63 |
|
|
64 |
private File symbolFolderToInsertInPackage = null; |
|
65 |
|
|
66 |
private WizardPanelActionListener wizardListenerAdapter = null; |
|
67 |
|
|
68 |
public DefaultMakeSymbolPackageWizard() throws LocatorException { |
|
69 |
URL iconURL = |
|
70 |
getClass().getClassLoader().getResource( |
|
71 |
"images/makepluginpackageicon.png"); |
|
72 |
ImageIcon icon = new ImageIcon(iconURL); |
|
73 |
wizardPanelWithLogo = new WizardPanelWithLogo(icon); |
|
74 |
|
|
75 |
setCancelButtonEnabled(true); |
|
76 |
setFinishButtonEnabled(false); |
|
77 |
|
|
78 |
WizardPanel wizardPanel = this; |
|
79 |
|
|
80 |
packageInfo = |
|
81 |
InstallerLocator.getInstallerManager().createPackageInfo(); |
|
82 |
packageInfo |
|
83 |
.setType(SymbolInstallerExecutionProviderFactory.PROVIDER_NAME); |
|
84 |
|
|
85 |
selectSymbolsFolderInstallWizard = |
|
86 |
new SelectSymbolsFolderInstallWizard(this, packageInfo); |
|
87 |
packageInfoWizard = new PackageInfoWizard(wizardPanel, packageInfo); |
|
88 |
outputWizard = new OutputWizard(wizardPanel, packageInfo); |
|
89 |
progressWizard = |
|
90 |
new ProgressWizard(wizardPanel, packageInfo, |
|
91 |
(JOutputPanel) (outputWizard.getJPanel())); |
|
92 |
|
|
93 |
addWizards(); |
|
94 |
|
|
95 |
// Adding the listeners |
|
96 |
wizardPanelWithLogo.setWizardListener(this); |
|
97 |
|
|
98 |
this.setLayout(new BorderLayout()); |
|
99 |
this.add(wizardPanelWithLogo, BorderLayout.CENTER); |
|
100 |
|
|
101 |
|
|
102 |
} |
|
103 |
|
|
104 |
private void addWizards() { |
|
105 |
// TODO: ?? |
|
106 |
wizardPanelWithLogo.addOptionPanel(selectSymbolsFolderInstallWizard); |
|
107 |
wizardPanelWithLogo.addOptionPanel(packageInfoWizard); |
|
108 |
wizardPanelWithLogo.addOptionPanel(outputWizard); |
|
109 |
wizardPanelWithLogo.addOptionPanel(progressWizard); |
|
110 |
} |
|
111 |
|
|
112 |
public void setNextButtonEnabled(boolean isEnabled) { |
|
113 |
wizardPanelWithLogo.setNextButtonEnabled(isEnabled); |
|
114 |
} |
|
115 |
|
|
116 |
public void setCancelButtonEnabled(boolean isEnabled) { |
|
117 |
wizardPanelWithLogo.setCancelButtonEnabled(isEnabled); |
|
118 |
} |
|
119 |
|
|
120 |
public void setFinishButtonEnabled(boolean isEnabled) { |
|
121 |
wizardPanelWithLogo.setFinishButtonEnabled(isEnabled); |
|
122 |
} |
|
123 |
|
|
124 |
public void setBackButtonEnabled(boolean isEnabled) { |
|
125 |
wizardPanelWithLogo.setBackButtonEnabled(isEnabled); |
|
126 |
} |
|
127 |
|
|
128 |
public WizardPanelActionListener getWizardPanelActionListener() { |
|
129 |
return wizardListenerAdapter; |
|
130 |
} |
|
131 |
|
|
132 |
public void setWizardPanelActionListener( |
|
133 |
WizardPanelActionListener wizardActionListener) { |
|
134 |
// TODO Auto-generated method stub |
|
135 |
// this.wizardListenerAdapter = wizardActionListener; |
|
136 |
throw new RuntimeException("Esto falta por ver que hace"); |
|
137 |
} |
|
138 |
|
|
139 |
public void setSymbolFolderToInsertInPackage(File file) { |
|
140 |
symbolFolderToInsertInPackage = file; |
|
141 |
} |
|
142 |
|
|
143 |
public File getSymbolFolderToInsertInPackage() { |
|
144 |
return symbolFolderToInsertInPackage; |
|
145 |
} |
|
146 |
|
|
147 |
} |
|
0 | 148 |
tags/v2_0_0_Build_2040/extensions/org.gvsig.symbology.app/org.gvsig.symbology.app.symbolinstaller/src/main/java/org/gvsig/symbology/app/symbolinstaller/creation/panel/SelectSymbolsFolderInstallPanel.java | ||
---|---|---|
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 |
package org.gvsig.symbology.app.symbolinstaller.creation.panel; |
|
23 |
|
|
24 |
import java.awt.BorderLayout; |
|
25 |
import java.awt.event.ActionEvent; |
|
26 |
import java.io.File; |
|
27 |
import java.util.ArrayList; |
|
28 |
|
|
29 |
import javax.swing.JLabel; |
|
30 |
import javax.swing.JList; |
|
31 |
import javax.swing.JPanel; |
|
32 |
import javax.swing.JScrollPane; |
|
33 |
import javax.swing.ListSelectionModel; |
|
34 |
|
|
35 |
import org.gvsig.andami.PluginsLocator; |
|
36 |
import org.gvsig.andami.PluginsManager; |
|
37 |
import org.gvsig.installer.swing.api.SwingInstallerLocator; |
|
38 |
import org.gvsig.installer.swing.api.SwingInstallerManager; |
|
39 |
|
|
40 |
/** |
|
41 |
* @author gvSIG Team |
|
42 |
* @version $Id$ |
|
43 |
* |
|
44 |
*/ |
|
45 |
public class SelectSymbolsFolderInstallPanel extends JPanel { |
|
46 |
|
|
47 |
private static final long serialVersionUID = 948949741432221418L; |
|
48 |
|
|
49 |
protected SwingInstallerManager swingInstallerManager = null; |
|
50 |
|
|
51 |
private JList folderJList; |
|
52 |
private File symbolsDirectory = null; |
|
53 |
private ArrayList<String> folders = null; |
|
54 |
|
|
55 |
public SelectSymbolsFolderInstallPanel() { |
|
56 |
super(); |
|
57 |
swingInstallerManager = |
|
58 |
SwingInstallerLocator.getSwingInstallerManager(); |
|
59 |
initComponents(); |
|
60 |
} |
|
61 |
|
|
62 |
private String getText(String string) { |
|
63 |
return string; |
|
64 |
} |
|
65 |
|
|
66 |
private void initComponents() { |
|
67 |
|
|
68 |
JLabel symbolsFolderLabel = |
|
69 |
new JLabel( |
|
70 |
getText("_please_select_the_folder_to_create_the_package_with:") |
|
71 |
+ ":"); |
|
72 |
|
|
73 |
PluginsManager pluginManager = PluginsLocator.getManager(); |
|
74 |
symbolsDirectory = |
|
75 |
new File(pluginManager.getApplicationHomeFolder() + File.separator |
|
76 |
+ "Symbols"); |
|
77 |
|
|
78 |
String[] itemsArray = symbolsDirectory.list(); |
|
79 |
folders = new ArrayList<String>(); |
|
80 |
|
|
81 |
for (int i = 0; i < itemsArray.length; i++) { |
|
82 |
File f = new File(symbolsDirectory, itemsArray[i]); |
|
83 |
if (f.isDirectory()) { |
|
84 |
folders.add(itemsArray[i]); |
|
85 |
} |
|
86 |
} |
|
87 |
|
|
88 |
folderJList = new JList(folders.toArray()); |
|
89 |
|
|
90 |
folderJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
|
91 |
|
|
92 |
//TODO: actionEvent should be added |
|
93 |
folderJList.setSelectedIndex(0); |
|
94 |
|
|
95 |
setLayout(new BorderLayout()); |
|
96 |
setBounds(2, 2, 2, 2); |
|
97 |
|
|
98 |
add(symbolsFolderLabel, BorderLayout.NORTH); |
|
99 |
|
|
100 |
JScrollPane scroller = new JScrollPane(folderJList); |
|
101 |
add(scroller); |
|
102 |
// add(folderJList); |
|
103 |
} |
|
104 |
|
|
105 |
public File getSelectedFolder() { |
|
106 |
String folderName = folders.get(folderJList.getSelectedIndex()); |
|
107 |
return new File(symbolsDirectory + "/" + folderName.toString()); |
|
108 |
} |
|
109 |
|
|
110 |
public void setSelectedFolder(File selectedFile) { |
|
111 |
folderJList.setSelectedValue(selectedFile, true); |
|
112 |
// folderTextField.setSelectedFile(selectedFile); |
|
113 |
} |
|
114 |
|
|
115 |
public void actionPerformed(ActionEvent arg0) { |
|
116 |
// TODO Auto-generated method stub |
|
117 |
|
|
118 |
} |
|
119 |
|
|
120 |
} |
|
0 | 121 |
tags/v2_0_0_Build_2040/extensions/org.gvsig.symbology.app/org.gvsig.symbology.app.symbolinstaller/src/main/java/org/gvsig/symbology/app/symbolinstaller/creation/wizard/PackageInfoWizard.java | ||
---|---|---|
1 |
package org.gvsig.symbology.app.symbolinstaller.creation.wizard; |
|
2 |
|
|
3 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
4 |
* |
|
5 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
6 |
* of the Valencian Government (CIT) |
|
7 |
* |
|
8 |
* This program is free software; you can redistribute it and/or |
|
9 |
* modify it under the terms of the GNU General Public License |
|
10 |
* as published by the Free Software Foundation; either version 2 |
|
11 |
* of the License, or (at your option) any later version. |
|
12 |
* |
|
13 |
* This program is distributed in the hope that it will be useful, |
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
* GNU General Public License for more details. |
|
17 |
* |
|
18 |
* You should have received a copy of the GNU General Public License |
|
19 |
* along with this program; if not, write to the Free Software |
|
20 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
21 |
* MA 02110-1301, USA. |
|
22 |
* |
|
23 |
*/ |
|
24 |
|
|
25 |
/* |
|
26 |
* AUTHORS (In addition to CIT): |
|
27 |
* 2010 {Prodevelop} {Task} |
|
28 |
*/ |
|
29 |
|
|
30 |
import javax.swing.JPanel; |
|
31 |
|
|
32 |
import org.gvsig.gui.beans.wizard.WizardPanel; |
|
33 |
import org.gvsig.gui.beans.wizard.panel.NotContinueWizardException; |
|
34 |
import org.gvsig.gui.beans.wizard.panel.OptionPanel; |
|
35 |
import org.gvsig.installer.lib.api.PackageInfo; |
|
36 |
import org.gvsig.installer.swing.api.SwingInstallerLocator; |
|
37 |
import org.gvsig.installer.swing.api.creation.JPackageInfoPanel; |
|
38 |
|
|
39 |
/** |
|
40 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</a> |
|
41 |
*/ |
|
42 |
public class PackageInfoWizard implements OptionPanel { |
|
43 |
|
|
44 |
private static final long serialVersionUID = 6880987804806802863L; |
|
45 |
|
|
46 |
// private WizardPanel wizard; |
|
47 |
|
|
48 |
private JPackageInfoPanel packageInfoPanel; |
|
49 |
|
|
50 |
private PackageInfo packageInfo; |
|
51 |
|
|
52 |
public PackageInfoWizard(WizardPanel wizard, PackageInfo packageInfo) { |
|
53 |
super(); |
|
54 |
// this.wizard = wizard; |
|
55 |
this.packageInfoPanel = |
|
56 |
SwingInstallerLocator.getSwingInstallerManager() |
|
57 |
.createPackageInfoPanel(); |
|
58 |
this.packageInfo = packageInfo; |
|
59 |
} |
|
60 |
|
|
61 |
private String getText(String msg) { |
|
62 |
return msg; // FIXME |
|
63 |
} |
|
64 |
|
|
65 |
public JPanel getJPanel() { |
|
66 |
return this.packageInfoPanel; |
|
67 |
} |
|
68 |
|
|
69 |
public String getPanelTitle() { |
|
70 |
return getText("plugin_description"); |
|
71 |
} |
|
72 |
|
|
73 |
public void lastPanel() { |
|
74 |
// TODO Auto-generated method stub |
|
75 |
|
|
76 |
} |
|
77 |
|
|
78 |
public void nextPanel() throws NotContinueWizardException { |
|
79 |
if (!this.packageInfoPanel.validatePanel()) { |
|
80 |
throw new NotContinueWizardException("", null, false); |
|
81 |
} |
|
82 |
this.packageInfoPanel.panelToPackageInfo(packageInfo); |
|
83 |
} |
|
84 |
|
|
85 |
public void updatePanel() { |
|
86 |
this.packageInfoPanel.packageInfoToPanel(packageInfo); |
|
87 |
} |
|
88 |
|
|
89 |
} |
|
0 | 90 |
tags/v2_0_0_Build_2040/extensions/org.gvsig.symbology.app/org.gvsig.symbology.app.symbolinstaller/src/main/java/org/gvsig/symbology/app/symbolinstaller/creation/wizard/SelectSymbolsFolderInstallWizard.java | ||
---|---|---|
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 |
package org.gvsig.symbology.app.symbolinstaller.creation.wizard; |
|
23 |
|
|
24 |
import javax.swing.JPanel; |
|
25 |
|
|
26 |
import org.gvsig.gui.beans.wizard.panel.NotContinueWizardException; |
|
27 |
import org.gvsig.gui.beans.wizard.panel.OptionPanel; |
|
28 |
import org.gvsig.installer.lib.api.PackageInfo; |
|
29 |
import org.gvsig.symbology.app.symbolinstaller.creation.DefaultMakeSymbolPackageWizard; |
|
30 |
import org.gvsig.symbology.app.symbolinstaller.creation.panel.SelectSymbolsFolderInstallPanel; |
|
31 |
|
|
32 |
/** |
|
33 |
* @author gvSIG Team |
|
34 |
* @version $Id$ |
|
35 |
* |
|
36 |
*/ |
|
37 |
public class SelectSymbolsFolderInstallWizard implements OptionPanel { |
|
38 |
|
|
39 |
private SelectSymbolsFolderInstallPanel panel = null; |
|
40 |
// private PackageInfo packageInfo; |
|
41 |
DefaultMakeSymbolPackageWizard wizard; |
|
42 |
|
|
43 |
/** |
|
44 |
* @param defaultMakeSymbolPackageWizard |
|
45 |
* @param packageInfo |
|
46 |
*/ |
|
47 |
public SelectSymbolsFolderInstallWizard( |
|
48 |
DefaultMakeSymbolPackageWizard defaultMakeSymbolPackageWizard, |
|
49 |
PackageInfo packageInfo) { |
|
50 |
super(); |
|
51 |
wizard = defaultMakeSymbolPackageWizard; |
|
52 |
panel = new SelectSymbolsFolderInstallPanel(); |
|
53 |
// this.packageInfo = packageInfo; |
|
54 |
} |
|
55 |
|
|
56 |
public JPanel getJPanel() { |
|
57 |
return panel; |
|
58 |
} |
|
59 |
|
|
60 |
public void lastPanel() { |
|
61 |
|
|
62 |
} |
|
63 |
|
|
64 |
public void nextPanel() throws NotContinueWizardException { |
|
65 |
|
|
66 |
wizard.setSymbolFolderToInsertInPackage(panel.getSelectedFolder()); |
|
67 |
} |
|
68 |
|
|
69 |
public void updatePanel() { |
|
70 |
|
|
71 |
} |
|
72 |
|
|
73 |
public String getPanelTitle() { |
|
74 |
return getText("_Select_symbol_folder"); |
|
75 |
} |
|
76 |
|
|
77 |
private String getText(String msg) { |
|
78 |
return msg; // FIXME |
|
79 |
} |
|
80 |
|
|
81 |
} |
|
0 | 82 |
tags/v2_0_0_Build_2040/extensions/org.gvsig.symbology.app/org.gvsig.symbology.app.symbolinstaller/src/main/java/org/gvsig/symbology/app/symbolinstaller/creation/wizard/OutputWizard.java | ||
---|---|---|
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.symbology.app.symbolinstaller.creation.wizard; |
|
29 |
|
|
30 |
import java.io.File; |
|
31 |
import java.net.URL; |
|
32 |
|
|
33 |
import javax.swing.JOptionPane; |
|
34 |
import javax.swing.JPanel; |
|
35 |
|
|
36 |
import org.gvsig.andami.PluginsLocator; |
|
37 |
import org.gvsig.andami.PluginsManager; |
|
38 |
import org.gvsig.gui.beans.wizard.WizardPanel; |
|
39 |
import org.gvsig.gui.beans.wizard.panel.NotContinueWizardException; |
|
40 |
import org.gvsig.gui.beans.wizard.panel.OptionPanel; |
|
41 |
import org.gvsig.installer.lib.api.InstallerLocator; |
|
42 |
import org.gvsig.installer.lib.api.PackageInfo; |
|
43 |
import org.gvsig.installer.swing.api.SwingInstallerLocator; |
|
44 |
import org.gvsig.installer.swing.api.creation.JOutputPanel; |
|
45 |
|
|
46 |
/** |
|
47 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</a> |
|
48 |
*/ |
|
49 |
public class OutputWizard implements OptionPanel { |
|
50 |
|
|
51 |
/** |
|
52 |
* |
|
53 |
*/ |
|
54 |
private static final long serialVersionUID = 555020268506822671L; |
|
55 |
// private WizardPanel wizard; |
|
56 |
private JOutputPanel outputPanel; |
|
57 |
private PackageInfo packageInfo; |
|
58 |
|
|
59 |
// private static final Logger logger = |
|
60 |
// LoggerFactory.getLogger(OutputWizard.class); |
|
61 |
|
|
62 |
public OutputWizard(WizardPanel wizardPanel, PackageInfo packageInfo) { |
|
63 |
super(); |
|
64 |
// this.wizard = wizardPanel; |
|
65 |
outputPanel = |
|
66 |
SwingInstallerLocator.getSwingInstallerManager() |
|
67 |
.createOutputPanel(); |
|
68 |
this.packageInfo = packageInfo; |
|
69 |
} |
|
70 |
|
|
71 |
public JPanel getJPanel() { |
|
72 |
return this.outputPanel; |
|
73 |
} |
|
74 |
|
|
75 |
private String getText(String msg) { |
|
76 |
return msg; // FIXME |
|
77 |
} |
|
78 |
|
|
79 |
public String getPanelTitle() { |
|
80 |
return getText("output_options"); |
|
81 |
} |
|
82 |
|
|
83 |
public void lastPanel() { |
|
84 |
|
|
85 |
} |
|
86 |
|
|
87 |
public void nextPanel() throws NotContinueWizardException { |
|
88 |
// try { |
|
89 |
File file = outputPanel.getPackageFile(); |
|
90 |
File filePath = new File(file.getParent()); |
|
91 |
if (!filePath.exists()) { |
|
92 |
JOptionPane |
|
93 |
.showMessageDialog(outputPanel, |
|
94 |
getText("The_package_file_folder_does_not_exist: _") |
|
95 |
+ filePath); |
|
96 |
throw new NotContinueWizardException("", null, false); |
|
97 |
} |
|
98 |
if (outputPanel.isCreatePackageIndex()) { |
|
99 |
URL url = outputPanel.getDownloadURL(); |
|
100 |
if (url == null) { |
|
101 |
throw new NotContinueWizardException("", null, false); |
Also available in: Unified diff