1 /*
2 * UrlDialog.java
3 *
4 * Copyright (c) 2002 Raben Systems, Inc. All Rights Reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * Neither the name of Raben Systems, Inc. nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 * Created on March 20, 2002, 6:16 PM
32 */
33
34 package com.raben.tools.xslteditor;
35 import java.net.PasswordAuthentication;
36 /***
37 *
38 * @author Vern Raben
39 */
40 public class UrlDialog extends javax.swing.JDialog {
41 /*** A return status code - returned if Cancel button has been pressed */
42 public static final int RET_CANCEL = 0;
43 /*** A return status code - returned if OK button has been pressed */
44 public static final int RET_OK = 1;
45
46 /*** Creates new form UrlDialog */
47 public UrlDialog(java.awt.Frame parent, boolean modal) {
48 super(parent, modal);
49 initComponents();
50 }
51
52 /*** @return the return status of this dialog - one of RET_OK or RET_CANCEL */
53 public int getReturnStatus() {
54 return returnStatus;
55 }
56
57 /*** This method is called from within the constructor to
58 * initialize the form.
59 * WARNING: Do NOT modify this code. The content of this method is
60 * always regenerated by the Form Editor.
61 */
62 private void initComponents() {//GEN-BEGIN:initComponents
63 jPanel1 = new javax.swing.JPanel();
64 jLabel3 = new javax.swing.JLabel();
65 urlTextField = new javax.swing.JTextField();
66 jPanel2 = new javax.swing.JPanel();
67 jLabel1 = new javax.swing.JLabel();
68 userNameTextField = new javax.swing.JTextField();
69 jPanel3 = new javax.swing.JPanel();
70 jLabel2 = new javax.swing.JLabel();
71 passwordTextField = new javax.swing.JPasswordField();
72 buttonPanel = new javax.swing.JPanel();
73 okButton = new javax.swing.JButton();
74 cancelButton = new javax.swing.JButton();
75
76 getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.Y_AXIS));
77
78 setTitle("Enter URL");
79 addWindowListener(new java.awt.event.WindowAdapter() {
80 public void windowClosing(java.awt.event.WindowEvent evt) {
81 closeDialog(evt);
82 }
83 });
84
85 jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
86
87 jLabel3.setText("URL:");
88 jPanel1.add(jLabel3);
89
90 urlTextField.setColumns(30);
91 urlTextField.setText("http://www.spaceweather.info/swData/servlet1?");
92 jPanel1.add(urlTextField);
93
94 getContentPane().add(jPanel1);
95
96 jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
97
98 jLabel1.setText("Username:");
99 jPanel2.add(jLabel1);
100
101 userNameTextField.setColumns(20);
102 jPanel2.add(userNameTextField);
103
104 getContentPane().add(jPanel2);
105
106 jPanel3.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
107
108 jLabel2.setText("Password:");
109 jPanel3.add(jLabel2);
110
111 passwordTextField.setColumns(20);
112 jPanel3.add(passwordTextField);
113
114 getContentPane().add(jPanel3);
115
116 buttonPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
117
118 okButton.setText("OK");
119 okButton.addActionListener(new java.awt.event.ActionListener() {
120 public void actionPerformed(java.awt.event.ActionEvent evt) {
121 okButtonActionPerformed(evt);
122 }
123 });
124
125 buttonPanel.add(okButton);
126
127 cancelButton.setText("Cancel");
128 cancelButton.addActionListener(new java.awt.event.ActionListener() {
129 public void actionPerformed(java.awt.event.ActionEvent evt) {
130 cancelButtonActionPerformed(evt);
131 }
132 });
133
134 buttonPanel.add(cancelButton);
135
136 getContentPane().add(buttonPanel);
137
138 pack();
139 }//GEN-END:initComponents
140
141 private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
142 firePropertyChange(propertyName,null,urlTextField.getText());
143 doClose(RET_OK);
144 }//GEN-LAST:event_okButtonActionPerformed
145
146 private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
147 doClose(RET_CANCEL);
148 }//GEN-LAST:event_cancelButtonActionPerformed
149
150 /*** Closes the dialog */
151 private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
152 doClose(RET_CANCEL);
153 }//GEN-LAST:event_closeDialog
154
155 private void doClose(int retStatus) {
156 returnStatus = retStatus;
157 setVisible(false);
158 dispose();
159 }
160
161
162 /***
163 * @param args the command line arguments
164 */
165 public static void main(String args[]) {
166 new UrlDialog(new javax.swing.JFrame(), true).show();
167 }
168
169 /***
170 * Set the name of the property change event that will be fired when
171 * the user presses the 'OK' button
172 * @param propertyName String Name of the event
173 */
174 public void setPropertyName(java.lang.String propertyName) {
175 this.propertyName=propertyName;
176 }
177
178 public void setUrl(java.lang.String urlStr) {
179 urlTextField.setText(urlStr);
180 }
181
182 public PasswordAuthentication getAuthentication() {
183 return new PasswordAuthentication(userNameTextField.getText(), passwordTextField.getPassword());
184 }
185
186 // Variables declaration - do not modify//GEN-BEGIN:variables
187 private javax.swing.JPanel jPanel1;
188 private javax.swing.JLabel jLabel3;
189 private javax.swing.JTextField urlTextField;
190 private javax.swing.JPanel jPanel2;
191 private javax.swing.JLabel jLabel1;
192 private javax.swing.JTextField userNameTextField;
193 private javax.swing.JPanel jPanel3;
194 private javax.swing.JLabel jLabel2;
195 private javax.swing.JPasswordField passwordTextField;
196 private javax.swing.JPanel buttonPanel;
197 private javax.swing.JButton okButton;
198 private javax.swing.JButton cancelButton;
199 // End of variables declaration//GEN-END:variables
200
201 private int returnStatus = RET_CANCEL;
202 private String propertyName="url";
203 }
This page was automatically generated by Maven