Java Code Examples for org.openide.WizardDescriptor#getProperty()

The following examples show how to use org.openide.WizardDescriptor#getProperty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PanelProjectLocationVisual.java    From netbeans with Apache License 2.0 6 votes vote down vote up
void read (WizardDescriptor d) {
    File projectLocation = (File) d.getProperty ("projectFolder");  //NOI18N
    if (projectLocation == null || projectLocation.getParentFile() == null || !projectLocation.getParentFile().isDirectory ()) {
        projectLocation = ProjectChooser.getProjectsFolder();
    } else {
        projectLocation = projectLocation.getParentFile();
    }
    
    Integer count = (Integer) d.getProperty("WizardPanel_GrailsProjectCounter");
    String formater = NbBundle.getMessage(PanelProjectLocationVisual.class, "TXT_GrailsApplication");
    
    int baseCount = count.intValue();
    
    String newPrjName = (String) d.getProperty ("name"); //NOI18N
    if (newPrjName == null) {        
        while ((newPrjName = validFreeProjectName(projectLocation, formater, baseCount)) == null) {
            baseCount++;
        }
    }
    
    projectLocationTextField.setText(projectLocation.getAbsolutePath());
    projectFolderTextField.setText( projectLocation.getAbsolutePath() + File.separatorChar + projectNameTextField.getText().trim() );
    projectNameTextField.setText(newPrjName);
}
 
Example 2
Source File: PanelSourceFolders.java    From netbeans with Apache License 2.0 6 votes vote down vote up
boolean valid (WizardDescriptor settings) {
    File projectLocation = (File) settings.getProperty (ProjectLocationWizardPanel.PROJECT_DIR);  //NOI18N
    String confFolder = jTextFieldConfigFiles.getText().trim();
    if (confFolder.length() == 0) {
        wizardDescriptor.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, // NOI18N
                NbBundle.getMessage(PanelSourceFolders.class, "MSG_BlankConfigurationFilesFolder"));
        return false;
    }
    File[] sourceRoots = ((FolderList)this.sourcePanel).getFiles();
    File[] testRoots = ((FolderList)this.testsPanel).getFiles();
    String result = checkValidity (projectLocation, getConfigFiles(), sourceRoots, testRoots);
    if (result == null) {
        wizardDescriptor.putProperty( WizardDescriptor.PROP_ERROR_MESSAGE," ");   //NOI18N
        return true;
    }
    else {
        wizardDescriptor.putProperty( WizardDescriptor.PROP_ERROR_MESSAGE,result);       //NOI18N
        return false;
    }
}
 
Example 3
Source File: BuildOptionsPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void readSettings(WizardDescriptor wiz) {
    if (wizard == null) {
        wizard = wiz;
    }

    component.setBuildContext((String) wiz.getProperty(BuildImageWizard.BUILD_CONTEXT_PROPERTY));
    String dockerfile = (String) wiz.getProperty(BuildImageWizard.DOCKERFILE_PROPERTY);
    if (dockerfile == null) {
        dockerfile = DockerAction.DOCKER_FILE;
    }
    component.setDockerfile(dockerfile);
    Boolean pull = (Boolean) wiz.getProperty(BuildImageWizard.PULL_PROPERTY);
    component.setPull(pull != null ? pull : BuildImageWizard.PULL_DEFAULT);
    Boolean noCache = (Boolean) wiz.getProperty(BuildImageWizard.NO_CACHE_PROPERTY);
    component.setPull(noCache != null ? noCache : BuildImageWizard.NO_CACHE_DEFAULT);

    // XXX revalidate; is this bug?
    changeSupport.fireChange();
}
 
Example 4
Source File: Util.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static void mergeSteps(WizardDescriptor wizard, WizardDescriptor.Panel[] panels, String[] steps) {
    Object prop = wizard.getProperty(WIZARD_PANEL_CONTENT_DATA);
    String[] beforeSteps;
    int offset;
    if (prop instanceof String[]) {
        beforeSteps = (String[]) prop;
        offset = beforeSteps.length;
        if (offset > 0 && ("...".equals(beforeSteps[offset - 1]))) {// NOI18N
            offset--;
        }
    } else {
        beforeSteps = null;
        offset = 0;
    }
    String[] resultSteps = new String[ (offset) + panels.length];
    for (int i = 0; i < offset; i++) {
        resultSteps[i] = beforeSteps[i];
    }
    setSteps(panels, steps, resultSteps, offset);
}
 
Example 5
Source File: hostviewPanelVisual.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
void read(WizardDescriptor settings) {
    File projectLocation = (File) settings.getProperty("projdir");
    if (projectLocation == null || projectLocation.getParentFile() == null || !projectLocation.getParentFile().isDirectory()) {
        projectLocation = ProjectChooser.getProjectsFolder();
    } else {
        projectLocation = projectLocation.getParentFile();
    }
    this.projectLocationTextField.setText(projectLocation.getAbsolutePath());

    String projectName = (String) settings.getProperty("name");
    if (projectName == null) {
        projectName = "hostview";
    }
    this.projectNameTextField.setText(projectName);
    this.projectNameTextField.selectAll();
}
 
Example 6
Source File: TargetMappingWizardPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void readSettings(Object settings) {
    wizardDescriptor = (WizardDescriptor)settings;        
    wizardDescriptor.putProperty("NewProjectWizard_Title", component.getClientProperty("NewProjectWizard_Title")); // NOI18N
    File f = (File)wizardDescriptor.getProperty(NewFreeformProjectSupport.PROP_ANT_SCRIPT);
    FileObject fo = FileUtil.toFileObject(f);
    // Util.getAntScriptTargetNames can return null when script is 
    // invalid but first panel checks script validity so it is OK here.
    List<String> l = null;
    try {
        l = AntScriptUtils.getCallableTargetNames(fo);
    } catch (IOException x) {/* ignore */}
    // #47784 - update panel only once or when Ant script has changed
    if (targetNames == null || !targetNames.equals(l)) {
        targetNames = new ArrayList<String>(l);
        component.setTargetNames(l, true);
    }
    File projDir = (File)wizardDescriptor.getProperty(NewFreeformProjectSupport.PROP_PROJECT_FOLDER);
    File antScript = (File)wizardDescriptor.getProperty(NewFreeformProjectSupport.PROP_ANT_SCRIPT);
    if (!(antScript.getParentFile().equals(projDir) && antScript.getName().equals("build.xml"))) { // NOI18N
        // NON-DEFAULT location of build file
        component.setScript("${"+ProjectConstants.PROP_ANT_SCRIPT+"}"); // NOI18N
    } else {
        component.setScript(null);
    }
}
 
Example 7
Source File: PanelProjectLocationVisual.java    From netbeans with Apache License 2.0 6 votes vote down vote up
void read (WizardDescriptor settings) {
    File projectLocation = (File) settings.getProperty(WizardProperties.PROJECT_DIR);
    if (projectLocation == null)
        projectLocation = ProjectChooser.getProjectsFolder();
    else
        projectLocation = projectLocation.getParentFile();
    
    projectLocationTextField.setText(projectLocation.getAbsolutePath());
    
    String formater = null;
    String projectName = (String) settings.getProperty(WizardProperties.NAME);
    
    if (projectName == null) {
        formater = NbBundle.getMessage(PanelProjectLocationVisual.class, "LBL_NPW1_DefaultProjectName"); //NOI18N
    } else {
        formater = projectName + "{0}"; //NOI18N
    }
    if ((projectName == null) || (validFreeProjectName(projectLocation, projectName) == null)) {
        int baseCount = 1;
        while ((projectName = validFreeProjectName(projectLocation, formater, baseCount)) == null) {
            baseCount++;
        }
    }
    projectNameTextField.setText(projectName);
    projectNameTextField.selectAll();
}
 
Example 8
Source File: ArchetypeWizardUtils.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Instantiates archetype stored in given wizard descriptor.
 */
static Set<FileObject> instantiate(WizardDescriptor wiz) throws IOException {
    ProjectInfo vi = new ProjectInfo((String) wiz.getProperty("groupId"), (String) wiz.getProperty("artifactId"), (String) wiz.getProperty("version"), (String) wiz.getProperty("package")); //NOI18N

    Archetype arch = (Archetype) wiz.getProperty("archetype"); //NOI18N
    logUsage(arch.getGroupId(), arch.getArtifactId(), arch.getVersion());

    @SuppressWarnings("unchecked")
    Map<String,String> additional = (Map<String,String>) wiz.getProperty(ADDITIONAL_PROPS);

    File projFile = FileUtil.normalizeFile((File) wiz.getProperty(CommonProjectActions.PROJECT_PARENT_FOLDER)); // NOI18N
    createFromArchetype(projFile, vi, arch, additional, true);
    Set<FileObject> projects = openProjects(projFile, null);
    return projects;
}
 
Example 9
Source File: TemplateValueInjector.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
public static void setupNewModule(Map<String, Object> parameters, WizardDescriptor wiz, String platformPropertyName, boolean newProject) {
    AndroidSdk androidSdk = (AndroidSdk) wiz.getProperty(PROP_PROJECT_SDK);
    parameters.put(ATTR_SDK_DIR, androidSdk.getSdkPath());
    int maxBuildLevel = (int) wiz.getProperty(PROP_MAX_BUILD_LEVEL);
    PlatformDecorator platformInfo = (PlatformDecorator) wiz.getProperty(platformPropertyName);
    parameters.put(ATTR_IS_NEW_PROJECT, newProject); // Android Modules are called Gradle Projects
    parameters.put(ATTR_THEME_EXISTS, true); // New modules always have a theme (unless its a library, but it will have no activity)

    parameters.put(ATTR_MIN_API_LEVEL, platformInfo.getAndroidVersion().getApiLevel());
    parameters.put(ATTR_MIN_API, platformInfo.getAndroidVersion().getApiString());
    parameters.put(ATTR_BUILD_API, maxBuildLevel);
    parameters.put(ATTR_BUILD_API_STRING, String.valueOf(maxBuildLevel));

    parameters.put(ATTR_TARGET_API, maxBuildLevel);
    parameters.put(ATTR_TARGET_API_STRING, String.valueOf(maxBuildLevel));

    parameters.put(ATTR_BUILD_API_REVISION, maxBuildLevel);
    parameters.put(ATTR_BUILD_TOOLS_VERSION, wiz.getProperty(BUILD_TOOL_VERSION));

    parameters.put(ATTR_GRADLE_PLUGIN_VERSION, "3.4.0");
    parameters.put(ATTR_GRADLE_VERSION, SdkConstants.GRADLE_LATEST_VERSION);
    parameters.put(ATTR_IS_INSTANT_APP, false);
    parameters.put(ATTR_JAVA_VERSION, "1.7");
    parameters.put(ATTR_KOTLIN_VERSION, "1.0.0");
    parameters.put(ATTR_IS_LOW_MEMORY, false);
    parameters.put(ATTR_IS_GRADLE, true);
    parameters.put(ATTR_MAKE_IGNORE, true);
    parameters.put("target.files", new HashSet<>());
    parameters.put("files.to.open", new ArrayList<>());
    parameters.put(ATTR_CREATE_ACTIVITY, true);

}
 
Example 10
Source File: ListenerIterator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void initialize (WizardDescriptor wiz) {
    this.wiz = (TemplateWizard) wiz;
    index = 0;
    panels = createPanels (this.wiz);
    
    // Creating steps.
    Object prop = wiz.getProperty (WizardDescriptor.PROP_CONTENT_DATA); // NOI18N
    String[] beforeSteps = null;
    if (prop != null && prop instanceof String[]) {
        beforeSteps = (String[])prop;
    }
    String[] steps = Utilities.createSteps (beforeSteps, panels);
    
    for (int i = 0; i < panels.length; i++) {
        Component c = panels[i].getComponent ();
        if (steps[i] == null) {
            // Default step name to component name of panel.
            // Mainly useful for getting the name of the target
            // chooser to appear in the list of steps.
            steps[i] = c.getName ();
        }
        if (c instanceof JComponent) { // assume Swing components
            JComponent jc = (JComponent) c;
            // Step #.
            jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, Integer.valueOf(i));
            // Step name (actually the whole list for reference).
            jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps);
        }
    }
}
 
Example 11
Source File: InitializrProjectPanelVisual2.java    From nb-springboot with Apache License 2.0 5 votes vote down vote up
void read(WizardDescriptor wd) {
    if (!initialized) {
        final JsonNode meta = (JsonNode) wd.getProperty(WIZ_METADATA);
        init(meta);
    } else {
        pBootDependencies.setSelectedDependenciesString((String) wd.getProperty(WIZ_DEPENDENCIES));
        cbBootVersion.setSelectedItem(wd.getProperty(WIZ_BOOT_VERSION));
    }
}
 
Example 12
Source File: CreateTerrainWizardPanel2.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void readSettings(Object settings) {
    WizardDescriptor wiz = (WizardDescriptor) settings;
    terrainTotalSize = (Integer)wiz.getProperty("totalSize");
}
 
Example 13
Source File: TvActivityWizardIterator.java    From NBANDROID-V2 with Apache License 2.0 4 votes vote down vote up
@Override
public void initialize(WizardDescriptor wizard) {
    this.wizard = wizard;
    index = 0;
    panels = createPanels();
    // Make sure list of steps is accurate.
    steps = createSteps();
    wizard.putProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, 0);
    for (int i = 0; i < panels.size(); i++) {
        Component c = panels.get(i).getComponent();
        if (c instanceof JComponent) { // assume Swing components
            JComponent jc = (JComponent) c;
            // Step #.
            // TODO if using org.openide.dialogs >= 7.8, can use WizardDescriptor.PROP_*:
            jc.putClientProperty("WizardPanel_contentSelectedIndex", new Integer(i));
            // Step name (actually the whole list for reference).
            jc.putClientProperty("WizardPanel_contentData", steps.toArray(new String[steps.size()]));
        }
    }
    NewFileWizard fileWizard = (NewFileWizard) wizard;
    try {
        Project project = (Project) wizard.getProperty("project");
        if (AndroidProjects.isAndroidMavenProject(project) && (project instanceof NbAndroidProjectImpl)) {
            NbAndroidProjectImpl gradleProject = (NbAndroidProjectImpl) project;
            File projectDirectory = gradleProject.getProjectDirectoryAsFile();
            DataFolder targetFolder = fileWizard.getTargetFolder();
            String targetPath = targetFolder.getPrimaryFile().getPath();
            BuildVariant buildVariant = project.getLookup().lookup(BuildVariant.class);
            AndroidSources androidSources = project.getLookup().lookup(AndroidSources.class);
            SourceGroup[] sourceGroups = androidSources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
            FileObject srcRootFolder = null;
            for (SourceGroup sourceGroup : sourceGroups) {
                if (sourceGroup.contains(targetFolder.getPrimaryFile())) {
                    srcRootFolder = sourceGroup.getRootFolder();
                }
            }
            sourceGroups = androidSources.getSourceGroups(AndroidConstants.ANDROID_MANIFEST_XML);
            FileObject manifestRootFolder = null;
            if (sourceGroups.length == 1) {
                manifestRootFolder = sourceGroups[0].getRootFolder();
            }
            wizard.putProperty(MANIFEST_ROOT_FOLDER, FileUtil.toFile(manifestRootFolder));
            Variant variant = buildVariant.getCurrentVariant();
            wizard.putProperty(BUILD_VARIANT, variant);
            if (srcRootFolder != null) {
                String packageName = targetPath.replace(srcRootFolder.getPath(), "");
                packageName = packageName.replace("/", ".").replace("\\", ".");
                packageName = packageName.substring(1);
                wizard.putProperty(PROP_PROJECT_PACKAGE, packageName);
            }
            AndroidPlatformInfo projectPlatform = AndroidProjects.projectPlatform(project);
            if (projectPlatform != null) {
                AndroidSdk sdk = projectPlatform.getSdk();
                wizard.putProperty(PROP_PROJECT_SDK, sdk);
                wizard.putProperty(AndroidProjectTemplatePanelVisualAndroidSettings.PROP_TV_PLATFORM, new PlatformDecorator(projectPlatform));
                wizard.putProperty(AndroidProjectTemplatePanelVisualAndroidSettings.PROP_TV_ENABLED, true);
            }
            Project rootProject = AndroidProjects.findRootProject(project);
            if (rootProject != null) {
                wizard.putProperty(AndroidProjectTemplatePanelVisualBasicSettings.PROP_PROJECT_DIR, FileUtil.toFile(rootProject.getProjectDirectory()));
                String folderName = project.getProjectDirectory().getPath().replace(rootProject.getProjectDirectory().getPath(), "").substring(1);
                if (!folderName.contains("/") && !folderName.contains("\\")) {
                    wizard.putProperty(AndroidProjectTemplatePanelVisualAndroidSettings.PROP_TV_FOLDER, folderName);
                }
            }
            AndroidProject aPrj = project.getLookup().lookup(AndroidProject.class);
            if (aPrj != null) {
                String buildToolsVersion = aPrj.getBuildToolsVersion();
                wizard.putProperty(BUILD_TOOL_VERSION, buildToolsVersion);
            }
            wizard.putProperty(ERROR_NO_ANDROID, false);
        } else {
            wizard.putProperty(ERROR_NO_ANDROID, true);
        }

    } catch (IOException ex) {
        Exceptions.printStackTrace(ex);
    }
}
 
Example 14
Source File: FileWizardIterator.java    From NBANDROID-V2 with Apache License 2.0 4 votes vote down vote up
@Override
public void initialize(WizardDescriptor wizard) {
    this.wizard = wizard;
    String displayName = (String) wizard.getProperty("NewFileWizard_Title");
    type = Type.find(displayName);
    index = 0;
    panels = createPanels();
    // Make sure list of steps is accurate.
    steps = createSteps();
    wizard.putProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, 0);
    for (int i = 0; i < panels.size(); i++) {
        Component c = panels.get(i).getComponent();
        if (c instanceof JComponent) { // assume Swing components
            JComponent jc = (JComponent) c;
            // Step #.
            // TODO if using org.openide.dialogs >= 7.8, can use WizardDescriptor.PROP_*:
            jc.putClientProperty("WizardPanel_contentSelectedIndex", new Integer(i));
            // Step name (actually the whole list for reference).
            jc.putClientProperty("WizardPanel_contentData", steps.toArray(new String[steps.size()]));
        }
    }
    NewFileWizard fileWizard = (NewFileWizard) wizard;
    try {
        Project project = (Project) wizard.getProperty("project");
        if (AndroidProjects.isAndroidMavenProject(project) && (project instanceof NbAndroidProjectImpl)) {
            NbAndroidProjectImpl gradleProject = (NbAndroidProjectImpl) project;
            File projectDirectory = gradleProject.getProjectDirectoryAsFile();
            DataFolder targetFolder = fileWizard.getTargetFolder();
            String targetPath = targetFolder.getPrimaryFile().getPath();
            BuildVariant buildVariant = project.getLookup().lookup(BuildVariant.class);
            AndroidSources androidSources = project.getLookup().lookup(AndroidSources.class);
            SourceGroup[] sourceGroups = androidSources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
            FileObject srcRootFolder = null;
            for (SourceGroup sourceGroup : sourceGroups) {
                if (sourceGroup.contains(targetFolder.getPrimaryFile())) {
                    srcRootFolder = sourceGroup.getRootFolder();
                }
            }
            sourceGroups = androidSources.getSourceGroups(AndroidConstants.ANDROID_MANIFEST_XML);
            FileObject manifestRootFolder = null;
            if (sourceGroups.length == 1) {
                manifestRootFolder = sourceGroups[0].getRootFolder();
            }
            wizard.putProperty(MANIFEST_ROOT_FOLDER, FileUtil.toFile(manifestRootFolder));
            Variant variant = buildVariant.getCurrentVariant();
            wizard.putProperty(BUILD_VARIANT, variant);
            if (srcRootFolder != null) {
                String packageName = targetPath.replace(srcRootFolder.getPath(), "");
                packageName = packageName.replace("/", ".").replace("\\", ".");
                packageName = packageName.substring(1);
                wizard.putProperty(PROP_PROJECT_PACKAGE, packageName);
            }
            AndroidPlatformInfo projectPlatform = AndroidProjects.projectPlatform(project);
            if (projectPlatform != null) {
                AndroidSdk sdk = projectPlatform.getSdk();
                wizard.putProperty(PROP_PROJECT_SDK, sdk);
                wizard.putProperty(PROP_PLATFORM, new PlatformDecorator(projectPlatform));
            }
            Project rootProject = AndroidProjects.findRootProject(project);
            if (rootProject != null) {
                wizard.putProperty(AndroidProjectTemplatePanelVisualBasicSettings.PROP_PROJECT_DIR, FileUtil.toFile(rootProject.getProjectDirectory()));
                String folderName = project.getProjectDirectory().getPath().replace(rootProject.getProjectDirectory().getPath(), "").substring(1);
                if (!folderName.contains("/") && !folderName.contains("\\")) {
                    wizard.putProperty(PROP_SUB_PROJECT_FOLDER, folderName);
                }
            }
            AndroidProject aPrj = project.getLookup().lookup(AndroidProject.class);
            if (aPrj != null) {
                String buildToolsVersion = aPrj.getBuildToolsVersion();
                wizard.putProperty(BUILD_TOOL_VERSION, buildToolsVersion);
            }
            wizard.putProperty(ERROR_NO_ANDROID, false);
        } else {
            wizard.putProperty(ERROR_NO_ANDROID, true);
        }

    } catch (IOException ex) {
        Exceptions.printStackTrace(ex);
    }
}
 
Example 15
Source File: WebLocationsWizardPanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void readSettings(Object settings) {
    wizardDescriptor = (WizardDescriptor) settings;
    wizardDescriptor.putProperty("NewProjectWizard_Title", component.getClientProperty("NewProjectWizard_Title")); // NOI18N

    //guess webapps well-known locations and preset them
    File baseFolder = (File)wizardDescriptor.getProperty(NewFreeformProjectSupport.PROP_PROJECT_LOCATION);
    File nbProjectFolder = (File)wizardDescriptor.getProperty(NewFreeformProjectSupport.PROP_PROJECT_FOLDER);
    final String webPages;
    final String webInf;
    final String srcPackages;
    if(baseFolder.equals(this.baseFolder)) {
        webPages = component.getWebPagesLocation().getAbsolutePath();
        webInf = component.getWebInfLocation().getAbsolutePath();
        srcPackages = component.getSrcPackagesLocation().getAbsolutePath();
    } else {
        this.baseFolder = baseFolder;
        FileObject fo = FileUtil.toFileObject(baseFolder);
        if (fo != null) {
            FileObject webPagesFO = FileSearchUtility.guessDocBase(fo);
            if (webPagesFO == null)
                webPages = ""; //NOI18N
            else
                webPages = FileUtil.toFile(webPagesFO).getAbsolutePath();
            
            FileObject webInfFO = FileSearchUtility.guessWebInf(fo);
            if (webInfFO == null)
                webInf = ""; //NOI18N
            else
                webInf = FileUtil.toFile(webInfFO).getAbsolutePath();
            
            srcPackages = guessJavaRoot(fo);
        } else {
            webPages = ""; // NOI18N
            webInf = ""; //NOI18N
            srcPackages = ""; // NOI18N
        }
    }
    component.setFolders(baseFolder, nbProjectFolder);
    component.setWebPages(webPages);
    component.setWebInf(webInf);
    component.setSrcPackages(srcPackages);
}
 
Example 16
Source File: WearActivityWizardIterator.java    From NBANDROID-V2 with Apache License 2.0 4 votes vote down vote up
@Override
public void initialize(WizardDescriptor wizard) {
    this.wizard = wizard;
    index = 0;
    panels = createPanels();
    // Make sure list of steps is accurate.
    steps = createSteps();
    wizard.putProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, 0);
    for (int i = 0; i < panels.size(); i++) {
        Component c = panels.get(i).getComponent();
        if (c instanceof JComponent) { // assume Swing components
            JComponent jc = (JComponent) c;
            // Step #.
            // TODO if using org.openide.dialogs >= 7.8, can use WizardDescriptor.PROP_*:
            jc.putClientProperty("WizardPanel_contentSelectedIndex", new Integer(i));
            // Step name (actually the whole list for reference).
            jc.putClientProperty("WizardPanel_contentData", steps.toArray(new String[steps.size()]));
        }
    }
    NewFileWizard fileWizard = (NewFileWizard) wizard;
    try {
        Project project = (Project) wizard.getProperty("project");
        if (AndroidProjects.isAndroidMavenProject(project) && (project instanceof NbAndroidProjectImpl)) {
            NbAndroidProjectImpl gradleProject = (NbAndroidProjectImpl) project;
            File projectDirectory = gradleProject.getProjectDirectoryAsFile();
            DataFolder targetFolder = fileWizard.getTargetFolder();
            String targetPath = targetFolder.getPrimaryFile().getPath();
            BuildVariant buildVariant = project.getLookup().lookup(BuildVariant.class);
            AndroidSources androidSources = project.getLookup().lookup(AndroidSources.class);
            SourceGroup[] sourceGroups = androidSources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
            FileObject srcRootFolder = null;
            for (SourceGroup sourceGroup : sourceGroups) {
                if (sourceGroup.contains(targetFolder.getPrimaryFile())) {
                    srcRootFolder = sourceGroup.getRootFolder();
                }
            }
            sourceGroups = androidSources.getSourceGroups(AndroidConstants.ANDROID_MANIFEST_XML);
            FileObject manifestRootFolder = null;
            if (sourceGroups.length == 1) {
                manifestRootFolder = sourceGroups[0].getRootFolder();
            }
            wizard.putProperty(MANIFEST_ROOT_FOLDER, FileUtil.toFile(manifestRootFolder));
            Variant variant = buildVariant.getCurrentVariant();
            wizard.putProperty(BUILD_VARIANT, variant);
            if (srcRootFolder != null) {
                String packageName = targetPath.replace(srcRootFolder.getPath(), "");
                packageName = packageName.replace("/", ".").replace("\\", ".");
                packageName = packageName.substring(1);
                wizard.putProperty(PROP_PROJECT_PACKAGE, packageName);
            }
            AndroidPlatformInfo projectPlatform = AndroidProjects.projectPlatform(project);
            if (projectPlatform != null) {
                AndroidSdk sdk = projectPlatform.getSdk();
                wizard.putProperty(PROP_PROJECT_SDK, sdk);
                wizard.putProperty(AndroidProjectTemplatePanelVisualAndroidSettings.PROP_WEAR_PLATFORM, new PlatformDecorator(projectPlatform));
                wizard.putProperty(AndroidProjectTemplatePanelVisualAndroidSettings.PROP_WEAR_ENABLED, true);
            }
            Project rootProject = AndroidProjects.findRootProject(project);
            if (rootProject != null) {
                wizard.putProperty(AndroidProjectTemplatePanelVisualBasicSettings.PROP_PROJECT_DIR, FileUtil.toFile(rootProject.getProjectDirectory()));
                String folderName = project.getProjectDirectory().getPath().replace(rootProject.getProjectDirectory().getPath(), "").substring(1);
                if (!folderName.contains("/") && !folderName.contains("\\")) {
                    wizard.putProperty(AndroidProjectTemplatePanelVisualAndroidSettings.PROP_WEAR_FOLDER, folderName);
                }
            }
            AndroidProject aPrj = project.getLookup().lookup(AndroidProject.class);
            if (aPrj != null) {
                String buildToolsVersion = aPrj.getBuildToolsVersion();
                wizard.putProperty(BUILD_TOOL_VERSION, buildToolsVersion);
            }
            wizard.putProperty(ERROR_NO_ANDROID, false);
        } else {
            wizard.putProperty(ERROR_NO_ANDROID, true);
        }

    } catch (IOException ex) {
        Exceptions.printStackTrace(ex);
    }
}
 
Example 17
Source File: SDKWizardPanelInstall.java    From NBANDROID-V2 with Apache License 2.0 4 votes vote down vote up
@Override
public void readSettings(WizardDescriptor wiz) {
    File platformTools = (File) wiz.getProperty(PLATFORM_TOOLS);
    File tools = (File) wiz.getProperty(SDK_TOOLS);
    getComponent().setZipFiles(tools, platformTools);
}
 
Example 18
Source File: MobileActivityWizardIterator.java    From NBANDROID-V2 with Apache License 2.0 4 votes vote down vote up
@Override
public void initialize(WizardDescriptor wizard) {
    this.wizard = wizard;
    index = 0;
    panels = createPanels();
    // Make sure list of steps is accurate.
    steps = createSteps();
    wizard.putProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, 0);
    for (int i = 0; i < panels.size(); i++) {
        Component c = panels.get(i).getComponent();
        if (c instanceof JComponent) { // assume Swing components
            JComponent jc = (JComponent) c;
            // Step #.
            // TODO if using org.openide.dialogs >= 7.8, can use WizardDescriptor.PROP_*:
            jc.putClientProperty("WizardPanel_contentSelectedIndex", new Integer(i));
            // Step name (actually the whole list for reference).
            jc.putClientProperty("WizardPanel_contentData", steps.toArray(new String[steps.size()]));
        }
    }
    NewFileWizard fileWizard = (NewFileWizard) wizard;
    try {
        Project project = (Project) wizard.getProperty("project");
        if (AndroidProjects.isAndroidMavenProject(project) && (project instanceof NbAndroidProjectImpl)) {
            NbAndroidProjectImpl gradleProject = (NbAndroidProjectImpl) project;
            File projectDirectory = gradleProject.getProjectDirectoryAsFile();
            DataFolder targetFolder = fileWizard.getTargetFolder();
            String targetPath = targetFolder.getPrimaryFile().getPath();
            BuildVariant buildVariant = project.getLookup().lookup(BuildVariant.class);
            AndroidSources androidSources = project.getLookup().lookup(AndroidSources.class);
            SourceGroup[] sourceGroups = androidSources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
            FileObject srcRootFolder = null;
            for (SourceGroup sourceGroup : sourceGroups) {
                if (sourceGroup.contains(targetFolder.getPrimaryFile())) {
                    srcRootFolder = sourceGroup.getRootFolder();
                }
            }
            sourceGroups = androidSources.getSourceGroups(AndroidConstants.ANDROID_MANIFEST_XML);
            FileObject manifestRootFolder = null;
            if (sourceGroups.length == 1) {
                manifestRootFolder = sourceGroups[0].getRootFolder();
            }
            wizard.putProperty(MANIFEST_ROOT_FOLDER, FileUtil.toFile(manifestRootFolder));
            Variant variant = buildVariant.getCurrentVariant();
            wizard.putProperty(BUILD_VARIANT, variant);
            if (srcRootFolder != null) {
                try {
                    String packageName = targetPath.replace(srcRootFolder.getPath(), "");
                    packageName = packageName.replace("/", ".").replace("\\", ".");
                    packageName = packageName.substring(1);
                    wizard.putProperty(PROP_PROJECT_PACKAGE, packageName);
                } catch (Exception e) {
                }
            }
            PlatformDecorator projectPlatform = new PlatformDecorator(AndroidProjects.projectPlatform(project));
            if (projectPlatform != null) {
                AndroidSdk sdk = projectPlatform.getSdk();
                wizard.putProperty(PROP_PROJECT_SDK, sdk);
                wizard.putProperty(PROP_PHONE_TABLET_PLATFORM, projectPlatform);
                wizard.putProperty(PROP_PHONE_TABLET_ENABLED, true);
            }
            Project rootProject = AndroidProjects.findRootProject(project);
            if (rootProject != null) {
                wizard.putProperty(AndroidProjectTemplatePanelVisualBasicSettings.PROP_PROJECT_DIR, FileUtil.toFile(rootProject.getProjectDirectory()));
                String folderName = project.getProjectDirectory().getPath().replace(rootProject.getProjectDirectory().getPath(), "").substring(1);
                if (!folderName.contains("/") && !folderName.contains("\\")) {
                    wizard.putProperty(PROP_PHONE_TABLET_FOLDER, folderName);
                }
            }
            AndroidProject aPrj = project.getLookup().lookup(AndroidProject.class);
            if (aPrj != null) {
                String buildToolsVersion = aPrj.getBuildToolsVersion();
                wizard.putProperty(BUILD_TOOL_VERSION, buildToolsVersion);
            }
            wizard.putProperty(ERROR_NO_ANDROID, false);
        } else {
            wizard.putProperty(ERROR_NO_ANDROID, true);
        }

    } catch (IOException ex) {
        Exceptions.printStackTrace(ex);
    }
}
 
Example 19
Source File: ProjectVisualSummaryPanel.java    From NBANDROID-V2 with Apache License 2.0 4 votes vote down vote up
boolean valid(WizardDescriptor wizardDescriptor) {
    Object property = wizardDescriptor.getProperty(ERROR_NO_ANDROID);
    if ((property instanceof Boolean) && ((Boolean) property)) {
        wizardDescriptor.putProperty("WizardPanel_errorMessage",
                "Unsupported project type.");
        return false;
    }
    property = wizardDescriptor.getProperty(AndroidProjectTemplatePanelVisualBasicSettings.PROP_PROJECT_PACKAGE);
    if (!(property instanceof String) || ((String) property).isEmpty()) {
        wizardDescriptor.putProperty("WizardPanel_errorMessage",
                "Bad package name.");
        return false;
    }
    property = wizardDescriptor.getProperty(MANIFEST_ROOT_FOLDER);
    if (!(property instanceof File)) {
        wizardDescriptor.putProperty("WizardPanel_errorMessage",
                "Android manifest was not found.");
        return false;
    }
    property = wizardDescriptor.getProperty(PROP_PROJECT_SDK);
    if (!(property instanceof AndroidSdk)) {
        wizardDescriptor.putProperty("WizardPanel_errorMessage",
                "Android SDK was not found.");
        return false;
    }
    switch (type) {
        case MOBILE:
            property = wizardDescriptor.getProperty(PROP_PHONE_TABLET_PLATFORM);
            break;
        case WEAR:
            property = wizardDescriptor.getProperty(AndroidProjectTemplatePanelVisualAndroidSettings.PROP_WEAR_PLATFORM);
            break;
        case TV:
            property = wizardDescriptor.getProperty(AndroidProjectTemplatePanelVisualAndroidSettings.PROP_TV_PLATFORM);
            break;
        case FILE:
            property = wizardDescriptor.getProperty(PROP_PLATFORM);

            break;
        default:
            throw new AssertionError(type.name());
    }
    if (!(property instanceof PlatformDecorator)) {
        wizardDescriptor.putProperty("WizardPanel_errorMessage",
                "Android Platform was not found.");
        return false;
    }
    property = wizardDescriptor.getProperty(MobileActivityWizardIterator.BUILD_VARIANT);
    if (!(property instanceof Variant)) {
        wizardDescriptor.putProperty("WizardPanel_errorMessage",
                "Android Build variant was not found.");
        return false;
    }
    switch (type) {
        case MOBILE:
            property = wizardDescriptor.getProperty(PROP_PHONE_TABLET_FOLDER);
            break;
        case WEAR:
            property = wizardDescriptor.getProperty(AndroidProjectTemplatePanelVisualAndroidSettings.PROP_WEAR_FOLDER);
            break;
        case TV:
            property = wizardDescriptor.getProperty(AndroidProjectTemplatePanelVisualAndroidSettings.PROP_TV_FOLDER);
            break;
        case FILE:
            property = wizardDescriptor.getProperty(PROP_SUB_PROJECT_FOLDER);

            break;
        default:
            throw new AssertionError(type.name());
    }
    if (!(property instanceof String) || ((String) property).isEmpty()) {
        wizardDescriptor.putProperty("WizardPanel_errorMessage",
                "Unsupported project structure.");
        return false;
    }
    return true;
}
 
Example 20
Source File: ContainerItemSetupPanelVisual.java    From netbeans with Apache License 2.0 4 votes vote down vote up
static boolean isClientControlledPattern(WizardDescriptor settings) {
    Pattern p = (Pattern) settings.getProperty(WizardProperties.PATTERN_SELECTION);
    return p == Pattern.CLIENTCONTROLLED;
}