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 @ 41
History | View | Annotate | Download (5.16 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.app.project.documents.view.legend.gui.ThemeManagerWindow; |
36 |
import org.gvsig.fmap.dal.serverexplorer.wfs.WFSServerExplorer; |
37 |
import org.gvsig.fmap.dal.store.wfs.WFSStoreProvider; |
38 |
import org.gvsig.fmap.mapcontext.exceptions.CreateLayerException; |
39 |
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException; |
40 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
41 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
42 |
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend; |
43 |
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend; |
44 |
import org.gvsig.gui.beans.panelGroup.PanelGroupManager; |
45 |
import org.gvsig.wfs.gui.panels.WFSParamsPanel; |
46 |
import org.gvsig.wfs.gui.panels.model.WFSSelectedFeatureManager; |
47 |
import org.slf4j.Logger; |
48 |
import org.slf4j.LoggerFactory; |
49 |
|
50 |
|
51 |
/**
|
52 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
|
53 |
*/
|
54 |
public class WFSProperties extends AbstractThemeManagerPage{ |
55 |
private static final long serialVersionUID = -3666226507540534256L; |
56 |
|
57 |
private static final Logger LOG = LoggerFactory.getLogger(WFSProperties.class); |
58 |
|
59 |
private WFSParamsPanel panel = null; |
60 |
private FLyrVect layer = null; |
61 |
private final String wfs_properties_extensionpoint_name = "WFSPropertiesDialog"; |
62 |
|
63 |
public WFSProperties() {
|
64 |
super();
|
65 |
setLayout(new BorderLayout()); |
66 |
} |
67 |
|
68 |
public void acceptAction() { |
69 |
applyAction(); |
70 |
} |
71 |
|
72 |
public void applyAction() { |
73 |
if (panel != null){ |
74 |
try{
|
75 |
ILegend legend = layer.getLegend(); |
76 |
/*
|
77 |
* The layer is re-created each time.
|
78 |
* TODO Check if this is really necessary
|
79 |
*/
|
80 |
FLyrVect newLayer = (FLyrVect)panel.createLayer(); |
81 |
|
82 |
/*
|
83 |
* Copy label strategy too
|
84 |
*/
|
85 |
newLayer.setIsLabeled(layer.isLabeled()); |
86 |
newLayer.setLabelingStrategy(layer.getLabelingStrategy()); |
87 |
// =======================================
|
88 |
|
89 |
if (newLayer != null){ |
90 |
layer.getMapContext().getLayers().replaceLayer(layer, newLayer); |
91 |
layer = newLayer; |
92 |
layer.setLegend((IVectorLegend)legend); |
93 |
} |
94 |
} catch (LoadLayerException e) {
|
95 |
LOG.error("Error loading the new layer", e);
|
96 |
} catch (CreateLayerException e) {
|
97 |
LOG.error("Error creating the new layer", e);
|
98 |
} |
99 |
|
100 |
} |
101 |
} |
102 |
|
103 |
public void cancelAction() { |
104 |
// TODO Auto-generated method stub
|
105 |
|
106 |
} |
107 |
|
108 |
public String getName() { |
109 |
return PluginServices.getText(this, "WFS"); |
110 |
} |
111 |
|
112 |
public boolean isTabEnabledForLayer(FLayer layer) { |
113 |
if(! (layer instanceof FLyrVect) ) { |
114 |
return false; |
115 |
} |
116 |
if( !WFSStoreProvider.NAME.equalsIgnoreCase(((FLyrVect)layer).getFeatureStore().getProviderName()) ) {
|
117 |
return false; |
118 |
} |
119 |
return true; |
120 |
} |
121 |
|
122 |
public void setModel(FLayer layer) { |
123 |
this.layer = (FLyrVect)layer;
|
124 |
PanelGroupManager manager = PanelGroupManager.getManager(); |
125 |
manager.registerPanelGroup(WFSParamsPanel.class); |
126 |
manager.setDefaultType(WFSParamsPanel.class); |
127 |
try {
|
128 |
if( ! (this.layer.getDataStore().getExplorer() instanceof WFSServerExplorer) ) { |
129 |
return;
|
130 |
} |
131 |
boolean firstExecution = (panel == null); |
132 |
WFSServerExplorer serverExplorer = (WFSServerExplorer)this.layer.getDataStore().getExplorer();
|
133 |
WFSSelectedFeatureManager selectedFeatureManager = WFSSelectedFeatureManager.getInstance(serverExplorer); |
134 |
panel = (WFSParamsPanel) manager.getPanelGroup(null);
|
135 |
panel.loadPanels(new PanelGroupLoaderFromExtensionPoint(wfs_properties_extensionpoint_name));
|
136 |
panel.setServerExplorer(serverExplorer); |
137 |
panel.setVisible(true);
|
138 |
if (firstExecution){
|
139 |
add(panel, BorderLayout.CENTER);
|
140 |
} |
141 |
|
142 |
//Refresh the forms with the capabilities information
|
143 |
panel.refreshCapabilitiesInfo(); |
144 |
|
145 |
//Set the datastore
|
146 |
panel.setDataStore(((FLyrVect)layer).getDataStore()); |
147 |
} catch (Exception e) { |
148 |
LOG.error("Error loading the layer", e);
|
149 |
} |
150 |
} |
151 |
|
152 |
} |
153 |
|