1 19 20 package org.netbeans.modules.ant.freeform.spi.support; 21 22 import java.io.File ; 23 import java.io.IOException ; 24 import java.util.List ; 25 import org.netbeans.modules.ant.freeform.FreeformProjectGenerator; 26 import org.netbeans.modules.ant.freeform.spi.TargetDescriptor; 27 import org.netbeans.modules.ant.freeform.ui.BasicProjectInfoWizardPanel; 28 import org.netbeans.modules.ant.freeform.ui.TargetMappingWizardPanel; 29 import org.netbeans.spi.project.support.ant.AntProjectHelper; 30 import org.openide.WizardDescriptor; 31 import org.openide.util.NbCollections; 32 33 57 public class NewFreeformProjectSupport { 58 59 60 public static final String PROP_ANT_SCRIPT = "antScript"; 62 63 public static final String PROP_PROJECT_NAME = "projectName"; 65 66 public static final String PROP_PROJECT_LOCATION = "projectLocation"; 68 69 public static final String PROP_PROJECT_FOLDER = "projectFolder"; 71 private NewFreeformProjectSupport() {} 72 73 78 public static final WizardDescriptor.Panel createBasicProjectInfoWizardPanel() { 79 return new BasicProjectInfoWizardPanel(); 80 } 81 82 87 public static final AntProjectHelper instantiateBasicProjectInfoWizardPanel(WizardDescriptor wiz) throws IOException { 88 File antScript = (File )wiz.getProperty(PROP_ANT_SCRIPT); 90 String projName = (String )wiz.getProperty(PROP_PROJECT_NAME); 91 File projLocation = (File )wiz.getProperty(PROP_PROJECT_LOCATION); 92 File projectFolder = (File )wiz.getProperty(PROP_PROJECT_FOLDER); 93 if (antScript.getParentFile().equals(projectFolder) && antScript.getName().equals("build.xml")) { antScript = null; 96 } 97 return FreeformProjectGenerator.createProject(projLocation, projectFolder, projName, antScript); 98 } 99 100 108 public static final WizardDescriptor.Panel createTargetMappingWizardPanel(List <TargetDescriptor> targets) { 109 return new TargetMappingWizardPanel(targets); 110 } 111 112 116 public static final void instantiateTargetMappingWizardPanel(AntProjectHelper helper, WizardDescriptor wiz) { 117 List <FreeformProjectGenerator.TargetMapping> mappings = NbCollections.checkedListByCopy( 118 (List ) wiz.getProperty(TargetMappingWizardPanel.PROP_TARGET_MAPPINGS), 119 FreeformProjectGenerator.TargetMapping.class, true); 120 121 FreeformProjectGenerator.putTargetMappings(helper, mappings); 122 FreeformProjectGenerator.putContextMenuAction(helper, mappings); 123 } 124 125 128 public static void uninitializeBasicProjectInfoWizardPanel(WizardDescriptor wiz) { 129 wiz.putProperty(NewFreeformProjectSupport.PROP_ANT_SCRIPT, null); 130 wiz.putProperty(NewFreeformProjectSupport.PROP_PROJECT_NAME, null); 131 wiz.putProperty(NewFreeformProjectSupport.PROP_PROJECT_LOCATION, null); 132 wiz.putProperty(NewFreeformProjectSupport.PROP_PROJECT_FOLDER, null); 133 } 134 135 136 139 public static void uninitializeTargetMappingWizardPanel(WizardDescriptor wiz) { 140 wiz.putProperty(TargetMappingWizardPanel.PROP_TARGET_MAPPINGS, null); 141 } 142 143 } 144 | Popular Tags |