svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.exportto.app / org.gvsig.exportto.app.mainplugin / src / main / java / org / gvsig / exportto / app / extension / LoadLayerAction.java @ 40557
History | View | Annotate | Download (2.8 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
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 3
|
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 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.exportto.app.extension; |
25 |
|
26 |
import javax.swing.JComponent; |
27 |
import javax.swing.JOptionPane; |
28 |
|
29 |
import org.slf4j.Logger; |
30 |
import org.slf4j.LoggerFactory; |
31 |
|
32 |
import org.gvsig.andami.PluginServices; |
33 |
import org.gvsig.exportto.ExporttoServiceFinishAction; |
34 |
import org.gvsig.fmap.dal.DataStoreParameters; |
35 |
import org.gvsig.fmap.mapcontext.MapContext; |
36 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
37 |
import org.gvsig.fmap.mapcontext.MapContextManager; |
38 |
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException; |
39 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
40 |
|
41 |
/**
|
42 |
* @author gvSIG Team
|
43 |
* @version $Id$
|
44 |
*
|
45 |
*/
|
46 |
public class LoadLayerAction implements ExporttoServiceFinishAction { |
47 |
|
48 |
private static final Logger LOG = LoggerFactory |
49 |
.getLogger(LoadLayerAction.class); |
50 |
private static final MapContextManager MAP_CONTEXT_MANAGER = |
51 |
MapContextLocator.getMapContextManager(); |
52 |
|
53 |
private MapContext mapContext = null; |
54 |
|
55 |
public LoadLayerAction(MapContext mapContext) {
|
56 |
super();
|
57 |
this.mapContext = mapContext;
|
58 |
} |
59 |
|
60 |
public void finished(String layerName, |
61 |
DataStoreParameters dataStoreParameters) { |
62 |
try {
|
63 |
int res =
|
64 |
JOptionPane.showConfirmDialog((JComponent) PluginServices |
65 |
.getMDIManager().getActiveWindow(), PluginServices.getText( |
66 |
this, "insertar_en_la_vista_la_capa_creada"), |
67 |
PluginServices.getText(this, "insertar_capa"), |
68 |
JOptionPane.YES_NO_OPTION);
|
69 |
|
70 |
if (res == JOptionPane.YES_OPTION) { |
71 |
FLayer layer = |
72 |
MAP_CONTEXT_MANAGER.createLayer(layerName, |
73 |
dataStoreParameters); |
74 |
mapContext.getLayers().addLayer(layer); |
75 |
} |
76 |
|
77 |
} catch (LoadLayerException e) {
|
78 |
LOG.error("Error loading the exported layer", e);
|
79 |
} |
80 |
} |
81 |
} |