01: /*
02: * DisconnectTabAction.java
03: *
04: * This file is part of SQL Workbench/J, http://www.sql-workbench.net
05: *
06: * Copyright 2002-2008, Thomas Kellerer
07: * No part of this code maybe reused without the permission of the author
08: *
09: * To contact the author please send an email to: support@sql-workbench.net
10: *
11: */
12: package workbench.gui.actions;
13:
14: import java.awt.event.ActionEvent;
15: import workbench.db.ConnectionProfile;
16: import workbench.gui.MainWindow;
17: import workbench.resource.ResourceMgr;
18:
19: /**
20: *
21: * @author support@sql-workbench.net
22: */
23: public class DisconnectTabAction extends WbAction {
24: private MainWindow window;
25:
26: public DisconnectTabAction(MainWindow client) {
27: this .initMenuDefinition("MnuTxtDisconnectTab");
28: this .setMenuItemName(ResourceMgr.MNU_TXT_FILE);
29: this .setEnabled(false);
30: this .window = client;
31: checkState();
32: }
33:
34: @Override
35: public void executeAction(ActionEvent e) {
36: if (this .window == null)
37: return;
38: ConnectionProfile prof = window.getCurrentProfile();
39: if (prof.getUseSeparateConnectionPerTab())
40: return;
41: this .window.disconnectCurrentPanel();
42: }
43:
44: public void checkState() {
45: if (this .window == null) {
46: this .setEnabled(false);
47: } else {
48: this.setEnabled(window.canUseSeparateConnection()
49: && window.usesSeparateConnection());
50: }
51: }
52:
53: }
|