use of org.eclipse.core.resources.IProjectDescription in project Palladio-Editors-Sirius by PalladioSimulator.
the class NewPalladioProjectWizard method performFinish.
@Override
public boolean performFinish() {
final IProject projectHandle = this.projectCreationPage.getProjectHandle();
final java.net.URI projectURI = (!this.projectCreationPage.useDefaults()) ? this.projectCreationPage.getLocationURI() : null;
final IWorkspace workspace = ResourcesPlugin.getWorkspace();
final IProjectDescription desc = workspace.newProjectDescription(projectHandle.getName());
desc.setLocationURI(projectURI);
/*
* Creating the project encapsulated in a workspace operation
*/
final WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
@Override
protected void execute(final IProgressMonitor monitor) throws CoreException {
NewPalladioProjectWizard.this.project = createProject(desc, projectHandle, monitor);
}
};
/*
* This isn't as robust as the code in the BasicNewProjectResourceWizard class. Consider
* beefing this up to improve error handling.
*/
try {
getContainer().run(true, true, op);
} catch (final Exception e) {
MessageDialog.openError(getShell(), "Error", "An unexpected error occured. See stack trace");
e.printStackTrace();
return false;
}
if (this.project == null) {
return false;
}
BasicNewProjectResourceWizard.updatePerspective(this.config);
BasicNewProjectResourceWizard.selectAndReveal(this.project, this.workbench.getActiveWorkbenchWindow());
if (!getCurrentPerspectiveId().equals(PERSPECTIVE_ID)) {
boolean confirm = MessageDialog.openConfirm(getShell(), "Palladio Perspective", "This project is associated with the Palladio perspective.\n\nDo you want to open this perspective now?");
if (confirm)
openPalladioPerspective();
}
return true;
}
use of org.eclipse.core.resources.IProjectDescription in project linuxtools by eclipse.
the class ProjectInitializationRule method createProject.
/**
* @param description
* @param projectName
* @param workspace
* @param project
* @throws InvocationTargetException
* @throws InterruptedException
* @throws CoreException
* @throws OperationCanceledException
*/
static void createProject(final IProjectDescription description, final String projectName, final IWorkspace workspace, final IProject project) throws InvocationTargetException, OperationCanceledException, CoreException, InterruptedException {
// import from file system
// import project from location copying files - use default project
// location for this workspace
// if location is null, project already exists in this location or
// some error condition occurred.
final IProjectDescription desc = workspace.newProjectDescription(projectName);
desc.setBuildSpec(description.getBuildSpec());
desc.setComment(description.getComment());
desc.setDynamicReferences(description.getDynamicReferences());
desc.setNatureIds(description.getNatureIds());
desc.setReferencedProjects(description.getReferencedProjects());
try {
project.create(desc, null);
project.open(IResource.BACKGROUND_REFRESH, null);
} catch (CoreException e) {
throw new InvocationTargetException(e);
}
buildProject(project);
}
use of org.eclipse.core.resources.IProjectDescription in project linuxtools by eclipse.
the class AbstractTest method createExternalProject.
/**
* Create a CDT project outside the default workspace.
*
* @param bundle
* The plug-in bundle.
* @param projname
* The name of the project.
* @param absProjectPath
* Absolute path to the directory to which the project should be
* mapped outside the workspace.
* @return A new external CDT project.
* @throws CoreException
* @throws URISyntaxException
* @throws IOException
* @throws InvocationTargetException
* @throws InterruptedException
*/
protected IProject createExternalProject(Bundle bundle, final String projname, final Path absProjectPath) throws CoreException, URISyntaxException, IOException, InvocationTargetException, InterruptedException {
IProject externalProject;
// Turn off auto-building
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceDescription wspDesc = workspace.getDescription();
wspDesc.setAutoBuilding(false);
workspace.setDescription(wspDesc);
// Create external project
IWorkspaceRoot root = workspace.getRoot();
externalProject = root.getProject(projname);
IProjectDescription description = workspace.newProjectDescription(projname);
URI fileProjectURL = new URI("file://" + absProjectPath.toString());
description.setLocationURI(fileProjectURL);
externalProject = CCorePlugin.getDefault().createCDTProject(description, externalProject, new NullProgressMonitor());
assertNotNull(externalProject);
externalProject.open(null);
try {
// CDT opens the Project with BACKGROUND_REFRESH enabled which
// causes the
// refresh manager to refresh the project 200ms later. This Job
// interferes
// with the resource change handler firing see: bug 271264
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_REFRESH, null);
} catch (Exception e) {
// Ignore
}
assertTrue(externalProject.isOpen());
// Import boiler-plate files which can then be built and profiled
URL location = FileLocator.find(bundle, new Path("resources/" + projname), // $NON-NLS-1$
null);
File testDir = new File(FileLocator.toFileURL(location).toURI());
ImportOperation op = new ImportOperation(externalProject.getFullPath(), testDir, FileSystemStructureProvider.INSTANCE, new IOverwriteQuery() {
@Override
public String queryOverwrite(String pathString) {
return ALL;
}
});
op.setCreateContainerStructure(false);
op.run(null);
IStatus status = op.getStatus();
if (!status.isOK()) {
throw new CoreException(status);
}
// Make sure import went well
assertNotNull(externalProject.findMember(new Path(IMPORTED_SOURCE_FILE)));
// Index the project
IIndexManager indexMgr = CCorePlugin.getIndexManager();
indexMgr.joinIndexer(IIndexManager.FOREVER, new NullProgressMonitor());
// These natures must be enabled at this point to continue
assertTrue(externalProject.isNatureEnabled(ScannerConfigNature.NATURE_ID));
assertTrue(externalProject.isNatureEnabled(ManagedCProjectNature.MNG_NATURE_ID));
return externalProject;
}
use of org.eclipse.core.resources.IProjectDescription in project linuxtools by eclipse.
the class CreaterepoProjectCreator method create.
/**
* Create a createrepo project given a project name and the progress
* monitor. The new project will contain an empty repodata folder.
*
* @param projectName The name of the project.
* @param locationPath The location path of the project
* @param monitor The progress monitor.
* @return The newly created project.
* @throws CoreException Thrown when creating a project fails.
*/
public static IProject create(String projectName, IPath locationPath, String repoName, IProgressMonitor monitor) throws CoreException {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject project = root.getProject(projectName);
IProjectDescription description = ResourcesPlugin.getWorkspace().newProjectDescription(projectName);
if (!Platform.getLocation().equals(locationPath)) {
description.setLocation(locationPath);
}
description.setNatureIds(new String[] { CreaterepoProjectNature.CREATEREPO_NATURE_ID });
project.create(description, monitor);
project.open(monitor);
IFile repoFile = project.getFile(repoName);
InputStream stream = new ByteArrayInputStream(ICreaterepoConstants.EMPTY_STRING.getBytes());
if (!repoFile.exists()) {
repoFile.create(stream, true, monitor);
}
return project;
}
use of org.eclipse.core.resources.IProjectDescription in project linuxtools by eclipse.
the class RpmlintNature method configure.
@Override
public void configure() throws CoreException {
IProjectDescription desc = project.getDescription();
ICommand[] commands = desc.getBuildSpec();
for (ICommand command : commands) {
if (command.getBuilderName().equals(RpmlintBuilder.BUILDER_ID)) {
return;
}
}
ICommand[] newCommands = new ICommand[commands.length + 1];
System.arraycopy(commands, 0, newCommands, 0, commands.length);
ICommand command = desc.newCommand();
command.setBuilderName(RpmlintBuilder.BUILDER_ID);
newCommands[newCommands.length - 1] = command;
desc.setBuildSpec(newCommands);
project.setDescription(desc, null);
}
Aggregations