svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / MyTableModel.java @ 312
History | View | Annotate | Download (2.63 KB)
1 |
package com.iver.cit.gvsig.project; |
---|---|
2 |
|
3 |
|
4 |
import javax.swing.table.AbstractTableModel; |
5 |
|
6 |
import com.iver.mdiApp.Utilities; |
7 |
|
8 |
|
9 |
/**
|
10 |
* Modelo para la JTable de MapProperties
|
11 |
*
|
12 |
* @author Fernando Gonz?lez Cort?s
|
13 |
*/
|
14 |
public class MyTableModel extends AbstractTableModel { |
15 |
private ProjectTable table;
|
16 |
|
17 |
/**
|
18 |
* Creates a new MyTableModel object.
|
19 |
*
|
20 |
* @param t Tabla del proyecto que se quiere mostrar
|
21 |
*/
|
22 |
public MyTableModel(ProjectTable t) {
|
23 |
table = t; |
24 |
} |
25 |
|
26 |
/**
|
27 |
* @see javax.swing.table.TableModel#getColumnCount()
|
28 |
*/
|
29 |
public int getColumnCount() { |
30 |
return 3; |
31 |
} |
32 |
|
33 |
/* (non-Javadoc)
|
34 |
* @see javax.swing.table.TableModel#getRowCount()
|
35 |
*/
|
36 |
public int getRowCount() { |
37 |
//TODO implementar bien
|
38 |
return 0; |
39 |
//return table.getModelo().getFieldsCount();
|
40 |
} |
41 |
|
42 |
/* (non-Javadoc)
|
43 |
* @see javax.swing.table.TableModel#getValueAt(int, int)
|
44 |
*/
|
45 |
public Object getValueAt(int rowIndex, int columnIndex) { |
46 |
if (columnIndex == 0) { |
47 |
return new Boolean(table.get(rowIndex)); |
48 |
} else if (columnIndex == 1) { |
49 |
//TODO implementar bien
|
50 |
return null; |
51 |
//return table.getModelo().getFieldName(rowIndex);
|
52 |
} else {
|
53 |
return "alias"; //table.getModelo().getColumnAlias(rowIndex); |
54 |
} |
55 |
} |
56 |
|
57 |
/* (non-Javadoc)
|
58 |
* @see javax.swing.table.TableModel#getColumnClass(int)
|
59 |
*/
|
60 |
public Class getColumnClass(int columnIndex) { |
61 |
if (columnIndex == 0) { |
62 |
return Boolean.class; |
63 |
} |
64 |
|
65 |
return String.class; |
66 |
} |
67 |
|
68 |
/* (non-Javadoc)
|
69 |
* @see javax.swing.table.TableModel#isCellEditable(int, int)
|
70 |
*/
|
71 |
public boolean isCellEditable(int rowIndex, int columnIndex) { |
72 |
return (columnIndex != 1); |
73 |
} |
74 |
|
75 |
/* (non-Javadoc)
|
76 |
* @see javax.swing.table.TableModel#setValueAt(java.lang.Object, int, int)
|
77 |
*/
|
78 |
public void setValueAt(Object aValue, int rowIndex, int columnIndex) { |
79 |
if (columnIndex == 0) { |
80 |
table.set(rowIndex, ((Boolean) aValue).booleanValue());
|
81 |
} else {
|
82 |
//table.getModelo().setColumnAlias(rowIndex, (String) aValue);
|
83 |
} |
84 |
} |
85 |
|
86 |
/* (non-Javadoc)
|
87 |
* @see javax.swing.table.TableModel#getColumnName(int)
|
88 |
*/
|
89 |
public String getColumnName(int column) { |
90 |
String ret = null; |
91 |
|
92 |
switch (column) {
|
93 |
case 0: |
94 |
ret = Utilities.getMessage(this, "visible"); |
95 |
|
96 |
break;
|
97 |
|
98 |
case 1: |
99 |
ret = Utilities.getMessage(this, "campo"); |
100 |
|
101 |
break;
|
102 |
|
103 |
case 2: |
104 |
ret = Utilities.getMessage(this, "alias"); |
105 |
|
106 |
break;
|
107 |
} |
108 |
|
109 |
return ret;
|
110 |
} |
111 |
} |