Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » QuickFix(Processor) and XML Editor
QuickFix(Processor) and XML Editor [message #233842] Sun, 19 July 2009 13:32 Go to next message
Xavier Coulon is currently offline Xavier CoulonFriend
Messages: 58
Registered: July 2009
Member
Dear community,

I'm stuck with the following problem : I'm developping an extension for
the XML Editor to provide content assist and validation (amongst other
features) to the log4j.xml configuration files (you can visit the site at
http://log4jconfig.org for now).

I'd like to provide a quickfix 'link' in the left margin of the editor
when the user adds 'deprecated elements' such as <category>. Content
validation works fine, since I get a warning in the workbench 'problems'
view with a quickfix that triggers a call to run(IMarker marker) on the
IMarkerResolution2 implementation.
Yet, I can't find how to provide the same quickfix from the editor's left
margin (just where the warning marker is).

Here is the subset of my plugin.xml I have for this feature :

<extension
id="org.log4jconfig.xml.editor.deprecatedElementMarker"
name="Log4jconfig warning marker for deprecated elements"
point="org.eclipse.core.resources.markers">
<super
type="org.eclipse.core.resources.problemmarker">
</super>
<super
type="org.eclipse.core.resources.textmarker">
</super>
<persistent
value="false">
</persistent>
<!--attribute
name="problemType">
</attribute -->
</extension>

<extension
id=" org.log4jconfig.xml.editor.quickfix.deprecatedElementQuickFi x "
point="org.eclipse.wst.sse.ui.quickFixProcessor">
<quickFixProcessor

class=" org.log4jconfig.xml.editor.quickassist.DeprecatedElementQuic kAssistProcessor "

problemType="org.log4jconfig.xml.editor.deprecatedElementProblemType ">
</quickFixProcessor>
</extension>

<extension
point="org.eclipse.ui.ide.markerResolution">
<markerResolutionGenerator

class=" org.log4jconfig.xml.editor.quickfix.AnyDeprecatedElementMark erResolutionGenerator "

markerType="org.log4jconfig.xml.editor.deprecatedElementMarker ">
</markerResolutionGenerator>
</extension>

The first extension declares a new marker type with id
'org.log4jconfig.xml.editor.deprecatedElementMarker' (having a
'problemType' attribute declared or not does not seem to change anything)
Then, the second extension declares a quickFixProcessor for a given
problemType 'org.log4jconfig.xml.editor.deprecatedElementProblemType'.
This problem type is set at runtime when creating a marker (at validation
time) as below:

protected void addMarkerOnDirtyRegion(String type, IStructuredDocument
document,
IStructuredDocumentRegion dirtyRegion, int severity, String message,
String problemType)
throws CoreException {
int startLine = document.getLineOfOffset(dirtyRegion.getStart());
IMarker marker = JdtUtils.getFile(document).createMarker(type);
if (marker.exists()) {
marker.setAttribute(IMarker.SEVERITY, severity);
if(problemType != null) {
marker.setAttribute("problemType", problemType);
}
marker.setAttribute(IMarker.LINE_NUMBER, startLine + 1);
marker.setAttribute(IMarker.CHAR_START, dirtyRegion.getStartOffset());
marker.setAttribute(IMarker.CHAR_END, dirtyRegion.getEndOffset());
marker.setAttribute(IMarker.MESSAGE, message);
} else {
Logger.warn("Marker does not exists");
}
}

the third extension provides a resolution (ie, my implementation of
IMarkerResolution2) when the marker type is
'org.log4jconfig.xml.editor.deprecatedElementMarker'.

Can you help me ?
what point did I miss in the configuration ?

Thank you in advance
Regards,
Xavier
Re: QuickFix(Processor) and XML Editor [message #233852 is a reply to message #233842] Mon, 20 July 2009 08:50 Go to previous messageGo to next message
Alessandro Carraro is currently offline Alessandro CarraroFriend
Messages: 27
Registered: July 2009
Junior Member
I had the same problem recently, see in "Resource Beign Edited" thread,
question n.2 for the solution, on date 29 June

In particular it seems that the 2 quick fixes (on problem view and on
XML editor)are different things, so I had to implement the QF twice.



Xavier Coulon wrote:
> Dear community,
>
> I'm stuck with the following problem : I'm developping an extension for
> the XML Editor to provide content assist and validation (amongst other
> features) to the log4j.xml configuration files (you can visit the site
> at http://log4jconfig.org for now).
>
> I'd like to provide a quickfix 'link' in the left margin of the editor
> when the user adds 'deprecated elements' such as <category>. Content
> validation works fine, since I get a warning in the workbench 'problems'
> view with a quickfix that triggers a call to run(IMarker marker) on the
> IMarkerResolution2 implementation.
> Yet, I can't find how to provide the same quickfix from the editor's
> left margin (just where the warning marker is).
>
> Here is the subset of my plugin.xml I have for this feature :
>
> <extension
> id="org.log4jconfig.xml.editor.deprecatedElementMarker"
> name="Log4jconfig warning marker for deprecated elements"
> point="org.eclipse.core.resources.markers">
> <super
> type="org.eclipse.core.resources.problemmarker">
> </super>
> <super
> type="org.eclipse.core.resources.textmarker">
> </super>
> <persistent
> value="false">
> </persistent>
> <!--attribute
> name="problemType">
> </attribute -->
> </extension>
> <extension
> id=" org.log4jconfig.xml.editor.quickfix.deprecatedElementQuickFi x "
> point="org.eclipse.wst.sse.ui.quickFixProcessor">
> <quickFixProcessor
>
> class=" org.log4jconfig.xml.editor.quickassist.DeprecatedElementQuic kAssistProcessor "
>
>
> problemType="org.log4jconfig.xml.editor.deprecatedElementProblemType ">
> </quickFixProcessor>
> </extension>
>
> <extension
> point="org.eclipse.ui.ide.markerResolution">
> <markerResolutionGenerator
>
> class=" org.log4jconfig.xml.editor.quickfix.AnyDeprecatedElementMark erResolutionGenerator "
>
> markerType="org.log4jconfig.xml.editor.deprecatedElementMarker ">
> </markerResolutionGenerator>
> </extension>
>
> The first extension declares a new marker type with id
> 'org.log4jconfig.xml.editor.deprecatedElementMarker' (having a
> 'problemType' attribute declared or not does not seem to change anything)
> Then, the second extension declares a quickFixProcessor for a given
> problemType 'org.log4jconfig.xml.editor.deprecatedElementProblemType'.
> This problem type is set at runtime when creating a marker (at
> validation time) as below:
>
> protected void addMarkerOnDirtyRegion(String type, IStructuredDocument
> document,
> IStructuredDocumentRegion dirtyRegion, int severity, String
> message, String problemType)
> throws CoreException {
> int startLine = document.getLineOfOffset(dirtyRegion.getStart());
> IMarker marker = JdtUtils.getFile(document).createMarker(type);
> if (marker.exists()) {
> marker.setAttribute(IMarker.SEVERITY, severity);
> if(problemType != null) {
> marker.setAttribute("problemType", problemType);
> }
> marker.setAttribute(IMarker.LINE_NUMBER, startLine + 1);
> marker.setAttribute(IMarker.CHAR_START,
> dirtyRegion.getStartOffset());
> marker.setAttribute(IMarker.CHAR_END,
> dirtyRegion.getEndOffset());
> marker.setAttribute(IMarker.MESSAGE, message);
> } else {
> Logger.warn("Marker does not exists");
> }
> }
>
> the third extension provides a resolution (ie, my implementation of
> IMarkerResolution2) when the marker type is
> 'org.log4jconfig.xml.editor.deprecatedElementMarker'.
>
> Can you help me ?
> what point did I miss in the configuration ?
>
> Thank you in advance
> Regards,
> Xavier
>
Re: QuickFix(Processor) and XML Editor [message #233860 is a reply to message #233852] Mon, 20 July 2009 09:36 Go to previous messageGo to next message
Xavier Coulon is currently offline Xavier CoulonFriend
Messages: 58
Registered: July 2009
Member
Hello,

Thank you for the reply.
From the thread you mentionned, I guess the answer wass 'You might have
JFace text Annotations inside of the editor that don't correspond to
on-disk Markers', but the explanation not that clear to me yet...

From the extensions point I provided on my original post, do you see any
error ?
Can you help me ?

Thank you in advance.
Regards,
Xavier
Re: QuickFix(Processor) and XML Editor [message #233868 is a reply to message #233860] Mon, 20 July 2009 09:50 Go to previous messageGo to next message
Xavier Coulon is currently offline Xavier CoulonFriend
Messages: 58
Registered: July 2009
Member
Hello again,

Do this mean I should also create custom annotations bound to the markers
when creating them at content validation time ?

Regards,
Xavier
Re: QuickFix(Processor) and XML Editor [message #233913 is a reply to message #233868] Mon, 20 July 2009 13:55 Go to previous messageGo to next message
Xavier Coulon is currently offline Xavier CoulonFriend
Messages: 58
Registered: July 2009
Member
Well, after several attempts, i'm definitely stuck.
From my current understanding, creating a new annotation type is not the
way to go, since I use the standard warning marker.

I did not find any way to provide quickFix in the contextual menu of the
XML Editor UI for the warning markers problem my plugin provides onto the
(document) file when I perform content validation.

I just don't understand why the 'Problems' view will provide a 'quick fix'
menu while the editor itself does not.

Any help will be greatly appreciated !

Thanx in advance
Regards,
Xavier
Re: QuickFix(Processor) and XML Editor [message #877749 is a reply to message #233913] Sun, 27 May 2012 16:15 Go to previous message
Robert Gruendler is currently offline Robert GruendlerFriend
Messages: 66
Registered: June 2011
Member
i'm trying to do the exact same thing and also can't figure out how to make the xml editor show the quickassist proposal using Ctrl+1.

Is this possible at all?
Previous Topic:Installing WTP
Next Topic:Content Assist of HTML5 API's in WTP
Goto Forum:
  


Current Time: Sun Dec 21 07:01:32 GMT 2014

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

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