| QuickFix(Processor) and XML Editor [message #233842] |
Sun, 19 July 2009 09:32  |
Xavier Coulon 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
|
|
|