/** * Creates and adds Java element hyperlinks. * * @param hyperlinksCollector the list to which hyperlinks should be added * @param wordRegion the region of the link * @param openAction the action to use to open the Java elements * @param element the Java element to open * @param qualify <code>true</code> if the hyperlink text should show a qualified name for * element * @param editor the active Java editor * * @since 3.5 */ protected void addHyperlinks(List<IHyperlink> hyperlinksCollector, IRegion wordRegion, SelectionDispatchAction openAction, IJavaElement element, boolean qualify, JavaEditor editor) { hyperlinksCollector.add(new JavaElementHyperlink(wordRegion, openAction, element, qualify)); }
/** * Creates and adds Java element hyperlinks. * * @param hyperlinksCollector the list to which hyperlinks should be added * @param wordRegion the region of the link * @param openAction the action to use to open the Java elements * @param element the Java element to open * @param qualify <code>true</code> if the hyperlink text should show a qualified name for * element * @param editor the active Java editor * * @since 3.5 */ protected void addHyperlinks(List<IHyperlink> hyperlinksCollector, IRegion wordRegion, SelectionDispatchAction openAction, IJavaElement element, boolean qualify, JavaEditor editor) { hyperlinksCollector.add(new JavaElementHyperlink(wordRegion, openAction, element, qualify)); }
return new IHyperlink[] { new JavaElementHyperlink(wordRegion, (SelectionDispatchAction)openAction, null, false) }; return new IHyperlink[] { new JavaElementHyperlink(wordRegion, (SelectionDispatchAction) openAction, null, false) };
public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) { if (region == null || canShowMultipleHyperlinks || !(fTextEditor instanceof AspectJEditor)) { return null; } IAction openAction = fTextEditor.getAction("OpenEditor"); //$NON-NLS-1$ if (openAction == null) { return null; } int offset = region.getOffset(); IJavaElement input = SelectionConverter .getInput((JavaEditor) fTextEditor); if (input instanceof ICompilationUnit) { input = AJCompilationUnitManager.mapToAJCompilationUnit((ICompilationUnit)input); } if (input instanceof AJCompilationUnit) { String source = PointcutUtilities.isInPointcutContext((AJCompilationUnit)input,offset); if (source != null) { IRegion reg = selectWord(source, offset); if (reg != null) { return new IHyperlink[] { new JavaElementHyperlink( reg, openAction) }; } } } return null; }
return new IHyperlink[] { new JavaElementHyperlink(wordRegion, (SelectionDispatchAction)openAction, null, false) };
public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) { ITextEditor textEditor= (ITextEditor)getAdapter(ITextEditor.class); if (region == null || canShowMultipleHyperlinks || !(textEditor instanceof JavaEditor)) return null; IAction openAction= textEditor.getAction("OpenEditor"); //$NON-NLS-1$ if (openAction == null) return null; int offset= region.getOffset(); IJavaElement input= EditorUtility.getEditorInputJavaElement(textEditor, false); if (input == null) return null; try { IDocument document= textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput()); IRegion wordRegion= JavaWordFinder.findWord(document, offset); if (wordRegion == null) return null; IJavaElement[] elements= null; elements= ((ICodeAssist) input).codeSelect(wordRegion.getOffset(), wordRegion.getLength()); if (elements != null && elements.length > 0) return new IHyperlink[] {new JavaElementHyperlink(wordRegion, openAction)}; } catch (JavaModelException e) { return null; } return null; }