root / org.gvsig.wfs.app / trunk / org.gvsig.wfs.app / org.gvsig.wfs.app.mainplugin / src / main / java / org / gvsig / wfs / gui / toc / WFSProperties.java @ 10
History | View | Annotate | Download (5.28 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 |
/*
|
81 |
* The layer is re-created each time.
|
82 |
* TODO Check if this is really necessary
|
83 |
*/
|
84 |
FLyrVect newLayer = (FLyrVect)panel.createLayer(); |
85 |
|
86 |
/*
|
87 |
* Copy label strategy too
|
88 |
*/
|
89 |
newLayer.setIsLabeled(layer.isLabeled()); |
90 |
newLayer.setLabelingStrategy(layer.getLabelingStrategy()); |
91 |
// =======================================
|
92 |
|
93 |
if (newLayer != null){ |
94 |
layer.getMapContext().getLayers().replaceLayer(layer, newLayer); |
95 |
layer = newLayer; |
96 |
layer.setLegend((IVectorLegend)legend); |
97 |
} |
98 |
} catch (LoadLayerException e) {
|
99 |
LOG.error("Error loading the new layer", e);
|
100 |
} catch (CreateLayerException e) {
|
101 |
LOG.error("Error creating the new layer", e);
|
102 |
} |
103 |
|
104 |
} |
105 |
} |
106 |
|
107 |
/* (non-Javadoc)
|
108 |
* @see com.iver.cit.gvsig.project.documents.view.legend.gui.AbstractThemeManagerPage#cancelAction()
|
109 |
*/
|
110 |
public void cancelAction() { |
111 |
// TODO Auto-generated method stub
|
112 |
|
113 |
} |
114 |
|
115 |
/* (non-Javadoc)
|
116 |
* @see com.iver.cit.gvsig.project.documents.view.legend.gui.AbstractThemeManagerPage#getName()
|
117 |
*/
|
118 |
public String getName() { |
119 |
return PluginServices.getText(this, "WFS"); |
120 |
} |
121 |
|
122 |
/* (non-Javadoc)
|
123 |
* @see com.iver.cit.gvsig.project.documents.view.legend.gui.AbstractThemeManagerPage#setModel(org.gvsig.fmap.mapcontext.layers.FLayer)
|
124 |
*/
|
125 |
public void setModel(FLayer layer) { |
126 |
this.layer = (FLyrVect)layer;
|
127 |
PanelGroupManager manager = PanelGroupManager.getManager(); |
128 |
manager.registerPanelGroup(WFSParamsPanel.class); |
129 |
manager.setDefaultType(WFSParamsPanel.class); |
130 |
try {
|
131 |
if( ! (this.layer.getDataStore().getExplorer() instanceof WFSServerExplorer) ) { |
132 |
return;
|
133 |
} |
134 |
boolean firstExecution = (panel == null); |
135 |
WFSServerExplorer serverExplorer = (WFSServerExplorer)this.layer.getDataStore().getExplorer();
|
136 |
WFSSelectedFeatureManager selectedFeatureManager = WFSSelectedFeatureManager.getInstance(serverExplorer); |
137 |
panel = (WFSParamsPanel) manager.getPanelGroup(null);
|
138 |
panel.loadPanels(new PanelGroupLoaderFromExtensionPoint(wfs_properties_extensionpoint_name));
|
139 |
panel.setServerExplorer(serverExplorer); |
140 |
panel.setVisible(true);
|
141 |
if (firstExecution){
|
142 |
add(panel, BorderLayout.CENTER);
|
143 |
} |
144 |
|
145 |
//Refresh the forms with the capabilities information
|
146 |
panel.refreshCapabilitiesInfo(); |
147 |
|
148 |
//Set the datastore
|
149 |
panel.setDataStore(((FLyrVect)layer).getDataStore()); |
150 |
} catch (Exception e) { |
151 |
LOG.error("Error loading the layer", e);
|
152 |
} |
153 |
} |
154 |
|
155 |
} |
156 |
|