Revision 35512
branches/v2_0_0_prep/extensions/extDalTransform/src/main/java/org/gvsig/daltransform/swing/impl/LoadLayerWizardPanel.java | ||
---|---|---|
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.daltransform.swing.impl; |
|
29 |
|
|
30 |
import java.awt.event.ItemEvent; |
|
31 |
import java.awt.event.ItemListener; |
|
32 |
import java.util.List; |
|
33 |
|
|
34 |
import javax.swing.DefaultListModel; |
|
35 |
import javax.swing.JCheckBox; |
|
36 |
import javax.swing.JLabel; |
|
37 |
import javax.swing.JList; |
|
38 |
import javax.swing.JPanel; |
|
39 |
import javax.swing.JScrollPane; |
|
40 |
import javax.swing.JTextArea; |
|
41 |
|
|
42 |
import org.gvsig.andami.PluginServices; |
|
43 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
44 |
import org.gvsig.app.project.ProjectManager; |
|
45 |
import org.gvsig.app.project.documents.Document; |
|
46 |
import org.gvsig.app.project.documents.view.BaseViewDocument; |
|
47 |
import org.gvsig.app.project.documents.view.ViewManager; |
|
48 |
import org.gvsig.app.project.documents.view.gui.IView; |
|
49 |
import org.gvsig.daltransform.swing.DataTransformGui; |
|
50 |
import org.gvsig.fmap.dal.DataTypes; |
|
51 |
import org.gvsig.fmap.dal.exception.DataException; |
|
52 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
53 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
54 |
import org.gvsig.fmap.dal.feature.FeatureStoreTransform; |
|
55 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
56 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
57 |
import org.slf4j.Logger; |
|
58 |
import org.slf4j.LoggerFactory; |
|
59 |
|
|
60 |
|
|
61 |
/** |
|
62 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
63 |
*/ |
|
64 |
public class LoadLayerWizardPanel extends AbstractDataTransformWizardPanel implements ItemListener{ |
|
65 |
/** |
|
66 |
* |
|
67 |
*/ |
|
68 |
private static final long serialVersionUID = -7893735055404404591L; |
|
69 |
|
|
70 |
private static final Logger logger = LoggerFactory.getLogger(LoadLayerWizardPanel.class); |
|
71 |
private JCheckBox loadLayerCb = null; |
|
72 |
private JScrollPane messageScroll = null; |
|
73 |
private JTextArea messageTextArea = null; |
|
74 |
private JPanel northPanel = null; |
|
75 |
private JLabel selectViewLabel; |
|
76 |
private JList selectViewList; |
|
77 |
private JScrollPane selectViewScroll; |
|
78 |
private JPanel centerPanel; |
|
79 |
private FeatureStoreTransform transform = null; |
|
80 |
// private boolean hasViews = false; |
|
81 |
|
|
82 |
/** |
|
83 |
* @param wizardComponents |
|
84 |
*/ |
|
85 |
public LoadLayerWizardPanel() { |
|
86 |
super(); |
|
87 |
initComponents(); |
|
88 |
initLabels(); |
|
89 |
addViews(); |
|
90 |
loadLayerCb.addItemListener(this); |
|
91 |
itemStateChanged(null); |
|
92 |
} |
|
93 |
|
|
94 |
private void initLabels(){ |
|
95 |
loadLayerCb.setText(PluginServices.getText(this, "transform_load_layer_query")); |
|
96 |
selectViewLabel.setText(PluginServices.getText(this, "transform_view_to_load")); |
|
97 |
} |
|
98 |
|
|
99 |
private void initComponents() { |
|
100 |
java.awt.GridBagConstraints gridBagConstraints; |
|
101 |
|
|
102 |
northPanel = new javax.swing.JPanel(); |
|
103 |
messageScroll = new javax.swing.JScrollPane(); |
|
104 |
messageTextArea = new javax.swing.JTextArea(); |
|
105 |
loadLayerCb = new javax.swing.JCheckBox(); |
|
106 |
selectViewLabel = new javax.swing.JLabel(); |
|
107 |
centerPanel = new javax.swing.JPanel(); |
|
108 |
selectViewScroll = new javax.swing.JScrollPane(); |
|
109 |
selectViewList = new javax.swing.JList(); |
|
110 |
selectViewList.setModel(new DefaultListModel()); |
|
111 |
|
|
112 |
setLayout(new java.awt.BorderLayout()); |
|
113 |
|
|
114 |
northPanel.setLayout(new java.awt.GridBagLayout()); |
|
115 |
|
|
116 |
messageScroll.setBorder(null); |
|
117 |
|
|
118 |
messageTextArea.setColumns(20); |
|
119 |
messageTextArea.setEditable(false); |
|
120 |
messageTextArea.setLineWrap(true); |
|
121 |
messageTextArea.setRows(5); |
|
122 |
messageTextArea.setBorder(null); |
|
123 |
messageScroll.setViewportView(messageTextArea); |
|
124 |
|
|
125 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
126 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
127 |
gridBagConstraints.weightx = 1.0; |
|
128 |
gridBagConstraints.insets = new java.awt.Insets(2, 2, 5, 2); |
|
129 |
northPanel.add(messageScroll, gridBagConstraints); |
|
130 |
|
|
131 |
loadLayerCb.setText("jCheckBox1"); |
|
132 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
133 |
gridBagConstraints.gridx = 0; |
|
134 |
gridBagConstraints.gridy = 1; |
|
135 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
136 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
|
137 |
gridBagConstraints.weightx = 1.0; |
|
138 |
gridBagConstraints.insets = new java.awt.Insets(5, 2, 2, 2); |
|
139 |
northPanel.add(loadLayerCb, gridBagConstraints); |
|
140 |
|
|
141 |
selectViewLabel.setText("jLabel1"); |
|
142 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
143 |
gridBagConstraints.gridx = 0; |
|
144 |
gridBagConstraints.gridy = 2; |
|
145 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
146 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
|
147 |
gridBagConstraints.weightx = 1.0; |
|
148 |
gridBagConstraints.insets = new java.awt.Insets(5, 2, 5, 2); |
|
149 |
northPanel.add(selectViewLabel, gridBagConstraints); |
|
150 |
|
|
151 |
add(northPanel, java.awt.BorderLayout.NORTH); |
|
152 |
|
|
153 |
centerPanel.setLayout(new java.awt.GridBagLayout()); |
|
154 |
|
|
155 |
selectViewScroll.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); |
|
156 |
selectViewScroll.setPreferredSize(null); |
|
157 |
|
|
158 |
selectViewScroll.setViewportView(selectViewList); |
|
159 |
|
|
160 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
161 |
gridBagConstraints.gridx = 0; |
|
162 |
gridBagConstraints.gridy = 0; |
|
163 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
|
164 |
gridBagConstraints.weightx = 1.0; |
|
165 |
gridBagConstraints.weighty = 1.0; |
|
166 |
gridBagConstraints.insets = new java.awt.Insets(5, 2, 2, 2); |
|
167 |
centerPanel.add(selectViewScroll, gridBagConstraints); |
|
168 |
|
|
169 |
add(centerPanel, java.awt.BorderLayout.CENTER); |
|
170 |
} |
|
171 |
|
|
172 |
/* |
|
173 |
* (non-Javadoc) |
|
174 |
* @see org.gvsig.app.daltransform.impl.AbstractDataTransformWizardPanel#updatePanel() |
|
175 |
*/ |
|
176 |
public void updatePanel() { |
|
177 |
//Gets the selected transformation |
|
178 |
DataTransformGui featureTransformGui = getDataTransformWizard().getDataTransformGui(); |
|
179 |
|
|
180 |
//Gets the selected FeatureStore |
|
181 |
FeatureStore featureStore = getFeatureStore(); |
|
182 |
|
|
183 |
//Apply the transformation |
|
184 |
try { |
|
185 |
transform = featureTransformGui.createFeatureStoreTransform(featureStore); |
|
186 |
|
|
187 |
if (getDataTransformWizard().isFeatureStoreLayer()){ |
|
188 |
updateGuiForLayer(transform); |
|
189 |
}else{ |
|
190 |
updateGuiForTable(transform); |
|
191 |
} |
|
192 |
} catch (DataException e) { |
|
193 |
logger.error("Error creating the transformation", e); |
|
194 |
} |
|
195 |
} |
|
196 |
|
|
197 |
/** |
|
198 |
* Update the form when the transform has been applied in |
|
199 |
* to a table |
|
200 |
* @param transform |
|
201 |
* @throws DataException |
|
202 |
*/ |
|
203 |
private void updateGuiForTable(FeatureStoreTransform transform) throws DataException{ |
|
204 |
FeatureType featureType = transform.getDefaultFeatureType(); |
|
205 |
FeatureAttributeDescriptor[] featureAttributeDescriptors = featureType.getAttributeDescriptors(); |
|
206 |
boolean hasGeometry = false; |
|
207 |
for (int i=0 ; i<featureAttributeDescriptors.length ; i++){ |
|
208 |
if (featureAttributeDescriptors[i].getType() == DataTypes.GEOMETRY){ |
|
209 |
hasGeometry = true; |
|
210 |
} |
|
211 |
} |
|
212 |
if (hasGeometry){ |
|
213 |
if (selectViewList.getModel().getSize() == 0){ |
|
214 |
messageTextArea.setText(PluginServices.getText(this, "transform_layout_not_view_to_load")); |
|
215 |
setLoadLayerVisible(false); |
|
216 |
}else{ |
|
217 |
messageTextArea.setText(PluginServices.getText(this, "transform_layout_geometry")); |
|
218 |
setLoadLayerVisible(true); |
|
219 |
} |
|
220 |
}else{ |
|
221 |
messageTextArea.setText(PluginServices.getText(this, "transform_layout_no_geometry")); |
|
222 |
setLoadLayerVisible(false); |
|
223 |
} |
|
224 |
} |
|
225 |
|
|
226 |
/** |
|
227 |
* Set if it is possible or not lo load a layer |
|
228 |
* from the transformation |
|
229 |
* @param isVisible |
|
230 |
*/ |
|
231 |
private void setLoadLayerVisible(boolean isVisible){ |
|
232 |
loadLayerCb.setVisible(isVisible); |
|
233 |
selectViewLabel.setVisible(isVisible); |
|
234 |
selectViewScroll.setVisible(isVisible); |
|
235 |
selectViewList.setVisible(isVisible); |
|
236 |
} |
|
237 |
|
|
238 |
/** |
|
239 |
* Add the project views |
|
240 |
*/ |
|
241 |
private void addViews(){ |
|
242 |
selectViewList.removeAll(); |
|
243 |
|
|
244 |
List<Document> views = ProjectManager.getInstance().getCurrentProject().getDocuments(ViewManager.TYPENAME); |
|
245 |
for (Document view : views) { |
|
246 |
((DefaultListModel)selectViewList.getModel()).addElement(view); |
|
247 |
} |
|
248 |
// ProjectExtension ext = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class); |
|
249 |
// ArrayList<ProjectDocument> projects = ext.getProject().getDocumentsByType(ProjectViewFactory.registerName); |
|
250 |
// for (int i=0 ; i<projects.size() ; i++){ |
|
251 |
// ProjectViewBase view = (ProjectViewBase)projects.get(i); |
|
252 |
// ((DefaultListModel)selectViewList.getModel()).addElement(view); |
|
253 |
// } |
|
254 |
// if (selectViewList.getModel().getSize() > 0){ |
|
255 |
// hasViews = true; |
|
256 |
// } |
|
257 |
IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
|
258 |
if (window instanceof IView){ |
|
259 |
selectViewList.setSelectedValue(window, true); |
|
260 |
}else{ |
|
261 |
selectViewList.setSelectedIndex(0); |
|
262 |
} |
|
263 |
} |
|
264 |
|
|
265 |
/** |
|
266 |
* Update the form when the transform has been applied in |
|
267 |
* to a layer |
|
268 |
* @param transform |
|
269 |
* @throws DataException |
|
270 |
*/ |
|
271 |
private void updateGuiForLayer(FeatureStoreTransform transform){ |
|
272 |
messageTextArea.setText(PluginServices.getText(this, "transform_layer")); |
|
273 |
setLoadLayerVisible(false); |
|
274 |
} |
|
275 |
|
|
276 |
/** |
|
277 |
* @return if the layer has to be loaded |
|
278 |
*/ |
|
279 |
public boolean isLayerLoaded(){ |
|
280 |
if (!loadLayerCb.isVisible()){ |
|
281 |
return false; |
|
282 |
} |
|
283 |
return loadLayerCb.isSelected(); |
|
284 |
} |
|
285 |
|
|
286 |
/** |
|
287 |
* @return the transform |
|
288 |
*/ |
|
289 |
public FeatureStoreTransform getTransform() { |
|
290 |
return transform; |
|
291 |
} |
|
292 |
|
|
293 |
/** |
|
294 |
* @return The mapcontext |
|
295 |
*/ |
|
296 |
public MapContext getMapContext(){ |
|
297 |
Object obj = selectViewList.getSelectedValue(); |
|
298 |
if (obj != null){ |
|
299 |
return ((BaseViewDocument)obj).getMapContext(); |
|
300 |
} |
|
301 |
return null; |
|
302 |
} |
|
303 |
|
|
304 |
/* (non-Javadoc) |
|
305 |
* @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent) |
|
306 |
*/ |
|
307 |
public void itemStateChanged(ItemEvent arg0) { |
|
308 |
boolean isSelected = loadLayerCb.isSelected(); |
|
309 |
selectViewLabel.setEnabled(isSelected); |
|
310 |
selectViewList.setEnabled(isSelected); |
|
311 |
} |
|
312 |
|
|
313 |
/* (non-Javadoc) |
|
314 |
* @see org.gvsig.app.daltransform.gui.FeatureTransformWizard#getPanelTitle() |
|
315 |
*/ |
|
316 |
public String getPanelTitle() { |
|
317 |
return PluginServices.getText(this, "transform_apply"); |
|
318 |
} |
|
319 |
} |
|
320 |
|
|
0 | 321 |
branches/v2_0_0_prep/extensions/extDalTransform/src/main/java/org/gvsig/daltransform/swing/impl/SelectDataStoreWizardPanel.java | ||
---|---|---|
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.daltransform.swing.impl; |
|
29 |
|
|
30 |
import java.util.List; |
|
31 |
|
|
32 |
import javax.swing.DefaultListModel; |
|
33 |
import javax.swing.JList; |
|
34 |
import javax.swing.JScrollPane; |
|
35 |
|
|
36 |
import org.gvsig.andami.PluginServices; |
|
37 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
38 |
import org.gvsig.app.project.ProjectManager; |
|
39 |
import org.gvsig.app.project.documents.Document; |
|
40 |
import org.gvsig.app.project.documents.table.TableDocument; |
|
41 |
import org.gvsig.app.project.documents.table.TableManager; |
|
42 |
import org.gvsig.app.project.documents.view.gui.IView; |
|
43 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
44 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
45 |
import org.gvsig.fmap.mapcontext.layers.LayersIterator; |
|
46 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
47 |
|
|
48 |
|
|
49 |
/** |
|
50 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
51 |
*/ |
|
52 |
public class SelectDataStoreWizardPanel extends AbstractDataTransformWizardPanel{ |
|
53 |
private static final long serialVersionUID = -1841990357325903449L; |
|
54 |
private JList dataStoreList; |
|
55 |
private JScrollPane dataStoreScrollPane; |
|
56 |
|
|
57 |
/** |
|
58 |
* @param wizardComponents |
|
59 |
*/ |
|
60 |
public SelectDataStoreWizardPanel() { |
|
61 |
super(); |
|
62 |
initComponents(); |
|
63 |
addDataStores(); |
|
64 |
} |
|
65 |
|
|
66 |
private void initComponents() { |
|
67 |
java.awt.GridBagConstraints gridBagConstraints; |
|
68 |
|
|
69 |
dataStoreScrollPane = new javax.swing.JScrollPane(); |
|
70 |
dataStoreList = new javax.swing.JList(); |
|
71 |
|
|
72 |
setLayout(new java.awt.GridBagLayout()); |
|
73 |
|
|
74 |
dataStoreScrollPane.setViewportView(dataStoreList); |
|
75 |
|
|
76 |
dataStoreList.setModel(new DefaultListModel()); |
|
77 |
|
|
78 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
79 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
|
80 |
gridBagConstraints.weightx = 1.0; |
|
81 |
gridBagConstraints.weighty = 1.0; |
|
82 |
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); |
|
83 |
add(dataStoreScrollPane, gridBagConstraints); |
|
84 |
} |
|
85 |
|
|
86 |
public void removeFeatureStore(FeatureStore featureStore){ |
|
87 |
DefaultListModel model =( DefaultListModel)dataStoreList.getModel(); |
|
88 |
for (int i=model.getSize()-1 ; i>=0 ; i--){ |
|
89 |
if (((FeatureStoreCombo)model.get(i)).getFeatureStore().equals(featureStore)){ |
|
90 |
model.remove(i); |
|
91 |
break; |
|
92 |
} |
|
93 |
} |
|
94 |
} |
|
95 |
|
|
96 |
/** |
|
97 |
* Adding the objects |
|
98 |
*/ |
|
99 |
private void addDataStores(){ |
|
100 |
//Add all the tables |
|
101 |
List<Document> tables = ProjectManager.getInstance().getCurrentProject() |
|
102 |
.getDocuments(TableManager.TYPENAME); |
|
103 |
for (Document table : tables) { |
|
104 |
((DefaultListModel)dataStoreList.getModel()).addElement( |
|
105 |
new FeatureStoreCombo( |
|
106 |
table.getName(), |
|
107 |
((TableDocument)table).getStore(), |
|
108 |
false |
|
109 |
) |
|
110 |
); |
|
111 |
} |
|
112 |
|
|
113 |
// ProjectExtension ext = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class); |
|
114 |
// ArrayList<ProjectDocument> tables = ext.getProject().getDocumentsByType(FeatureTableDocumentFactory.registerName); |
|
115 |
// for (int i=0 ; i<tables.size() ; i++){ |
|
116 |
// FeatureTableDocument table = (FeatureTableDocument)tables.get(i); |
|
117 |
// ((DefaultListModel)dataStoreList.getModel()).addElement( |
|
118 |
// new FeatureStoreCombo(table.getName(), |
|
119 |
// table.getStore(), |
|
120 |
// false)); |
|
121 |
// } |
|
122 |
//Add the layers from the current view |
|
123 |
IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
|
124 |
if (window instanceof IView){ |
|
125 |
IView view = (IView)window; |
|
126 |
LayersIterator it = new LayersIterator( |
|
127 |
view.getMapControl().getMapContext().getLayers()); |
|
128 |
while(it.hasNext()){ |
|
129 |
FLayer layer = it.nextLayer(); |
|
130 |
if (layer instanceof FLyrVect){ |
|
131 |
// try { |
|
132 |
FLyrVect layerVect = (FLyrVect)layer; |
|
133 |
FeatureStore featureStore = layerVect.getFeatureStore(); |
|
134 |
boolean found = false; |
|
135 |
for (int i=0 ; i<tables.size() ; i++){ |
|
136 |
TableDocument table = (TableDocument)tables.get(i); |
|
137 |
if (table.getStore().equals(featureStore)) { |
|
138 |
found = true; |
|
139 |
} |
|
140 |
} |
|
141 |
if (!found){ |
|
142 |
((DefaultListModel)dataStoreList.getModel()).addElement( |
|
143 |
new FeatureStoreCombo(layerVect.getName(), |
|
144 |
featureStore, |
|
145 |
true)); |
|
146 |
} |
|
147 |
// } catch (ReadException e) { |
|
148 |
// logger.error("It is not possible to read the FeatureStore", e); |
|
149 |
// } |
|
150 |
} |
|
151 |
} |
|
152 |
} |
|
153 |
} |
|
154 |
|
|
155 |
|
|
156 |
/** |
|
157 |
* @return the selected feature store |
|
158 |
*/ |
|
159 |
public FeatureStore getSelectedFeatureStore(){ |
|
160 |
Object obj = dataStoreList.getSelectedValue(); |
|
161 |
if (obj != null){ |
|
162 |
return ((FeatureStoreCombo)obj).getFeatureStore(); |
|
163 |
} |
|
164 |
return null; |
|
165 |
} |
|
166 |
|
|
167 |
/* (non-Javadoc) |
|
168 |
* @see org.gvsig.app.daltransform.impl.AbstractDataTransformWizardPanel#getFeatureStore() |
|
169 |
*/ |
|
170 |
@Override |
|
171 |
public FeatureStore getFeatureStore() { |
|
172 |
return getSelectedFeatureStore(); |
|
173 |
} |
|
174 |
|
|
175 |
/** |
|
176 |
* @return the selected feature store |
|
177 |
*/ |
|
178 |
public boolean isSelectedFeatureStoreLoaded(){ |
|
179 |
Object obj = dataStoreList.getSelectedValue(); |
|
180 |
if (obj != null){ |
|
181 |
return ((FeatureStoreCombo)obj).isLoaded(); |
|
182 |
} |
|
183 |
return false; |
|
184 |
} |
|
185 |
|
|
186 |
/** |
|
187 |
* Used to fill the combo |
|
188 |
* @author jpiera |
|
189 |
*/ |
|
190 |
private class FeatureStoreCombo{ |
|
191 |
private FeatureStore featureStore = null; |
|
192 |
private String name = null; |
|
193 |
private boolean isLoaded = false; |
|
194 |
|
|
195 |
public FeatureStoreCombo(String name, FeatureStore featureStore, boolean isLoaded) { |
|
196 |
super(); |
|
197 |
this.name = name; |
|
198 |
this.featureStore = featureStore; |
|
199 |
this.isLoaded = isLoaded; |
|
200 |
} |
|
201 |
|
|
202 |
/** |
|
203 |
* @return the isLoaded |
|
204 |
*/ |
|
205 |
public boolean isLoaded() { |
|
206 |
return isLoaded; |
|
207 |
} |
|
208 |
|
|
209 |
/** |
|
210 |
* @return the featureStore |
|
211 |
*/ |
|
212 |
public FeatureStore getFeatureStore() { |
|
213 |
return featureStore; |
|
214 |
} |
|
215 |
|
|
216 |
/* (non-Javadoc) |
|
217 |
* @see java.lang.Object#toString() |
|
218 |
*/ |
|
219 |
public String toString() { |
|
220 |
return name; |
|
221 |
} |
|
222 |
} |
|
223 |
|
|
224 |
/* |
|
225 |
* (non-Javadoc) |
|
226 |
* @see org.gvsig.app.daltransform.gui.FeatureTransformWizard#getPanelTitle() |
|
227 |
*/ |
|
228 |
public String getPanelTitle() { |
|
229 |
return PluginServices.getText(this, "transform_datastore_selection"); |
|
230 |
} |
|
231 |
|
|
232 |
/* (non-Javadoc) |
|
233 |
* @see org.gvsig.app.daltransform.DataTransformWizard#updatePanel() |
|
234 |
*/ |
|
235 |
public void updatePanel() { |
|
236 |
if (dataStoreList.getSelectedIndex() == -1){ |
|
237 |
if (dataStoreList.getModel().getSize() > 0){ |
|
238 |
dataStoreList.setSelectedIndex(0); |
|
239 |
getDataTransformWizard().setApplicable(true); |
|
240 |
}else{ |
|
241 |
getDataTransformWizard().setApplicable(false); |
|
242 |
} |
|
243 |
} |
|
244 |
} |
|
245 |
|
|
246 |
/** |
|
247 |
* @return |
|
248 |
*/ |
|
249 |
public boolean isFeatureStoreLayer() { |
|
250 |
Object obj = dataStoreList.getSelectedValue(); |
|
251 |
if (obj != null){ |
|
252 |
return ((FeatureStoreCombo)obj).isLoaded; |
|
253 |
} |
|
254 |
return false; |
|
255 |
} |
|
256 |
|
|
257 |
/* (non-Javadoc) |
|
258 |
* @see org.gvsig.app.daltransform.impl.AbstractDataTransformWizardPanel#nextPanel() |
|
259 |
*/ |
|
260 |
@Override |
|
261 |
public void nextPanel() { |
|
262 |
getDataTransformWizard().updateGui(); |
|
263 |
} |
|
264 |
|
|
265 |
|
|
266 |
} |
|
267 |
|
|
0 | 268 |
branches/v2_0_0_prep/extensions/extDalTransform/src/main/java/org/gvsig/daltransform/swing/impl/DataTransformSelectionAction.java | ||
---|---|---|
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.daltransform.swing.impl; |
|
29 |
|
|
30 |
import jwizardcomponent.FinishAction; |
|
31 |
|
|
32 |
import org.gvsig.andami.PluginServices; |
|
33 |
import org.gvsig.daltransform.swing.DataTransformGui; |
|
34 |
import org.gvsig.fmap.crs.CRSFactory; |
|
35 |
import org.gvsig.fmap.dal.exception.DataException; |
|
36 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
37 |
import org.gvsig.fmap.dal.feature.FeatureStoreTransform; |
|
38 |
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException; |
|
39 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
40 |
import org.gvsig.fmap.mapcontext.layers.LayerFactory; |
|
41 |
import org.slf4j.Logger; |
|
42 |
import org.slf4j.LoggerFactory; |
|
43 |
|
|
44 |
|
|
45 |
/** |
|
46 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
47 |
*/ |
|
48 |
public class DataTransformSelectionAction extends FinishAction{ |
|
49 |
private static final Logger logger = LoggerFactory.getLogger(DataTransformSelectionAction.class); |
|
50 |
private DefaultDataTransformWizard dataTransformWizard = null; |
|
51 |
|
|
52 |
public DataTransformSelectionAction(DefaultDataTransformWizard dataTransformWizard) { |
|
53 |
super(dataTransformWizard.getWizardComponents()); |
|
54 |
this.dataTransformWizard = dataTransformWizard; |
|
55 |
} |
|
56 |
|
|
57 |
/* (non-Javadoc) |
|
58 |
* @see jwizardcomponent.Action#performAction() |
|
59 |
*/ |
|
60 |
public void performAction() { |
|
61 |
//Gets the selected transformation |
|
62 |
DataTransformGui featureTransformGui = dataTransformWizard.getDataTransformGui(); |
|
63 |
|
|
64 |
//Gets the selected FeatureStore |
|
65 |
FeatureStore featureStore = dataTransformWizard.getFeatureStore(); |
|
66 |
|
|
67 |
try { |
|
68 |
//Gets the transform |
|
69 |
FeatureStoreTransform featureStoreTransform = featureTransformGui.createFeatureStoreTransform(featureStore); |
|
70 |
|
|
71 |
//Apply the transformation |
|
72 |
featureStore.getTransforms().add(featureStoreTransform); |
|
73 |
|
|
74 |
//Create and load a new layer... |
|
75 |
if (dataTransformWizard.isLayerLoaded()){ |
|
76 |
FLayer layer = LayerFactory.getInstance().createLayer(featureTransformGui.toString(), |
|
77 |
featureStore); |
|
78 |
layer.setProjection(CRSFactory.getCRS("EPSG:23030")); |
|
79 |
dataTransformWizard.getMapContext().getLayers().addLayer(layer); |
|
80 |
layer.dispose(); |
|
81 |
} |
|
82 |
} catch (DataException e) { |
|
83 |
logger.error("Error creating the transformation", e); |
|
84 |
} catch (LoadLayerException e) { |
|
85 |
logger.error("Error loading the layer", e); |
|
86 |
} |
|
87 |
//Closing the window |
|
88 |
PluginServices.getMDIManager().closeWindow(dataTransformWizard); |
|
89 |
} |
|
90 |
|
|
91 |
} |
|
92 |
|
|
0 | 93 |
branches/v2_0_0_prep/extensions/extDalTransform/src/main/java/org/gvsig/daltransform/swing/impl/DataTransformWizardContainer.java | ||
---|---|---|
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.daltransform.swing.impl; |
|
29 |
|
|
30 |
import java.awt.BorderLayout; |
|
31 |
|
|
32 |
import jwizardcomponent.JWizardComponents; |
|
33 |
import jwizardcomponent.JWizardPanel; |
|
34 |
|
|
35 |
import org.gvsig.daltransform.swing.DataTransformWizardPanel; |
|
36 |
|
|
37 |
|
|
38 |
/** |
|
39 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
40 |
*/ |
|
41 |
public class DataTransformWizardContainer extends JWizardPanel { |
|
42 |
private static final long serialVersionUID = -3410258554443619626L; |
|
43 |
private DataTransformWizardPanel wizard = null; |
|
44 |
|
|
45 |
/** |
|
46 |
* @param wizardComponents |
|
47 |
*/ |
|
48 |
public DataTransformWizardContainer(JWizardComponents wizardComponents, DataTransformWizardPanel wizard) { |
|
49 |
super(wizardComponents); |
|
50 |
this.wizard = wizard; |
|
51 |
setLayout(new BorderLayout()); |
|
52 |
setBorder(javax.swing.BorderFactory.createTitledBorder(wizard.getPanelTitle())); |
|
53 |
add(wizard.getJPanel(), BorderLayout.CENTER); |
|
54 |
} |
|
55 |
|
|
56 |
/* (non-Javadoc) |
|
57 |
* @see jwizardcomponent.WizardPanel#back() |
|
58 |
*/ |
|
59 |
@Override |
|
60 |
public void back() { |
|
61 |
wizard.lastPanel(); |
|
62 |
super.back(); |
|
63 |
} |
|
64 |
|
|
65 |
/* (non-Javadoc) |
|
66 |
* @see jwizardcomponent.WizardPanel#next() |
|
67 |
*/ |
|
68 |
@Override |
|
69 |
public void next() { |
|
70 |
wizard.nextPanel(); |
|
71 |
super.next(); |
|
72 |
} |
|
73 |
|
|
74 |
/* (non-Javadoc) |
|
75 |
* @see jwizardcomponent.JWizardPanel#update() |
|
76 |
*/ |
|
77 |
@Override |
|
78 |
public void update() { |
|
79 |
wizard.updatePanel(); |
|
80 |
super.update(); |
|
81 |
} |
|
82 |
} |
|
83 |
|
|
0 | 84 |
branches/v2_0_0_prep/extensions/extDalTransform/src/main/java/org/gvsig/daltransform/swing/impl/AbstractDataTransformWizardPanel.java | ||
---|---|---|
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.daltransform.swing.impl; |
|
29 |
|
|
30 |
import javax.swing.JPanel; |
|
31 |
|
|
32 |
import org.gvsig.andami.PluginServices; |
|
33 |
import org.gvsig.daltransform.swing.DataTransformWizard; |
|
34 |
import org.gvsig.daltransform.swing.DataTransformWizardPanel; |
|
35 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
36 |
import org.slf4j.Logger; |
|
37 |
import org.slf4j.LoggerFactory; |
|
38 |
|
|
39 |
|
|
40 |
/** |
|
41 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
42 |
*/ |
|
43 |
public abstract class AbstractDataTransformWizardPanel extends JPanel implements DataTransformWizardPanel { |
|
44 |
protected static final Logger logger = LoggerFactory.getLogger(AbstractDataTransformWizardPanel.class); |
|
45 |
private DefaultDataTransformWizard dataTransformWizard = null; |
|
46 |
|
|
47 |
/** |
|
48 |
* @param featureStore |
|
49 |
*/ |
|
50 |
public AbstractDataTransformWizardPanel() { |
|
51 |
super(); |
|
52 |
} |
|
53 |
|
|
54 |
/* (non-Javadoc) |
|
55 |
* @see org.gvsig.app.daltransform.DataTransformWizardPanel#setDataTransformWizard(org.gvsig.app.daltransform.DataTransformWizard) |
|
56 |
*/ |
|
57 |
public void setDataTransformWizard(DataTransformWizard dataTransformWizard) { |
|
58 |
this.dataTransformWizard = (DefaultDataTransformWizard)dataTransformWizard; |
|
59 |
} |
|
60 |
|
|
61 |
/* (non-Javadoc) |
|
62 |
* @see org.gvsig.app.daltransform.DataTransformWizard#getJPanel() |
|
63 |
*/ |
|
64 |
public JPanel getJPanel() { |
|
65 |
return this; |
|
66 |
} |
|
67 |
|
|
68 |
/* (non-Javadoc) |
|
69 |
* @see org.gvsig.app.daltransform.DataTransformWizard#getPanelTitle() |
|
70 |
*/ |
|
71 |
public String getPanelTitle() { |
|
72 |
return PluginServices.getText(this, "transform_parameters"); |
|
73 |
} |
|
74 |
|
|
75 |
/* (non-Javadoc) |
|
76 |
* @see org.gvsig.app.daltransform.DataTransformWizard#isNextButtonEnabled() |
|
77 |
*/ |
|
78 |
public boolean isNextButtonEnabled() { |
|
79 |
return true; |
|
80 |
} |
|
81 |
|
|
82 |
/* (non-Javadoc) |
|
83 |
* @see org.gvsig.app.daltransform.DataTransformWizard#lastPanel() |
|
84 |
*/ |
|
85 |
public void lastPanel() { |
|
86 |
// TODO Auto-generated method stub |
|
87 |
|
|
88 |
} |
|
89 |
|
|
90 |
/* (non-Javadoc) |
|
91 |
* @see org.gvsig.app.daltransform.DataTransformWizard#nextPanel() |
|
92 |
*/ |
|
93 |
public void nextPanel() { |
|
94 |
// TODO Auto-generated method stub |
|
95 |
|
|
96 |
} |
|
97 |
|
|
98 |
/* (non-Javadoc) |
|
99 |
* @see org.gvsig.app.daltransform.DataTransformWizard#updatePanel() |
|
100 |
*/ |
|
101 |
public void updatePanel() { |
|
102 |
// TODO Auto-generated method stub |
|
103 |
|
|
104 |
} |
|
105 |
|
|
106 |
/** |
|
107 |
* @return the featureStore |
|
108 |
*/ |
|
109 |
public FeatureStore getFeatureStore() { |
|
110 |
if (dataTransformWizard != null){ |
|
111 |
return dataTransformWizard.getFeatureStore(); |
|
112 |
} |
|
113 |
return null; |
|
114 |
} |
|
115 |
|
|
116 |
/** |
|
117 |
* @return the dataTransformWizard |
|
118 |
*/ |
|
119 |
public DefaultDataTransformWizard getDataTransformWizard() { |
|
120 |
return dataTransformWizard; |
|
121 |
} |
|
122 |
|
|
123 |
} |
|
124 |
|
|
0 | 125 |
branches/v2_0_0_prep/extensions/extDalTransform/src/main/java/org/gvsig/daltransform/swing/impl/DefaultDataTransformWizard.java | ||
---|---|---|
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.daltransform.swing.impl; |
|
29 |
|
|
30 |
import java.util.List; |
|
31 |
|
|
32 |
import org.gvsig.andami.PluginServices; |
|
33 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
34 |
import org.gvsig.andami.ui.wizard.WizardAndami; |
|
35 |
import org.gvsig.daltransform.swing.DataTransformGui; |
|
36 |
import org.gvsig.daltransform.swing.DataTransformWizard; |
|
37 |
import org.gvsig.daltransform.swing.DataTransformWizardPanel; |
|
38 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
39 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
40 |
|
|
41 |
|
|
42 |
/** |
|
43 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
44 |
*/ |
|
45 |
public class DefaultDataTransformWizard extends WizardAndami implements DataTransformWizard{ |
|
46 |
private List<DataTransformWizardPanel> transformWizardPanels = null; |
|
47 |
//The three default panels |
|
48 |
private LoadLayerWizardPanel loadLayerWizardPanel = null; |
|
49 |
private SelectDataStoreWizardPanel selectDataStoreWizardPanel = null; |
|
50 |
private SelectTransformWizardPanel selectTransformWizardPanel = null; |
|
51 |
//If the wizard has to use a concrete transformation |
|
52 |
private DataTransformGui dataTransformGui = null; |
|
53 |
private int PANELS_TO_REFRESH = 2; |
|
54 |
|
|
55 |
/** |
|
56 |
* @param wizard |
|
57 |
*/ |
|
58 |
public DefaultDataTransformWizard() { |
|
59 |
super(PluginServices.getIconTheme().get("feature-transform")); |
|
60 |
loadLayerWizardPanel = new LoadLayerWizardPanel(); |
|
61 |
selectDataStoreWizardPanel = new SelectDataStoreWizardPanel(); |
|
62 |
selectTransformWizardPanel = new SelectTransformWizardPanel(); |
|
63 |
initialize(); |
|
64 |
setSize(selectTransformWizardPanel.getMaxHeight(), |
|
65 |
selectTransformWizardPanel.getMaxWidth()); |
|
66 |
} |
|
67 |
|
|
68 |
private void initialize() { |
|
69 |
getWizardComponents().getFinishButton().setEnabled(false); |
|
70 |
getWindowInfo().setTitle(PluginServices.getText(this, "transform_wizard")); |
|
71 |
addDataTransformWizardPanel(selectTransformWizardPanel); |
|
72 |
addDataTransformWizardPanel(selectDataStoreWizardPanel); |
|
73 |
getWizardComponents().setFinishAction(new DataTransformSelectionAction(this)); |
|
74 |
} |
|
75 |
|
|
76 |
/* |
|
77 |
* (non-Javadoc) |
|
78 |
* @see org.gvsig.app.daltransform.gui.DataTransformWizard#setApplicable(boolean) |
|
79 |
*/ |
|
80 |
public void setApplicable(boolean isEnabled) { |
|
81 |
getWizardComponents().getNextButton().setEnabled(isEnabled); |
|
82 |
} |
|
83 |
|
|
84 |
/* (non-Javadoc) |
|
85 |
* @see org.gvsig.app.daltransform.DataTransformWizard#getDataTransformGui() |
|
86 |
*/ |
|
87 |
public DataTransformGui getDataTransformGui() { |
|
88 |
if (dataTransformGui == null){ |
|
89 |
return selectTransformWizardPanel.getFeatureTransformGui(); |
|
90 |
}else{ |
|
91 |
return dataTransformGui; |
|
92 |
} |
|
93 |
} |
|
94 |
|
|
95 |
/* (non-Javadoc) |
|
96 |
* @see org.gvsig.app.daltransform.DataTransformWizard#setDataTransformGui(org.gvsig.app.daltransform.DataTransformGui) |
|
97 |
*/ |
|
98 |
public void updateGui() { |
|
99 |
//Remove all the panels |
|
100 |
for (int i=getWizardComponents().getWizardPanelList().size()-1 ; i>=PANELS_TO_REFRESH ; i--){ |
|
101 |
getWizardComponents().removeWizardPanel(i); |
|
102 |
} |
|
103 |
//Add new panels |
|
104 |
transformWizardPanels = getDataTransformGui().createPanels(); |
|
105 |
for (int i=0 ; i<transformWizardPanels.size() ; i++){ |
|
106 |
addDataTransformWizardPanel(transformWizardPanels.get(i)); |
|
107 |
} |
|
108 |
addDataTransformWizardPanel(loadLayerWizardPanel); |
|
109 |
} |
|
110 |
|
|
111 |
public void addDataTransformWizardPanel(DataTransformWizardPanel dataTransformWizardPanel){ |
|
112 |
dataTransformWizardPanel.setDataTransformWizard(this); |
|
113 |
getWizardComponents().addWizardPanel( |
|
114 |
new DataTransformWizardContainer(getWizardComponents(), dataTransformWizardPanel)); |
|
115 |
} |
|
116 |
|
|
117 |
/* (non-Javadoc) |
|
118 |
* @see org.gvsig.app.daltransform.DataTransformWizard#getFeatureStore() |
|
119 |
*/ |
|
120 |
public FeatureStore getFeatureStore() { |
|
121 |
return selectDataStoreWizardPanel.getFeatureStore(); |
|
122 |
} |
|
123 |
|
|
124 |
/* (non-Javadoc) |
|
125 |
* @see org.gvsig.app.daltransform.DataTransformWizard#isFeatureStoreLayer() |
|
126 |
*/ |
|
127 |
public boolean isFeatureStoreLayer() { |
|
128 |
return selectDataStoreWizardPanel.isFeatureStoreLayer(); |
|
129 |
} |
|
130 |
|
|
131 |
public boolean isLayerLoaded(){ |
|
132 |
return loadLayerWizardPanel.isLayerLoaded(); |
|
133 |
} |
|
134 |
|
|
135 |
public MapContext getMapContext(){ |
|
136 |
return loadLayerWizardPanel.getMapContext(); |
|
137 |
} |
|
138 |
|
|
139 |
/* (non-Javadoc) |
|
140 |
* @see org.gvsig.app.daltransform.gui.DataTransformWizard#getWindow() |
|
141 |
*/ |
|
142 |
public IWindow getWindow() { |
|
143 |
return this; |
|
144 |
} |
|
145 |
|
|
146 |
/* (non-Javadoc) |
|
147 |
* @see org.gvsig.app.daltransform.gui.DataTransformWizard#setDataTransformGui(org.gvsig.app.daltransform.gui.DataTransformGui) |
|
148 |
*/ |
|
149 |
public void setDataTransformGui(DataTransformGui dataTransformGui) { |
|
150 |
this.dataTransformGui = dataTransformGui; |
|
151 |
PANELS_TO_REFRESH = 1; |
|
152 |
getWizardComponents().removeWizardPanel(0); |
|
153 |
} |
|
154 |
} |
|
155 |
|
|
0 | 156 |
branches/v2_0_0_prep/extensions/extDalTransform/src/main/java/org/gvsig/daltransform/swing/impl/SelectTransformWizardPanel.java | ||
---|---|---|
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.daltransform.swing.impl; |
|
29 |
|
|
30 |
import java.awt.Dimension; |
|
31 |
import java.util.ArrayList; |
|
32 |
|
|
33 |
import javax.swing.DefaultListModel; |
|
34 |
import javax.swing.JList; |
|
35 |
import javax.swing.JScrollPane; |
|
36 |
import javax.swing.JTextArea; |
|
37 |
import javax.swing.event.ListSelectionEvent; |
|
38 |
import javax.swing.event.ListSelectionListener; |
|
39 |
|
|
40 |
import org.gvsig.andami.PluginServices; |
|
41 |
import org.gvsig.daltransform.DataTransformLocator; |
|
42 |
import org.gvsig.daltransform.DataTransformManager; |
|
43 |
import org.gvsig.daltransform.swing.DataTransformGui; |
|
44 |
|
|
45 |
|
|
46 |
/** |
|
47 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
48 |
*/ |
|
49 |
public class SelectTransformWizardPanel extends AbstractDataTransformWizardPanel implements ListSelectionListener{ |
|
50 |
private JList transformList; |
|
51 |
private JScrollPane transformScrollPane; |
|
52 |
private JScrollPane descriptionScrollPane; |
|
53 |
private JTextArea descriptionText; |
|
54 |
private int maxWidth = 315; |
|
55 |
private int maxHeight = 600; |
|
56 |
|
|
57 |
/** |
|
58 |
* @param wizardComponents |
|
59 |
*/ |
|
60 |
public SelectTransformWizardPanel() { |
|
61 |
super(); |
|
62 |
initComponents(); |
|
63 |
addTransforms(); |
|
64 |
transformList.addListSelectionListener(this); |
|
65 |
} |
|
66 |
|
|
67 |
private void initComponents() { |
|
68 |
java.awt.GridBagConstraints gridBagConstraints; |
|
69 |
|
|
70 |
transformScrollPane = new javax.swing.JScrollPane(); |
|
71 |
transformList = new javax.swing.JList(); |
|
72 |
descriptionScrollPane = new javax.swing.JScrollPane(); |
|
73 |
descriptionText = new javax.swing.JTextArea(); |
|
74 |
|
|
75 |
setLayout(new java.awt.GridBagLayout()); |
|
76 |
|
|
77 |
transformScrollPane.setViewportView(transformList); |
|
78 |
|
|
79 |
transformList.setModel(new DefaultListModel()); |
|
80 |
|
|
81 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
82 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
|
83 |
gridBagConstraints.weightx = 1.0; |
|
84 |
gridBagConstraints.weighty = 1.0; |
|
85 |
gridBagConstraints.insets = new java.awt.Insets(2, 2, 5, 2); |
|
86 |
add(transformScrollPane, gridBagConstraints); |
|
87 |
|
|
88 |
descriptionText.setColumns(20); |
|
89 |
descriptionText.setEditable(false); |
|
90 |
descriptionText.setRows(5); |
|
91 |
descriptionText.setLineWrap(true); |
|
92 |
descriptionText.setBorder(null); |
|
93 |
descriptionScrollPane.setBorder(null); |
|
94 |
descriptionScrollPane.setViewportView(descriptionText); |
|
95 |
|
|
96 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
97 |
gridBagConstraints.gridx = 0; |
|
98 |
gridBagConstraints.gridy = 1; |
|
99 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
100 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH; |
|
101 |
gridBagConstraints.weightx = 1.0; |
|
102 |
gridBagConstraints.insets = new java.awt.Insets(5, 2, 2, 2); |
|
103 |
add(descriptionScrollPane, gridBagConstraints); |
|
104 |
} |
|
105 |
|
|
106 |
/** |
|
107 |
* Adding the objects |
|
108 |
*/ |
|
109 |
protected void addTransforms(){ |
|
110 |
DataTransformManager featureTransformManager = |
|
111 |
DataTransformLocator.getDataTransformManager(); |
|
112 |
ArrayList<DataTransformGui> dataTransformGui = |
|
113 |
featureTransformManager.getDataTransforms(); |
|
114 |
for (int i=0 ; i<dataTransformGui.size() ; i++){ |
|
115 |
((DefaultListModel)transformList.getModel()).addElement(new FeatureTransformGuiWrapper(dataTransformGui.get(i))); |
|
116 |
Dimension dimension = dataTransformGui.get(i).getMinDimension(); |
|
117 |
if (dimension != null){ |
|
118 |
if (dimension.getHeight() > maxHeight){ |
|
119 |
maxHeight = (int)dimension.getHeight(); |
|
120 |
} |
|
121 |
if (dimension.getWidth() > maxWidth){ |
|
122 |
maxWidth = (int)dimension.getWidth(); |
|
123 |
} |
|
124 |
} |
|
125 |
} |
|
126 |
updatePanel(); |
|
127 |
} |
|
128 |
|
|
129 |
/* |
|
130 |
* (non-Javadoc) |
|
131 |
* @see org.gvsig.app.daltransform.impl.AbstractDataTransformWizardPanel#updatePanel() |
|
132 |
*/ |
|
133 |
@Override |
|
134 |
public void updatePanel() { |
|
135 |
if (transformList.getSelectedIndex() == -1){ |
|
136 |
if (transformList.getModel().getSize() > 0){ |
|
137 |
transformList.setSelectedIndex(0); |
|
138 |
valueChanged(null); |
|
139 |
} |
|
140 |
}else{ |
|
141 |
if (transformList.getModel().getSize() == 0){ |
|
142 |
getDataTransformWizard().setApplicable(false); |
|
143 |
} |
|
144 |
} |
|
145 |
} |
|
146 |
|
|
147 |
/* (non-Javadoc) |
|
148 |
* @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent) |
|
149 |
*/ |
|
150 |
public void valueChanged(ListSelectionEvent e) { |
|
151 |
Object obj = transformList.getSelectedValue(); |
|
152 |
if (obj != null){ |
|
153 |
descriptionText.setText(((FeatureTransformGuiWrapper)obj).getFeatureTransformGui().getDescription()); |
|
154 |
} |
|
155 |
} |
|
156 |
|
|
157 |
public DataTransformGui getFeatureTransformGui(){ |
|
158 |
Object obj = transformList.getSelectedValue(); |
|
159 |
if (obj != null){ |
|
160 |
return ((FeatureTransformGuiWrapper)obj).getFeatureTransformGui(); |
|
161 |
} |
|
162 |
return null; |
|
163 |
} |
|
164 |
|
|
165 |
/* (non-Javadoc) |
|
166 |
* @see org.gvsig.app.daltransform.gui.FeatureTransformWizard#getPanelTitle() |
|
167 |
*/ |
|
168 |
public String getPanelTitle() { |
|
169 |
return PluginServices.getText(this, "transform_selection"); |
|
170 |
} |
|
171 |
|
|
172 |
/** |
|
173 |
* @return the maxWidth |
|
174 |
*/ |
|
175 |
public int getMaxWidth() { |
|
176 |
return maxWidth; |
|
177 |
} |
|
178 |
|
|
179 |
/** |
|
180 |
* @return the maxHeight |
|
181 |
*/ |
|
182 |
public int getMaxHeight() { |
|
183 |
return maxHeight; |
|
184 |
} |
|
185 |
|
|
186 |
private class FeatureTransformGuiWrapper{ |
|
187 |
private DataTransformGui featureTransformGui = null; |
|
188 |
|
|
189 |
/** |
|
190 |
* @param featureTransformGui |
|
191 |
*/ |
|
192 |
public FeatureTransformGuiWrapper( |
|
193 |
DataTransformGui featureTransformGui) { |
|
194 |
super(); |
|
195 |
this.featureTransformGui = featureTransformGui; |
|
196 |
} |
|
197 |
|
|
198 |
/** |
|
199 |
* @return the featureTransformGui |
|
200 |
*/ |
|
201 |
public DataTransformGui getFeatureTransformGui() { |
|
202 |
return featureTransformGui; |
|
203 |
} |
|
204 |
|
|
205 |
/* (non-Javadoc) |
|
206 |
* @see java.lang.Object#toString() |
|
207 |
*/ |
|
208 |
public String toString() { |
|
209 |
return featureTransformGui.getName(); |
|
210 |
} |
|
211 |
} |
|
212 |
} |
|
213 |
|
|
0 | 214 |
Also available in: Unified diff