Revision 44934 trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.daltransform.app/org.gvsig.daltransform.app.eventtheme/src/main/java/org/gvsig/app/eventtheme/daltransform/EventThemeTransformPanel.java
EventThemeTransformPanel.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* gvSIG. Desktop Geographic Information System. |
3 | 3 |
* |
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
|
4 |
* Copyright (C) 2007-2022 gvSIG Association.
|
|
5 | 5 |
* |
6 | 6 |
* This program is free software; you can redistribute it and/or |
7 | 7 |
* modify it under the terms of the GNU General Public License |
... | ... | |
21 | 21 |
* For any additional information, do not hesitate to contact us |
22 | 22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
23 | 23 |
*/ |
24 |
/* |
|
25 |
* AUTHORS (In addition to CIT): |
|
26 |
* 2009 {Iver T.I.} {Task} |
|
27 |
*/ |
|
28 |
|
|
29 | 24 |
package org.gvsig.app.eventtheme.daltransform; |
30 | 25 |
|
31 | 26 |
import java.awt.BorderLayout; |
... | ... | |
50 | 45 |
import org.gvsig.daltransform.swing.impl.components.FeatureTypeCombo; |
51 | 46 |
import org.gvsig.daltransform.swing.impl.components.NumericFeatureTypeAttributesCombo; |
52 | 47 |
import org.gvsig.fmap.crs.CRSFactory; |
53 |
import org.gvsig.fmap.dal.exception.DataException; |
|
54 | 48 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
55 | 49 |
import org.gvsig.fmap.dal.feature.FeatureType; |
56 | 50 |
import org.gvsig.fmap.mapcontext.MapContext; |
... | ... | |
58 | 52 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
59 | 53 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
60 | 54 |
|
61 |
|
|
62 | 55 |
/** |
63 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
|
|
56 |
* @author gvSIG Team
|
|
64 | 57 |
*/ |
65 | 58 |
public class EventThemeTransformPanel extends AbstractDataTransformWizardPanel implements ActionListener { |
66 |
private JLabel nameLabel; |
|
67 |
private JTextField nameText; |
|
68 |
private NumericFeatureTypeAttributesCombo xCombo; |
|
69 |
private JLabel xLabel; |
|
70 |
private NumericFeatureTypeAttributesCombo yCombo; |
|
71 |
private JLabel yLabel; |
|
72 |
private FeatureTypeCombo featureTypeCombo; |
|
73 |
private JLabel featureTypeLabel; |
|
74 |
private JPanel northPanel = null; |
|
75 |
private JTextField projectionText; |
|
76 |
private JLabel projectionLabel; |
|
77 |
private JButton projectionButton = null; |
|
78 | 59 |
|
79 |
public EventThemeTransformPanel() { |
|
80 |
super(); |
|
81 |
initComponents(); |
|
82 |
initLabels(); |
|
83 |
resetProjection(); |
|
84 |
featureTypeCombo.addActionListener(this); |
|
85 |
projectionButton.addActionListener(this); |
|
86 |
} |
|
60 |
private JLabel nameLabel; |
|
61 |
private JTextField nameText; |
|
62 |
private NumericFeatureTypeAttributesCombo xCombo; |
|
63 |
private JLabel xLabel; |
|
64 |
private NumericFeatureTypeAttributesCombo yCombo; |
|
65 |
private JLabel yLabel; |
|
66 |
private FeatureTypeCombo featureTypeCombo; |
|
67 |
private JLabel featureTypeLabel; |
|
68 |
private JPanel northPanel = null; |
|
69 |
private JTextField projectionText; |
|
70 |
private JLabel projectionLabel; |
|
71 |
private JButton projectionButton = null; |
|
87 | 72 |
|
88 |
private void resetProjection() { |
|
89 |
|
|
90 |
DefaultDataTransformWizard dtw = getDataTransformWizard(); |
|
91 |
if (dtw != null) { |
|
92 |
MapContext mco = dtw.getMapContext(); |
|
93 |
if (mco != null && mco.getProjection() != null) { |
|
94 |
projectionText.setText(mco.getProjection().getAbrev()); |
|
95 |
return; |
|
96 |
} |
|
97 |
} |
|
98 |
|
|
73 |
public EventThemeTransformPanel() { |
|
74 |
super(); |
|
75 |
initComponents(); |
|
76 |
initLabels(); |
|
77 |
resetProjection(); |
|
78 |
featureTypeCombo.addActionListener(this); |
|
79 |
projectionButton.addActionListener(this); |
|
80 |
} |
|
81 |
|
|
82 |
private void resetProjection() { |
|
83 |
|
|
84 |
DefaultDataTransformWizard dtw = getDataTransformWizard(); |
|
85 |
if (dtw != null) { |
|
86 |
MapContext mco = dtw.getMapContext(); |
|
87 |
if (mco != null && mco.getProjection() != null) { |
|
88 |
projectionText.setText(mco.getProjection().getAbrev()); |
|
89 |
return; |
|
90 |
} |
|
91 |
} |
|
92 |
|
|
99 | 93 |
ProjectPreferences prefs = new ProjectPreferences(); |
100 | 94 |
projectionText.setText(prefs.getDefaultProjection().getAbrev()); |
101 |
}
|
|
95 |
}
|
|
102 | 96 |
|
103 |
|
|
104 |
public void setDataTransformWizard(DataTransformWizard dtw) {
|
|
105 |
super.setDataTransformWizard(dtw);
|
|
106 |
resetProjection();
|
|
107 |
}
|
|
97 |
@Override |
|
98 |
public void setDataTransformWizard(DataTransformWizard dtw) {
|
|
99 |
super.setDataTransformWizard(dtw);
|
|
100 |
resetProjection();
|
|
101 |
}
|
|
108 | 102 |
|
109 |
private void initLabels() {
|
|
110 |
featureTypeLabel.setText(PluginServices.getText(this, "events_feature_type_field") + ":");
|
|
111 |
xLabel.setText(PluginServices.getText(this, "events_x_field") + ":");
|
|
112 |
yLabel.setText(PluginServices.getText(this, "events_y_field") + ":");
|
|
113 |
nameLabel.setText(PluginServices.getText(this, "events_geom_field") + ":");
|
|
114 |
projectionLabel.setText(PluginServices.getText(this, "projection") + ":");
|
|
115 |
projectionButton.setText("...");
|
|
116 |
}
|
|
103 |
private void initLabels() {
|
|
104 |
featureTypeLabel.setText(PluginServices.getText(this, "events_feature_type_field") + ":");
|
|
105 |
xLabel.setText(PluginServices.getText(this, "events_x_field") + ":");
|
|
106 |
yLabel.setText(PluginServices.getText(this, "events_y_field") + ":");
|
|
107 |
nameLabel.setText(PluginServices.getText(this, "events_geom_field") + ":");
|
|
108 |
projectionLabel.setText(PluginServices.getText(this, "projection") + ":");
|
|
109 |
projectionButton.setText("...");
|
|
110 |
}
|
|
117 | 111 |
|
118 |
private void initComponents() {
|
|
119 |
java.awt.GridBagConstraints gridBagConstraints;
|
|
112 |
private void initComponents() {
|
|
113 |
java.awt.GridBagConstraints gridBagConstraints;
|
|
120 | 114 |
|
121 |
featureTypeCombo = new FeatureTypeCombo();
|
|
122 |
featureTypeLabel = new javax.swing.JLabel();
|
|
123 |
xLabel = new javax.swing.JLabel();
|
|
124 |
xCombo = new NumericFeatureTypeAttributesCombo();
|
|
125 |
yLabel = new javax.swing.JLabel();
|
|
126 |
yCombo = new NumericFeatureTypeAttributesCombo();
|
|
127 |
nameLabel = new javax.swing.JLabel();
|
|
128 |
nameText = new javax.swing.JTextField();
|
|
129 |
northPanel= new JPanel();
|
|
130 |
projectionText = new JTextField();
|
|
131 |
projectionLabel = new JLabel();
|
|
132 |
projectionButton = new JButton();
|
|
133 |
projectionButton.setSize(25, 25);
|
|
134 |
projectionText.setEnabled(false);
|
|
115 |
featureTypeCombo = new FeatureTypeCombo();
|
|
116 |
featureTypeLabel = new javax.swing.JLabel();
|
|
117 |
xLabel = new javax.swing.JLabel();
|
|
118 |
xCombo = new NumericFeatureTypeAttributesCombo();
|
|
119 |
yLabel = new javax.swing.JLabel();
|
|
120 |
yCombo = new NumericFeatureTypeAttributesCombo();
|
|
121 |
nameLabel = new javax.swing.JLabel();
|
|
122 |
nameText = new javax.swing.JTextField();
|
|
123 |
northPanel = new JPanel();
|
|
124 |
projectionText = new JTextField();
|
|
125 |
projectionLabel = new JLabel();
|
|
126 |
projectionButton = new JButton();
|
|
127 |
projectionButton.setSize(25, 25);
|
|
128 |
projectionText.setEnabled(false);
|
|
135 | 129 |
|
136 |
setLayout(new BorderLayout());
|
|
137 |
northPanel.setLayout(new java.awt.GridBagLayout());
|
|
130 |
setLayout(new BorderLayout());
|
|
131 |
northPanel.setLayout(new java.awt.GridBagLayout());
|
|
138 | 132 |
|
139 |
// gridBagConstraints = new java.awt.GridBagConstraints(); |
|
140 |
// gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
|
141 |
// gridBagConstraints.insets = new Insets(5,2,2,2); |
|
142 |
// northPanel.add(featureTypeLabel, gridBagConstraints); |
|
143 |
// |
|
144 |
// featureTypeCombo.setModel(new javax.swing.DefaultComboBoxModel()); |
|
145 |
// gridBagConstraints = new java.awt.GridBagConstraints(); |
|
146 |
// gridBagConstraints.gridx = 0; |
|
147 |
// gridBagConstraints.gridy = 1; |
|
148 |
// gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
149 |
// gridBagConstraints.weightx = 1.0; |
|
150 |
// gridBagConstraints.insets = new Insets(2,2,5,2); |
|
151 |
// northPanel.add(featureTypeCombo, gridBagConstraints); |
|
133 |
// gridBagConstraints = new java.awt.GridBagConstraints(); |
|
134 |
// gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
|
135 |
// gridBagConstraints.insets = new Insets(5,2,2,2); |
|
136 |
// northPanel.add(featureTypeLabel, gridBagConstraints); |
|
137 |
// |
|
138 |
// featureTypeCombo.setModel(new javax.swing.DefaultComboBoxModel()); |
|
139 |
// gridBagConstraints = new java.awt.GridBagConstraints(); |
|
140 |
// gridBagConstraints.gridx = 0; |
|
141 |
// gridBagConstraints.gridy = 1; |
|
142 |
// gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
143 |
// gridBagConstraints.weightx = 1.0; |
|
144 |
// gridBagConstraints.insets = new Insets(2,2,5,2); |
|
145 |
// northPanel.add(featureTypeCombo, gridBagConstraints); |
|
146 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
147 |
gridBagConstraints.gridx = 0; |
|
148 |
gridBagConstraints.gridy = 0; |
|
149 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
|
150 |
gridBagConstraints.gridwidth = 2; |
|
151 |
gridBagConstraints.insets = new Insets(5, 2, 2, 2); |
|
152 |
northPanel.add(xLabel, gridBagConstraints); |
|
152 | 153 |
|
153 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
154 |
gridBagConstraints.gridx = 0; |
|
155 |
gridBagConstraints.gridy = 0; |
|
156 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
|
157 |
gridBagConstraints.gridwidth = 2; |
|
158 |
gridBagConstraints.insets = new Insets(5,2,2,2); |
|
159 |
northPanel.add(xLabel, gridBagConstraints); |
|
154 |
xCombo.setModel(new javax.swing.DefaultComboBoxModel()); |
|
155 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
156 |
gridBagConstraints.gridx = 0; |
|
157 |
gridBagConstraints.gridy = 1; |
|
158 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
159 |
gridBagConstraints.gridwidth = 2; |
|
160 |
gridBagConstraints.insets = new Insets(2, 2, 5, 2); |
|
161 |
gridBagConstraints.weightx = 1.0; |
|
162 |
northPanel.add(xCombo, gridBagConstraints); |
|
160 | 163 |
|
161 |
xCombo.setModel(new javax.swing.DefaultComboBoxModel()); |
|
162 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
163 |
gridBagConstraints.gridx = 0; |
|
164 |
gridBagConstraints.gridy = 1; |
|
165 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
166 |
gridBagConstraints.gridwidth = 2; |
|
167 |
gridBagConstraints.insets = new Insets(2,2,5,2); |
|
168 |
gridBagConstraints.weightx = 1.0; |
|
169 |
northPanel.add(xCombo, gridBagConstraints); |
|
164 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
165 |
gridBagConstraints.gridx = 0; |
|
166 |
gridBagConstraints.gridy = 2; |
|
167 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
|
168 |
gridBagConstraints.insets = new Insets(5, 2, 2, 2); |
|
169 |
gridBagConstraints.gridwidth = 2; |
|
170 |
northPanel.add(yLabel, gridBagConstraints); |
|
170 | 171 |
|
171 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
172 |
gridBagConstraints.gridx = 0; |
|
173 |
gridBagConstraints.gridy = 2; |
|
174 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
|
175 |
gridBagConstraints.insets = new Insets(5,2,2,2); |
|
176 |
gridBagConstraints.gridwidth = 2; |
|
177 |
northPanel.add(yLabel, gridBagConstraints); |
|
172 |
yCombo.setModel(new javax.swing.DefaultComboBoxModel()); |
|
173 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
174 |
gridBagConstraints.gridx = 0; |
|
175 |
gridBagConstraints.gridy = 3; |
|
176 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
177 |
gridBagConstraints.weightx = 1.0; |
|
178 |
gridBagConstraints.insets = new Insets(2, 2, 5, 2); |
|
179 |
gridBagConstraints.gridwidth = 2; |
|
180 |
northPanel.add(yCombo, gridBagConstraints); |
|
178 | 181 |
|
179 |
yCombo.setModel(new javax.swing.DefaultComboBoxModel()); |
|
180 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
181 |
gridBagConstraints.gridx = 0; |
|
182 |
gridBagConstraints.gridy = 3; |
|
183 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
184 |
gridBagConstraints.weightx = 1.0; |
|
185 |
gridBagConstraints.insets = new Insets(2,2,5,2); |
|
186 |
gridBagConstraints.gridwidth = 2; |
|
187 |
northPanel.add(yCombo, gridBagConstraints); |
|
182 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
183 |
gridBagConstraints.gridx = 0; |
|
184 |
gridBagConstraints.gridy = 4; |
|
185 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
|
186 |
gridBagConstraints.insets = new Insets(5, 2, 2, 2); |
|
187 |
gridBagConstraints.gridwidth = 2; |
|
188 |
northPanel.add(nameLabel, gridBagConstraints); |
|
188 | 189 |
|
189 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
190 |
gridBagConstraints.gridx = 0; |
|
191 |
gridBagConstraints.gridy = 4; |
|
192 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
|
193 |
gridBagConstraints.insets = new Insets(5,2,2,2); |
|
194 |
gridBagConstraints.gridwidth = 2; |
|
195 |
northPanel.add(nameLabel, gridBagConstraints); |
|
190 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
191 |
gridBagConstraints.gridx = 0; |
|
192 |
gridBagConstraints.gridy = 5; |
|
193 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
194 |
gridBagConstraints.weightx = 1.0; |
|
195 |
gridBagConstraints.insets = new Insets(2, 2, 5, 2); |
|
196 |
gridBagConstraints.gridwidth = 2; |
|
197 |
northPanel.add(nameText, gridBagConstraints); |
|
196 | 198 |
|
197 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
198 |
gridBagConstraints.gridx = 0; |
|
199 |
gridBagConstraints.gridy = 5; |
|
200 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
201 |
gridBagConstraints.weightx = 1.0; |
|
202 |
gridBagConstraints.insets = new Insets(2,2,5,2); |
|
203 |
gridBagConstraints.gridwidth = 2; |
|
204 |
northPanel.add(nameText, gridBagConstraints); |
|
199 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
200 |
gridBagConstraints.gridx = 0; |
|
201 |
gridBagConstraints.gridy = 6; |
|
202 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
|
203 |
gridBagConstraints.gridwidth = 2; |
|
204 |
gridBagConstraints.insets = new Insets(5, 2, 2, 2); |
|
205 |
northPanel.add(projectionLabel, gridBagConstraints); |
|
205 | 206 |
|
206 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
207 |
gridBagConstraints.gridx = 0; |
|
208 |
gridBagConstraints.gridy = 6; |
|
209 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
|
210 |
gridBagConstraints.gridwidth = 2; |
|
211 |
gridBagConstraints.insets = new Insets(5,2,2,2); |
|
212 |
northPanel.add(projectionLabel, gridBagConstraints); |
|
207 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
208 |
gridBagConstraints.gridx = 0; |
|
209 |
gridBagConstraints.gridy = 7; |
|
210 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
211 |
gridBagConstraints.weightx = 1.0; |
|
212 |
gridBagConstraints.gridwidth = 1; |
|
213 |
gridBagConstraints.insets = new Insets(2, 2, 5, 2); |
|
214 |
northPanel.add(projectionText, gridBagConstraints); |
|
213 | 215 |
|
214 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
215 |
gridBagConstraints.gridx = 0; |
|
216 |
gridBagConstraints.gridy = 7; |
|
217 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
218 |
gridBagConstraints.weightx = 1.0; |
|
219 |
gridBagConstraints.gridwidth = 1; |
|
220 |
gridBagConstraints.insets = new Insets(2,2,5,2); |
|
221 |
northPanel.add(projectionText, gridBagConstraints); |
|
216 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
217 |
gridBagConstraints.gridx = 1; |
|
218 |
gridBagConstraints.gridy = 7; |
|
219 |
gridBagConstraints.gridwidth = 1; |
|
220 |
gridBagConstraints.insets = new Insets(2, 2, 5, 2); |
|
221 |
northPanel.add(projectionButton, gridBagConstraints); |
|
222 | 222 |
|
223 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
224 |
gridBagConstraints.gridx = 1; |
|
225 |
gridBagConstraints.gridy = 7; |
|
226 |
gridBagConstraints.gridwidth = 1; |
|
227 |
gridBagConstraints.insets = new Insets(2,2,5,2); |
|
228 |
northPanel.add(projectionButton, gridBagConstraints); |
|
223 |
add(northPanel, BorderLayout.NORTH); |
|
224 |
} |
|
229 | 225 |
|
230 |
add(northPanel, BorderLayout.NORTH); |
|
231 |
} |
|
226 |
@Override |
|
227 |
public void actionPerformed(ActionEvent event) { |
|
228 |
if (event == null) { |
|
229 |
return; |
|
230 |
} |
|
231 |
if (event.getSource() == featureTypeCombo) { |
|
232 |
Object obj = featureTypeCombo.getSelectedItem(); |
|
233 |
if (obj != null) { |
|
234 |
xCombo.addFeatureAttributes(featureTypeCombo.getSelectedFeatureType()); |
|
235 |
yCombo.addFeatureAttributes(featureTypeCombo.getSelectedFeatureType()); |
|
236 |
} |
|
237 |
} else if (event.getSource() == projectionButton) { |
|
238 |
ISelectCrsPanel panel = CRSSelectPanel.getUIFactory().getSelectCrsPanel( |
|
239 |
CRSFactory.getCRS(projectionText.getText()), false); |
|
240 |
ToolsSwingLocator.getWindowManager().showWindow( |
|
241 |
panel.asJComponent(), |
|
242 |
ToolsLocator.getI18nManager().getTranslation("selecciona_sistema_de_referencia"), |
|
243 |
WindowManager.MODE.DIALOG |
|
244 |
); |
|
245 |
if (panel.isOkPressed()) { |
|
246 |
IProjection proj = panel.getProjection(); |
|
247 |
projectionText.setText(proj.getAbrev()); |
|
248 |
} |
|
249 |
} |
|
250 |
} |
|
232 | 251 |
|
233 |
/* (non-Javadoc) |
|
234 |
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) |
|
235 |
*/ |
|
236 |
public void actionPerformed(ActionEvent event) { |
|
237 |
if (event == null){ |
|
238 |
return; |
|
239 |
} |
|
240 |
if (event.getSource() == featureTypeCombo){ |
|
241 |
Object obj = featureTypeCombo.getSelectedItem(); |
|
242 |
if (obj != null){ |
|
243 |
xCombo.addFeatureAttributes(featureTypeCombo.getSelectedFeatureType()); |
|
244 |
yCombo.addFeatureAttributes(featureTypeCombo.getSelectedFeatureType()); |
|
245 |
} |
|
246 |
}else if (event.getSource() == projectionButton){ |
|
247 |
ISelectCrsPanel panel = CRSSelectPanel.getUIFactory().getSelectCrsPanel( |
|
248 |
CRSFactory.getCRS(projectionText.getText()), false); |
|
249 |
ToolsSwingLocator.getWindowManager().showWindow( |
|
250 |
panel.asJComponent(), |
|
251 |
ToolsLocator.getI18nManager().getTranslation("selecciona_sistema_de_referencia"), |
|
252 |
WindowManager.MODE.DIALOG |
|
253 |
); |
|
254 |
if (panel.isOkPressed()) { |
|
255 |
IProjection proj = panel.getProjection(); |
|
256 |
projectionText.setText(proj.getAbrev()); |
|
257 |
} |
|
258 |
} |
|
259 |
} |
|
252 |
public String getGeometryName() { |
|
253 |
return nameText.getText(); |
|
254 |
} |
|
260 | 255 |
|
261 |
public String getGeometryName(){
|
|
262 |
return nameText.getText();
|
|
263 |
}
|
|
256 |
public String getXName() {
|
|
257 |
return xCombo.getSelectedFeatureAttributeDescriptor().getName();
|
|
258 |
}
|
|
264 | 259 |
|
265 |
public String getXName(){
|
|
266 |
return xCombo.getSelectedFeatureAttributeDescriptor().getName();
|
|
267 |
}
|
|
260 |
public String getYName() {
|
|
261 |
return yCombo.getSelectedFeatureAttributeDescriptor().getName();
|
|
262 |
}
|
|
268 | 263 |
|
269 |
public String getYName(){ |
|
270 |
return yCombo.getSelectedFeatureAttributeDescriptor().getName(); |
|
271 |
} |
|
264 |
@Override |
|
265 |
public void updatePanel() { |
|
266 |
featureTypeCombo.addFeatureStore(getFeatureStore()); |
|
267 |
if (nameText != null) { |
|
268 |
nameText.setText(this.suggestedGeomFieldName(getFeatureStore())); |
|
269 |
} |
|
270 |
} |
|
272 | 271 |
|
273 |
/* |
|
274 |
* (non-Javadoc) |
|
275 |
* @see org.gvsig.app.daltransform.impl.AbstractDataTransformWizardPanel#updatePanel() |
|
276 |
*/ |
|
277 |
public void updatePanel() { |
|
278 |
featureTypeCombo.addFeatureStore(getFeatureStore()); |
|
279 |
if (nameText != null) { |
|
280 |
nameText.setText(this.suggestedGeomFieldName(getFeatureStore())); |
|
281 |
} |
|
282 |
// actionPerformed(null); |
|
283 |
} |
|
272 |
public IProjection getProjection() { |
|
273 |
return CRSFactory.getCRS(projectionText.getText()); |
|
274 |
} |
|
284 | 275 |
|
285 |
public IProjection getProjection() { |
|
286 |
return CRSFactory.getCRS(projectionText.getText()); |
|
287 |
} |
|
288 |
|
|
289 |
private String suggestedGeomFieldName(FeatureStore fsto) { |
|
290 |
|
|
291 |
if (fsto == null) { |
|
292 |
return ""; |
|
293 |
} |
|
294 |
|
|
295 |
FeatureType ft = null; |
|
296 |
try { |
|
297 |
ft = fsto.getDefaultFeatureType(); |
|
298 |
} catch (DataException e) { |
|
299 |
logger.info("Error: unable to suggest geom field name.", e); |
|
276 |
private String suggestedGeomFieldName(FeatureStore fsto) { |
|
277 |
|
|
278 |
if (fsto == null) { |
|
300 | 279 |
return ""; |
301 | 280 |
} |
302 |
|
|
303 |
if (ft.getAttributeDescriptor("geometry") == null) { |
|
304 |
return "geometry"; |
|
305 |
} |
|
306 |
if (ft.getAttributeDescriptor("geom") == null) { |
|
307 |
return "geom"; |
|
308 |
} |
|
309 |
String aux = ""; |
|
310 |
int i = -1; |
|
311 |
do { |
|
312 |
i++; |
|
313 |
aux = "geom" + i; |
|
314 |
} while (ft.getAttributeDescriptor(aux) != null); |
|
315 |
|
|
316 |
return aux; |
|
317 |
} |
|
318 |
} |
|
281 |
|
|
282 |
FeatureType ft = fsto.getDefaultFeatureTypeQuietly(); |
|
283 |
if (ft == null) { |
|
284 |
logger.info("Unable to suggest geom field name, can't access to the feature type."); |
|
285 |
return ""; |
|
286 |
} |
|
287 |
|
|
288 |
if (ft.getAttributeDescriptor("geometry") == null) { |
|
289 |
return "geometry"; |
|
290 |
} |
|
291 |
if (ft.getAttributeDescriptor("geom") == null) { |
|
292 |
return "geom"; |
|
293 |
} |
|
294 |
String aux = ""; |
|
295 |
int i = -1; |
|
296 |
do { |
|
297 |
i++; |
|
298 |
aux = "geom" + i; |
|
299 |
} while (ft.getAttributeDescriptor(aux) != null); |
|
300 |
|
|
301 |
return aux; |
|
302 |
} |
|
303 |
} |
Also available in: Unified diff