Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Setting isDirty in Eclipse Form
Setting isDirty in Eclipse Form [message #441930] Mon, 09 January 2006 01:53 Go to next message
Timothy Vogel is currently offline Timothy Vogel
Messages: 71
Registered: July 2009
Member
Background
The RCP application I am working on has a multipage editor for a custom
model, i.e. not file based, implemented using FormEditor. I add separate
pages as needed for the model.

Problem
I am struggling with how to mark the editor as dirty so that save becomes
enabled.

I have hooked the text fields that display the model on the indivdual
pages with a ModifyListner. In the modify listener I check the current
FormPage using CourseForm.this.getManagedForm().isDirty(), where
CourseForm is the name of the class that extends FormPage. I thought that
I could call CourseForm.this.getManagedForm().dirtyStateChanged(); but
after tracing this does not set a dirty flag, it only gives the FormEditor
notification that it has changed.

I think I have to change the dirty flag of the ManagedForm but can't
figure out how.

Any tips, references or solutions would be greatly appreciated.

Thanks for taking the time to read my post.
Timothy Vogel
Re: Setting isDirty in Eclipse Form [message #441936 is a reply to message #441930] Mon, 09 January 2006 07:38 Go to previous messageGo to next message
Reinhard Moser is currently offline Reinhard Moser
Messages: 43
Registered: July 2009
Member
Hi Timothy,

to get a dirty state in your FormEditor you have to implement the
dirty state yourself.

boolean bDirty = false;

public boolean isDirty() {
return bDirty;
}

public void dirtyStateChanged() {
bDirty = !bDirty;
}

If a form page is set dirty, simply call dirtyStateChanged on your editor.

The other possibility is to get the dirty state of your pages and
compute the dirty state like the PDEFormEditor does:

private boolean lastDirtyState;

public boolean isDirty() {
lastDirtyState = computeDirtyState();
return lastDirtyState;
}

private boolean computeDirtyState() {
IFormPage page = getActivePageInstance();
if (page != null && page.isDirty())
return true;
return super.isDirty();
}

public boolean getLastDirtyState() {
return lastDirtyState;
}

reinhard

Timothy J Vogel schrieb:
> Background
> The RCP application I am working on has a multipage editor for a custom
> model, i.e. not file based, implemented using FormEditor. I add
> separate pages as needed for the model.
> Problem
> I am struggling with how to mark the editor as dirty so that save
> becomes enabled.
> I have hooked the text fields that display the model on the indivdual
> pages with a ModifyListner. In the modify listener I check the current
> FormPage using CourseForm.this.getManagedForm().isDirty(), where
> CourseForm is the name of the class that extends FormPage. I thought
> that I could call CourseForm.this.getManagedForm().dirtyStateChanged();
> but after tracing this does not set a dirty flag, it only gives the
> FormEditor notification that it has changed.
> I think I have to change the dirty flag of the ManagedForm but can't
> figure out how.
> Any tips, references or solutions would be greatly appreciated.
>
> Thanks for taking the time to read my post.
> Timothy Vogel
>
Re: Setting isDirty in Eclipse Form [message #441940 is a reply to message #441930] Mon, 09 January 2006 08:52 Go to previous messageGo to next message
Daniel Rohe is currently offline Daniel Rohe
Messages: 63
Registered: July 2009
Member
Timothy J Vogel schrieb:
> Background
> The RCP application I am working on has a multipage editor for a custom
> model, i.e. not file based, implemented using FormEditor. I add
> separate pages as needed for the model.
> Problem
> I am struggling with how to mark the editor as dirty so that save
> becomes enabled.
> I have hooked the text fields that display the model on the indivdual
> pages with a ModifyListner. In the modify listener I check the current
> FormPage using CourseForm.this.getManagedForm().isDirty(), where
> CourseForm is the name of the class that extends FormPage. I thought
> that I could call CourseForm.this.getManagedForm().dirtyStateChanged();
> but after tracing this does not set a dirty flag, it only gives the
> FormEditor notification that it has changed.
> I think I have to change the dirty flag of the ManagedForm but can't
> figure out how.
> Any tips, references or solutions would be greatly appreciated.
>
> Thanks for taking the time to read my post.
> Timothy Vogel
>

You are using an instance of FormEditor as your editor. This editor
contains instances of FormPage as pages. I hope that you have
specialized SectionParts (or AbstractParts) as sections in the page. In
the section you have Text widgets that display some data and have an
ModifyListener attached. In this listener call markDirty() for the
section and the ManagedForm and FormEditor will handle dirty state for
you. And don't forget to add each SectionPart to the ManagedForm by
addPart(section)!

Kind regards,
Daniel
Re: Setting isDirty in Eclipse Form [message #441951 is a reply to message #441936] Mon, 09 January 2006 13:01 Go to previous messageGo to next message
Timothy Vogel is currently offline Timothy Vogel
Messages: 71
Registered: July 2009
Member
reinhard,
Thanks for your reply!

Another reply suggests that if I use a section on the page, it has a
markDirty() method that hooks into the provided logic of the page / form.
If that doesn't work or if I need a page with no section, I will use your
suggestions.

Timothy Vogel
Re: Setting isDirty in Eclipse Form [message #441952 is a reply to message #441940] Mon, 09 January 2006 13:05 Go to previous message
Timothy Vogel is currently offline Timothy Vogel
Messages: 71
Registered: July 2009
Member
Daniel Rohe wrote:

> Timothy J Vogel schrieb:
>> Background
>> The RCP application I am working on has a multipage editor for a custom
>> model, i.e. not file based, implemented using FormEditor. I add
>> separate pages as needed for the model.
>> Problem
>> I am struggling with how to mark the editor as dirty so that save
>> becomes enabled.
>> I have hooked the text fields that display the model on the indivdual
>> pages with a ModifyListner. In the modify listener I check the current
>> FormPage using CourseForm.this.getManagedForm().isDirty(), where
>> CourseForm is the name of the class that extends FormPage. I thought
>> that I could call CourseForm.this.getManagedForm().dirtyStateChanged();
>> but after tracing this does not set a dirty flag, it only gives the
>> FormEditor notification that it has changed.
>> I think I have to change the dirty flag of the ManagedForm but can't
>> figure out how.
>> Any tips, references or solutions would be greatly appreciated.
>>
>> Thanks for taking the time to read my post.
>> Timothy Vogel
>>

> You are using an instance of FormEditor as your editor. This editor
> contains instances of FormPage as pages. I hope that you have
> specialized SectionParts (or AbstractParts) as sections in the page. In
> the section you have Text widgets that display some data and have an
> ModifyListener attached. In this listener call markDirty() for the
> section and the ManagedForm and FormEditor will handle dirty state for
> you. And don't forget to add each SectionPart to the ManagedForm by
> addPart(section)!

> Kind regards,
> Daniel

Daniel,
I was "keeping it simple" since this is my first exposure to developing a
solution in Eclipse. Right now the Text widget is the only control on the
form, I didn't put a section on the form. I will try it with a section.

Thanks for your reply!
Timothy Vogel
Previous Topic:GEF in a rcp application
Next Topic:Propose perspective change from object type
Goto Forum:
  


Current Time: Thu Oct 23 00:08:05 GMT 2014

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

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