private static void showMessage(Shell shell, JavaEditor editor, String msg) { IEditorStatusLine statusLine= editor.getAdapter(IEditorStatusLine.class); if (statusLine != null) statusLine.setMessage(true, msg, null); shell.getDisplay().beep(); } }
private IDocument getDocument() { JavaEditor editor= fEditor; if (editor == null) return null; IDocumentProvider provider= editor.getDocumentProvider(); if (provider == null) return null; return provider.getDocument(editor.getEditorInput()); }
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 public void windowDeactivated(IWorkbenchWindow window) { if (window == getEditorSite().getWorkbenchWindow() && fMarkOccurrenceAnnotations && isActivePart()) removeOccurrenceAnnotations(); }
ISourceViewer sourceViewer= getSourceViewer(); if (sourceViewer == null) return; if (isJavaEditorHoverProperty(property)) updateHoverBehavior(); selectionChanged(); return; fMarkOccurrenceAnnotations= newBooleanValue; if (!fMarkOccurrenceAnnotations) uninstallOccurrencesFinder(); else installOccurrencesFinder(true); if (SemanticHighlightings.affectsEnablement(getPreferenceStore(), event)) { if (isSemanticHighlightingEnabled()) installSemanticHighlighting(); else uninstallSemanticHighlighting(); return; ((JavaSourceViewerConfiguration)getSourceViewerConfiguration()).handlePropertyChangeEvent(event); if (affectsOverrideIndicatorAnnotations(event)) { if (isShowingOverrideIndicators()) { if (fOverrideIndicatorManager == null) installOverrideIndicator(true);
ISourceViewer sourceViewer= getSourceViewer(); if (sourceViewer == null) return; if (isJavaEditorHoverProperty(property)) updateHoverBehavior(); selectionChanged(); return; fMarkOccurrenceAnnotations= newBooleanValue; if (!fMarkOccurrenceAnnotations) uninstallOccurrencesFinder(); else installOccurrencesFinder(true); if (property.equals(getBreadcrumbPreferenceKey())) { if (newBooleanValue != fIsBreadcrumbVisible) { fIsBreadcrumbVisible= newBooleanValue; if (fIsBreadcrumbVisible) showBreadcrumb(); else hideBreadcrumb(); if (SemanticHighlightings.affectsEnablement(getPreferenceStore(), event)) { if (isSemanticHighlightingEnabled()) installSemanticHighlighting(); else uninstallSemanticHighlighting();
private ISelection getEditorSelection(JavaEditor editor) { ITypeRoot element= SelectionConverter.getInput(editor); if (element == null) return null; if (editor.isBreadcrumbActive()) return editor.getBreadcrumb().getSelectionProvider().getSelection(); else { ITextSelection textSelection= (ITextSelection) editor.getSelectionProvider().getSelection(); IDocument document= JavaUI.getDocumentProvider().getDocument(editor.getEditorInput()); return new JavaTextSelection(element, document, textSelection.getOffset(), textSelection.getLength()); } }
private void deregisterHelper(IEditingSupport helper, JavaEditor editor) { ISourceViewer viewer= editor.getViewer(); if (viewer instanceof IEditingSupportRegistry) { IEditingSupportRegistry registry= (IEditingSupportRegistry) viewer; registry.unregister(helper); } } }
/** * Note: This constructor is for internal use only. Clients should not call this constructor. * @param editor the java editor * * @noreference This constructor is not intended to be referenced by clients. */ public ReplaceInvocationsAction(JavaEditor editor) { this(editor.getEditorSite()); fEditor= editor; setEnabled(true); }
@Override public final void run() { IJavaElement inputElement= EditorUtility.getEditorInputJavaElement(fEditor, false); if (!(inputElement instanceof ITypeRoot && inputElement.exists())) return; ITypeRoot typeRoot= (ITypeRoot) inputElement; ISourceRange sourceRange; try { sourceRange= typeRoot.getSourceRange(); if (sourceRange == null || sourceRange.getLength() == 0) { MessageDialog.openInformation(fEditor.getEditorSite().getShell(), SelectionActionMessages.StructureSelect_error_title, SelectionActionMessages.StructureSelect_error_message); return; } } catch (JavaModelException e) { } ITextSelection selection= getTextSelection(); ISourceRange newRange= getNewSelectionRange(createSourceRange(selection), typeRoot); // Check if new selection differs from current selection if (selection.getOffset() == newRange.getOffset() && selection.getLength() == newRange.getLength()) return; fSelectionHistory.remember(new SourceRange(selection.getOffset(), selection.getLength())); try { fSelectionHistory.ignoreSelectionChanges(); fEditor.selectAndReveal(newRange.getOffset(), newRange.getLength()); } finally { fSelectionHistory.listenToSelectionChanges(); } }
public OccurrencesFinderJob(IDocument document, Position[] positions, ISelection selection) { super(JavaEditorMessages.JavaEditor_markOccurrences_job_name); fDocument= document; fSelection= selection; fPositions= positions; if (getSelectionProvider() instanceof ISelectionValidator) fPostSelectionValidator= (ISelectionValidator)getSelectionProvider(); }
private void doListSelectionChanged(int page, ISourceRange[] ranges, JavaEditor editor) { if (editor != null && ranges != null && page >= 0 && page < ranges.length) { ISourceRange range= ranges[page]; editor.selectAndReveal(range.getOffset(), range.getLength()); } }
public void createPartControl(Composite parent) { super.createPartControl(parent); fEditorSelectionChangedListener= new EditorSelectionChangedListener(); fEditorSelectionChangedListener.install(getSelectionProvider()); if (isSemanticHighlightingEnabled()) installSemanticHighlighting(); PlatformUI.getWorkbench().addWindowListener(fActivationListener); }
@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()); }
private static ICompilationUnit getCompilationUnit(JavaEditor editor) { IJavaElement element= JavaUI.getEditorInputJavaElement(editor.getEditorInput()); if (!(element instanceof ICompilationUnit)) return null; return (ICompilationUnit)element; }
private TypeNameMatch[] doChooseImports(TypeNameMatch[][] openChoices, final ISourceRange[] ranges, final JavaEditor editor) { ISelection sel= editor.getSelectionProvider().getSelection(); TypeNameMatch[] result= null; ILabelProvider labelProvider= new TypeNameMatchLabelProvider(TypeNameMatchLabelProvider.SHOW_FULLYQUALIFIED); editor.selectAndReveal(textSelection.getOffset(), textSelection.getLength());
/** * Creates the outline page used with this editor. * * @return the created Java outline page */ protected JavaOutlinePage createOutlinePage() { JavaOutlinePage page= new JavaOutlinePage(fOutlinerContextMenuId, this); fOutlineSelectionChangedListener.install(page); setOutlinePageInput(page, getEditorInput()); return page; }
@Override public void run() { if (editor instanceof JavaEditor) { JavaEditor javaEditor= (JavaEditor) editor; javaEditor.collapseMembers(); } } };
public void run() { if (editor instanceof JavaEditor) { JavaEditor javaEditor= (JavaEditor) editor; javaEditor.collapseComments(); } } };
ISourceViewer sourceViewer= getSourceViewer(); if (sourceViewer == null) return; if (isJavaEditorHoverProperty(property)) updateHoverBehavior(); selectionChanged(); return; fMarkOccurrenceAnnotations= newBooleanValue; if (!fMarkOccurrenceAnnotations) uninstallOccurrencesFinder(); else installOccurrencesFinder(true); if (property.equals(getBreadcrumbPreferenceKey())) { if (newBooleanValue != fIsBreadcrumbVisible) { fIsBreadcrumbVisible= newBooleanValue; if (fIsBreadcrumbVisible) showBreadcrumb(); else hideBreadcrumb(); if (SemanticHighlightings.affectsEnablement(getPreferenceStore(), event)) { if (isSemanticHighlightingEnabled()) installSemanticHighlighting(); else uninstallSemanticHighlighting();