Toolbar Contributions
Toolbar Contributions
Abstract
As of URCap API version 1.4, support for URCap toolbar contributions with a Swing-
based user interface is introduced for version 5.0.0 of PolyScope. This document will de-
scribe how to contribute a toolbar view to the toolbar in PolyScope for a URCap.
Contents
1 Introduction 3
1 Introduction
This document describes the purpose of URCap toolbar contributions in PolyScope and how to
work with them through the URCap API.
Multiple URCaps from different providers can be installed on the robot at the same time and
the toolbar functionality will allow URCaps to provide toolbar panels that will coexists with
panels from other URCaps.
The individual panels are Swing JPanels and PolyScope provides functionality to bind these
panels together and make them available via a toolbar of contributed URCap panels.
• void buildUI(JPanel): Called once at start up. The UI is built on the provided JPanel. List-
ing 1 shows how Swing GUI components are added to the JPanel to form the contribution.
The provided panel will have a Swing UI manager already set, meaning that components
without additional styling will look as native PolyScope ones including the correct font
types. In order to resemble PolyScope the components should therefore only use limited
styling, such as font sizes or component sizes (if the applied ones are not suitable). Note:
PolyScope will restrict the given JPanel in some ways to prevent a URCap from breaking
the PolyScope UI and help the URCap provider to align with PolyScope UI styling.
• void openView(): Called each time the user selects this URCap toolbar contribution in the
toolbar
• void closeView(): Called each time the user exits this URCap toolbar contribution in the
toolbar
68 pane2 . setText ( " < HTML > Currently , the robot is configured to use the Locale :
" + locale . ge tDisplay Name () + " </ HTML > " ) ;
69 infoBox . add ( pane2 ) ;
70
71 demo ToolStat us = new JLabel () ;
72 demo ToolStat us . setText ( " < HTML > " + g e t 3 r d P a r t y S t a t u s () + " </ HTML > " ) ;
73 demo ToolStat us . setBorder ( BorderFactory . c r e a t e E m p t y B o r d e r (5 , 5 , 5 , 5) ) ;
74 infoBox . add ( demoToo lStatus ) ;
75 return infoBox ;
76 }
77
78 private Component c r e a t e V e r t i c a l S p a c e () {
79 return Box . c re a te Ri gi d Ar ea ( new Dimension (0 , V ERTICAL _SPACE ) ) ;
80 }
81
82 private String g e t 3 r d P a r t y S t a t u s () {
83 Date now = new Date () ;
84 int number = new Random () . nextInt (10) + 20;
85 return String . format ( " Tool status reading : %d , read at % tF % tT . " , number ,
now , now ) ;
86 }
87 }
• Icon getIcon(): Returns the icon for visual identification of the contributed panel in the
toolbar
• void configureContribution(ToolbarConfiguration): Use the argument supplied to configure
the contribution. The configuration will already have default values for its properties (see
default values in the Javadoc). If the default values are appropriate, leave this method
empty. The values of the ToolbarConfiguration will be read once immediately after this
method call.
• SwingToolbarContribution createToolbar(ToolbarContext): Creates a new toolbar contribution
instance. The ToolbarContext object gives access to services and APIs provided by PolyScope
relevant to the toolbar contribution.
When enabled, the provided toolbar panels will be accessible via a tabbed toolbar panel over-
laying the right hand side of PolyScope.
Pressing the icon identifying the individual toolbar in the tabbed panel will display the con-
tributed toolbar panel. Figure 2 shows a toolbar with multiple toolbar contributions.
Like the content of the toolbar panel, the icons used to identify the panels in the toolbar should
conform to the Universal Robots style guide. The icons are restricted to a width of 89px and a
height of 30px.