MIRA
|
This tutorial shows how to create a View for MIRA's Rich Client Platform. The view can e.g. be used within the miracenter. When we are finished, our view will show a message informing the user if the currently selected workbench part supports properties.
The full working example (source code, makefile) can be found in gui/examples/PropertyInfoView
.
First we will create our view class. We can do that using the mirawizard, or manually by deriving a class from mira::ViewPart:
In order to compile our new view, we need to provide a CMakeLists file.
Afterwards, we can add it to the workbench of miracenter via "Windows->Add view". For many views, this will be sufficient and the rest of the development will be Qt-GUI related.
However, in this example we want to show our content depending on what other view or window is selected. Hence, we need to react whenever the user activates or deactivates another window within the workbench.
To get informed whenever the active/selected workbench part changes, we can implement the mira::IPartListener interface:
In the createPartControl() method, our class is registered as a part listener and will get informed whenever a view part or an editor part is activated or closed.
What we need to do now is to check if the selected workbench part supports properties. The interaction of workbench parts is done via adapters. Parts supporting properties will be able to provide the property adapter in their getAdapter() method. The method takes the class of the desired adapter as parameter and will return a pointer to that adapter, if supported:
If we add our view to the MIRACenter workbench and click on a workbench part that has the property adapter implemented, we should see our "supports" message.