use of org.erlide.engine.model.IErlElement 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.IErlElement in project erlide_eclipse by erlang.
the class ErlElementSorter method compare.
@Override
public int compare(final Viewer viewer, final Object o1, final Object o2) {
if (o1 instanceof IErlElement && o2 instanceof IErlElement) {
final IErlElement e1 = (IErlElement) o1;
final IErlElement e2 = (IErlElement) o2;
if (e1.getKind() == ErlElementKind.CLAUSE && e2.getKind() == ErlElementKind.CLAUSE) {
return comparePositions(viewer, (ISourceReference) o1, (ISourceReference) o2);
}
}
return super.compare(viewer, o1, o2);
}
use of org.erlide.engine.model.IErlElement 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.IErlElement in project erlide_eclipse by erlang.
the class OpenErlangAction method isEnabled.
@Override
public boolean isEnabled() {
selectedElement = null;
selectedClosedProjects.clear();
final ISelection selection = provider.getSelection();
if (!selection.isEmpty()) {
final IStructuredSelection sSelection = (IStructuredSelection) selection;
if (sSelection.size() == 1 && sSelection.getFirstElement() instanceof IErlElement) {
selectedElement = (IErlElement) sSelection.getFirstElement();
return true;
}
for (final Object element : sSelection.toList()) {
if (element instanceof IProject) {
final IProject project = (IProject) element;
if (!project.isOpen()) {
selectedClosedProjects.add(project);
return true;
}
}
}
}
return false;
}
use of org.erlide.engine.model.IErlElement in project erlide_eclipse by erlang.
the class FindAction method run.
// private IErlElement findType(ICompilationUnit cu, final boolean silent)
// {
// IType[] types = null;
// try {
// types = cu.getAllTypes();
// } catch (JavaModelException ex) {
// if (JavaModelUtil.isExceptionToBeLogged(ex)) {
// ExceptionHandler.log(ex,
// SearchMessages.JavaElementAction_error_open_message);
// }
// if (silent) {
// return RETURN_WITHOUT_BEEP;
// } else {
// return null;
// }
// }
// if (types.length == 1 || silent && types.length > 0) {
// return types[0];
// }
// if (silent) {
// return RETURN_WITHOUT_BEEP;
// }
// if (types.length == 0) {
// return null;
// }
// final String title =
// SearchMessages.JavaElementAction_typeSelectionDialog_title;
// final String message =
// SearchMessages.JavaElementAction_typeSelectionDialog_message;
// final int flags = JavaElementLabelProvider.SHOW_DEFAULT;
//
// final ElementListSelectionDialog dialog = new ElementListSelectionDialog(
// getShell(), new JavaElementLabelProvider(flags));
// dialog.setTitle(title);
// dialog.setMessage(message);
// dialog.setElements(types);
//
// if (dialog.open() == Window.OK) {
// return (IType) dialog.getFirstResult();
// } else {
// return RETURN_WITHOUT_BEEP;
// }
// }
/*
* Method declared on SelectionChangedAction.
*/
@Override
public void run(final IStructuredSelection selection) {
final IErlElement element = getErlElement(selection, false);
if (element == null || !element.exists()) {
showOperationUnavailableDialog();
return;
}
// else if (element == RETURN_WITHOUT_BEEP) {
// return;
// }
run(element);
}
Aggregations