root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / TableOperations.java @ 7738
History | View | Annotate | Download (16.6 KB)
1 | 1103 | fjp | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
4 | *
|
||
5 | * This program is free software; you can redistribute it and/or
|
||
6 | * modify it under the terms of the GNU General Public License
|
||
7 | * as published by the Free Software Foundation; either version 2
|
||
8 | * of the License, or (at your option) any later version.
|
||
9 | *
|
||
10 | * This program is distributed in the hope that it will be useful,
|
||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
13 | * GNU General Public License for more details.
|
||
14 | *
|
||
15 | * You should have received a copy of the GNU General Public License
|
||
16 | * along with this program; if not, write to the Free Software
|
||
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
18 | *
|
||
19 | * For more information, contact:
|
||
20 | *
|
||
21 | * Generalitat Valenciana
|
||
22 | * Conselleria d'Infraestructures i Transport
|
||
23 | * Av. Blasco Ib??ez, 50
|
||
24 | * 46010 VALENCIA
|
||
25 | * SPAIN
|
||
26 | *
|
||
27 | * +34 963862235
|
||
28 | * gvsig@gva.es
|
||
29 | * www.gvsig.gva.es
|
||
30 | *
|
||
31 | * or
|
||
32 | *
|
||
33 | * IVER T.I. S.A
|
||
34 | * Salamanca 50
|
||
35 | * 46005 Valencia
|
||
36 | * Spain
|
||
37 | *
|
||
38 | * +34 963163400
|
||
39 | * dac@iver.es
|
||
40 | */
|
||
41 | 312 | fernando | package com.iver.cit.gvsig; |
42 | |||
43 | 6736 | caballero | import java.awt.Dimension; |
44 | 1830 | fernando | import java.io.IOException; |
45 | |||
46 | 1219 | vcaballero | import com.hardcode.driverManager.DriverLoadException; |
47 | 884 | fernando | import com.hardcode.gdbms.engine.data.DataSource; |
48 | import com.hardcode.gdbms.engine.data.DataSourceFactory; |
||
49 | 2217 | fernando | import com.hardcode.gdbms.engine.instruction.EvaluationException; |
50 | 884 | fernando | import com.hardcode.gdbms.engine.instruction.SemanticException; |
51 | import com.hardcode.gdbms.parser.ParseException; |
||
52 | 855 | fernando | import com.iver.andami.PluginServices; |
53 | import com.iver.andami.messages.NotificationManager; |
||
54 | 596 | fernando | import com.iver.andami.plugins.Extension; |
55 | 6877 | cesar | import com.iver.andami.ui.mdiManager.IWindow; |
56 | 3940 | caballero | import com.iver.cit.gvsig.fmap.edition.EditableAdapter; |
57 | 884 | fernando | import com.iver.cit.gvsig.fmap.layers.FBitSet; |
58 | 1774 | fernando | import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
59 | 855 | fernando | import com.iver.cit.gvsig.fmap.layers.SelectableDataSource; |
60 | import com.iver.cit.gvsig.gui.filter.ExpressionListener; |
||
61 | 7304 | caballero | import com.iver.cit.gvsig.project.documents.table.FieldSelectionModel; |
62 | import com.iver.cit.gvsig.project.documents.table.ObjectSelectionStep; |
||
63 | import com.iver.cit.gvsig.project.documents.table.ProjectTable; |
||
64 | 7379 | caballero | import com.iver.cit.gvsig.project.documents.table.ProjectTableFactory; |
65 | 7304 | caballero | import com.iver.cit.gvsig.project.documents.table.TableSelectionModel; |
66 | import com.iver.cit.gvsig.project.documents.table.gui.AndamiWizard; |
||
67 | import com.iver.cit.gvsig.project.documents.table.gui.Table; |
||
68 | 1830 | fernando | import com.iver.utiles.swing.objectSelection.SelectionException; |
69 | import com.iver.utiles.swing.wizard.WizardControl; |
||
70 | import com.iver.utiles.swing.wizard.WizardEvent; |
||
71 | import com.iver.utiles.swing.wizard.WizardListener; |
||
72 | 312 | fernando | |
73 | |||
74 | /**
|
||
75 | 1219 | vcaballero | * Extensi?n que controla las operaciones realizadas sobre las tablas.
|
76 | 312 | fernando | *
|
77 | * @author Fernando Gonz?lez Cort?s
|
||
78 | */
|
||
79 | 5005 | jorpiell | public class TableOperations extends Extension implements ExpressionListener { |
80 | 855 | fernando | private SelectableDataSource dataSource = null; |
81 | 2183 | fernando | //private Table vista;
|
82 | 312 | fernando | |
83 | 1219 | vcaballero | /**
|
84 | 5005 | jorpiell | * @see com.iver.mdiApp.plugins.IExtension#updateUI(java.lang.String)
|
85 | 1219 | vcaballero | */
|
86 | public void execute(String actionCommand) { |
||
87 | 2183 | fernando | if ("JOIN".equals(actionCommand)) { |
88 | 1830 | fernando | ProjectExtension pe = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class); |
89 | 7379 | caballero | ProjectTable[] pts = (ProjectTable[]) pe.getProject().getDocumentsByType(ProjectTableFactory.registerName) |
90 | 1830 | fernando | .toArray(new ProjectTable[0]); |
91 | 855 | fernando | |
92 | 1830 | fernando | try {
|
93 | final ObjectSelectionStep sourceTable = new ObjectSelectionStep(); |
||
94 | sourceTable.setModel(new TableSelectionModel(pts,
|
||
95 | 2337 | fernando | PluginServices.getText(this, "seleccione_tabla_origen"))); |
96 | 312 | fernando | |
97 | 1830 | fernando | final ObjectSelectionStep targetTable = new ObjectSelectionStep(); |
98 | targetTable.setModel(new TableSelectionModel(pts,
|
||
99 | 2337 | fernando | PluginServices.getText(this, "seleccione_tabla_a_enlazar"))); |
100 | 312 | fernando | |
101 | 1830 | fernando | final ObjectSelectionStep firstTableField = new ObjectSelectionStep(); |
102 | final ObjectSelectionStep secondTableField = new ObjectSelectionStep(); |
||
103 | 2337 | fernando | final AndamiWizard wiz = new AndamiWizard(PluginServices.getText(this, "back"), PluginServices.getText(this, "next"), PluginServices.getText(this, "finish"), PluginServices.getText(this, "cancel")); |
104 | 6736 | caballero | wiz.setSize(new Dimension(450,200)); |
105 | 1830 | fernando | wiz.addStep(sourceTable); |
106 | wiz.addStep(firstTableField); |
||
107 | wiz.addStep(targetTable); |
||
108 | wiz.addStep(secondTableField); |
||
109 | |||
110 | wiz.addWizardListener(new WizardListener() {
|
||
111 | public void cancel(WizardEvent w) { |
||
112 | 6880 | cesar | PluginServices.getMDIManager().closeWindow(wiz); |
113 | 1830 | fernando | } |
114 | |||
115 | public void finished(WizardEvent w) { |
||
116 | 6880 | cesar | PluginServices.getMDIManager().closeWindow(wiz); |
117 | 1830 | fernando | |
118 | ProjectTable sourceProjectTable = (ProjectTable) sourceTable.getSelected(); |
||
119 | 3940 | caballero | SelectableDataSource sds=null;
|
120 | try {
|
||
121 | 7304 | caballero | sds = sourceProjectTable.getModelo().getRecordset(); |
122 | 3940 | caballero | } catch (DriverLoadException e1) {
|
123 | // TODO Auto-generated catch block
|
||
124 | e1.printStackTrace(); |
||
125 | } |
||
126 | 1830 | fernando | String tableName1 = sds.getName();
|
127 | |||
128 | ProjectTable targetProjectTable = (ProjectTable) targetTable.getSelected(); |
||
129 | 3940 | caballero | try {
|
130 | 7304 | caballero | sds = targetProjectTable.getModelo().getRecordset(); |
131 | 3940 | caballero | } catch (DriverLoadException e1) {
|
132 | // TODO Auto-generated catch block
|
||
133 | e1.printStackTrace(); |
||
134 | } |
||
135 | 1830 | fernando | |
136 | String tableName2 = sds.getName();
|
||
137 | |||
138 | String field1 = (String) firstTableField.getSelected(); |
||
139 | String field2 = (String) secondTableField.getSelected(); |
||
140 | |||
141 | 2183 | fernando | String sql =
|
142 | "custom com_iver_cit_gvsig_arcjoin tables '" +
|
||
143 | tableName1 + "', '" + tableName2 + "' values(" + |
||
144 | field1 + ", " + field2 + ");"; |
||
145 | 1830 | fernando | System.out.println(sql);
|
146 | |||
147 | try {
|
||
148 | 2183 | fernando | SelectableDataSource result = new SelectableDataSource(LayerFactory.getDataSourceFactory()
|
149 | .executeSQL(sql, |
||
150 | 2758 | fernando | DataSourceFactory.AUTOMATIC_OPENING)); |
151 | 1830 | fernando | ProjectTable projectTable = (ProjectTable) sourceTable.getSelected(); |
152 | 3940 | caballero | EditableAdapter auxea=new EditableAdapter();
|
153 | auxea.setOriginalDataSource(result); |
||
154 | projectTable.replaceDataSource(auxea); |
||
155 | 1830 | fernando | } catch (ParseException e) { |
156 | throw new RuntimeException(e); |
||
157 | } catch (DriverLoadException e) {
|
||
158 | NotificationManager.addError("Error con la carga de drivers",
|
||
159 | e); |
||
160 | } catch (com.hardcode.gdbms.engine.data.driver.DriverException e) {
|
||
161 | NotificationManager.addError("Error leyendo del driver",
|
||
162 | e); |
||
163 | } catch (SemanticException e) {
|
||
164 | throw new RuntimeException(e); |
||
165 | } catch (IOException e) { |
||
166 | NotificationManager.addError("Error de entrada/salida",
|
||
167 | e); |
||
168 | 2217 | fernando | } catch (EvaluationException e) {
|
169 | NotificationManager.addError("Error de evaluaci?n de la expresi?n",
|
||
170 | e); |
||
171 | } |
||
172 | 1830 | fernando | } |
173 | |||
174 | public void next(WizardEvent w) { |
||
175 | WizardControl wiz = w.wizard; |
||
176 | wiz.enableBack(true);
|
||
177 | 2183 | fernando | wiz.enableNext(((ObjectSelectionStep) wiz.getCurrentStep()).getSelectedItem() != null);
|
178 | |||
179 | 1830 | fernando | if (w.currentStep == 1) { |
180 | ProjectTable pt = (ProjectTable) sourceTable.getSelected(); |
||
181 | |||
182 | try {
|
||
183 | firstTableField.setModel(new FieldSelectionModel(
|
||
184 | 3940 | caballero | pt.getModelo().getRecordset(), |
185 | 2337 | fernando | PluginServices.getText(this, "seleccione_campo_enlace"), |
186 | 1830 | fernando | -1));
|
187 | } catch (SelectionException e) {
|
||
188 | NotificationManager.addError("Error obteniendo los campos de la tabla",
|
||
189 | e); |
||
190 | 3940 | caballero | } catch (DriverLoadException e) {
|
191 | // TODO Auto-generated catch block
|
||
192 | e.printStackTrace(); |
||
193 | 1830 | fernando | } |
194 | } else if (w.currentStep == 3) { |
||
195 | try {
|
||
196 | //tabla
|
||
197 | ProjectTable pt = (ProjectTable) sourceTable.getSelected(); |
||
198 | |||
199 | //?ndice del campo
|
||
200 | 7304 | caballero | SelectableDataSource sds = pt.getModelo().getRecordset(); |
201 | 1830 | fernando | String fieldName = (String) firstTableField.getSelected(); |
202 | int fieldIndex = sds.getFieldIndexByName(fieldName);
|
||
203 | int type = sds.getFieldType(fieldIndex);
|
||
204 | |||
205 | secondTableField.setModel(new FieldSelectionModel(
|
||
206 | 3940 | caballero | ((ProjectTable) targetTable.getSelected()).getModelo().getRecordset(), |
207 | 2337 | fernando | PluginServices.getText(this, "seleccione_campo_enlace"), |
208 | 1830 | fernando | type)); |
209 | } catch (SelectionException e) {
|
||
210 | NotificationManager.addError("Error obteniendo los campos de la tabla",
|
||
211 | e); |
||
212 | } catch (com.hardcode.gdbms.engine.data.driver.DriverException e) {
|
||
213 | NotificationManager.addError("Error obteniendo los campos de la tabla",
|
||
214 | e); |
||
215 | 3940 | caballero | } catch (DriverLoadException e) {
|
216 | // TODO Auto-generated catch block
|
||
217 | e.printStackTrace(); |
||
218 | 1830 | fernando | } |
219 | } |
||
220 | } |
||
221 | |||
222 | public void back(WizardEvent w) { |
||
223 | WizardControl wiz = w.wizard; |
||
224 | wiz.enableBack(true);
|
||
225 | 2183 | fernando | wiz.enableNext(((ObjectSelectionStep) wiz.getCurrentStep()).getSelectedItem() != null);
|
226 | 1830 | fernando | } |
227 | }); |
||
228 | 6880 | cesar | PluginServices.getMDIManager().addWindow(wiz); |
229 | 1830 | fernando | } catch (SelectionException e) {
|
230 | NotificationManager.addError("Error abriendo el asistente", e);
|
||
231 | } |
||
232 | 2183 | fernando | }else if ("LINK".equals(actionCommand)) { |
233 | ProjectExtension pe = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class); |
||
234 | 7379 | caballero | ProjectTable[] pts = (ProjectTable[]) pe.getProject().getDocumentsByType(ProjectTableFactory.registerName) |
235 | 2183 | fernando | .toArray(new ProjectTable[0]); |
236 | |||
237 | try {
|
||
238 | final ObjectSelectionStep sourceTable = new ObjectSelectionStep(); |
||
239 | sourceTable.setModel(new TableSelectionModel(pts,
|
||
240 | 2337 | fernando | PluginServices.getText(this, "seleccione_tabla_origen"))); |
241 | 2183 | fernando | |
242 | final ObjectSelectionStep targetTable = new ObjectSelectionStep(); |
||
243 | targetTable.setModel(new TableSelectionModel(pts,
|
||
244 | 2337 | fernando | PluginServices.getText(this, "seleccione_tabla_a_enlazar"))); |
245 | 2183 | fernando | |
246 | final ObjectSelectionStep firstTableField = new ObjectSelectionStep(); |
||
247 | final ObjectSelectionStep secondTableField = new ObjectSelectionStep(); |
||
248 | 2337 | fernando | final AndamiWizard wiz = new AndamiWizard(PluginServices.getText(this, "back"), PluginServices.getText(this, "next"), PluginServices.getText(this, "finish"), PluginServices.getText(this, "cancel")); |
249 | 6736 | caballero | wiz.setSize(new Dimension(450,200)); |
250 | 2183 | fernando | wiz.addStep(sourceTable); |
251 | wiz.addStep(firstTableField); |
||
252 | wiz.addStep(targetTable); |
||
253 | wiz.addStep(secondTableField); |
||
254 | |||
255 | wiz.addWizardListener(new WizardListener() {
|
||
256 | public void cancel(WizardEvent w) { |
||
257 | 6880 | cesar | PluginServices.getMDIManager().closeWindow(wiz); |
258 | 2183 | fernando | } |
259 | |||
260 | public void finished(WizardEvent w) { |
||
261 | 6880 | cesar | PluginServices.getMDIManager().closeWindow(wiz); |
262 | 2183 | fernando | |
263 | ProjectTable sourceProjectTable = (ProjectTable) sourceTable.getSelected(); |
||
264 | 3940 | caballero | SelectableDataSource sds1=null;;
|
265 | try {
|
||
266 | 7304 | caballero | sds1 = sourceProjectTable.getModelo().getRecordset(); |
267 | 3940 | caballero | } catch (DriverLoadException e) {
|
268 | // TODO Auto-generated catch block
|
||
269 | e.printStackTrace(); |
||
270 | } |
||
271 | 7304 | caballero | //String tableName1 = sds1.getName();
|
272 | 2183 | fernando | |
273 | ProjectTable targetProjectTable = (ProjectTable) targetTable.getSelected(); |
||
274 | 3940 | caballero | SelectableDataSource sds2=null;
|
275 | try {
|
||
276 | 7304 | caballero | sds2 = targetProjectTable.getModelo().getRecordset(); |
277 | 3940 | caballero | } catch (DriverLoadException e) {
|
278 | // TODO Auto-generated catch block
|
||
279 | e.printStackTrace(); |
||
280 | } |
||
281 | 2183 | fernando | |
282 | 7304 | caballero | //String tableName2 = sds2.getName();
|
283 | 2183 | fernando | |
284 | String field1 = (String) firstTableField.getSelected(); |
||
285 | String field2 = (String) secondTableField.getSelected(); |
||
286 | sourceProjectTable.setLinkTable(sds2.getName(),field1,field2); |
||
287 | ((ProjectExtension)PluginServices.getExtension(ProjectExtension.class)).getProject().setLinkTable(); |
||
288 | } |
||
289 | |||
290 | public void next(WizardEvent w) { |
||
291 | WizardControl wiz = w.wizard; |
||
292 | wiz.enableBack(true);
|
||
293 | wiz.enableNext(((ObjectSelectionStep) wiz.getCurrentStep()).getSelectedItem() != null);
|
||
294 | |||
295 | if (w.currentStep == 1) { |
||
296 | ProjectTable pt = (ProjectTable) sourceTable.getSelected(); |
||
297 | |||
298 | try {
|
||
299 | firstTableField.setModel(new FieldSelectionModel(
|
||
300 | 3940 | caballero | pt.getModelo().getRecordset(), |
301 | 2337 | fernando | PluginServices.getText(this, "seleccione_campo_enlace"), |
302 | 2183 | fernando | -1));
|
303 | } catch (SelectionException e) {
|
||
304 | NotificationManager.addError("Error obteniendo los campos de la tabla",
|
||
305 | e); |
||
306 | 3940 | caballero | } catch (DriverLoadException e) {
|
307 | // TODO Auto-generated catch block
|
||
308 | e.printStackTrace(); |
||
309 | 2183 | fernando | } |
310 | } else if (w.currentStep == 3) { |
||
311 | try {
|
||
312 | //tabla
|
||
313 | ProjectTable pt = (ProjectTable) sourceTable.getSelected(); |
||
314 | |||
315 | //?ndice del campo
|
||
316 | 7304 | caballero | SelectableDataSource sds = pt.getModelo().getRecordset(); |
317 | 2183 | fernando | String fieldName = (String) firstTableField.getSelected(); |
318 | int fieldIndex = sds.getFieldIndexByName(fieldName);
|
||
319 | int type = sds.getFieldType(fieldIndex);
|
||
320 | |||
321 | secondTableField.setModel(new FieldSelectionModel(
|
||
322 | 3940 | caballero | ((ProjectTable) targetTable.getSelected()).getModelo().getRecordset(), |
323 | 2337 | fernando | PluginServices.getText(this, "seleccione_campo_enlace"), |
324 | 2183 | fernando | type)); |
325 | } catch (SelectionException e) {
|
||
326 | NotificationManager.addError("Error obteniendo los campos de la tabla",
|
||
327 | e); |
||
328 | } catch (com.hardcode.gdbms.engine.data.driver.DriverException e) {
|
||
329 | NotificationManager.addError("Error obteniendo los campos de la tabla",
|
||
330 | e); |
||
331 | 3940 | caballero | } catch (DriverLoadException e) {
|
332 | // TODO Auto-generated catch block
|
||
333 | e.printStackTrace(); |
||
334 | 2183 | fernando | } |
335 | } |
||
336 | } |
||
337 | |||
338 | public void back(WizardEvent w) { |
||
339 | WizardControl wiz = w.wizard; |
||
340 | wiz.enableBack(true);
|
||
341 | wiz.enableNext(((ObjectSelectionStep) wiz.getCurrentStep()).getSelectedItem() != null);
|
||
342 | } |
||
343 | }); |
||
344 | 6880 | cesar | PluginServices.getMDIManager().addWindow(wiz); |
345 | 2183 | fernando | } catch (SelectionException e) {
|
346 | NotificationManager.addError("Error abriendo el asistente", e);
|
||
347 | } |
||
348 | 3940 | caballero | } |
349 | 1219 | vcaballero | } |
350 | 312 | fernando | |
351 | 1219 | vcaballero | /**
|
352 | 855 | fernando | * @see com.iver.cit.gvsig.gui.filter.ExpressionListener#newSet(java.lang.String)
|
353 | 312 | fernando | */
|
354 | public void newSet(String expression) { |
||
355 | 884 | fernando | long[] sel = doSet(expression); |
356 | 1219 | vcaballero | |
357 | if (sel == null) { |
||
358 | throw new RuntimeException("Not a 'where' clause?"); |
||
359 | } |
||
360 | |||
361 | 884 | fernando | FBitSet selection = new FBitSet();
|
362 | 1219 | vcaballero | |
363 | 884 | fernando | for (int i = 0; i < sel.length; i++) { |
364 | selection.set((int) sel[i]);
|
||
365 | } |
||
366 | 1219 | vcaballero | |
367 | 312 | fernando | dataSource.clearSelection(); |
368 | 884 | fernando | dataSource.setSelection(selection); |
369 | 312 | fernando | } |
370 | 1219 | vcaballero | |
371 | 312 | fernando | /**
|
372 | 855 | fernando | * @see com.iver.cit.gvsig.gui.filter.ExpressionListener#newSet(java.lang.String)
|
373 | 312 | fernando | */
|
374 | 884 | fernando | private long[] doSet(String expression) { |
375 | try {
|
||
376 | 2183 | fernando | DataSource ds = LayerFactory.getDataSourceFactory().executeSQL(expression,
|
377 | 2667 | fernando | DataSourceFactory.MANUAL_OPENING); |
378 | 1219 | vcaballero | |
379 | 884 | fernando | return ds.getWhereFilter();
|
380 | } catch (DriverLoadException e) {
|
||
381 | NotificationManager.addError("Error cargando el driver", e);
|
||
382 | 1830 | fernando | } catch (com.hardcode.gdbms.engine.data.driver.DriverException e) {
|
383 | 884 | fernando | NotificationManager.addError("Error accediendo al driver", e);
|
384 | } catch (ParseException e) { |
||
385 | NotificationManager.addError("Parse error", e);
|
||
386 | } catch (SemanticException e) {
|
||
387 | NotificationManager.addError(e.getMessage(), e); |
||
388 | } catch (IOException e) { |
||
389 | NotificationManager.addError("GDBMS internal error", e);
|
||
390 | 2217 | fernando | } catch (EvaluationException e) {
|
391 | NotificationManager.addError("Error con la expresi?n", e);
|
||
392 | } |
||
393 | 1219 | vcaballero | |
394 | 884 | fernando | return null; |
395 | 312 | fernando | } |
396 | |||
397 | 1219 | vcaballero | /**
|
398 | * @see com.iver.cit.gvsig.gui.filter.ExpressionListener#addToSet(java.lang.String)
|
||
399 | */
|
||
400 | public void addToSet(String expression) { |
||
401 | 884 | fernando | long[] sel = doSet(expression); |
402 | 1219 | vcaballero | |
403 | if (sel == null) { |
||
404 | throw new RuntimeException("Not a 'where' clause?"); |
||
405 | } |
||
406 | |||
407 | 884 | fernando | FBitSet selection = new FBitSet();
|
408 | 1219 | vcaballero | |
409 | 884 | fernando | for (int i = 0; i < sel.length; i++) { |
410 | selection.set((int) sel[i]);
|
||
411 | } |
||
412 | 1219 | vcaballero | |
413 | 884 | fernando | FBitSet fbs = dataSource.getSelection(); |
414 | fbs.or(selection); |
||
415 | dataSource.setSelection(fbs); |
||
416 | 1219 | vcaballero | } |
417 | 312 | fernando | |
418 | 1219 | vcaballero | /**
|
419 | * @see com.iver.cit.gvsig.gui.filter.ExpressionListener#fromSet(java.lang.String)
|
||
420 | */
|
||
421 | public void fromSet(String expression) { |
||
422 | 884 | fernando | long[] sel = doSet(expression); |
423 | 1219 | vcaballero | |
424 | if (sel == null) { |
||
425 | throw new RuntimeException("Not a 'where' clause?"); |
||
426 | } |
||
427 | |||
428 | 884 | fernando | FBitSet selection = new FBitSet();
|
429 | 1219 | vcaballero | |
430 | 884 | fernando | for (int i = 0; i < sel.length; i++) { |
431 | selection.set((int) sel[i]);
|
||
432 | 312 | fernando | } |
433 | 1219 | vcaballero | |
434 | 884 | fernando | FBitSet fbs = dataSource.getSelection(); |
435 | fbs.and(selection); |
||
436 | dataSource.setSelection(fbs); |
||
437 | 1219 | vcaballero | } |
438 | 312 | fernando | |
439 | /**
|
||
440 | 5005 | jorpiell | * @see com.iver.mdiApp.plugins.IExtension#isVisible()
|
441 | 312 | fernando | */
|
442 | public boolean isVisible() { |
||
443 | 6880 | cesar | IWindow v = PluginServices.getMDIManager().getActiveWindow(); |
444 | 312 | fernando | |
445 | 855 | fernando | if (v == null) { |
446 | 312 | fernando | return false; |
447 | } |
||
448 | 1219 | vcaballero | |
449 | 5900 | jorpiell | if (v instanceof Table) { |
450 | 312 | fernando | return true; |
451 | 2183 | fernando | } /*else {
|
452 | 1219 | vcaballero | if (v instanceof com.iver.cit.gvsig.gui.View) {
|
453 | 855 | fernando | com.iver.cit.gvsig.gui.View view = (com.iver.cit.gvsig.gui.View) v;
|
454 | ProjectView pv = view.getModel();
|
||
455 | 1219 | vcaballero | FLayer[] seleccionadas = pv.getMapContext().getLayers()
|
456 | .getActives();
|
||
457 | |||
458 | if (seleccionadas.length == 1) {
|
||
459 | if (seleccionadas[0] instanceof AlphanumericData) {
|
||
460 | 855 | fernando | return true;
|
461 | }
|
||
462 | 312 | fernando | }
|
463 | }
|
||
464 | 2183 | fernando | */
|
465 | 312 | fernando | return false; |
466 | 2183 | fernando | //}
|
467 | 312 | fernando | } |
468 | |||
469 | 596 | fernando | /**
|
470 | 5005 | jorpiell | * @see com.iver.andami.plugins.IExtension#initialize()
|
471 | 596 | fernando | */
|
472 | 5005 | jorpiell | public void initialize() { |
473 | 596 | fernando | } |
474 | |||
475 | /**
|
||
476 | 5005 | jorpiell | * @see com.iver.andami.plugins.IExtension#isEnabled()
|
477 | 596 | fernando | */
|
478 | public boolean isEnabled() { |
||
479 | 855 | fernando | return true; |
480 | 596 | fernando | } |
481 | 2183 | fernando | |
482 | 3940 | caballero | |
483 | 312 | fernando | } |