Search in sources :

Example 1 with PackageExplorerPart

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);
    }
}
Also used : IJavaScriptElement(org.eclipse.wst.jsdt.core.IJavaScriptElement) ISelection(org.eclipse.jface.viewers.ISelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ISetSelectionTarget(org.eclipse.ui.part.ISetSelectionTarget) PackageExplorerPart(org.eclipse.wst.jsdt.internal.ui.packageview.PackageExplorerPart) IResource(org.eclipse.core.resources.IResource)

Aggregations

IResource (org.eclipse.core.resources.IResource)1 ISelection (org.eclipse.jface.viewers.ISelection)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 ISetSelectionTarget (org.eclipse.ui.part.ISetSelectionTarget)1 IJavaScriptElement (org.eclipse.wst.jsdt.core.IJavaScriptElement)1 PackageExplorerPart (org.eclipse.wst.jsdt.internal.ui.packageview.PackageExplorerPart)1