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.
42
package org.netbeans.modules.form.palette;
45
import javax.swing.event.*;
48
import org.openide.WizardDescriptor;
49
import org.openide.explorer.*;
52
* The third panel in the wizard for adding new components to the palette.
53
* Lets the user choose the palette category where to add the selected
59
class ChooseCategoryWizardPanel implements WizardDescriptor.FinishablePanel {
61
private CategorySelector categorySelector;
63
private EventListenerList listenerList;
66
// WizardDescriptor.Panel implementation
68
public java.awt.Component getComponent() {
69
if (categorySelector == null) { // create the UI component for the wizard step
70
categorySelector = new CategorySelector();
72
// wizard API: set the caption and index of this panel
73
categorySelector.setName(PaletteUtils.getBundleString("CTL_SelectCategory_Caption")); // NOI18N
74
categorySelector.putClientProperty("WizardPanel_contentSelectedIndex", // NOI18N
77
categorySelector.getExplorerManager().addPropertyChangeListener(
78
new PropertyChangeListener() {
79
public void propertyChange(PropertyChangeEvent ev) {
80
if (ExplorerManager.PROP_SELECTED_NODES.equals(ev.getPropertyName()))
86
return categorySelector;
89
public org.openide.util.HelpCtx getHelp() {
91
return new org.openide.util.HelpCtx("beans.adding"); // NOI18N
94
public boolean isValid() {
95
return categorySelector != null
96
&& categorySelector.getSelectedCategory() != null;
99
public void readSettings(Object settings) {
102
public void storeSettings(Object settings) {
103
if (categorySelector != null)
104
((AddToPaletteWizard)settings).setSelectedCategory(categorySelector.getSelectedCategory());
107
public void addChangeListener(ChangeListener listener) {
108
if (listenerList == null)
109
listenerList = new EventListenerList();
110
listenerList.add(ChangeListener.class, listener);
113
public void removeChangeListener(ChangeListener listener) {
114
if (listenerList != null)
115
listenerList.remove(ChangeListener.class, listener);
118
// WizardDescriptor.FinishablePanel implementation
119
public boolean isFinishPanel() {
125
void fireStateChanged() {
126
if (listenerList == null)
129
ChangeEvent e = null;
130
Object[] listeners = listenerList.getListenerList();
131
for (int i=listeners.length-2; i >= 0; i-=2) {
132
if (listeners[i] == ChangeListener.class) {
134
e = new ChangeEvent(this);
135
((ChangeListener)listeners[i+1]).stateChanged(e);