1 19 20 package org.netbeans.modules.ant.freeform.customcommands; 21 22 import java.awt.Component ; 23 import java.util.ArrayList ; 24 import java.util.Iterator ; 25 import java.util.List ; 26 import javax.swing.event.ChangeEvent ; 27 import javax.swing.event.ChangeListener ; 28 import org.openide.WizardDescriptor; 29 import org.openide.util.HelpCtx; 30 31 public class NewCommandWizardPanel implements WizardDescriptor.Panel { 32 33 private NewCommandVisualPanel component; 34 private String [] likelyCommandNames; 35 36 public NewCommandWizardPanel(String [] likelyCommandNames) { 37 this.likelyCommandNames = likelyCommandNames; 38 } 39 40 public Component getComponent() { 41 if (component == null) { 42 component = new NewCommandVisualPanel(this, likelyCommandNames); 43 } 44 return component; 45 } 46 47 public HelpCtx getHelp() { 48 return new HelpCtx("org.netbeans.modules.ant.freeform.samples.custom-commands"); 49 } 50 51 public boolean isValid() { 52 return component.getCommand().length() > 0 && 53 component.getDisplayName().length() > 0 && 54 component.getMenu().length() > 0 && 55 component.getPosition() >= 0; 56 } 57 58 private final List listeners = new ArrayList (); 59 public final void addChangeListener(ChangeListener l) { 60 synchronized (listeners) { 61 listeners.add(l); 62 } 63 } 64 public final void removeChangeListener(ChangeListener l) { 65 synchronized (listeners) { 66 listeners.remove(l); 67 } 68 } 69 final void fireChangeEvent() { 70 Iterator it; 71 synchronized (listeners) { 72 it = new ArrayList (listeners).iterator(); 73 } 74 ChangeEvent ev = new ChangeEvent (this); 75 while (it.hasNext()) { 76 ((ChangeListener ) it.next()).stateChanged(ev); 77 } 78 } 79 80 public void readSettings(Object settings) {} 81 public void storeSettings(Object settings) { 82 WizardDescriptor d = (WizardDescriptor) settings; 83 d.putProperty("command", component.getCommand()); d.putProperty("displayName", component.getDisplayName() + " {0,choice,0#File|1#\"{1}\"|1<Files}"); d.putProperty("menu", component.getMenu()); d.putProperty("position", new Integer (component.getPosition())); } 88 89 } 90 91 | Popular Tags |