1 19 20 package org.netbeans.modules.form.palette; 21 22 import javax.swing.*; 23 import javax.swing.event.*; 24 import java.beans.*; 25 26 import org.openide.WizardDescriptor; 27 import org.openide.explorer.*; 28 29 36 37 class ChooseCategoryWizardPanel implements WizardDescriptor.FinishablePanel { 38 39 private CategorySelector categorySelector; 40 41 private EventListenerList listenerList; 42 43 46 public java.awt.Component getComponent() { 47 if (categorySelector == null) { categorySelector = new CategorySelector(); 49 50 categorySelector.setName(PaletteUtils.getBundleString("CTL_SelectCategory_Caption")); categorySelector.putClientProperty("WizardPanel_contentSelectedIndex", new Integer (2)); 54 55 categorySelector.getExplorerManager().addPropertyChangeListener( 56 new PropertyChangeListener() { 57 public void propertyChange(PropertyChangeEvent ev) { 58 if (ExplorerManager.PROP_SELECTED_NODES.equals(ev.getPropertyName())) 59 fireStateChanged(); 60 } 61 }); 62 } 63 64 return categorySelector; 65 } 66 67 public org.openide.util.HelpCtx getHelp() { 68 return new org.openide.util.HelpCtx("beans.adding"); } 71 72 public boolean isValid() { 73 return categorySelector != null 74 && categorySelector.getSelectedCategory() != null; 75 } 76 77 public void readSettings(Object settings) { 78 } 79 80 public void storeSettings(Object settings) { 81 if (categorySelector != null) 82 ((AddToPaletteWizard)settings).setSelectedCategory(categorySelector.getSelectedCategory()); 83 } 84 85 public void addChangeListener(ChangeListener listener) { 86 if (listenerList == null) 87 listenerList = new EventListenerList(); 88 listenerList.add(ChangeListener.class, listener); 89 } 90 91 public void removeChangeListener(ChangeListener listener) { 92 if (listenerList != null) 93 listenerList.remove(ChangeListener.class, listener); 94 } 95 96 public boolean isFinishPanel() { 98 return true; 99 } 100 101 103 void fireStateChanged() { 104 if (listenerList == null) 105 return; 106 107 ChangeEvent e = null; 108 Object [] listeners = listenerList.getListenerList(); 109 for (int i=listeners.length-2; i >= 0; i-=2) { 110 if (listeners[i] == ChangeListener.class) { 111 if (e == null) 112 e = new ChangeEvent(this); 113 ((ChangeListener)listeners[i+1]).stateChanged(e); 114 } 115 } 116 } 117 } 118 | Popular Tags |