1 19 20 package org.netbeans.modules.projectimport.eclipse.wizard; 21 22 import java.awt.Component ; 23 import java.beans.PropertyChangeEvent ; 24 import java.beans.PropertyChangeListener ; 25 import java.io.File ; 26 import org.netbeans.modules.projectimport.eclipse.EclipseUtils; 27 import org.openide.WizardDescriptor; 28 import org.openide.WizardValidationException; 29 30 35 final class SelectionWizardPanel extends ImporterWizardPanel implements 36 PropertyChangeListener , WizardDescriptor.ValidatingPanel { 37 38 private SelectionPanel panel; 39 40 41 SelectionWizardPanel() { 42 panel = new SelectionPanel(); 43 panel.addPropertyChangeListener(this); 44 initPanel(panel, 0); 45 } 46 47 public Component getComponent() { 48 return panel; 49 } 50 51 public void propertyChange(PropertyChangeEvent evt) { 52 String propName = evt.getPropertyName(); 53 if ("errorMessage".equals(propName)) { setErrorMessage((String ) evt.getNewValue()); 55 } else if ("workspaceChoosen".equals(propName)) { String [] steps; 57 if (((Boolean ) evt.getNewValue()).booleanValue()) { 58 steps = new String [] { WORKSPACE_LOCATION_STEP, PROJECTS_SELECTION_STEP }; 59 } else { 60 steps = new String [] { PROJECT_SELECTION_STEP }; 61 } 62 panel.putClientProperty("WizardPanel_contentData", steps); } 64 } 65 66 68 boolean isWorkspaceChosen() { 69 return panel.isWorkspaceChosen(); 70 } 71 72 73 String getProjectDir() { 74 return panel.getProjectDir(); 75 } 76 77 78 public String getProjectDestinationDir() { 79 return panel.getProjectDestinationDir(); 80 } 81 82 83 public String getWorkspaceDir() { 84 return panel.getWorkspaceDir(); 85 } 86 87 public void validate() throws WizardValidationException { 88 if (!panel.isWorkspaceChosen()) { 89 String dest = getProjectDestinationDir(); 90 91 String message = null; 92 if ((!new File (dest).isAbsolute()) || !EclipseUtils.isWritable(dest)) { 93 message = ProjectImporterWizard.getMessage( 94 "MSG_CannotCreateProjectInFolder", dest); } else if (!EclipseUtils.isRegularJavaProject(getProjectDir())) { 96 message = ProjectImporterWizard.getMessage( 97 "MSG_CannotImportNonJavaProject"); } 99 if (message != null) { 100 setErrorMessage(message); 101 throw new WizardValidationException(panel, message, null); 102 } 103 } 104 } 105 } 106 | Popular Tags |