01: package net.sourceforge.squirrel_sql.plugins.hibernate.mapping;
02:
03: import net.sourceforge.squirrel_sql.fw.datasetviewer.EmptyDataSet;
04: import net.sourceforge.squirrel_sql.fw.datasetviewer.DataSetException;
05: import net.sourceforge.squirrel_sql.fw.datasetviewer.HashtableDataSet;
06:
07: import javax.swing.*;
08:
09: public class DetailPanelController {
10: private DetailPanel _detailPanel;
11:
12: public DetailPanelController() {
13: _detailPanel = new DetailPanel();
14: }
15:
16: public JComponent getDetailComponent() {
17: return _detailPanel;
18: }
19:
20: void clearDetail() {
21: try {
22: _detailPanel.tblDetails.show(new EmptyDataSet());
23: } catch (DataSetException e) {
24: throw new RuntimeException(e);
25: }
26: }
27:
28: public void selectionChanged(Object userObject) {
29: try {
30: if (userObject instanceof MappingRoot) {
31: MappingRoot root = (MappingRoot) userObject;
32:
33: if (0 == root.getMappingProperties().size()) {
34: _detailPanel.tblDetails.show(new EmptyDataSet());
35: } else {
36: _detailPanel.tblDetails.show(new HashtableDataSet(
37: root.getMappingProperties()));
38: }
39: } else if (userObject instanceof MappedClassInfoTreeWrapper) {
40: MappedClassInfoTreeWrapper mappedClassInfoTreeWrapper = (MappedClassInfoTreeWrapper) userObject;
41: MappedClassInfo mci = mappedClassInfoTreeWrapper
42: .getMappedClassInfo();
43: DetailAttribute[] attributes = DetailAttribute
44: .createDetailtAttributes(mci.getAttributes());
45: _detailPanel.tblDetails
46: .show(new DetailAttributeDataSet(attributes));
47: }
48: } catch (DataSetException e) {
49: throw new RuntimeException(e);
50: }
51:
52: }
53: }
|