@Override protected ShowInContext getContext(IWorkbenchPart sourcePart) { return new ShowInContext(null, selectedItems); }
/** * @param aPart * @param aShowInContext */ public PropertyShowInContext(IWorkbenchPart aPart, ShowInContext aShowInContext) { super(aShowInContext.getInput(), aShowInContext.getSelection()); part = aPart; }
public boolean show(ShowInContext context) { if (context.getSelection() != null) { getViewer().setSelection(context.getSelection()); return true; } return false; }
public boolean show(ShowInContext context) { ISelection selection = context.getSelection(); if (selection instanceof IStructuredSelection) { IStructuredSelection structuredSelection = (IStructuredSelection) selection; for (Object element : structuredSelection.toList()) { if (element instanceof RepositoryTreeNode) { RepositoryTreeNode node = (RepositoryTreeNode) element; showReflogFor(node.getRepository()); return true; } } } return false; }
/** * Returns the <code>ShowInContext</code> to show in the selected target, * or <code>null</code> if there is no valid context to show. * <p> * This implementation obtains the context from global variables provide. * showInSelection and showInInput should be available. * <p> * * @return the <code>ShowInContext</code> to show or <code>null</code> */ private ShowInContext getContext(ISelection showInSelection, Object input) { if (input == null && showInSelection == null) { return null; } return new ShowInContext(input, showInSelection); }
/** * @param aPart * @param aShowInContext */ public PropertyShowInContext(IWorkbenchPart aPart, ShowInContext aShowInContext) { super(aShowInContext.getInput(), aShowInContext.getSelection()); part = aPart; }
private void updateSelectionToMatchEditor() { if (getEditor() == null) { return; } IShowInSource source = (IShowInSource) getEditor().getAdapter(IShowInSource.class); if (source != null) { ShowInContext showInContext = source.getShowInContext(); if (showInContext != null) { if (showInContext.getSelection() instanceof IStructuredSelection) { Object firstElement = ((IStructuredSelection) showInContext.getSelection()).getFirstElement(); if (firstElement instanceof OutlineItem) { setSelection(new StructuredSelection(firstElement)); } } } } } }
@Override public ShowInContext getShowInContext() { return new ShowInContext(null, fSelectionProviderMediator.getSelection()); } };
@Override public boolean show(ShowInContext context) { ISelection selection = context.getSelection(); if (selection instanceof IStructuredSelection) { IStructuredSelection ss = (IStructuredSelection) selection; if (ss.size() == 1) { // If we can show the selection, return. // Otherwise, fall through and attempt to show the input if ((showHistoryFor(ss.getFirstElement()) != null)) return true; } } if (context.getInput() != null) { return (showHistoryFor(context.getInput()) != null); } return false; } }
@Override 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; } };
@Override public ShowInContext getShowInContext() { return new ShowInContext(null, fSelectionProviderMediator.getSelection()); } };
public boolean show(ShowInContext context) { ISelection selection = context.getSelection(); if (selection instanceof IStructuredSelection) { IStructuredSelection ss = (IStructuredSelection) selection; if (ss.size() == 1) { // If we can show the selection, return. // Otherwise, fall through and attempt to show the input if ((showHistoryFor(ss.getFirstElement()) != null)) return true; } } if (context.getInput() != null) { return (showHistoryFor(context.getInput()) != null); } return false; } }
@Override 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; } };
@Override public ShowInContext getShowInContext() { return new ShowInContext(null, getSelectionProvider().getSelection()); } };
public boolean show(ShowInContext context) { ISelection selection = context.getSelection(); if (selection instanceof IStructuredSelection) { IStructuredSelection ss = (IStructuredSelection) selection; List<IPath> paths = new ArrayList<IPath>(); for (Iterator it = ss.iterator(); it.hasNext();) { Object element = it.next(); IResource resource = AdapterUtils.adapt(element, IResource.class); if (resource != null) { IPath location = resource.getLocation(); if (location != null) paths.add(location); } else if (element instanceof IPath) paths.add((IPath) element); } if (!paths.isEmpty()) { showPaths(paths); return true; } } if(context.getInput() instanceof IFileEditorInput) { IFileEditorInput input = (IFileEditorInput) context.getInput(); showResource(input.getFile()); } return false; }
@Override public boolean show(ShowInContext context) { ISelection selection = context.getSelection(); if (selection != null) { if (selection instanceof IStructuredSelection) { IStructuredSelection ss = (IStructuredSelection)selection; if (ss.size() == 1) { Object obj = ss.getFirstElement(); if (obj instanceof IDebugTarget || obj instanceof IProcess) { Viewer viewer = getViewer(); if (viewer instanceof InternalTreeModelViewer) { InternalTreeModelViewer tv = (InternalTreeModelViewer) viewer; tv.setSelection(selection, true, true); } else { viewer.setSelection(selection, true); } return true; } } } } return false; }
public ShowInContext getShowInContext() { return new ShowInContext(null, getSelectionProvider().getSelection()); } };
private IStructuredSelection getSelection(ShowInContext context) { if (context == null) return StructuredSelection.EMPTY; ISelection selection = context.getSelection(); if (selection != null && !selection.isEmpty() && selection instanceof IStructuredSelection) return (IStructuredSelection)selection; Object input = context.getInput(); if (input instanceof IEditorInput) { LinkHelperService lhs = getLinkHelperService(); return lhs.getSelectionFor((IEditorInput) input); } if (input != null) { return new StructuredSelection(input); } return StructuredSelection.EMPTY; }
public boolean show(ShowInContext context) { ISelection selection = context.getSelection(); if (selection instanceof IStructuredSelection) { for (Object element : ((IStructuredSelection) selection).toArray()) { if (element instanceof OutlineItem) { OutlineItem item = (OutlineItem) element; viewer.setSelection(new TextSelection(item.getOffset(), item.getLength()), true); return true; } } } else if (selection instanceof ITextSelection) { viewer.setSelection(selection, true); return true; } return false; }
@Override public <T> T getAdapter(Class<T> adapterType) { if (adapterType == IShowInSource.class) { return adapterType.cast((IShowInSource) () -> new ShowInContext(null, getSelection())); } if (adapterType == IShowInTargetList.class) { return adapterType.cast((IShowInTargetList) () -> new String[] { IPageLayout.ID_RES_NAV }); } return super.getAdapter(adapterType); }