001: /*
002: * Created on Sep 29, 2004
003: *
004: * @author ctaylor
005: *
006: */
007: package com.pk.script.ui;
008:
009: import java.awt.Color;
010: import java.awt.GridBagConstraints;
011: import java.awt.GridBagLayout;
012: import java.awt.Insets;
013: import java.awt.event.ActionListener;
014:
015: import javax.swing.BorderFactory;
016: import javax.swing.JButton;
017: import javax.swing.JLabel;
018: import javax.swing.JPanel;
019: import javax.swing.JTextField;
020:
021: /**
022: * @author ctaylor
023: *
024: */
025: public class ConnectionPanel extends JPanel {
026: /**
027: *
028: */
029: private static final long serialVersionUID = 4254774480356323583L;
030: private JTextField connNameLabel;
031: private JTextField userNameLabel;
032: private JButton newConnectionButton;
033: private JButton loadButton;
034: private JButton pasteButton;
035: private JButton saveButton;
036: private JButton runButton;
037: private JButton closeButton;
038: private JButton commitButton;
039: private JButton rollbackButton;
040:
041: private ActionListener actionListener;
042:
043: public ConnectionPanel(ActionListener argActionListener) {
044: actionListener = argActionListener;
045: this .setLayout(new GridBagLayout());
046: GridBagConstraints gbc = new GridBagConstraints();
047: gbc.anchor = GridBagConstraints.NORTH;
048: gbc.insets = new Insets(6, 5, 6, 5);
049:
050: JLabel label = null;
051: gbc.gridx = 0;
052: gbc.gridy = 0;
053: label = new JLabel("Connection Name:", JLabel.LEFT);
054: this .add(label, gbc);
055:
056: gbc.gridy++;
057: label = new JLabel("User Name:", JLabel.LEFT);
058: this .add(label, gbc);
059:
060: gbc.gridx = 1;
061: gbc.gridy = 0;
062:
063: connNameLabel = new JTextField(10);
064: connNameLabel.setEditable(false);
065: connNameLabel.setBorder(BorderFactory
066: .createLineBorder(Color.black));
067: this .add(connNameLabel, gbc);
068:
069: gbc.gridy++;
070: userNameLabel = new JTextField(10);
071: userNameLabel.setEditable(false);
072: userNameLabel.setBorder(BorderFactory
073: .createLineBorder(Color.black));
074: this .add(userNameLabel, gbc);
075:
076: GridBagConstraints gbc2 = new GridBagConstraints();
077: gbc2.anchor = GridBagConstraints.CENTER;
078: gbc2.insets = new Insets(6, 5, 6, 5);
079: gbc2.gridx = 2;
080: gbc2.gridy = 0;
081:
082: this .setBorder(BorderFactory.createLineBorder(Color.black));
083: newConnectionButton = new JButton("New Connection");
084: newConnectionButton.addActionListener(actionListener);
085: this .add(newConnectionButton, gbc2);
086:
087: gbc2.gridx++;
088: loadButton = new JButton("Load Script");
089: loadButton
090: .setToolTipText("Load a script file into the script runner");
091: loadButton.addActionListener(actionListener);
092: this .add(loadButton, gbc2);
093:
094: gbc2.gridx++;
095: saveButton = new JButton("Save Script");
096: saveButton.setToolTipText("Save current script to a file");
097: saveButton.addActionListener(actionListener);
098: this .add(saveButton, gbc2);
099:
100: gbc2.gridx++;
101: pasteButton = new JButton("Paste Script");
102: pasteButton
103: .setToolTipText("Paste a script or command from the clipboard");
104: pasteButton.addActionListener(actionListener);
105: this .add(pasteButton, gbc2);
106:
107: gbc2.gridx = 2;
108: gbc2.gridy = 1;
109:
110: runButton = new JButton("Run");
111: runButton.setToolTipText("Run current script");
112: runButton.addActionListener(actionListener);
113: this .add(runButton, gbc2);
114:
115: gbc2.gridx++;
116:
117: commitButton = new JButton("Commit");
118: commitButton.setToolTipText("Commit current transaction");
119: commitButton.addActionListener(actionListener);
120: this .add(commitButton, gbc2);
121:
122: gbc2.gridx++;
123: rollbackButton = new JButton("Rollback");
124: rollbackButton.setToolTipText("Rollback current transaction");
125: rollbackButton.addActionListener(actionListener);
126: this .add(rollbackButton, gbc2);
127:
128: gbc2.gridx++;
129: closeButton = new JButton("Close");
130: closeButton.setToolTipText("Close script runner");
131: closeButton.addActionListener(actionListener);
132: this .add(closeButton, gbc2);
133:
134: }
135:
136: /**
137: * @return Returns the connNameLabel.
138: */
139: public JTextField getConnNameLabel() {
140: return connNameLabel;
141: }
142:
143: /**
144: * @return Returns the newConnectionButton.
145: */
146: public JButton getNewConnectionButton() {
147: return newConnectionButton;
148: }
149:
150: /**
151: * @return Returns the userNameLabel.
152: */
153: public JTextField getUserNameLabel() {
154: return userNameLabel;
155: }
156:
157: /**
158: * @param actionListener The actionListener to set.
159: */
160: public void setActionListener(ActionListener actionListener) {
161: this .actionListener = actionListener;
162: }
163:
164: /**
165: * @return Returns the loadButton.
166: */
167: public JButton getLoadButton() {
168: return loadButton;
169: }
170:
171: /**
172: * @return Returns the pasteButton.
173: */
174: public JButton getPasteButton() {
175: return pasteButton;
176: }
177:
178: /**
179: * @return Returns the saveButton.
180: */
181: public JButton getSaveButton() {
182: return saveButton;
183: }
184:
185: /**
186: * @return Returns the runButton.
187: */
188: public JButton getRunButton() {
189: return runButton;
190: }
191:
192: /**
193: * @return Returns the closeButton.
194: */
195: public JButton getCloseButton() {
196: return closeButton;
197: }
198:
199: /**
200: * @param closeButton The closeButton to set.
201: */
202: public void setCloseButton(JButton closeButton) {
203: this .closeButton = closeButton;
204: }
205:
206: /**
207: * @return Returns the commitButton.
208: */
209: public JButton getCommitButton() {
210: return commitButton;
211: }
212:
213: /**
214: * @return Returns the rollbackButton.
215: */
216: public JButton getRollbackButton() {
217: return rollbackButton;
218: }
219: }
|