KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > projectimport > jbuilder > ImportAction


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.projectimport.jbuilder;
21 import java.io.IOException JavaDoc;
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 /**
39  * Runs JBuilder Importer.
40  *
41  * @author Radek Matous
42  */

43 public class ImportAction extends CallableSystemAction {
44     private BasicWizardIterator wizardIterator;
45     public ImportAction() {
46         putValue("noIconInMenu", Boolean.TRUE); //NOI18N
47
}
48     
49     public void performAction() {
50         try {
51             JBWizardData wizardData = showWizard();
52             if (wizardData != null) {
53                 performImport(wizardData);
54             }
55         } catch (Throwable JavaDoc 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 JavaDoc {
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 JavaDoc getName() {
83         return NbBundle.getMessage(ImportAction.class, "CTL_MenuItem"); // NOI18N
84
}
85     
86     public HelpCtx getHelpCtx() {
87         return null;
88     }
89     
90     protected boolean asynchronous() {
91         return false;
92     }
93     
94 }
95
Popular Tags