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.webservices.ui;
043:
044: import org.openide.DialogDisplayer;
045: import org.openide.NotifyDescriptor;
046: import org.openide.util.NbBundle;
047:
048: /**
049: *
050: * @author Martin Adamek
051: */
052: public class DeleteWsDialog extends javax.swing.JPanel {
053:
054: public static final String DELETE_NOTHING = "deleteNothing"; //NOI18N
055: public static final String DELETE_ALL = "deleteALL"; //NOI18N
056: public static final String DELETE_WS = "deleteWebService"; //NOI18N
057: public static final String DELETE_PACKAGE = "deletePackage"; //NOI18N
058: public static final String DELETE_WSDL = "deleteWsdl"; //NOI18N
059:
060: private String wsName, packageName, wsdlName;
061:
062: private DeleteWsDialog(String wsName, String packageName,
063: String wsdlName) {
064: this .wsName = wsName;
065: this .packageName = packageName;
066: this .wsdlName = wsdlName;
067: initComponents();
068: // display the delete_wsdl checkbox only if wsdl exists
069: if (wsdlName == null)
070: deleteWsdlCheckBox.setVisible(false);
071: }
072:
073: public static String open(String wsName, String packageName,
074: String wsdlName) {
075: String title = NbBundle.getMessage(DeleteWsDialog.class,
076: "MSG_ConfirmDeleteObjectTitle");
077: DeleteWsDialog delDialog = new DeleteWsDialog(wsName,
078: packageName, wsdlName);
079: NotifyDescriptor desc = new NotifyDescriptor.Confirmation(
080: delDialog, title, NotifyDescriptor.YES_NO_OPTION);
081: Object result = DialogDisplayer.getDefault().notify(desc);
082: if (result.equals(NotifyDescriptor.CLOSED_OPTION)) {
083: return DELETE_NOTHING;
084: } else if (result.equals(NotifyDescriptor.NO_OPTION)) {
085: return DELETE_NOTHING;
086: } else if (delDialog.deletePackage() && delDialog.deleteWsdl()) {
087: return DELETE_ALL;
088: } else if (delDialog.deletePackage()) {
089: return DELETE_PACKAGE;
090: } else if (delDialog.deleteWsdl()) {
091: return DELETE_WSDL;
092: } else
093: return DELETE_WS;
094:
095: }
096:
097: private boolean deletePackage() {
098: return deletePackageCheckBox.isSelected();
099: }
100:
101: private boolean deleteWsdl() {
102: if (wsdlName == null)
103: return false;
104: else
105: return deleteWsdlCheckBox.isSelected();
106: }
107:
108: /** This method is called from within the constructor to
109: * initialize the form.
110: * WARNING: Do NOT modify this code. The content of this method is
111: * always regenerated by the Form Editor.
112: */
113: // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
114: private void initComponents() {
115: java.awt.GridBagConstraints gridBagConstraints;
116:
117: jLabel1 = new javax.swing.JLabel();
118: deletePackageCheckBox = new javax.swing.JCheckBox();
119: deleteWsdlCheckBox = new javax.swing.JCheckBox();
120:
121: setLayout(new java.awt.GridBagLayout());
122:
123: org.openide.awt.Mnemonics.setLocalizedText(jLabel1,
124: org.openide.util.NbBundle.getMessage(
125: DeleteWsDialog.class,
126: "MSG_ConfirmDeleteObject",
127: new Object[] { wsName })); // NOI18N
128: gridBagConstraints = new java.awt.GridBagConstraints();
129: gridBagConstraints.gridx = 0;
130: gridBagConstraints.gridy = 0;
131: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
132: gridBagConstraints.weightx = 1.0;
133: gridBagConstraints.insets = new java.awt.Insets(0, 0, 8, 0);
134: add(jLabel1, gridBagConstraints);
135:
136: org.openide.awt.Mnemonics.setLocalizedText(
137: deletePackageCheckBox, org.openide.util.NbBundle
138: .getMessage(DeleteWsDialog.class,
139: "MSG_DeletePackage",
140: new Object[] { packageName })); // NOI18N
141: gridBagConstraints = new java.awt.GridBagConstraints();
142: gridBagConstraints.gridx = 0;
143: gridBagConstraints.gridy = 1;
144: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
145: gridBagConstraints.weightx = 1.0;
146: add(deletePackageCheckBox, gridBagConstraints);
147:
148: deleteWsdlCheckBox.setSelected(true);
149: org.openide.awt.Mnemonics.setLocalizedText(deleteWsdlCheckBox,
150: org.openide.util.NbBundle.getMessage(
151: DeleteWsDialog.class, "MSG_DeleteWsdl",
152: new Object[] { wsdlName })); // NOI18N
153: gridBagConstraints = new java.awt.GridBagConstraints();
154: gridBagConstraints.gridx = 0;
155: gridBagConstraints.gridy = 2;
156: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
157: gridBagConstraints.weightx = 1.0;
158: add(deleteWsdlCheckBox, gridBagConstraints);
159: }// </editor-fold>//GEN-END:initComponents
160:
161: // Variables declaration - do not modify//GEN-BEGIN:variables
162: private javax.swing.JCheckBox deletePackageCheckBox;
163: private javax.swing.JCheckBox deleteWsdlCheckBox;
164: private javax.swing.JLabel jLabel1;
165: // End of variables declaration//GEN-END:variables
166:
167: }
|