History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: FKS-6
Type: Improvement Improvement
Status: In Progress In Progress
Priority: Minor Minor
Assignee: Vivek Prahlad
Reporter: Chris Blackburn
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Frankenstein

Should the ButtonClickRecorder be using instanceof JToggleButton?

Created: 19/Nov/07 06:14 PM   Updated: 22/Nov/07 06:31 AM
Component/s: Recorder
Affects Version/s: None
Fix Version/s: None

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown
File Attachments: 1. Text File JToggleButton.patch (0.7 kb)

Environment: Using Frankenstein source downloaded on 11/16/2007


 Description  « Hide
Is there a reason why the ButtonClickRecorder is not using instanceof JToggleButton instead of the current matching of class JToggleButton.class?
We have some custom components that extent JToggleButton and they do not get picked up by the recorder currently.

 All   Comments   Work Log   Change History      Sort Order:
Chris Blackburn - 19/Nov/07 06:16 PM
I have attached the patch I used to put in the instanceof JToggleButton. Pretty straight forward.

Vivek Prahlad - 22/Nov/07 06:29 AM
Chris,

The reason why there's no instanceof check is because both JCheckbox and JRadiobutton extend from JToggleButton. With the instanceof check, two events would get recorded for clicks on checkboxes and radio buttons: one from the ButtonClickRecorder, and the other from either the CheckBox or RadioButton recorders. Another way of solving this problem would be create a custom recorder and register it with FrankensteinIntegration:

public class YourButtonClickRecorder extends AbstractComponentRecorder implements ActionListener {

    public YourButtonClickRecorder(EventRecorder recorder, NamingStrategy namingStrategy) {
        super(recorder, namingStrategy, YourCustomButton.class);
    }

    void componentShown(Component component) {
        button(component).addActionListener(this);
    }

    private YourCustomButton button(Component event) {
        return (YourCustomButton) event;
    }

    void componentHidden(Component component) {
        button(component).removeActionListener(this);
    }

    public void actionPerformed(ActionEvent e) {
        YourCustomButton button = button(e);
        recorder.record(new YourButtonEvent(componentName(button), new ClickAction()));
    }
}