root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / tables / FieldSelectionModel.java @ 2183
History | View | Annotate | Download (1.63 KB)
1 |
package com.iver.cit.gvsig.gui.tables; |
---|---|
2 |
|
3 |
import java.util.ArrayList; |
4 |
|
5 |
import com.hardcode.gdbms.engine.data.DataSource; |
6 |
import com.hardcode.gdbms.engine.data.driver.DriverException; |
7 |
import com.iver.utiles.swing.objectSelection.ObjectSelectionModel; |
8 |
import com.iver.utiles.swing.objectSelection.SelectionException; |
9 |
|
10 |
|
11 |
/**
|
12 |
* DOCUMENT ME!
|
13 |
*
|
14 |
* @author Fernando Gonz?lez Cort?s
|
15 |
*/
|
16 |
public class FieldSelectionModel implements ObjectSelectionModel { |
17 |
private DataSource ds; |
18 |
private String msg; |
19 |
private int type; |
20 |
|
21 |
/**
|
22 |
* Crea un nuevo FirstFieldSelectionModel.
|
23 |
*
|
24 |
* @param ds DOCUMENT ME!
|
25 |
* @param msg DOCUMENT ME!
|
26 |
* @param allowedTypes DOCUMENT ME!
|
27 |
*/
|
28 |
public FieldSelectionModel(DataSource ds, String msg, |
29 |
int type) {
|
30 |
this.ds = ds;
|
31 |
this.msg = msg;
|
32 |
this.type = type;
|
33 |
} |
34 |
|
35 |
/**
|
36 |
* DOCUMENT ME!
|
37 |
*
|
38 |
* @return DOCUMENT ME!
|
39 |
*
|
40 |
* @throws SelectionException
|
41 |
*
|
42 |
* @see com.iver.utiles.swing.objectSelection.ObjectSelectionModel#getObjects()
|
43 |
*/
|
44 |
public Object[] getObjects() throws SelectionException { |
45 |
try {
|
46 |
ds.start(); |
47 |
|
48 |
ArrayList fields = new ArrayList(); |
49 |
|
50 |
for (int i = 0; i < ds.getFieldCount(); i++) { |
51 |
if (type != -1) { |
52 |
System.out.println(ds.getFieldName(i) + " tipo: " + ds.getFieldType(i)); |
53 |
if (ds.getFieldType(i) == type) {
|
54 |
fields.add(ds.getFieldName(i)); |
55 |
} |
56 |
} else {
|
57 |
fields.add(ds.getFieldName(i)); |
58 |
} |
59 |
} |
60 |
|
61 |
ds.stop(); |
62 |
|
63 |
return (String[]) fields.toArray(new String[0]); |
64 |
} catch (DriverException e) {
|
65 |
throw new SelectionException(e); |
66 |
} |
67 |
} |
68 |
|
69 |
/**
|
70 |
* @see com.iver.utiles.swing.objectSelection.ObjectSelectionModel#getMsg()
|
71 |
*/
|
72 |
public String getMsg() { |
73 |
return msg;
|
74 |
} |
75 |
} |