public PropertiesAction(Shell shell, ISelectionProvider selectionProvider) { super(shell, selectionProvider, Messages.actionProperties); try { selectionChanged((IStructuredSelection) selectionProvider.getSelection()); } catch (Exception e) { // ignore } }
private void refactorMenuHidden() { ITextSelection textSelection= (ITextSelection)fEditor.getSelectionProvider().getSelection(); for (Iterator<SelectionDispatchAction> iter= fActions.iterator(); iter.hasNext(); ) { SelectionDispatchAction action= iter.next(); action.update(textSelection); } }
private ISelection getSelection() { ISelectionProvider provider= fViewPart.getSite().getSelectionProvider(); if (provider != null) { return provider.getSelection(); } return null; }
private void initialize() { ISelection selection= fSelectionProvider.getSelection(); fOpen.update(selection); if (!fIsEditorOwner) { fSelectionProvider.addSelectionChangedListener(fOpen); } }
private ISelection getSelection() { ISelectionProvider provider= fView.getSite().getSelectionProvider(); if (provider != null) { return provider.getSelection(); } return null; }
private IMember getSelectedMemberFromEditor() throws JavaModelException { final IJavaElement element= SelectionConverter.resolveEnclosingElement(fEditor, (ITextSelection) fEditor.getSelectionProvider().getSelection()); if (element == null || !(element instanceof IMember)) return null; return (IMember) element; }
public PublishCleanAction(Shell shell, ISelectionProvider selectionProvider) { super(shell, selectionProvider, Messages.actionPublishClean); setToolTipText(Messages.actionPublishCleanToolTip); try { selectionChanged((IStructuredSelection) selectionProvider.getSelection()); } catch (Exception e) { // ignore } }
public static IJavaElement[] codeResolveOrInputForked(JavaEditor editor) throws InvocationTargetException, InterruptedException { ITypeRoot input= getInput(editor); if (input == null) return EMPTY_RESULT; ITextSelection selection= (ITextSelection)editor.getSelectionProvider().getSelection(); IJavaElement[] result= performForkedCodeResolve(input, selection); if (result.length == 0) { result= new IJavaElement[] {input}; } return result; }
public static IJavaElement[] codeResolveOrInputForked(JavaEditor editor) throws InvocationTargetException, InterruptedException { IJavaElement input= getInput(editor); ITextSelection selection= (ITextSelection)editor.getSelectionProvider().getSelection(); IJavaElement[] result= performForkedCodeResolve(input, selection); if (result.length == 0) { result= new IJavaElement[] {input}; } return result; }
/** * @param primaryOnly if <code>true</code> only primary working copies will be returned * @since 3.2 */ public static IJavaElement[] codeResolve(JavaEditor editor, boolean primaryOnly) throws JavaModelException { return codeResolve(getInput(editor, primaryOnly), (ITextSelection)editor.getSelectionProvider().getSelection()); }
public void setSelectionProvider(ISelectionProvider selectionProvider) { if (mSelectionProvider != null) { mSelectionProvider.removeSelectionChangedListener(this); } mSelectionProvider = selectionProvider; if (mSelectionProvider != null) { mSelectionProvider.addSelectionChangedListener(this); ISelection selection = mSelectionProvider.getSelection(); selectionChanged(selection instanceof IStructuredSelection ? (IStructuredSelection) selection : StructuredSelection.EMPTY); } }
protected ISelection getTargetSelection() { IWorkbenchPart part = getTargetPart(); if (part != null) { ISelectionProvider provider = part.getSite().getSelectionProvider(); if (provider != null) { return provider.getSelection(); } } return null; }
void setSelectionFromEditor(IWorkbenchPart part) { if (!fProcessSelectionEvents || !linkBrowsingViewSelectionToEditor() || !(part instanceof IEditorPart)) return; IWorkbenchPartSite site= part.getSite(); if (site == null) return; ISelectionProvider provider= site.getSelectionProvider(); if (provider != null) setSelectionFromEditor(part, provider.getSelection()); }
public void run() { IMarker[] markers= getMarkers(fSelectionProvider.getSelection()); if (markers != null) try { SearchPlugin.getWorkspace().deleteMarkers(markers); } catch (CoreException ex) { ExceptionHandler.handle(ex, SearchMessages.Search_Error_deleteMarkers_title, SearchMessages.Search_Error_deleteMarkers_message); } }
protected void initializeAndAdjustCompletionOffset(int offset) { selection = (ITextSelection) viewer.getSelectionProvider().getSelection(); completionOffset = offset; if (selection.getOffset() + selection.getLength() == offset) completionOffset = selection.getOffset(); }
public void run() { IStructuredSelection selection= (IStructuredSelection)fPackageExplorer.getSite().getSelectionProvider().getSelection(); Object element= selection.getFirstElement(); if (element instanceof ClassPathContainer.RequiredProjectWrapper) { ClassPathContainer.RequiredProjectWrapper wrapper= (ClassPathContainer.RequiredProjectWrapper) element; fPackageExplorer.tryToReveal(wrapper.getProject()); } } }
@Override public void editorContextMenuAboutToShow(IMenuManager menu) { super.editorContextMenuAboutToShow(menu); ActionContext context= new ActionContext(getSelectionProvider().getSelection()); fContextMenuGroup.setContext(context); fContextMenuGroup.fillContextMenu(menu); fContextMenuGroup.setContext(null); }
private boolean computeEnablement(ITextEditor editor) { if (editor == null) return false; ITextOperationTarget target= editor.getAdapter(ITextOperationTarget.class); if (target == null || ! target.canDoOperation(ISourceViewer.CONTENTASSIST_PROPOSALS)) return false; IJavaProject javaProject = EditorUtility.getJavaProject(editor.getEditorInput()); if (! fCategory.matches(javaProject)) return false; ISelection selection= editor.getSelectionProvider().getSelection(); return isValidSelection(selection); }
public void windowActivated(IWorkbenchWindow window) { if (window == getEditorSite().getWorkbenchWindow() && fMarkOccurrenceAnnotations && isActivePart()) { fForcedMarkOccurrencesSelection= getSelectionProvider().getSelection(); updateOccurrenceAnnotations((ITextSelection)fForcedMarkOccurrencesSelection, JavaPlugin.getDefault().getASTProvider().getAST(getInputJavaElement(), ASTProvider.WAIT_NO, getProgressMonitor())); } }
@Override protected void activateBreadcrumb() { fEditorSelection= getJavaEditor().getSelectionProvider().getSelection(); IEditorSite editorSite= getJavaEditor().getEditorSite(); editorSite.getKeyBindingService().setScopes(new String[] { "org.eclipse.jdt.ui.breadcrumbEditorScope" }); //$NON-NLS-1$ getJavaEditor().setActionsActivated(false); fBreadcrumbActionGroup.fillActionBars(editorSite.getActionBars()); }