KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > ejbcore > ui > logicalview > ejb > action > DeleteEJBDialog


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.j2ee.ejbcore.ui.logicalview.ejb.action;
21
22 import org.netbeans.modules.j2ee.ejbcore.ui.EJBPreferences;
23 import org.openide.DialogDisplayer;
24 import org.openide.NotifyDescriptor;
25 import org.openide.util.NbBundle;
26
27 /**
28  *
29  * @author Martin Adamek
30  */

31 public class DeleteEJBDialog extends javax.swing.JPanel JavaDoc {
32
33     public static final String JavaDoc DELETE_NOTHING = "deleteNothing";
34     public static final String JavaDoc DELETE_ONLY_DD = "deleteOnlyDD";
35     public static final String JavaDoc DELETE_ALL = "deleteAll";
36
37     private final String JavaDoc ejbDisplayName;
38     private final EJBPreferences ejbPreferences;
39     
40     private DeleteEJBDialog(String JavaDoc ejbDisplayName) {
41         this.ejbDisplayName = ejbDisplayName;
42         initComponents();
43         ejbPreferences = new EJBPreferences();
44         deleteClassesCheckBox.setSelected(ejbPreferences.isAgreedDeleteEJBGeneratedSources());
45     }
46
47     public static String JavaDoc open(String JavaDoc ejbDisplayName) {
48         String JavaDoc title = NbBundle.getMessage(DeleteEJBDialog.class, "MSG_ConfirmDeleteObjectTitle");
49         DeleteEJBDialog delDialog = new DeleteEJBDialog(ejbDisplayName);
50         NotifyDescriptor desc = new NotifyDescriptor.Confirmation(delDialog, title, NotifyDescriptor.YES_NO_OPTION);
51         Object JavaDoc result = DialogDisplayer.getDefault().notify(desc);
52         if (result.equals(NotifyDescriptor.CLOSED_OPTION)) {
53             return DELETE_NOTHING;
54         } else if (result.equals(NotifyDescriptor.NO_OPTION)) {
55             return DELETE_NOTHING;
56         } else if (delDialog.deleteClassesCheckBox.isSelected()) {
57             return DELETE_ALL;
58         } else {
59             return DELETE_ONLY_DD;
60         }
61         
62     }
63     
64     /** This method is called from within the constructor to
65      * initialize the form.
66      * WARNING: Do NOT modify this code. The content of this method is
67      * always regenerated by the Form Editor.
68      */

69     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
70
private void initComponents() {
71         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
72
73         jLabel1 = new javax.swing.JLabel JavaDoc();
74         deleteClassesCheckBox = new javax.swing.JCheckBox JavaDoc();
75
76         setLayout(new java.awt.GridBagLayout JavaDoc());
77
78         jLabel1.setText(org.openide.util.NbBundle.getMessage(DeleteEJBDialog.class, "MSG_ConfirmDeleteObject", new Object JavaDoc[] {ejbDisplayName}));
79         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
80         gridBagConstraints.gridx = 0;
81         gridBagConstraints.gridy = 0;
82         gridBagConstraints.weightx = 1.0;
83         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 8, 0);
84         add(jLabel1, gridBagConstraints);
85
86         deleteClassesCheckBox.setText(org.openide.util.NbBundle.getBundle(DeleteEJBDialog.class).getString("MSG_DeleteClasses"));
87         deleteClassesCheckBox.addActionListener(new java.awt.event.ActionListener JavaDoc() {
88             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
89                 deleteClassesCheckBoxActionPerformed(evt);
90             }
91         });
92
93         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
94         gridBagConstraints.gridx = 0;
95         gridBagConstraints.gridy = 1;
96         gridBagConstraints.weightx = 1.0;
97         add(deleteClassesCheckBox, gridBagConstraints);
98
99     }
100     // </editor-fold>//GEN-END:initComponents
101

102     private void deleteClassesCheckBoxActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_deleteClassesCheckBoxActionPerformed
103
ejbPreferences.setAgreedDeleteEJBGeneratedSources(deleteClassesCheckBox.isSelected());
104     }//GEN-LAST:event_deleteClassesCheckBoxActionPerformed
105

106     
107     // Variables declaration - do not modify//GEN-BEGIN:variables
108
private javax.swing.JCheckBox JavaDoc deleteClassesCheckBox;
109     private javax.swing.JLabel JavaDoc jLabel1;
110     // End of variables declaration//GEN-END:variables
111

112 }
113
Popular Tags