Need help in design
Posted on 2002-05-24
I am designing a GUI part of an application.
-We know how the GUI screens should look like and how many screens are there etc.
- Each screen will have a MenuBar, ToolBar
and the rest of the screen(call it workarea) will have the portion divided into 3 panels. (left side, right side and bottom)
- Right side there can be some GUI components displayed and this data can keep changing depending on the navigation on left side(tree)
- What I am trying to do is provide a framework for GUi so that the developers have to plug in their individual screens in the workarea.
- As part of framework, I want to provide MenuBar, ToolBar functionality.
- Depending on what is clicked on MenuBar, the corresponding screen should get loaded
- Tool Bar has other functionality like print, save etc
- ToolBar, MenuBar do not share any functionality(Both are different and described in above two points)
The problem I have now is that :
How do I have an elegent solution for my Menubar and Tool bar listeners.
- I do not want to have if else kind of code which checks if this is clicked, do this etc.
So can I have some kind of elegent solution for this?
I am thinking that I can achieve this if I keep a map of the option pressed and the command that needs to take place.
For e.g., if save is pressed, I have a mapping for this in some hash table like :
SaveCmd class would have implemented execute() method
(Yes, I am talking of command pattern)
so I call execute() on SaveCmd.
is this the right approach?
Please send me your response.