01: package com.vividsolutions.jump.workbench.ui.plugin.datastore;
02:
03: import java.awt.BorderLayout;
04:
05: import javax.swing.JCheckBoxMenuItem;
06: import javax.swing.JComponent;
07:
08: import com.vividsolutions.jump.I18N;
09: import com.vividsolutions.jump.util.Blackboard;
10: import com.vividsolutions.jump.workbench.datastore.ConnectionManager;
11: import com.vividsolutions.jump.workbench.plugin.EnableCheck;
12: import com.vividsolutions.jump.workbench.plugin.PlugInContext;
13: import com.vividsolutions.jump.workbench.ui.GUIUtil;
14: import com.vividsolutions.jump.workbench.ui.MenuNames;
15: import com.vividsolutions.jump.workbench.ui.plugin.FeatureInstaller;
16: import com.vividsolutions.jump.workbench.ui.toolbox.ToolboxDialog;
17: import com.vividsolutions.jump.workbench.ui.toolbox.ToolboxPlugIn;
18:
19: public class ConnectionManagerToolboxPlugIn extends ToolboxPlugIn {
20:
21: private static final String INSTANCE_KEY = ConnectionManagerToolboxPlugIn.class
22: .getName()
23: + " - INSTANCE";
24:
25: private ConnectionManagerToolboxPlugIn() {
26: }
27:
28: public String getName() {
29: // Specify name explicitly, as auto-name-generator
30: // says "Connection Manager Toolbox" [Jon Aquino 2005-03-14]
31: return I18N
32: .get("jump.workbench.ui.plugin.datastore.ConnectionManagerToolboxPlugIn.Connection-Manager");
33: }
34:
35: public static final ConnectionManagerToolboxPlugIn instance(
36: Blackboard blackboard) {
37: if (blackboard.get(INSTANCE_KEY) == null) {
38: blackboard.put(INSTANCE_KEY,
39: new ConnectionManagerToolboxPlugIn());
40: }
41: return (ConnectionManagerToolboxPlugIn) blackboard
42: .get(INSTANCE_KEY);
43: }
44:
45: public void initialize(final PlugInContext context)
46: throws Exception {
47: if (1 == 1) {
48: throw new UnsupportedOperationException(
49: "To do: fix: ConnectionManagerToolbox does not stay in sync with ConnectionManager object. Implement eventing. [Jon Aquino 2005-03-24]");
50: }
51: new FeatureInstaller(context.getWorkbenchContext())
52: .addMainMenuItem(this ,
53: (new String[] { MenuNames.VIEW }), getName()
54: + "...{pos:1}", true, null,
55: new EnableCheck() {
56: public String check(JComponent component) {
57: ((JCheckBoxMenuItem) component)
58: .setSelected(getToolbox(
59: context
60: .getWorkbenchContext())
61: .isVisible());
62: return null;
63: }
64: });
65: }
66:
67: protected void initializeToolbox(ToolboxDialog toolbox) {
68: ConnectionManagerPanel connectionManagerPanel = new ConnectionManagerPanel(
69: ConnectionManager.instance(toolbox.getContext()),
70: toolbox.getContext().getRegistry(), toolbox
71: .getContext().getErrorHandler(), toolbox
72: .getContext());
73: toolbox.getCenterPanel().add(connectionManagerPanel,
74: BorderLayout.CENTER);
75: toolbox.setInitialLocation(new GUIUtil.Location(20, true, 20,
76: false));
77: }
78:
79: }
|