Search in sources :

Example 1 with ProjectConfigType

use of org.erlide.engine.model.root.ProjectConfigType in project erlide_eclipse by erlang.

the class ErlangEclipseBuilder method build.

@Override
public IProject[] build(final int kind, final Map<String, String> args, final IProgressMonitor monitor) throws CoreException {
    final IProject project = getProject();
    if (project == null || !project.isAccessible()) {
        return null;
    }
    final IErlProject erlProject = ErlangEngine.getInstance().getModel().getErlangProject(project);
    final ProjectConfigType config = erlProject.getConfigType();
    final BuilderTool tool = erlProject.getBuilderProperties().getBuilderTool();
    if (!validateBuildConfiguration(erlProject)) {
        ErlLogger.warn("Builder tool and config mismatch: " + tool + " " + config);
        monitor.setCanceled(true);
    }
    final ErlangBuilder builder = ErlangBuilderFactory.get(tool);
    if (builder != null) {
        final BuildNotifier notifier = new BuildNotifier(monitor, project);
        if (builder instanceof InternalBuilder) {
            // temporary hack; rebar builder will not need this
            ((InternalBuilder) builder).setDelta(getDelta(project));
        }
        builder.build(ErlangBuilder.BuildKind.get(kind), erlProject, notifier);
    }
    return null;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) BuilderTool(org.erlide.engine.model.builder.BuilderTool) IProject(org.eclipse.core.resources.IProject) ProjectConfigType(org.erlide.engine.model.root.ProjectConfigType)

Example 2 with ProjectConfigType

use of org.erlide.engine.model.root.ProjectConfigType in project erlide_eclipse by erlang.

the class ErlangEclipseBuilder method validateBuildConfiguration.

private boolean validateBuildConfiguration(final IErlProject erlProject) {
    final ProjectConfigType config = erlProject.getConfigType();
    final BuilderTool tool = erlProject.getBuilderProperties().getBuilderTool();
    if (!config.matchesTool(tool)) {
        final String msg = String.format("Project's builder tool %s and configuration %s don't match", tool, config);
        MarkerUtils.createProblemMarker(erlProject.getWorkspaceProject(), null, msg, 0, IMarker.SEVERITY_WARNING);
        return false;
    }
    return true;
}
Also used : BuilderTool(org.erlide.engine.model.builder.BuilderTool) ProjectConfigType(org.erlide.engine.model.root.ProjectConfigType)

Example 3 with ProjectConfigType

use of org.erlide.engine.model.root.ProjectConfigType in project erlide_eclipse by erlang.

the class ErlangProjectPropertyPage method createContents.

@Override
protected Control createContents(final Composite parent) {
    final IProject project = getElement().getAdapter(IProject.class);
    erlProject = ErlangEngine.getInstance().getModel().getErlangProject(project);
    model = erlProject.getProperties();
    final Composite composite = new Composite(parent, SWT.NONE);
    boolean globalEnable = true;
    final ProjectConfigType configType = erlProject.getConfigType();
    if (configType != ProjectConfigType.INTERNAL) {
        globalEnable = false;
        setMessage("Please edit " + configType.getConfigName() + " to change settings for this project");
    }
    composite.setLayout(new GridLayout(2, false));
    {
        final Label lblRequiredErlangVersion = new Label(composite, SWT.NONE);
        lblRequiredErlangVersion.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
        lblRequiredErlangVersion.setText("Required Erlang version");
    }
    {
        runtimeCombo = new Combo(composite, SWT.NONE);
        final GridData gd_combo = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1);
        gd_combo.widthHint = 83;
        runtimeCombo.setLayoutData(gd_combo);
        runtimeCombo.setEnabled(globalEnable);
        final RuntimeVersion[] runtimeVersions = ProjectPreferencesConstants.SUPPORTED_VERSIONS;
        runtimeCombo.setItems(ListExtensions.map(Arrays.asList(runtimeVersions), new Functions.Function1<RuntimeVersion, String>() {

            @Override
            public String apply(final RuntimeVersion p) {
                return p.toString();
            }
        }).toArray(new String[] {}));
        runtimeCombo.setText(model.getRequiredRuntimeVersion().asMajor().toString());
        runtimeCombo.addSelectionListener(new SelectionListener() {

            @Override
            public void widgetSelected(final SelectionEvent e) {
                model.setRequiredRuntimeVersion(RuntimeVersion.Serializer.parse(runtimeCombo.getText()));
            }

            @Override
            public void widgetDefaultSelected(final SelectionEvent e) {
            }
        });
    }
    new Label(composite, SWT.NONE);
    new Label(composite, SWT.NONE);
    {
        final Label lblNewLabel = new Label(composite, SWT.NONE);
        lblNewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
        lblNewLabel.setText("Output directory");
    }
    {
        outputText = new Text(composite, SWT.BORDER);
        outputText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
        outputText.setEnabled(globalEnable);
        outputText.setText(model.getOutputDir().toPortableString());
        outputText.addModifyListener(new ModifyListener() {

            @Override
            public void modifyText(final ModifyEvent e) {
                model.setOutputDir(new Path(outputText.getText()));
            }
        });
    }
    {
        final Label lblNewLabel = new Label(composite, SWT.NONE);
        lblNewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
        lblNewLabel.setText("Source directories");
    }
    {
        sourcesText = new Text(composite, SWT.BORDER);
        sourcesText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
        sourcesText.setEnabled(globalEnable);
        sourcesText.setText(PathSerializer.packList(model.getSourceDirs()));
        sourcesText.addModifyListener(new ModifyListener() {

            @Override
            public void modifyText(final ModifyEvent e) {
                model.setSourceDirs(PathSerializer.unpackList(sourcesText.getText()));
            }
        });
    }
    {
        final Label lblNewLabel = new Label(composite, SWT.NONE);
        lblNewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
        lblNewLabel.setText("Include directories");
    }
    {
        includesText = new Text(composite, SWT.BORDER);
        includesText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
        includesText.setEnabled(globalEnable);
        includesText.setText(PathSerializer.packList(model.getIncludeDirs()));
        includesText.addModifyListener(new ModifyListener() {

            @Override
            public void modifyText(final ModifyEvent e) {
                model.setIncludeDirs(PathSerializer.unpackList(includesText.getText()));
            }
        });
    }
    {
        final Label lblNewLabel = new Label(composite, SWT.NONE);
        lblNewLabel.setEnabled(false);
        lblNewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
        lblNewLabel.setText("Test directories");
    }
    {
        testsText = new Text(composite, SWT.BORDER);
        testsText.setEnabled(globalEnable && false);
        testsText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
        testsText.setText(PathSerializer.packList(model.getTestDirs()));
        testsText.addModifyListener(new ModifyListener() {

            @Override
            public void modifyText(final ModifyEvent e) {
                model.setTestDirs(PathSerializer.unpackList(testsText.getText()));
            }
        });
    }
    new Label(composite, SWT.NONE);
    new Label(composite, SWT.NONE);
    {
        final Label lblExternalModules = new Label(composite, SWT.NONE);
        lblExternalModules.setVisible(true);
        lblExternalModules.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
        lblExternalModules.setText("External modules");
    }
    {
        extModsText = new Text(composite, SWT.BORDER);
        extModsText.setEditable(false);
        extModsText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
        extModsText.setEnabled(globalEnable && SystemConfiguration.getInstance().isDeveloper());
        extModsText.setText(model.getExternalModulesFile());
    }
    {
        final Label lblExternalIncludes = new Label(composite, SWT.NONE);
        lblExternalIncludes.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
        lblExternalIncludes.setText("External includes");
    }
    {
        extIncsText = new Text(composite, SWT.BORDER);
        extIncsText.setEditable(false);
        extIncsText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
        extIncsText.setEnabled(globalEnable && SystemConfiguration.getInstance().isDeveloper());
        extIncsText.setText(model.getExternalIncludesFile());
    }
    return composite;
}
Also used : Path(org.eclipse.core.runtime.Path) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) Label(org.eclipse.swt.widgets.Label) RuntimeVersion(org.erlide.runtime.runtimeinfo.RuntimeVersion) Combo(org.eclipse.swt.widgets.Combo) Text(org.eclipse.swt.widgets.Text) IProject(org.eclipse.core.resources.IProject) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ProjectConfigType(org.erlide.engine.model.root.ProjectConfigType) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 4 with ProjectConfigType

use of org.erlide.engine.model.root.ProjectConfigType in project erlide_eclipse by erlang.

the class NewErlangProjectWizard method addPages.

@Override
public void addPages() {
    try {
        super.addPages();
        info = new NewProjectData();
        info.copyFrom(ErlangProjectProperties.DEFAULT);
        buildPages = Maps.newEnumMap(ProjectConfigType.class);
        mainPage = new ErlangNewProjectCreationPage("mainPage", info);
        mainPage.setTitle(ErlideUIPlugin.getResourceString("wizards.titles.newproject"));
        mainPage.setDescription(ErlideUIPlugin.getResourceString("wizards.descs.newproject"));
        mainPage.setImageDescriptor(ErlideUIPlugin.getDefault().getImageDescriptor(ErlideUIConstants.IMG_NEW_PROJECT_WIZARD));
        addPage(mainPage);
        builderPage = new ErlangProjectBuilderPage("builderPage", info);
        builderPage.setTitle(ErlideUIPlugin.getResourceString("wizards.titles.builderprefs"));
        builderPage.setDescription(ErlideUIPlugin.getResourceString("wizards.descs.builderprefs"));
        builderPage.setImageDescriptor(ErlideUIPlugin.getDefault().getImageDescriptor(ErlideUIConstants.IMG_NEW_PROJECT_WIZARD));
        addPage(builderPage);
        for (final ProjectConfigType builder : ProjectConfigType.values()) {
            final ProjectPreferencesWizardPage buildPage = ProjectPreferencesWizardPageFactory.create(builder, info);
            buildPages.put(builder, buildPage);
            buildPage.setImageDescriptor(ErlideUIPlugin.getDefault().getImageDescriptor(ErlideUIConstants.IMG_NEW_PROJECT_WIZARD));
            addPage(buildPage);
        }
        // only add page if there are already projects in the workspace
        if (ResourcesPlugin.getWorkspace().getRoot().getProjects().length > 0) {
            referencePage = new WizardNewProjectReferencePage(// $NON-NLS-1$
            "basicReferenceProjectPage");
            referencePage.setTitle(WizardMessages.NewProject_referenceTitle);
            referencePage.setDescription(WizardMessages.NewProject_referenceDescription);
            addPage(referencePage);
        }
    } catch (final Exception x) {
        reportError(x);
    }
}
Also used : NewProjectData(org.erlide.engine.NewProjectData) WizardNewProjectReferencePage(org.eclipse.ui.dialogs.WizardNewProjectReferencePage) CoreException(org.eclipse.core.runtime.CoreException) ProjectConfigType(org.erlide.engine.model.root.ProjectConfigType)

Aggregations

ProjectConfigType (org.erlide.engine.model.root.ProjectConfigType)4 IProject (org.eclipse.core.resources.IProject)2 BuilderTool (org.erlide.engine.model.builder.BuilderTool)2 CoreException (org.eclipse.core.runtime.CoreException)1 Path (org.eclipse.core.runtime.Path)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 SelectionListener (org.eclipse.swt.events.SelectionListener)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Combo (org.eclipse.swt.widgets.Combo)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1 Text (org.eclipse.swt.widgets.Text)1 WizardNewProjectReferencePage (org.eclipse.ui.dialogs.WizardNewProjectReferencePage)1 NewProjectData (org.erlide.engine.NewProjectData)1 IErlProject (org.erlide.engine.model.root.IErlProject)1 RuntimeVersion (org.erlide.runtime.runtimeinfo.RuntimeVersion)1