1 /***
2 * Redistribution and use of this software and associated documentation
3 * ("Software"), with or without modification, are permitted provided
4 * that the following conditions are met:
5 *
6 * 1. Redistributions of source code must retain copyright
7 * statements and notices. Redistributions must also contain a
8 * copy of this document.
9 *
10 * 2. Redistributions in binary form must reproduce the
11 * above copyright notice, this list of conditions and the
12 * following disclaimer in the documentation and/or other
13 * materials provided with the distribution.
14 *
15 * 3. The name "Exolab" must not be used to endorse or promote
16 * products derived from this Software without prior written
17 * permission of Exoffice Technologies. For written permission,
18 * please contact info@exolab.org.
19 *
20 * 4. Products derived from this Software may not be called "Exolab"
21 * nor may "Exolab" appear in their names without prior written
22 * permission of Exoffice Technologies. Exolab is a registered
23 * trademark of Exoffice Technologies.
24 *
25 * 5. Due credit should be given to the Exolab Project
26 * (http://www.exolab.org/).
27 *
28 * THIS SOFTWARE IS PROVIDED BY EXOFFICE TECHNOLOGIES AND CONTRIBUTORS
29 * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
30 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
31 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
32 * EXOFFICE TECHNOLOGIES OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
33 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
34 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
35 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
37 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
39 * OF THE POSSIBILITY OF SUCH DAMAGE.
40 *
41 * Copyright 2000 (C) Exoffice Technologies Inc. All Rights Reserved.
42 *
43 * $Id: CreateQueueDialog.java,v 1.1 2004/11/26 01:51:15 tanderson Exp $
44 *
45 * Date Author Changes
46 * $Date jimm Created
47 */
48
49 package org.exolab.jms.tools.admin;
50
51 import java.awt.BorderLayout;
52 import java.awt.FlowLayout;
53 import java.awt.event.ActionEvent;
54 import java.awt.event.ActionListener;
55 import java.awt.event.KeyEvent;
56 import java.awt.event.WindowAdapter;
57 import java.awt.event.WindowEvent;
58
59 import javax.swing.BorderFactory;
60 import javax.swing.JButton;
61 import javax.swing.JFrame;
62 import javax.swing.JLabel;
63 import javax.swing.JPanel;
64 import javax.swing.JSeparator;
65 import javax.swing.JTextField;
66 import javax.swing.KeyStroke;
67 import javax.swing.SwingConstants;
68 import javax.swing.SwingUtilities;
69 import javax.swing.border.Border;
70 import javax.swing.text.Keymap;
71
72
73 /***
74 * A simple dialog to collect information for creating a queue
75 *
76 * @version $Revision: 1.1 $ $Date: 2004/11/26 01:51:15 $
77 * @author <a href="mailto:mourikis@exolab.org">Jim Mourikis</a>
78 * @see AdminMgr
79 */
80 public class CreateQueueDialog extends BaseDialog {
81
82
83 private JPanel jPanel1;
84 private JButton okButton;
85 private JButton cancelButton;
86 private JPanel jPanel2;
87 private JSeparator jSeparator2;
88 private JLabel jLabel1;
89
90
91 static private CreateQueueDialog instance_;
92
93
94 /***
95 * Creates new form QueueDialog
96 *
97 * @param parent The parent form.
98 */
99 public CreateQueueDialog(JFrame parent) {
100 super(parent);
101 }
102
103 /***
104 * Create all the gui components that comprise this form, and setup all
105 * action handlers.
106 *
107 */
108 protected void initComponents() {
109 jPanel1 = new JPanel();
110 okButton = new JButton();
111 cancelButton = new JButton();
112 jPanel2 = new JPanel();
113 jLabel1 = new JLabel();
114 jLabel1.setText("Enter the queue name");
115 displayText = new JTextField();
116 jSeparator2 = new JSeparator();
117 setTitle("Create Administered Queue");
118 setModal(true);
119 setResizable(true);
120 addWindowListener(new WindowAdapter() {
121
122 public void windowClosing(WindowEvent evt) {
123 closeDialog(evt);
124 }
125 }
126 );
127
128 jPanel1.setLayout(new FlowLayout(1, 50, 10));
129 okButton.setToolTipText("Press to confirm Action");
130 okButton.setText("OK");
131 getRootPane().setDefaultButton(okButton);
132 jPanel1.add(okButton);
133 cancelButton.setToolTipText("Press to abort Action");
134 cancelButton.setText("Cancel");
135 jPanel1.add(cancelButton);
136 getContentPane().add(jPanel1, BorderLayout.SOUTH);
137 jPanel2.setLayout(new BorderLayout(0, 15));
138 displayText.setToolTipText
139 ("Enter the unique queue name for this object");
140
141 Border loweredbevel = BorderFactory.createLoweredBevelBorder();
142 displayText.setBorder(loweredbevel);
143 displayText.setEditable(true);
144 displayText.setText("");
145 displayText.setHorizontalAlignment(SwingConstants.LEFT);
146 jPanel2.add(jLabel1, BorderLayout.NORTH);
147 jPanel2.add(displayText, BorderLayout.CENTER);
148 jPanel2.add(jSeparator2, BorderLayout.SOUTH);
149 getContentPane().add(jPanel2, BorderLayout.CENTER);
150
151 okButton.addActionListener(new ActionListener() {
152
153 public void actionPerformed(ActionEvent evt) {
154 confirm();
155 }
156 }
157 );
158
159 cancelButton.addActionListener(new ActionListener() {
160
161 public void actionPerformed(ActionEvent evt) {
162 cancel();
163 }
164 }
165 );
166
167
168
169 KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
170 Keymap km = displayText.getKeymap();
171 km.removeKeyStrokeBinding(enter);
172 }
173
174 /***
175 * Display the create queue dialog box
176 */
177 public void displayCreateQueue() {
178 displayText.setText("");
179
180 setLocationRelativeTo(getParent());
181 status_ = CANCELED;
182 setVisible(true);
183
184 SwingUtilities.invokeLater(new Runnable() {
185
186 public void run() {
187 cancelButton.requestFocus();
188 }
189 }
190 );
191 }
192
193 /***
194 * Get the one and only instance of this dialog. The dialog must first
195 * have been created with the create call below.
196 *
197 * @return QueueDialog the one and only instance
198 *
199 */
200 public static CreateQueueDialog instance() {
201 return instance_;
202 }
203
204 /***
205 * Create the one and only instance of the Queue Dialog.
206 *
207 * @param parent the parent of this dialog
208 * @return QueueDialog the one and only instance
209 *
210 */
211 public static CreateQueueDialog create(JFrame parent) {
212 if (instance_ == null) {
213 instance_ = new CreateQueueDialog(parent);
214 }
215 return instance_;
216 }
217 }