/** * @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; }
/** * @param aPart * @param aShowInContext */ public PropertyShowInContext(IWorkbenchPart aPart, ShowInContext aShowInContext) { super(aShowInContext.getInput(), aShowInContext.getSelection()); part = aPart; }
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; }
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; }
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)); } } } } } }
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; }
@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 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; } };
public void updateShowInSources(MPart part) { IWorkbenchPart workbenchPart = getWorkbenchPart(part); ShowInContext context = getContext(workbenchPart); if (context != null) { window.getContext().set(ISources.SHOW_IN_INPUT, context.getInput()); window.getContext().set(ISources.SHOW_IN_SELECTION, context.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 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; }
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; }
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) { Object selection = getSingleElement(context.getSelection()); if (selection != null) { // If can show the selection, do it. // Otherwise, fall through and attempt to show the input if (showInput(selection)) return true; } Object input = context.getInput(); if (input != null) { if (input instanceof IEditorInput) { return showInput(getInputFromEditor((IEditorInput) input)); } return showInput(input); } return false; }
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; selectAndReveal(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; }
@Override 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; }
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; selectAndReveal(item); if (outlinePage != null && outlinePage.getControl() != null && !outlinePage.getControl().isDisposed()) { outlinePage.setSelection(selection); } return true; } } } else if (selection instanceof ITextSelection) { ITextSelection textSel = (ITextSelection) selection; selectAndReveal(textSel.getOffset(), textSel.getLength()); return true; } return false; }
@Override public void fillContextMenu(IMenuManager menuManager) { ISearchResult result= getCurrentSearchResult(); if (result != null) { // first check if we have a selection for the show in mechanism, bugzilla 127718 IShowInSource showInSource= getAdapter(IShowInSource.class); if (showInSource != null) { ShowInContext context= showInSource.getShowInContext(); if (context != null) { ISelection sel= context.getSelection(); if (sel != null && !sel.isEmpty()) { MenuManager showInSubMenu= new MenuManager(getShowInMenuLabel()); showInSubMenu.add(ContributionItemFactory.VIEWS_SHOW_IN.create(getViewSite().getWorkbenchWindow())); menuManager.appendToGroup(IContextMenuConstants.GROUP_OPEN, showInSubMenu); } } } } }
public void fillContextMenu(IMenuManager menuManager) { ISearchResult result= getCurrentSearchResult(); if (result != null) { menuManager.appendToGroup(IContextMenuConstants.GROUP_SEARCH, fSearchAgainAction); // first check if we have a selection for the show in mechanism, bugzilla 127718 IShowInSource showInSource= (IShowInSource) getAdapter(IShowInSource.class); if (showInSource != null) { ShowInContext context= showInSource.getShowInContext(); if (context != null) { ISelection sel= context.getSelection(); if (sel != null && !sel.isEmpty()) { MenuManager showInSubMenu= new MenuManager(getShowInMenuLabel()); showInSubMenu.add(ContributionItemFactory.VIEWS_SHOW_IN.create(getViewSite().getWorkbenchWindow())); menuManager.appendToGroup(IContextMenuConstants.GROUP_OPEN, showInSubMenu); } } } } }