1 19 20 package org.netbeans.modules.projectimport.eclipse.wizard; 21 22 import java.util.ArrayList ; 23 import java.util.Iterator ; 24 import java.util.List ; 25 import javax.swing.JComponent ; 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 36 abstract class ImporterWizardPanel implements WizardDescriptor.Panel { 37 38 39 private List changeListeners; 40 41 42 private boolean valid; 43 44 45 private String errorMessage; 46 47 static final String WORKSPACE_LOCATION_STEP = 48 ProjectImporterWizard.getMessage("CTL_WorkspaceLocationStep"); static final String PROJECT_SELECTION_STEP = 50 ProjectImporterWizard.getMessage("CTL_ProjectSelectionStep"); static final String PROJECTS_SELECTION_STEP = 52 ProjectImporterWizard.getMessage("CTL_ProjectsSelectionStep"); 54 55 void initPanel(JComponent comp, int wizardNumber) { 56 comp.putClientProperty("WizardPanel_autoWizardStyle", Boolean.TRUE); comp.putClientProperty("WizardPanel_contentDisplayed", Boolean.TRUE); comp.putClientProperty("WizardPanel_contentNumbered", Boolean.TRUE); comp.putClientProperty("WizardPanel_contentSelectedIndex", new Integer (wizardNumber)); 61 comp.putClientProperty("WizardPanel_contentData", new String [] { WORKSPACE_LOCATION_STEP, PROJECTS_SELECTION_STEP 63 }); 64 comp.setPreferredSize(new java.awt.Dimension (500, 380)); 65 } 66 67 72 public void addChangeListener(ChangeListener l) { 73 if (changeListeners == null) { 74 changeListeners = new ArrayList (2); 75 } 76 changeListeners.add(l); 77 } 78 79 public void removeChangeListener(ChangeListener l) { 80 if (changeListeners != null) { 81 if (changeListeners.remove(l) && changeListeners.isEmpty()) { 82 changeListeners = null; 83 } 84 } 85 } 86 87 protected void fireChange() { 88 if (changeListeners != null) { 89 ChangeEvent e = new ChangeEvent (this); 90 for (Iterator i = changeListeners.iterator(); i.hasNext(); ) { 91 ((ChangeListener ) i.next()).stateChanged(e); 92 } 93 } 94 } 95 96 101 protected void setErrorMessage(String newError) { 102 boolean changed = 103 (errorMessage == null && newError != null) || 104 (errorMessage != null && !errorMessage.equals(newError)); 105 if (changed) errorMessage = newError; 106 setValid(newError == null, changed); 107 } 108 109 110 111 protected void setValid(boolean valid, boolean forceFiring) { 112 boolean changed = this.valid != valid; 113 if (changed) this.valid = valid; 114 if (changed || forceFiring) { 115 fireChange(); 116 } 117 } 118 119 120 String getErrorMessage() { 121 return errorMessage; 122 } 123 124 125 public boolean isValid() { 126 return valid; 127 } 128 129 public HelpCtx getHelp() { 130 return null; 131 } 132 133 public void storeSettings(Object settings) {;} 134 135 public void readSettings(Object settings) {;} 136 } 137 | Popular Tags |