Index  | Recent Threads  | List Attachments  | Search
 Welcome Guest  |  Register  |  Login
Login Name  Password
 

Sweet Home 3D Forum



No member browsing this thread
Thread Status: Active
Total posts in this thread: 6
[ Jump to Last Post ]
Post new Thread
Author
Previous Thread This topic has been viewed 3261 times and has 5 replies Next Thread
Cardinal
Member




Joined: Jul 4, 2011
Post Count: 22
Status: Offline
Reply to this Post  Reply with Quote 
Is this a mistake in the ActionAdapter Class?

Hi Emmanuel,

For the plugin I'm writing I'd like the plugin's icon in the Toolbar to stay "toggled" when the user clicks it (like the standard drawing modes, selection and panning). But the PluginAction is wrapped in an ActionAdapter instance and has no knowledge of the button it's assigned to so it can't access it's ButtonModel.

So I tried another approach: have the icon change it's image when it's clicked to make it look like setSelected(true) was called in the ButtonModel.

Now the ActionAdapter Class registers itself as a listener for the PluginAction Class and propagates it's changes. Before this happens, you're translating the PluginAction properties so that they match the keys for the Action class, like so :

if (PluginAction.Property.NAME.name().equals(propertyName))
propertyChangeSupport.firePropertyChange(new PropertyChangeEvent(ev.getSource(),
Action.NAME, oldValue, newValue));

you're also putting this code in a if statement that makes sure the event is fired only when the new value for the property is not null.
However, this is how this new value is obtained:

String propertyName = ev.getPropertyName();
Object newValue = getValue(propertyName);

Here, the getValue() method is expecting a Key for a property from Action, but it's recieving one from PluginAction, wich means the output is always null because none of the if statements is going to eval to true. eg:

if("NAME".equals("Name")) // false

So I think either the keys in PluginAction should be made to match those of the Action Class, or they should be translated before being passed to getValue().

Please correct me if I'm wrong. Thanks in advance.
[Jul 28, 2011, 9:33:01 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Puybaret
Expert
Member's Avatar

France
Joined: Nov 7, 2005
Post Count: 9426
Status: Offline
Reply to this Post  Reply with Quote 
Re: Is this a mistake in the ActionAdapter Class?

Thanks for finding out this bug. smile
I fixed it by simply retrieving property value with ev.getNewValue().
As I just released version 3.3, this correction won't be released in a close future but I committed it in CVS. If you need it, you'll have to work on the current version of the source code.
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator
[Jul 28, 2011, 11:08:57 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Cardinal
Member




Joined: Jul 4, 2011
Post Count: 22
Status: Offline
Reply to this Post  Reply with Quote 
Re: Is this a mistake in the ActionAdapter Class?

No problem smile
I'll make this modification for the current version and building against it, assuming it'll be there in future versions smile
[Jul 28, 2011, 1:02:42 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Cardinal
Member




Joined: Jul 4, 2011
Post Count: 22
Status: Offline
Reply to this Post  Reply with Quote 
Re: Is this a mistake in the ActionAdapter Class?

Emmanuel, I was able to do what I wanted but the result wasn't extremely satisfaying because all what i can do is surround the icon with a rectangle, however the other buttons in the Toolbar have the bounds of their button surrounded with a rectangle not the icon. So there's a small difference in the size sad If you have a workround for this I'd love to hear from you! Thanks!
[Jul 28, 2011, 2:04:47 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Puybaret
Expert
Member's Avatar

France
Joined: Nov 7, 2005
Post Count: 9426
Status: Offline
Reply to this Post  Reply with Quote 
Re: Is this a mistake in the ActionAdapter Class?

Instead of trying to show the same icon as selected, I would show a different icon, like for example the locked / unlocked icon used at the top left corner of the plan.
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator
[Jul 29, 2011, 1:25:01 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Cardinal
Member




Joined: Jul 4, 2011
Post Count: 22
Status: Offline
Reply to this Post  Reply with Quote 
Re: Is this a mistake in the ActionAdapter Class?

This could be a nice alternative indeed. Thanks!
[Jul 31, 2011, 7:18:56 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
[ Jump to Last Post ]
Show Printable Version of Thread  Post new Thread

  Get Sweet Home 3D at SourceForge.net. Fast, secure and Free Open Source software downloads  
© Copyright 2024 Space Mushrooms - All rights reserved