Return-Path: Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: (qmail 71212 invoked from network); 24 Jul 2010 12:51:23 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 24 Jul 2010 12:51:23 -0000 Received: (qmail 63239 invoked by uid 500); 24 Jul 2010 12:51:22 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 62944 invoked by uid 500); 24 Jul 2010 12:51:19 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 62936 invoked by uid 99); 24 Jul 2010 12:51:18 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 24 Jul 2010 12:51:18 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 24 Jul 2010 12:51:15 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o6OCorKB027864 for ; Sat, 24 Jul 2010 12:50:54 GMT Message-ID: <28593652.567571279975853282.JavaMail.jira@thor> Date: Sat, 24 Jul 2010 08:50:53 -0400 (EDT) From: "James Carman (JIRA)" To: issues@commons.apache.org Subject: [jira] Resolved: (LANG-580) Add Event Support Utilities In-Reply-To: <868938532.23371262624754653.JavaMail.jira@brutus.apache.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/LANG-580?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] James Carman resolved LANG-580. ------------------------------- Resolution: Fixed Patch applied, SVN revision 978864 > Add Event Support Utilities > --------------------------- > > Key: LANG-580 > URL: https://issues.apache.org/jira/browse/LANG-580 > Project: Commons Lang > Issue Type: New Feature > Components: General > Affects Versions: 3.0 > Environment: Java SE 5.0+ > Reporter: Michael Wooten > Assignee: James Carman > Priority: Minor > Fix For: 3.0 > > Attachments: commons-lang-event-support-docs.patch, commons-lang-event-support.patch, commons-lang-events-merged.patch, commons-lang-events-package-html.txt > > Original Estimate: 96h > Remaining Estimate: 96h > > I would like to propose some support be added to Lang for basic event handling. This would be based on the way that PropertyChangeSupport can be used to add and remove listeners and post events. > Add interface EventSupport > addListener(L listener) > The signature for the method that can add a listener of some subtype of EventListener > removeListener(L listener) > The signature for the method that can remove a listener of some subtype of EventListener > Add class AbstractEventSupport implements EventSupport, Iterable > AbstractEventSupport(Object eventSource) > Constructs a new AbstractEventSupport object and associates it with the object that will be used as the source of all events (much like PropertyChangeSupport). > addListener(L) > An implementation that adds a listener to an internal collection. > removeListener(L) > An implementation that removes a listener from an internal collection. > iterator() > Returns an iterator over the attached listeners. > getSource() > Returns a reference to the source object of all events. > The best way to describe this would be to demonstrate an example of how it can be used. > public class ButtonPressedEventSupport extends AbstractEventSupport { > public ButtonPressedEventSupport(Object source) { super(source); } > public void fireButtonPressed(Button button) { > ButtonPressedEvent bpe = new ButtonPressedEvent(getSource(), button); > for (ButtonPressedListener listener : this) > { > listener.buttonPressed(bpe); > } > } > } > public class MyWindow implements EventSupport { > private final ButtonPressedEventSupport buttonPressedEventSupport; > public MyWindow { buttonPressedEventSupport = new ButtonPressedEventSupport(this); } > public void addListener(ButtonPressedListener listener) { buttonPressedEventSupport.addListener(listener); } > public void removeListener(ButtonPressedListener listener) { buttonPressedEventSupport.removeListener(listener); } > ... > private void onDetectButtonPressed(Button button) { > buttonPressedEventSupport.fireButtonPressed(button); > } > } > I haven't compiled the above code. It's just an example of how these classes could be used so that you're not constantly rewriting the code and interfaces for adding and removing listeners, and it provides a fairly easy method of creating methods to fire events. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.