KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > core > jaxws > nodes > RefreshWsDialog


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.core.jaxws.nodes;
21
22 import org.openide.DialogDisplayer;
23 import org.openide.NotifyDescriptor;
24 import org.openide.util.NbBundle;
25
26 /**
27  *
28  * @author Martin Adamek
29  */

30 public class RefreshWsDialog extends javax.swing.JPanel JavaDoc {
31     
32     static final int CLOSE = 0;
33     static final int DO_NOTHING = 1;
34     static final int DOWNLOAD_WSDL = 2;
35     static final int REGENERATE_IMPL_CLASS = 3;
36     static final int DO_ALL = 4;
37     
38     private String JavaDoc implClass,url;
39     private boolean downloadWsdl;
40     
41     private RefreshWsDialog(boolean downloadWsdl, String JavaDoc implClass, String JavaDoc url) {
42         this.downloadWsdl=downloadWsdl;
43         this.implClass = implClass;
44         this.url=url;
45         initComponents();
46         // display the delete_wsdl checkbox only if wsdl exists
47
if (!downloadWsdl) {
48             downloadWsdlCheckBox.setVisible(false);
49             jLabel1.setVisible(false);
50         }
51     }
52  
53     public static int open(boolean downloadWsdl, String JavaDoc implClass, String JavaDoc url) {
54         String JavaDoc title = NbBundle.getMessage(RefreshWsDialog.class, "MSG_ConfirmServiceRefresh");
55         RefreshWsDialog delDialog = new RefreshWsDialog(downloadWsdl, implClass, url);
56         NotifyDescriptor desc = new NotifyDescriptor.Confirmation(delDialog, title, NotifyDescriptor.YES_NO_OPTION);
57         Object JavaDoc result = DialogDisplayer.getDefault().notify(desc);
58         if (result.equals(NotifyDescriptor.CLOSED_OPTION)) {
59             return CLOSE;
60         } else if (result.equals(NotifyDescriptor.NO_OPTION)) {
61             return CLOSE;
62         } else if (delDialog.downloadWsdl() && delDialog.regenerate()) {
63             return DO_ALL;
64         } else if (delDialog.downloadWsdl()) {
65             return DOWNLOAD_WSDL;
66         } else if (delDialog.regenerate()) {
67             return REGENERATE_IMPL_CLASS;
68         } else return DO_NOTHING;
69         
70     }
71     
72     /**
73      * This prompts the user if he/she wants to regenerate the impl bean
74      * but does not give a choice as to refreshing the nodes (i.e. the nodes are
75      * always refreshed.
76      */

77     public static int openWithOKButtonOnly(boolean downloadWsdl, String JavaDoc implClass, String JavaDoc url){
78         String JavaDoc title = NbBundle.getMessage(RefreshWsDialog.class, "MSG_ConfirmServiceRefresh");
79         RefreshWsDialog delDialog = new RefreshWsDialog(downloadWsdl, implClass, url);
80         NotifyDescriptor desc = new NotifyDescriptor.Message(delDialog, NotifyDescriptor.INFORMATION_MESSAGE);
81         DialogDisplayer.getDefault().notify(desc);
82         if(delDialog.regenerate()){
83             return REGENERATE_IMPL_CLASS;
84         }
85         return DO_NOTHING;
86     }
87     
88     
89     private boolean downloadWsdl() {
90         if (!downloadWsdl) return false;
91         return downloadWsdlCheckBox.isSelected();
92     }
93     
94     private boolean regenerate() {
95         return regenerateCheckBox.isSelected();
96     }
97     
98     /** This method is called from within the constructor to
99      * initialize the form.
100      * WARNING: Do NOT modify this code. The content of this method is
101      * always regenerated by the Form Editor.
102      */

103     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
104
private void initComponents() {
105         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
106
107         downloadWsdlCheckBox = new javax.swing.JCheckBox JavaDoc();
108         regenerateCheckBox = new javax.swing.JCheckBox JavaDoc();
109         jLabel1 = new javax.swing.JLabel JavaDoc();
110         jLabel2 = new javax.swing.JLabel JavaDoc();
111         jLabel3 = new javax.swing.JLabel JavaDoc();
112
113         setLayout(new java.awt.GridBagLayout JavaDoc());
114
115         downloadWsdlCheckBox.setMnemonic(org.openide.util.NbBundle.getMessage(RefreshWsDialog.class, "MSG_DownloadWsdl_mnem").charAt(0));
116         downloadWsdlCheckBox.setText(org.openide.util.NbBundle.getMessage(RefreshWsDialog.class, "MSG_DownloadWsdl", new Object JavaDoc[] {url}));
117         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
118         gridBagConstraints.gridx = 0;
119         gridBagConstraints.gridy = 1;
120         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
121         gridBagConstraints.weightx = 1.0;
122         add(downloadWsdlCheckBox, gridBagConstraints);
123
124         regenerateCheckBox.setMnemonic(org.openide.util.NbBundle.getMessage(RefreshWsDialog.class, "MSG_RegenerateImplClass_mnem").charAt(0));
125         regenerateCheckBox.setSelected(true);
126         regenerateCheckBox.setText(org.openide.util.NbBundle.getMessage(RefreshWsDialog.class, "MSG_RegenerateImplClass"));
127         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
128         gridBagConstraints.gridx = 0;
129         gridBagConstraints.gridy = 3;
130         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
131         gridBagConstraints.weightx = 1.0;
132         gridBagConstraints.insets = new java.awt.Insets JavaDoc(10, 0, 0, 0);
133         add(regenerateCheckBox, gridBagConstraints);
134
135         jLabel1.setText(org.openide.util.NbBundle.getMessage(RefreshWsDialog.class, "HINT_DownloadWsdl"));
136         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
137         gridBagConstraints.gridx = 0;
138         gridBagConstraints.gridy = 2;
139         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
140         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 22, 0, 0);
141         add(jLabel1, gridBagConstraints);
142
143         jLabel2.setText(org.openide.util.NbBundle.getMessage(RefreshWsDialog.class, "HINT_RegenerateImplClass", new Object JavaDoc[] {implClass+".java.old"}));
144         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
145         gridBagConstraints.gridx = 0;
146         gridBagConstraints.gridy = 4;
147         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
148         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 22, 0, 0);
149         add(jLabel2, gridBagConstraints);
150
151         jLabel3.setText(org.openide.util.NbBundle.getMessage(RefreshWsDialog.class, "HINT_RefreshService"));
152         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
153         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
154         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 20, 0);
155         add(jLabel3, gridBagConstraints);
156
157     }// </editor-fold>//GEN-END:initComponents
158

159     
160     // Variables declaration - do not modify//GEN-BEGIN:variables
161
private javax.swing.JCheckBox JavaDoc downloadWsdlCheckBox;
162     private javax.swing.JLabel JavaDoc jLabel1;
163     private javax.swing.JLabel JavaDoc jLabel2;
164     private javax.swing.JLabel JavaDoc jLabel3;
165     private javax.swing.JCheckBox JavaDoc regenerateCheckBox;
166     // End of variables declaration//GEN-END:variables
167

168 }
169
Popular Tags