How to force filterValidationProblems

Post here questions and problems related to oXygen frameworks/document types.
Johann
Posts: 198
Joined: Wed Jun 17, 2015 12:46 pm

How to force filterValidationProblems

Post by Johann »

Hi,

In my AuthorComponent (version 17), I've created a class which extends ValidationProblemsFilter. In this class, I've overrided the filterValidationProblems method which enables me to get customized error messages in my editor.

I've noticed that this method is called when there is a change in the editor or when the current file is saved. I would like to call this "validation" when I click on a button. Is it and how is it possible ? On debug mode, we cannot see what triggers this method (class ro.sync.exml.editor.validate.o is hidden).

Thanks for your help,

Johann
alex_jitianu
Posts: 1008
Joined: Wed Nov 16, 2005 11:11 am

Re: How to force filterValidationProblems

Post by alex_jitianu »

Hello Johann,

What you've noticed is the automatic validation that is triggered when the user edits the document. There is also a Validate action on the toolbar that triggers a validation.
Best regards,
Alex
Johann
Posts: 198
Joined: Wed Jun 17, 2015 12:46 pm

Re: How to force filterValidationProblems

Post by Johann »

Hello Alex,

thanks for your response. I know the Validate action on the Oxygen toolbar but in my application, I'm using an AuthorComponent and I would like to "recreate" this Validate button. I didn't find the Validate Action in the map returned by the method getAuthorCommonActions() of the AuthorActionsProvider class. How can I add the "Validate" button in my application ?

Thanks,

Johann
alex_jitianu
Posts: 1008
Joined: Wed Nov 16, 2005 11:11 am

Re: How to force filterValidationProblems

Post by alex_jitianu »

Hello Johann,

Can I ask why would you need this button? Isn't the automatic validation enough to signal to the user the problem? Currently, in the Author Component you don't have access to this validate button so I guess we would have to add some additional API.

Best regards,
Alex
Johann
Posts: 198
Joined: Wed Jun 17, 2015 12:46 pm

Re: How to force filterValidationProblems

Post by Johann »

Hello Alex,

In fact, I need this button to add customized validation errors in the standard errors. These customized validation errors have to be added only on user request so by clicking on a button. Have you planned to add the possibility to access the validate button in next releases ?

Best regards,

Johann
alex_jitianu
Posts: 1008
Joined: Wed Nov 16, 2005 11:11 am

Re: How to force filterValidationProblems

Post by alex_jitianu »

Hello Johann,

How about if you add a button and when this button is clicked you run your custom validation and :
- you present the errors in a custom view
- you add a highlight in the document for each error:

Code: Select all

WSAuthorEditorPage edPage = (WSAuthorEditorPage) editorComponent.getWSEditorAccess().getCurrentPage();
// Add a highlight.
edPage.getHighlighter().addHighlight(
startOffset,
endOffset,
new ColorHighlightPainter(),
additionalData);
// TODO Add an entry in a custom view.
The will be missing is that these errors wont appear on the errors stripe, on the right of the editor.

I will add an issue for a validate() method in the API.

Best regards,
Alex
Johann
Posts: 198
Joined: Wed Jun 17, 2015 12:46 pm

Re: How to force filterValidationProblems

Post by Johann »

Hello Alex,

I wanted to use your solution but I thought that's a shame not to use the existing errors report (by clicking on the status bar). So, I found a workaround. When I click on my validation button, if the current document is already saved, I save it again and if it is modified, I perform an undo/redo to force an edition on the document and so a validation. It's not pretty but it works in waiting for a "true" validation button ;)

Best regards,

Johann
Radu
Posts: 9018
Joined: Fri Jul 09, 2004 5:18 pm

Re: How to force filterValidationProblems

Post by Radu »

Hi,

Just to update this thread, the Oxygen 17.1 API should have a new method for this:

ro.sync.exml.workspace.api.editor.WSEditor.checkValid()

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply