KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > project > uiapi > DefaultProjectDeletePanel


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.project.uiapi;
21 import java.awt.CardLayout JavaDoc;
22 import javax.swing.event.ChangeListener JavaDoc;
23 import org.netbeans.api.progress.ProgressHandle;
24 import org.netbeans.api.progress.ProgressHandleFactory;
25 import org.netbeans.modules.project.uiapi.DefaultProjectOperationsImplementation.InvalidablePanel;
26 import org.openide.util.NbBundle;
27
28 /**
29  *
30  * @author Jan Lahoda
31  */

32 final class DefaultProjectDeletePanel extends javax.swing.JPanel JavaDoc implements InvalidablePanel {
33
34     private String JavaDoc projectDisplaName;
35     private String JavaDoc projectFolder;
36     private boolean enableCheckbox;
37     private ProgressHandle handle;
38     
39     /**
40      * Creates new form DefaultProjectDeletePanel
41      */

42     public DefaultProjectDeletePanel(ProgressHandle handle, String JavaDoc projectDisplaName, String JavaDoc projectFolder, boolean enableCheckbox) {
43         this.projectDisplaName = projectDisplaName;
44         this.projectFolder = projectFolder;
45         this.enableCheckbox = enableCheckbox;
46         this.handle = handle;
47         initComponents();
48         
49         if (Boolean.getBoolean("org.netbeans.modules.project.uiapi.DefaultProjectOperations.showProgress")) {
50             ((CardLayout JavaDoc) progress.getLayout()).show(progress, "progress");
51         }
52     }
53     
54     /** This method is called from within the constructor to
55      * initialize the form.
56      * WARNING: Do NOT modify this code. The content of this method is
57      * always regenerated by the Form Editor.
58      */

59     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
60
private void initComponents() {
61         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
62
63         warningText = new javax.swing.JTextArea JavaDoc();
64         deleteSourcesCheckBox = new javax.swing.JCheckBox JavaDoc();
65         progress = new javax.swing.JPanel JavaDoc();
66         jPanel4 = new javax.swing.JPanel JavaDoc();
67         progressImpl = new javax.swing.JPanel JavaDoc();
68         jLabel5 = new javax.swing.JLabel JavaDoc();
69         jPanel3 = new javax.swing.JPanel JavaDoc();
70
71         setLayout(new java.awt.GridBagLayout JavaDoc());
72
73         getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(DefaultProjectDeletePanel.class, "ACSD_Delete_Panel", new Object JavaDoc[] {}));
74         warningText.setEditable(false);
75         warningText.setFont(javax.swing.UIManager.getFont("Label.font"));
76         warningText.setText(org.openide.util.NbBundle.getMessage(DefaultProjectDeletePanel.class, "LBL_Pre_Delete_Warning", new Object JavaDoc[] {projectDisplaName}));
77         warningText.setDisabledTextColor(javax.swing.UIManager.getColor("Label.foreground"));
78         warningText.setOpaque(false);
79         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
80         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
81         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
82         gridBagConstraints.weightx = 1.0;
83         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 12);
84         add(warningText, gridBagConstraints);
85         warningText.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(DefaultProjectDeletePanel.class, "ASCN_Pre_Delete_Warning", new Object JavaDoc[] {}));
86         warningText.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(DefaultProjectDeletePanel.class, "ACSD_Pre_Delete_Warning", new Object JavaDoc[] {projectDisplaName}));
87
88         org.openide.awt.Mnemonics.setLocalizedText(deleteSourcesCheckBox, org.openide.util.NbBundle.getMessage(DefaultProjectDeletePanel.class, "LBL_Delete_Also_Sources", new Object JavaDoc[] {projectFolder}));
89         deleteSourcesCheckBox.setEnabled(enableCheckbox);
90         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
91         gridBagConstraints.gridx = 0;
92         gridBagConstraints.gridy = 3;
93         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
94         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 12);
95         add(deleteSourcesCheckBox, gridBagConstraints);
96         deleteSourcesCheckBox.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(DefaultProjectDeletePanel.class, "ACSN_Delete_Also_Sources", new Object JavaDoc[] {projectFolder}));
97         deleteSourcesCheckBox.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(DefaultProjectDeletePanel.class, "ACSD_Delete_Also_Sources", new Object JavaDoc[] {}));
98
99         progress.setLayout(new java.awt.CardLayout JavaDoc());
100
101         progress.add(jPanel4, "not-progress");
102
103         progressImpl.setLayout(new java.awt.GridBagLayout JavaDoc());
104
105         org.openide.awt.Mnemonics.setLocalizedText(jLabel5, org.openide.util.NbBundle.getMessage(DefaultProjectDeletePanel.class, "LBL_Deleting_Project", new Object JavaDoc[] {}));
106         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
107         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
108         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
109         gridBagConstraints.weightx = 1.0;
110         progressImpl.add(jLabel5, gridBagConstraints);
111
112         jPanel3.setLayout(new java.awt.BorderLayout JavaDoc());
113
114         jPanel3.add(ProgressHandleFactory.createProgressComponent(handle));
115         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
116         gridBagConstraints.gridx = 0;
117         gridBagConstraints.gridy = 1;
118         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
119         gridBagConstraints.weightx = 1.0;
120         progressImpl.add(jPanel3, gridBagConstraints);
121
122         progress.add(progressImpl, "progress");
123
124         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
125         gridBagConstraints.gridx = 0;
126         gridBagConstraints.gridy = 5;
127         gridBagConstraints.gridwidth = 2;
128         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
129         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
130         gridBagConstraints.weightx = 1.0;
131         gridBagConstraints.weighty = 1.0;
132         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 0, 0, 0);
133         add(progress, gridBagConstraints);
134
135     }
136     // </editor-fold>//GEN-END:initComponents
137

138     
139     // Variables declaration - do not modify//GEN-BEGIN:variables
140
private javax.swing.JCheckBox JavaDoc deleteSourcesCheckBox;
141     private javax.swing.JLabel JavaDoc jLabel5;
142     private javax.swing.JPanel JavaDoc jPanel3;
143     private javax.swing.JPanel JavaDoc jPanel4;
144     private javax.swing.JPanel JavaDoc progress;
145     private javax.swing.JPanel JavaDoc progressImpl;
146     private javax.swing.JTextArea JavaDoc warningText;
147     // End of variables declaration//GEN-END:variables
148

149     public boolean isDeleteSources() {
150         return deleteSourcesCheckBox.isSelected();
151     }
152
153     void setDeleteSources(boolean value) {
154         deleteSourcesCheckBox.setSelected(value);
155     }
156     
157     private String JavaDoc getCheckboxText() {
158         return NbBundle.getMessage(DefaultProjectDeletePanel.class, "LBL_Delete_Also_Sources", new Object JavaDoc[] {projectFolder});
159     }
160
161     public void addChangeListener(ChangeListener JavaDoc l) {
162         //no changes.
163
}
164
165     public void removeChangeListener(ChangeListener JavaDoc l) {
166         //no changes.
167
}
168
169     public void showProgress() {
170         deleteSourcesCheckBox.setEnabled(false);
171         
172         ((CardLayout JavaDoc) progress.getLayout()).last(progress);
173     }
174
175     public boolean isPanelValid() {
176         return true;
177     }
178     
179 }
180
Popular Tags