use of org.eclipse.wst.jsdt.internal.ui.packageview.PackageExplorerPart in project webtools.sourceediting by eclipse.
the class ShowInScriptExplorerAction method run.
public void run(IAction action) {
IJavaScriptElement[] elements = JsElementActionProxy.getJsElementsFromSelection(getCurrentSelection());
if (elements == null || elements.length == 0) {
return;
}
IResource resource = null;
if (elements[0].isVirtual()) {
resource = getHostResource(elements[0]);
} else {
resource = elements[0].getResource();
}
if (resource == null) {
return;
}
try {
PackageExplorerPart view = PackageExplorerPart.openInActivePerspective();
view.tryToReveal(resource);
// IViewPart view= page.showView(IPageLayout.ID_RES_NAV);
if (view instanceof ISetSelectionTarget) {
ISelection selection = new StructuredSelection(resource);
((ISetSelectionTarget) view).selectReveal(selection);
}
} catch (Exception e) {
// ExceptionHandler.handle(e,
// targetWorkbenchPart.getSite().getShell(), "Error Opening in
// Script View", "Error while displaying element in Script View:\n"
// + e);
}
}
Aggregations