Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Best way to track modified state in SWT app
Best way to track modified state in SWT app [message #446379] Wed, 24 November 2004 02:28 Go to next message
Eclipse UserFriend
Originally posted by: martin_hulth.hotmail.com

I have a SWT based app (an electronic notebook/journal of sorts) that
includes several Text boxes, List boxes, Combo boxes and Tables. The
user can interact with the app in several ways including by typing in
the fields, dragging and dropping, ftp-like file-moving list boxes, and
more.

For saving purposes, I need to do the typical tracking of a global
"modifyFlag" that gets turned as soon as the user changes any field.
Ideally, I would like it if I would only need to add a modifiedListener
to a parent container, which listens to all children, grandchildren,
etc. I have not found a way to do this, and the only way I have that
works (but has it's own problems) is listed below.

Since several of the SWT classes cannot be subclassed, I can wrap all of
them in my own version of the class that automatically adds a
modifiedListener to the SWT member of the class. This works, but
everytime I need a new SWT object, I need to create a new wrapper for
it. And the user will also be able to add new widgets, so I would have
to wrap every possible widget the user may use.

Is this the best way to do it, or is there a much more elegant solution?

Thank you for any ideas, answers and comments

-Martin
Re: Best way to track modified state in SWT app [message #446473 is a reply to message #446379] Thu, 25 November 2004 15:18 Go to previous message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
Adding the listener to each text widget is the right thing to do. Another
approach is to investigate Display.addFilter() but this might be overkill.

"Martin Hulth" <martin_hulth@hotmail.com> wrote in message
news:co0rkt$o41$1@www.eclipse.org...
> I have a SWT based app (an electronic notebook/journal of sorts) that
> includes several Text boxes, List boxes, Combo boxes and Tables. The
> user can interact with the app in several ways including by typing in
> the fields, dragging and dropping, ftp-like file-moving list boxes, and
> more.
>
> For saving purposes, I need to do the typical tracking of a global
> "modifyFlag" that gets turned as soon as the user changes any field.
> Ideally, I would like it if I would only need to add a modifiedListener
> to a parent container, which listens to all children, grandchildren,
> etc. I have not found a way to do this, and the only way I have that
> works (but has it's own problems) is listed below.
>
> Since several of the SWT classes cannot be subclassed, I can wrap all of
> them in my own version of the class that automatically adds a
> modifiedListener to the SWT member of the class. This works, but
> everytime I need a new SWT object, I need to create a new wrapper for
> it. And the user will also be able to add new widgets, so I would have
> to wrap every possible widget the user may use.
>
> Is this the best way to do it, or is there a much more elegant solution?
>
> Thank you for any ideas, answers and comments
>
> -Martin
Previous Topic:Problem with javascript prompt dialogs and SWT browser widget on linux
Next Topic:Toolbar Problem.
Goto Forum:
  


Current Time: Fri Mar 29 11:15:59 GMT 2024

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

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

Back to the top