本文整理匯總了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 ();
}
示例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 ();
}
示例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;
}
示例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;
}
示例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);
}
示例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 ();
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
}