Search in sources :

Example 71 with IErlProject

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

the class ErlangNodeLaunchShortcut method getProjectNames.

private List<String> getProjectNames(final Collection<IErlProject> projects) {
    final List<String> result = Lists.newArrayListWithCapacity(projects.size());
    for (final IErlProject project : projects) {
        String name = project.getName();
        if (name.startsWith("org.erlide.")) {
            name = name.substring("org.erlide.".length());
        }
        result.add(name.replaceAll("\\.", ""));
    }
    return result;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject)

Example 72 with IErlProject

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

the class ErlangNodeLaunchShortcut method launch.

@Override
public void launch(final IEditorPart editor, final String mode) {
    ErlLogger.debug("** Launch :: " + editor.getTitle());
    if (editor instanceof AbstractErlangEditor) {
        final AbstractErlangEditor erlangEditor = (AbstractErlangEditor) editor;
        final IErlProject project = erlangEditor.getProject();
        if (project != null) {
            try {
                doLaunch(mode, Lists.newArrayList(project));
            } catch (final CoreException e) {
                final IWorkbench workbench = PlatformUI.getWorkbench();
                final Shell shell = workbench.getActiveWorkbenchWindow().getShell();
                MessageDialog.openError(shell, "Error", e.getStatus().getMessage());
            }
        }
    }
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IWorkbench(org.eclipse.ui.IWorkbench) Shell(org.eclipse.swt.widgets.Shell) CoreException(org.eclipse.core.runtime.CoreException) AbstractErlangEditor(org.erlide.ui.editors.erl.AbstractErlangEditor)

Example 73 with IErlProject

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

the class CoverMainTab method initializeFrom.

@Override
public void initializeFrom(final ILaunchConfiguration config) {
    try {
        final String projectName = config.getAttribute(ICoverAttributes.PROJECT, "");
        projectMBr.setText(projectName);
        if (projectName != null && !projectName.isEmpty()) {
            final IErlProject p = ErlangEngine.getInstance().getModel().getErlangProject(ResourcesPlugin.getWorkspace().getRoot().getProject(projectName));
            if (p != null) {
                moduleDialog.setElements(createModuleArray(p));
            }
        }
    } catch (final CoreException e) {
        projectMBr.setText("");
    }
    try {
        moduleBr.setText(config.getAttribute(ICoverAttributes.MODULE, ""));
    } catch (final CoreException e) {
        moduleBr.setText("");
    }
    try {
        fileBr.setText(config.getAttribute(ICoverAttributes.FILE, ""));
    } catch (final CoreException e) {
        fileBr.setText("");
    }
    try {
        final String type = config.getAttribute(ICoverAttributes.TYPE, LaunchType.MODULE.toString());
        final LaunchType typeT = LaunchType.valueOf(type);
        switch(typeT) {
            case MODULE:
                singleRadio.setSelection(true);
                projectMBr.setEnabled(true);
                moduleBr.setEnabled(true);
                fileBr.setEnabled(false);
                break;
            case ALL:
                allRadio.setSelection(true);
                projectMBr.setEnabled(false);
                moduleBr.setEnabled(false);
                fileBr.setEnabled(true);
                break;
            default:
                singleRadio.setSelection(true);
                projectMBr.setEnabled(true);
                moduleBr.setEnabled(true);
                fileBr.setEnabled(false);
                break;
        }
    } catch (final CoreException e) {
        singleRadio.setSelection(true);
    }
    String combo;
    try {
        combo = config.getAttribute(ICoverAttributes.COMBO, FrameworkType.EUNIT.getRepr());
        final int idx = testCombo.indexOf(combo);
        testCombo.select(idx);
    } catch (final CoreException e) {
        testCombo.select(0);
    }
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) CoreException(org.eclipse.core.runtime.CoreException) LaunchType(org.erlide.cover.runtime.launch.LaunchType)

Example 74 with IErlProject

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

the class CoverMainTab method createModuleGroup.

private void createModuleGroup(final Composite comp) {
    final ElementListSelectionDialog projectDialog = new ElementListSelectionDialog(getShell(), new ProjectLabelProvider());
    final Object[] elements = createProjectArray();
    projectDialog.setElements(elements);
    projectDialog.setTitle("Select project");
    projectDialog.setMessage("Select Erlang project: ");
    moduleDialog = new ElementListSelectionDialog(getShell(), new ProjectLabelProvider());
    moduleDialog.setElements(new Object[0]);
    moduleDialog.setTitle("Select module");
    moduleDialog.setMessage("Select Erlang module: ");
    projectMBr = browserWithLabel(comp, "Project:", projectDialog);
    projectMBr.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(final ModifyEvent e) {
            updateLaunchConfigurationDialog();
            final String projectName = projectMBr.getText();
            if (projectName != null && !projectName.isEmpty()) {
                final IErlProject p = ErlangEngine.getInstance().getModel().getErlangProject(ResourcesPlugin.getWorkspace().getRoot().getProject(projectName));
                if (p != null) {
                    moduleDialog.setElements(createModuleArray(p));
                }
            }
        }
    });
    moduleBr = browserWithLabel(comp, "Module:", moduleDialog);
    moduleBr.addModifyListener(basicModifyListener);
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ProjectLabelProvider(org.erlide.cover.ui.launch.helpers.ProjectLabelProvider) ModifyListener(org.eclipse.swt.events.ModifyListener) ElementListSelectionDialog(org.eclipse.ui.dialogs.ElementListSelectionDialog)

Example 75 with IErlProject

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

the class SearchCoreUtil method addProjectToScope.

static void addProjectToScope(final IProject project, final ErlSearchScope result) throws CoreException {
    if (project == null) {
        return;
    }
    final IErlProject erlProject = ErlangEngine.getInstance().getModel().getErlangProject(project);
    if (erlProject != null) {
        final Collection<IPath> sourcePaths = erlProject.getProperties().getSourceDirs();
        for (final IPath path : sourcePaths) {
            final IFolder folder = project.getFolder(path);
            SearchCoreUtil.addFolderToScope(folder, result);
        }
    }
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IPath(org.eclipse.core.runtime.IPath) IFolder(org.eclipse.core.resources.IFolder)

Aggregations

IErlProject (org.erlide.engine.model.root.IErlProject)123 IErlModule (org.erlide.engine.model.root.IErlModule)57 Test (org.junit.Test)47 IPath (org.eclipse.core.runtime.IPath)30 IProject (org.eclipse.core.resources.IProject)29 ErlProject (org.erlide.engine.internal.model.root.ErlProject)25 File (java.io.File)19 Path (org.eclipse.core.runtime.Path)16 CoreException (org.eclipse.core.runtime.CoreException)13 ErlModelException (org.erlide.engine.model.ErlModelException)13 IErlElementLocator (org.erlide.engine.model.root.IErlElementLocator)13 IErlModel (org.erlide.engine.model.root.IErlModel)13 ArrayList (java.util.ArrayList)11 IErlElement (org.erlide.engine.model.IErlElement)10 IFile (org.eclipse.core.resources.IFile)9 IResource (org.eclipse.core.resources.IResource)9 HashSet (java.util.HashSet)7 IProjectDescription (org.eclipse.core.resources.IProjectDescription)7 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)6 IErlPreprocessorDef (org.erlide.engine.model.erlang.IErlPreprocessorDef)6