use of org.erlide.engine.model.root.IOpenable in project erlide_eclipse by erlang.
the class ErlProject method getExternalModules.
@Override
public Collection<IErlModule> getExternalModules() throws ErlModelException {
final List<IErlModule> result = Lists.newArrayList();
accept(new IErlElementVisitor() {
@Override
public boolean visit(final IErlElement element) throws ErlModelException {
final boolean isExternalOrProject = element.getKind() == ErlElementKind.EXTERNAL_ROOT || element.getKind() == ErlElementKind.EXTERNAL_APP || element.getKind() == ErlElementKind.EXTERNAL_FOLDER || element.getKind() == ErlElementKind.PROJECT;
if (element instanceof IErlModule) {
final IErlModule module = (IErlModule) element;
if (module.getAncestorOfKind(ErlElementKind.PROJECT) == ErlProject.this) {
result.add(module);
}
return false;
} else if (isExternalOrProject && element instanceof IOpenable) {
final IOpenable openable = (IOpenable) element;
openable.open(null);
}
return isExternalOrProject;
}
}, EnumSet.noneOf(AcceptFlags.class), ErlElementKind.MODULE);
return result;
}
use of org.erlide.engine.model.root.IOpenable in project erlide_eclipse by erlang.
the class ErlStructureCreator method recursiveMakeErlNodes.
private ErlNode recursiveMakeErlNodes(final IErlElement element, final ErlNode parent, final IDocument doc) throws ErlModelException {
final ErlNode n = ErlNode.createErlNode(parent, element, doc);
if (element instanceof IOpenable) {
final IOpenable o = (IOpenable) element;
o.open(null);
}
if (element instanceof IParent) {
final IParent p = (IParent) element;
final Collection<IErlElement> children = p.getChildren();
for (final IErlElement child : children) {
recursiveMakeErlNodes(child, n, doc);
}
}
return n;
}
use of org.erlide.engine.model.root.IOpenable 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.IOpenable 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;
}
use of org.erlide.engine.model.root.IOpenable in project erlide_eclipse by erlang.
the class ErlangFileContentProvider method getChildren.
/**
* Return the model elements for a *.erl IFile or NO_CHILDREN for otherwise.
*/
@Override
public Object[] getChildren(final Object parentElement0) {
Object parentElement = parentElement0;
try {
if (parentElement instanceof IFile) {
parentElement = ErlangEngine.getInstance().getModel().findModule((IFile) parentElement);
}
if (parentElement instanceof IOpenable) {
final IOpenable openable = (IOpenable) parentElement;
openable.open(null);
}
if (parentElement instanceof IParent) {
final IParent parent = (IParent) parentElement;
final Collection<IErlElement> children = parent.getChildren();
return children.toArray();
}
} catch (final ErlModelException e) {
ErlLogger.warn(e);
}
return ErlangFileContentProvider.NO_CHILDREN;
}
Aggregations