gvsig-educa / org.gvsig.educa.thematicmap.app / trunk / org.gvsig.educa.thematicmap.app / org.gvsig.educa.thematicmap.app.editor / src / main / java / org / gvsig / educa / thematicmap / app / editor / document / ViewToThematicMapAction.java @ 214
History | View | Annotate | Download (3.51 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.educa.thematicmap.app.editor.document; |
23 |
|
24 |
import java.util.List; |
25 |
|
26 |
import javax.swing.SwingUtilities; |
27 |
|
28 |
import org.gvsig.andami.PluginServices; |
29 |
import org.gvsig.andami.messages.NotificationManager; |
30 |
import org.gvsig.app.project.ProjectManager; |
31 |
import org.gvsig.app.project.documents.AbstractDocumentAction; |
32 |
import org.gvsig.app.project.documents.Document; |
33 |
import org.gvsig.app.project.documents.view.ViewDocument; |
34 |
import org.gvsig.educa.thematicmap.ThematicMapLocator; |
35 |
import org.gvsig.educa.thematicmap.ThematicMapManager; |
36 |
import org.gvsig.educa.thematicmap.app.editor.ThematicMapEditorLocator; |
37 |
import org.gvsig.educa.thematicmap.app.editor.ThematicMapEditorManager; |
38 |
|
39 |
/**
|
40 |
* Document action which create a Thematic Map from a View
|
41 |
*
|
42 |
* @author gvSIG Team
|
43 |
* @version $Id$
|
44 |
*
|
45 |
*/
|
46 |
public class ViewToThematicMapAction extends AbstractDocumentAction { |
47 |
|
48 |
private final ThematicMapEditorManager editorManager; |
49 |
private final ThematicMapManager manager; |
50 |
|
51 |
/**
|
52 |
*
|
53 |
*/
|
54 |
public ViewToThematicMapAction() {
|
55 |
super("ViewToThematicMap"); |
56 |
this.order = 0; |
57 |
this.title = PluginServices.getText(this, "create_thematic_map"); |
58 |
this.group =
|
59 |
ProjectManager.getInstance().addDocumentActionGroup( |
60 |
"ThematicMapActions", "Thematic Map actions", null, 0); |
61 |
editorManager = ThematicMapEditorLocator.getManager(); |
62 |
manager = ThematicMapLocator.getManager(); |
63 |
} |
64 |
|
65 |
/** {@inheridDoc} */
|
66 |
public boolean isVisible(Document document, List<Document> documents) { |
67 |
if (document != null || documents.size() != 1) { |
68 |
return false; |
69 |
} |
70 |
return true; |
71 |
} |
72 |
|
73 |
/** {@inheridDoc} */
|
74 |
public boolean isAvailable(Document document, List<Document> documents) { |
75 |
return true; |
76 |
} |
77 |
|
78 |
/** {@inheridDoc} */
|
79 |
public void execute(Document document, List<Document> documents) { |
80 |
final ViewDocument viewDoc;
|
81 |
if (document != null) { |
82 |
viewDoc = (ViewDocument) document; |
83 |
} else {
|
84 |
if (documents.size() != 1) { |
85 |
return;
|
86 |
} |
87 |
viewDoc = (ViewDocument) documents.get(0);
|
88 |
} |
89 |
|
90 |
SwingUtilities.invokeLater(new Runnable() { |
91 |
|
92 |
public void run() { |
93 |
try {
|
94 |
editorManager |
95 |
.createThematicMapFromView(viewDoc, null, true); |
96 |
} catch (Exception ex) { |
97 |
NotificationManager.addError( |
98 |
manager |
99 |
.getTranslation("problems_creating_thematic_map_from_a_view"),
|
100 |
ex); |
101 |
} |
102 |
|
103 |
} |
104 |
}); |
105 |
} |
106 |
} |