Java Code Examples for org.netbeans.spi.project.ui.support.ProjectChooser#setProjectsFolder()
The following examples show how to use
org.netbeans.spi.project.ui.support.ProjectChooser#setProjectsFolder() .
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: SampleWizardIterator.java From netbeans with Apache License 2.0 | 6 votes |
@Override public Set<?> instantiate(ProgressHandle handle) throws IOException { FileObject targetFolder = Templates.getTargetFolder(descriptor); String targetName = Templates.getTargetName(descriptor); FileUtil.toFile(targetFolder).mkdirs(); FileObject projectFolder = targetFolder.createFolder(targetName); FileObject template = Templates.getTemplate(descriptor); unZipFile(template.getInputStream(), projectFolder); ProjectManager.getDefault().clearNonProjectCache(); Map<String, String> map = new HashMap<String, String>(); map.put("${project.name}", targetName); // NOI18N replaceTokens(projectFolder, map , "nbproject/project.properties"); // NOI18N ProjectChooser.setProjectsFolder(FileUtil.toFile(targetFolder)); return Collections.singleton(projectFolder); }
Example 2
Source File: datasourceWizardIterator.java From visualvm with GNU General Public License v2.0 | 5 votes |
public Set/*<FileObject>*/ instantiate(/*ProgressHandle handle*/) throws IOException { Set<FileObject> resultSet = new LinkedHashSet<FileObject>(); File dirF = FileUtil.normalizeFile((File) wiz.getProperty("projdir")); dirF.mkdirs(); FileObject template = Templates.getTemplate(wiz); FileObject dir = FileUtil.toFileObject(dirF); unZipFile(template.getInputStream(), dir); // Always open top dir as a project: resultSet.add(dir); // Look for nested projects to open as well: Enumeration<? extends FileObject> e = dir.getFolders(true); while (e.hasMoreElements()) { FileObject subfolder = e.nextElement(); if (ProjectManager.getDefault().isProject(subfolder)) { resultSet.add(subfolder); } } File parent = dirF.getParentFile(); if (parent != null && parent.exists()) { ProjectChooser.setProjectsFolder(parent); } return resultSet; }
Example 3
Source File: jvmcapsWizardIterator.java From visualvm with GNU General Public License v2.0 | 5 votes |
public Set/*<FileObject>*/ instantiate(/*ProgressHandle handle*/) throws IOException { Set<FileObject> resultSet = new LinkedHashSet<FileObject>(); File dirF = FileUtil.normalizeFile((File) wiz.getProperty("projdir")); dirF.mkdirs(); FileObject template = Templates.getTemplate(wiz); FileObject dir = FileUtil.toFileObject(dirF); unZipFile(template.getInputStream(), dir); // Always open top dir as a project: resultSet.add(dir); // Look for nested projects to open as well: Enumeration<? extends FileObject> e = dir.getFolders(true); while (e.hasMoreElements()) { FileObject subfolder = e.nextElement(); if (ProjectManager.getDefault().isProject(subfolder)) { resultSet.add(subfolder); } } File parent = dirF.getParentFile(); if (parent != null && parent.exists()) { ProjectChooser.setProjectsFolder(parent); } return resultSet; }
Example 4
Source File: ProjectServicesImpl.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void createNewProject(File workingDir) { Action newProjectAction = CommonProjectActions.newProjectAction(); if (newProjectAction != null) { ProjectChooser.setProjectsFolder(workingDir); newProjectAction.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "command")); // NOI18N } }
Example 5
Source File: PanelProjectLocationVisual.java From netbeans with Apache License 2.0 | 5 votes |
void store(WizardDescriptor d) { String name = projectNameTextField.getText().trim(); d.putProperty(WizardProperties.PROJECT_DIR, new File(createdFolderTextField.getText().trim())); d.putProperty(WizardProperties.NAME, name); File projectsDir = new File(this.projectLocationTextField.getText()); if (projectsDir.isDirectory()) { ProjectChooser.setProjectsFolder (projectsDir); } }
Example 6
Source File: hellovvmWizardIterator.java From visualvm with GNU General Public License v2.0 | 5 votes |
public Set/*<FileObject>*/ instantiate(/*ProgressHandle handle*/) throws IOException { Set<FileObject> resultSet = new LinkedHashSet<FileObject>(); File dirF = FileUtil.normalizeFile((File) wiz.getProperty("projdir")); dirF.mkdirs(); FileObject template = Templates.getTemplate(wiz); FileObject dir = FileUtil.toFileObject(dirF); unZipFile(template.getInputStream(), dir); // Always open top dir as a project: resultSet.add(dir); // Look for nested projects to open as well: Enumeration<? extends FileObject> e = dir.getFolders(true); while (e.hasMoreElements()) { FileObject subfolder = e.nextElement(); if (ProjectManager.getDefault().isProject(subfolder)) { resultSet.add(subfolder); } } File parent = dirF.getParentFile(); if (parent != null && parent.exists()) { ProjectChooser.setProjectsFolder(parent); } return resultSet; }
Example 7
Source File: apptypeWizardIterator.java From visualvm with GNU General Public License v2.0 | 5 votes |
public Set/*<FileObject>*/ instantiate(/*ProgressHandle handle*/) throws IOException { Set<FileObject> resultSet = new LinkedHashSet<FileObject>(); File dirF = FileUtil.normalizeFile((File) wiz.getProperty("projdir")); dirF.mkdirs(); FileObject template = Templates.getTemplate(wiz); FileObject dir = FileUtil.toFileObject(dirF); unZipFile(template.getInputStream(), dir); // Always open top dir as a project: resultSet.add(dir); // Look for nested projects to open as well: Enumeration<? extends FileObject> e = dir.getFolders(true); while (e.hasMoreElements()) { FileObject subfolder = e.nextElement(); if (ProjectManager.getDefault().isProject(subfolder)) { resultSet.add(subfolder); } } File parent = dirF.getParentFile(); if (parent != null && parent.exists()) { ProjectChooser.setProjectsFolder(parent); } return resultSet; }
Example 8
Source File: subnodesWizardIterator.java From visualvm with GNU General Public License v2.0 | 5 votes |
public Set/*<FileObject>*/ instantiate(/*ProgressHandle handle*/) throws IOException { Set<FileObject> resultSet = new LinkedHashSet<FileObject>(); File dirF = FileUtil.normalizeFile((File) wiz.getProperty("projdir")); dirF.mkdirs(); FileObject template = Templates.getTemplate(wiz); FileObject dir = FileUtil.toFileObject(dirF); unZipFile(template.getInputStream(), dir); // Always open top dir as a project: resultSet.add(dir); // Look for nested projects to open as well: Enumeration<? extends FileObject> e = dir.getFolders(true); while (e.hasMoreElements()) { FileObject subfolder = e.nextElement(); if (ProjectManager.getDefault().isProject(subfolder)) { resultSet.add(subfolder); } } File parent = dirF.getParentFile(); if (parent != null && parent.exists()) { ProjectChooser.setProjectsFolder(parent); } return resultSet; }
Example 9
Source File: BasicGameWizardIterator.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public Set/*<FileObject>*/ instantiate(/*ProgressHandle handle*/) throws IOException { Set<FileObject> resultSet = new LinkedHashSet<FileObject>(); File dirF = FileUtil.normalizeFile((File) wiz.getProperty("projdir")); dirF.mkdirs(); FileObject template = Templates.getTemplate(wiz); FileObject dir = FileUtil.toFileObject(dirF); unZipFile(template.getInputStream(), dir); // Always open top dir as a project: resultSet.add(dir); // Look for nested projects to open as well: Enumeration<? extends FileObject> e = dir.getFolders(true); while (e.hasMoreElements()) { FileObject subfolder = e.nextElement(); if (ProjectManager.getDefault().isProject(subfolder)) { resultSet.add(subfolder); } } File parent = dirF.getParentFile(); if (parent != null && parent.exists()) { ProjectChooser.setProjectsFolder(parent); } return resultSet; }
Example 10
Source File: GroovyJavaDemoWizardIterator.java From netbeans with Apache License 2.0 | 5 votes |
public Set/*<FileObject>*/ instantiate(/*ProgressHandle handle*/) throws IOException { Set<FileObject> resultSet = new LinkedHashSet<FileObject>(); File dirF = FileUtil.normalizeFile((File) wiz.getProperty("projdir")); dirF.mkdirs(); FileObject template = Templates.getTemplate(wiz); FileObject dir = FileUtil.toFileObject(dirF); unZipFile(template.getInputStream(), dir); // Always open top dir as a project: resultSet.add(dir); // Look for nested projects to open as well: Enumeration<? extends FileObject> e = dir.getFolders(true); while (e.hasMoreElements()) { FileObject subfolder = e.nextElement(); if (ProjectManager.getDefault().isProject(subfolder)) { resultSet.add(subfolder); } } File parent = dirF.getParentFile(); if (parent != null && parent.exists()) { ProjectChooser.setProjectsFolder(parent); } return resultSet; }
Example 11
Source File: ProjectAttributesPanelVisual.java From netbeans with Apache License 2.0 | 5 votes |
void write(WizardDescriptor settings) { File projectFolder = new File(tfProjectLocation.getText()); ProjectChooser.setProjectsFolder(projectFolder); settings.putProperty(CommonProjectActions.PROJECT_PARENT_FOLDER, projectFolder); settings.putProperty(PROP_NAME, tfProjectName.getText()); settings.putProperty(PROP_GROUP, tfGroup.getText()); settings.putProperty(PROP_VERSION, tfVersion.getText()); settings.putProperty(PROP_DESCRIPTION, tfDescription.getText()); settings.putProperty(PROP_PACKAGE_BASE, tfPackageBase.getText()); settings.putProperty(PROP_CHANGED_PKG, changedPackageBase); settings.putProperty(PROP_INIT_WRAPPER, cbInitWrapper.isSelected()); }
Example 12
Source File: ApisupportAntUIUtils.java From netbeans with Apache License 2.0 | 5 votes |
/** * Calls in turn {@link ProjectChooser#setProjectsFolder} if the * <code>folder</code> is not <code>null</code> and is a directory. */ public static void setProjectChooserDir(File folder) { if (folder == null || !folder.isDirectory()) { return; } ProjectChooser.setProjectsFolder(folder); }
Example 13
Source File: PanelProjectLocationVisual.java From netbeans with Apache License 2.0 | 5 votes |
void store(WizardDescriptor d) { String name = projectNameTextField.getText().trim(); d.putProperty(WizardProperties.PROJECT_DIR, new File(createdFolderTextField.getText().trim())); d.putProperty(WizardProperties.NAME, name); File projectsDir = new File(this.projectLocationTextField.getText()); if (projectsDir.isDirectory()) { ProjectChooser.setProjectsFolder (projectsDir); } }
Example 14
Source File: pluggableViewDemoSuiteWizardIterator.java From visualvm with GNU General Public License v2.0 | 5 votes |
public Set/*<FileObject>*/ instantiate(/*ProgressHandle handle*/) throws IOException { Set<FileObject> resultSet = new LinkedHashSet<FileObject>(); File dirF = FileUtil.normalizeFile((File) wiz.getProperty("projdir")); dirF.mkdirs(); FileObject template = Templates.getTemplate(wiz); FileObject dir = FileUtil.toFileObject(dirF); unZipFile(template.getInputStream(), dir); // Always open top dir as a project: resultSet.add(dir); // Look for nested projects to open as well: Enumeration<? extends FileObject> e = dir.getFolders(true); while (e.hasMoreElements()) { FileObject subfolder = e.nextElement(); if (ProjectManager.getDefault().isProject(subfolder)) { resultSet.add(subfolder); } } File parent = dirF.getParentFile(); if (parent != null && parent.exists()) { ProjectChooser.setProjectsFolder(parent); } return resultSet; }
Example 15
Source File: hostviewWizardIterator.java From visualvm with GNU General Public License v2.0 | 5 votes |
public Set/*<FileObject>*/ instantiate(/*ProgressHandle handle*/) throws IOException { Set<FileObject> resultSet = new LinkedHashSet<FileObject>(); File dirF = FileUtil.normalizeFile((File) wiz.getProperty("projdir")); dirF.mkdirs(); FileObject template = Templates.getTemplate(wiz); FileObject dir = FileUtil.toFileObject(dirF); unZipFile(template.getInputStream(), dir); // Always open top dir as a project: resultSet.add(dir); // Look for nested projects to open as well: Enumeration<? extends FileObject> e = dir.getFolders(true); while (e.hasMoreElements()) { FileObject subfolder = e.nextElement(); if (ProjectManager.getDefault().isProject(subfolder)) { resultSet.add(subfolder); } } File parent = dirF.getParentFile(); if (parent != null && parent.exists()) { ProjectChooser.setProjectsFolder(parent); } return resultSet; }
Example 16
Source File: NewEarProjectWizardIterator.java From netbeans with Apache License 2.0 | 4 votes |
static void setProjectChooserFolder(final File dirF) { File parentF = (dirF != null) ? dirF.getParentFile() : null; if (parentF != null && parentF.exists()) { ProjectChooser.setProjectsFolder(parentF); } }
Example 17
Source File: ImportAppClientProjectWizardIterator.java From netbeans with Apache License 2.0 | 4 votes |
public Set<FileObject> instantiate(ProgressHandle handle) throws IOException { handle.start(3); handle.progress(NbBundle.getMessage(ImportAppClientProjectWizardIterator.class, "LBL_NewAppClientProjectWizardIterator_WizardProgress_CreatingProject"), 1); Set<FileObject> resultSet = new HashSet<FileObject>(); File dirF = (File) wiz.getProperty(ProjectLocationWizardPanel.PROJECT_DIR); if (dirF != null) { dirF = FileUtil.normalizeFile(dirF); } AppClientProjectCreateData createData = new AppClientProjectCreateData(); createData.setProjectDir(dirF); createData.setName((String) wiz.getProperty(ProjectLocationWizardPanel.NAME)); createData.setSourceFolders((File[]) wiz.getProperty(WizardProperties.JAVA_ROOT)); createData.setTestFolders((File[]) wiz.getProperty(WizardProperties.TEST_ROOT)); createData.setConfFolder((File) wiz.getProperty(WizardProperties.CONFIG_FILES_FOLDER)); createData.setLibFolder((File) wiz.getProperty(WizardProperties.LIB_FOLDER)); createData.setServerInstanceID((String) wiz.getProperty(ProjectServerWizardPanel.SERVER_INSTANCE_ID)); createData.setJavaEEProfile((Profile) wiz.getProperty(ProjectServerWizardPanel.J2EE_LEVEL)); createData.setLibrariesDefinition( SharabilityUtility.getLibraryLocation((String) wiz.getProperty(ProjectServerWizardPanel.WIZARD_SHARED_LIBRARIES))); AntProjectHelper h = AppClientProjectGenerator.importProject(createData); handle.progress(2); FileObject dir = FileUtil.toFileObject (dirF); Project earProject = (Project) wiz.getProperty(ProjectServerWizardPanel.EAR_APPLICATION); AppClientProject createdAppClientProject = (AppClientProject) ProjectManager.getDefault().findProject(dir); if (earProject != null && createdAppClientProject != null) { Ear ear = Ear.getEar(earProject.getProjectDirectory()); if (ear != null) { ear.addCarModule(createdAppClientProject.getAPICar()); } } resultSet.add (dir); dirF = (dirF != null) ? dirF.getParentFile() : null; if (dirF != null && dirF.exists()) { ProjectChooser.setProjectsFolder (dirF); } // remember last used server UserProjectSettings.getDefault().setLastUsedServer(createData.getServerInstanceID()); // downgrade the Java platform or src level to 1.4 String platformName = (String)wiz.getProperty(ProjectServerWizardPanel.JAVA_PLATFORM); String sourceLevel = (String)wiz.getProperty(ProjectServerWizardPanel.SOURCE_LEVEL); if (platformName != null || sourceLevel != null) { AppClientProjectGenerator.setPlatform(h, platformName, sourceLevel); } handle.progress(NbBundle.getMessage(ImportAppClientProjectWizardIterator.class, "LBL_NewAppClientProjectWizardIterator_WizardProgress_PreparingToOpen"), 3); return resultSet; }
Example 18
Source File: ClientSideProjectWizardIterator.java From netbeans with Apache License 2.0 | 4 votes |
@NbBundle.Messages({ "ClientSideProjectWizardIterator.progress.creatingProject=Creating project", "ClientSideProjectWizardIterator.error.noSources=<html>Source folder cannot be created.<br><br>Use <i>Resolve Project Problems...</i> action to repair the project.", "ClientSideProjectWizardIterator.error.noSiteRoot=<html>Site Root folder cannot be created.<br><br>Use <i>Resolve Project Problems...</i> action to repair the project.", }) @Override public Set<FileObject> instantiate(ProgressHandle handle) throws IOException { handle.start(); handle.progress(Bundle.ClientSideProjectWizardIterator_progress_creatingProject()); Set<FileObject> files = new LinkedHashSet<>(); File projectDirectory = FileUtil.normalizeFile((File) wizardDescriptor.getProperty(Wizard.PROJECT_DIRECTORY)); String name = (String) wizardDescriptor.getProperty(Wizard.NAME); if (!projectDirectory.isDirectory() && !projectDirectory.mkdirs()) { throw new IOException("Cannot create project directory"); //NOI18N } FileObject dir = FileUtil.toFileObject(projectDirectory); CommonProjectHelper projectHelper = ClientSideProjectUtilities.setupProject(dir, name); // Always open top dir as a project: files.add(dir); ClientSideProject project = (ClientSideProject) FileOwnerQuery.getOwner(projectHelper.getProjectDirectory()); Pair<FileObject, FileObject> folders = wizard.instantiate(files, handle, wizardDescriptor, project); FileObject sources = folders.first(); FileObject siteRoot = folders.second(); if (sources != null) { // main file FileObject mainFile = sources.getFileObject("main.js"); // NOI18N if (mainFile != null) { files.add(mainFile); } } else if (wizard.hasSources()) { errorOccured(Bundle.ClientSideProjectWizardIterator_error_noSources()); } if (siteRoot != null) { // index file FileObject indexFile = siteRoot.getFileObject("index", "html"); // NOI18N if (indexFile != null) { files.add(indexFile); } } else if (wizard.hasSiteRoot()) { errorOccured(Bundle.ClientSideProjectWizardIterator_error_noSiteRoot()); } File parent = projectDirectory.getParentFile(); if (parent != null && parent.exists()) { ProjectChooser.setProjectsFolder(parent); } handle.finish(); wizard.logUsage(wizardDescriptor, dir, sources, siteRoot); return files; }
Example 19
Source File: InitializrProjectWizardIterator.java From nb-springboot with Apache License 2.0 | 4 votes |
@Override public Set<FileObject> instantiate(ProgressHandle handle) throws IOException { handle.start(4); Set<FileObject> resultSet = new LinkedHashSet<>(); File dirF = FileUtil.normalizeFile((File) wiz.getProperty(WIZ_PROJ_LOCATION)); dirF.mkdirs(); FileObject foDir = FileUtil.toFileObject(dirF); // prepare service invocation params String bootVersion = ((NamedItem) wiz.getProperty(WIZ_BOOT_VERSION)).getId(); String mvnGroup = (String) wiz.getProperty(WIZ_GROUP); String mvnArtifact = (String) wiz.getProperty(WIZ_ARTIFACT); String mvnVersion = (String) wiz.getProperty(WIZ_VERSION); String mvnName = (String) wiz.getProperty(WIZ_NAME); String mvnDesc = (String) wiz.getProperty(WIZ_DESCRIPTION); String packaging = ((NamedItem) wiz.getProperty(WIZ_PACKAGING)).getId(); String pkg = (String) wiz.getProperty(WIZ_PACKAGE); String lang = ((NamedItem) wiz.getProperty(WIZ_LANGUAGE)).getId(); String javaVersion = ((NamedItem) wiz.getProperty(WIZ_JAVA_VERSION)).getId(); String deps = (String) wiz.getProperty(WIZ_DEPENDENCIES); handle.progress(1); try { // invoke initializr webservice InputStream stream = InitializrService.getInstance().getProject(bootVersion, mvnGroup, mvnArtifact, mvnVersion, mvnName, mvnDesc, packaging, pkg, lang, javaVersion, deps); handle.progress(2); // unzip response unZipFile(stream, foDir, (boolean) wiz.getProperty(WIZ_REMOVE_MVN_WRAPPER)); handle.progress(3); // parse pom.xml final FileObject foPom = foDir.getFileObject("pom.xml"); // manage run/debug trough maven plugin if ((boolean) wiz.getProperty(WIZ_USE_SB_MVN_PLUGIN)) { // create nbactions.xml file with custom maven actions configuration createNbActions(bootVersion, pkg, mvnName, foDir); } // clear non project cache ProjectManager.getDefault().clearNonProjectCache(); // Always open top dir as a project: resultSet.add(foDir); // open pom.xml file resultSet.add(foPom); // trigger download of dependencies Project prj = ProjectManager.getDefault().findProject(foDir); if (prj != null) { final NbMavenProject mvn = prj.getLookup().lookup(NbMavenProject.class); if (mvn != null) { mvn.downloadDependencyAndJavadocSource(false); } } // remember folder for creation of new projects File parent = dirF.getParentFile(); if (parent != null && parent.exists()) { ProjectChooser.setProjectsFolder(parent); } // remember used deps final Preferences prefs = BootDependenciesPanel.depsCountPrefNode(); String[] splitDeps = deps.split(","); // add to counts in prefs for (String depName : splitDeps) { prefs.putInt(depName, prefs.getInt(depName, 0) + 1); } } catch (Exception ex) { Exceptions.printStackTrace(ex); } handle.finish(); return resultSet; }
Example 20
Source File: ProjectUtilities.java From netbeans with Apache License 2.0 | 3 votes |
/** * Runs <i>New Project...</i> wizard with redefined defaults: * <ul> * <li>default project directory to working folder to * capture creating new project in placeholder * directory prepared by CVS server admin * <li>CommonProjectActions.EXISTING_SOURCES_FOLDER * pointing to working folder to capture * typical <i>... from Existing Sources</i> panel * <i>Add</i> button behaviour. * </ul> * @param workingDirectory */ public static void newProjectWizard(File workingDirectory) { Action action = CommonProjectActions.newProjectAction(); if (action != null) { File original = ProjectChooser.getProjectsFolder(); ProjectChooser.setProjectsFolder(workingDirectory); FileObject workingFolder = FileUtil.toFileObject(workingDirectory); action.putValue(CommonProjectActions.EXISTING_SOURCES_FOLDER, workingFolder); performAction(action); } }