svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / table / FieldSelectionModel.java @ 28940
History | View | Annotate | Download (1.65 KB)
1 | 7304 | caballero | package com.iver.cit.gvsig.project.documents.table; |
---|---|---|---|
2 | |||
3 | import java.util.ArrayList; |
||
4 | |||
5 | 10626 | caballero | import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
6 | 7304 | caballero | import com.hardcode.gdbms.engine.data.DataSource; |
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 | 10626 | caballero | } catch (ReadDriverException e) {
|
65 | 7304 | caballero | 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 | } |