• Post Reply Bookmark Topic Watch Topic
  • New Topic

monitor changes - log only the actions.  RSS feed

 
Peter Primrose
Ranch Hand
Posts: 755
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Consider a GUI with 10 (or more) elements: JTextField, JRadioBox, JCheckBox, JComboBox...

the end user is looking at the GUI and make some changes. Example: he check the checkbox that says Emply Sign or select a different item on a comobBox.

Say, I wish to create a log that monitors only the *changes*. So if in the example above the user has performed 2 actions - only those action will be logged (they will not be logged next time)

What is the best way to do that?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37462
537
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peter,
You could set up event handlers to intercept the event when it occurs. This would log every time the user does something though.

If a user types selects a checkbox and immediately unselects it, do you want to log that once, twice or not at all?
 
Peter Primrose
Ranch Hand
Posts: 755
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hן Jeanne,
thanks for your reply.

"If a user types selects a checkbox and immediately unselects it, do you want to log that once, twice or not at all?"

well, if he pressed save - I count the changes otherwise not, so in your example the answer is 'not at all'.

I'm not sure I understand the solution you offer with 'event handlers' I mean if the user clicks SAVE - log the event (again, log only the changes)
thanks again
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37462
537
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peter,
The solution I offered above was for if you wanted to log everything that happened even if the user rolled it back before pressing save. So in my example, it would have logged the data twice.

What you are looking for is something like audit logging the changes when the user saves the record. The way to do this is store a master copy of the data. It can be in memory or wherever you got the original record from (file, database, etc.) Then when the user presses save, you compare the original values with the current values.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!