Revision 95

View differences:

org.gvsig.educa.thematicmap/tags/Build_5/org.gvsig.educa.thematicmap/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/xsd/maven-4.0.0.xsd">
5
	<modelVersion>4.0.0</modelVersion>
6
	<artifactId>org.gvsig.educa.thematicmap</artifactId>
7
	<packaging>pom</packaging>
8
	<version>1.0.0-SNAPSHOT</version>
9
	<name>org.gvsig.educa.thematicmap</name>
10
	<description>ThematicMap example project</description>
11
	<parent>
12
		<groupId>org.gvsig</groupId>
13
		<artifactId>org.gvsig.maven.base.pom</artifactId>
14
		<version>1.0.8-SNAPSHOT</version>
15
	</parent>
16
	<properties>
17
		<educa.version>${project.version}</educa.version>
18
		<gvsig.version>2.0-SNAPSHOT</gvsig.version>
19
		<gvsig.i18n.version>2.0.1-SNAPSHOT</gvsig.i18n.version>
20
		<gvsig.symbology.version>2.0.0-SNAPSHOT</gvsig.symbology.version>
21
		<gvsig.ui.version>2.0.1-SNAPSHOT</gvsig.ui.version>
22
		<gvsig.tools.version>3.0.0-SNAPSHOT</gvsig.tools.version>
23
		<gvsig.timesupport>1.0.0-SNAPSHOT</gvsig.timesupport>
24
		<gvsig.installer.version>1.0.1-SNAPSHOT</gvsig.installer.version>
25
		<apache.commons-io.version>1.3.2</apache.commons-io.version>
26
		<apache.commons-lang3.version>3.1</apache.commons-lang3.version>
27
	</properties>	
28
	<scm>
29
		<connection>scm:svn:https://devel.gvsig.org/svn/gvsig-educa/org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap</connection>
30
		<developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-educa/org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap</developerConnection>
31
		<url>https://devel.gvsig.org/redmine/projects/gvsig-educa/repository/show/org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap</url>
32
	</scm>
33
	<developers>
34
		<developer>
35
			<id>cordinyana</id>
36
			<name>C?sar Ordi?ana</name>
37
			<email>cordinyana@gvsig.com</email>
38
			<roles>
39
				<role>Architect</role>
40
				<role>Developer</role>
41
			</roles>
42
		</developer>
43
		<developer>
44
			<id>jmvivo</id>
45
			<name>Jose Manuel Viv? Arnal</name>
46
			<email>jmvivo@disid.com</email>
47
			<roles>
48
				<role>Analyst</role>
49
				<role>Developer</role>
50
			</roles>
51
		</developer>
52
	</developers>
53
	<repositories>
54
		<repository>
55
			<id>gvsig-public-http-repository</id>
56
			<name>gvSIG maven public HTTP repository</name>
57
			<url>http://devel.gvsig.org/m2repo/j2se</url>
58
			<releases>
59
				<enabled>true</enabled>
60
				<updatePolicy>daily</updatePolicy>
61
				<checksumPolicy>warn</checksumPolicy>
62
			</releases>
63
			<snapshots>
64
				<enabled>true</enabled>
65
				<updatePolicy>daily</updatePolicy>
66
				<checksumPolicy>warn</checksumPolicy>
67
			</snapshots>
68
		</repository>
69
	</repositories>
70
	<build>
71
		<plugins>
72
			<plugin>
73
				<groupId>org.apache.maven.plugins</groupId>
74
				<artifactId>maven-release-plugin</artifactId>
75
				<configuration>
76
					<tagBase>https://devel.gvsig.org/svn/gvsig-educa/org.gvsig.educa.thematicmap/tags</tagBase>
77
				</configuration>
78
			</plugin>
79
		</plugins>
80
	</build>
81
	<dependencyManagement>
82
		<dependencies>
83
			<!-- gvSIG educa -->
84
			<dependency>
85
				<groupId>org.gvsig</groupId>
86
				<artifactId>org.gvsig.educa.thematicmap.lib.api</artifactId>
87
				<version>${educa.version}</version>
88
			</dependency>
89
			<dependency>
90
				<groupId>org.gvsig</groupId>
91
				<artifactId>org.gvsig.educa.thematicmap.lib.api</artifactId>
92
				<version>${educa.version}</version>
93
				<type>test-jar</type>
94
				<scope>test</scope>
95
			</dependency>
96
			<dependency>
97
				<groupId>org.gvsig</groupId>
98
				<artifactId>org.gvsig.educa.thematicmap.lib.impl</artifactId>
99
				<version>${educa.version}</version>
100
			</dependency>
101
			<dependency>
102
				<groupId>org.gvsig</groupId>
103
				<artifactId>org.gvsig.educa.thematicmap.lib.prov.installer</artifactId>
104
				<version>${educa.version}</version>
105
			</dependency>
106
			<dependency>
107
				<groupId>org.gvsig</groupId>
108
				<artifactId>org.gvsig.educa.thematicmap.swing.api</artifactId>
109
				<version>${educa.version}</version>
110
			</dependency>
111
			<dependency>
112
				<groupId>org.gvsig</groupId>
113
				<artifactId>org.gvsig.educa.thematicmap.swing.api</artifactId>
114
				<version>${educa.version}</version>
115
				<type>test-jar</type>
116
				<scope>test</scope>
117
			</dependency>
118
			<dependency>
119
				<groupId>org.gvsig</groupId>
120
				<artifactId>org.gvsig.educa.thematicmap.swing.impl</artifactId>
121
				<version>${educa.version}</version>
122
			</dependency>
123

  
124
			<!-- gvSIG -->
125
			<dependency>
126
				<groupId>org.gvsig</groupId>
127
				<artifactId>org.gvsig.i18n</artifactId>
128
				<version>${gvsig.i18n.version}</version>
129
			</dependency>
130
			<dependency>
131
				<groupId>org.gvsig</groupId>
132
				<artifactId>org.gvsig.tools.lib</artifactId>
133
				<version>${gvsig.tools.version}</version>
134
			</dependency>
135
			<dependency>
136
				<groupId>org.gvsig</groupId>
137
				<artifactId>org.gvsig.tools.lib</artifactId>
138
				<version>${gvsig.tools.version}</version>
139
				<type>test-jar</type>
140
				<scope>test</scope>
141
			</dependency>
142
			<dependency>
143
				<groupId>org.gvsig</groupId>
144
				<artifactId>org.gvsig.tools.swing.api</artifactId>
145
				<version>${gvsig.tools.version}</version>
146
			</dependency>
147
			<dependency>
148
				<groupId>org.gvsig</groupId>
149
				<artifactId>org.gvsig.tools.swing.impl</artifactId>
150
				<version>${gvsig.tools.version}</version>
151
			</dependency>
152
			<dependency>
153
				<groupId>org.gvsig</groupId>
154
				<artifactId>org.gvsig.utils</artifactId>
155
				<version>${gvsig.version}</version>
156
			</dependency>
157
			<dependency>
158
				<groupId>org.gvsig</groupId>
159
				<artifactId>org.gvsig.fmap.geometry</artifactId>
160
				<version>${gvsig.version}</version>
161
			</dependency>
162
			<dependency>
163
				<groupId>org.gvsig</groupId>
164
				<artifactId>org.gvsig.fmap.dal</artifactId>
165
				<version>${gvsig.version}</version>
166
			</dependency>
167
			<dependency>
168
				<groupId>org.gvsig</groupId>
169
				<artifactId>org.gvsig.compat</artifactId>
170
				<version>${gvsig.version}</version>
171
			</dependency>
172
			<dependency>
173
				<groupId>org.gvsig</groupId>
174
				<artifactId>org.gvsig.compat</artifactId>
175
				<version>${gvsig.version}</version>
176
				<classifier>se</classifier>
177
				<scope>runtime</scope>
178
			</dependency>
179
			<dependency>
180
				<groupId>org.gvsig</groupId>
181
				<artifactId>org.gvsig.fmap.mapcontext</artifactId>
182
				<version>${gvsig.version}</version>
183
			</dependency>
184
			<dependency>
185
				<groupId>org.gvsig</groupId>
186
				<artifactId>org.gvsig.fmap.control</artifactId>
187
				<version>${gvsig.version}</version>
188
			</dependency>
189
			<dependency>
190
				<groupId>org.gvsig</groupId>
191
				<artifactId>org.gvsig.symbology.lib.api</artifactId>
192
				<version>${gvsig.symbology.version}</version>
193
			</dependency>
194
			<dependency>
195
				<groupId>org.gvsig</groupId>
196
				<artifactId>org.gvsig.symbology.lib.impl</artifactId>
197
				<version>${gvsig.symbology.version}</version>
198
				<scope>runtime</scope>
199
			</dependency>
200
			<dependency>
201
				<groupId>org.gvsig</groupId>
202
				<artifactId>org.gvsig.fmap.dal.file</artifactId>
203
				<version>${gvsig.version}</version>
204
				<scope>compile</scope>
205
			</dependency>
206
			<dependency>
207
				<groupId>org.gvsig</groupId>
208
				<artifactId>org.gvsig.fmap.dal.file</artifactId>
209
				<version>${gvsig.version}</version>
210
				<classifier>store.dbf</classifier>
211
			</dependency>
212
			<dependency>
213
				<groupId>org.gvsig</groupId>
214
				<artifactId>org.gvsig.fmap.dal.file</artifactId>
215
				<version>${gvsig.version}</version>
216
				<classifier>store.shp</classifier>
217
			</dependency>
218
			<dependency>
219
				<groupId>org.gvsig</groupId>
220
				<artifactId>org.gvsig.fmap.geometry</artifactId>
221
				<version>${gvsig.version}</version>
222
				<classifier>impl</classifier>
223
			</dependency>
224
			<dependency>
225
				<groupId>org.gvsig</groupId>
226
				<artifactId>org.gvsig.projection</artifactId>
227
				<version>${gvsig.version}</version>
228
				<classifier>cresques-impl</classifier>
229
				<scope>test</scope>
230
			</dependency>
231
			<dependency>
232
				<groupId>org.gvsig</groupId>
233
				<artifactId>org.gvsig.timesupport.lib.impl</artifactId>
234
				<version>${gvsig.timesupport}</version>
235
			</dependency>
236
			<dependency>
237
				<groupId>org.gvsig</groupId>
238
				<artifactId>org.gvsig.ui</artifactId>
239
				<version>${gvsig.ui.version}</version>
240
			</dependency>
241
			<dependency>
242
				<groupId>org.gvsig</groupId>
243
				<artifactId>org.gvsig.fmap.dal.db</artifactId>
244
				<version>${gvsig.version}</version>
245
				<scope>runtime</scope>
246
			</dependency>
247
			<dependency>
248
				<groupId>org.gvsig</groupId>
249
				<artifactId>org.gvsig.fmap.dal.db</artifactId>
250
				<version>${gvsig.version}</version>
251
				<classifier>store.jdbc</classifier>
252
				<scope>runtime</scope>
253
			</dependency>
254
			<dependency>
255
				<groupId>org.gvsig</groupId>
256
				<artifactId>org.gvsig.fmap.dal.db</artifactId>
257
				<version>${gvsig.version}</version>
258
				<classifier>store.postgresql</classifier>
259
				<scope>runtime</scope>
260
			</dependency>
261
			<dependency>
262
				<groupId>org.gvsig</groupId>
263
				<artifactId>org.gvsig.fmap.dal.db</artifactId>
264
				<version>${gvsig.version}</version>
265
				<classifier>store.mysql</classifier>
266
				<scope>runtime</scope>
267
			</dependency>
268
			<dependency>
269
				<groupId>org.gvsig</groupId>
270
				<artifactId>org.gvsig.installer.lib.api</artifactId>
271
				<version>${gvsig.installer.version}</version>
272
			</dependency>
273
			<dependency>
274
				<groupId>org.gvsig</groupId>
275
				<artifactId>org.gvsig.installer.lib.spi</artifactId>
276
				<version>${gvsig.installer.version}</version>
277
			</dependency>
278
			<dependency>
279
				<groupId>org.gvsig</groupId>
280
				<artifactId>org.gvsig.installer.lib.impl</artifactId>
281
				<version>${gvsig.installer.version}</version>
282
				<scope>runtime</scope>
283
			</dependency>
284
			<dependency>
285
				<groupId>org.gvsig</groupId>
286
				<artifactId>org.gvsig.installer.swing.api</artifactId>
287
				<version>${gvsig.installer.version}</version>
288
			</dependency>
289
			<dependency>
290
				<groupId>org.gvsig</groupId>
291
				<artifactId>org.gvsig.installer.swing.impl</artifactId>
292
				<version>${gvsig.installer.version}</version>
293
				<scope>runtime</scope>
294
			</dependency>
295

  
296

  
297
			<!-- apache commons -->
298
			<dependency>
299
				<groupId>org.apache.commons</groupId>
300
				<artifactId>commons-io</artifactId>
301
				<version>${apache.commons-io.version}</version>
302
			</dependency>
303
			<dependency>
304
				<groupId>org.apache.commons</groupId>
305
				<artifactId>commons-lang3</artifactId>
306
				<version>${apache.commons-lang3.version}</version>
307
			</dependency>
308

  
309
		</dependencies>
310
	</dependencyManagement>
311

  
312
	<dependencies>
313
		<dependency>
314
			<groupId>org.gvsig</groupId>
315
			<artifactId>org.gvsig.tools.lib</artifactId>
316
		</dependency>
317
		<dependency>
318
			<groupId>org.gvsig</groupId>
319
			<artifactId>org.gvsig.tools.lib</artifactId>
320
			<type>test-jar</type>
321
		</dependency>
322
		<dependency>
323
			<groupId>org.slf4j</groupId>
324
			<artifactId>slf4j-api</artifactId>
325
			<scope>compile</scope>
326
		</dependency>
327
	</dependencies>
328

  
329
	<modules>
330
		<module>org.gvsig.educa.thematicmap.lib</module>
331
		<module>org.gvsig.educa.thematicmap.swing</module>
332
		<module>org.gvsig.educa.thematicmap.main</module>
333
	</modules>
334

  
335
</project>
org.gvsig.educa.thematicmap/tags/Build_5/org.gvsig.educa.thematicmap/README-ECLIPSE.txt
1
The first time you checkout the current project to a new workspace, 
2
you have to prepare it to be able to work easily with maven from
3
eclipse itself.
4

  
5
Perform the following steps:
6

  
7
1.- Launch the *prepare-workspace.xml* ant build file. 
8
    You can do it by loading the file into the ant view, 
9
    and running the default task, or right-clicking the 
10
    file from the package explorer or the navigator and
11
    select the option: *Run as > Ant build*. 
12
    
13
2.- Restart eclipse.
14

  
15
3.- Import the subprojects of the project you have just checked out.
16

  
17
Those steps are only needed once per workspace.     
18

  
org.gvsig.educa.thematicmap/tags/Build_5/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.main/src/main/resources/log4j.xml
1
<?xml version="1.0" encoding="ISO-8859-1" ?>
2
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
3

  
4
<!--
5
Log4J configuration file for unit tests execution.
6
 -->
7
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
8

  
9
	<!-- Appender configuration to show logging messages through the console -->
10
	<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
11
		<layout class="org.apache.log4j.PatternLayout">
12
			<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n  %m%n" />
13
		</layout>
14
	</appender>
15

  
16
	<!--
17
	Activate logging messages of DEBUG level of higher only for the
18
	org.gvsig.tools packages.
19
	You can put full classes names or packages instead, to configure
20
	logging for all the classes and subpackages of the package.
21
	-->
22
	<category name="org.gvsig.tools">
23
		<priority value="DEBUG" />
24
	</category>
25
	<category name="org.gvsig.educa">
26
		<priority value="DEBUG" />
27
	</category>
28

  
29
	<!--
30
	By default, show only logging messages of INFO level or higher,
31
	through the previously configured CONSOLE appender.
32
	-->
33
	<root>
34
		<priority value="DEBUG" />
35
		<appender-ref ref="CONSOLE" />
36
	</root>
37
</log4j:configuration>
org.gvsig.educa.thematicmap/tags/Build_5/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.main/src/main/resources/README.txt
1
Put into this folder the resources needed by your classes.
2

  
3
This folder is added to the classpath, so you can load any resources 
4
through the ClassLoader.
5

  
6
By default, in this folder you can find an example of log4j configuration,
7
prepared to log messages through the console, so logging works when you
8
run your classes.
org.gvsig.educa.thematicmap/tags/Build_5/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.main/src/main/java/org/gvsig/educa/thematicmap/main/OpenThematicMap.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.educa.thematicmap.main;
23

  
24
import java.awt.BorderLayout;
25
import java.awt.Dimension;
26
import java.awt.event.ActionEvent;
27
import java.util.ArrayList;
28
import java.util.List;
29

  
30
import javax.swing.AbstractAction;
31
import javax.swing.Box;
32
import javax.swing.BoxLayout;
33
import javax.swing.JButton;
34
import javax.swing.JLabel;
35
import javax.swing.JList;
36
import javax.swing.JPanel;
37
import javax.swing.JScrollPane;
38
import javax.swing.ListSelectionModel;
39
import javax.swing.event.ListSelectionEvent;
40
import javax.swing.event.ListSelectionListener;
41

  
42
import org.gvsig.educa.thematicmap.map.ThematicMap;
43
import org.gvsig.educa.thematicmap.swing.ThematicMapSwingLocator;
44
import org.gvsig.educa.thematicmap.swing.ThematicMapSwingManager;
45
import org.gvsig.educa.thematicmap.swing.viewer.ThematicMapInforamtionViewer;
46
import org.gvsig.tools.swing.api.ToolsSwingLocator;
47
import org.gvsig.tools.swing.api.dynobject.DynObjectSwingManager;
48
import org.gvsig.tools.swing.api.usability.UsabilitySwingManager;
49

  
50
/**
51
 * Open Thematic Map dialog
52
 * 
53
 * @author gvSIG Team
54
 * @version $Id$
55
 * 
56
 */
57
public class OpenThematicMap extends JPanel implements ListSelectionListener {
58

  
59
    /**
60
     *
61
     */
62
    private static final long serialVersionUID = 1L;
63

  
64
    private static final org.slf4j.Logger LOG = org.slf4j.LoggerFactory
65
        .getLogger(OpenThematicMap.class);
66

  
67
    private final ThematicMapSwingManager swingManager;
68
    private final DynObjectSwingManager dynSwingManager;
69
    private final UsabilitySwingManager usabManager;
70

  
71
    private final Main main;
72

  
73
    private List<ThematicMap> maps;
74
    private final List<String> mapNames;
75
    private JPanel listPanel;
76
    private JList list;
77
    private JPanel informationPanel;
78
    private ThematicMapInforamtionViewer information;
79

  
80
    private JPanel actionPanel;
81
    private JButton botOpen;
82
    private JButton botCancel;
83
    private ThematicMap curMap;
84

  
85
    private int lastSelectedIndex;
86

  
87
    private JPanel container;
88

  
89
    public OpenThematicMap(Main main, List<ThematicMap> installedMaps) {
90
        super();
91

  
92
        this.main = main;
93
        swingManager = ThematicMapSwingLocator.getSwingManager();
94

  
95
        dynSwingManager = ToolsSwingLocator.getDynObjectSwingManager();
96
        usabManager = ToolsSwingLocator.getUsabilitySwingManager();
97

  
98
        maps = installedMaps;
99
        mapNames = new ArrayList<String>(installedMaps.size());
100
        for (ThematicMap map : maps) {
101
            mapNames.add(map.getInformation().getName());
102
        }
103
        curMap = null;
104
        lastSelectedIndex = -1;
105

  
106
        initializeUI();
107

  
108
    }
109

  
110
    /**
111
     * Initialize user interface
112
     * 
113
     */
114
    private void initializeUI() {
115
        setLayout(new BorderLayout(5, 5));
116

  
117
        setMaximumSize(new Dimension(300, 200));
118
        setPreferredSize(new Dimension(800, 600));
119

  
120
        list = new JList(mapNames.toArray());
121
        list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
122
        list.addListSelectionListener(this);
123

  
124
        listPanel = new JPanel();
125
        listPanel.setLayout(new BorderLayout(5, 5));
126
        listPanel.add(new JLabel("Thematic Maps availables:"),
127
            BorderLayout.NORTH);
128
        listPanel.add(list, BorderLayout.CENTER);
129

  
130
        add(new JScrollPane(listPanel), BorderLayout.WEST);
131

  
132
        informationPanel = new JPanel();
133
        informationPanel.setLayout(new BorderLayout(5, 5));
134

  
135
        informationPanel.add(new JLabel("Thematic Map information:"),
136
            BorderLayout.NORTH);
137

  
138
        information = swingManager.newInformationViewer();
139
        informationPanel.add(information.getSwingComponent(),
140
            BorderLayout.CENTER);
141

  
142
        add(informationPanel, BorderLayout.CENTER);
143

  
144
        actionPanel = new JPanel();
145
        BoxLayout actionPanelLayout =
146
            new BoxLayout(actionPanel, BoxLayout.X_AXIS);
147
        actionPanel.setLayout(actionPanelLayout);
148

  
149
        actionPanel.add(Box.createHorizontalGlue());
150

  
151
        botOpen = usabManager.createJButton(new AbstractAction("Open Map") {
152

  
153
            /**
154
             *
155
             */
156
            private static final long serialVersionUID = -3437007146684939225L;
157

  
158
            public void actionPerformed(ActionEvent e) {
159
                openSelected();
160
            }
161
        });
162
        botOpen.setEnabled(false);
163

  
164
        botCancel = usabManager.createJButton(new AbstractAction("Cancel") {
165

  
166
            /**
167
             *
168
             */
169
            private static final long serialVersionUID = -2227776656041247582L;
170

  
171
            public void actionPerformed(ActionEvent e) {
172
                close();
173
            }
174
        });
175

  
176
        actionPanel.add(botOpen);
177
        actionPanel.add(Box.createHorizontalStrut(10));
178
        actionPanel.add(botCancel);
179
        actionPanel.add(Box.createHorizontalStrut(5));
180

  
181
        add(actionPanel, BorderLayout.SOUTH);
182

  
183
    }
184

  
185
    /**
186
     * Opens selected thematic map
187
     */
188
    private void openSelected() {
189
        if (curMap == null) {
190
            return;
191
        }
192
        main.openMap(curMap);
193
        close();
194
    }
195

  
196
    /**
197
     * Close this dialog
198
     */
199
    private void close() {
200
        this.setVisible(false);
201
        maps = null;
202
        curMap = null;
203
    }
204

  
205
    /**
206
     * Update UI with Thematic list selection
207
     */
208
    public void valueChanged(ListSelectionEvent e) {
209
        int index = list.getSelectedIndex();
210
        if (index == lastSelectedIndex) {
211
            return;
212
        }
213
        lastSelectedIndex = index;
214
        if (index < 0) {
215
            if (information != null) {
216
                information.clean();
217
            }
218
            botOpen.setEnabled(false);
219
            return;
220
        }
221
        botOpen.setEnabled(true);
222
        curMap = maps.get(index);
223
        information.loadMapInfromation(curMap);
224
    }
225
}
org.gvsig.educa.thematicmap/tags/Build_5/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.main/src/main/java/org/gvsig/educa/thematicmap/main/package.html
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
<html xmlns="http://www.w3.org/1999/xhtml">
4
<head>
5
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6
<title>org.gvsig.educa.thematicmap package documentation</title>
7
</head>
8
<body>
9

  
10
	<p>ThematicMap library testing and demo application.</p>
11

  
12
</body>
13
</html>
org.gvsig.educa.thematicmap/tags/Build_5/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.main/src/main/java/org/gvsig/educa/thematicmap/main/MapToolsRegistrant.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.educa.thematicmap.main;
23

  
24
import org.gvsig.educa.thematicmap.swing.viewer.MapControlToolRegistrant;
25
import org.gvsig.fmap.mapcontrol.MapControl;
26
import org.gvsig.fmap.mapcontrol.tools.PanListenerImpl;
27
import org.gvsig.fmap.mapcontrol.tools.ZoomInListenerImpl;
28
import org.gvsig.fmap.mapcontrol.tools.ZoomOutRightButtonListener;
29
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior;
30
import org.gvsig.fmap.mapcontrol.tools.Behavior.MouseWheelBehavior;
31
import org.gvsig.fmap.mapcontrol.tools.Behavior.MoveBehavior;
32
import org.gvsig.fmap.mapcontrol.tools.Behavior.PointBehavior;
33
import org.gvsig.fmap.mapcontrol.tools.Behavior.RectangleBehavior;
34

  
35
/**
36
 * @author gvSIG Team
37
 * @version $Id$
38
 * 
39
 */
40
public class MapToolsRegistrant implements MapControlToolRegistrant {
41

  
42
    public static final String TOOL_ZOOM_ID = "zoom";
43

  
44
    public static final String TOOL_PAN_ID = "pan";
45

  
46
    public void registerTools(MapControl mapControl) {
47
        // Adds tools to mapControl
48
        // mouseWhell
49
        mapControl.addCombinedBehavior(new MouseWheelBehavior());
50
        // zoom
51
        mapControl.addBehavior(TOOL_ZOOM_ID, new Behavior[] {
52
            new RectangleBehavior(new ZoomInListenerImpl(mapControl)),
53
            new PointBehavior(new ZoomOutRightButtonListener(mapControl)) });
54
        // pan
55
        mapControl.addBehavior(TOOL_PAN_ID, new MoveBehavior(
56
            new PanListenerImpl(mapControl)));
57

  
58
        mapControl.setTool(TOOL_PAN_ID);
59
    }
60

  
61
}
org.gvsig.educa.thematicmap/tags/Build_5/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.main/src/main/java/org/gvsig/educa/thematicmap/main/Main.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.educa.thematicmap.main;
23

  
24
import java.awt.BorderLayout;
25
import java.awt.Dimension;
26
import java.awt.event.ActionEvent;
27
import java.io.File;
28
import java.io.IOException;
29
import java.net.URL;
30
import java.util.List;
31

  
32
import javax.swing.AbstractAction;
33
import javax.swing.Box;
34
import javax.swing.JButton;
35
import javax.swing.JFileChooser;
36
import javax.swing.JFrame;
37
import javax.swing.JMenu;
38
import javax.swing.JMenuBar;
39
import javax.swing.JMenuItem;
40
import javax.swing.JToolBar;
41
import javax.swing.WindowConstants;
42

  
43
import org.slf4j.Logger;
44
import org.slf4j.LoggerFactory;
45

  
46
import org.gvsig.educa.thematicmap.ThematicMapLocator;
47
import org.gvsig.educa.thematicmap.ThematicMapManager;
48
import org.gvsig.educa.thematicmap.compilation.ThematicMapCompilation;
49
import org.gvsig.educa.thematicmap.compilation.ThematicMapCompiler;
50
import org.gvsig.educa.thematicmap.compilation.ThematicMapCompilerListener;
51
import org.gvsig.educa.thematicmap.compilation.ThematicMapCompilerStatus;
52
import org.gvsig.educa.thematicmap.map.ThematicMap;
53
import org.gvsig.educa.thematicmap.swing.ThematicMapSwingLocator;
54
import org.gvsig.educa.thematicmap.swing.ThematicMapSwingManager;
55
import org.gvsig.educa.thematicmap.swing.ThematicMapWindowManager;
56
import org.gvsig.educa.thematicmap.swing.ThematicMapWindowManager.CONFIRM_DIALOG_OPTION;
57
import org.gvsig.educa.thematicmap.swing.ThematicMapWindowManager.CONFIRM_DIALOG_TYPE;
58
import org.gvsig.educa.thematicmap.swing.ThematicMapWindowManager.MESSAGE_DIALOG_TYPE;
59
import org.gvsig.educa.thematicmap.swing.editor.ThematicMapCompilationEditor;
60
import org.gvsig.educa.thematicmap.swing.editor.ThematicMapCompilationEditorListener;
61
import org.gvsig.educa.thematicmap.swing.viewer.ThematicMapViewer;
62
import org.gvsig.installer.swing.api.SwingInstallerLocator;
63
import org.gvsig.installer.swing.api.SwingInstallerManager;
64
import org.gvsig.installer.swing.api.execution.InstallPackageWizardException;
65
import org.gvsig.installer.swing.api.wizard.AbstractInstallerWizard;
66
import org.gvsig.tools.ToolsLocator;
67
import org.gvsig.tools.dispose.DisposableManager;
68
import org.gvsig.tools.exception.BaseException;
69
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer;
70
import org.gvsig.tools.swing.api.ToolsSwingLocator;
71
import org.gvsig.tools.swing.api.usability.UsabilitySwingManager;
72
import org.gvsig.tools.swing.api.windowmanager.WindowManager.MODE;
73

  
74
/**
75
 * Main executable class for testing the ThematicMap library.
76
 * 
77
 * @author gvSIG Team
78
 * @version $Id$
79
 */
80
public class Main {
81

  
82
    private static final Logger LOG = LoggerFactory.getLogger(Main.class);
83

  
84
    private final ThematicMapManager manager;
85
    private final ThematicMapSwingManager swingManager;
86
    private final ThematicMapWindowManager winManager;
87
    private final UsabilitySwingManager usabManager;
88
    private final DisposableManager disposeManager;
89
    private final SwingInstallerManager swingInstallerManager;
90

  
91
    private final JFileChooser fileChooser;
92
    private JFrame mainFrame;
93
    private ThematicMapViewer curViewer = null;
94

  
95
    private AbstractAction setPanToolAction;
96
    private AbstractAction setZoomToolAction;
97
    private AbstractAction zoomAllAction;
98
    private AbstractAction setThematiMapFolderAction;
99
    private AbstractAction showOpenThematicMapDialogAction;
100
    private AbstractAction exitAction;
101
    private AbstractAction closeThematicMapAction;
102

  
103
    private AbstractAction createCompilationAction;
104

  
105
    private AbstractAction createCompilationFromMapAction;
106

  
107
    private AbstractAction installThematicMaps;
108

  
109
    private AbstractAction addInstallUrl;
110

  
111
    public static void main(String args[]) {
112
        new DefaultLibrariesInitializer().fullInitialize();
113

  
114
        Main main = new Main();
115
        main.show();
116
    }
117

  
118
    /**
119
     * New instance of Main
120
     */
121
    public Main() {
122
        manager = ThematicMapLocator.getManager();
123
        swingManager = ThematicMapSwingLocator.getSwingManager();
124
        winManager = swingManager.getWindowManager();
125
        usabManager = ToolsSwingLocator.getUsabilitySwingManager();
126
        disposeManager = ToolsLocator.getDisposableManager();
127
        swingInstallerManager =
128
            SwingInstallerLocator.getSwingInstallerManager();
129

  
130
        String defaultFolderPath =
131
            "gvSIG/plugins/org.gvsig.educa.thematicmap.app.viewer/thematicMaps";
132
        File defaultFolder =
133
            new File(System.getProperty("user.home"), defaultFolderPath);
134

  
135
        if (defaultFolder.exists() && defaultFolder.isDirectory()) {
136
            manager.setInstallationMapFolder(defaultFolder.getAbsolutePath());
137
        }
138

  
139
        swingManager.addMapControlRegistrant(new MapToolsRegistrant());
140

  
141
        fileChooser = new JFileChooser();
142

  
143
    }
144

  
145
    /**
146
     * Shows main frame
147
     */
148
    public void show() {
149

  
150
        // Create actions
151
        createActions();
152

  
153
        // Create JFrame to show data
154
        mainFrame = new JFrame("ThematicMap example app");
155
        mainFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
156
        mainFrame.setLayout(new BorderLayout(10, 10));
157

  
158
        // Create menu bar
159
        createMenu();
160

  
161
        // Create tools bar
162
        createToolBar();
163

  
164
        updateControls();
165

  
166
        // Display the window.
167
        mainFrame.pack();
168
        mainFrame.setSize(800, 600);
169
        mainFrame.setVisible(true);
170

  
171
    }
172

  
173
    /**
174
     * Creates all the action for menu and tools bar
175
     * 
176
     */
177
    @SuppressWarnings("serial")
178
    private void createActions() {
179
        setThematiMapFolderAction =
180
            new AbstractAction("Set thematic map folder") {
181

  
182
                public void actionPerformed(ActionEvent e) {
183
                    setThematicMapFolder();
184
                }
185
            };
186

  
187
        showOpenThematicMapDialogAction =
188
            new AbstractAction("Open a Thematic Map") {
189

  
190
                public void actionPerformed(ActionEvent e) {
191
                    showOpenThematicMapDialog();
192
                }
193
            };
194
        showOpenThematicMapDialogAction.setEnabled(false);
195

  
196
        setZoomToolAction = new AbstractAction("Tool Zoom") {
197

  
198
            public void actionPerformed(ActionEvent e) {
199
                setZoomTool();
200
            }
201
        };
202
        setZoomToolAction.setEnabled(false);
203

  
204
        setPanToolAction = new AbstractAction("Tool Pan") {
205

  
206
            public void actionPerformed(ActionEvent e) {
207
                setPanTool();
208
            }
209
        };
210
        setPanToolAction.setEnabled(false);
211

  
212
        zoomAllAction = new AbstractAction("Zoom all") {
213

  
214
            public void actionPerformed(ActionEvent e) {
215
                zoomAll();
216
            }
217
        };
218
        zoomAllAction.setEnabled(false);
219

  
220
        closeThematicMapAction = new AbstractAction("Close Map") {
221

  
222
            public void actionPerformed(ActionEvent e) {
223
                closeMap();
224
            }
225
        };
226
        closeThematicMapAction.setEnabled(false);
227

  
228
        exitAction = new AbstractAction("Exit") {
229

  
230
            public void actionPerformed(ActionEvent e) {
231
                exit();
232
            }
233
        };
234

  
235
        createCompilationAction = new AbstractAction("Create a compilation") {
236

  
237
            public void actionPerformed(ActionEvent e) {
238
                createCompilation();
239
            }
240
        };
241
        createCompilationAction.setEnabled(false);
242

  
243
        createCompilationFromMapAction =
244
            new AbstractAction("Create compilation from current map") {
245

  
246
                public void actionPerformed(ActionEvent e) {
247
                    createCompilationFromMap();
248
                }
249
            };
250
        createCompilationFromMapAction.setEnabled(false);
251

  
252
        addInstallUrl = new AbstractAction("Add a ThematicMap install URL") {
253

  
254
            public void actionPerformed(ActionEvent e) {
255
                addThematicMapUrl();
256
            }
257

  
258
        };
259

  
260
        installThematicMaps = new AbstractAction("Install ThematicMaps") {
261

  
262
            public void actionPerformed(ActionEvent e) {
263
                installThematicMap();
264
            }
265

  
266
        };
267
        installThematicMaps.setEnabled(false);
268

  
269
    }
270

  
271
    /**
272
     * Creates the menu bar
273
     */
274
    private void createMenu() {
275
        // Create the menu bar.
276
        JMenuBar menuBar = new JMenuBar();
277

  
278
        // Build the menu.
279
        JMenu menuFile = new JMenu("File");
280
        menuFile.add(new JMenuItem(setThematiMapFolderAction));
281
        menuFile.addSeparator();
282
        menuFile.add(new JMenuItem(showOpenThematicMapDialogAction));
283
        menuFile.add(new JMenuItem(closeThematicMapAction));
284
        menuFile.addSeparator();
285
        menuFile.add(new JMenuItem(createCompilationAction));
286
        menuFile.add(new JMenuItem(createCompilationFromMapAction));
287
        menuFile.addSeparator();
288
        menuFile.add(new JMenuItem(addInstallUrl));
289
        menuFile.add(new JMenuItem(installThematicMaps));
290
        menuFile.addSeparator();
291
        menuFile.add(new JMenuItem(exitAction));
292

  
293
        JMenu menuViewer = new JMenu("Viewer");
294
        menuViewer.add(setPanToolAction);
295
        menuViewer.add(setZoomToolAction);
296
        menuViewer.addSeparator();
297
        menuViewer.add(zoomAllAction);
298

  
299
        menuBar.add(menuFile);
300
        menuBar.add(menuViewer);
301

  
302
        mainFrame.setJMenuBar(menuBar);
303
    }
304

  
305
    /**
306
     * Creates the tools bar
307
     */
308
    private void createToolBar() {
309
        Dimension sepSize = new Dimension(20, 5);
310
        JToolBar toolBar = new JToolBar();
311
        toolBar.add(usabManager.createJButton(showOpenThematicMapDialogAction));
312
        toolBar.add(usabManager.createJButton(closeThematicMapAction));
313

  
314
        toolBar.addSeparator(sepSize);
315
        toolBar.add(usabManager.createJButton(setPanToolAction));
316
        toolBar.add(usabManager.createJButton(setZoomToolAction));
317

  
318
        toolBar.addSeparator(sepSize);
319
        toolBar.add(usabManager.createJButton(zoomAllAction));
320

  
321
        toolBar.add(Box.createHorizontalGlue());
322
        toolBar.add(new JButton(exitAction));
323

  
324
        mainFrame.add(toolBar, BorderLayout.PAGE_START);
325
    }
326

  
327
    /**
328
     * Shows file chooser to select thematic map folder
329
     */
330
    public void setThematicMapFolder() {
331
        fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
332
        int result =
333
            fileChooser.showDialog(mainFrame, "Select ThematicMap folder");
334
        if (result != JFileChooser.APPROVE_OPTION) {
335
            return;
336
        }
337
        File folder = fileChooser.getSelectedFile();
338
        List<ThematicMap> maps =
339
            manager.getInstalledMaps(folder.getAbsolutePath());
340
        if (maps.isEmpty()) {
341
            LOG.info("No maps foudn in required folder: {}",
342
                folder.getAbsolutePath());
343
            CONFIRM_DIALOG_OPTION resp =
344
                winManager.showConfirmDialog(mainFrame,
345
                    "No maps found. Select this folder anyway?",
346
                    "Set ThematicMap folder", CONFIRM_DIALOG_TYPE.YES_NO,
347
                    MESSAGE_DIALOG_TYPE.WARNING);
348
            if (resp != CONFIRM_DIALOG_OPTION.OK_YES) {
349
                return;
350
            }
351
        }
352
        LOG.info("Selected map folder: {}", folder.getAbsolutePath());
353
        try {
354
            manager.setInstallationMapFolder(folder.getAbsolutePath());
355
        } catch (Exception e) {
356
            LOG.error("Error setting thematic map folder", e);
357
            winManager
358
                .showMessageDialog(
359
                    mainFrame,
360
                    "Setting folder",
361
                    "Problem foudn setting Thematic Map folder (See log for more information)",
362
                    MESSAGE_DIALOG_TYPE.ERROR);
363
        }
364
        updateControls();
365
    }
366

  
367
    /**
368
     * Shows a dialog to select a Thematic Map to open
369
     */
370
    public void showOpenThematicMapDialog() {
371
        if (manager.getInstallationMapFolder() == null) {
372
            LOG.warn("thematic map folder not set on open Thematic Map request");
373
            winManager.showMessageDialog(mainFrame, "Open a Thematic Map",
374
                "Select a Thematic Map folder first", MESSAGE_DIALOG_TYPE.INFO);
375
            return;
376
        }
377
        OpenThematicMap openThematicMap =
378
            new OpenThematicMap(this, manager.getInstalledMaps());
379
        winManager.showWindow(openThematicMap, "Open a Thematic Map...",
380
            MODE.DIALOG);
381
    }
382

  
383
    /**
384
     * Opens a thematic map in main frame
385
     * 
386
     * @param curMap
387
     * @return
388
     */
389
    public boolean openMap(ThematicMap curMap) {
390
        ThematicMapViewer viewer;
391
        try {
392
            viewer = swingManager.getViewer(curMap);
393
        } catch (Exception e) {
394
            LOG.error("Can't open map", e);
395
            winManager.showMessageDialog(mainFrame, "Open Thematic map",
396
                "Problem found opening map (see log for details)",
397
                MESSAGE_DIALOG_TYPE.ERROR);
398
            return false;
399
        }
400
        doCloseMap();
401

  
402
        mainFrame.add(viewer.getSwingComponent(), BorderLayout.CENTER);
403
        curViewer = viewer;
404
        updateControls();
405
        return true;
406
    }
407

  
408
    /**
409
     * Closes the current thematic map
410
     */
411
    public void closeMap() {
412
        doCloseMap();
413
        updateControls();
414
    }
415

  
416
    /**
417
     * Removes thematic map view from main frame
418
     */
419
    private void doCloseMap() {
420
        if (curViewer != null) {
421
            mainFrame.remove(curViewer.getSwingComponent());
422
            try {
423
                curViewer.getThematicMap().close();
424
            } catch (IOException e) {
425
                LOG.warn("Exception clossing map", e);
426
            }
427
            curViewer = null;
428
        }
429
    }
430

  
431
    /**
432
     * Update actions ability and updates main frame content
433
     */
434
    public void updateControls() {
435
        showOpenThematicMapDialogAction.setEnabled(manager
436
            .getInstallationMapFolder() != null);
437
        createCompilationAction
438
            .setEnabled(manager.getInstallationMapFolder() != null);
439
        createCompilationFromMapAction.setEnabled(curViewer != null);
440
        setZoomToolAction.setEnabled(curViewer != null);
441
        setPanToolAction.setEnabled(curViewer != null);
442
        closeThematicMapAction.setEnabled(curViewer != null);
443
        zoomAllAction.setEnabled(curViewer != null);
444
        installThematicMaps
445
            .setEnabled(manager.getInstallationMapFolder() != null);
446

  
447
        mainFrame.getContentPane().invalidate();
448
        mainFrame.doLayout();
449
        Dimension d = mainFrame.getSize();
450
        d.width--;
451
        mainFrame.setSize(d);
452
        d.width++;
453
        mainFrame.setSize(d);
454

  
455
    }
456

  
457
    /**
458
     * Sets the zoom tool
459
     */
460
    public void setZoomTool() {
461
        if (curViewer != null) {
462
            curViewer.setTool(MapToolsRegistrant.TOOL_ZOOM_ID);
463
        }
464
    }
465

  
466
    /**
467
     * Sets the pan tool
468
     */
469
    public void setPanTool() {
470
        if (curViewer != null) {
471
            curViewer.setTool(MapToolsRegistrant.TOOL_PAN_ID);
472
        }
473
    }
474

  
475
    /**
476
     * Zoom to all thematic map contents
477
     */
478
    public void zoomAll() {
479
        if (curViewer != null) {
480
            curViewer.zoomAll();
481
        }
482
    }
483

  
484
    /**
485
     * Exit from app
486
     */
487
    public void exit() {
488
        // Close current thematic map
489
        closeMap();
490

  
491
        // clean resources
492
        try {
493
            disposeManager.releaseAll();
494
        } catch (BaseException e) {
495
            LOG.warn("Problems dispossing", e);
496
        }
497

  
498
        try {
499
            Thread.sleep(200);
500
        } catch (InterruptedException e) {
501
            // Do nothing
502
        }
503

  
504
        // exit app
505
        System.exit(0);
506
    }
507

  
508
    public void createCompilation() {
509
        ThematicMapCompilation compilation =
510
            manager.createCompilationInstance();
511

  
512
        ThematicMapCompilationEditor editor =
513
            swingManager.getCopilationEditor(compilation, true);
514

  
515
        editor.setListener(new ThematicMapCompilationEditorListener() {
516

  
517
            public void finished(ThematicMapCompilationEditor editor) {
518
                CONFIRM_DIALOG_OPTION resp =
519
                    winManager.showConfirmDialog(mainFrame,
520
                        "Compile thematic map", "Create a compilation",
521
                        CONFIRM_DIALOG_TYPE.YES_NO,
522
                        MESSAGE_DIALOG_TYPE.QUESTION);
523
                if (resp != CONFIRM_DIALOG_OPTION.OK_YES) {
524
                    winManager.showMessageDialog(mainFrame,
525
                        "Create a compilation",
526
                        "Process finished: no compiled",
527
                        MESSAGE_DIALOG_TYPE.INFO);
528
                    return;
529
                }
530
                compileMap(editor.getCompilation());
531

  
532
            }
533

  
534
            public void canceled(ThematicMapCompilationEditor editor) {
535
                // Do nothing
536

  
537
            }
538
        });
539

  
540
        winManager.showCompilationEditor(editor, MODE.WINDOW);
541

  
542
    }
543

  
544
    public void createCompilationFromMap() {
545
        ThematicMapCompilation compilation;
546
        try {
547
            compilation =
548
                manager.createCompilationInstanceFromMap(curViewer
549
                    .getThematicMap());
550
        } catch (Exception ex) {
551
            winManager.showMessageDialog(mainFrame,
552
                "Create Compilation from Thematic Map",
553
                "Problems creating compilation (show log for more info)",
554
                MESSAGE_DIALOG_TYPE.ERROR);
555
            LOG.error("Problems creating compilation from map", ex);
556
            return;
557
        }
558

  
559
        ThematicMapCompilationEditor editor =
560
            swingManager.getCopilationEditor(compilation, true);
561

  
562
        editor.setListener(new ThematicMapCompilationEditorListener() {
563

  
564
            public void finished(ThematicMapCompilationEditor editor) {
565
                CONFIRM_DIALOG_OPTION resp =
566
                    winManager.showConfirmDialog(mainFrame,
567
                        "Compile thematic map", "Create a compilation",
568
                        CONFIRM_DIALOG_TYPE.YES_NO,
569
                        MESSAGE_DIALOG_TYPE.QUESTION);
570
                if (resp != CONFIRM_DIALOG_OPTION.OK_YES) {
571
                    winManager.showMessageDialog(mainFrame,
572
                        "Create a compilation",
573
                        "Process finished: no compiled",
574
                        MESSAGE_DIALOG_TYPE.INFO);
575
                    return;
576
                }
577
                compileMap(editor.getCompilation());
578

  
579
            }
580

  
581
            public void canceled(ThematicMapCompilationEditor editor) {
582
                // Do nothing
583

  
584
            }
585
        });
586

  
587
        winManager.showCompilationEditor(editor, MODE.WINDOW);
588

  
589
    }
590

  
591
    public void installThematicMap() {
592
        AbstractInstallerWizard panel;
593
        try {
594
            panel =
595
                swingInstallerManager.createInstallPackageWizard(new File("."),
596
                    new File(manager.getInstallationMapFolder()), null);
597
        } catch (InstallPackageWizardException ex) {
598
            LOG.error("Error opening installer panel", ex);
599
            winManager.showMessageDialog("Install Thematic Maps",
600
                "Error opening installer panel", MESSAGE_DIALOG_TYPE.ERROR);
601
            return;
602

  
603
        }
604

  
605
        winManager.showWindow(panel, "Install Thematic Map", MODE.DIALOG);
606

  
607
    }
608

  
609
    public void addThematicMapUrl() {
610
        String inUrl =
611
            winManager.showInputStringDialog("Input the url",
612
                "Add install Thematic Map URL", "http://",
613
                MESSAGE_DIALOG_TYPE.QUESTION);
614
        URL url;
615
        try {
616
            url = new URL(inUrl);
617
        } catch (Exception ex) {
618
            LOG.error("Invalid URL: ".concat(inUrl).concat("'"), ex);
619
            winManager.showMessageDialog("Add install Thematic Map URL",
620
                "Invalid URL: '".concat(inUrl).concat("'"),
621
                MESSAGE_DIALOG_TYPE.ERROR);
622
            return;
623
        }
624
        swingInstallerManager.addDefaultDownloadURL(url);
625
    }
626

  
627
    public void compileMap(ThematicMapCompilation compilation) {
628
        ThematicMapCompiler compiler = manager.createCompilerInstance();
629
        compiler.setTargetFolder(manager.getInstallationMapFolder());
630
        File workFolder =
631
            new File(manager.getTemporalFolder() + File.separatorChar
632
                + "compiler");
633
        workFolder.mkdirs();
634
        compiler.setWorkFolder(workFolder.getAbsolutePath()
635
            + File.separatorChar);
636

  
637
        compiler.setCompilerListener(new CompilerProcessListener(LOG));
638
        ThematicMapCompilerStatus resul = compiler.compile(compilation);
639

  
640
        if (resul.getStatus() != ThematicMapCompilerStatus.Status.finished_ok) {
641
            winManager.showMessageDialog(mainFrame, "Compile Thematic Map",
642
                "Problems found in process (show log for more info)",
643
                MESSAGE_DIALOG_TYPE.ERROR);
644
            return;
645

  
646
        }
647
        winManager.showMessageDialog(mainFrame, "Compile Thematic Map",
648
            "<html>Process successful:<br>"
649
                + resul.getGeneratedThematicMapFile().getAbsolutePath()
650
                + "</html>", MESSAGE_DIALOG_TYPE.INFO);
651

  
652
        CONFIRM_DIALOG_OPTION generatePkg =
653
            winManager.showConfirmDialog(
654
                "Would you like to generete a gvSIG pakage file?",
655
                "Compile Thematic Map", CONFIRM_DIALOG_TYPE.YES_NO,
656
                MESSAGE_DIALOG_TYPE.QUESTION);
657

  
658
        if (generatePkg != CONFIRM_DIALOG_OPTION.OK_YES) {
659
            return;
660
        }
661
        fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
662
        int targetFolderAnswere =
663
            fileChooser.showDialog(mainFrame,
664
                "Select folder where store the package file");
665
        if (targetFolderAnswere != JFileChooser.APPROVE_OPTION) {
666
            return;
667
        }
668
        File gvsigPkg = null;
669
        try {
670
            gvsigPkg =
671
                manager.generatePackageFile(
672
                    resul.getGeneratedInstalationThematicMapFolder(),
673
                    fileChooser.getSelectedFile());
674
        } catch (Exception ex) {
675
            LOG.error("Error generating gvSIG package", ex);
676
            winManager
677
                .showMessageDialog(
678
                    mainFrame,
679
                    "Compile Thematic Map",
680
                    "Problems found generating gvSIG package (show log for more info)",
681
                    MESSAGE_DIALOG_TYPE.ERROR);
682
            return;
683

  
684
        }
685
        winManager.showMessageDialog(mainFrame, "Compile Thematic Map",
686
            "<html>Generated gvSIG package:<br>" + gvsigPkg.getAbsolutePath()
687
                + "</html>", MESSAGE_DIALOG_TYPE.INFO);
688
    }
689

  
690
    private class CompilerProcessListener implements
691
        ThematicMapCompilerListener {
692

  
693
        private final Logger log;
694

  
695
        public CompilerProcessListener(Logger log) {
696
            this.log = log;
697
        }
698

  
699
        public void updatedStatus(ThematicMapCompilerStatus currentStatus) {
700
            if (log.isDebugEnabled()) {
701
                log.debug(
702
                    "Process status:\n\tStatus: {}\n\tStep: {}/{} ({}%)\n\tMessage: '{}'",
703
                    new Object[] { currentStatus.getStatus().name(),
704
                        currentStatus.getCurrentStep(),
705
                        currentStatus.getTotalSteps(),
706
                        currentStatus.getCompleted(), currentStatus.getLabel() });
707
            }
708

  
709
        }
710

  
711
        public void notifyWarning(String message,
712
            ThematicMapCompilerStatus currentStatus) {
713
            log.warn("Process warining: {}", message);
714

  
715
        }
716

  
717
        public void notifyException(ThematicMapCompilerStatus currentStatus) {
718
            log.error("Process error: {}", currentStatus.getFailMessage());
719
        }
720

  
721
    }
722
}
org.gvsig.educa.thematicmap/tags/Build_5/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.main/pom.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4
	<modelVersion>4.0.0</modelVersion>
5
	<artifactId>org.gvsig.educa.thematicmap.main</artifactId>
6
	<packaging>jar</packaging>
7
	<name>org.gvsig.educa.thematicmap.main</name>
8
	<parent>
9
		<groupId>org.gvsig</groupId>
10
		<artifactId>org.gvsig.educa.thematicmap</artifactId>
11
		<version>1.0.0-SNAPSHOT</version>
12
	</parent>
13
	<properties>
14
		<main.class>org.gvsig.educa.thematicmap.main.Main</main.class>
15
	</properties>
16

  
17

  
18
	<build>
19
		<plugins>
20
			<plugin>
21
				<groupId>org.apache.maven.plugins</groupId>
22
				<artifactId>maven-jar-plugin</artifactId>
23
				<configuration>
24
					<archive>
25
						<manifest>
26
							<addClasspath>true</addClasspath>
27
							<classpathPrefix>lib/</classpathPrefix>
28
							<mainClass>${main.class}</mainClass>
29
						</manifest>
30
					</archive>
31
				</configuration>
32
			</plugin>
33

  
34
			<plugin>
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff