2
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
* Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
6
* The contents of this file are subject to the terms of either the GNU
7
* General Public License Version 2 only ("GPL") or the Common
8
* Development and Distribution License("CDDL") (collectively, the
9
* "License"). You may not use this file except in compliance with the
10
* License. You can obtain a copy of the License at
11
* http://www.netbeans.org/cddl-gplv2.html
12
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
* specific language governing permissions and limitations under the
14
* License. When distributing the software, include this License Header
15
* Notice in each file and include the License file at
16
* nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17
* particular file as subject to the "Classpath" exception as provided
18
* by Sun in the GPL Version 2 section of the License file that
19
* accompanied this code. If applicable, add the following below the
20
* License Header, with the fields enclosed by brackets [] replaced by
21
* your own identifying information:
22
* "Portions Copyrighted [year] [name of copyright owner]"
26
* The Original Software is NetBeans. The Initial Developer of the Original
27
* Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
* Microsystems, Inc. All Rights Reserved.
30
* If you wish your version of this file to be governed by only the CDDL
31
* or only the GPL Version 2, indicate your decision by adding
32
* "[Contributor] elects to include this software in this distribution
33
* under the [CDDL or GPL Version 2] license." If you do not indicate a
34
* single choice of license, a recipient has the option to distribute
35
* your version of this file under either the CDDL, the GPL Version 2 or
36
* to extend the choice of license to its licensees as provided above.
37
* However, if you add GPL Version 2 code and therefore, elected the GPL
38
* Version 2 license, then the option applies only if the new code is
39
* made subject to such option by the copyright holder.
41
package org.netbeans.bluej.export;
43
import java.awt.Component;
45
import java.util.HashSet;
46
import java.util.Iterator;
48
import javax.swing.event.ChangeEvent;
49
import javax.swing.event.ChangeListener;
50
import org.openide.WizardDescriptor;
51
import org.openide.filesystems.FileObject;
52
import org.openide.util.HelpCtx;
54
public class ExportWizardPanel1 implements WizardDescriptor.Panel {
58
* The visual component that displays this panel. If you need to access the
59
* component from this class, just use getComponent().
61
private Component component;
63
private FileObject dir;
64
private boolean valid = false;
65
private WizardDescriptor settings;
67
ExportWizardPanel1(FileObject fo) {
71
// Get the visual component for the panel. In this template, the component
72
// is kept separate. This can be more efficient: if the wizard is created
73
// but never displayed, or not all panels are displayed, it is better to
74
// create only those which really need to be visible.
75
public Component getComponent() {
76
if (component == null) {
77
component = new ExportPanel(dir, this);
82
public HelpCtx getHelp() {
83
// Show no Help button for this panel:
84
return HelpCtx.DEFAULT_HELP;
85
// If you have context help:
86
// return new HelpCtx(SampleWizardPanel1.class);
89
public boolean isValid() {
93
private final Set listeners = new HashSet(1);
94
public final void addChangeListener(ChangeListener l) {
95
synchronized (listeners) {
99
public final void removeChangeListener(ChangeListener l) {
100
synchronized (listeners) {
104
protected final void fireChangeEvent() {
106
synchronized (listeners) {
107
it = new HashSet(listeners).iterator();
109
ChangeEvent ev = new ChangeEvent(this);
110
while (it.hasNext()) {
111
((ChangeListener)it.next()).stateChanged(ev);
115
// You can use a settings object to keep track of state. Normally the
116
// settings object will be the WizardDescriptor, so you can use
117
// WizardDescriptor.getProperty & putProperty to store information entered
119
public void readSettings(Object sets) {
120
this.settings = (WizardDescriptor)sets;
121
File fil = (File)settings.getProperty("NewProjectLocation");
122
String path = fil != null ? fil.getAbsolutePath() : "";
125
public void storeSettings(Object set) {
126
WizardDescriptor wiz = (WizardDescriptor)set;
128
//#79637 can be null when immediately cancelling the wizard.
129
wiz.putProperty("NewProjectLocation", new File(path.trim())); // NOI18N
133
void updateValue(String value) {
135
if (path == null || path.trim().length() == 0) {
136
settings.putProperty("WizardPanel_errorMessage", org.openide.util.NbBundle.getMessage(ExportWizardPanel1.class, "ERROR_noFolder"));
139
File fil = new File(path.trim());
140
if (fil.exists() && (fil.isFile() || (fil.isDirectory() && fil.listFiles().length > 0))) {
141
settings.putProperty("WizardPanel_errorMessage", org.openide.util.NbBundle.getMessage(ExportWizardPanel1.class, "ERROR_WrongFolder"));
144
settings.putProperty("WizardPanel_errorMessage", null);