KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > jaxrpc > client > ui > DownloadWsdlPanel


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.websvc.jaxrpc.client.ui;
21
22 import org.openide.DialogDescriptor;
23 import org.openide.util.NbBundle;
24 import org.netbeans.modules.websvc.core.WsdlRetriever;
25
26 /**
27  *
28  * @author Peter Williams
29  */

30 public class DownloadWsdlPanel extends javax.swing.JPanel JavaDoc implements WsdlRetriever.MessageReceiver {
31
32     private DialogDescriptor descriptor;
33     private WsdlRetriever retriever;
34     private String JavaDoc newWsdlUrl;
35     private String JavaDoc downloadMsg;
36     private boolean downloadOk;
37
38     public DownloadWsdlPanel(String JavaDoc newWsdlUrl) {
39         this.newWsdlUrl = newWsdlUrl;
40         this.retriever = null;
41         this.downloadMsg = " "; // NOI18N
42
this.downloadOk = false;
43         
44         initComponents();
45     }
46
47     /** This method is called from within the constructor to
48      * initialize the form.
49      * WARNING: Do NOT modify this code. The content of this method is
50      * always regenerated by the Form Editor.
51      */

52     private void initComponents() {//GEN-BEGIN:initComponents
53
java.awt.GridBagConstraints JavaDoc gridBagConstraints;
54
55         jLblStatusLabel = new javax.swing.JLabel JavaDoc();
56         jTxtStatus = new javax.swing.JLabel JavaDoc();
57
58         setLayout(new java.awt.GridBagLayout JavaDoc());
59
60         jLblStatusLabel.setText(NbBundle.getMessage(DownloadWsdlPanel.class, "LBL_Status"));
61         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
62         gridBagConstraints.insets = new java.awt.Insets JavaDoc(11, 11, 11, 4);
63         add(jLblStatusLabel, gridBagConstraints);
64
65         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
66         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
67         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
68         gridBagConstraints.weightx = 1.0;
69         gridBagConstraints.insets = new java.awt.Insets JavaDoc(11, 0, 11, 11);
70         add(jTxtStatus, gridBagConstraints);
71
72     }//GEN-END:initComponents
73

74     
75     // Variables declaration - do not modify//GEN-BEGIN:variables
76
private javax.swing.JLabel JavaDoc jLblStatusLabel;
77     private javax.swing.JLabel JavaDoc jTxtStatus;
78     // End of variables declaration//GEN-END:variables
79

80     public void addNotify() {
81         super.addNotify();
82         
83         retriever = new WsdlRetriever(this, newWsdlUrl);
84         new Thread JavaDoc(retriever).start();
85     }
86     
87     public void setDescriptor(DialogDescriptor descriptor) {
88         this.descriptor = descriptor;
89         descriptor.setValid(downloadOk);
90     }
91
92     public byte [] getWsdl() {
93         byte [] result = null;
94         
95         if(retriever.getState() == WsdlRetriever.STATUS_COMPLETE) {
96             result = retriever.getWsdl();
97         }
98         
99         return result;
100     }
101     
102     public void setWsdlDownloadMessage(String JavaDoc m) {
103         downloadMsg = m;
104         jTxtStatus.setText(downloadMsg);
105         
106         if(retriever.getState() == WsdlRetriever.STATUS_COMPLETE) {
107             downloadOk = true;
108
109             // !PW FIXME Find a way to press <OK> button from here.
110
}
111         
112         descriptor.setValid(downloadOk);
113     }
114
115     public java.awt.Dimension JavaDoc getPreferredSize() {
116         java.awt.Dimension JavaDoc result = super.getPreferredSize();
117         if(result.width < 240) {
118             result.width = 240;
119         }
120         return result;
121     }
122 }
123
Popular Tags