1 19 20 package org.netbeans.modules.projectimport.jbuilder; 21 import java.io.IOException ; 22 import org.netbeans.api.project.ui.OpenProjects; 23 import org.netbeans.modules.projectimport.j2seimport.ui.BasicWizardIterator; 24 import org.netbeans.modules.projectimport.j2seimport.ui.ProgressPanel; 25 import org.netbeans.modules.projectimport.j2seimport.ui.WarningMessage; 26 import org.netbeans.modules.projectimport.jbuilder.ui.JBWizardData; 27 import org.netbeans.modules.projectimport.jbuilder.ui.JBuilderWizardIterator; 28 import org.openide.ErrorManager; 29 import org.openide.filesystems.FileObject; 30 import org.openide.filesystems.FileUtil; 31 import org.openide.util.HelpCtx; 32 import org.openide.util.NbBundle; 33 import org.openide.util.actions.CallableSystemAction; 34 import org.netbeans.modules.projectimport.j2seimport.ImportProcess; 35 import org.netbeans.modules.projectimport.j2seimport.ImportUtils; 36 import org.netbeans.modules.projectimport.j2seimport.ui.WizardSupport; 37 38 43 public class ImportAction extends CallableSystemAction { 44 private BasicWizardIterator wizardIterator; 45 public ImportAction() { 46 putValue("noIconInMenu", Boolean.TRUE); } 48 49 public void performAction() { 50 try { 51 JBWizardData wizardData = showWizard(); 52 if (wizardData != null) { 53 performImport(wizardData); 54 } 55 } catch (Throwable thr) { 56 ErrorManager.getDefault().notify(thr); 57 } 58 } 59 60 private JBWizardData showWizard() { 61 if (wizardIterator == null) { 62 wizardIterator = JBuilderWizardIterator.createIterator(); 63 } 64 wizardIterator.setData(new JBWizardData()); 65 return (JBWizardData)WizardSupport.show(wizardIterator); 66 } 67 68 private void performImport(final JBWizardData wizardData) throws IOException { 69 ImportProcess iProcess; 70 FileObject prjDir = FileUtil.createFolder(wizardData.getDestinationDir()); 71 assert prjDir != null; 72 73 iProcess = ImportUtils.createImportProcess(prjDir,wizardData.getProjectDefinition(), 74 wizardData.isIncludeDependencies()); 75 76 ProgressPanel.showProgress(iProcess); 77 WarningMessage.showMessages(iProcess); 78 OpenProjects.getDefault().open(iProcess.getProjectsToOpen(), true); 79 } 80 81 82 public String getName() { 83 return NbBundle.getMessage(ImportAction.class, "CTL_MenuItem"); } 85 86 public HelpCtx getHelpCtx() { 87 return null; 88 } 89 90 protected boolean asynchronous() { 91 return false; 92 } 93 94 } 95 | Popular Tags |