View Javadoc
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: CreateTopicDialog.java,v 1.3 2003/08/17 01:32:27 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.JOptionPane; 64 import javax.swing.JPanel; 65 import javax.swing.JSeparator; 66 import javax.swing.JTextField; 67 import javax.swing.KeyStroke; 68 import javax.swing.SwingConstants; 69 import javax.swing.SwingUtilities; 70 import javax.swing.border.Border; 71 import javax.swing.text.Keymap; 72 73 74 /*** 75 * A simple dialog to collect information for creating a topic 76 * 77 * @version $Revision: 1.3 $ $Date: 2003/08/17 01:32:27 $ 78 * @author <a href="mailto:mourikis@exolab.org">Jim Mourikis</a> 79 * @see AdminMgr 80 */ 81 public class CreateTopicDialog extends BaseDialog { 82 83 // All the gui objects for this dialog 84 private JPanel jPanel1; 85 private JButton okButton; 86 private JButton cancelButton; 87 private JPanel jPanel2; 88 private JSeparator jSeparator2; 89 private JLabel jLabel1; 90 91 // The one and only instance of this object. 92 static private CreateTopicDialog instance_; 93 94 /*** 95 * Creates new form TopicDialog 96 * 97 * @param parent The parent form. 98 */ 99 public CreateTopicDialog(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 topic name"); 115 displayText = new JTextField(); 116 jSeparator2 = new JSeparator(); 117 setTitle("Create Administered Topic"); 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 topic 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 // Have default button get the keypress event. 168 // This is broken with jdk1.3rc1 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 topic dialog box 176 */ 177 public void displayCreateTopic() { 178 displayText.setText(""); 179 setLocationRelativeTo(getParent()); 180 status_ = CANCELED; 181 setVisible(true); 182 183 SwingUtilities.invokeLater(new Runnable() { 184 185 public void run() { 186 cancelButton.requestFocus(); 187 } 188 } 189 ); 190 } 191 192 /*** 193 * Display rhe create durable consumer dialog box 194 */ 195 public void displayCreateConsumer() { 196 name_ = JOptionPane.showInputDialog 197 (getParent(), "Enter a unique consumer name", 198 "OpenJMS Consumer Creation", JOptionPane.PLAIN_MESSAGE); 199 if (name_ == null || name_.equals("")) { 200 status_ = CANCELED; 201 } else { 202 status_ = CONFIRMED; 203 } 204 } 205 206 /*** 207 * Get the one and only instance of this dialog. The dialog must first 208 * have been created with the create call below. 209 * 210 * @return TopicDialog the one and only instance 211 * 212 */ 213 public static CreateTopicDialog instance() { 214 return instance_; 215 } 216 217 /*** 218 * Create the one and only instance of the Topic Dialog. 219 * 220 * @param parent the parent of this dialog 221 * @return TopicDialog the one and only instance 222 * 223 */ 224 public static CreateTopicDialog create(JFrame parent) { 225 if (instance_ == null) { 226 instance_ = new CreateTopicDialog(parent); 227 } 228 return instance_; 229 } 230 }

This page was automatically generated by Maven