Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Disabling save for dirty Editor Part
Disabling save for dirty Editor Part [message #542074] Wed, 23 June 2010 18:01 Go to next message
Greg Babcock is currently offline Greg BabcockFriend
Messages: 53
Registered: July 2009
Member
I would like to disable saving editor input when the contents are invalid.
I could have isDirty () return false, but this will also remove the dirty
decorator from the tab.

Any ideas?

GB
Re: Disabling save for dirty Editor Part [message #542745 is a reply to message #542074] Fri, 25 June 2010 19:07 Go to previous messageGo to next message
Johnny Mongiat is currently offline Johnny MongiatFriend
Messages: 7
Registered: December 2009
Junior Member
GB,

I'm not quite sure that disabling the save command (i.e. menuitem, toolbar button...), yet still having the dirty decoration ("*") present is good usability (seems to break fundamental Eclipse UI rules). Why don't you just pop up some sort of error dialog message (e.g. "Invalid content" when a user decides to save the editor, and that editor contains invalid content (read the javadoc for ISaveablePart.doSave(...)):

public void doSave(IProgressMonitor monitor) {
...
if(content is invalid) {
// display an error message
// monitor.setCancelled(true);
return;
}
...
}

Otherwise, you may need to override your editor's setPartName(String partName) method to ensure that a "*" decoration is prepended whenever the underlying contents are invalid - I'm not really sure if this would work but you can try:

protected void setPartName(String partName) {
String name = partName;
if(content is invalid) {
if(!isDirty()) {// the "*" decoration will automatically be present if editor is dirty???
name = "*" + partName;
}
}

super.setPartName(name);
}

Thanks,
Johnny
Re: Disabling save for dirty Editor Part [message #542925 is a reply to message #542745] Sun, 27 June 2010 14:36 Go to previous message
Greg Babcock is currently offline Greg BabcockFriend
Messages: 53
Registered: July 2009
Member
Thanks for the reply, my current non RCP application uses an error decorator
on the tab and disables save so I was looking to do the same thing with RCP.
Now that I think about it more, I think you are correct in that having
doSave display an error message is a better way to go.

GB


"Johnny Mongiat" <johnnymongiat@gmail.com> wrote in message
news:i02up0$tam$1@build.eclipse.org...
> GB,
>
> I'm not quite sure that disabling the save command (i.e. menuitem, toolbar
> button...), yet still having the dirty decoration ("*") present is good
> usability (seems to break fundamental Eclipse UI rules). Why don't you
> just pop up some sort of error dialog message (e.g. "Invalid content" when
> a user decides to save the editor, and that editor contains invalid
> content (read the javadoc for ISaveablePart.doSave(...)):
>
> public void doSave(IProgressMonitor monitor) {
> ...
> if(content is invalid) {
> // display an error message
> // monitor.setCancelled(true);
> return;
> }
> ...
> }
>
> Otherwise, you may need to override your editor's setPartName(String
> partName) method to ensure that a "*" decoration is prepended whenever the
> underlying contents are invalid - I'm not really sure if this would work
> but you can try:
>
> protected void setPartName(String partName) {
> String name = partName;
> if(content is invalid) {
> if(!isDirty()) {// the "*" decoration will automatically be present
> if editor is dirty???
> name = "*" + partName;
> }
> }
> super.setPartName(name);
> }
>
> Thanks,
> Johnny
Previous Topic:How to make a modal Job ?
Next Topic:Visible Action set
Goto Forum:
  


Current Time: Mon Dec 06 03:27:44 GMT 2021

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

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

Back to the top