Search in sources :

Example 1 with BuilderProperties

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;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IResourceStatus(org.eclipse.core.resources.IResourceStatus) StatusAdapter(org.eclipse.ui.statushandlers.StatusAdapter) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) ExecutionException(org.eclipse.core.commands.ExecutionException) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) BuilderProperties(org.erlide.engine.model.builder.BuilderProperties) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) IWorkspace(org.eclipse.core.resources.IWorkspace) IProjectDescription(org.eclipse.core.resources.IProjectDescription) CreateProjectOperation(org.eclipse.ui.ide.undo.CreateProjectOperation) ExecutionException(org.eclipse.core.commands.ExecutionException) BuilderTool(org.erlide.engine.model.builder.BuilderTool)

Example 2 with BuilderProperties

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
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) BuilderProperties(org.erlide.engine.model.builder.BuilderProperties)

Aggregations

BuilderProperties (org.erlide.engine.model.builder.BuilderProperties)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1 IProject (org.eclipse.core.resources.IProject)1 IProjectDescription (org.eclipse.core.resources.IProjectDescription)1 IResourceStatus (org.eclipse.core.resources.IResourceStatus)1 IWorkspace (org.eclipse.core.resources.IWorkspace)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 CreateProjectOperation (org.eclipse.ui.ide.undo.CreateProjectOperation)1 StatusAdapter (org.eclipse.ui.statushandlers.StatusAdapter)1 BuilderTool (org.erlide.engine.model.builder.BuilderTool)1 IErlProject (org.erlide.engine.model.root.IErlProject)1