Non-modifying custom actions

Post here questions and problems related to oXygen frameworks/document types.
Patrik
Posts: 228
Location: Hamburg/Germany

Non-modifying custom actions

Mon Nov 02, 2015 9:47 am

Hi,

I have non-modifying AuthorOperations. To avoid the document being marked as modified after performing the actions I'm setting the it as unmodified explicitly. Since the PseudoClassOperations should have the same problem I'm wondering if there's already a better solution!?

Thanks and regards,

Patrik
Radu
Posts: 5689

Re: Non-modifying custom actions

Mon Nov 02, 2015 10:19 am

Hi Patrik,

We have an undoable edit manager and most of modifications you make to the document are marked as edits and registered in the edit manager in order to have undo/redo support.
The pseudo class change operations are the only operations which do not register edits in the undo manager (as we did not want undo/redo to reset the pseudo class back to the original).
So if your operations perform other changes, you will need to explicitly set the document as modified (if it was not modified before the operation). There is no other way.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Patrik
Posts: 228
Location: Hamburg/Germany

Re: Non-modifying custom actions

Mon Nov 02, 2015 10:42 am

Hi Radu,

I checked again and indeed: opening another file did neither mark the document as modified nor did it add an entry to the undo list. So that's fine.

But calling AuthorDocumentController.refreshNodeReferences() marks the document as modified. And you can undo this operation as well. You might consider this operation not to register edits in the undo manager as well. But it's a minor issue...

Regards,
Patrik
Radu
Posts: 5689

Re: Non-modifying custom actions

Mon Nov 02, 2015 10:55 am

Hi Patrik,

Making the refresh nodes not register undo events in the document is quite hard to do using our current internal architecture.
The entire Author content is a single sequence of characters corresponding to the text nodes. And the hierarchy of Author nodes points in the sequence of characters using the getStartOffset and getEndOffset methods.
Most of the undoable edits remember precise offsets in the content where they need to be re-done or undone. When you refresh the nodes the Author content changes. If that would not be registered as an edit and it would not be undone, when the edit which was done before the nodes refresh would be undone, it would be possible that the offset it remembers in the content as the offset where it needs to be undone would be the wrong one.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Patrik
Posts: 228
Location: Hamburg/Germany

Re: Non-modifying custom actions

Mon Nov 02, 2015 10:59 am

Hi Radu,

I understand, thanks for the explanation.

Patrik

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

Who is online

Users browsing this forum: No registered users and 0 guests