Return-Path: Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: (qmail 13756 invoked from network); 24 Jul 2010 01:51:15 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 24 Jul 2010 01:51:15 -0000 Received: (qmail 11664 invoked by uid 500); 24 Jul 2010 01:51:15 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 11550 invoked by uid 500); 24 Jul 2010 01:51:14 -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 11542 invoked by uid 99); 24 Jul 2010 01:51:14 -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 01:51:14 +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 01:51:11 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o6O1onXd024159 for ; Sat, 24 Jul 2010 01:50:50 GMT Message-ID: <31613350.563691279936249397.JavaMail.jira@thor> Date: Fri, 23 Jul 2010 21:50:49 -0400 (EDT) From: "Henri Yandell (JIRA)" To: issues@commons.apache.org Subject: [jira] Reopened: (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 ] Henri Yandell reopened LANG-580: -------------------------------- Reopening for the additional patch to be considered. > 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.