use of org.erlide.engine.model.builder.BuilderProperties in project erlide_eclipse by erlang.
the class ProjectCreator method createProject.
public IProject createProject() throws CoreException {
final IWorkspace workspace = ResourcesPlugin.getWorkspace();
final IProject newProjectHandle = workspace.getRoot().getProject(name);
if (newProjectHandle.exists()) {
throw new CoreException(Status.OK_STATUS);
}
final IProjectDescription description = workspace.newProjectDescription(name);
description.setLocationURI(location);
// // update the referenced project if provided
if (referencedProjects != null) {
description.setReferencedProjects(referencedProjects);
}
// create the new project operation
final IRunnableWithProgress op = new IRunnableWithProgress() {
@Override
public void run(final IProgressMonitor monitor) throws InvocationTargetException {
final CreateProjectOperation op1 = new CreateProjectOperation(description, WizardMessages.NewProject_windowTitle);
try {
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=219901
// Making this undoable would be a bad idea
op1.execute(monitor, notifier);
newProjectHandle.open(monitor);
description.setNatureIds(new String[] { ErlangCore.NATURE_ID });
newProjectHandle.setDescription(description, null);
final BuilderTool builder = info.getBuilder();
ErlangNature.setErlangProjectBuilder(newProjectHandle, builder);
createBuilderConfig(builder);
createFolders(newProjectHandle, Lists.newArrayList(info.getOutputDir()), monitor);
createFolders(newProjectHandle, info.getSourceDirs(), monitor);
createFolders(newProjectHandle, info.getIncludeDirs(), monitor);
createConfig(newProjectHandle, info.getConfigType(), monitor);
final IErlProject erlProject = ErlangEngine.getInstance().getModel().getErlangProject(newProjectHandle);
erlProject.setConfigType(info.getConfigType());
final BuilderProperties builderProperties = new BuilderProperties();
builderProperties.setBuilderTool(builder);
builderProperties.setCompileTarget(info.getBuilderData().get("compile"));
builderProperties.setCleanTarget(info.getBuilderData().get("clean"));
erlProject.setBuilderProperties(builderProperties);
erlProject.setProperties(info);
} catch (final Exception e) {
throw new InvocationTargetException(e);
}
}
};
// run the new project creation operation
try {
context.run(false, true, op);
} catch (final InterruptedException e) {
return null;
} catch (final InvocationTargetException e) {
final Throwable t = e.getTargetException();
if (t instanceof ExecutionException && t.getCause() instanceof CoreException) {
final CoreException cause = (CoreException) t.getCause();
StatusAdapter status;
if (cause.getStatus().getCode() == IResourceStatus.CASE_VARIANT_EXISTS) {
status = new StatusAdapter(StatusUtil.newStatus(IStatus.WARNING, NLS.bind(WizardMessages.NewProject_caseVariantExistsError, newProjectHandle.getName()), cause));
} else {
status = new StatusAdapter(StatusUtil.newStatus(cause.getStatus().getSeverity(), WizardMessages.NewProject_errorMessage, cause));
}
status.setProperty(IStatusAdapterConstants.TITLE_PROPERTY, WizardMessages.NewProject_errorMessage);
StatusManager.getManager().handle(status, StatusManager.BLOCK);
} else {
final StatusAdapter status = new StatusAdapter(new Status(IStatus.WARNING, ErlideUIPlugin.PLUGIN_ID, 0, NLS.bind(WizardMessages.NewProject_internalError, t.getMessage()), t));
status.setProperty(IStatusAdapterConstants.TITLE_PROPERTY, WizardMessages.NewProject_errorMessage);
StatusManager.getManager().handle(status, StatusManager.LOG | StatusManager.BLOCK);
}
return null;
}
return newProjectHandle;
}
use of org.erlide.engine.model.builder.BuilderProperties in project erlide_eclipse by erlang.
the class ErlProject method loadBuilderProperties.
private void loadBuilderProperties() {
final IEclipsePreferences node = getCorePropertiesNode();
final String data = node.get("builderData", "");
builderProperties = new BuilderProperties();
builderProperties.fromString(data);
// TODO more
}
Aggregations