Menu, Toolbar and Popup actions - <Mapping to command class>

From: Abraham Khalil (akhalil_at_pacific.net.au)
Date: 10/04/03


Date: 3 Oct 2003 22:30:24 -0700

With all the Menu items, toolbar items and popup items that can total to
about 50-75 choices in a gui design, what the 'easiest' way to map the
action names with the class to call.

Like to use the Command design pattern to do this generically:
Somehow get the "action string" and map it to a "command class".

Is this possible with Command, Reflection etc?
Somehow:

Command c = new <ReflectCallCommandClass> ();
c.execute();

How do the reflection part? More important if their is a better way
than this...

public interface Command {
   public void execute();
}

public class MyCommandClass1 extends Command {
   public void execute() {
      // code for action 1,
      // could be from Menu, Toolbar, popups doesn't matter...
   }
}



Relevant Pages