svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.swing / org.gvsig.fmap.dal.swing.impl / src / main / java / org / gvsig / fmap / dal / swing / impl / featuretype / FeatureRulesModel.java @ 45739
History | View | Annotate | Download (3.18 KB)
1 |
package org.gvsig.fmap.dal.swing.impl.featuretype; |
---|---|
2 |
|
3 |
import java.util.Collections; |
4 |
import java.util.Iterator; |
5 |
import javax.swing.table.AbstractTableModel; |
6 |
import org.gvsig.fmap.dal.DALLocator; |
7 |
import org.gvsig.fmap.dal.DataManager; |
8 |
import org.gvsig.fmap.dal.feature.FeatureRule; |
9 |
import org.gvsig.fmap.dal.feature.FeatureRuleExpression; |
10 |
import org.gvsig.fmap.dal.feature.FeatureRules; |
11 |
import org.gvsig.tools.ToolsLocator; |
12 |
import org.gvsig.tools.i18n.I18nManager; |
13 |
|
14 |
/**
|
15 |
*
|
16 |
* @author gvSIG Team
|
17 |
*/
|
18 |
public class FeatureRulesModel |
19 |
extends AbstractTableModel |
20 |
implements AggregateController.AggregateModel<FeatureRule> {
|
21 |
|
22 |
private static final int COLUMN_NAME = 0; |
23 |
private static final int COLUMN_AT_FINISH_EDITING = 1; |
24 |
private static final int COLUMN_AT_INSERT = 2; |
25 |
|
26 |
private FeatureRules rules;
|
27 |
private String[] columnNames; |
28 |
private Class[] columnClases; |
29 |
|
30 |
public FeatureRulesModel() {
|
31 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
32 |
this.rules = null; |
33 |
this.columnNames = new String[] { |
34 |
i18n.getTranslation("_Name"),
|
35 |
i18n.getTranslation("_At_finish_editing"),
|
36 |
i18n.getTranslation("_At_insert")
|
37 |
}; |
38 |
this.columnClases = new Class[] { |
39 |
String.class,
|
40 |
Boolean.class,
|
41 |
Boolean.class
|
42 |
}; |
43 |
} |
44 |
|
45 |
public FeatureRulesModel(FeatureRules rules) {
|
46 |
this();
|
47 |
this.rules = rules;
|
48 |
} |
49 |
|
50 |
@Override
|
51 |
public FeatureRule createItem() {
|
52 |
DataManager manager = DALLocator.getDataManager(); |
53 |
FeatureRuleExpression rule = manager.createFeatureRuleExpression(); |
54 |
return rule;
|
55 |
} |
56 |
|
57 |
@Override
|
58 |
public void addItem(FeatureRule rule) { |
59 |
if( this.rules == null ) { |
60 |
return;
|
61 |
} |
62 |
this.rules.add(rule);
|
63 |
} |
64 |
|
65 |
@Override
|
66 |
public FeatureRule get(int position) { |
67 |
if( this.rules == null ) { |
68 |
return null; |
69 |
} |
70 |
return this.rules.get(position); |
71 |
} |
72 |
|
73 |
@Override
|
74 |
public Iterator<FeatureRule> iterator() { |
75 |
if( this.rules == null ) { |
76 |
return Collections.EMPTY_LIST.iterator(); |
77 |
} |
78 |
return this.rules.iterator(); |
79 |
} |
80 |
|
81 |
@Override
|
82 |
public int getRowCount() { |
83 |
if( this.rules == null ) { |
84 |
return 0; |
85 |
} |
86 |
return this.rules.size(); |
87 |
} |
88 |
|
89 |
@Override
|
90 |
public int getColumnCount() { |
91 |
return this.columnNames.length; |
92 |
} |
93 |
|
94 |
@Override
|
95 |
public String getColumnName(int columnIndex) { |
96 |
return this.columnNames[columnIndex]; |
97 |
} |
98 |
|
99 |
@Override
|
100 |
public Class<?> getColumnClass(int columnIndex) { |
101 |
return this.columnClases[columnIndex]; |
102 |
} |
103 |
|
104 |
@Override
|
105 |
public Object getValueAt(int rowIndex, int columnIndex) { |
106 |
if( this.rules == null ) { |
107 |
return null; |
108 |
} |
109 |
FeatureRule rule = this.rules.get(rowIndex);
|
110 |
switch(columnIndex) {
|
111 |
case COLUMN_NAME:
|
112 |
return rule.getName();
|
113 |
case COLUMN_AT_FINISH_EDITING:
|
114 |
return rule.checkAtFinishEditing();
|
115 |
case COLUMN_AT_INSERT:
|
116 |
return rule.checkAtUpdate();
|
117 |
default:
|
118 |
return null; |
119 |
|
120 |
} |
121 |
} |
122 |
|
123 |
|
124 |
} |