/** * Provides input so that the Project Explorer can locate the editor's input in its tree. */ @Override public ShowInContext getShowInContext() { IEditorInput editorInput = getEditorInput(); if (editorInput instanceof FileEditorInput) { FileEditorInput fei = (FileEditorInput) getEditorInput(); return new ShowInContext(fei.getFile(), null); } else if (editorInput instanceof XtextReadonlyEditorInput) { XtextReadonlyEditorInput readOnlyEditorInput = (XtextReadonlyEditorInput) editorInput; IStorage storage; try { storage = readOnlyEditorInput.getStorage(); return new ShowInContext(storage.getFullPath(), null); } catch (CoreException e) { // Do nothing } } return new ShowInContext(null, null); }
@Override public ShowInContext getShowInContext() { final IStructuredSelection selection = (IStructuredSelection) getViewSite().getSelectionProvider().getSelection(); final Object[] elements = selection.toArray(); for (int i = 0; i < elements.length; i++) { if (elements[i] instanceof ChangeItem) { final ChangeItem changeItem = (ChangeItem) elements[i]; if (changeItem.getType() == ChangeItemType.PENDING) { final PendingChange pendingChange = changeItem.getPendingChange(); final IResource resource = getResourceForPendingChange(pendingChange); if (resource != null) { elements[i] = resource; } } } } return new ShowInContext(null, new StructuredSelection(elements)); }
@Override public boolean show(ShowInContext context) { ISelection selection = context.getSelection(); if (selection instanceof IStructuredSelection) { for (Object element : ((IStructuredSelection) selection).toArray()) { if (element instanceof PagePart) { PagePart item = (PagePart) element; revealPart(item); if (isOutlinePageValid()) { outlinePage.setSelection(selection); } return true; } } } else if (selection instanceof ITextSelection) { ITextSelection textSel = (ITextSelection) selection; selectAndReveal(textSel.getOffset(), textSel.getLength()); return true; } return false; }
protected void handleSelection() { ITreeSelection selection = (ITreeSelection) treeViewer.getSelection(); if (selection != null) { Object element = selection.getFirstElement(); if (element instanceof AbstractNode) { Model model = ((AbstractNode) element).getModel(); if (model.getPath() != null) { DocumentUtils.openAndReveal(model.getPath(), selection); } else { editor.show(new ShowInContext(null, selection)); } } } }
@Override public boolean show(ShowInContext context) { ISelection selection = context.getSelection(); if (selection instanceof IStructuredSelection) { Object selected = ((IStructuredSelection) selection).getFirstElement(); if (selected instanceof AbstractNode) { Position position = ((AbstractNode) selected).getPosition(getSourceViewer().getDocument()); selectAndReveal(position.getOffset(), position.getLength()); return true; } } return false; }
@SuppressWarnings("rawtypes") @Override public Object getAdapter(Class adapter) { if (IShowInSource.class == adapter) { return new IShowInSource() { public ShowInContext getShowInContext() { ResourceBundleKey entry = getSelectedEntry(); if (entry == null) { return null; } ResourceBundle bundle = entry.getParent().getBundle( new Locale("")); if (bundle == null) { return null; } Object resource = bundle.getUnderlyingResource(); return new ShowInContext(resource, new StructuredSelection( resource)); } }; } return super.getAdapter(adapter); }
@SuppressWarnings("unchecked") @Override public Object getAdapter(Class adapter) { if (IShowInSource.class == adapter) { return new IShowInSource() { public ShowInContext getShowInContext() { ResourceBundleKey entry = getSelectedEntry(); if (entry == null) return null; ResourceBundle bundle = entry.getParent().getBundle(new Locale("")); if (bundle == null) return null; Object resource = bundle.getUnderlyingResource(); return new ShowInContext(resource, new StructuredSelection(resource)); } }; } return super.getAdapter(adapter); }
public boolean show(ShowInContext context) { ISelection selection= context.getSelection(); if (selection instanceof IStructuredSelection) { // fix for 64634 Navigate/Show in/Package Explorer doesn't work IStructuredSelection structuredSelection= ((IStructuredSelection) selection); if (structuredSelection.size() == 1) { int res= tryToReveal(structuredSelection.getFirstElement()); if (res == IStatus.OK) return true; if (res == IStatus.CANCEL) return false; } else if (structuredSelection.size() > 1) { selectReveal(structuredSelection); return true; } } Object input= context.getInput(); if (input instanceof IEditorInput) { Object elementOfInput= getInputFromEditor((IEditorInput) input); return elementOfInput != null && (tryToReveal(elementOfInput) == IStatus.OK); } return false; }
/** * 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; } }; }
/** * Implements the 'show in...' action */ @Override public boolean show(ShowInContext context) { Object elementOfInput = null; ISelection selection = context.getSelection(); if (selection instanceof IStructuredSelection) { IStructuredSelection structuredSelection = ((IStructuredSelection) selection); if (structuredSelection.size() == 1) { elementOfInput = structuredSelection.getFirstElement(); } } Object input = context.getInput(); if (input instanceof IEditorInput) { elementOfInput = getElementOfInput((IEditorInput) context.getInput()); } return elementOfInput != null && tryToReveal(elementOfInput); }
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; } }; }
public boolean show(ShowInContext context) { final ISelection selection = context.getSelection(); if (selection instanceof IStructuredSelection) { viewer.setSelection(selection); return true; } return false; }
@Override public Object getAdapter(Class adapter) { if (adapter == IPropertySheetPage.class) { propertyPage = new PropertySheetPage(); return propertyPage; } if (adapter == IShowInSource.class) { return new IShowInSource() { public ShowInContext getShowInContext() { return new ShowInContext(null, bookmarksTreeViewer.getSelection()); } }; } return super.getAdapter(adapter); }
@Override public ShowInContext getShowInContext() { PagePart part = getMatchingPagePart(); StructuredSelection sel; if (part == null) { sel = new StructuredSelection(); } else { sel = new StructuredSelection(part); } return new ShowInContext(getEditorInput(), sel); }
public Object getAdapter(Class adapter) { if (IShowInTargetList.class.equals(adapter)) { return SHOW_IN_TARGET_LIST; } if (adapter == IShowInSource.class) { ISelectionProvider selectionProvider= getSite().getSelectionProvider(); if (selectionProvider == null) return null; ISelection selection= selectionProvider.getSelection(); if (selection instanceof IStructuredSelection) { IStructuredSelection structuredSelection= ((StructuredSelection)selection); final Set newSelection= new HashSet(structuredSelection.size()); Iterator iter= structuredSelection.iterator(); while (iter.hasNext()) { Object element= iter.next(); if (element instanceof LineElement) element= ((LineElement)element).getParent(); newSelection.add(element); } return new IShowInSource() { public ShowInContext getShowInContext() { return new ShowInContext(null, new StructuredSelection(new ArrayList(newSelection))); } }; } return null; } return null; }
/** * 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)); } }
@Override public ShowInContext getShowInContext() { IStructuredSelection selection = getSelection(); if(selection.size() != 1){ return null; } TreeObject firstElement = (TreeObject) selection.getFirstElement(); if(firstElement.getIResource() != null) { return new ShowInContext(null, new StructuredSelection(firstElement.getIResource())); } return null; }
/** * Retrieves the current {@link IProject} instance based on the * currently opened editor. */ public static IProject getCurrentProjectForOpenEditor() { IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (activeWorkbenchWindow != null && activeWorkbenchWindow.getActivePage() != null) { IEditorPart p = activeWorkbenchWindow.getActivePage().getActiveEditor(); if(p == null) { IWorkbenchPart activePart = activeWorkbenchWindow.getActivePage().getActivePart(); if(activePart instanceof PropertySheet) { ShowInContext showInContext = ((PropertySheet)activePart).getShowInContext(); if(showInContext instanceof PropertyShowInContext) { IWorkbenchPart part = ((PropertyShowInContext)showInContext).getPart(); if(part instanceof IEditorPart) { p = (IEditorPart) part; } else { JasperReportsPlugin.getDefault().logWarning("Unable to retrieve the current project for the open editor."); return null; } } } } IEditorInput editorInput = p.getEditorInput(); IFile file = getFile(editorInput); if(file!=null){ return file.getProject(); } } return null; }
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()); } } }); }
/** * Returns the <code>IShowInSource</code> for this view. * @return the <code>IShowInSource</code> */ protected IShowInSource getShowInSource() { return new IShowInSource() { public ShowInContext getShowInContext() { return new ShowInContext( getTreeViewer().getInput(), getTreeViewer().getSelection()); } }; }
/** * @return the <code>IShowInSource</code> for this view. */ private IShowInSource getShowInSource() { return new IShowInSource() { public ShowInContext getShowInContext() { return new ShowInContext(null, fSelectionProviderMediator.getSelection()); } }; }
/** * Returns the <code>IShowInSource</code> for this view. * * @return the {@link IShowInSource} */ protected IShowInSource getShowInSource() { return new IShowInSource() { public ShowInContext getShowInContext() { return new ShowInContext( null, getSite().getSelectionProvider().getSelection()); } }; }
/** * @return Returns the <code>IShowInSource</code> for this view. */ protected IShowInSource getShowInSource() { return new IShowInSource() { public ShowInContext getShowInContext() { return new ShowInContext( null, getSite().getSelectionProvider().getSelection()); } }; }
/** * Returns the <code>IShowInSource</code> for this view. * @return returns the <code>IShowInSource</code> */ protected IShowInSource getShowInSource() { return new IShowInSource() { public ShowInContext getShowInContext() { return new ShowInContext( null, getSite().getSelectionProvider().getSelection()); } }; }
public Object getAdapter(Class<?> adapter) { if (IShowInTargetList.class.equals(adapter)) { return SHOW_IN_TARGET_LIST; } if (adapter == IShowInSource.class) { ISelectionProvider selectionProvider = getSite().getSelectionProvider(); if (selectionProvider == null) { return null; } ISelection selection = selectionProvider.getSelection(); if (selection instanceof IStructuredSelection) { IStructuredSelection structuredSelection = ((StructuredSelection) selection); final Set<Object> newSelection = new HashSet<>(structuredSelection.size()); Iterator<?> iter = structuredSelection.iterator(); while (iter.hasNext()) { Object element = iter.next(); if (element instanceof ICustomLineElement) { element = ((ICustomLineElement) element).getParent(); } newSelection.add(element); } return new IShowInSource() { @Override public ShowInContext getShowInContext() { return new ShowInContext(null, new StructuredSelection(new ArrayList<>(newSelection))); } }; } return null; } return null; }
@Override public ShowInContext getShowInContext() { return editor.getShowInContext(); }
@Override public boolean show(ShowInContext context) { return editor.show(context); }
/** * @generated */ public ShowInContext getShowInContext() { return new ShowInContext(getEditorInput(), getNavigatorSelection()); }
@Override public boolean show(ShowInContext context) { System.out.println(this.getClass().getName()+" - show() for "+context); return false; }
@Override public ShowInContext getShowInContext() { return new ShowInContext(null, selectionProvider.getSelection()); }