root / 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 / ThematicMapToViewAction.java @ 62
History | View | Annotate | Download (3.41 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.educa.thematicmap.app.editor.ThematicMapEditorLocator; |
34 |
import org.gvsig.educa.thematicmap.app.editor.ThematicMapEditorManager; |
35 |
import org.gvsig.educa.thematicmap.app.viewer.ThematicMapDocument; |
36 |
import org.gvsig.educa.thematicmap.swing.ThematicMapSwingLocator; |
37 |
import org.gvsig.educa.thematicmap.swing.ThematicMapSwingManager; |
38 |
|
39 |
/**
|
40 |
* @author gvSIG Team
|
41 |
* @version $Id$
|
42 |
*
|
43 |
*/
|
44 |
public class ThematicMapToViewAction extends AbstractDocumentAction { |
45 |
|
46 |
private final ThematicMapEditorManager editorManager; |
47 |
private final ThematicMapSwingManager swingManager; |
48 |
|
49 |
/**
|
50 |
*
|
51 |
*/
|
52 |
public ThematicMapToViewAction() {
|
53 |
super("ThematicMapToView"); |
54 |
this.order = 0; |
55 |
this.title = PluginServices.getText(this, "export_to_view"); |
56 |
this.group =
|
57 |
ProjectManager.getInstance().addDocumentActionGroup( |
58 |
"ThematicMapActions", "Thematic Map actions", null, 0); |
59 |
editorManager = ThematicMapEditorLocator.getManager(); |
60 |
swingManager = ThematicMapSwingLocator.getSwingManager(); |
61 |
} |
62 |
|
63 |
public boolean isVisible(Document document, List<Document> documents) { |
64 |
if (document != null || documents.size() != 1) { |
65 |
return false; |
66 |
} |
67 |
return true; |
68 |
} |
69 |
|
70 |
public boolean isAvailable(Document document, List<Document> documents) { |
71 |
return true; |
72 |
} |
73 |
|
74 |
public void execute(Document document, List<Document> documents) { |
75 |
final ThematicMapDocument tmDoc;
|
76 |
if (document != null) { |
77 |
tmDoc = (ThematicMapDocument) document; |
78 |
} else {
|
79 |
if (documents.size() != 1) { |
80 |
return;
|
81 |
} |
82 |
tmDoc = (ThematicMapDocument) documents.get(0);
|
83 |
} |
84 |
|
85 |
SwingUtilities.invokeLater(new Runnable() { |
86 |
|
87 |
public void run() { |
88 |
try {
|
89 |
editorManager.exportThematicMapToView(tmDoc, true);
|
90 |
} catch (Exception ex) { |
91 |
NotificationManager.addError( |
92 |
swingManager |
93 |
.getTranslation("problems_exporting_thematic_map_to_view"),
|
94 |
ex); |
95 |
} |
96 |
|
97 |
} |
98 |
}); |
99 |
|
100 |
} |
101 |
|
102 |
} |