01: package net.sourceforge.squirrel_sql.plugins.i18n;
02:
03: import net.sourceforge.squirrel_sql.fw.util.StringManager;
04: import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
05:
06: import javax.swing.table.DefaultTableModel;
07: import java.util.ArrayList;
08: import java.util.Arrays;
09:
10: public class BundlesTableModel extends DefaultTableModel {
11:
12: private static final StringManager s_stringMgr = StringManagerFactory
13: .getStringManager(I18nProps.class);
14:
15: private I18nBundle[] _bundles;
16:
17: public BundlesTableModel() {
18: addColumn(s_stringMgr.getString("i18n.bundle"));
19: // i18n[i18n.bundle=Bundle]
20: addColumn(s_stringMgr.getString("i18n.missingTarnslation"));
21: // i18n[i18n.missingTarnslation=Missing translations]
22:
23: }
24:
25: public int getColumnCount() {
26: return 2;
27: }
28:
29: public boolean isCellEditable(int row, int column) {
30: return false;
31: }
32:
33: public int getRowCount() {
34: if (null == _bundles) {
35: return 0;
36: } else {
37: return _bundles.length;
38: }
39: }
40:
41: public Object getValueAt(int row, int column) {
42: if (0 == column) {
43: return _bundles[row].getName();
44: } else if (1 == column) {
45: return _bundles[row].getMissingTranslationsCount();
46: } else {
47: throw new IllegalArgumentException("Unknown column "
48: + column);
49: }
50:
51: }
52:
53: public void setBundles(I18nBundle[] bundles) {
54: _bundles = bundles;
55:
56: Arrays.sort(_bundles);
57:
58: fireTableDataChanged();
59: }
60:
61: public I18nBundle[] getBundlesForRows(int[] rows) {
62: ArrayList<I18nBundle> ret = new ArrayList<I18nBundle>(
63: rows.length);
64:
65: for (int i = 0; i < rows.length; i++) {
66: ret.add(_bundles[rows[i]]);
67: }
68:
69: return ret.toArray(new I18nBundle[ret.size()]);
70: }
71: }
|