1 19 20 package org.netbeans.modules.form.palette; 21 22 import java.io.File ; 23 import java.util.Map ; 24 import javax.swing.event.ChangeListener ; 25 26 import org.openide.*; 27 28 import org.netbeans.modules.form.project.ClassSource; 29 30 39 40 class AddToPaletteWizard extends WizardDescriptor { 41 42 ATPWizardIterator wizardIterator; 43 44 private File [] selectedFiles; 45 private BeanInstaller.ItemInfo[] selectedBeans; 46 private String selectedCategory; 47 private String sourceType; 48 49 Map libraryNameMap; 52 private java.awt.Dialog dialog; 53 54 56 public AddToPaletteWizard() { 57 this(new ATPWizardIterator()); 58 } 59 60 private AddToPaletteWizard(ATPWizardIterator iterator) { 61 super(iterator); 62 wizardIterator = iterator; 63 64 putProperty("WizardPanel_autoWizardStyle", Boolean.TRUE); putProperty("WizardPanel_contentDisplayed", Boolean.TRUE); putProperty("WizardPanel_contentNumbered", Boolean.TRUE); 68 setTitle(PaletteUtils.getBundleString("CTL_AddToPaletteWizard_Title")); setTitleFormat(new java.text.MessageFormat ("{0}")); } 71 72 public boolean show(String sourceType) { 73 String firstStep_key; 74 this.sourceType = sourceType; 75 if (ClassSource.JAR_SOURCE.equals(sourceType)) 76 firstStep_key = "CTL_SelectJAR_Step"; else if (ClassSource.LIBRARY_SOURCE.equals(sourceType)) 78 firstStep_key = "CTL_SelectLibrary_Step"; else if (ClassSource.PROJECT_SOURCE.equals(sourceType)) 80 firstStep_key = "CTL_SelectProject_Step"; else 82 throw new IllegalArgumentException (); 83 84 putProperty("WizardPanel_contentData", new String [] { PaletteUtils.getBundleString(firstStep_key), 86 PaletteUtils.getBundleString("CTL_SelectBeans_Step"), PaletteUtils.getBundleString("CTL_SelectCategory_Step") }); 89 libraryNameMap = null; 90 wizardIterator.setSourceType(sourceType); 91 updateState(); 92 93 if (dialog == null) 94 dialog = DialogDisplayer.getDefault().createDialog(this); 95 dialog.setVisible(true); 96 dialog.dispose(); 97 98 return getValue() == FINISH_OPTION; 99 } 100 101 103 void stepToNext() { 104 if (wizardIterator.hasNext()) { 105 wizardIterator.nextPanel(); 106 updateState(); 107 } 108 } 109 110 void setJARFiles(File [] files) { 111 selectedFiles = files; 112 } 113 114 116 File [] getJARFiles() { 117 return selectedFiles; 118 } 119 120 void setSelectedBeans(BeanInstaller.ItemInfo[] beans) { 121 selectedBeans = beans; 122 } 123 124 BeanInstaller.ItemInfo[] getSelectedBeans() { 125 return selectedBeans; 126 } 127 128 void setSelectedCategory(String name) { 129 selectedCategory = name; 130 } 131 132 String getSelectedCategory() { 133 return selectedCategory; 134 } 135 136 String getSourceType() { 137 return sourceType; 138 } 139 140 142 143 static class ATPWizardIterator implements WizardDescriptor.Iterator { 144 145 WizardDescriptor.Panel[] panels = new WizardDescriptor.Panel[getPanelsCount()]; 146 int stage; 147 148 void setSourceType(String sourceType) { 149 if (ClassSource.JAR_SOURCE.equals(sourceType)) 150 panels[0] = new ChooseJARWizardPanel(); 151 else if (ClassSource.LIBRARY_SOURCE.equals(sourceType)) 152 panels[0] = new ChooseLibraryWizardPanel(); 153 else if (ClassSource.PROJECT_SOURCE.equals(sourceType)) 154 panels[0] = new ChooseProjectWizardPanel(); 155 else 156 throw new IllegalArgumentException (); 157 158 panels[1] = new ChooseBeansWizardPanel(); 159 panels[2] = new ChooseCategoryWizardPanel(); 160 161 stage = 1; 162 } 163 164 static int getPanelsCount() { 165 return 3; 166 } 167 168 171 public WizardDescriptor.Panel current() { 172 return panels[stage-1]; 173 } 174 175 public boolean hasNext() { 176 return stage < getPanelsCount(); 177 } 178 179 public boolean hasPrevious() { 180 return stage > 1; 181 } 182 183 public java.lang.String name() { 184 return ""; } 186 187 public void nextPanel() { 188 if (stage < getPanelsCount()) 189 stage++; 190 } 191 192 public void previousPanel() { 193 if (stage > 1) 194 stage--; 195 } 196 197 public void addChangeListener(ChangeListener listener) { 198 } 199 200 public void removeChangeListener(ChangeListener listener) { 201 } 202 } 203 } 204 | Popular Tags |