Statistics
| Revision:

root / branches / v2_0_0_prep / extensions / extWFS2 / src / org / gvsig / wfs / gui / toc / WFSProperties.java @ 38564

History | View | Annotate | Download (4.91 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
* 2009 {Iver T.I.}   {Task}
26
*/
27
 
28
package org.gvsig.wfs.gui.toc;
29

    
30
import java.awt.BorderLayout;
31

    
32
import org.gvsig.andami.PluginServices;
33
import org.gvsig.app.panelGroup.loaders.PanelGroupLoaderFromExtensionPoint;
34
import org.gvsig.app.project.documents.view.legend.gui.AbstractThemeManagerPage;
35
import org.gvsig.fmap.dal.serverexplorer.wfs.WFSServerExplorer;
36
import org.gvsig.fmap.mapcontext.exceptions.CreateLayerException;
37
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException;
38
import org.gvsig.fmap.mapcontext.layers.FLayer;
39
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
40
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend;
41
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend;
42
import org.gvsig.gui.beans.panelGroup.PanelGroupManager;
43
import org.gvsig.wfs.gui.panels.WFSParamsPanel;
44
import org.gvsig.wfs.gui.panels.model.WFSSelectedFeatureManager;
45
import org.slf4j.Logger;
46
import org.slf4j.LoggerFactory;
47

    
48

    
49
/**
50
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
51
 */
52
public class WFSProperties extends AbstractThemeManagerPage{
53
    private static final long serialVersionUID = -3666226507540534256L;
54

    
55
    private static final Logger LOG = LoggerFactory.getLogger(WFSProperties.class);
56
    
57
    private WFSParamsPanel panel = null;
58
        private FLyrVect layer = null;
59
        private final String wfs_properties_extensionpoint_name = "WFSPropertiesDialog";
60
        
61
        public WFSProperties() {
62
                super();
63
                setLayout(new BorderLayout());                
64
        }
65

    
66
        /* (non-Javadoc)
67
         * @see com.iver.cit.gvsig.project.documents.view.legend.gui.AbstractThemeManagerPage#acceptAction()
68
         */
69
        public void acceptAction() {
70
                applyAction();                
71
        }
72

    
73
        /* (non-Javadoc)
74
         * @see com.iver.cit.gvsig.project.documents.view.legend.gui.AbstractThemeManagerPage#applyAction()
75
         */        
76
        public void applyAction() {
77
                if (panel != null){                        
78
                    try{
79
                        ILegend legend = layer.getLegend();
80
                        FLyrVect newLayer = (FLyrVect)panel.createLayer();
81
                        if (newLayer != null){                      
82
                            layer.getMapContext().getLayers().replaceLayer(layer, newLayer);
83
                            layer = newLayer;
84
                            layer.setLegend((IVectorLegend)legend);
85
                        }
86
                    } catch (LoadLayerException e) {
87
                        LOG.error("Error loading the new layer", e);
88
                    } catch (CreateLayerException e) {
89
                        LOG.error("Error creating the new layer", e);
90
            }
91

    
92
                }
93
        }
94

    
95
        /* (non-Javadoc)
96
         * @see com.iver.cit.gvsig.project.documents.view.legend.gui.AbstractThemeManagerPage#cancelAction()
97
         */
98
        public void cancelAction() {
99
                // TODO Auto-generated method stub
100
                
101
        }
102

    
103
        /* (non-Javadoc)
104
         * @see com.iver.cit.gvsig.project.documents.view.legend.gui.AbstractThemeManagerPage#getName()
105
         */
106
        public String getName() {
107
                return PluginServices.getText(this, "WFS");
108
        }
109

    
110
        /* (non-Javadoc)
111
         * @see com.iver.cit.gvsig.project.documents.view.legend.gui.AbstractThemeManagerPage#setModel(org.gvsig.fmap.mapcontext.layers.FLayer)
112
         */
113
        public void setModel(FLayer layer) {
114
                this.layer = (FLyrVect)layer;
115
                PanelGroupManager manager = PanelGroupManager.getManager();
116
                manager.registerPanelGroup(WFSParamsPanel.class);
117
                manager.setDefaultType(WFSParamsPanel.class);
118
                try {
119
                        if( ! (this.layer.getDataStore().getExplorer() instanceof  WFSServerExplorer) ) {
120
                                return;
121
                        }
122
                        boolean firstExecution = (panel == null);
123
                        WFSServerExplorer serverExplorer = (WFSServerExplorer)this.layer.getDataStore().getExplorer();
124
                        WFSSelectedFeatureManager selectedFeatureManager = WFSSelectedFeatureManager.getInstance(serverExplorer);
125
                        panel = (WFSParamsPanel) manager.getPanelGroup(null);
126
                        panel.loadPanels(new PanelGroupLoaderFromExtensionPoint(wfs_properties_extensionpoint_name));
127
                        panel.setServerExplorer(serverExplorer);
128
                        panel.setVisible(true);                
129
                        if (firstExecution){                                
130
                                add(panel, BorderLayout.CENTER);                                
131
                        }                
132
                        
133
                        //Refresh the forms with the capabilities information
134
                        panel.refreshCapabilitiesInfo();
135
                        
136
                        //Set the datastore
137
                        panel.setDataStore(((FLyrVect)layer).getDataStore());
138
                } catch (Exception e) {
139
                    LOG.error("Error loading the layer", e);
140
                }                
141
        }
142

    
143
}
144