Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » hyperlinkDetectors and hyperlinkDetectorTargets(getAdapter(ITextEditor.class) return null)
hyperlinkDetectors and hyperlinkDetectorTargets [message #540587] Wed, 16 June 2010 15:16 Go to next message
Stella Levin is currently offline Stella Levin
Messages: 88
Registered: July 2009
Member
Hi, I try to contribute hyperlink detector via extension point. Below is the code and plugin.xml. But the function getAdapter always returns null and fContextField of AbstractHyperlinkDetector is null. Why?

<extension    point="org.eclipse.ui.workbench.texteditor.hyperlinkDetectorTargets">
   <target
         id="org.mlnx.aria.trav.ReportEditorTarget"
         name="ReportEditorTarget">
      <context
            type="org.eclipse.ui.texteditor.ITextEditor">
      </context>
   </target>
</extension>
<extension
      point="org.eclipse.ui.workbench.texteditor.hyperlinkDetectors">
   <hyperlinkDetector
         activate="true"
         class="org.mlnx.aria.trav.ReportEditorHyperlinkDetector"
         id="org.mlnx.aria.trav.ReportEditorHyperlinkDetector"
         name="ReportEditorHyperlinkDetector"
         targetId="org.mlnx.aria.trav.ReportEditorTarget">
   </hyperlinkDetector>
</extension>


public class ReportEditorHyperlinkDetector ... {
public IHyperlink[] detectHyperlinks(ITextViewer textViewer,
IRegion region, boolean canShowMultipleHyperlinks) {
ITextEditor textEditor= (ITextEditor)getAdapter(ITextEditor.class);
...
Re: hyperlinkDetectors and hyperlinkDetectorTargets [message #541182 is a reply to message #540587] Fri, 18 June 2010 14:48 Go to previous messageGo to next message
Dani Megert is currently offline Dani Megert
Messages: 3801
Registered: July 2009
Senior Member
Stella wrote:
> Hi, I try to contribute hyperlink detector via extension point. Below
> is the code and plugin.xml. But the function getAdapter always returns
> null and fContextField of AbstractHyperlinkDetector is null. Why?
Because you didn't set it, see
org.eclipse.jface.text.hyperlink.AbstractHyperlinkDetector.s etContext(IAdaptable).

Dani
>
> <extension
> point=" org.eclipse.ui.workbench.texteditor.hyperlinkDetectorTargets ">
> <target
> id="org.mlnx.aria.trav.ReportEditorTarget"
> name="ReportEditorTarget">
> <context
> type="org.eclipse.ui.texteditor.ITextEditor">
> </context>
> </target>
> </extension>
> <extension
> point="org.eclipse.ui.workbench.texteditor.hyperlinkDetectors ">
> <hyperlinkDetector
> activate="true"
> class="org.mlnx.aria.trav.ReportEditorHyperlinkDetector"
> id="org.mlnx.aria.trav.ReportEditorHyperlinkDetector"
> name="ReportEditorHyperlinkDetector"
> targetId="org.mlnx.aria.trav.ReportEditorTarget">
> </hyperlinkDetector>
> </extension>
>
>
> public class ReportEditorHyperlinkDetector ... {
> public IHyperlink[] detectHyperlinks(ITextViewer textViewer,
> IRegion region, boolean canShowMultipleHyperlinks) {
> ITextEditor textEditor= (ITextEditor)getAdapter(ITextEditor.class);
> ..
Re: hyperlinkDetectors and hyperlinkDetectorTargets [message #541336 is a reply to message #541182] Sun, 20 June 2010 08:48 Go to previous messageGo to next message
Stella Levin is currently offline Stella Levin
Messages: 88
Registered: July 2009
Member
Hi Dani, thanks a lot for reply. The problem happen even before this.
The plugin A defines the Editor and HyperlinkDetectorA. The plugin B try to contribute HyperlinkDetectorB to the Editor. But the execution never get to HyperlinkDetectorB class constructor and detectHyperlinks function. Always original HyperlinkDetectorA is called. Why?

The plugin B contribution as in previous post.

Thanks, Stella
Re: hyperlinkDetectors and hyperlinkDetectorTargets [message #541433 is a reply to message #541336] Mon, 21 June 2010 07:08 Go to previous messageGo to next message
Dani Megert is currently offline Dani Megert
Messages: 3801
Registered: July 2009
Senior Member
Stella wrote:
> Hi Dani, thanks a lot for reply. The problem happen even before this.
> The plugin A defines the Editor and HyperlinkDetectorA. The plugin B
> try to contribute HyperlinkDetectorB to the Editor. But the execution
> never get to HyperlinkDetectorB class constructor and detectHyperlinks
> function. Always original HyperlinkDetectorA is called. Why?
Maybe you use FIRST as detection strategy, in which case the first good
match will be returned.

Dani
>
> The plugin B contribution as in previous post.
>
> Thanks, Stella
Re: hyperlinkDetectors and hyperlinkDetectorTargets [message #541453 is a reply to message #541433] Mon, 21 June 2010 09:05 Go to previous messageGo to next message
Stella Levin is currently offline Stella Levin
Messages: 88
Registered: July 2009
Member
Hi Dani. I want the plugin B to override the Editor HyperlinkDetectorA, defined in plugin A. Is it possible? It doesn't correspond to existing strategies: FIRST, ALL, LONGEST_REGION_ALL, LONGEST_REGION_FIRST. Thanks a lot. Stella
Re: hyperlinkDetectors and hyperlinkDetectorTargets [message #541504 is a reply to message #541453] Mon, 21 June 2010 12:09 Go to previous messageGo to next message
Dani Megert is currently offline Dani Megert
Messages: 3801
Registered: July 2009
Senior Member
Stella wrote:
> Hi Dani. I want the plugin B to override the Editor
> HyperlinkDetectorA, defined in plugin A. Is it possible?
You could try to use the same ID but in general there's no official
support to replace a detector.

Dani
> It doesn't correspond to existing strategies: FIRST, ALL,
> LONGEST_REGION_ALL, LONGEST_REGION_FIRST. Thanks a lot. Stella
Re: hyperlinkDetectors and hyperlinkDetectorTargets [message #541965 is a reply to message #541504] Wed, 23 June 2010 12:10 Go to previous messageGo to next message
Stella Levin is currently offline Stella Levin
Messages: 88
Registered: July 2009
Member
Hi, thanks a lot for reply. I actually detected that I cannot contribute the hyperlink detector within plugin.xml definitions:
<extension
point="org.eclipse.ui.workbench.texteditor.hyperlinkDetectorTargets">
   <target
         id="org.mlnx.aria.ApplicationTextEditorTarget"
         name="ApplicationTextEditor">
         <context type="org.mlnx.aria.ApplicationTextEditor"/>
   </target>
 </extension>
<extension
      point="org.eclipse.ui.workbench.texteditor.hyperlinkDetectors">
   <hyperlinkDetector
         class="org.mlnx.aria.ApplicationHyperlinkDetector"
         id="org.mlnx.aria.ApplicationHyperlinkDetector"
         name="ApplicationHyperlinkDetector"
         targetId="org.mlnx.aria.ApplicationTextEditorTarget">
   </hyperlinkDetector>
</extension>   

and inside the SourceViewerConfiguration
public class ApplicationSourceViewerConfiguration extends
		TextSourceViewerConfiguration {
  protected Map getHyperlinkDetectorTargets(ISourceViewer sourceViewer) {
      Map targets= super.getHyperlinkDetectorTargets(sourceViewer);
      targets.put("org.mlnx.aria.ApplicationTextEditorTarget", editor);
      return targets;
}


But it does work when I define the HyperlinkDetector inside SourceViewerConfiguration, like the following
public class ApplicationSourceViewerConfiguration extends
		TextSourceViewerConfiguration {
public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
        if (sourceViewer == null) return null;
        return new IHyperlinkDetector[] { new ApplicationHyperlinkDetector() };
} 

What is wrong? I use eclipse 3.4. Thanks, Stella
Re: hyperlinkDetectors and hyperlinkDetectorTargets [message #544646 is a reply to message #541965] Mon, 05 July 2010 07:47 Go to previous messageGo to next message
Dani Megert is currently offline Dani Megert
Messages: 3801
Registered: July 2009
Senior Member
Stella wrote:
> Hi, thanks a lot for reply. I actually detected that I cannot
> contribute the hyperlink detector within plugin.xml definitions:
> <extension
> point=" org.eclipse.ui.workbench.texteditor.hyperlinkDetectorTargets ">
> <target
> id="org.mlnx.aria.ApplicationTextEditorTarget"
> name="ApplicationTextEditor">
> <context type="org.mlnx.aria.ApplicationTextEditor"/>
> </target>
> </extension>
> <extension
> point="org.eclipse.ui.workbench.texteditor.hyperlinkDetectors ">
> <hyperlinkDetector
> class="org.mlnx.aria.ApplicationHyperlinkDetector"
> id="org.mlnx.aria.ApplicationHyperlinkDetector"
> name="ApplicationHyperlinkDetector"
> targetId="org.mlnx.aria.ApplicationTextEditorTarget">
> </hyperlinkDetector>
> </extension> and inside the SourceViewerConfiguration
> public class ApplicationSourceViewerConfiguration extends
> TextSourceViewerConfiguration {
> protected Map getHyperlinkDetectorTargets(ISourceViewer sourceViewer) {
> Map targets= super.getHyperlinkDetectorTargets(sourceViewer);
> targets.put("org.mlnx.aria.ApplicationTextEditorTarget", editor);
> return targets;
> }
>
> But it does work when I define the HyperlinkDetector inside
> SourceViewerConfiguration, like the following
> public class ApplicationSourceViewerConfiguration extends
> TextSourceViewerConfiguration {
> public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer
> sourceViewer) {
> if (sourceViewer == null) return null;
> return new IHyperlinkDetector[] { new
> ApplicationHyperlinkDetector() };
> }
> What is wrong? I use eclipse 3.4. Thanks, Stella
Nothing is wrong. This is as designed: by default the extension point is
used/read but you can override this in your code.

Dani
Re: hyperlinkDetectors and hyperlinkDetectorTargets [message #544651 is a reply to message #544646] Mon, 05 July 2010 08:09 Go to previous messageGo to next message
Stella Levin is currently offline Stella Levin
Messages: 88
Registered: July 2009
Member
Hi Dani, thanks for reply. The problem that contribution via plugin.xml (without code in SourceViewerConfiguration ) doesn't work. What may be a reason? Thanks a lot again. Stella
Re: hyperlinkDetectors and hyperlinkDetectorTargets [message #544677 is a reply to message #544651] Mon, 05 July 2010 08:27 Go to previous message
Dani Megert is currently offline Dani Megert
Messages: 3801
Registered: July 2009
Senior Member
Stella wrote:
> Hi Dani, thanks for reply. The problem that contribution via
> plugin.xml (without code in SourceViewerConfiguration ) doesn't work.
> What may be a reason?
As said, this is not supported: you cannot replace an existing hyperlink
detector via plugin.xml.

Dani
> Thanks a lot again. Stella
Previous Topic:can't open file in root directory on Mac OS X with ResourcesPlugin.getWorkspace().getRoot().getFile
Next Topic:multiple context menu's in one editor
Goto Forum:
  


Current Time: Thu Sep 18 23:48:06 GMT 2014

Powered by FUDForum. Page generated in 0.11079 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software