1 19 20 package org.netbeans.modules.j2ee.earproject.ui.wizards; 21 22 import java.awt.Component ; 23 import java.util.HashSet ; 24 import java.util.Iterator ; 25 import java.util.Set ; 26 27 import javax.swing.JComponent ; 28 import javax.swing.event.ChangeEvent ; 29 import javax.swing.event.ChangeListener ; 30 31 import org.openide.WizardDescriptor; 32 import org.openide.util.HelpCtx; 33 import java.util.ResourceBundle ; 34 35 39 final public class PanelConfigureProject implements WizardDescriptor.Panel, WizardDescriptor.FinishablePanel { 40 41 private WizardDescriptor wizardDescriptor; 42 private PanelConfigureProjectVisual component; 43 private String namePropIndex; 44 private ResourceBundle customBundle; 45 boolean importStyle = false; 46 private HelpCtx helpId; 47 private final Set <ChangeListener > listeners = new HashSet <ChangeListener >(1); 48 49 50 public PanelConfigureProject(String namePropIndex, ResourceBundle customBundle, 51 HelpCtx helpId, boolean importStyle) { 52 this(namePropIndex, customBundle, helpId); 53 this.importStyle = importStyle; 54 } 55 56 public PanelConfigureProject(String namePropIndex, ResourceBundle customBundle, 57 HelpCtx helpId) { 58 this.namePropIndex = namePropIndex; 59 this.customBundle = customBundle; 60 this.helpId = helpId; 61 } 62 63 public boolean isFinishPanel() { 64 return true; 65 } 66 67 public Component getComponent() { 68 if (component == null) { 69 component = new PanelConfigureProjectVisual(this, namePropIndex, customBundle, importStyle); 70 } 71 return component; 72 } 73 74 public HelpCtx getHelp() { 75 return helpId; 76 } 77 78 public boolean isValid() { 79 getComponent(); 80 return component.valid(wizardDescriptor); 81 } 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 protected final void fireChangeEvent() { 94 Iterator <ChangeListener > it; 95 synchronized (listeners) { 96 it = new HashSet <ChangeListener >(listeners).iterator(); 97 } 98 ChangeEvent ev = new ChangeEvent (this); 99 while (it.hasNext()) { 100 it.next().stateChanged(ev); 101 } 102 } 103 104 public void readSettings(Object settings) { 105 wizardDescriptor = (WizardDescriptor) settings; 106 component.read (wizardDescriptor); 107 108 Object substitute = ((JComponent ) component).getClientProperty("NewProjectWizard_Title"); if (substitute != null) 112 wizardDescriptor.putProperty("NewProjectWizard_Title", substitute); } 114 115 public void storeSettings(Object settings) { 116 WizardDescriptor d = (WizardDescriptor) settings; 117 component.store(d); 118 ((WizardDescriptor) d).putProperty("NewProjectWizard_Title", null); } 120 121 public String getProjectTypeFlag() { 122 return "NWP1"; 123 } 124 125 } 126 | Popular Tags |