public Object getAdapter(Class key) { if (key == IShowInSource.class) { return getShowInSource(); } if (key == IShowInTargetList.class) { return new IShowInTargetList() { public String[] getShowInTargetIds() { return new String[] { JavaUI.ID_PACKAGES }; } }; } if (key == IShowInTarget.class) { return getShowInTarget(); } return null; }
/** * Returns the <code>IShowInTarget</code> for this view. * * @return the {@link IShowInTarget} */ protected IShowInTarget getShowInTarget() { return new IShowInTarget() { public boolean show(ShowInContext context) { ISelection sel= context.getSelection(); if (sel instanceof ITextSelection) { ITextSelection tsel= (ITextSelection) sel; int offset= tsel.getOffset(); IJavaElement element= fEditor.getElementAt(offset); if (element != null) { setSelection(new StructuredSelection(element)); return true; } } else if (sel instanceof IStructuredSelection) { setSelection(sel); return true; } return false; } }; }
protected IShowInTarget getShowInTarget() { return new IShowInTarget() { @Override public boolean show(ShowInContext context) { StructureElement structureElement = getStructureElementFor(context.getSelection()); if(structureElement != null) { setSelection(new StructuredSelection(structureElement)); return true; } return false; } }; }
/** * Opens the editor for the file located at the given path and reveal the selection. * * @param path * @param selection */ public static void openAndReveal(IPath path, ISelection selection) { final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); final IFile file = root.getFile(path); final IEditorPart editor = openEditor(file); if (editor instanceof IShowInTarget) { IShowInTarget showIn = (IShowInTarget) editor; showIn.show(new ShowInContext(null, selection)); } }
private void highlightResult(final VmResource formattedResource, final IWorkbenchPart workbenchPart, Shell shell) { shell.getDisplay().asyncExec(new Runnable() { public void run() { if (workbenchPart instanceof IShowInTarget) { IShowInTarget showInTarget = (IShowInTarget) workbenchPart; ShowInContext showInContext = new ShowInContext(formattedResource.getVProjectFile(), null); showInTarget.show(showInContext); } else { openFileInEditorAsync(formattedResource, workbenchPart.getSite().getWorkbenchWindow()); } } }); }
@Override public Object getAdapter(Class adapter) { if (adapter == IShowInTarget.class) { return this; } return null; }
@SuppressWarnings("unchecked") @Override public <T> T getAdapter(Class<T> adapter) { if(adapter == IShowInTarget.class) { return (T) getShowInTarget(); } return null; }
public JsonContentOutlinePage(IDocumentProvider documentProvider, IShowInTarget showInTarget) { super(); this.documentProvider = documentProvider; this.showInTarget = showInTarget; }
/** * provide a {@link IShowInTarget show in target} to connect the quick-outline popup with the * editor. */ public IShowInTarget getShowInTarget() { return showInTarget; }
/** * provide a {@link IShowInTarget show in target} to connect the quick-outline popup with the * editor. */ public void setShowInTarget(IShowInTarget showInTarget) { this.showInTarget = showInTarget; }