1 19 20 package org.netbeans.modules.xml.wsdl.ui.wizard; 21 22 import java.awt.Component ; 23 import java.util.HashSet ; 24 import java.util.Iterator ; 25 import java.util.NoSuchElementException ; 26 import java.util.Set ; 27 28 import javax.swing.JComponent ; 29 import javax.swing.event.ChangeEvent ; 30 import javax.swing.event.ChangeListener ; 31 32 import org.netbeans.modules.xml.wsdl.model.PortType; 33 import org.netbeans.modules.xml.wsdl.ui.extensibility.model.WSDLExtensibilityElements; 34 import org.netbeans.modules.xml.wsdl.ui.extensibility.model.WSDLExtensibilityElementsFactory; 35 import org.openide.WizardDescriptor; 36 37 public final class CreateBindingFromPortTypeWizardIterator implements WizardDescriptor.Iterator { 38 39 56 57 private int index; 58 59 private WizardDescriptor.Panel[] panels; 60 61 private PortType mPortType; 62 private WSDLExtensibilityElements extensibilityElements; 63 64 public CreateBindingFromPortTypeWizardIterator(PortType portType) { 65 mPortType = portType; 66 try { 67 extensibilityElements 68 = WSDLExtensibilityElementsFactory.getInstance().getWSDLExtensibilityElements(); 69 70 } catch (Exception e) { 71 72 } 73 } 74 78 private WizardDescriptor.Panel[] getPanels() { 79 if (panels == null) { 80 panels = new WizardDescriptor.Panel[] { 81 new CreateBindingFromPortTypeWizardPanel1(mPortType, extensibilityElements) 85 }; 86 String [] steps = new String [panels.length]; 87 for (int i = 0; i < panels.length; i++) { 88 Component c = panels[i].getComponent(); 89 steps[i] = c.getName(); 91 if (c instanceof JComponent ) { JComponent jc = (JComponent ) c; 93 jc.putClientProperty("WizardPanel_contentSelectedIndex", new Integer (i)); 95 jc.putClientProperty("WizardPanel_contentData", steps); 97 jc.putClientProperty("WizardPanel_autoWizardStyle", Boolean.TRUE); 99 jc.putClientProperty("WizardPanel_contentDisplayed", Boolean.TRUE); 101 jc.putClientProperty("WizardPanel_contentNumbered", Boolean.TRUE); 103 } 104 } 105 } 106 return panels; 107 } 108 109 public WizardDescriptor.Panel current() { 110 return getPanels()[index]; 111 } 112 113 public String name() { 114 return index + 1 + ". from " + getPanels().length; 115 } 116 117 public boolean hasNext() { 118 if (current().isValid()) { 119 return index < getPanels().length - 1; 120 } 121 return false; 122 } 123 124 public boolean hasPrevious() { 125 return index > 0; 126 } 127 128 public void nextPanel() { 129 if (!hasNext()) { 130 throw new NoSuchElementException (); 131 } 132 index++; 133 } 134 135 public void previousPanel() { 136 if (!hasPrevious()) { 137 throw new NoSuchElementException (); 138 } 139 index--; 140 } 141 142 145 146 150 private Set <ChangeListener > listeners = new HashSet <ChangeListener >(1); 151 public final void addChangeListener(ChangeListener l) { 152 synchronized (listeners) { 153 listeners.add(l); 154 } 155 } 156 public final void removeChangeListener(ChangeListener l) { 157 synchronized (listeners) { 158 listeners.remove(l); 159 } 160 } 161 protected final void fireChangeEvent() { 162 Iterator <ChangeListener > it; 163 synchronized (listeners) { 164 it = new HashSet <ChangeListener >(listeners).iterator(); 165 } 166 ChangeEvent ev = new ChangeEvent (this); 167 while (it.hasNext()) { 168 it.next().stateChanged(ev); 169 } 170 } 171 172 173 } 174 | Popular Tags |