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 @ 33274

History | View | Annotate | Download (2.64 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

    
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
import org.gvsig.fmap.mapcontext.MapContextLocator;
39
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException;
40
import org.gvsig.fmap.mapcontext.layers.FLayer;
41
import org.gvsig.tools.locator.LocatorException;
42

    
43
/**
44
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
45
 */
46
public class AddLayerFinishAction implements AnnotationCreationFinishAction {
47
        private DefaultViewPanel viewPanel;
48
        
49
        public AddLayerFinishAction(DefaultViewPanel viewPanel) {
50
                this.viewPanel = viewPanel;
51
        }
52

    
53
        public void finished(FeatureStore featureStore) {
54
                int res = JOptionPane.showConfirmDialog((JComponent) PluginServices.getMDIManager()
55
                                .getActiveWindow(),
56
                                PluginServices.getText(this,
57
                                "insertar_en_la_vista_la_capa_creada"),
58
                                PluginServices.getText(this, "insertar_capa"),
59
                                JOptionPane.YES_NO_OPTION);
60

    
61
                if (res == JOptionPane.YES_OPTION) {
62
                        try {
63
                                addShape(featureStore);
64
                        } catch (LoadLayerException e) {
65
                                NotificationManager.addError(e);
66
                        } catch (LocatorException e) {
67
                                NotificationManager.addError(e);
68
                        }
69
                }
70
        }
71

    
72
        private void addShape(FeatureStore featureStore) throws LoadLayerException, LocatorException {
73
                FLayer layer = MapContextLocator.getMapContextManager().createLayer("Annotations", featureStore);
74
                viewPanel.getMapControl().getMapContext().getLayers().addLayer(layer);                
75
        }
76

    
77
}
78