001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.websvc.core.jaxws.nodes;
043:
044: import java.awt.event.ItemEvent;
045: import java.awt.event.ItemListener;
046: import org.openide.DialogDisplayer;
047: import org.openide.NotifyDescriptor;
048: import org.openide.util.NbBundle;
049:
050: /**
051: *
052: * @author Milan Kuchtiak
053: */
054: public class RefreshClientDialog extends javax.swing.JPanel {
055:
056: static final String CLOSE = "close";
057: static final String NO_DOWNLOAD = "no_download";
058: //static final int DOWNLOAD_WSDL = 2;
059:
060: private String url;
061:
062: private RefreshClientDialog(String url) {
063: this .url = url;
064: initComponents();
065: jTextField1.setText(url);
066: downloadWsdlCheckBox.addItemListener(new ItemListener() {
067:
068: public void itemStateChanged(ItemEvent e) {
069: if (((javax.swing.JCheckBox) e.getSource())
070: .isSelected())
071: jTextField1.setEditable(true);
072: else
073: jTextField1.setEditable(false);
074: }
075:
076: });
077: }
078:
079: public static String open(String url) {
080: String title = NbBundle.getMessage(RefreshClientDialog.class,
081: "MSG_ConfirmClientRefresh");
082: RefreshClientDialog refreshDialog = new RefreshClientDialog(url);
083: NotifyDescriptor desc = new NotifyDescriptor.Confirmation(
084: refreshDialog, title, NotifyDescriptor.YES_NO_OPTION);
085: Object result = DialogDisplayer.getDefault().notify(desc);
086: if (result.equals(NotifyDescriptor.CLOSED_OPTION)) {
087: return CLOSE;
088: } else if (result.equals(NotifyDescriptor.NO_OPTION)) {
089: return CLOSE;
090: } else if (refreshDialog.downloadWsdl()) {
091: return refreshDialog.getWsdlUrl();
092: } else
093: return NO_DOWNLOAD;
094:
095: }
096:
097: private boolean downloadWsdl() {
098: return downloadWsdlCheckBox.isSelected();
099: }
100:
101: /** This method is called from within the constructor to
102: * initialize the form.
103: * WARNING: Do NOT modify this code. The content of this method is
104: * always regenerated by the Form Editor.
105: */
106: // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
107: private void initComponents() {
108: java.awt.GridBagConstraints gridBagConstraints;
109:
110: downloadWsdlCheckBox = new javax.swing.JCheckBox();
111: jLabel1 = new javax.swing.JLabel();
112: jLabel2 = new javax.swing.JLabel();
113: jTextField1 = new javax.swing.JTextField();
114:
115: setLayout(new java.awt.GridBagLayout());
116:
117: org.openide.awt.Mnemonics.setLocalizedText(
118: downloadWsdlCheckBox, org.openide.util.NbBundle
119: .getMessage(RefreshClientDialog.class,
120: "MSG_DownloadWsdl")); // NOI18N
121: gridBagConstraints = new java.awt.GridBagConstraints();
122: gridBagConstraints.gridx = 0;
123: gridBagConstraints.gridy = 1;
124: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
125: gridBagConstraints.weightx = 1.0;
126: add(downloadWsdlCheckBox, gridBagConstraints);
127:
128: org.openide.awt.Mnemonics
129: .setLocalizedText(jLabel1, org.openide.util.NbBundle
130: .getMessage(RefreshClientDialog.class,
131: "HINT_DownloadWsdl")); // NOI18N
132: gridBagConstraints = new java.awt.GridBagConstraints();
133: gridBagConstraints.gridx = 0;
134: gridBagConstraints.gridy = 3;
135: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
136: gridBagConstraints.insets = new java.awt.Insets(15, 22, 0, 0);
137: add(jLabel1, gridBagConstraints);
138:
139: org.openide.awt.Mnemonics.setLocalizedText(jLabel2,
140: org.openide.util.NbBundle
141: .getMessage(RefreshClientDialog.class,
142: "HINT_RefreshClient")); // NOI18N
143: gridBagConstraints = new java.awt.GridBagConstraints();
144: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
145: gridBagConstraints.insets = new java.awt.Insets(0, 0, 20, 0);
146: add(jLabel2, gridBagConstraints);
147:
148: jTextField1.setEditable(false);
149: gridBagConstraints = new java.awt.GridBagConstraints();
150: gridBagConstraints.gridx = 0;
151: gridBagConstraints.gridy = 2;
152: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
153: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
154: gridBagConstraints.insets = new java.awt.Insets(5, 22, 0, 22);
155: add(jTextField1, gridBagConstraints);
156: }// </editor-fold>//GEN-END:initComponents
157:
158: // Variables declaration - do not modify//GEN-BEGIN:variables
159: private javax.swing.JCheckBox downloadWsdlCheckBox;
160: private javax.swing.JLabel jLabel1;
161: private javax.swing.JLabel jLabel2;
162: private javax.swing.JTextField jTextField1;
163:
164: // End of variables declaration//GEN-END:variables
165:
166: private String getWsdlUrl() {
167: return jTextField1.getText().trim();
168: }
169:
170: }
|