use of org.eclipse.ui.part.ShowInContext in project KaiZen-OpenAPI-Editor by RepreZen.
the class JsonContentOutlinePage method selectionChanged.
@Override
public void selectionChanged(SelectionChangedEvent event) {
super.selectionChanged(event);
showInTarget.show(new ShowInContext(null, event.getSelection()));
}
use of org.eclipse.ui.part.ShowInContext in project KaiZen-OpenAPI-Editor by RepreZen.
the class DocumentUtils method openAndReveal.
/**
* 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));
}
}
use of org.eclipse.ui.part.ShowInContext in project eclipse.platform.text by eclipse.
the class FileSearchPage method getAdapter.
@SuppressWarnings("unchecked")
@Override
public <T> T getAdapter(Class<T> adapter) {
if (IShowInTargetList.class.equals(adapter)) {
return (T) 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 LineElement)
element = ((LineElement) element).getParent();
newSelection.add(element);
}
return (T) (IShowInSource) () -> new ShowInContext(null, new StructuredSelection(new ArrayList<>(newSelection)));
}
return null;
}
return null;
}
use of org.eclipse.ui.part.ShowInContext in project eclipse.platform.text by eclipse.
the class SearchView method fillContextMenu.
@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);
}
}
}
}
}
Aggregations