Java 类org.eclipse.ui.part.ShowInContext 实例源码

项目:n4js    文件:N4MFEditor.java   
/**
 * 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);
}
项目:team-explorer-everywhere    文件:PendingChangesView.java   
@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));
}
项目:fluentmark    文件:FluentMkEditor.java   
@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;
}
项目:KaiZen-OpenAPI-Editor    文件:QuickOutline.java   
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));
            }
        }
    }
}
项目:KaiZen-OpenAPI-Editor    文件:JsonEditor.java   
@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;
}
项目:PDFReporter-Studio    文件:LocalizationEditor.java   
@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);
   }
项目:mytourbook    文件:LocalizationEditor.java   
@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);
}
项目:mytourbook    文件:LocalizationEditor.java   
@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);
}
项目:mytourbook    文件:LocalizationEditor.java   
@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);
}
项目:Eclipse-Postfix-Code-Completion    文件:PackageExplorerPart.java   
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;
}
项目:Eclipse-Postfix-Code-Completion    文件:JavaOutlinePage.java   
/**
 * 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;
        }
    };
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:PackageExplorerPart.java   
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;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavaOutlinePage.java   
/**
 * 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;
        }
    };
}
项目:Pydev    文件:PydevPackageExplorer.java   
/**
 * 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);
}
项目:goclipse    文件:LangOutlinePage.java   
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;
        }

    };
}
项目:n4js    文件:N4JSEditor.java   
/**
 * 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);
}
项目:eclemma    文件:CoverageView.java   
public boolean show(ShowInContext context) {
  final ISelection selection = context.getSelection();
  if (selection instanceof IStructuredSelection) {
    viewer.setSelection(selection);
    return true;
  }
  return false;
}
项目:mesfavoris    文件:BookmarksView.java   
@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);
}
项目:fluentmark    文件:FluentMkEditor.java   
@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);
}
项目:typescript.java    文件:TypeScriptSearchResultPage.java   
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;
}
项目:KaiZen-OpenAPI-Editor    文件:DocumentUtils.java   
/**
 * 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));
    }
}
项目:jdepend4eclipse    文件:PackageTreeView.java   
@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;
}
项目:PDFReporter-Studio    文件:JDTUtils.java   
/**
 * 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;
}
项目:chromedevtools    文件:TemporarilyFormatSourceAction.java   
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());
      }
    }
  });
}
项目:Eclipse-Postfix-Code-Completion    文件:PackageExplorerPart.java   
/**
 * 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());
        }
    };
}
项目:Eclipse-Postfix-Code-Completion    文件:CallHierarchyViewPart.java   
/**
 * @return the <code>IShowInSource</code> for this view.
 */
private IShowInSource getShowInSource() {
    return new IShowInSource() {
        public ShowInContext getShowInContext() {
            return new ShowInContext(null, fSelectionProviderMediator.getSelection());
        }
    };
}
项目:Eclipse-Postfix-Code-Completion    文件:JavaOutlinePage.java   
/**
 * 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());
        }
    };
}
项目:Eclipse-Postfix-Code-Completion    文件:TypeHierarchyViewPart.java   
/**
 * @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());
        }
    };
}
项目:Eclipse-Postfix-Code-Completion    文件:JavaBrowsingPart.java   
/**
 * 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());
        }
    };
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:PackageExplorerPart.java   
/**
 * 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());
        }
    };
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:CallHierarchyViewPart.java   
/**
 * @return the <code>IShowInSource</code> for this view.
 */
private IShowInSource getShowInSource() {
    return new IShowInSource() {
        public ShowInContext getShowInContext() {
            return new ShowInContext(null, fSelectionProviderMediator.getSelection());
        }
    };
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavaOutlinePage.java   
/**
 * 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());
        }
    };
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:TypeHierarchyViewPart.java   
/**
 * @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());
        }
    };
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavaBrowsingPart.java   
/**
 * 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());
        }
    };
}
项目:Pydev    文件:AbstractSearchIndexResultPage.java   
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;
}
项目:fluentmark    文件:MkOutlinePage.java   
@Override
public ShowInContext getShowInContext() {
    return editor.getShowInContext();
}
项目:fluentmark    文件:MkOutlinePage.java   
@Override
public boolean show(ShowInContext context) {
    return editor.show(context);
}
项目:xtext-gef    文件:StatemachineDiagramEditor.java   
/**
 * @generated
 */
public ShowInContext getShowInContext() {
    return new ShowInContext(getEditorInput(), getNavigatorSelection());
}
项目:IDM-Enh-Trace    文件:DetailedTraceEditor.java   
@Override
public boolean show(ShowInContext context) {
    System.out.println(this.getClass().getName()+" - show() for "+context);
    return false;
}
项目:datahierarchy    文件:DataHierarchyView.java   
@Override
public ShowInContext getShowInContext() {
    return new ShowInContext(null, selectionProvider.getSelection());
}