Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Question about save
Question about save [message #458225] Thu, 16 November 2006 04:12 Go to next message
Eclipse UserFriend
Hi

When I hit Save when I'm in an editor, I can manage to save my editor
and also do some validation before the actual save persists my data and
give a warning if the validations fails so I can revise the editor.

But if I close the editor tab while it is dirty and my validation fails,
how do I stop the tab from being closed?

Hints please... :-)

Henrik
Re: Question about save [message #458228 is a reply to message #458225] Thu, 16 November 2006 06:01 Go to previous messageGo to next message
Eclipse UserFriend
mark the editor dirty to activate the saveButtons and the user question
dialog when closing dirty editors / the workbench
Re: Question about save [message #458229 is a reply to message #458225] Thu, 16 November 2006 06:04 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: diebosto.fi.vupv.es

Just guessing... have you tried to launch an exception? normally, those
kind of actions abort when an exception comes

hope it helps

Henrik Skovgaard <hsk2840@gmail.com> wrote in news:ejha1l$2n6$1
@utils.eclipse.org:

> Hi
>
> When I hit Save when I'm in an editor, I can manage to save my editor
> and also do some validation before the actual save persists my data and
> give a warning if the validations fails so I can revise the editor.
>
> But if I close the editor tab while it is dirty and my validation
fails,
> how do I stop the tab from being closed?
>
> Hints please... :-)
>
> Henrik
>
Re: Question about save [message #458233 is a reply to message #458225] Thu, 16 November 2006 06:12 Go to previous messageGo to next message
Eclipse UserFriend
sorry for the wrong answer.
didn't read your question in detail.

i hit the same problem and decided to let the user close the editor
(that's what he wanted) and to inform him/her that the work was not saved
due to validation errors. so only consistend data gets persisted.
the user can watch the validation status of each of his editors in a
special view.
Re: Question about save [message #458287 is a reply to message #458229] Thu, 16 November 2006 08:51 Go to previous messageGo to next message
Eclipse UserFriend
Diego Bosca wrote:
> Just guessing... have you tried to launch an exception? normally, those
> kind of actions abort when an exception comes

That's what I want - but where do I throw the exception ?

/Henrik
Re: Question about save [message #458741 is a reply to message #458225] Thu, 23 November 2006 13:02 Go to previous messageGo to next message
Eclipse UserFriend
Your editor can implement ISaveablesSource (just return a single Saveable
instance from both methods). Saves will then go through Saveable.doSave()
instead of ISaveablePart.doSave() which allows you to throw an exception.
The exception will be reported to the end user.

To trivially implement Saveable, just delegate everything except doSave() to
the corresponding methods that you already implemented in your IEditorPart,
but make sure you implement equals and hashCode according to the Javadoc
spec.

Boris

"Henrik Skovgaard" <hsk2840@gmail.com> wrote in message
news:ejha1l$2n6$1@utils.eclipse.org...
> Hi
>
> When I hit Save when I'm in an editor, I can manage to save my editor and
> also do some validation before the actual save persists my data and give a
> warning if the validations fails so I can revise the editor.
>
> But if I close the editor tab while it is dirty and my validation fails,
> how do I stop the tab from being closed?
>
> Hints please... :-)
>
> Henrik
Re: Question about save [message #459453 is a reply to message #458233] Fri, 01 December 2006 11:30 Go to previous messageGo to next message
Eclipse UserFriend
Probably not a good idea- at least not what other applications do. If you
want your work to be lost, you should answer the 'Save' question with 'No',
that's the expected behaviour.
I've found that monitor.setCancelled(true) prevents the tab from closing- I
think that's what needed. It get's tricky when the closing/ validation is a
long-running task though. Not sure yet how to handle that.

Andi

"Sebastian Fuchs" <spacehorst@gmail.com> wrote in message
news:f084df1c3e64bbd8dff607e81eee2325$1@www.eclipse.org...
> sorry for the wrong answer.
> didn't read your question in detail.
>
> i hit the same problem and decided to let the user close the editor
> (that's what he wanted) and to inform him/her that the work was not saved
> due to validation errors. so only consistend data gets persisted.
> the user can watch the validation status of each of his editors in a
> special view.
>
Re: Question about save [message #459524 is a reply to message #459453] Mon, 04 December 2006 12:27 Go to previous messageGo to next message
Eclipse UserFriend
I've meanwhile solved this for me by cancelling the doSave through
monitor.setCancelled(true), then trigger my background job and when that
finishes with event.getResult().isOK() closing the editor through
editor.close(false);

What remains is identifying if the used has modified the editor again after
starting the submission job...

"Andreas Goetz" <cpuidle@gmx.de> wrote in message
news:ekpl9k$o92$1@utils.eclipse.org...
> Probably not a good idea- at least not what other applications do. If you
> want your work to be lost, you should answer the 'Save' question with
> 'No', that's the expected behaviour.
> I've found that monitor.setCancelled(true) prevents the tab from closing-
> I think that's what needed. It get's tricky when the closing/ validation
> is a long-running task though. Not sure yet how to handle that.
>
> Andi
>
> "Sebastian Fuchs" <spacehorst@gmail.com> wrote in message
> news:f084df1c3e64bbd8dff607e81eee2325$1@www.eclipse.org...
>> sorry for the wrong answer.
>> didn't read your question in detail.
>>
>> i hit the same problem and decided to let the user close the editor
>> (that's what he wanted) and to inform him/her that the work was not saved
>> due to validation errors. so only consistend data gets persisted.
>> the user can watch the validation status of each of his editors in a
>> special view.
>>
>
>
Re: Question about save [message #459657 is a reply to message #459524] Tue, 05 December 2006 13:10 Go to previous message
Eclipse UserFriend
Depending on your use case, you might want to disable your editor's controls
until you know whether it can be closed or not. This will prevent users
from continuing to edit while your background job is running.

There is a related bugzilla (background save for editors) that you might be
interested in:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=154122

Boris

"Andreas Goetz" <cpuidle@gmx.de> wrote in message
news:el1ln2$kjh$1@utils.eclipse.org...
> I've meanwhile solved this for me by cancelling the doSave through
> monitor.setCancelled(true), then trigger my background job and when that
> finishes with event.getResult().isOK() closing the editor through
> editor.close(false);
>
> What remains is identifying if the used has modified the editor again
> after starting the submission job...
>
> "Andreas Goetz" <cpuidle@gmx.de> wrote in message
> news:ekpl9k$o92$1@utils.eclipse.org...
>> Probably not a good idea- at least not what other applications do. If you
>> want your work to be lost, you should answer the 'Save' question with
>> 'No', that's the expected behaviour.
>> I've found that monitor.setCancelled(true) prevents the tab from closing-
>> I think that's what needed. It get's tricky when the closing/ validation
>> is a long-running task though. Not sure yet how to handle that.
>>
>> Andi
>>
>> "Sebastian Fuchs" <spacehorst@gmail.com> wrote in message
>> news:f084df1c3e64bbd8dff607e81eee2325$1@www.eclipse.org...
>>> sorry for the wrong answer.
>>> didn't read your question in detail.
>>>
>>> i hit the same problem and decided to let the user close the editor
>>> (that's what he wanted) and to inform him/her that the work was not
>>> saved due to validation errors. so only consistend data gets persisted.
>>> the user can watch the validation status of each of his editors in a
>>> special view.
>>>
>>
>>
>
>
Previous Topic:Generating MouseEvents
Next Topic:fixed editor part size
Goto Forum:
  


Current Time: Wed Mar 26 21:40:38 EDT 2025

Powered by FUDForum. Page generated in 0.06861 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top