Revision 5113
trunk/extensions/extAddEventTheme/src/com/iver/gvsig/addeventtheme/gui/AddEventThemePanel.java | ||
---|---|---|
58 | 58 |
import com.iver.cit.gvsig.fmap.FMap; |
59 | 59 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
60 | 60 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
61 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.AlphanumericData; |
|
61 | 62 |
import com.iver.cit.gvsig.project.ProjectTable; |
62 | 63 |
import com.iver.gvsig.addeventtheme.AddEventThemeDriver; |
63 | 64 |
|
... | ... | |
74 | 75 |
* user can input the name of the gvSIG Table from that the |
75 | 76 |
* plugin will create the new point Layer, and the fields |
76 | 77 |
* corresponding with the point coordinates. |
77 |
*
|
|
78 |
* |
|
78 | 79 |
* @author jmorell |
79 | 80 |
*/ |
80 | 81 |
public class AddEventThemePanel extends JPanel implements View { |
... | ... | |
120 | 121 |
|
121 | 122 |
/** |
122 | 123 |
* This method initializes this |
123 |
*
|
|
124 |
* |
|
124 | 125 |
* @return void |
125 | 126 |
*/ |
126 | 127 |
private void initialize() { |
... | ... | |
172 | 173 |
} |
173 | 174 |
return fieldNames; |
174 | 175 |
} |
175 |
|
|
176 |
|
|
176 | 177 |
private ProjectTable getProjectTable(String tableName) { |
177 | 178 |
ProjectTable projectTable = null; |
178 | 179 |
for (int i=0;i<tableList.size();i++) { |
... | ... | |
183 | 184 |
} |
184 | 185 |
return projectTable; |
185 | 186 |
} |
186 |
|
|
187 |
|
|
187 | 188 |
private void createNewLayerFromDataSource() { |
188 | 189 |
String tableName = (String)tableComboBox.getSelectedItem(); |
189 | 190 |
ProjectTable projectTable = getProjectTable(tableName); |
... | ... | |
191 | 192 |
DataSource ds = projectTable.getModelo().getRecordset(); |
192 | 193 |
int xFieldIndex = 0; |
193 | 194 |
int yFieldIndex = 0; |
194 |
|
|
195 |
|
|
195 | 196 |
xFieldIndex = ds.getFieldIndexByName(getXFieldName()); |
196 | 197 |
yFieldIndex = ds.getFieldIndexByName(getYFieldName()); |
197 | 198 |
AddEventThemeDriver addEventThemeDriver = new AddEventThemeDriver(); |
... | ... | |
203 | 204 |
// TODO Auto-generated catch block |
204 | 205 |
e.printStackTrace(); |
205 | 206 |
} |
207 |
projectTable.setAssociatedTable((AlphanumericData)capa); |
|
206 | 208 |
mapContext.getLayers().addLayer(capa); |
207 | 209 |
} catch (com.hardcode.gdbms.engine.data.driver.DriverException e1) { |
208 | 210 |
NotificationManager.addError(e1); |
209 | 211 |
} catch (DriverLoadException e) { |
210 | 212 |
NotificationManager.addError(e); |
211 | 213 |
} |
212 |
|
|
214 |
|
|
213 | 215 |
} |
214 |
|
|
216 |
|
|
215 | 217 |
private String getXFieldName() { |
216 | 218 |
return ((String)xComboBox.getSelectedItem()); |
217 | 219 |
} |
... | ... | |
219 | 221 |
private String getYFieldName() { |
220 | 222 |
return ((String)yComboBox.getSelectedItem()); |
221 | 223 |
} |
222 |
|
|
224 |
|
|
223 | 225 |
/* (non-Javadoc) |
224 | 226 |
* @see com.iver.andami.ui.mdiManager.View#getViewInfo() |
225 | 227 |
*/ |
... | ... | |
233 | 235 |
} |
234 | 236 |
|
235 | 237 |
/** |
236 |
* This method initializes tableComboBox
|
|
237 |
*
|
|
238 |
* @return javax.swing.JComboBox
|
|
239 |
*/
|
|
238 |
* This method initializes tableComboBox |
|
239 |
* |
|
240 |
* @return javax.swing.JComboBox |
|
241 |
*/ |
|
240 | 242 |
private JComboBox getTableComboBox() { |
241 | 243 |
if (tableComboBox == null) { |
242 | 244 |
tableComboBox = new JComboBox(); |
243 | 245 |
DefaultComboBoxModel defaultModel = new DefaultComboBoxModel(getTableNames()); |
244 | 246 |
tableComboBox.setModel(defaultModel); |
245 | 247 |
tableComboBox.setBounds(43, 6, 161, 24); |
246 |
tableComboBox.addItemListener(new java.awt.event.ItemListener() {
|
|
247 |
public void itemStateChanged(java.awt.event.ItemEvent e) {
|
|
248 |
tableComboBox.addItemListener(new java.awt.event.ItemListener() { |
|
249 |
public void itemStateChanged(java.awt.event.ItemEvent e) { |
|
248 | 250 |
System.out.println("itemStateChanged()"); // TODO Auto-generated Event stub itemStateChanged() |
249 | 251 |
// Cambiar el estado del xComboBox |
250 | 252 |
DefaultComboBoxModel defaultModel = new DefaultComboBoxModel(getFieldNames()); |
... | ... | |
259 | 261 |
} |
260 | 262 |
|
261 | 263 |
/** |
262 |
* This method initializes xComboBox
|
|
263 |
*
|
|
264 |
* @return javax.swing.JComboBox
|
|
265 |
*/
|
|
264 |
* This method initializes xComboBox |
|
265 |
* |
|
266 |
* @return javax.swing.JComboBox |
|
267 |
*/ |
|
266 | 268 |
private JComboBox getXComboBox() { |
267 | 269 |
if (xComboBox == null) { |
268 | 270 |
xComboBox = new JComboBox(); |
... | ... | |
274 | 276 |
} |
275 | 277 |
|
276 | 278 |
/** |
277 |
* This method initializes yComboBox
|
|
278 |
*
|
|
279 |
* @return javax.swing.JComboBox
|
|
280 |
*/
|
|
279 |
* This method initializes yComboBox |
|
280 |
* |
|
281 |
* @return javax.swing.JComboBox |
|
282 |
*/ |
|
281 | 283 |
private JComboBox getYComboBox() { |
282 | 284 |
if (yComboBox == null) { |
283 | 285 |
yComboBox = new JComboBox(); |
... | ... | |
289 | 291 |
} |
290 | 292 |
|
291 | 293 |
/** |
292 |
* This method initializes okButton
|
|
293 |
*
|
|
294 |
* @return javax.swing.JButton
|
|
295 |
*/
|
|
294 |
* This method initializes okButton |
|
295 |
* |
|
296 |
* @return javax.swing.JButton |
|
297 |
*/ |
|
296 | 298 |
private JButton getOkButton() { |
297 | 299 |
if (okButton == null) { |
298 | 300 |
okButton = new JButton(); |
299 | 301 |
okButton.setBounds(104, 100, 100, 24); |
300 |
okButton.addActionListener(new java.awt.event.ActionListener() {
|
|
301 |
public void actionPerformed(java.awt.event.ActionEvent e) {
|
|
302 |
okButton.addActionListener(new java.awt.event.ActionListener() { |
|
303 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
302 | 304 |
System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed() |
303 | 305 |
createNewLayerFromDataSource(); |
304 | 306 |
// y sale. |
Also available in: Unified diff