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.project.uiapi;
043:
044: import java.awt.CardLayout;
045: import javax.swing.event.ChangeListener;
046: import org.netbeans.api.progress.ProgressHandle;
047: import org.netbeans.api.progress.ProgressHandleFactory;
048: import org.netbeans.modules.project.uiapi.DefaultProjectOperationsImplementation.InvalidablePanel;
049: import org.openide.util.NbBundle;
050:
051: /**
052: *
053: * @author Jan Lahoda
054: */
055: final class DefaultProjectDeletePanel extends javax.swing.JPanel
056: implements InvalidablePanel {
057:
058: private String projectDisplaName;
059: private String projectFolder;
060: private boolean enableCheckbox;
061: private ProgressHandle handle;
062:
063: /**
064: * Creates new form DefaultProjectDeletePanel
065: */
066: public DefaultProjectDeletePanel(ProgressHandle handle,
067: String projectDisplaName, String projectFolder,
068: boolean enableCheckbox) {
069: this .projectDisplaName = projectDisplaName;
070: this .projectFolder = projectFolder;
071: this .enableCheckbox = enableCheckbox;
072: this .handle = handle;
073: initComponents();
074:
075: if (Boolean
076: .getBoolean("org.netbeans.modules.project.uiapi.DefaultProjectOperations.showProgress")) {
077: ((CardLayout) progress.getLayout()).show(progress,
078: "progress");
079: }
080: }
081:
082: /** This method is called from within the constructor to
083: * initialize the form.
084: * WARNING: Do NOT modify this code. The content of this method is
085: * always regenerated by the Form Editor.
086: */
087: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
088: private void initComponents() {
089: java.awt.GridBagConstraints gridBagConstraints;
090:
091: warningText = new javax.swing.JTextArea();
092: deleteSourcesCheckBox = new javax.swing.JCheckBox();
093: progress = new javax.swing.JPanel();
094: jPanel4 = new javax.swing.JPanel();
095: progressImpl = new javax.swing.JPanel();
096: jLabel5 = new javax.swing.JLabel();
097: jPanel3 = new javax.swing.JPanel();
098:
099: setLayout(new java.awt.GridBagLayout());
100:
101: getAccessibleContext().setAccessibleDescription(
102: org.openide.util.NbBundle.getMessage(
103: DefaultProjectDeletePanel.class,
104: "ACSD_Delete_Panel", new Object[] {}));
105: warningText.setEditable(false);
106: warningText
107: .setFont(javax.swing.UIManager.getFont("Label.font"));
108: warningText.setText(org.openide.util.NbBundle.getMessage(
109: DefaultProjectDeletePanel.class,
110: "LBL_Pre_Delete_Warning",
111: new Object[] { projectDisplaName }));
112: warningText.setDisabledTextColor(javax.swing.UIManager
113: .getColor("Label.foreground"));
114: warningText.setOpaque(false);
115: gridBagConstraints = new java.awt.GridBagConstraints();
116: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
117: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
118: gridBagConstraints.weightx = 1.0;
119: gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 12);
120: add(warningText, gridBagConstraints);
121: warningText.getAccessibleContext().setAccessibleName(
122: org.openide.util.NbBundle.getMessage(
123: DefaultProjectDeletePanel.class,
124: "ASCN_Pre_Delete_Warning", new Object[] {}));
125: warningText.getAccessibleContext().setAccessibleDescription(
126: org.openide.util.NbBundle.getMessage(
127: DefaultProjectDeletePanel.class,
128: "ACSD_Pre_Delete_Warning",
129: new Object[] { projectDisplaName }));
130:
131: org.openide.awt.Mnemonics.setLocalizedText(
132: deleteSourcesCheckBox, org.openide.util.NbBundle
133: .getMessage(DefaultProjectDeletePanel.class,
134: "LBL_Delete_Also_Sources",
135: new Object[] { projectFolder }));
136: deleteSourcesCheckBox.setEnabled(enableCheckbox);
137: gridBagConstraints = new java.awt.GridBagConstraints();
138: gridBagConstraints.gridx = 0;
139: gridBagConstraints.gridy = 3;
140: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
141: gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 12);
142: add(deleteSourcesCheckBox, gridBagConstraints);
143: deleteSourcesCheckBox.getAccessibleContext().setAccessibleName(
144: org.openide.util.NbBundle.getMessage(
145: DefaultProjectDeletePanel.class,
146: "ACSN_Delete_Also_Sources",
147: new Object[] { projectFolder }));
148: deleteSourcesCheckBox.getAccessibleContext()
149: .setAccessibleDescription(
150: org.openide.util.NbBundle.getMessage(
151: DefaultProjectDeletePanel.class,
152: "ACSD_Delete_Also_Sources",
153: new Object[] {}));
154:
155: progress.setLayout(new java.awt.CardLayout());
156:
157: progress.add(jPanel4, "not-progress");
158:
159: progressImpl.setLayout(new java.awt.GridBagLayout());
160:
161: org.openide.awt.Mnemonics.setLocalizedText(jLabel5,
162: org.openide.util.NbBundle.getMessage(
163: DefaultProjectDeletePanel.class,
164: "LBL_Deleting_Project", new Object[] {}));
165: gridBagConstraints = new java.awt.GridBagConstraints();
166: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
167: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
168: gridBagConstraints.weightx = 1.0;
169: progressImpl.add(jLabel5, gridBagConstraints);
170:
171: jPanel3.setLayout(new java.awt.BorderLayout());
172:
173: jPanel3.add(ProgressHandleFactory
174: .createProgressComponent(handle));
175: gridBagConstraints = new java.awt.GridBagConstraints();
176: gridBagConstraints.gridx = 0;
177: gridBagConstraints.gridy = 1;
178: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
179: gridBagConstraints.weightx = 1.0;
180: progressImpl.add(jPanel3, gridBagConstraints);
181:
182: progress.add(progressImpl, "progress");
183:
184: gridBagConstraints = new java.awt.GridBagConstraints();
185: gridBagConstraints.gridx = 0;
186: gridBagConstraints.gridy = 5;
187: gridBagConstraints.gridwidth = 2;
188: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
189: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
190: gridBagConstraints.weightx = 1.0;
191: gridBagConstraints.weighty = 1.0;
192: gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 0);
193: add(progress, gridBagConstraints);
194:
195: }
196:
197: // </editor-fold>//GEN-END:initComponents
198:
199: // Variables declaration - do not modify//GEN-BEGIN:variables
200: private javax.swing.JCheckBox deleteSourcesCheckBox;
201: private javax.swing.JLabel jLabel5;
202: private javax.swing.JPanel jPanel3;
203: private javax.swing.JPanel jPanel4;
204: private javax.swing.JPanel progress;
205: private javax.swing.JPanel progressImpl;
206: private javax.swing.JTextArea warningText;
207:
208: // End of variables declaration//GEN-END:variables
209:
210: public boolean isDeleteSources() {
211: return deleteSourcesCheckBox.isSelected();
212: }
213:
214: void setDeleteSources(boolean value) {
215: deleteSourcesCheckBox.setSelected(value);
216: }
217:
218: private String getCheckboxText() {
219: return NbBundle.getMessage(DefaultProjectDeletePanel.class,
220: "LBL_Delete_Also_Sources",
221: new Object[] { projectFolder });
222: }
223:
224: public void addChangeListener(ChangeListener l) {
225: //no changes.
226: }
227:
228: public void removeChangeListener(ChangeListener l) {
229: //no changes.
230: }
231:
232: public void showProgress() {
233: deleteSourcesCheckBox.setEnabled(false);
234:
235: ((CardLayout) progress.getLayout()).last(progress);
236: }
237:
238: public boolean isPanelValid() {
239: return true;
240: }
241:
242: }
|