01: package net.sourceforge.squirrel_sql.plugins.hibernate.mapping;
02:
03: import net.sourceforge.squirrel_sql.fw.util.StringManager;
04: import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
05:
06: import javax.swing.*;
07: import java.awt.*;
08: import java.util.prefs.Preferences;
09:
10: public class MappedObjectPanel extends JPanel {
11: private static final StringManager s_stringMgr = StringManagerFactory
12: .getStringManager(MappedObjectPanel.class);
13:
14: JTree objectTree;
15: JCheckBox chkShowQualified;
16:
17: private JSplitPane _split;
18: private static final String PERF_KEY_OBJ_TAB_DIV_LOC = "Squirrel.hibernateplugin.objTabDivLoc";
19:
20: public MappedObjectPanel(JComponent detailComp) {
21: super (new BorderLayout());
22:
23: add(createTopPanel(), BorderLayout.NORTH);
24:
25: objectTree = new JTree();
26:
27: _split = new JSplitPane();
28:
29: _split.setLeftComponent(new JScrollPane(objectTree));
30: _split.setRightComponent(detailComp);
31:
32: add(_split, BorderLayout.CENTER);
33:
34: SwingUtilities.invokeLater(new Runnable() {
35: public void run() {
36: _split.setDividerLocation(Preferences.userRoot()
37: .getDouble(PERF_KEY_OBJ_TAB_DIV_LOC, 0.5));
38: }
39: });
40:
41: }
42:
43: private JPanel createTopPanel() {
44: JPanel ret = new JPanel(new GridBagLayout());
45:
46: GridBagConstraints gbc;
47:
48: gbc = new GridBagConstraints(0, 0, 1, 1, 0, 0,
49: GridBagConstraints.WEST, GridBagConstraints.NONE,
50: new Insets(5, 5, 5, 5), 0, 0);
51: // i18n[MappedObjectPanel.QualifiedNames=Show qualified names]
52: chkShowQualified = new JCheckBox(s_stringMgr
53: .getString("MappedObjectPanel.QualifiedNames"));
54:
55: ret.add(chkShowQualified, gbc);
56:
57: // dist
58: gbc = new GridBagConstraints(1, 0, 1, 1, 1, 1,
59: GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
60: new Insets(5, 5, 5, 5), 0, 0);
61: ret.add(new JPanel(), gbc);
62:
63: return ret;
64: }
65:
66: public void closing() {
67: Preferences.userRoot().putDouble(
68: PERF_KEY_OBJ_TAB_DIV_LOC,
69: ((double) _split.getDividerLocation())
70: / ((double) _split.getWidth()));
71: }
72: }
|