Statistics
| Revision:

root / branches / v2_0_0_prep / extensions / org.gvsig.annotation.app / org.gvsig.annotation.app.extension / src / main / java / org / gvsig / annotation / app / extension / AddLayerFinishAction.java @ 38194

History | View | Annotate | Download (2.65 KB)

1 33274 jpiera
/* 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.annotation.app.extension;
29
30
import javax.swing.JComponent;
31
import javax.swing.JOptionPane;
32
33
import org.gvsig.andami.PluginServices;
34
import org.gvsig.andami.messages.NotificationManager;
35
import org.gvsig.annotation.AnnotationCreationFinishAction;
36
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel;
37
import org.gvsig.fmap.dal.feature.FeatureStore;
38 38194 vacevedo
import org.gvsig.fmap.mapcontext.MapContext;
39 33274 jpiera
import org.gvsig.fmap.mapcontext.MapContextLocator;
40
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException;
41
import org.gvsig.fmap.mapcontext.layers.FLayer;
42
import org.gvsig.tools.locator.LocatorException;
43
44
/**
45
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
46
 */
47
public class AddLayerFinishAction implements AnnotationCreationFinishAction {
48 38194 vacevedo
        private MapContext mapContext;
49 33274 jpiera
50 38194 vacevedo
        public AddLayerFinishAction(MapContext mapContext) {
51
                this.mapContext = mapContext;
52 33274 jpiera
        }
53
54
        public void finished(FeatureStore featureStore) {
55
                int res = JOptionPane.showConfirmDialog((JComponent) PluginServices.getMDIManager()
56
                                .getActiveWindow(),
57
                                PluginServices.getText(this,
58
                                "insertar_en_la_vista_la_capa_creada"),
59
                                PluginServices.getText(this, "insertar_capa"),
60
                                JOptionPane.YES_NO_OPTION);
61
62
                if (res == JOptionPane.YES_OPTION) {
63
                        try {
64
                                addShape(featureStore);
65
                        } catch (LoadLayerException e) {
66
                                NotificationManager.addError(e);
67
                        } catch (LocatorException e) {
68
                                NotificationManager.addError(e);
69
                        }
70
                }
71
        }
72
73
        private void addShape(FeatureStore featureStore) throws LoadLayerException, LocatorException {
74
                FLayer layer = MapContextLocator.getMapContextManager().createLayer("Annotations", featureStore);
75 38194 vacevedo
                mapContext.getLayers().addLayer(layer);
76 33274 jpiera
        }
77
78
}