How to force filterValidationProblems

Post here questions and problems related to oXygen frameworks/document types.
Johann
Posts: 60

How to force filterValidationProblems

Mon Aug 10, 2015 7:32 pm

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: 604

Re: How to force filterValidationProblems

Tue Aug 11, 2015 11:01 am

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: 60

Re: How to force filterValidationProblems

Tue Aug 11, 2015 11:49 am

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: 604

Re: How to force filterValidationProblems

Tue Aug 11, 2015 1:58 pm

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: 60

Re: How to force filterValidationProblems

Tue Aug 11, 2015 3:31 pm

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: 604

Re: How to force filterValidationProblems

Tue Aug 11, 2015 4:02 pm

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: 60

Re: How to force filterValidationProblems

Thu Aug 13, 2015 3:23 pm

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: 5221

Re: How to force filterValidationProblems

Fri Dec 18, 2015 3:00 pm

Hi,

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

[url]ro.sync.exml.workspace.api.editor.WSEditor.checkValid()[/url]

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

Return to “SDK-API, Frameworks - Document Types”

Who is online

Users browsing this forum: No registered users and 1 guest