1 19 20 package org.netbeans.modules.ruby.rubyproject.ui.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.JComponent ; 27 import javax.swing.event.ChangeEvent ; 28 import javax.swing.event.ChangeListener ; 29 import org.openide.WizardDescriptor; 30 import org.openide.WizardValidationException; 31 import org.openide.util.HelpCtx; 32 33 37 public final class PanelConfigureProject implements WizardDescriptor.Panel, WizardDescriptor.ValidatingPanel, WizardDescriptor.FinishablePanel { 38 39 private WizardDescriptor wizardDescriptor; 40 private int type; 41 private PanelConfigureProjectVisual component; 42 43 44 public PanelConfigureProject( int type ) { 45 this.type = type; 46 } 47 48 public Component getComponent() { 49 if (component == null) { 50 component = new PanelConfigureProjectVisual(this, this.type); 51 } 52 return component; 53 } 54 55 public HelpCtx getHelp() { 56 57 switch ( type ) { 58 case NewRubyProjectWizardIterator.TYPE_APP: 59 return new HelpCtx( this.getClass().getName() + "_APP" ); case NewRubyProjectWizardIterator.TYPE_EXT: 63 return new HelpCtx( this.getClass().getName() + "_EXT" ); } 65 return new HelpCtx( PanelConfigureProject.class ); 66 } 67 68 public boolean isValid() { 69 getComponent(); 70 return component.valid( wizardDescriptor ); 71 } 72 73 private final Set listeners = new HashSet (1); 74 public final void addChangeListener(ChangeListener l) { 75 synchronized (listeners) { 76 listeners.add(l); 77 } 78 } 79 public final void removeChangeListener(ChangeListener l) { 80 synchronized (listeners) { 81 listeners.remove(l); 82 } 83 } 84 protected final void fireChangeEvent() { 85 Iterator it; 86 synchronized (listeners) { 87 it = new HashSet (listeners).iterator(); 88 } 89 ChangeEvent ev = new ChangeEvent (this); 90 while (it.hasNext()) { 91 ((ChangeListener )it.next()).stateChanged(ev); 92 } 93 } 94 95 public void readSettings(Object settings) { 96 wizardDescriptor = (WizardDescriptor)settings; 97 component.read (wizardDescriptor); 98 99 Object substitute = ((JComponent )component).getClientProperty ("NewProjectWizard_Title"); if (substitute != null) { 103 wizardDescriptor.putProperty ("NewProjectWizard_Title", substitute); } 105 } 106 107 public void storeSettings(Object settings) { 108 WizardDescriptor d = (WizardDescriptor)settings; 109 component.store(d); 110 ((WizardDescriptor)d).putProperty ("NewProjectWizard_Title", null); } 112 113 public boolean isFinishPanel() { 114 return true; 115 } 116 117 public void validate () throws WizardValidationException { 118 getComponent (); 119 component.validate (wizardDescriptor); 120 } 121 122 } 123 | Popular Tags |