當前位置: 首頁>>代碼示例>>Java>>正文


Java IProject.create方法代碼示例

本文整理匯總了Java中org.eclipse.core.resources.IProject.create方法的典型用法代碼示例。如果您正苦於以下問題:Java IProject.create方法的具體用法?Java IProject.create怎麽用?Java IProject.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.core.resources.IProject的用法示例。


在下文中一共展示了IProject.create方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createProject

import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
protected void createProject ( final IProgressMonitor monitor ) throws CoreException
{
    monitor.beginTask ( "Create project", 2 );

    final IProject project = this.info.getProject ();

    final IProjectDescription desc = project.getWorkspace ().newProjectDescription ( project.getName () );
    desc.setLocation ( this.info.getProjectLocation () );
    desc.setNatureIds ( new String[] { Constants.PROJECT_NATURE_CONFIGURATION, PROJECT_NATURE_JS } );

    final ICommand jsCmd = desc.newCommand ();
    jsCmd.setBuilderName ( BUILDER_JS_VALIDATOR );

    final ICommand localBuilder = desc.newCommand ();
    localBuilder.setBuilderName ( Constants.PROJECT_BUILDER );

    desc.setBuildSpec ( new ICommand[] { jsCmd, localBuilder } );

    if ( !project.exists () )
    {
        project.create ( desc, new SubProgressMonitor ( monitor, 1 ) );
        project.open ( new SubProgressMonitor ( monitor, 1 ) );
    }
    monitor.done ();
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:26,代碼來源:CreateProjectOperation.java

示例2: createFeatureProject

import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
private void createFeatureProject ( final IProject project, final Map<String, String> properties, final IProgressMonitor monitor ) throws CoreException
{
    monitor.beginTask ( "Creating feature project", 6 );

    final String name = this.pluginId + ".feature"; //$NON-NLS-1$
    final IProjectDescription desc = project.getWorkspace ().newProjectDescription ( name );

    final ICommand featureBuilder = desc.newCommand ();
    featureBuilder.setBuilderName ( "org.eclipse.pde.FeatureBuilder" ); //$NON-NLS-1$

    desc.setNatureIds ( new String[] { "org.eclipse.pde.FeatureNature" } ); //$NON-NLS-1$
    desc.setBuildSpec ( new ICommand[] {
            featureBuilder
    } );

    final IProject newProject = project.getWorkspace ().getRoot ().getProject ( name );
    newProject.create ( desc, new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1
    newProject.open ( new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1

    addFilteredResource ( newProject, "pom.xml", getResource ( "feature-pom.xml" ), "UTF-8", properties, new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1
    addFilteredResource ( newProject, "feature.xml", getResource ( "feature/feature.xml" ), "UTF-8", properties, new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1
    addFilteredResource ( newProject, "feature.properties", getResource ( "feature/feature.properties" ), "ISO-8859-1", properties, new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1
    addFilteredResource ( newProject, "build.properties", getResource ( "feature/build.properties" ), "ISO-8859-1", properties, new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1

    monitor.done ();
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:27,代碼來源:ClientTemplate.java

示例3: createProjectPluginResource

import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
public IProject createProjectPluginResource(String projectName, IProgressMonitor monitor) throws CoreException {
	IWorkspace myWorkspace = ResourcesPlugin.getWorkspace();
	IWorkspaceRoot myWorkspaceRoot = myWorkspace.getRoot();
	IProject resourceProject = myWorkspaceRoot.getProject(projectName);
	
	if (!resourceProject.exists()) {		
		if(myWorkspaceRoot.getLocation().toFile().equals(new Path(Engine.PROJECTS_PATH).toFile())){
			logDebug("createProjectPluginResource : project is in the workspace folder");
			
			resourceProject.create(monitor);
		}else{
			logDebug("createProjectPluginResource: project isn't in the workspace folder");
	
			IPath projectPath = new Path(Engine.PROJECTS_PATH + "/" + projectName).makeAbsolute();
			IProjectDescription description = myWorkspace.newProjectDescription(projectName);
			description.setLocation(projectPath);
			resourceProject.create(description, monitor);
		}
	}
	
	return resourceProject;
}
 
開發者ID:convertigo,項目名稱:convertigo-eclipse,代碼行數:23,代碼來源:ConvertigoPlugin.java

示例4: importProject

import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
private static IProject importProject(File probandsFolder, String projectName, boolean prepareDotProject)
		throws Exception {
	File projectSourceFolder = new File(probandsFolder, projectName);
	if (!projectSourceFolder.exists()) {
		throw new IllegalArgumentException("proband not found in " + projectSourceFolder);
	}

	if (prepareDotProject) {
		prepareDotProject(projectSourceFolder);
	}

	IProgressMonitor monitor = new NullProgressMonitor();
	IWorkspace workspace = ResourcesPlugin.getWorkspace();

	IProjectDescription newProjectDescription = workspace.newProjectDescription(projectName);
	IProject project = workspace.getRoot().getProject(projectName);
	project.create(newProjectDescription, monitor);
	project.open(monitor);
	if (!project.getLocation().toFile().exists()) {
		throw new IllegalArgumentException("test project correctly created in " + project.getLocation());
	}

	IOverwriteQuery overwriteQuery = new IOverwriteQuery() {
		@Override
		public String queryOverwrite(String file) {
			return ALL;
		}
	};
	ImportOperation importOperation = new ImportOperation(project.getFullPath(), projectSourceFolder,
			FileSystemStructureProvider.INSTANCE, overwriteQuery);
	importOperation.setCreateContainerStructure(false);
	importOperation.run(monitor);

	return project;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:36,代碼來源:ProjectUtils.java

示例5: createTempProject

import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
/***/
protected URI createTempProject(String projectName) throws CoreException {
	IProjectDescription description = workspace.getWorkspace().newProjectDescription(projectName);
	// deliberately avoid the build command
	description.setNatureIds(new String[] { XtextProjectHelper.NATURE_ID });
	IProject newProject = workspace.getProject(projectName);
	newProject.create(null);
	newProject.open(null);
	newProject.setDescription(description, null);
	return URI.createPlatformResourceURI(projectName, true);
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:12,代碼來源:EclipseBasedProjectModelSetup.java

示例6: createParentProject

import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
private void createParentProject ( final IProject project, final Map<String, String> properties, final IProgressMonitor monitor ) throws CoreException
{
    monitor.beginTask ( "Creating parent project", 3 );

    final String name = this.pluginId + "-parent"; //$NON-NLS-1$
    final IProjectDescription desc = project.getWorkspace ().newProjectDescription ( name );

    final IProject newProject = project.getWorkspace ().getRoot ().getProject ( name );
    newProject.create ( desc, new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1
    newProject.open ( new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1

    addFilteredResource ( newProject, "pom.xml", getResource ( "parent-pom.xml" ), "UTF-8", properties, new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1

    monitor.done ();
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:16,代碼來源:ClientTemplate.java

示例7: createProject

import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
public static IJavaProject createProject(String name) throws CoreException {

		IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
		IProject project = root.getProject(name);
		if (!project.exists()) {
			project.create(new NullProgressMonitor());
		} else {
			project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
		}

		if (!project.isOpen()) {
			project.open(new NullProgressMonitor());
		}

		IFolder binFolder = project.getFolder("bin");
		if (!binFolder.exists()) {
			createFolder(binFolder, false, true, new NullProgressMonitor());
		}
		IPath outputLocation = binFolder.getFullPath();

		addNatureToProject(project, JavaCore.NATURE_ID, new NullProgressMonitor());

		IJavaProject jproject = JavaCore.create(project);
		jproject.setOutputLocation(outputLocation, new NullProgressMonitor());

		IClasspathEntry[] entries = PreferenceConstants.getDefaultJRELibrary();

		jproject.setRawClasspath(entries, new NullProgressMonitor());

		return jproject;
	}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:32,代碼來源:ProjectHelper.java

示例8: testGenericEditorCanOpenCamelFile

import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
@Test
public void testGenericEditorCanOpenCamelFile() throws Exception {
	IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
	IProject project = root.getProject(CamelLSPLoadedByExtensionPointIT.class.getSimpleName());
	project.create(null);
	project.open(null);
	IFile camelFile = project.getFile("camelFile.xml");
	camelFile.create(new ByteArrayInputStream("<from uri=\"\" xmlns=\"http://camel.apache.org/schema/spring\"></from>\n".getBytes()), IResource.FORCE, null);
	IEditorPart openEditor = IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), camelFile, "org.eclipse.ui.genericeditor.GenericEditor");
	assertThat(openEditor).isInstanceOf(ExtensionBasedTextEditor.class);
}
 
開發者ID:lhein,項目名稱:camel-language-server,代碼行數:12,代碼來源:CamelLSPLoadedByExtensionPointIT.java

示例9: createPgDbProject

import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
public static PgDbProject createPgDbProject(IProject newProject, URI location)
        throws CoreException {
    if (!newProject.exists()) {
        IProjectDescription desc = newProject.getWorkspace()
                .newProjectDescription(newProject.getName());

        desc.setLocationURI(location);
        desc.setNatureIds(new String[] {NATURE.ID});
        newProject.create(desc, null);
        newProject.open(IResource.BACKGROUND_REFRESH, null);
        newProject.getNature(NATURE.ID).configure();
    }
    return new PgDbProject(newProject);
}
 
開發者ID:pgcodekeeper,項目名稱:pgcodekeeper,代碼行數:15,代碼來源:PgDbProject.java

示例10: createTheProjectAtSpecifiedLocation

import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
private IProject createTheProjectAtSpecifiedLocation(String projectName,
		URI location) throws CoreException {
	IProject newProject;
	newProject = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);

	if(!newProject.exists()){
		IProjectDescription desc = newProject.getWorkspace().newProjectDescription(newProject.getName());
		if (location != null && ResourcesPlugin.getWorkspace().getRoot().getLocationURI().equals(location)) {
			desc.setLocationURI(null);
		}
		else{
			desc.setLocationURI(location);
		}

		try {
			newProject.create(desc, null);
			if (!newProject.isOpen()) {
				newProject.open(null);
			}
			logger.debug("Project base structure created"); 
		} catch (CoreException exception) {
			logger.debug("Project base structure creation failed");
			throw exception;
		}
	}
	return newProject;
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:28,代碼來源:ProjectStructureCreator.java

示例11: createJavaProject

import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
private IJavaProject createJavaProject(String name) throws CoreException {
  IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
  if (project.exists())
    project.delete(true, null);
  project.create(null);
  project.open(null);
  IProjectDescription description = project.getDescription();
  description.setNatureIds(new String[] { JavaCore.NATURE_ID });
  project.setDescription(description, null);
  IJavaProject javaProject = JavaCore.create(project);
  javaProject.setRawClasspath(new IClasspathEntry[] { JavaCore.newVariableEntry(new Path("JRE_LIB"), null, null) }, null);
  return javaProject;
}
 
開發者ID:RuiChen08,項目名稱:dacapobench,代碼行數:14,代碼來源:FullSourceWorkspaceModelTests.java

示例12: createProject

import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
protected IProject createProject(IProgressMonitor monitor) {
	IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
	IProject project = root.getProject(HELLO_WORLD);
	try {
		if (project.exists())
			project.delete(true, monitor);
		project.create(monitor);
		project.open(monitor);
		addNature(project);
	} catch (Exception ex) {
		ex.printStackTrace();
	}
	return project;
}
 
開發者ID:Yakindu,項目名稱:solidity-ide,代碼行數:15,代碼來源:KickStartNewProjectAction.java

示例13: createProject

import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
/**
 * This method creates a new java project based on the user inputs, captured in WizardInput object.
 * The new project is created in the current workspace.
 * @param wizardInput
 * @return IJavaProject
 * @throws CoreException
 * @throws IOException
 **/
public IJavaProject createProject(WizardInput wizardInput) throws CoreException, IOException
{
	IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
	IProject project = root.getProject(wizardInput.getProjectName());
	project.create(null);
	project.open(null);		
	IProjectDescription description = project.getDescription();
	description.setNatureIds(new String[] { JavaCore.NATURE_ID });
	project.setDescription(description, null);
	IJavaProject javaProject = JavaCore.create(project); 
	IFolder binFolder = project.getFolder("bin");
	binFolder.create(false, true, null);
	javaProject.setOutputLocation(binFolder.getFullPath(), null);
	List<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();
	IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall();
	LibraryLocation[] locations = JavaRuntime.getLibraryLocations(vmInstall);
	for (LibraryLocation element : locations) {
	 entries.add(JavaCore.newLibraryEntry(element.getSystemLibraryPath(), null, null));
	}
	InputStream is = new BufferedInputStream(new FileInputStream(wizardInput.getSootPath().toOSString()));
    IFile jarFile = project.getFile("soot-trunk.jar");
    jarFile.create(is, false, null);
    IPath path = jarFile.getFullPath();
    entries.add(JavaCore.newLibraryEntry(path, null, null));
	javaProject.setRawClasspath(entries.toArray(new IClasspathEntry[entries.size()]), null);		
	IFolder sourceFolder = project.getFolder("src");
	sourceFolder.create(false, true, null);
	IPackageFragmentRoot root1 = javaProject.getPackageFragmentRoot(sourceFolder);
	IClasspathEntry[] oldEntries = javaProject.getRawClasspath();
	IClasspathEntry[] newEntries = new IClasspathEntry[oldEntries.length + 1];
	System.arraycopy(oldEntries, 0, newEntries, 0, oldEntries.length);
	newEntries[oldEntries.length] = JavaCore.newSourceEntry(root1.getPath());
	javaProject.setRawClasspath(newEntries, null);
	String filepath = sourceFolder.getLocation().toOSString();
	File file = new File(filepath);
	wizardInput.setFile(file);
	try {
		CodeGenerator.generateSource(wizardInput);
	} catch (JClassAlreadyExistsException e) {
		e.printStackTrace();
	}
	sourceFolder.refreshLocal(1, null);
	javaProject.open(null);
	return javaProject;
}
 
開發者ID:VisuFlow,項目名稱:visuflow-plugin,代碼行數:54,代碼來源:ProjectGenerator.java

示例14: run

import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
@Override
public void run(String[] params, ICheatSheetManager manager) {

	if (params == null || params[0] == null) {
		return;
	}
	IWorkspace workspace = ResourcesPlugin.getWorkspace();
	String projectName = params[0];
	String zipName = params[1];
	IProjectDescription newProjectDescription = workspace.newProjectDescription(projectName);
	IProject newProject = workspace.getRoot().getProject(projectName);
	try {
		newProject.create(newProjectDescription, null);
		newProject.open(null);

		URL url = this.getClass().getClassLoader().getResource(zipName);
		File f = new File(FileLocator.toFileURL(url).getPath());

		IOverwriteQuery overwriteQuery = new IOverwriteQuery() {
			public String queryOverwrite(String file) {
				System.out.println(file);
				return ALL;
			}
		};

		FileSystemStructureProvider provider = FileSystemStructureProvider.INSTANCE;

		File root = createTempDirectory();

		unzip(f.getAbsolutePath(), root.getAbsolutePath());

		List<File> files = readFiles(root.getAbsolutePath());
		ImportOperation importOperation = new ImportOperation(newProject.getFullPath(), root, provider,
				overwriteQuery, files);
		importOperation.setCreateContainerStructure(false);
		importOperation.run(new NullProgressMonitor());
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:42,代碼來源:ProjectImport.java


注:本文中的org.eclipse.core.resources.IProject.create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。