Page 1 of 1

Delete AuthorNode without undo functionality

Posted: Wed Dec 12, 2012 7:20 pm
by SSC
Hello,

Currently I am using the ro.sync.ecss.extensions.api.AuthorDocumentController.deleteNode(AuthorNode) method in order to delete certain content programmatically, but if the user uses the undo functionality the removed AuthorNode will appear again.

Is there an opportunity to delete a certain AuthorNode without having the possibility to use the undo functionality in order to get back the removed XML element?

Best regards,

Simon

Re: Delete AuthorNode without undo functionality

Posted: Thu Dec 13, 2012 9:52 am
by Radu
Hi Simon,

The short answer is no, but it would help me to know more about the user case.
When the document gets loaded do you perform some kind of a clean-up of certain nodes in it?
Or while the user is editing it you sometimes delete nodes from it?
We have API to start a compound edit operation (which contains several modifications) which can be undone in one step.

There is a sequence of undo tasks which is usually created by any application which has undo support.
You cannot remove one undo task from the list because the tasks depend on each other, each undo task must leave the document in exactly the same state as it was before the operation was made.
What could possibly be done would be to clean the entire undo buffer completely but we do not have the API for this yet.

Regards,
Radu

Re: Delete AuthorNode without undo functionality

Posted: Thu Dec 13, 2012 12:17 pm
by SSC
Hello Radu,
Radu wrote: The short answer is no, but it would help me to know more about the user case.
My use case is the following:

I implemented the drop of graphic objects onto the editor.
Our graphic objects can contain several graphic-options(different languages, etc.)
To get the desired graphic-option, which fits to the current XML document there is a query to the server and if a suitable graphic-option is found it will be downloaded.

While the query and download takes place I already added a <image> XML Element, where a "downloading images..." graphic is shown.
When the download finishes correctly the "downloading images..." graphic is replaced by the desired one.

In the case that no suitable graphic-option is found the user is informed about that by a dialog and I delete the <image> XML element, which was inserted before, so that the "downloading images..." graphic is not shown any more.

So when the user does an undo the deleted "downloading images..." graphic is shown up, which should not be the case.

Best regards,

Simon

Re: Delete AuthorNode without undo functionality

Posted: Thu Dec 13, 2012 12:22 pm
by SSC
I came up with the idea, because your API also has two different kinds of setting attributes.
Using the AuthorDocumentController with undo functionality or the setAttribute method on an AuthorElement without undo functionality.

Best regards,

Simon

Re: Delete AuthorNode without undo functionality

Posted: Thu Dec 13, 2012 1:24 pm
by Radu
Hi Simon,

I understand.
I came up with the idea, because your API also has two different kinds of setting attributes.
Using the AuthorDocumentController with undo functionality or the setAttribute method on an AuthorElement without undo functionality.
The second choice should be taken only when the AuthorElement is inside an AuthorDocumentFragment (and not inside the edited document). Otherwise, this might mess up our undo management.

Have you tried showing the image from the StylesFilter instead? Like a static content.
Is it expected that the user can continue working while the image is downloaded?

Regards,
Radu

Re: Delete AuthorNode without undo functionality

Posted: Thu Dec 13, 2012 2:42 pm
by SSC
Radu wrote: Have you tried showing the image from the StylesFilter instead? Like a static content.
That is already the case:

Code: Select all


[href*="downloadingGraphic"]{
content: url(icons/graphic_download.png);
}
And after the download the href attribute is changed.
Radu wrote: Is it expected that the user can continue working while the image is downloaded?
Yes.

Best regards,

Simon

Re: Delete AuthorNode without undo functionality

Posted: Thu Dec 13, 2012 3:39 pm
by Radu
Hi Simon,

Can you compute the @href of the image correctly and insert the image with the final @href set to it from the very beginning (when it is dropped) or is the final @href computed after the CMS brings it locally?

Regards,
Radu

Re: Delete AuthorNode without undo functionality

Posted: Fri Dec 14, 2012 10:34 am
by SSC
Radu wrote: Can you compute the @href of the image correctly and insert the image with the final @href set to it from the very beginning (when it is dropped) or is the final @href computed after the CMS brings it locally?
The second guess is the case.

When we were at the Oxygen Meetup in Frankfurt, we were just dropping the GraphicOption objects directly, where we already have the href attribute inside the object.
With the Graphic objects, which may have several relations to different GraphicOption objects, it is more complicated, so that we get the href or even no result when the server responses.

Maybe I could also just clear the href to the "downloading graphics..." image, so that your no image found error appears, but the better approach would be to remove this dummy/placeholder graphic XML element again.

I consider the fact that the deletion of the "downloading graphics..." image is in the undo registry as minor mistake, which is not too bad, but the User maybe confused if he/she sees hat dummy graphic while undoing.

Best regards,

Simon

Re: Delete AuthorNode without undo functionality

Posted: Fri Dec 14, 2012 12:01 pm
by Radu
Hi Simon,
With the Graphic objects, which may have several relations to different GraphicOption objects, it is more complicated, so that we get the href or even no result when the server responses.
Maybe when the drag starts you show the user a confirmation dialog in which you ask whether the resource should be checked out from the CMS. If so, you could show the user a progress in your own view and when the resource is checked out the user could drag and drop again the object.

Or maybe after the drop instead of inserting the missing image you insert nothing in the document (you just remember the drop offset) and show the user some progress in another way (maybe in your own view) and when the CMS has a result then you insert the image with the proper @href at the previously chose drop offset.

Regards,
Radu

Re: Delete AuthorNode without undo functionality

Posted: Fri Dec 14, 2012 2:00 pm
by SSC
Hi Radu,
Radu wrote: Maybe when the drag starts you show the user a confirmation dialog in which you ask whether the resource should be checked out from the CMS. If so, you could show the user a progress in your own view and when the resource is checked out the user could drag and drop again the object.
This lacks in usability, which is the main aim for our CMS client.
Radu wrote: Or maybe after the drop instead of inserting the missing image you insert nothing in the document (you just remember the drop offset) and show the user some progress in another way (maybe in your own view) and when the CMS has a result then you insert the image with the proper @href at the previously chose drop offset.
This can lead to bad errors, because the target offset may change during the async finding/download process.

Maybe you could consider some enhancements that allow programmatic content modifing without affecting the undo/redo stack.(like the setAttribute mechanism I mentioned earlier)

I mean you rather found some reasons for providing such functionality by yourself:
Radu wrote: When the document gets loaded do you perform some kind of a clean-up of certain nodes in it?
Or while the user is editing it you sometimes delete nodes from it?
So why not providing it?

I guess it should be quite easy to leave the undo/redo stack out under certain circumstances.
Maybe by adding a placeInUndoStack boolean flag or extra methods or even a global flag/mechanisnm to activate and deactivate the undo/redo stack addition.

For now we´ll stick to the current solution, because it fits better than the alternatives.

Best regards,

Simon

Re: Delete AuthorNode without undo functionality

Posted: Fri Dec 14, 2012 3:01 pm
by Radu
Hi Simon,
This can lead to bad errors, because the target offset may change during the async finding/download process.
You can create flexible positions using our API:

Code: Select all

AuthorDocumentController.createPositionInContent(int)
These positions get automatically updated as the user makes changes before or after the offset at which you initially created them.
Maybe you could consider some enhancements that allow programmatic content modifing without affecting the undo/redo stack.(like the setAttribute mechanism I mentioned earlier)
This cannot be done for the reasons I explained earlier, all undo operations are chained together and leave a document in exactly the same state as it was before the operation was performed. The same goes for Redo.

We have methods of beginning compound edits like:

AuthorDocumentController.beginCompoundEdit()
and
AuthorDocumentController.endCompoundEdit()

Basically whatever simple or complex operations are executed between these calls, calling Undo will undo them all.

You always have to end a compound edit so potentially you could begin the edit before you set the dummy attribute to the image and end it after you set the proper attribute (you have to end it even if the server reports a problem).
But there are dangers to this approach also, if the user makes operations and then uses "Undo" in the meantime, this could lead to problems.

Regards,
Radu