Table of Contents
The plugin “org.csstudio.ui.menu” defines through
extensions the CSS Menu (which appears in the menu bar) and the
context sensitive pop-up submenu for object adaptable to
org.csstudio.csdata.ProcessVariable
. The plugin “org.csstudio.ui.menu”
provides examples of how to contribute actions/commands, how to implement
a view that displays the pop-up menu, and with the same view one can
test whether a popup action/commands actually displays as intended.
The overall structure of the menu is:
CSS (id: css) - Display (id: display) - Alarm (id: alarm) - Diagnostic (id: diag) - Debugging (id: debugging) - Configuration (id: configuration) - Management (id: management) - Editors (id: editors) - Utilities (id: utility) - Trends (id: trends) - Test (id: test) - Other (id: other)
where the each line has the name of each sub-menus and the “id” which is needed to define contributions to those menus. Only sub-menus that have contributions are going to be displayed
The following example adds a command to the display
sub-menu:
<plugin> ... <extension point="org.eclipse.ui.menus"> ... <menuContribution allPopups="false" locationURI="menu:display"> <command commandId="org.eclipse.ui.views.showView" icon="icons/my_icon.png" label="My View" style="push" tooltip="Show My View"> <parameter name="org.eclipse.ui.views.showView.viewId" value="org.csstudio.my_tool.MyView"> </parameter> </command> </menuContribution> </extension>
This example shows the rather common case where your menu
entry opens a View, using the command org.eclipse.ui.views.showView
that is provided by Eclipse. That command expects a command parameter
to provide the ID of the view to open.
You can of course also add new commands to the menus. In that case, you also need to define a handler for your command. Refer to the Eclipse online help on commands and handlers for details.
This popup menu (id:
org.csstudio.ui.menu.popup.processvariable
) will
appear only on objects that are adaptable to
org.csstudio.csdata.ProcessVariable
. Given that the
whole menu is hidden/displayed, one only has to contribute commands
without worrying about the display condition for each command. It
also makes it easier for the user to predict which entries he will
find in the menu and where they are located: if the “Process
Variable” sub-menu is present, then the object is of the
right type and all the same commands are going to be available in
the same order.
The following example adds a command to the popup menu:
<plugin> ... <extension point="org.eclipse.ui.menus"> ... <menuContribution allPopups="false" locationURI="popup:org.csstudio.ui.menu.popup.processvariable"> <command commandId="org.csstudio.display.waterfall.SomeCommand" icon="icons/water.png" style="push"> </command> </menuContribution> ... </extension> ... </plugin>
To handle the received PV names in a command handler, see Chapter 27, Common SWT/JFace utilities - org.csstudio.ui.util
The following example adds an action to the popup menu
(note the contribution to the main
section):
<plugin> ... <extension point="org.eclipse.ui.popupMenus"> ... <objectContribution adaptable="true" id="org.csstudio.ui.menu.test.objectContribution1" objectClass="org.csstudio.csdata.ProcessVariable"> <action class="org.csstudio.ui.menu.test.TestPVAction" icon="icons/test.png" id="org.csstudio.ui.menu.test.testpvaction" label="Test Action" menubarPath= "org.csstudio.ui.menu.popup.processvariable/main"> </action> </objectContribution> ... </extension> ... </plugin>