use of org.python.pydev.navigator.LabelAndImage in project Pydev by fabioz.
the class PydevPackageExplorer method tryToReveal.
/**
* This is the method that actually tries to reveal some item in the tree.
*
* It will go through the pipeline to see if the actual object to reveal has been replaced in the replace pipeline.
*/
public boolean tryToReveal(Object element) {
element = getPythonModelElement(element);
if (element instanceof PydevZipFileStorage) {
pythonLinkHelper.setCommonViewer(this.getCommonViewer());
PydevZipFileStorage pydevZipFileStorage = (PydevZipFileStorage) element;
IStructuredSelection externalFileSelectionInTree = pythonLinkHelper.findExternalFileSelection(pydevZipFileStorage.zipFile);
if (externalFileSelectionInTree != null && !externalFileSelectionInTree.isEmpty()) {
Object firstElement = externalFileSelectionInTree.getFirstElement();
if (firstElement instanceof TreeNode) {
TreeNode treeNode = (TreeNode) firstElement;
// Ok, got to the zip file, let's try to find the path below it...
String zipPath = pydevZipFileStorage.zipPath;
List<String> split = StringUtils.split(zipPath, '/');
for (String string : split) {
List<TreeNode> children = treeNode.getChildren();
for (TreeNode<LabelAndImage> child : children) {
if (string.equals(child.getData().label)) {
treeNode = child;
// Goes on to the next substring...
break;
}
}
}
if (revealAndVerify(new StructuredSelection(treeNode))) {
return true;
}
} else {
Log.log("Expected a TreeNode. Found: " + firstElement);
// Just go on to show the zip, not the internal contents...
if (revealAndVerify(externalFileSelectionInTree)) {
return true;
}
}
}
} else if (element instanceof File) {
pythonLinkHelper.setCommonViewer(this.getCommonViewer());
IStructuredSelection externalFileSelectionInTree = pythonLinkHelper.findExternalFileSelection((File) element);
if (externalFileSelectionInTree != null && !externalFileSelectionInTree.isEmpty()) {
if (revealAndVerify(externalFileSelectionInTree)) {
return true;
}
}
}
// null is checked in the revealAndVerify function
if (revealAndVerify(element)) {
return true;
}
// if it is a wrapped resource that we couldn't show, try to reveal as a resource...
if (element instanceof IAdaptable && !(element instanceof IResource)) {
IAdaptable adaptable = (IAdaptable) element;
IResource resource = adaptable.getAdapter(IResource.class);
if (resource != null) {
if (revealAndVerify(resource)) {
return true;
}
}
}
return false;
}
use of org.python.pydev.navigator.LabelAndImage in project Pydev by fabioz.
the class AbstractFilter method getName.
protected String getName(Object element) {
if (element instanceof IAdaptable) {
IAdaptable adaptable = (IAdaptable) element;
Object adapted = adaptable.getAdapter(IResource.class);
if (adapted instanceof IResource) {
IResource resource = (IResource) adapted;
return resource.getName();
}
} else if (element instanceof TreeNode) {
TreeNode treeNode = (TreeNode) element;
Object data = treeNode.getData();
if (data instanceof LabelAndImage) {
return ((LabelAndImage) data).label;
}
}
return null;
}
Aggregations