Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » HowTo: EditorPages isDirty() and markDirty()
HowTo: EditorPages isDirty() and markDirty() [message #465888] Wed, 11 April 2007 10:32 Go to next message
Eclipse UserFriend
Next problem

For my UI i am following the tutorial
*http://www.eclipse.org/articles/Article-Forms/article.html* which is
quite good but not complete. The part how to use the lifecycle of a
formpage is missing. I thought I can add a ModifyListener to my
controlls and just call markDirty() but this method is only used for
ContributionManagers (as far as I found out). How can I set an editor
(with multiple pages) to a dirty state which then schould show a * in
the title of this editor

Thx
-- Marc
Re: HowTo: EditorPages isDirty() and markDirty() [message #465893 is a reply to message #465888] Wed, 11 April 2007 13:44 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bugjester.yahoo.com

You need to fire an PROP_DIRTY event from your editor whenever you
change the dirty state. Something like this:

public class MyEditor extends EditorPart
{
private boolean isDirty = false;

private void setDirty(boolean dirty) {
this.isDirty = dirty;
firePropertyChange(PROP_DIRTY);
}

public boolean isDirty() {
return this.isDirty();
}
}

Steve


Marc Schlegel wrote:
> Next problem
>
> For my UI i am following the tutorial
> *http://www.eclipse.org/articles/Article-Forms/article.html* which is
> quite good but not complete. The part how to use the lifecycle of a
> formpage is missing. I thought I can add a ModifyListener to my
> controlls and just call markDirty() but this method is only used for
> ContributionManagers (as far as I found out). How can I set an editor
> (with multiple pages) to a dirty state which then schould show a * in
> the title of this editor
>
> Thx
> -- Marc
Re: HowTo: EditorPages isDirty() and markDirty() [message #465894 is a reply to message #465893] Wed, 11 April 2007 14:22 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bugjester.yahoo.com

Woops, there is an infinite loop in there. The isDirty() method should be:

public boolean isDirty() {
return this.isDirty;
}

I should practice "pair newsgrouping" to avoid those kinds of problems.

Steve

Steve Paquin wrote:
> You need to fire an PROP_DIRTY event from your editor whenever you
> change the dirty state. Something like this:
>
> public class MyEditor extends EditorPart
> {
> private boolean isDirty = false;
>
> private void setDirty(boolean dirty) {
> this.isDirty = dirty;
> firePropertyChange(PROP_DIRTY);
> }
>
> public boolean isDirty() {
> return this.isDirty();
> }
> }
>
> Steve
>
>
> Marc Schlegel wrote:
>> Next problem
>>
>> For my UI i am following the tutorial
>> *http://www.eclipse.org/articles/Article-Forms/article.html* which is
>> quite good but not complete. The part how to use the lifecycle of a
>> formpage is missing. I thought I can add a ModifyListener to my
>> controlls and just call markDirty() but this method is only used for
>> ContributionManagers (as far as I found out). How can I set an editor
>> (with multiple pages) to a dirty state which then schould show a * in
>> the title of this editor
>>
>> Thx
>> -- Marc
Re: HowTo: EditorPages isDirty() and markDirty() [message #466006 is a reply to message #465894] Thu, 12 April 2007 05:30 Go to previous messageGo to next message
Eclipse UserFriend
Thanks for your help

I had a look at the implementation of isDirty() in FormEditor and this
one checks all FormPages if there is one dirty

public boolean isDirty() {
if (pages != null) {
for (int i = 0; i < pages.size(); i++) {
Object page = pages.get(i);
if (page instanceof IFormPage) {
IFormPage fpage = (IFormPage) page;
if (fpage.isDirty())
return true;
}
}
}
return super.isDirty();
}
so, it must be possible to set the registered FormPages to dirty...but how?

best regards
-- Marc

Steve Paquin schrieb:
> Woops, there is an infinite loop in there. The isDirty() method should be:
>
> public boolean isDirty() {
> return this.isDirty;
> }
>
> I should practice "pair newsgrouping" to avoid those kinds of problems.
>
> Steve
>
> Steve Paquin wrote:
>> You need to fire an PROP_DIRTY event from your editor whenever you
>> change the dirty state. Something like this:
>>
>> public class MyEditor extends EditorPart
>> {
>> private boolean isDirty = false;
>>
>> private void setDirty(boolean dirty) {
>> this.isDirty = dirty;
>> firePropertyChange(PROP_DIRTY);
>> }
>>
>> public boolean isDirty() {
>> return this.isDirty();
>> }
>> }
Re: HowTo: EditorPages isDirty() and markDirty() [message #466040 is a reply to message #466006] Thu, 12 April 2007 13:59 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bugjester.yahoo.com

As far as I know, each form page is responsible for managing its own
dirty state. That is why I just put a setDirty() method in each page
which can get called from a ModifyListener or other listener watching
for form element changes. That setDirty() method just sets a flag that
is returned by isDirty() and it fires the PROP_DIRTY event so the
platform knows that the dirty state has changed.


> so, it must be possible to set the registered FormPages to dirty...but how?
Re: HowTo: EditorPages isDirty() and markDirty() [message #466056 is a reply to message #466040] Thu, 12 April 2007 17:38 Go to previous messageGo to next message
Eclipse UserFriend
Thank you very much Steve, it works just fine. The only thing I am
missing is the * in front of editors title. Do I have to implement this
by my own?

Steve Paquin schrieb:
> As far as I know, each form page is responsible for managing its own
> dirty state. That is why I just put a setDirty() method in each page
> which can get called from a ModifyListener or other listener watching
> for form element changes. That setDirty() method just sets a flag that
> is returned by isDirty() and it fires the PROP_DIRTY event so the
> platform knows that the dirty state has changed.
>
>
>> so, it must be possible to set the registered FormPages to dirty...but
>> how?
Re: HowTo: EditorPages isDirty() and markDirty() [message #466058 is a reply to message #466056] Thu, 12 April 2007 19:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bugjester.yahoo.com

You shouldn't have to. For me just calling
WorkenchPart.firePropertyChange(PROP_DIRTY) causes the * to show up in
the title.

Are you using setPartName() to set the title of the editor? If you are
overriding getPartName() instead, I think you will have to implement
putting the * on there yourself. The recommended way to do it is to
call setPartName() and let the framework handle displaying whether it is
dirty or not.

Marc Schlegel wrote:
> Thank you very much Steve, it works just fine. The only thing I am
> missing is the * in front of editors title. Do I have to implement this
> by my own?
Re: HowTo: EditorPages isDirty() and markDirty() [message #466073 is a reply to message #466058] Fri, 13 April 2007 04:44 Go to previous messageGo to next message
Eclipse UserFriend
You're right, it works but the * is only shown after I selected another
editor and switch back to former one. So I have to call a refresh-method
on my editor-view in the setDirty-method somehow. Do you know how?

Thanks again
-- Marc

Steve Paquin schrieb:
> You shouldn't have to. For me just calling
> WorkenchPart.firePropertyChange(PROP_DIRTY) causes the * to show up in
> the title.
>
> Are you using setPartName() to set the title of the editor? If you are
> overriding getPartName() instead, I think you will have to implement
> putting the * on there yourself. The recommended way to do it is to
> call setPartName() and let the framework handle displaying whether it is
> dirty or not.
>
> Marc Schlegel wrote:
>> Thank you very much Steve, it works just fine. The only thing I am
>> missing is the * in front of editors title. Do I have to implement this
>> by my own?
Re: HowTo: EditorPages isDirty() and markDirty() [message #466107 is a reply to message #466073] Fri, 13 April 2007 19:48 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bugjester.yahoo.com

I've never had to do that. I just checked to make sure and as soon as I
call firePropertyChange(PROP_DIRTY), the * is added on there. Sorry I
don't have any other ideas off the top of my head.

Marc Schlegel wrote:
> You're right, it works but the * is only shown after I selected another
> editor and switch back to former one. So I have to call a refresh-method
> on my editor-view in the setDirty-method somehow. Do you know how?
Re: HowTo: EditorPages isDirty() and markDirty() [message #466117 is a reply to message #466107] Sat, 14 April 2007 05:31 Go to previous message
Eclipse UserFriend
Ok, now it is working. First I modified you version as I marked the
registered FormPages dirty which was wrong but I thought the
isDirty-implementation of FormEditor is better. If I set the dirty state
NOT in the FormPages but only in my editor its working the way it should.

Thanks for your help
-- Marc

Steve Paquin schrieb:
> I've never had to do that. I just checked to make sure and as soon as I
> call firePropertyChange(PROP_DIRTY), the * is added on there. Sorry I
> don't have any other ideas off the top of my head.
>
> Marc Schlegel wrote:
>> You're right, it works but the * is only shown after I selected another
>> editor and switch back to former one. So I have to call a refresh-method
>> on my editor-view in the setDirty-method somehow. Do you know how?
Previous Topic:RCP and SWT: how does it work
Next Topic:Help button on Macintosh laptops
Goto Forum:
  


Current Time: Wed Nov 05 23:11:45 EST 2025

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

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

Back to the top