use of org.erlide.engine.model.root.IErlProject in project erlide_eclipse by erlang.
the class ErlangNodeLaunchShortcut method launch.
@Override
public void launch(final ISelection selection, final String mode) {
ErlLogger.debug("** Launch:: " + selection.toString());
if (selection.isEmpty()) {
return;
}
if (!(selection instanceof IStructuredSelection)) {
return;
}
final Set<IErlProject> projects = Sets.newHashSet();
final IStructuredSelection structuredSelection = (IStructuredSelection) selection;
for (final Object element : structuredSelection.toArray()) {
if (!(element instanceof IResource)) {
return;
}
final IErlElement erlElement = ErlangEngine.getInstance().getModel().findElement((IResource) element);
final IErlProject project = ErlangEngine.getInstance().getModelUtilService().getProject(erlElement);
if (project != null) {
projects.add(project);
}
}
if (projects.isEmpty()) {
return;
}
projects.addAll(getDependentProjects(projects));
final List<IErlProject> projectList = Lists.newArrayList(projects);
projectList.sort(new Comparator<IErlProject>() {
@Override
public int compare(final IErlProject o1, final IErlProject o2) {
return o1.getName().compareTo(o2.getName());
}
});
try {
doLaunch(mode, projectList);
} catch (final CoreException e) {
final IWorkbench workbench = PlatformUI.getWorkbench();
final Shell shell = workbench.getActiveWorkbenchWindow().getShell();
MessageDialog.openError(shell, "Error", e.getStatus().getMessage());
}
}
use of org.erlide.engine.model.root.IErlProject in project erlide_eclipse by erlang.
the class ErlangNodeLaunchShortcut method getProjectAndModuleNames.
private List<String> getProjectAndModuleNames(final Collection<IErlProject> projects) throws ErlModelException {
final List<String> moduleNames = Lists.newArrayList();
for (final IErlProject project : projects) {
final Collection<IErlModule> modules = project.getModules();
final String projectNameColon = project.getName() + ":";
for (final IErlModule module : modules) {
moduleNames.add(projectNameColon + module.getName());
}
}
return moduleNames;
}
use of org.erlide.engine.model.root.IErlProject in project erlide_eclipse by erlang.
the class ErlangExternalsContentProvider method hasChildren.
@Override
public boolean hasChildren(final Object element0) {
Object element = element0;
if (element instanceof IProject) {
final IProject project = (IProject) element;
if (project.isOpen()) {
element = ErlangEngine.getInstance().getModel().findProject(project);
}
}
if (element instanceof IErlModule) {
return erlangFileContentProvider.hasChildren(element);
}
if (element instanceof IParent) {
if (element instanceof IErlExternalRoot || element instanceof IErlProject || element instanceof IErlModel) {
// we know these have children
return true;
}
final Stopwatch clock = Stopwatch.createStarted();
if (element instanceof IOpenable) {
final IOpenable openable = (IOpenable) element;
try {
openable.open(null);
} catch (final ErlModelException e) {
}
}
final IParent parent = (IParent) element;
final boolean result = parent.hasChildrenOfKind(ErlElementKind.EXTERNAL_ROOT, ErlElementKind.EXTERNAL_APP, ErlElementKind.EXTERNAL_FOLDER, ErlElementKind.MODULE);
if (clock.elapsed(TimeUnit.MILLISECONDS) > 100) {
ErlLogger.debug("TIME open " + element.getClass() + " " + element + " " + clock.elapsed(TimeUnit.MILLISECONDS) + " ms");
}
return result;
}
return false;
}
use of org.erlide.engine.model.root.IErlProject in project erlide_eclipse by erlang.
the class ErlangFileContentProvider method getParent.
/**
* Load the model from the given file, if possible.
*
* @param modelFile
* The IFile which contains the persisted model
*/
@Override
public Object getParent(final Object element) {
if (element instanceof IErlElement) {
final IErlElement elt = (IErlElement) element;
final IParent parent = elt.getParent();
if (parent instanceof IErlModule || parent instanceof IErlProject) {
final IErlElement e = (IErlElement) parent;
return e.getCorrespondingResource();
}
}
return null;
}
use of org.erlide.engine.model.root.IErlProject in project erlide_eclipse by erlang.
the class CompilerPreferencePage method doLinkActivated.
void doLinkActivated(final Link widget) {
if (isProjectPreferencePage()) {
openWorkspacePreferences(null);
} else {
final List<IProject> erlProjects = new ArrayList<>();
final Set<IProject> projectsWithSpecifics = new HashSet<>();
final IErlModel model = ErlangEngine.getInstance().getModel();
try {
for (final IErlProject ep : model.getErlangProjects()) {
final IProject p = ep.getWorkspaceProject();
if (hasProjectSpecificOptions(p)) {
projectsWithSpecifics.add(p);
}
erlProjects.add(p);
}
} catch (final ErlModelException e) {
}
final ProjectSelectionDialog dialog = new ProjectSelectionDialog(getShell(), erlProjects, projectsWithSpecifics);
if (dialog.open() == Window.OK) {
final IProject res = (IProject) dialog.getFirstResult();
openProjectProperties(res);
}
}
}
Aggregations