1 19 20 package org.netbeans.modules.tasklist.core.util; 21 22 import java.awt.Component ; 23 import javax.swing.JComponent ; 24 import javax.swing.event.ChangeEvent ; 25 import javax.swing.event.ChangeListener ; 26 import javax.swing.event.EventListenerList ; 27 import org.openide.WizardDescriptor; 28 import org.openide.util.HelpCtx; 29 30 33 public class SimpleWizardPanel implements WizardDescriptor.FinishablePanel { 34 private EventListenerList listeners = new EventListenerList (); 35 36 37 protected Component component; 38 39 protected HelpCtx helpCtx = HelpCtx.DEFAULT_HELP; 40 41 42 private boolean valid = true; 43 44 45 protected WizardDescriptor wizard; 46 47 private boolean finish; 48 49 54 public SimpleWizardPanel(Component component) { 55 this.component = component; 56 } 57 58 63 public void setFinishPanel(boolean finish) { 64 this.finish = finish; 65 } 66 67 public void readSettings(Object settings) { 68 wizard = (WizardDescriptor) settings; 69 check(); 70 } 71 72 public void storeSettings(Object settings) { 73 } 74 75 81 public void setErrorMessage(String err) { 82 if (wizard != null) 83 wizard.putProperty("WizardPanel_errorMessage", err); this.valid = err == null; 85 } 86 87 92 public void setHelpContext(HelpCtx h) { 93 this.helpCtx = h; 94 } 95 96 public boolean isValid() { 97 return valid; 98 } 99 100 103 protected void check() { 104 } 105 106 public java.awt.Component getComponent() { 107 return component; 108 } 109 110 public HelpCtx getHelp() { 111 return helpCtx; 112 } 113 114 public void addChangeListener(ChangeListener l) { 115 listeners.add(ChangeListener .class, l); 116 } 117 118 public void removeChangeListener(ChangeListener l) { 119 listeners.remove(ChangeListener .class, l); 120 } 121 122 private void fireChange() { 123 Object [] l = listeners.getListenerList(); 125 ChangeEvent event = null; 126 127 for (int i = l.length - 2; i >= 0; i -= 2) { 130 if (l[i] == ChangeListener .class) { 131 if (event == null) 133 event = new ChangeEvent (this); 134 ((ChangeListener ) l[i+1]).stateChanged(event); 135 } 136 } 137 } 138 139 public boolean isFinishPanel() { 140 return finish; 141 } 142 143 148 public void setContentHighlightedIndex(int index) { 149 if (wizard != null) 150 wizard.putProperty("WizardPanel_contentSelectedIndex", new Integer (index)); 152 else 153 ((JComponent ) getComponent()).putClientProperty( 154 "WizardPanel_contentSelectedIndex", 155 new Integer (index)); } 157 } 158 | Popular Tags |