01: /*
02: * CreateNewConnection.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.gui.MainWindow;
16: import workbench.resource.ResourceMgr;
17:
18: /**
19: *
20: * @author support@sql-workbench.net
21: */
22: public class CreateNewConnection extends WbAction {
23: private MainWindow window;
24:
25: public CreateNewConnection(MainWindow client) {
26: this .initMenuDefinition("MnuTxtCreateNewConn");
27: this .setMenuItemName(ResourceMgr.MNU_TXT_FILE);
28: this .setEnabled(false);
29: this .window = client;
30: checkState();
31: }
32:
33: @Override
34: public void executeAction(ActionEvent e) {
35: if (this .window == null)
36: return;
37: if (!window.canUseSeparateConnection())
38: return;
39: this .window.createNewConnectionForCurrentPanel();
40: }
41:
42: public void checkState() {
43: if (this .window == null) {
44: this .setEnabled(false);
45: } else {
46: this.setEnabled(window.canUseSeparateConnection()
47: && !window.usesSeparateConnection());
48: }
49: }
50:
51: }
|