1 19 20 package org.netbeans.modules.projectimport.eclipse.wizard; 21 22 import java.awt.Dialog ; 23 import java.util.Iterator ; 24 import java.util.Set ; 25 import javax.swing.event.ChangeEvent ; 26 import javax.swing.event.ChangeListener ; 27 import org.netbeans.modules.projectimport.eclipse.EclipseProject; 28 import org.openide.DialogDescriptor; 29 import org.openide.DialogDisplayer; 30 import org.openide.NotifyDescriptor; 31 import org.openide.WizardDescriptor; 32 import org.openide.util.NbBundle; 33 34 39 public final class ProjectImporterWizard { 40 41 private Set projects; 42 private String destination; 43 private boolean recursively; 44 private boolean cancelled; 45 private int numberOfImportedProjects; 46 47 48 public void start() { 49 final EclipseWizardIterator iterator = new EclipseWizardIterator(); 50 final WizardDescriptor wizardDescriptor = new WizardDescriptor(iterator); 51 iterator.addChangeListener(new ChangeListener () { 52 public void stateChanged(ChangeEvent e) { 53 wizardDescriptor.putProperty("WizardPanel_errorMessage", iterator.getErrorMessage()); 55 } 56 }); 57 wizardDescriptor.setTitleFormat(new java.text.MessageFormat ("{1}")); wizardDescriptor.setTitle( 59 ProjectImporterWizard.getMessage("CTL_WizardTitle")); Dialog dialog = DialogDisplayer.getDefault().createDialog(wizardDescriptor); 61 dialog.setVisible(true); 62 dialog.toFront(); 63 cancelled = wizardDescriptor.getValue() != WizardDescriptor.FINISH_OPTION; 64 if (!cancelled) { 65 projects = iterator.getProjects(); 66 showAdditionalInfo(projects); 67 destination = iterator.getDestination(); 68 recursively = iterator.getRecursively(); 69 numberOfImportedProjects = iterator.getNumberOfImportedProject(); 70 } 71 } 72 73 private void showAdditionalInfo(Set projects) { 74 StringBuffer messages = null; 75 for (Iterator it = projects.iterator(); it.hasNext(); ) { 76 EclipseProject prj = (EclipseProject) it.next(); 77 Set natures = prj.getOtherNatures(); 78 if (natures != null && !natures.isEmpty()) { 79 if (messages == null) { 80 messages = new StringBuffer ( 81 getMessage("MSG_CreatedByPlugin") + "\n\n"); } 83 messages.append(" - " + prj.getName()); } 85 } 86 if (messages != null) { 87 NotifyDescriptor d = new DialogDescriptor.Message( 88 messages.toString(), NotifyDescriptor.INFORMATION_MESSAGE); 89 DialogDisplayer.getDefault().notify(d); 90 } 91 } 92 93 94 public Set getProjects() { 95 return projects; 96 } 97 98 102 public int getNumberOfImportedProject() { 103 return numberOfImportedProjects; 104 } 105 106 109 public String getDestination() { 110 return destination; 111 } 112 113 public boolean getRecursively() { 114 return recursively; 115 } 116 117 120 public boolean isCancelled() { 121 return cancelled; 122 } 123 124 125 static String getMessage(String key) { 126 return NbBundle.getMessage(ProjectImporterWizard.class, key); 127 } 128 129 130 static String getMessage(String key, Object param1) { 131 return NbBundle.getMessage(ProjectImporterWizard.class, key, param1); 132 } 133 } 134 | Popular Tags |