|
Sweet Home 3D Forum » List all forums » » Forum: Developers » » » Thread: Is this a mistake in the ActionAdapter Class? » » » » Post: Is this a mistake in the ActionAdapter Class? |
Print at Dec 20, 2025, 1:35:02 PM |
| Posted by Cardinal at Jul 28, 2011, 9:33:01 AM |
|
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. |
|
|
Current timezone is GMT Dec 20, 2025, 1:35:02 PM |