I've started working on the UIService. Initially it will provide some methods allowing to add plugin components in the UI. But even for such an apparently simple task some questions arose.
A brief introduction to the current implementation:
We have plugin components - like buttons, menu items, etc., let's call them plugins for short. They could be added at any place (container) of the UI that could host a plugin. Each "place" is identified by a String - a Constraint.
- The available constraints could be obtained via getSupportedConstraints().
- A new plugin could be added via addComponent(Object component, String conctraint).
All plugins are stored and no events are fired upon plugin addition. Each time a container is initialized, it takes all plugins added with its constraint and shows them.
In the current GUI implementation we could differentiate two types of containers that can accept plugins:
- ones that are placed in the main program window
- ones that are placed in other windows (chat window, ...).
We make this difference because:
- the chat window is initialized when a user clicks on a contact. At this time it'll obtain and show all plugins that were registered for its constraint.
- the main program window is initialized when the UIService is started. Thus it should be somehow notified and refreshed when a plugin is added.
This poses some problems. I could make a listener that would be added to all containers wanting to be notified when a plugin is added. When notified they could use revalidate() to refresh the interface. But I'm not so sure that this would work properly and what would be the case with other UI implementations (using frameworks other than swing).
Another idea is to have all plugins added before the initialization of the GUI. In order to achieve this we could split the ui bundle into two bundles:
- a very simple bundle exporting UIPluginService, which would only provide getSupportedConstraints and addComponent (making it essentially a kind of "map"). It would be started before all other services (right after the ConfigurationService).
- the bundle providing the actual GUI - which would be started last.
What do you think? Any other suggestions?