1 19 20 package org.netbeans.modules.web.struts.wizards; 21 22 import java.awt.Component ; 23 import java.util.HashSet ; 24 import java.util.Iterator ; 25 import java.util.Set ; 26 import javax.swing.event.ChangeEvent ; 27 import javax.swing.event.ChangeListener ; 28 29 import org.openide.WizardDescriptor; 30 import org.openide.util.HelpCtx; 31 32 import org.netbeans.api.project.Project; 33 34 38 public class ActionPanel implements WizardDescriptor.Panel, WizardDescriptor.FinishablePanel, ChangeListener { 39 40 private WizardDescriptor wizardDescriptor; 41 private ActionPanelVisual component; 42 private Project project; 43 44 45 public ActionPanel(Project project, WizardDescriptor wizardDescriptor) { 46 this.project=project; 47 this.wizardDescriptor = wizardDescriptor; 48 } 49 50 Project getProject() { 51 return project; 52 } 53 54 public Component getComponent() { 55 if (component == null){ 56 component = new ActionPanelVisual(this); 57 component.addChangeListener(this); 58 } 59 return component; 60 } 61 62 public boolean isValid() { 63 getComponent(); 64 return component.valid(wizardDescriptor); 65 } 66 67 public void readSettings(Object settings) { 68 wizardDescriptor = (WizardDescriptor) settings; 69 component.read(wizardDescriptor); 70 } 71 72 public void storeSettings(Object settings) { 73 WizardDescriptor desc = (WizardDescriptor) settings; 74 component.store(desc); 75 } 76 77 public HelpCtx getHelp() { 78 return new HelpCtx(ActionPanel.class); 79 } 80 81 private final Set listeners = new HashSet (1); 82 83 public final void addChangeListener(ChangeListener l) { 84 synchronized (listeners) { 85 listeners.add(l); 86 } 87 } 88 public final void removeChangeListener(ChangeListener l) { 89 synchronized (listeners) { 90 listeners.remove(l); 91 } 92 } 93 public boolean isFinishPanel() { 94 return isValid(); 95 } 96 97 public void stateChanged(ChangeEvent e) { 98 fireChange(); 99 } 100 101 private void fireChange() { 102 ChangeEvent e = new ChangeEvent (this); 103 Iterator it = listeners.iterator(); 104 while (it.hasNext()) { 105 ((ChangeListener )it.next()).stateChanged(e); 106 } 107 } 108 } 109 | Popular Tags |