use of org.erlide.engine.model.IParent 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.IParent 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.IParent in project erlide_eclipse by erlang.
the class DefaultErlangFoldingStructureProvider method computeAdditions.
private void computeAdditions(final Collection<? extends IErlElement> elements, final Map<ErlangProjectionAnnotation, Position> map) throws ErlModelException {
if (elements == null) {
return;
}
for (final IErlElement element : elements) {
computeAdditions(element, map);
if (element instanceof IParent) {
final IParent parent = (IParent) element;
computeAdditions(parent.getChildren(), map);
}
}
}
use of org.erlide.engine.model.IParent in project erlide_eclipse by erlang.
the class EditorUtility method getEditorInput.
private static IEditorInput getEditorInput(final IErlElement element0) {
IErlElement element = element0;
final IResource resource = element.getResource();
if (resource instanceof IFile) {
IFile file = (IFile) resource;
file = EditorUtility.resolveFile(file);
return new FileEditorInput(file);
}
String filePath = element.getFilePath();
while (filePath == null) {
final IParent parent = element.getParent();
if (parent instanceof IErlElement) {
element = (IErlElement) parent;
filePath = element.getFilePath();
} else {
break;
}
}
if (filePath != null) {
final IPath path = new Path(filePath);
IFileStore fileStore = EFS.getLocalFileSystem().getStore(path.removeLastSegments(1));
fileStore = fileStore.getChild(path.lastSegment());
final IFileInfo fetchInfo = fileStore.fetchInfo();
if (!fetchInfo.isDirectory() && fetchInfo.exists()) {
if (element instanceof IErlModule && element.getParent() instanceof IErlExternal) {
return new ErlangExternalEditorInput(fileStore, (IErlModule) element);
}
return new FileStoreEditorInput(fileStore);
}
}
return null;
}
use of org.erlide.engine.model.IParent in project erlide_eclipse by erlang.
the class ErlangExternalsContentProvider method getChildren.
@Override
public Object[] getChildren(final Object parentElement0) {
Object parentElement = parentElement0;
try {
if (parentElement instanceof IProject) {
final IProject project = (IProject) parentElement;
if (project.isOpen()) {
parentElement = ErlangEngine.getInstance().getModel().findProject(project);
}
}
if (parentElement instanceof IErlModule) {
return erlangFileContentProvider.getChildren(parentElement);
}
if (parentElement instanceof IParent) {
if (parentElement instanceof IOpenable) {
final IOpenable openable = (IOpenable) parentElement;
openable.open(null);
}
final IParent parent = (IParent) parentElement;
final Collection<IErlElement> children = parent.getChildrenOfKind(ErlElementKind.EXTERNAL_ROOT, ErlElementKind.EXTERNAL_APP, ErlElementKind.EXTERNAL_FOLDER);
return children.toArray();
}
} catch (final ErlModelException e) {
}
return ErlangExternalsContentProvider.NO_CHILDREN;
}
Aggregations