01: /*
02: * AppendResultsAction.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 javax.swing.JToggleButton;
15: import javax.swing.JToolBar;
16: import workbench.gui.components.WbToolbarButton;
17: import workbench.gui.sql.SqlPanel;
18: import workbench.resource.ResourceMgr;
19:
20: /**
21: * Action to toggle the if running statements should replace the current
22: * results or simply add a new result tab to SqlPanel
23: *
24: * @author support@sql-workbench.net
25: */
26: public class AppendResultsAction extends CheckBoxAction {
27: private SqlPanel client;
28: private JToggleButton toggleButton;
29:
30: public AppendResultsAction(SqlPanel panel) {
31: super ("MnuTxtToggleAppendResults", null);
32: this .client = panel;
33: this .setMenuItemName(ResourceMgr.MNU_TXT_SQL);
34: this .setSwitchedOn(client.getAppendResults());
35: }
36:
37: public void setSwitchedOn(boolean aFlag) {
38: super .setSwitchedOn(aFlag);
39: if (this .toggleButton != null) {
40: this .toggleButton.setSelected(this .isSwitchedOn());
41: }
42: client.setAppendResults(this .isSwitchedOn());
43: }
44:
45: public JToggleButton getButton() {
46: if (this .toggleButton == null) {
47: this .toggleButton = new JToggleButton(this );
48: this .toggleButton.setText(null);
49: this .toggleButton.setMargin(WbToolbarButton.MARGIN);
50: this .toggleButton.setIcon(ResourceMgr
51: .getImage("AppendResult"));
52: this .toggleButton.setSelected(this .isSwitchedOn());
53: }
54: return this .toggleButton;
55: }
56:
57: public void addToToolbar(JToolBar aToolbar) {
58: aToolbar.add(this.getButton());
59: }
60:
61: }
|