Java Event Wizard for Eclipse

The Java Event Wizard for Eclipse (v1.0.0 beta) makes adding an event to a Java class a simple point and click operation. The wizard inserts code to add and remove listeners and to fire events. It also creates an interface for listeners to implement.  All code is compliant with the JavaBean specification.

 
    Installation
 
 
  1. Open Eclipse.
  2. Select Help | Install New Software...
  3. In the "Work With" textbox, enter http://www.cogitoengineering.com/javaeventwizard
  4. Check the "Add Java Event Wizard" box.

    Install

  5. Follow prompts to complete the install, including accepting the license and selecting "Install anyway" when the unsigned content warning is displayed). 
 
 
 
    Basic Usage
 
 
  1. In a Java source code file:
    1. Right-click, select Add Java Event.



  2. In the New Event Wizard:
    1. Type in the name of an event (e.g. CountChanged).
    2. Click Finish.

  3. The following code will be added by the wizard:
    1. In the current class:
      1. A list variable to hold references to observers:

        private ArrayList<CountChangedListener> countChangedListeners = new ArrayList<>();

         
      2. Add methods to add and remove observers:

        public void addCountChangedListener( CountChangedListener listener) {
           countChangedListeners.add(listener);
        }

        public void removeCountChangedListener(CountChangedListener listener) {
           countChangedListeners.remove(listener);
        }


      3. Add a method to fire events (i.e. inform observers of the change):

        private void fireCountChanged() {
           for (CountChangedListener listener : countChangedListeners)
             listener.countChanged(new CountChangedEvent(this));
           }
        }


    2. To the package
      1. An interface called CountChangedListener with a single method called countChanged().
 
 
 
   Alternate Installation
 
 

Note: the alternate installation method circumvents Eclipse's built-in configuration management system, making updates to the Java Event Wizard more difficult (essentially requiring the developer to manually remove the old plug-in files and directories prior to installation of a new version).  For this reason, it is recommended that the standard installation procedure described above be used.  If you still want to perform a manual install, simply follow these steps:

  1. Download com.cogitoresearch.eclipse.javaeventwizard_1.0.0.jar.
  2. Copy the jar file into plugins subfolder of your eclipse folder.