01: package net.sourceforge.squirrel_sql.plugins.hibernate.mapping;
02:
03: import net.sourceforge.squirrel_sql.fw.datasetviewer.IDataSet;
04: import net.sourceforge.squirrel_sql.fw.datasetviewer.DataSetException;
05: import net.sourceforge.squirrel_sql.fw.datasetviewer.DataSetDefinition;
06: import net.sourceforge.squirrel_sql.fw.datasetviewer.ColumnDisplayDefinition;
07: import net.sourceforge.squirrel_sql.fw.util.IMessageHandler;
08: import net.sourceforge.squirrel_sql.fw.util.StringManager;
09: import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
10:
11: public class DetailAttributeDataSet implements IDataSet {
12: private static final StringManager s_stringMgr = StringManagerFactory
13: .getStringManager(DetailAttributeDataSet.class);
14:
15: private static final int DISPLAY_WIDTH = 20;
16:
17: private DetailAttribute[] _attributes;
18: private int _curIx = -1;
19: private ColumnDisplayDefinition[] _columnDisplayDefinitions = new ColumnDisplayDefinition[] {
20: // i18n[HibernateAttribuiteDataSet.attrName=Attribute name]
21: new ColumnDisplayDefinition(DISPLAY_WIDTH, s_stringMgr
22: .getString("HibernateAttribuiteDataSet.attrName")),
23: // i18n[HibernateAttribuiteDataSet.attrClassName=Attribute class name]
24: new ColumnDisplayDefinition(
25: DISPLAY_WIDTH,
26: s_stringMgr
27: .getString("HibernateAttribuiteDataSet.attrClassName")),
28: // i18n[HibernateAttribuiteDataSet.identifier=Identifier]
29: new ColumnDisplayDefinition(DISPLAY_WIDTH, s_stringMgr
30: .getString("HibernateAttribuiteDataSet.identifier")),
31: // i18n[HibernateAttribuiteDataSet.dbTableName=Database table name]
32: new ColumnDisplayDefinition(
33: DISPLAY_WIDTH,
34: s_stringMgr
35: .getString("HibernateAttribuiteDataSet.dbTableName")),
36: // i18n[HibernateAttribuiteDataSet.tableCols=Table columns]
37: new ColumnDisplayDefinition(DISPLAY_WIDTH, s_stringMgr
38: .getString("HibernateAttribuiteDataSet.tableCols")) };
39:
40: public DetailAttributeDataSet(DetailAttribute[] attributes) {
41: _attributes = attributes;
42: }
43:
44: public int getColumnCount() throws DataSetException {
45: return _columnDisplayDefinitions.length;
46: }
47:
48: public DataSetDefinition getDataSetDefinition()
49: throws DataSetException {
50: return new DataSetDefinition(_columnDisplayDefinitions);
51: }
52:
53: public boolean next(IMessageHandler msgHandler)
54: throws DataSetException {
55: return ++_curIx < _attributes.length;
56: }
57:
58: public Object get(int columnIndex) throws DataSetException {
59: switch (columnIndex) {
60: case 0:
61: return _attributes[_curIx].getAttributeName();
62: case 1:
63: return _attributes[_curIx]
64: .getClassNameRegardingCollection();
65: case 2:
66: return _attributes[_curIx].isIdentifier();
67: case 3:
68: return _attributes[_curIx].getTableName();
69: case 4:
70: return _attributes[_curIx].getColumnNamesString();
71: default:
72: throw new IndexOutOfBoundsException("Invalid column index "
73: + columnIndex);
74: }
75: }
76: }
|