_labelProvider = labelProvider;
}
public Object[] getElements(Object parent) {
Object actualParent = parent;
IWOLipsResource wolipsResource = null;
// MS: If we add the dependency it is a circular dependency, so that
// sucks ... We'll just do it Reflection-Style.
if (actualParent != null && actualParent.getClass().getName().equals("org.objectstyle.wolips.components.input.ComponentEditorFileEditorInput")) {
try {
actualParent = actualParent.getClass().getMethod("getFile", (Class[]) null).invoke(actualParent, (Object[]) null);
} catch (Exception e) {
e.printStackTrace();
}
// System.out.println("ViewContentProvider.getElements: " +
// parent);
}
if (actualParent instanceof IFileEditorInput) {
IFileEditorInput input = (IFileEditorInput) actualParent;
actualParent = input.getFile();
}
if (actualParent instanceof IFile) {
try {
// HACK AK: we should use sth more generic here
if ("java".equals(((IFile)actualParent).getFileExtension())) {
actualParent = JavaCore.createCompilationUnitFrom((IFile)actualParent);
}
} catch (Exception ex) {
UIPlugin.getDefault().log(ex);
}
}
if (actualParent instanceof IMember) {
actualParent = ((IMember) actualParent).getCompilationUnit();
}
if (actualParent instanceof IAdaptable) {
wolipsResource = (IWOLipsResource)((IAdaptable)actualParent).getAdapter(IWOLipsResource.class);
// getViewer().setInput(wolipsResource);
}
Object[] resultList;
if (_lastResource != null && wolipsResource != null && _lastResource.equals(wolipsResource)) {
resultList = _lastResultList;
}
else {
List<IResource> result = new LinkedList<IResource>();
if (wolipsResource != null) {
try {
List<IResource> list = wolipsResource.getRelatedResources();
result.addAll(list);
} catch (Exception e) {
UIPlugin.getDefault().log(e);
}