0% found this document useful (0 votes)
10 views209 pages

AMP Studio Developer Version4.0

Uploaded by

gustavo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views209 pages

AMP Studio Developer Version4.0

Uploaded by

gustavo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 209

Developer Guide

ANTENNA MOBILITY PLATFORM

AMP™ Studio
Version 4.0
ANTENNA PROPRIETARY & CONFIDENTIAL

Contents

AMP™ Studio Developer Guide 9


Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Identifying Components of AMP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Identifying Reference Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Additional AMP Studio Documents. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Generic Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Windows Mobile Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
BlackBerry Requirements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
iPhone and iPad Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Android Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Pre-installation Requirements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Installing the Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Installation Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Using AMP Studio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Eclipse Toolbar. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Creating Data Projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Adding Data Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Viewing AMP Studio Explorer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Creating UI Projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Adding Styles, Screens, Panels and Folders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Choosing Device Compatibility. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Windows Mobile Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
BlackBerry Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
iPhone Setup. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Android Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Server Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Application Startup Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Multi-Lingual Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Strings Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Server Settings Screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Application Development. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Code Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

AMP™ Studio Developer Guide 1


ANTENNA PROPRIETARY & CONFIDENTIAL Contents

BlackBerry Simulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
iPhone Simulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Windows Mobile Simulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Android Simulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Hello World Application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Creating a UI Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Data Project Using VRPC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
VDSC Data Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Data Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Sorting. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Unique Keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Counting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Query Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Link Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Virtual Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
TimestampField . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Converting a String to an Integer for Sorting Purposes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
VRPC Data Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Data Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
VRPC sample code snippet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
UI Projects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
UI Project mScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Strings Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Images Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Colors Editor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Sound Effects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
Styles. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
Services and Managers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Log . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
PhoneManager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
MessagingManager. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Message Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Reference to a Data Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
Screens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
Creating a Screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79

AMP™ Studio Developer Guide 2


ANTENNA PROPRIETARY & CONFIDENTIAL Contents

Setting a Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
Message Box. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
Panels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
HorizontalPanel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
VerticalPanel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
FormPanel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
BorderPanel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
TablePanel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
GridPanel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
TabbedPanel. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
StackPanel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
SectionedPanel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
CalendarPanel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Panel Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Reusing Panels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
Folders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
Models. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
Text Format Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
Table Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
BarChart Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
PieChart Model. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
Choice Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
Multi Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
Text Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
TimeStamp Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
TimestampFormat Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Time Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
TimeFormat Model. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
NumberFormat Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Date Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
DateFormat Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
Setting Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
Application Callbacks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
On Close. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
UI Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
Bar Chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
Pie Chart. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110

AMP™ Studio Developer Guide 3


ANTENNA PROPRIETARY & CONFIDENTIAL Contents

Button. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
CheckBox. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
Choice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
Combo Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
Date Box. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
Label. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
Link . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
Ticker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
PasswordField . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
TextField . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
E-mailField. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
NumericField . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
PinpadField . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
InteractiveImageField . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
Picture Box. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
Progress Bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
Separator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
Rich Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
Sticky Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
Sticky Table (Grouped) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
Text Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Text Area . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
ToolBar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
RadioGroup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
Browser/HTML Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
Title Bar Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
Map Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
Animated Image Control (Customizable Animation) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
Horizontal Page Swipe Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
Video Player. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
Document Viewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
Callbacks for UI Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
Add Visual Style. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
On Click . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
On Focus Gained . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
On Focus Lost . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
On Value Change . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
Data Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156

AMP™ Studio Developer Guide 4


ANTENNA PROPRIETARY & CONFIDENTIAL Contents

Get Value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157


Row Changed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
Panel Callbacks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
On Activate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
On DeActivate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
On Open . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
On Close. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
On Create . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
On Selection Changed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
On Orientation Change . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
Messaging Callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
Phone Callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
Login Callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
On LoggedIn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
On LoggedOut . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
On Login Completed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
On Login Failed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
On Login Starting. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
Data Store Callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
Mobile Web Service Callbacks (VRPC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
On Request Sent. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
On Request Failed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
On Data Ready . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
Message Service Callbacks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
On Server Available. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
On Server Recovering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
On Server Unavailable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
On Server Starting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
On Server Request Attempted . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
On Server Request Failed. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
UI Project Callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
On Start . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
On Stop. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
On Day Change . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
Application Upgrades . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
Version Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
mScript Basics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169

AMP™ Studio Developer Guide 5


ANTENNA PROPRIETARY & CONFIDENTIAL Contents

Single line comment. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169


Multiline comment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
Primitive Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
Numeric Primitive Data Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
Operations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
Basic Numeric Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
Assignment Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
Compound Assignment Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
Bitwise Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
Relational Operators. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
Conditional Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
if . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
switch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
?:. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
Block and Scope. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
while. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
do-while . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
break. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
continue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
new . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
Object Fields and Methods. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
Object Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
Static Fields and Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
Factories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
Polymorphism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
Callbacks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
mscript File Structure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
Code Reuse in mScript. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
Best Practices for Error Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
Login. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191

AMP™ Studio Developer Guide 6


ANTENNA PROPRIETARY & CONFIDENTIAL Contents

VRPC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
AMP Studio Debugging Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
Eclipse.ini File Troubleshooting. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
AMP Studio Frequently Asked Questions (FAQs) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
Coding Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
Class Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
Variable Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
Method Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
Indentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
Spaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
One Liners . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203

AMP™ Studio Developer Guide 7


ANTENNA PROPRIETARY & CONFIDENTIAL Contents

AMP™ Studio Developer Guide 8


ANTENNA PROPRIETARY & CONFIDENTIAL

AMP™ Studio Developer Guide

Introduction
Antenna is the leader in mobility solutions for the enterprise. We extend run-the-business data, processes, and applications
in real-time to any mobile device over any network, worldwide. Combining mobile solution software applications, and an
integrated development environment, Antenna Mobility Platform (AMP™) solutions are straightforward to implement
and simple to manage and use.

AMP Studio is an open source Eclipse-based IDE used to develop mobile applications. With AMP Studio, you can create
one application for multiple devices and generate code for multiple devices (currently Windows Mobile, BlackBerry,
Android, iPhone, and iPad). AMP Studio includes Eclipse-based backend integration tools for Web Services and database
access. The AMP Studio scripting language, mScript, allows the programmer to create rich UI applications, define
business logic, access the local data store, and communicate with backend Web Services.

Major functions include:

■ Abstraction from device-specific API’s


■ Built-in layout managers
■ Rich library of controls
■ Charting engine
■ Screen real estate management
■ Touch event handling
■ Support for PIM, Phone, GPS, SMS, and Camera integration
■ Multi-lingual support

AMP Studio serves to create applications that can be installed on various devices without the need to adjust code for each
device. After an application is created, AMP Studio generates code for target platforms. For example, the same
application can be converted to Android Java, BlackBerry Java, iPhone Objective C, and .NET to be compiled for
different platforms. The AMP Studio application consists of a data project and a UI project. A data project defines data to
work with and a UI project defines the UI of the application.

A connector connects the AMP Server to the customer backend (e.g. Web Services or a database). It defines what data
objects the application can use. A data object is similar to a table in a database and has fields.

The guide is designed for Application Developers and IT consultants who will develop applications using AMP Studio.

AMP™ Studio Developer Guide 9


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Identifying Components of AMP


The AMP suite of software tools is comprised of components for development, deployment, and monitoring of mobile
applications.

The Antenna Mobility PlatformTM (AMP) provides a wireless business solution with easy to assemble mobile
application components that connect quickly and efficiently to your existing business. It is an event-driven, Service-
Oriented Architecture (SOA) platform that sustains the core principles of dynamic Information Technology, thus
delivering business process rich applications for the mobile workforce.

The AMP suite of tools enables you to integrate the Antenna Mobility Platform within your organization's existing
infrastructure, to organize and manage the flow of information for your workforce.

The following is a brief outline of each component.

■ AMP™ Mobile Application: AMP Mobile Applications are run-able configurations of developer built projects,
natively compiled for Windows® Mobile®, RIM BlackBerry®, Android®, iPhone® and/or iPad® platforms.
■ AMP™ Studio: AMP Studio is a powerful development environment used to build wireless applications. Built
using the Eclipse platform, it enables developers to create and simulate applications for BlackBerry, Android,
iPhone, iPad, Windows Mobile Professional, and Windows Mobile Standard devices.
■ AMP™ Server: Provides connectivity to the back-end enterprise systems. It manages the connectivity of the
user device and the server.

Identifying Reference Documents


For more information on Antenna Mobility Platform, you can refer to the following manuals.

■ AMP Installation Guide for Standard Edition (SE): This guide describes the minimum system requirements,
prerequisites and step-by-step instructions for installing AMP™ Server Standard Edition (SE). The Standard
Edition consists of a single server instance that supports both Authentication and Application data access
functions in a single Java process. The Cluster Coordinator is not installed and there is no replication of user
state.
■ AMP Installation Guide for Enterprise Edition (EE): This guide describes the minimum system requirements,
prerequisites and step-by-step instructions for installing AMP™ Server Enterprise Edition (EE). Enterprise
Edition is a high availability set-up with no single point of failure. This set-up requires minimum of two AMP
Servers with a load balancer front-end. It also requires two independent machines to host cluster coordinators
(the Terracotta engine). The load balancer is used to direct mobile device traffic to one of the AMP servers in the
cluster.
■ AMP Installation Guide for Advanced Edition (AE): This guide describes the minimum system requirements,
prerequisites and step-by-step instructions for installing AMP™ Server Advanced Edition (AE). AMP Server
Advanced Edition is comprised of multiple AMP Servers behind a Load Balancer connected to an AMP
Database and a back-end application server. Advanced Edition supports multiple clusters in which each cluster
can support a different set of applications. New applications can either be deployed by adding them to all servers
in an existing cluster or by creating a new cluster for this application.
■ AMP Configuration Guide: This guide describes steps for configuring various types of AMP Servers.
■ AMP Planning Guide: This guide describes AMP Server components, configurations, AMP database,
application management, and procedures for disaster recovery planning.

AMP™ Studio Developer Guide 10


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

■ AMP Administration Guide: This guide describes the logs, configuration files, tables and statistics used for
proper monitoring and maintenance of AMP Server High Availability (HA).

Additional AMP Studio Documents


The following is a list of additional documents that describe other AMP Studio tools.

■ Web Services Connector Designer Guide: This document describes how to design a Web Services connector
within Eclipse.
■ Database Connector Designer Guide: This document describes how to design a Web Services connector within
Eclipse.
■ Composite Connector Designer Guide: This document describes how to build a Composite Connector using
existing pre-built connectors.

Prerequisites
This section describes the system requirements needed to install AMP Studio.

Generic Requirements
The following are the generic requirements:

■ A carrier data plan or wireless networking for each device. Unlimited data plans are recommended but may not
be available everywhere.
■ Approximately 5 MB of free device memory to install the AMP SmartClient application and 10-15 MB of excess
space to download data. This number depends upon the amount of data you may need to download. Note that
more memory may be required depending on the implementation specific data requirements.
■ A WinZip® program on the user’s PC may be required if you install the AMP SmartClient application via
Microsoft ActiveSync.

Windows Mobile Requirements


The following requirements are for the Windows Mobile device:

■ Windows Mobile version 5.0 or higher


■ Microsoft ActiveSync application on the user's PC may be required on your Windows computer in order to
install the executable onto the device. It is not required if the AMP SmartClient application is installed Over-the-
Air (OTA).

AMP™ Studio Developer Guide 11


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

BlackBerry Requirements
The following requirements are for the BlackBerry device:

■ BlackBerry JDE 4.2.1 or higher

iPhone and iPad Requirements


The following are requirements for the iPhone or iPad device:

■ iPhone version iOS 3.2 or iPhone version OS 4.0 or higher

Android Requirements
In order to develop for Android devices, the Android SDK and Android Development Tools (ADT) Eclipse plugin must
be installed and configured using the following steps:

■ Install the latest version of the Android SDK.


— Android SDK installation instructions can be found at http://developer.android.com/sdk/installing.html and
are excerpted below for your convenience.
— Get the latest version of the SDK starter package at http://developer.android.com/sdk/index.html
— If you downloaded a .zip or .tgz package (instead of the SDK installer), unpack it to a safe location on your
machine. By default, the SDK files are unpacked into a directory named android-sdk-<machine-
platform>.
— If you downloaded the Windows installer (.exe file), run it now and it will check whether the proper Java SE
Development Kit (JDK) is installed (installing it, if necessary), then install the SDK Tools into a default
location (which you can modify).
— Make a note of the name and location of the SDK directory on your system-you will need to refer to the
SDK directory later, when setting up the ADT plugin and when using the SDK tools from command line.
■ Install the latest version of the Android Development Tools (ADT) Eclipse plugin.
— ADT installation requires an active Internet connection since it will download its prerequisites from the
Internet.
— ADT installation may take some time to complete, especially over a slow Internet connection.
— Please ensure that ADT has successfully installed before installing AMP Studio.
— ADT installation instructions can be found at http://developer.android.com/sdk/eclipse-adt.html and are
excerpted below for your convenience.

1 Start Eclipse, then select Help > Install New Software....

2 Click Add in the top-right corner.

3 In the Add Repository dialog that appears, enter "ADT Plugin" for the Name and the following URL for
the Location:

AMP™ Studio Developer Guide 12


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

https://dl-ssl.google.com/android/eclipse/

NOTE: If you have trouble acquiring the plugin, try using "http" in the Location URL, instead
of "https" (https is preferred for security reasons).

Click OK.

4 In the Available Software dialog, select the check box next to Developer Tools and click Next.

5 In the next window, you will see a list of the tools to be downloaded. Click Next.

6 Read and accept the license agreements, then click Finish.

7 When the installation completes, restart Eclipse.

■ Download Platforms and Other Components


— The Android SDK requires platform bundles to be installed separately from the initial install. To develop an
Android application, you also need to download at least one Android platform and the SDK Platform-tools.
— Full directions are available at: http://developer.android.com/sdk/installing.html#AddingComponents and
are excerpted below for convenience:

You can launch the Android SDK and AVD Manager in one of the following ways:

… From within Eclipse, select Window > Android SDK and AVD Manager.
… On Windows, double-click the SDK Manager.exe file at the root of the Android SDK directory.
… On Mac or Linux, open a terminal and navigate to the tools/ directory in the Android SDK, then
execute:
android

Select the desired Android platform, its corresponding SDK Platform-tools, and any desired optional
components and ensure the installation completes.

Pre-installation Requirements
Before you install AMP Studio, make sure your PC meets the following hardware and software requirements:

Hardware Recommendation

PC Requirements (minimum) ■ Windows XP SP3 or Vista SP1


■ Intel Core-Duo 2Ghz processor
■ 2 GB of memory
■ 10GB of free disk space

AMP™ Studio Developer Guide 13


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Hardware Recommendation

PC Requirements (recommended) ■ 64 bit Windows XP SP3 or Vista SP1


■ Intel Core-Duo 2.5 Ghz processor
■ 4 GB of memory
■ 10GB of free disk, 7200 rpm or solid disk

Mac Requirements (required to build and ■ 2Ghz Processor


run iPhone Simulator) ■ 2 GB of memory

Mac Requirements (for running VMware ■ 2Ghz Processor


Fusion to run AMP Studio on a Windows ■ 4 GB of memory
VM on the Mac)

Software Recommendation

Eclipse Eclipse SDK 3.6.1

Java Java SDK 1.6

Windows Mobile Client ■ Windows Mobile 6 Professional and Standard Software


Development Kits Refresh (Windows Mobile Simulators for
WM5, WM6, and WM6.1)

BlackBerry Client ■ Various device simulators including for Curve 8300/8800,


Curve 8900, Bold, and Storm
■ RIM Signing keys to allow deployment of application on device
(requires agreement with RIM)

Apple iPhone ■ Apple Xcode 3.2.5 and iOS SDK 4.2 or latest (requires
membership to iPhone developer program)
■ Apple iPhone Developers Agreement to allow deployment of
application on device

Android SmartPhones ■ Android SDK r07 or latest is required and needs to be installed
prior to use.
■ Android version 2.0 and above
■ Android Eclipse plugin version 0.9.9 is bundled with the AMP
Studio installer.
■ Developer needs to generate marketplace keys using Android
SDK.

Installing the Software


To install AMP Studio, do the following:

■ Run the StudioInstaller.exe file.


■ Follow the prompts to select the installation location and options to install.
■ Once the installation has been completed, a shortcut for Eclipse is created. Use this shortcut to launch AMP
Studio.

AMP™ Studio Developer Guide 14


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Installation Components
The AMP Studio installation package includes the following components:

■ Studio for creating Data and UI projects for different Mobile devices
■ Web Services Connector designer
■ Database Connector designer
■ Composite Connector designer
■ Web Services sample connector (VRPC connector)
■ Database sample connector (VDSC connector)

Using AMP Studio


This section describes the following AMP Studio components:

■ Eclipse toolbar
■ Creating Data Projects
■ Creating UI Projects
■ Choosing Device Compatibility
■ Windows Mobile Setup
■ BlackBerry Setup
■ iPhone Setup
■ Authentication Server Setup
■ Application Startup Setup
■ Multi-Lingual Setup

AMP™ Studio Developer Guide 15


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Eclipse Toolbar
AMP Studio adds a set of icons to the Eclipse toolbar so you can easily access the tools.

The following are the icon definitions starting from the first icon in the red highlighted rectangle:

■ Create New Data Project to create a new data project


■ Create New UI Project to create a new user interface project
■ Compile mScript to compile Script sources
■ Run Server to run the built-in authentication and application server
■ Run BlackBerry Device Simulator to run the BlackBerry device simulator
■ Package BlackBerry Applications to run the BlackBerry JDE with a pre-configured application project file
■ Run Windows Mobile Applications to run the Windows Mobile device simulator
■ Package Windows Mobile Applications to create a deployment package for Windows Mobile
■ Run Android Application to run the Android device simulator
■ Package Android Application to run the Android
■ Create Job Jar for server deployment

Creating Data Projects


To create a new Data project, do the following:

1 Launch Eclipse.

2 Switch to the AMP Studio perspective.

3 From the menu, select AMP Studio.

AMP™ Studio Developer Guide 16


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

4 Select Create New Data Project.

NOTE: For more information about Eclipse, refer to www.eclipse.org.

The Data Project Wizard screen appears.

5 Enter the name of the project in the Project name box.

6 Select the connector from the drop-down box.

AMP™ Studio Developer Guide 17


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

7 Click Finish to create the project.

Adding Data Objects


Add data objects to the project by doing the following:

1 Expand the created project.

2 Double-click Connection from the left panel. The connection dialog box appears.

3 Enter any required information and click Connect.

4 From the left panel options, highlight VDSC or VRPC and expand getObjectRows.mscript and right-click
Request to Add Object.
.

AMP™ Studio Developer Guide 18


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

The Object Wizard screen appears.

5 Select one or more objects from the list.

6 Click Finish to add data objects to the created data project. The following image displays a sample project with
the added data objects.

Viewing AMP Studio Explorer


You can view the AMP Studio Explorer in the right panel. The Explorer shows the hierarchy of the project and its data
objects.

1 Double-click a data object. By default, all fields of a data object are not selected.

2 Select fields to be used in the project. The selected objects are shown in AMP Studio in the Outline tab. The
project and each data object have mScript files.

3 Double-click an mScript file to start editing it.

AMP™ Studio Developer Guide 19


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

The following image displays a sample project mScript file.

Creating UI Projects
To create a new UI project, do the following:

1 Launch Eclipse.

2 Switch to the AMP Studio perspective.

3 From the toolbar, click AMP Studio.

4 Select Create New UI Project.

AMP™ Studio Developer Guide 20


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

The UI Project Wizard is displayed.

5 Enter the name of the project in the Project name box.

6 Click Next. The UI Project Wizard is displayed with the existing data project.

7 Check the data project to link the existing data project with the new UI project.

AMP™ Studio Developer Guide 21


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

8 Click Finish to create the project.

Adding Styles, Screens, Panels and Folders


After the UI project is created, you can add styles, screens, panels, strings, and folders to the project.

1 Right-click on the UI project.

2 From the menu options, select Add Style.

AMP™ Studio Developer Guide 22


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

The Style Wizard is displayed.

3 Enter the Style Name.

4 Click Finish to add the new style to the UI project.

You can also select the following menu options:

■ Add Strings Bundle to add a string to the UI project


■ Add Style to add a style to the UI project
■ Add Class to add a class to the UI project
■ Add Screen to add a screen to the UI project
■ Add Pop-up to add a pop-up message to the UI project
■ Add Camera Dialog to add a camera dialog to the UI project
■ Add Panel to add a panel to the UI project
■ Add Folder to add a folder to the UI project
■ Add Virtual Object to add a virtual object to the UI project
■ Update Cache to update the cache in the UI project
■ Add Data Projects to add a data project to the UI project
■ Remove Data Projects to remove a data project to the UI project

AMP™ Studio Developer Guide 23


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Choosing Device Compatibility


Every project requires the selection of device compatibility to create appropriate packages for runtime.

1 From the menu, click Window and select Preferences. The Preferences screen appears.

2 Select AMP Studio from the left panel and click Client.

You can see the list of clients in the right panel.

AMP™ Studio Developer Guide 24


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

3 Optionally, you can click on the black arrow to the right of the blue compile button to select the devices for
which you want to compile.

— Select BlackBerry for all BlackBerry devices.


— Select NET for Windows Mobile devices.
— Select Pocket PC and Smart Phone for all Windows Mobile Devices (5.0/6.0/6.1 and 6.5 devices.)
— Select iPhone and iPhone4 for iPhone devices.
— Select iPad for iPad devices.
— Select Android for Android devices.

Windows Mobile Setup


1 From the menu, click Windows and select Preferences. The Preferences screen appears.

2 Select AMP Studio from the left panel and click Client.

3 Browse to the Microsoft.NET file from the directory.

4 Click Apply.

AMP™ Studio Developer Guide 25


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

BlackBerry Setup
The BlackBerry setup screen is used to define the JDE, MDS simulator, and Device simulator to be used for development.

1 From the menu, click Windows and select Preferences. The Preferences screen appears.

2 Select AMP Studio from the left panel and click Client. Expand the Client folder on the left panel.

3 Click BlackBerry.

The BlackBerry dialog box appears in the right panel.

4 Click Apply.

AMP™ Studio Developer Guide 26


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

iPhone Setup
AMP Studio generates objective C source files for iPhone compatible projects. These source files are compiled on a Mac
with iPhone SDK development tools and can be run on a simulator or device.

1 From the menu, click Windows and select Preferences. The Preferences screen appears.

2 Select AMP Studio from the left panel and click Client. Expand the Client folder in the left panel.

3 Click iPhone.

The iPhone dialog box appears in the right panel.

4 The XCode project bundle ID is used from project-Info.plist under Resources.

AMP™ Studio Developer Guide 27


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

5 To find the AppID on your Mac machine, select Developer Profile under Organizer. The App Identifier is listed
under Provisioning Profiles.

6 Click Apply.

AMP™ Studio Developer Guide 28


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Android Setup
1 From the Windows menu, click Preferences and select Android and set the SDK.

Optionally, you can do the following:

1 From the menu, click Windows and select Preferences. The Preferences screen appears.

2 Select Android from the left panel and select the SDK tab.

3 Browse to the android-sdk-windows file from the directory and select the Android Virtual Device.

4 Click Apply.

AMP™ Studio Developer Guide 29


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Server Setup
AMP Studio can be set up to access an internal or external AMP Server Authentication server.

1 From the menu, click Windows and select Preferences. The Preferences dialog box is displayed.

2 Select AMP Studio from the left panel and click Server.

The Server Configuration dialog box appears on the right panel.

3 Click Apply.

Application Startup Setup


The Application setup screen defines the title, splash image, home screen, and rollover icons. The properties are bundled
within the application executable for runtime access. BlackBerry runtime picks the appropriate home screen and rolls over
icons and the splash screen based on the device model.

AMP™ Studio Developer Guide 30


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Multi-Lingual Setup
AMP Studio provides the ability to set up a project for multi-lingual deployment.

1 From the menu, click Windows and select Preferences. The Preferences screen appears.

2 Select AMP Studio from the left panel and click Languages.

The Languages dialog box appears on the right panel. The default installed language is English.

AMP™ Studio Developer Guide 31


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

3 You can add languages by moving the appropriate language definition from the left to right in previous control.

After the languages are added, the selected languages are displayed in the Strings node in the UI project.

AMP™ Studio Developer Guide 32


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Strings Setup
You can also set up the Strings as constants in a project.

1 Right-click the UI project.

2 From the menu options, select Add Strings to add strings.

The Strings Wizard is displayed.

AMP™ Studio Developer Guide 33


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

3 In the Strings Bundle Name, type Constants. The Constants icon is created and is displayed in the left panel.

The Constants dialog box appears on the right panel.

AMP™ Studio Developer Guide 34


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

4 Click Add String to add another new string as a constant.

The string bundle can be used inside the code as shown below:

Label lblHeader = new Label();

lblHeader.setText(Constants.SCR_HOME.getString());

Button btnBack = new Button();

btnBack.setText(Constants.BACK.getString());

Server Settings Screen


The Server settings screen on a Windows Mobile client can be customized to reflect customer-supplied strings.

1 From the menu, click Windows and select Preferences. The Preferences screen appears.

2 Select AMP Studio from the left panel and click Server. The Server Settings screen appears.

AMP™ Studio Developer Guide 35


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

3 Select Log Properties. The Log Properties dialog box appears on the right panel.

You can view the log properties of the server settings in the screen.

Application Development
AMP Studio provides the ability to run BlackBerry, Windows Mobile, Android, and desktop simulators. The application
development process consists of following steps:

■ Create one or more data projects.


■ Connect to data sources to obtain metadata for use within data and UI projects.
■ Create the UI project.
■ Set up device compatibility options for the UI application.
■ Define the application title, icons, and splash screen(s).
■ Create application screens and business logic using mScript as described in UI Project mScript on page 64.
■ Once the application is ready for testing, compile the mScript and then run the server.

AMP™ Studio Developer Guide 36


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

■ Run the Windows Mobile Simulator (for WM applications).

NOTE: You do not need to run MDS because by default, you can use a Direct TCP connection and not an
MDS connection.

■ After compiling, you need to switch to a Mac and compile and run the application in xCode.
■ Run the Android emulator (for Android applications).

Code Generation
AMP Studio generates device-specific native code for application data and UI projects. Native code is used for the
following device types:

■ .netCF for Windows Mobile


■ BlackBerry Java for BlackBerry devices
■ Objective C for iPhone and iPod touch devices

Application code is supplemented by the AMP Server and AMP Studio device-specific runtimes.

The code generation process is activated when you select the mscript compile toolbar button from the Antenna >
Compile menu options.

AMP Studio generates device-specific source files and they are located under the project folder. These files are recreated
whenever the application is compiled within AMP Studio. You can force a cleanup of these directories before compiling
by selecting Project from the menu, then Clean.

AMP™ Studio Developer Guide 37


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

BlackBerry Simulator
1 From the menu, click AMP Studio and select BlackBerry

2 Click Run Device Simulator. The BlackBerry simulator is launched.

■ Additionally, you can launch the BlackBerry Device Simulator from the toolbar:

or,

■ Select Start JDE to run the BlackBerry JDE with the AMP Studio application project that is pre-configured. Use
F5 within the JDE to launch the simulator.

AMP™ Studio Developer Guide 38


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

iPhone Simulator
AMP Studio generates Objective C source files for iPhone compatible projects. These source files are compiled on a Mac
with iPhone SDK development tools and can be run on a simulator or device. Do the following to build an application in
the iPhone simulator.

1 From the menu, click AMP Studio and select iPhone.

2 Select Client.

3 Select AMP Studio from the left panel and select Client. Expand the Client folder in the left panel.

4 Select iPhone or iPhone4.

5 Click Apply.

6 Click OK.

7 Compile the code using the mScript compiler.

8 Copy your workspace to one of the folders inside the Mac mini.

9 Double-click YourApp-iphone4.xcodeproj and select Build.

AMP™ Studio Developer Guide 39


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

The XCode editor will be displayed with the list of files.

NOTE: Ensure that the Client.properties file contains the CLIENTSERVICE$AUTH_SERVER as the IP
address of the machine where your AMP Server is running.

AMP™ Studio Developer Guide 40


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

10 After the build is completed, the iPhone-4 simulator is displayed with the application’s Login screen.

NOTE: This file will be generated by AMP Studio. You may not copy all the files every time. If you are
making changes only to the UI after the first copy, then copy only the UI project compile code ending with
objc. In case you are adding an image or a bundle, you can copy all the files.

11 Reset the settings of the iPhone simulator before using it.

NOTE: You may clear the cache.

AMP™ Studio Developer Guide 41


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Windows Mobile Simulator


1 From the menu, click AMP Studio and select Windows Mobile.

2 Click Run. The WM simulator is launched.

— Optionally, you can launch the Windows Mobile from the toolbar:

The Run process launches a new process for managing Windows Mobile simulators. This launch includes a DOS
window and Antenna Device Manager:

AMP™ Studio Developer Guide 42


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

The Device list is based on simulators installed in Visual Studio and any additional device skins downloaded
from the Web.

3 Right-click the appropriate device simulator and perform the following steps:

A Select Connect. This will launch the simulator along with activating Microsoft ActiveSync.

B Select Deploy Compact Framework. This step is required only once for each simulator (provided you have
saved the state when you closed the simulator).

C Select Deploy. This loads the application package to the device simulator.

D Select Run. This launches the application. (This step may take a few minutes as the application loads.)

E Select Bring to Front. This will bring the simulator window to the foreground.

AMP™ Studio Developer Guide 43


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Android Simulator
1 Download the latest Android SDK from Google for Windows. From the Windows menu, select Preferences and
click Android.

AMP™ Studio Developer Guide 44


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

2 Browse to the location where the Android SDK is located in your local Mac. You will see all the supported
API’s.

3 From the Windows menu, select Android SDK and AVD Manager. You need to create new device simulator
for testing.

4 Click New. The Create new Android Virtual Device screen appears.

5 Name the Simulator and select the target. You can create as many device simulators you need and test against
different target APIs.

6 Create a project in AMP Studio as explained for other devices and ensure that Android is selected in the Client
list under AMP Studio.

AMP™ Studio Developer Guide 45


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

7 Click the Run Android Application icon.

8 If the splash screen is specified, the Android device simulator starts and displays the splash screen before
displaying the Hello World Screen.

Hello World Application


This section describes how to create a sample Hello World application for a UI project and a Data project.

AMP™ Studio Developer Guide 46


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Creating a UI Project
To create a UI project, do the following:

1 Launch the Eclipse application.

2 Select UI Project.

A From the toolbar, select the New UI project icon, or from the File menu, click New and select UI Project.

or,

B From the File menu, click New and select Other.

The New wizard screen appears.

3 Expand AMP Studio, select UI Project, and click Next.

AMP™ Studio Developer Guide 47


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

4 Enter the name of the project as HelloWorld and click Next.

5 Check AMP Studio Preferences and click Finish.

6 Expand the HelloWorld UI Project.

7 Right-click the HelloWorld UI Project and select Add Screen.

AMP™ Studio Developer Guide 48


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

8 Enter the name of the screen as StartScreen and click Finish.

9 View the StartScreen.mscript file.

AMP™ Studio Developer Guide 49


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

10 Declare a new label at the top of the screen (within the screen brackets but before the first callback), as shown in
the following example.

Label lblHelloWorld = new Label();

11 In the onCreate() callback, set the text on the label and add the label to the Screen.

callback onCreate(Container container){

lblHelloWorld.setText("Hello World!");

add(lblHelloWorld,"hfill=fill");

12 Double-click the HelloWorld.mscript file and declare the StartScreen:

StartScreen scrStart;

13 In the onStart() callback, instantiate and push the StartScreen:

callback onStart(){

scrStart = new StartScreen();

scrStart.push();

14 From the Windows menu, select Preferences.

15 Select AMP Studio and click Client.

NOTE: The BlackBerry option should be checked.

16 Select Client and click BlackBerry.

NOTE: Ensure that the JDE and Device Simulator settings are valid.

17 Click OK.

18 Click Compile mScript in AMP Studio.

NOTE: Check the Problems tab to make sure that there are no errors. You can ignore warning messages.

19 Click the icon to start the server.

AMP™ Studio Developer Guide 50


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

20 Click the drop-down arrow to the right of the Run BlackBerry Device Simulator selection button and select a
BlackBerry simulator. When the simulator starts, find the Antenna application icon (it may be in the
Applications or Downloads folder) and select it. You can view the Hello World label on your device.

Data Project Using VRPC


To create a data project, do the following:

1 Launch the Eclipse application.

2 From the File menu, click New and select Data Project. The Data Project Wizard screen appears.

3 Enter the name of the project as HelloWorldDP.

4 Select the connector as SAMPLE_VRPC.

5 Click Finish.

6 Expand the HelloWorldDP Data Project and double-click Connection.

7 Click Connect.

8 Right-click VRPC and select Add VRPC.

9 Select getObjectRows and click Finish.

AMP™ Studio Developer Guide 51


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

10 Click getObjectRows and right-click Request and select Add Object.

11 Select SelectionCriteria, and click Finish.

12 Right-click Reply, select Add Object, select TEST, and then click Finish.

13 Double-click the SelectionCriteria Request object and move the NumRows and ObjectIndex fields from left to
right.

NOTE: SelectionCriteria Request objects are moved to the right for them to used by the application.

14 Double-click the SelectionCriteria Reply object and move the TEXT field from left to right.

15 Double-click the HelloWorld.mscript file and declare and instantiate the Data Project, the VRPC object, and the
MessageService:

HelloWorldDP.VRPC dp = new HelloWorldDP.VRPC();

HelloWorldDP.VRPC.getObjectRows vrpcGetObjectRows = dp.getObjectRows();

MessageService messageService = getMessageService();

16 In the HelloWorld.mscript's onStart() callback, set the user name to the deviceID, log in the user, start the
message service, and instantiate the StartScreen:

callback onStart(){

setUser(getDeviceID());

login();

messageService.start(true);

scrStart = new StartScreen();

scrStart.push();

17 When the user logs in, open the Data Project:

callback onLoggedIn(){

open(dp);

AMP™ Studio Developer Guide 52


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

18 Double-click the SelectionCriteria.mscript file. Add a prepareVRPC() method. This method will create a new
DataRow and set the NumRows field of this DataRow.

VRPCInputObject {

void prepareVRPC(){

DataRow dtRwSelectionCriteria = SelectionCriteria.getNewRow();

SelectionCriteria.ID.setStringValue("0", dtRwSelectionCriteria);

SelectionCriteria.NumRows.setStringValue("10", dtRwSelectionCriteria);

SelectionCriteria.ObjectIndex.setStringValue("0", dtRwSelectionCriteria);
dtRwSelectionCriteria.applyUpdates();

19 Double-click the getObjectRows.mscript file and add a sendVRPC() method.

VRPCRequest {

Request.SelectionCriteria SelectionCriteria = new Request.SelectionCriteria();

Reply.TEST TEST = new Reply.TEST();

void sendVRPC() {

reset();

SelectionCriteria.prepareVRPC();

send();

20 In HelloWorld.mscript file, call the VRPC in the messageService onServerAvailable callback:

callback messageService onServerAvailable() {

vrpcGetObjectRows.sendVRPC();

21 In StartScreen, create a VRPC callback for onReplyReceived:

callback vrpcGetObjectRows onReplyReceived(VRPCRequest request) {

AMP™ Studio Developer Guide 53


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

info("VRPC Reply Received");

22 Right-click the UI project and select your unassigned Data Project.

23 Click Finish to assign the DP to UI.

NOTE: If the DP is already assigned, it will not be displayed on the DP list

24 Click the Compile mScript button in AMP Studio. Check the Problems tab to make sure that there are no errors.
You can safely ignore Warning messages.

25 Start the AMP Studio server by clicking the Run Server button.

26 Click the Run BlackBerry Device Simulator button and select a BlackBerry simulator.

27 When the simulator starts, find the Antenna application icon (it may be in the Applications or Downloads folder)
and select it. You should see VRPC Reply Received pop-up message when the VRPC is returned.

VDSC Data Project

Data Objects
A data project uses data provided by a data connector. A data connector exposes data objects and their fields. To add a
data object to a data project, right-click VDSC in the AMP Studio Explorer:

A data object's field is the DataAttribute type. There are a number of specific DataAttribute types:

■ BinaryAttribute
■ BooleanAttribute
■ CurrencyAttribute
■ DateAttribute

AMP™ Studio Developer Guide 54


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

■ FloatAttribute
■ IDAttribute
■ IntegerAttribute
■ StringAttribute
■ TimeAttribute
■ TimestampAttribute

In AMP Studio Explorer, click a data object to select fields:

Query
The following is a sample empty query:

query myQuery<>{}

By default, a query takes data from the current data object. Because this query does not have any constraints, it will return
all rows from this data object. Each returned row has all fields of the current data object. In the following examples,
assume that the current data object has these fields:

id, username, valid, score, country, city, hobby

where:

the following query imposes a constraint:

query myQuery<>{

where valid == true;

AMP™ Studio Developer Guide 55


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

This query will return all valid users. The where clause is similar to SQL, but as you will see it is not the same. It is
possible to impose several constraints:

query myQuery<>{

where valid == true;

where score > 10;

This query will return all valid users with a score higher than 10.

The following operators can be used in where clause: ==, !=, <, >, <=, >=, startsWith, contains. An operator must be used
for two objects of the same type. For example, it is possible to use == between two boolean objects: valid == true but not
between a boolean object and a string: valid == "true" (this is illegal).

NOTE: Notice that valid is of type BooleanAttribute whereas true is of type boolean. Formally, these are
different types and cannot be used in the same operation. Nevertheless, within the query clause AMP Studio
performs automatic conversion between these types, and they can be used in the same operation. The same is
true for the DataAttribute type.

The following is the entire list of queries:

DataField Primitive Operators

BooleanAttribute boolean ==, !=

CurrencyAttribute float ==, !=, <, >, <=, >=

DateAttribute Date ==, !=, <, >, <=, >=

FloatAttribute float ==, !=, <, >, <=, >=,

IDAttribute String ==, !=, startsWith, contains

IntegerAttribute int ==, !=, <, >, <=, >=

StringAttribute String ==, !=, startsWith, contains

TimeAttribute Date ==, !=, <, >, <=, >=,

TimestampAttribute Date ==, !=, <, >, <=, >=

AMP™ Studio Developer Guide 56


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Sorting
The results of a query can be sorted in ascending or descending order:

query myQuery<>{

where valid == true;

where score > 10;

ascendingBy username;

This query will return all valid users with a score higher than 10 sorted by their user name in ascending order. Unlike the
where clause, a query may have only one sorting statement and only by one field.

Unique Keywords
In cases when unique results are required, use a unique keyword:

query myQuery<>{

where valid == true;

where score > 10;

ascendingBy username;

unique;

This query will return all unique valid users with a score higher than 10 sorted by their user name in ascending order.

Counting
In some cases, it is necessary to count the number of results from a query. In this case the number of results should be
stored in one of the fields of a data object.

query myQuery<>{

where valid == true;

ascendingBy username;

unique count score;

This query returns all unique valid users sorted by their user name in ascending order, and the number of these users is
stored in the score field.

AMP™ Studio Developer Guide 57


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Query Parameters
A query can have parameters:

query myQuery<boolean state, int minScore, DataAttribute sortBy>{

where valid == state;

where score > minScore;

ascendingBy sortBy;

unique;

In this example, the query receives three parameters: state (valid or not), minScore (minimum score) and sortBy (a field of
this data object by which the sorting will be performed).

Constraints imposed by the where clause are basic comparison operations. When more advanced constraints must be
imposed, it is possible to define a rowfilter. A rowfilter is basically a method that returns true or false:

rowfilter canadaUser<String city>{

return city.indexOf("Ottawa") > -1 || city.indexOf("Montreal") > -1;

This rowfilter takes a user's city as an input and returns true if a user is either from Ottawa or from Montreal.

This is how this rowfilter is used in a query:

query myQuery<boolean state, int minScore, DataAttribute sortBy>{

where valid == state;

where score > minScore;

cannadaUser<city>;

ascendingBy sortBy;

unique;

It is possible to use several row filters:

query myQuery<boolean state, int minScore, DataAttribute sortBy>{

where valid == state;

where score > minScore;

cannadaUser<city>;

legalHobby<hobby>;

ascendingBy sortBy;

AMP™ Studio Developer Guide 58


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

unique;

Index
For a faster lookup of data, it is possible to define an index. A data object may have only one index definition:

index myIndex{

username ascending;

country descending;

NOTE: In an index definition, the sorting keywords are ascending/descending and not ascendingBy/
descendingBy as in a query

Link Fields
A Link Field is a field of type DataAttribute that obtains its value from another DataAttribute in a way similar to the SQL
join.

Assume that the current data object is Company. Company has the AccountManagerID attribute. There is a need to obtain
the name of a manager by AccountManagerID from another data object Employee that has an EmployeeID and
EmployeeName for each employee.

A Link Field that obtains the manager’s name will look like:

StringAttribute managerName = AccountManagerID => Employee.EmployeeID ->


EmployeeName;

The type of managerName must be StringAttribute because Employee.EmployeeName is of type StringAttribute.

A Link Field definition consists of several parts separated by =>. The first part is a field inside the current data object.
Therefore there is no need to write the full name Company.AccountManagerID. It is enough to write just
AccountManagerID. The next parts are usually from other data objects and the name of a data object is mandatory in the
first half of -> expression but not in the second:

Employee.EmployeeID -> EmployeeName

Both parts of the -> expression must be from the same data objects. It is possible to chain several data objects:

StringAttribute jobDescription = AccountManagerID => Employee.EmployeeID -> JobID =>


Job.JobID -> JobDescription;

This example obtains the job description of the current account manager.

AMP™ Studio Developer Guide 59


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Virtual Fields
Fields of a data object are defined by a data connector. In some cases, it is necessary to define additional fields. Such
fields are called virtual fields.

The following is a list of virtual field types:

■ BinaryField
■ BooleanField
■ CurrencyField
■ DateField
■ FloatField
■ IDField
■ IntegerField
■ StringField
■ TimeField

TimestampField
Example:

BooleanField isFrequent{

return valid && score > 100;

This example defines a virtual field isFrequent of type BooleanField that returns true if a user is valid and has a high
score.

It is impossible to set a value to a virtual field. For example, the following line is incorrect:

isFrequent = true;

Virtual Data Objects

The regular data objects are defined in a data connector. Virtual data objects are defined in mScript. The first step in a
definition of a virtual data object is to define one or more mappings. A mapping defines a new view over data objects.

AMP™ Studio Developer Guide 60


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Example:

mapping userActivity<User user, UserHistory history>{

join user.user_id == history.user_id;

map user.username as username;

map history.date as actionDate;

map history.action_type as actionType;

This mapping defines a join by a user ID between two data objects: User and UserHistory. Then this mapping exposes
three fields under slightly different names. Now it is possible to run queries over this mapping:

query getUserActivity<User user, History history, Date fromDate>{

from userActivity<user, history>;

where actionDate > fromDate;

descendingBy actionDate;

This query returns the username, action date and action type sorted by action date in descending order and it filters results
by date. Use it to specify mappings over which a query is executed.

NOTE: The query that uses the mapping does not use the original names of data object fields (data,
action_type), but names exposed by the mapping: actionDate, actionType

It is possible to create a mapping over more than two data objects:

mapping userActivity<User user, UserHistory history, ActionInfo actionInfo>{

join user.user_id == history.user_id;

join history.action_type == actionInfo.action_type;

map user.username as username;

map history.date as actionDate;

map actionInfo.action_name as actionName;

Converting a String to an Integer for Sorting Purposes


In the VRPC Reply object, use the following code:

VRPCOutputObject {
query qryGetAll<> {

AMP™ Studio Developer Guide 61


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

ascendingBy intKeyAttr;
}

IntegerField intKeyAttr {
return Platform.createInteger(v_vms_key_attr_);
}
}

VRPC Data Project


VRPC is an abbreviation for Vaultus Remote Procedure Call. VRPC allows a developer to access online data, such as
from a Web Service, in a way that is optimized for efficient and secure access over a wireless network. VRPC takes a
request of a fixed set of objects (analogous to tables) that can contain a set of one or more rows. When the VRPC is
invoked, the input rows that were passed by the client application are sent to the server to actually invoke the procedure
call, and the reply rows are sent back to the client.

To invoke a VRPC, the application must obtain the VRPC Request object for each object that is being exposed by the
VRPC connector. Once each of the VRPC Requests has been populated with VRPCRows, send() is called to make the
call.

When the server results are available, the application is notified via the onReplyReceived callback. The VRPC Reply
object will contain rows with the values returned by the server.

To use VRPC, VRPC support must be enabled in the connector. A connector can have support for both VDSC and VRPC,
resulting in a hybrid application.

VRPC can be asynchronous, meaning that the calls are executed in a non-blocking scheme, allowing the main program
flow to continue processing.

VRPC is more efficient than having the client make Web Service calls directly. The connector removes the headers before
routing the response to the client, leading to reduced computation on the client and less data transmitted over the wireless
network.

The Client does not make direct Web Service calls. Instead, the connector and the server do the heavy lifting. The
connector creates Request and Reply objects for each Web Service call listed in the WSDL file. It creates Request objects
for the Request Elements and creates Reply objects for the Response Elements.

Data Objects
VRPC data objects are added to projects in the same way as VDSC data objects.

VRPC sample code snippet


Create one or more prepareVRPC() methods in the VRPC Request objects' mScript:

void prepareVRPC(){

AMP™ Studio Developer Guide 62


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

DataRow dtRwAggAcctSummaryReq = RetrieveAggregatedAccountSummaryReq.getNewRow();


RetrieveAggregatedAccountSummaryReq.Id.setStringValue("_", dtRwAggAcctSummaryReq);

RetrieveAggregatedAccountSummaryReq.IncludeCustomerDetail.setBooleanValue
(Platform.createBoolean(true), dtRwAggAcctSummaryReq);

dtRwAggAcctSummaryReq.applyUpdates();

Create a sendVRPC() method in the VRPC object mScript and call the prepareVRPC methods that you created:

void sendVRPC(String strUser) {

reset();

VRPCHeader.prepareVRPC();

RetrieveAggregatedAccountSummaryReqDocument.prepareVRPC();

RetrieveAggregatedAccountSummaryReq.prepareVRPC();

Id.prepareVRPC(strUser);

send();

In the UI project, call the sendVRPC() method:

vrpcAccountSummary.sendVRPC(strUser);

The VRPC Reply should be listened for in the onReplyReceived() callback. The UI can then be updated based on the
VRPC Reply.

callback vrpcAccountSummary onReplyReceived(VRPCRequest request){

dtRwSetError = vrpcAccountSummary.VRPCError.createQuery().getRowSet();

if(dtRwSetError.first() != null){

// show error

else {

tblPnlAccountSummary.rchTblMdlAccounts.setRows
(vrpcAccountSummary.SummaryDocument_24_Summary.qryGetTypes());

You can refer to more information about VRPC error handling in Best Practices for Error Handling on page 191.

AMP™ Studio Developer Guide 63


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

UI Projects
A UI project consists of the following:

■ mScript file
■ Strings Editor
■ Images Editor
■ Colors Editor
■ Styles folder
■ Screens
■ Panels
■ Folders

UI Project mScript
A UI project is created with one project level as mScript. For example, if a project is called as LearnUI, the mScript file
will be named as LearnUI.mscript. This top level mScript is used to define visible fields and is used in all mScript files of
the UI project. Usually it contains the definitions of the following:

■ Strings
■ Images
■ Styles
■ Services
■ Reference to a data project
■ Top level screens

It also contains important callbacks such as the onStart and onApplicationStyleSetup. It may also contain callbacks for
services and data project events.

Strings Editor
Strings are used to define string resources for localization purposes. You should add appropriate locales.

To add a string, do the following:

1 Right-click Strings and select New. The Strings screen appears.

2 Enter the name of a string and enter the corresponding actual value.

AMP™ Studio Developer Guide 64


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

An existing string resource can be deleted by right-clicking its name and selecting the Delete option.

Images Editor
Images are defined under the Images node of a UI project. To add an image, do the following:

1 Right-click Images and select Add Image Bundle. The Image Bundle screen appears. The Strings dialog box
appears in the right panel.

2 The Image Bundle Wizard screen appears.

AMP™ Studio Developer Guide 65


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

3 Enter the Name of the Image Bundle Wizard, and select the device in the Type field. Each image bundle has a
properties page that can be accessed by double-clicking an image bundle name.

4 Select the device compatibility for each image bundle. This enables AMP Studio to package only relevant
images with WM, BB, or iPhone executables.

Each image has a name and an appropriate image file can be assigned for each of the bundles. The .png file is
recommended, but you can also add .jpeg or .bmp files.

AMP™ Studio Developer Guide 66


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Colors Editor
Colors are defined under the Colors node of a UI project. All standard Java colors are listed in the left panel. The Colors
screen appears.

To add a new color, click the New button. The new color will be called NewColor and be listed in alphabetical order.

To edit an existing color, rename it in the Color name field, type in the appropriate RGB colors, and click the Save
button. Colors can be used in mScript as static fields in the class Colors.

Example:

txtMdlAccount.setForeColor(Colors.MobileTradingBlue);

txtMdlAccount.setFocusedForeColor(Colors.White);

Colors can also be defined with mScript. Colors defined with mScript also allow the developer to set the alpha as the first
(optional) parameter. This can provide a transparent effect.

Example:

Color clrWhite = Color.create(192,255,255,255);

Background bg = Background.createColorRectangleBackground(clrWhite);

rchTblAccounts.setOddUIRowBackground(bg);

rchTblAccounts.setEvenUIRowBackground(bg);

AMP™ Studio Developer Guide 67


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Sound Effects
The following is a sample code to add the sound effects:

Button btn1 = new Button();

TextField txtData = new TextField();

btn1.setText("Click here");

btn1.setOnClickSoundEffect(SoundEffects.btn_click);

txtData.setTextHint("Type here");

txtData.setOnValueChangeSoundEffect(SoundEffects.val_changed);

Styles
Styles are defined under the Styles folder of a UI project. In order to add a style, right-click either the UI project icon or
Styles in the AMP Studio Explorer.

You can use a style to define that the text color of a button is red. This red text color will be applied to all buttons of a UI
project.

A style can be set to the following types of controls:

■ Button
■ TextField

AMP™ Studio Developer Guide 68


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

■ Table
■ Rich_Table
■ Label
■ Message_box

Example:

Table.setCellBackColor(Color.WhiteSmoke);

This line sets the default color of a cell in all tables to Color.WhiteSmoke

Usually in order to create a consistent look, more than one visual setting must be applied to more than one type of UI
control. These settings are grouped in a Style definition. Each Style definition is in a separate mscript file. Each UI project
may have more than one Style.

Assume that the LearnUI has three styles: Default, Bright, Dark. It means that there are three mscript files:
DefaultStyle.mscript, BrightStyle.mscript and DarkStyle.mscript.

DefaultStyle.mscript looks like:

Style {

callback onStyleCreation(Style style) {

Label.setBackColor(Colors.LightGray);

Label.setForeColor(Colors.Black);

TextField.setBackColor(Colors.LightGray);

TextField.setForeColor(Colors.Black);

//more settings

Styles are often used for different device models or types. In order to apply a style to the LearnUI project, the following
code must be placed in LearnUI.mscript:

Styles.StyWM styWM = new Styles.StyWM();

Styles.StyBB styBB = new Styles.StyBB();

Styles.StyIPhone styIPhone = new Styles.StyIPhone();

callback onApplicationStyleSetup(StyleReceptor styleReceptor){

if (Device.isBlackberry()) {

styleReceptor.applyVisualStyle(styBB);

else if (Device.isWindowsMobile()) {

AMP™ Studio Developer Guide 69


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

styleReceptor.applyVisualStyle(styWM);

else if (Device.isIPhone()) {

styleReceptor.applyVisualStyle(styIPhone);

A style can be overwritten for a particular screen.

callback applyVisualStyle(Widget widget, StyleReceptor styleReceptor){

if (Device.isBlackberry()) {

styleReceptor.applyVisualStyle(styDetailsBB);

} else if (Device.isWindowsMobile()) {

styleReceptor.applyVisualStyle(styDetailsWM);

} else if (Device.isIPhone()) {

styleReceptor.applyVisualStyle(styDetailsIPhone);

A style can be overwritten locally. The following code overwrites the background color set globally:

someLabel.setBackColor(Color.DimGray);

Sample code snippet to create different styles


Style {

//Strings

String defaultFontFamily;

String titleFontFamily;

Label defHeaderLabel;

Label defTitleLabel;

Label defSectionLabel;

TextShadow txtShadow = new TextShadow();

//Fonts

Font fntDefault = new Font();

Font fntLabel = new Font();

Font fntButton = new Font();

Font fntBackgroundButton = new Font();

AMP™ Studio Developer Guide 70


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Font fntTextField = new Font();

Font fntTextArea = new Font();

Font fntComobBox = new Font();

Font fntScrHeader = new Font();

Font fntScrTitle = new Font();

Font fntScrSection = new Font();

//Font Sizes

int fntLabelSize;

int fntButtonSize;

int fntBackgroundButtonSize;

int fntTextFieldSize;

int fntTextAreaSize;

int fntComobBoxSize;

int fntScrHeaderSize;

int fntScrTitleSize;

int fntScrSectionSize;

//Callback onStyleCreation

callback onStyleCreation(Style style) {

defaultFontFamily = "";

defHeaderLabel =new Label();

defTitleLabel = new Label();

defSectionLabel = new Label();

/*

These generic labels can be used on any screen (or pop-up message, etc.) in the project. The text of these labels will be set
according to the parent screen. These labels can be used on multiple screens. Therefore, they save memory and
programming efforts.

*/

//Font Sizes

if (Device.isBlackberry()) {

defaultFontFamily = "BBAlpha Sans";

titleFontFamily = "BBAlpha Sans";

AMP™ Studio Developer Guide 71


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

fntLabelSize = 6;

fntButtonSize = 5;

fntBackgroundButtonSize = 5;

fntTextFieldSize = 6;

fntTextAreaSize = 5;

fntComobBoxSize = 6;

fntScrHeaderSize = 8;

fntScrTitleSize = 6;

fntScrSectionSize = 5;

} else if (Device.isBlackberry() && !Device.hasTouchScreen()) {

defaultFontFamily = "BBAlpha Sans";

titleFontFamily = "BBAlpha Sans";

fntLabelSize = 6;

fntButtonSize = 5;

fntBackgroundButtonSize = 5;

fntTextFieldSize = 6;

fntTextAreaSize = 5;

fntComobBoxSize = 6;

fntScrHeaderSize = 8;

fntScrTitleSize = 6;

fntScrSectionSize = 5;

} else if (Device.isBlackberry() && Device.hasTouchScreen()) {

defaultFontFamily = "BBAlpha Sans";

titleFontFamily = "BBAlpha Sans";

fntLabelSize = 6;

fntButtonSize = 5;

fntBackgroundButtonSize = 5;

fntTextFieldSize = 6;

fntTextAreaSize = 5;

fntComobBoxSize = 6;

fntScrHeaderSize = 8;

fntScrTitleSize = 6;

AMP™ Studio Developer Guide 72


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

fntScrSectionSize = 5;

} else if (Device.isIPhone()) {

defaultFontFamily = "Helvetica";

titleFontFamily = "Georgia-Bold";

fntLabelSize = 14;

fntButtonSize = 10;

fntBackgroundButtonSize = 10;

fntTextFieldSize = 14;

fntTextAreaSize = 12;

fntComobBoxSize = 12;

fntScrHeaderSize = 18;

fntScrTitleSize = 10;

fntScrSectionSize =14;

} else {

defaultFontFamily = "Helvetica";

titleFontFamily = "Georgia-Bold";

fntLabelSize = 14;

fntButtonSize = 10;

fntBackgroundButtonSize = 10;

fntTextFieldSize = 14;

fntTextAreaSize = 12;

fntComobBoxSize = 12;

fntScrHeaderSize =18;

fntScrTitleSize = 10;

fntScrSectionSize = 14;

setDefaultFontProperties(fntDefault, defaultFontFamily, fntBackgroundButtonSize);

setLabelProperties(fntLabel, defaultFontFamily, fntLabelSize);

setButtonProperties(fntButton, defaultFontFamily, fntButtonSize);

setTextFieldProperties(fntTextField, defaultFontFamily, fntTextFieldSize);

setTextAreaProperties(fntTextArea, defaultFontFamily, fntTextAreaSize);

setComobBoxProperties(fntComobBox, defaultFontFamily, fntComobBoxSize);

AMP™ Studio Developer Guide 73


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

setScrHeaderProperties(fntScrHeader, defaultFontFamily, fntScrHeaderSize);

setScrTitleProperties(fntScrTitle, defaultFontFamily, fntScrTitleSize);

setScrSectionProperties(fntScrSection, defaultFontFamily, fntScrSectionSize);

void setLabelProperties(Font fontType, String fontFamily, int fontSize) {

fontType.setFamily(fontFamily);

fontType.setSize(fontSize);

fontType.setBold();

Label.setFont(fontType);

Label.setForeColor(Colors.Black);

void setButtonProperties(Font fontType, String fontFamily, int fontSize) {

fontType.setFamily(fontFamily);

fontType.setSize(fontSize);

Button.setFont(fontType);

Button.setBackColor(Colors.Blue);

Button.setFocusedBackColor(Colors.Green);

Button.setForeColor(Colors.White);

Button.setFocusedForeColor(Colors.White);

void setDefaultFontProperties(Font fontType, String fontFamily, int fontSize) {

fontType.setFamily(fontFamily);

fontType.setSize(fontSize);

fontType.setBold();

void setTextFieldProperties(Font fontType, String fontFamily, int fontSize) {

fontType.setFamily(defaultFontFamily);

fontType.setSize(fontSize);

TextField.setFont(fontType);

TextField.setBorder(Border.createSimpleBorder(Colors.CadetBlue));

TextField.setForeColor(Colors.MediumBlue);

TextField.setFocusedForeColor(Colors.Black);

TextField.setBackColor(Colors.White);

AMP™ Studio Developer Guide 74


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

TextField.setFocusedBackColor(Colors.MintCream);

void setTextAreaProperties(Font fontType, String fontFamily, int fontSize) {

fontType.setFamily(defaultFontFamily);

fontType.setSize(fontSize);

TextArea.setFont(fontType);

TextArea.setBorder(Border.createSimpleBorder(Colors.CadetBlue));

TextArea.setForeColor(Colors.Black);

TextArea.setFocusedForeColor(Colors.Black);

TextArea.setBackColor(Colors.White);

TextArea.setFocusedBackColor(Colors.MintCream);

void setComobBoxProperties(Font fontType, String fontFamily, int fontSize) {

fontType.setFamily(fontFamily);

fontType.setSize(fontSize);

ComboBox.setFont(fontType);

ComboBox.setBorder(Border.createSimpleBorder(Colors.CadetBlue));

ComboBox.setForeColor(Colors.White);

ComboBox.setFocusedForeColor(Colors.MidnightBlue);

ComboBox.setBackColor(Colors.LightSlateGray);

ComboBox.setFocusedBackColor(Colors.White);

void setScrHeaderProperties(Font fontType, String fontFamily, int fontSize) {

fontType.setFamily(fontFamily);

fontType.setSize(fontSize);

fontType.setBold();

txtShadow.setShadowColor(Colors.DarkGray);

txtShadow.setShadowOffset(0,5);

defHeaderLabel.setFont(fontType);

defHeaderLabel.setForeColor(Colors.White);

void setScrTitleProperties(Font fontType, String fontFamily, int fontSize) {

AMP™ Studio Developer Guide 75


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

fontType.setFamily(fontFamily);

fontType.setSize(fontSize);

fontType.setBold();

defTitleLabel.setFont(fontType);

defTitleLabel.setForeColor(Colors.Silver);

void setScrSectionProperties(Font fontType, String fontFamily, int fontSize) {

fontType.setFamily(fontFamily);

fontType.setSize(fontSize);

fontType.setBold();

defSectionLabel.setFont(fontType);

defSectionLabel.setForeColor(Colors.Silver);

Services and Managers


There are two services: the Log and MessageService and two managers: MessagingManager, PhoneManager

Services are obtained through the corresponding get methods:

Log log = getLog();

MessageService messageService = getMessageService();

Managers are created by new commands:

MessagingManager messaging = new MessagingManager();

PhoneManager phoneManager = new PhoneManager();

Log
Every platform may have its own destination for log messages.

PhoneManager
PhoneManager serves to make and receive calls.

MessagingManager
MessagingManager serves to send and receive e-mail and SMS messages.
AMP™ Studio Developer Guide 76
ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Message Service
MessageService is used to allow the client and server to communicate with each other. It has a number of useful methods
and callbacks. The following example checks the server status:

int status = messageService.getMessageServiceStatus();

if (status == Service.AVAILABLE) {

//do something

else {

/*

Do something else. For example, show an alert.

*/

The following code explains how to set properties on the server.

callback messageService onServerRequestDenied(ApplicationPermission applicationPermission)


{

if (displayServerUpgradeMsg) {

if(applicationPermission.getStatus() = ApplicationPermission.STATUS_MUST_UPGRADE){

Array arOptions = new Array();

arOptions.addItem("Upgrade");

ask(false, null, applicationPermission.getMessage(), arOptions, 0);

if( Device.isBlackberry() ) shutdown();

goToWebPage(applicationPermission.getLatestUrl());

if(applicationPermission.getStatus() == ApplicationPermission.STATUS_MUST_UPGRADE){

Array arOptions = new Array();

arOptions.addItem("Upgrade");

ask(false, null, applicationPermission.getMessage(), arOptions, 0);

if( Device.isBlackberry() ) shutdown();

goToWebPage(applicationPermission.getLatestUrl());

AMP™ Studio Developer Guide 77


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

callback messageService onServerRequestGranted(ApplicationPermission applicationPermis-


sion) {

if (displayServerUpgradeMsg) {

if(applicationPermission.getStatus() == ApplicationPermission.STATUS_CAN_UPGRADE){

Array arOptions = new Array();

arOptions.addItem("Continue");

arOptions.addItem("Upgrade");

int response = ask(false, null, applicationPermission.getMessage(), arOptions,


1);

if(response == 1) {

if(Device.isBlackberry()) shutdown();

goToWebPage(applicationPermission.getLatestUrl());

if(applicationPermission.getStatus() == ApplicationPermission.STATUS_CAN_UPGRADE){

Array arOptions = new Array();

arOptions.addItem("Continue to Login");

arOptions.addItem("Upgrade");

int response = ask(false, null, applicationPermission.getMessage(), arOptions,


1);

if(response == 1) {

if( Device.isBlackberry() ) shutdown();

goToWebPage(applicationPermission.getLatestUrl());

AMP™ Studio Developer Guide 78


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Reference to a Data Project


Usually a UI project works with data from a data project. In order to work with a data project, it is necessary to create an
object of the data project.

Assume that the data project is a VDSC data project named LearnDP. Then the object will be:

LearnDP.VDSC dp = new LearnDP.VDSC();

Assume that the data project is a VRPC data project named LearnDP. Then the object will be:

LearnDP.VRPC dp = new LearnDP.VRPC();

Screens
A screen is a UI component. Some applications have a login screen, a main screen, and a number of other screens. The
following features describe the characteristics of a screen:

■ Title
■ Menu
■ Controls such as labels, buttons, text fields, etc.
■ Open message dialogs
■ A number of callbacks that are called during the lifecycle events of a screen: onCreate, onOpen, onActivate, etc.

You can add a screen by selecting Add Screen from the menu.

After a screen's folder and mscript are created in AMP Studio, the screen may be declared in the UI project's mscript
(LearnUI.mscript):

LoginScreen screen = new LoginScreen();

MainScreen mainScreen = new MainScreen();

Creating a Screen
Use the following code to create a screen:

LoginScreen loginScreen = new LoginScreen();

//Setting a Title

loginScreen.setTitle("Login");

Setting a Menu
Use the following code to set a menu:

AMP™ Studio Developer Guide 79


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Menu mn = new Menu();

Action actHelp = new Action();

Action actClose = new Action();

actHelp.setText("Help");

actClose.setText("Close");

mn.add(actHelp);

mn.add(actClose);

setMenu(mn);

Message Box
MessageBox is used to display a non-modal, platform-native pop-up dialog box.

Sample code snippet for MessageBox Class


Screen {

int fontSize,cnt=0;

BackgroundButton b1 = new BackgroundButton();

BackgroundButton b2 = new BackgroundButton();

BackgroundButton b3 = new BackgroundButton();

BackgroundButton b4 = new BackgroundButton();

BackgroundButton b5 = new BackgroundButton();

BackgroundButton b6 = new BackgroundButton();

HorizontalPanel hzPanel = new HorizontalPanel();

MessageBox msgBox = new MessageBox ();

Array askOptions = new Array();

callback onCreate(Container container){

b1.setText("Ask Sample 1");

setBackgroundButtonProperties(b1);

b2.setText("Ask Sample 2");

setBackgroundButtonProperties(b2);

b3.setText("Ask Sample 3");

setBackgroundButtonProperties(b3);

b4.setText("Error Sample");

AMP™ Studio Developer Guide 80


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

setBackgroundButtonProperties(b4);

b5.setText("Info Sample");

setBackgroundButtonProperties(b5);

b6.setText("Warning Sample");

setBackgroundButtonProperties(b6);

askOptions.addItem("Option 1");

askOptions.addItem("Option 2");

askOptions.addItem("Option 3");

askOptions.addItem("Option 4");

add(b1,"hfill=fill");

add(b2,"hfill=fill");

add(b3,"hfill=fill");

add(b4,"hfill=fill");

add(b5,"hfill=fill");

add(b6,"hfill=fill");

callback b1 onClick(Control c){

msgBox.ask(1,"This is ask");

callback b2 onClick(Control c){

msgBox.ask(2,true,"My Ask","This is ask",askOptions,2);

callback b3 onClick(Control c){

msgBox.ask(3,true,"My Ask","This is ask",askOptions,2,"Thats okay","Cancel It");

callback b4 onClick(Control c){

msgBox.error(4,"This is error");

callback b5 onClick(Control c){

msgBox.info(5,"This is info");

AMP™ Studio Developer Guide 81


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

callback b6 onClick(Control c){

msgBox.warning(6 ,"This is warning");

callback msgBox onDismissed ( MessageBox messageBox , int contextId , int


dismissalType , int result , String value ) {

String dismType = "";

if(dismissalType==MessageBox.DISMISS_UI){

dismType="UI Dismissed";

else if(dismissalType==MessageBox.DISMISS_PROGRAMMATIC){

dismType="Programatically Dismissed";

info("cid: "+contextId+", dismisal type: "+dismType+", result: "+result +",


value: "+value);

AMP™ Studio Developer Guide 82


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

The output for the message box class would be:

AMP™ Studio Developer Guide 83


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

AMP™ Studio Developer Guide 84


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Panels
A panel is a container for controls and other panels. The difference between the panels is in how they lay out their
controls. The basic panels are HorizontalPanel and VerticalPanel.

The following is a list of panel classes:

■ HorizontalPanel
■ VerticalPanel
■ FormPanel
■ BorderPanel
■ TablePanel
■ GridPanel
■ TabbedPanel
■ StackPanel
■ SectionedPanel
■ CalendarPanel

AMP™ Studio Developer Guide 85


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

HorizontalPanel
The HorizontalPanel places controls one after another horizontally.

Controls are added by using the add(Drawable) method. Both panels and controls inherit from the Drawable method. This
means that it is possible to add either a control or another panel with its own controls and panels. This provides the ability
to create complex layouts.

Sample code snippet for a HorizontalPanel


HorizontalPanel myHorizontalPanel = new HorizontalPanel();

Label lblHeader = new Label();

Label lbl1 = new Label();

Label lbl2 = new Label();

Label lbl3= new Label();

lbl1.setText("Peter Parker");

lbl2.setText(" Is ");

lbl3.setText("SPIDERMAN");

myHorizontalPanel.setColumnWidth(0,Sizing.PERCENTS,40);

myHorizontalPanel.setColumnWidth(1,Sizing.PERCENTS,20);

myHorizontalPanel.setColumnWidth(2,Sizing.PERCENTS,40);

myHorizontalPanel.setPanelHeight(Sizing.PERCENTS,60);

myHorizontalPanel.add(lbl1,"vfill=fill,hfill=fill");

myHorizontalPanel.add(lbl2,"halign=center");

myHorizontalPanel.add(lbl3,"vfill=fill,hfill=fill");

add(myHorizontalPanel,"hfill=fill");

AMP™ Studio Developer Guide 86


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

The output for the HorizontalPanel would be:

VerticalPanel
VerticalPanel lays out the controls vertically.

The previous example shows a simple case of TablePanel with one column. It simplifies adding elements to the table. The
number of rows is unlimited. The width of the column equals the maximal width of table elements. Panels and controls are
added using add(Drawable) method.

Sample code snippet for a VerticalPanel


VerticalPanel myVerticalPanel = new VerticalPanel();

myVerticalPanel.add(lblName);

myVerticalPanel.add(txtName);

myVerticalPanel.add(lblDob);

myVerticalPanel.add(txtDob);

myVerticalPanel.add(lblContact);

myVerticalPanel.add(txtContact);

myVerticalPanel.add(btnSubmit);

add(myVerticalPanel,"hfill=fill");

AMP™ Studio Developer Guide 87


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

The output for the VerticalPanel would be:

FormPanel
FormPanel lays the controls in two columns. The left control must be a Label.

Controls are added using the add(Label, Control) method.

Sample code snippet for a FormPanel


FormPanel myFormPanel = new FormPanel();

myFormPanel.add(lblName,"halign=right", txtName,"halign=left,hfill=fill");

myFormPanel.add(lblDob,"halign=right",txtDob,"halign=left,hfill=fill");

myFormPanel.add(lblContact,"halign=right",txtContact,"halign=left,hfill=fill");

myFormPanel.add(lblAddress,"halign=right",txtAddress,"halign=left,hfill=fill");
add(myFormPanel,"hfill=fill");

The output for the FormPanel would be:

AMP™ Studio Developer Guide 88


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

BorderPanel
A BorderPanel lays out the control in the top, bottom, left, right and center of a panel.

This container accommodates up to five layout elements. Four elements are along the borders and one in the center.
Border elements receive all the space needed. The remaining space goes to the center. North and South elements are
placed first; they receive full panel width. East and West elements receive the height remaining between North and South.
You should not attempt to place North and South elements whose height is greater than the panel height, and East or West
elements whose width is greater than the panel width.

Panels and controls are added by setNorth(Drawable), setWest(Drawable), setCenter(Drawable), setEast(Drawable),


setSouth(Drawable). It is not necessary to set all of these areas. For example, you may choose to only call setNorth() and
setCenter().

Sample code snippet for a BorderPanel


BorderPanel myBorderPanel = new BorderPanel();

btnEast.setText("East");

btnWest.setText("West");

btnNorth.setText("North");

btnSouth.setText("South");

btnCenter.setText("Center");

myBorderPanel.setEast(btnEast);

myBorderPanel.setWest(btnWest);

myBorderPanel.setNorth(btnNorth);

myBorderPanel.setSouth(btnSouth);

myBorderPanel.setCenter(btnCenter);

add(myBorderPanel,"hfill=fill,vfill=fill");

AMP™ Studio Developer Guide 89


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

The output for the BorderPanel would be:

TablePanel
TablePanel lays out controls in columns and rows. It has no grid lines. It has both horizontal and vertical scrollbars on
devices that support scrollbars.

It arranges various layout elements in columns and rows. It has methods to automatically regulate row/column width and
element positioning inside table cells.

The controls are added horizontally, one after another. Each control will be placed in the next spare cell. To begin a new
row, startNewRow() must be called.

The following code example creates a 100 columns x 1 row table.

TablePanel panel = new TablePanel();

for(int j = 0; j < 100; j++){

Label label = new Label();

label.setText("Label " + j);

panel.add(label, null);

panel.startNewRow();

This example creates a 1 column x 100 rows table. The second parameter of add method is used to set constraints on the
added control. The constraints specify the alignment of a control within its cell, if the control must fill the cell, and if the
control must span several columns or rows.

AMP™ Studio Developer Guide 90


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Sample code snippet for a TablePanel


TablePanel tblPanel = new TablePanel();

tblPanel.setColumnWidth(0,Sizing.PERCENTS,30);

tblPanel.setColumnWidth(1,Sizing.PERCENTS,30);

tblPanel.setColumnWidth(2,Sizing.PERCENTS,30);

tblPanel.setRowHeight(0,Sizing.PERCENTS,30);

tblPanel.setRowHeight(1,Sizing.PERCENTS,30);

tblPanel.add(label1);

tblPanel.add(label2);

tblPanel.add(label3);

tblPanel.startNewRow();

tblPanel.add(label4);

tblPanel.add(label5);

tblPanel.add(label6);

add(tblPanel,"halign=center");

The output for the TablePanel would be:

The last label spans two cells. The E button has colspan = 2, and it expands to fill the two columns.

Sizes of grid cells are determined automatically using elements’ preferred sizes. Sizes of grid cells can be overridden
using setRowHeight() and setColumnWidth(). Sizing.PIXELS should be used when the element size is known, for
example, for an image. Sizing.PERCENTS should be used when the element size is variable. The percentage base is the
panel size.

AMP™ Studio Developer Guide 91


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Example:

tblPnlRoot.setColumnWidth(0,Sizing.PREFERRED,1);

tblPnlRoot.setRowHeight(0, Sizing.PREFERRED, 1);

GridPanel
GridPanel lays out the controls in columns and rows. It has gridlines and only a vertical scrollbar. Instead of having a
horizontal scrollbar, it has left and right buttons.

This container arranges controls in a rectangular grid. It also provides special means for scrolling such as scroll buttons
(which can be hidden and disabled) or arrow keys for touch scrolling. The grid can have frozen columns and rows.

Both columns and row numbers must be set. It has no constraints. It has frozen columns. A frozen column is a column that
does not move during scrolling. If a GridPanel has two frozen columns, the first two columns do not move during
scrolling.

Panels and controls are added to GridPanel by set method:

GridPanel panel = new GridPanel();

panel.setColumnCount = 5;

panel.setRowCount = 100;

Label label = new Label();

Panel.setCellControl(label, 1, 2);

This example creates a 5 X 100 grid and sets a label in the row 1, column 2. Rows and columns are counted from 0. So
from a user’s point of view the label is added to row 2, column 3.

Sample code snippet for a GridPanel


GridPanel myGridPanel = new GridPanel();

myGridPanel.setColumnCount(3);

myGridPanel.setRowCount(4);

myGridPanel.setCellControl(new Separator(), 0, 0);

myGridPanel.setCellControl(lblHeader, 0, 1);

myGridPanel.setCellControl(new Separator(), 0, 2);

myGridPanel.setCellControl(lbl1, 1, 0);

myGridPanel.setCellControl(new Separator(), 1, 1);

myGridPanel.setCellControl(lbl2, 1, 2);

myGridPanel.setCellControl(new Separator(), 2, 0);

myGridPanel.setCellControl(lbl3, 2, 1);

myGridPanel.setCellControl(new Separator(), 2, 2);

AMP™ Studio Developer Guide 92


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

myGridPanel.setCellControl(lbl4, 3, 0);

myGridPanel.setCellControl(new Separator(), 3, 1);

myGridPanel.setCellControl(lbl5, 3, 2);

myGridPanel.setGridLineStyle(2);

add(myGridPanel,"halign=center");

The output for the GridPanel would be:

TabbedPanel
TabbedPanel has one or more tabs. Each tab is a panel with its own controls.

It manages a set of overlapping panels, switchable by a tab control. The Tab control location is platform-specific and can
be either at the top or bottom.

Panels and controls are added by add(Drawable, String). The string is the name of a tab. In the previous example the tabs
are named Tab 1 and Tab 2.

Sample code snippet for a TabbedPanel


Screen {

TabbedPanel myTabbedPanel = new TabbedPanel();

TabHeader tbHeader1 = new TabHeader();

TabHeader tbHeader2 = new TabHeader();

VerticalPanel vertPanel1 = new VerticalPanel();

VerticalPanel vertPanel2 = new VerticalPanel();

tbHeader1.setText("Tab1");

tbHeader2.setText("Tab2");

AMP™ Studio Developer Guide 93


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

vertPanel1.add(lbl1);

vertPanel1.add(btnNext);

myTabbedPanel.add(tbHeader1,vertPanel1);

vertPanel2.add(lbl2);

vertPanel2.add(btnPrevious);

myTabbedPanel.add(tbHeader2, vertPanel2);

add(myTabbedPanel,"hfill=fill,vfill=fill");

callback btnNext onClick(Control c){

myTabbedPanel.showTab(1);

callback btnPrevious onClick(Control c){

myTabbedPanel.showTab(0);

The output for the TabbedPanel would be:

StackPanel
StackPanel has a number of panels or controls but shows only one at a time. On different platforms this may look
different. It manages a set of overlapping panels with no switching control—switching must be programmed in mscript.

Panels and controls are added by add(Drawable).

Sample code snippet for a StackPanel


Screen {

StackPanel myStackPanel = new StackPanel();

VerticalPanel vertPanel1 = new VerticalPanel();

VerticalPanel vertPanel2 = new VerticalPanel();

AMP™ Studio Developer Guide 94


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

VerticalPanel vertPanel3 = new VerticalPanel();

HorizontalPanel hzPanel = new HorizontalPanel();

Label lbl1 = new Label();

Label lbl2 = new Label();

Label lbl3= new Label();

RadioGroup rdGrp = new RadioGroup();

ToolBarButton btn1 = new ToolBarButton();

ToolBarButton btn2 = new ToolBarButton();

ToolBarButton btn3 = new ToolBarButton();

callback onCreate(Container container){

lbl1.setText("Section A");

lbl2.setText("Section B");

lbl3.setText("Section C");

lbl1.setBackColor(Colors.Lavender);

lbl2.setBackColor(Colors.Lavender);

lbl3.setBackColor(Colors.Lavender);

vertPanel1.add(lbl1);

myStackPanel.add(vertPanel1);

vertPanel2.add(lbl2);

myStackPanel.add(vertPanel2);

vertPanel3.add(lbl3);

myStackPanel.add(vertPanel3);

hzPanel.setColumnWidth(0,Sizing.PERCENTS,100);

hzPanel.setPanelHeight(Sizing.PERCENTS,80);

hzPanel.add(myStackPanel,"valign=center,hfill=fill");

add(hzPanel,"valign=top");

btn1.setFocusedImage(Images.toolbarbtn3.getImage());

btn1.setImage(Images.toolbarbtn.getImage());

btn1.setSelectedImage(Images.toolbarbtn2.getImage());

btn1.setText(" A");

btn2.setFocusedImage(Images.toolbarbtn3.getImage());

AMP™ Studio Developer Guide 95


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

btn2.setImage(Images.toolbarbtn.getImage());

btn2.setSelectedImage(Images.toolbarbtn2.getImage());

btn2.setText(" B");

btn3.setFocusedImage(Images.toolbarbtn3.getImage());

btn3.setImage(Images.toolbarbtn.getImage());

btn3.setSelectedImage(Images.toolbarbtn2.getImage());

btn3.setText(" C");

rdGrp.addButton(btn1);

rdGrp.addButton(btn2);

rdGrp.addButton(btn3);

rdGrp.setButtonSpacing(5);

rdGrp.setNavigationType(ToolBar.SCROLLER);

add(rdGrp,"hfill=fill");

callback rdGrp onToolBarButtonClicked ( ToolBar c , int idxClicked , ToolBarButton


tbb , boolean isChanged ) {

if(idxClicked==0){

myStackPanel.select(vertPanel1,Animation.UNCOVER_FROM_BOTTOM);

else if(idxClicked==1){

myStackPanel.select(vertPanel2,Animation.CURL_UP);

else if(idxClicked==2){

myStackPanel.select(vertPanel3,Animation.UNCOVER_FROM_TOP);

AMP™ Studio Developer Guide 96


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

The following is output for the StackPanel sample code. (The Button B is selected and Button C has the focus.)

SectionedPanel
SectionedPanel is a panel container that contains panels with rounded corners and space between the panels. This is a
popular layout on iPhones. SectionedPanel is supported by iPhone and BlackBerry devices, but not by Windows Mobile
devices.

CalendarPanel
CalendarPanel is an advanced calendar widget. The output for the CalendarPanel would be:

AMP™ Studio Developer Guide 97


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Panel Methods
In addition to methods that serve to add controls, panels also have methods that do the following:

■ Methods that return controls


■ Methods that adjust the look of a panel and callbacks invoked during lifecycle events of a panel such as
onCreate, onOpen, onActivate, etc.

Reusing Panels
Some controls are reusable across multiple screens. Such panels may be defined in their own mscript file. Right-click a UI
project icon or a folder to add a panel.

You can define generic panels and then reuse them in different screens of the project. For adding a panel, right-click the
project name in the Project Explorer window and select Add Panel. Now select the type of panel you want to define.

AMP™ Studio Developer Guide 98


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

In the new window, type a name for the panel.

Inside the panel script, you can define and view properties. See HorizontalPanel on page 99 for an example.

HorizontalPanel
//Callback methods

callback onCreate(Container source) {

setBackground(Background.createHorizontalTiledImageRectangle
Background(Images.image_Header.getImage(), 2, 2));

setVGap(10);

setHGap(5);

setColumnWidth(0,Sizing.PERCENTS,25);

setColumnWidth(1,Sizing.PERCENTS,50);

setColumnWidth(2,Sizing.PERCENTS,25);

You can use the defined panels in as many screens as you want. They also help to make the view of all project screens
more uniform. To use a defined panel, instantiate it and then use it like a regular panel.

HeaderPanel headerPanel = new HeaderPanel();

ContentsPanel contentsPanel = new ContentsPanel();

FooterPanel footerPanel = new FooterPanel();

..........

headerPanel.add(btnAbout,"hfill=fill");

headerPanel.add(lblHeader,"halign=center");

AMP™ Studio Developer Guide 99


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

headerPanel.add(btnNext,"hfill=fill");

add(headerPanel,null);

contentsPanel.add(lblContent1);

contentsPanel.add(lblContent2);

contentsPanel.add(lblContent3);

contentsPanel.add(lblContent4);

add(contentsPanel,"halign=center");

footerPanel.add(lblFooter,"halign=center");

add(footerPanel,null);

Tables
Table displays data in a grid of columns and rows. It is used to display a data rowset, along with TableModel. The
following is a sample code to set an image in a Grouped Table programmatically:

callback grpTbl onCellInfo (Control c, Section section, int row, Cell info, boolean
focused) {

if(section == sct){

String strText = vrpcGetObjectRows.TEST.TEXT.getStringValue(info.getDataRow());

if (strText.equals("TEST Row 0")) {

imgMdl.setImage(Images.imgTest.getImage());

} else {

imgMdl.setImage(Images.imgArrow.getImage());

Folders
A folder serves to group screens and panels in order to create neatly organized projects. To add a folder, right-click a UI
project icon or an existing folder.

A folder becomes a part of the full name of a screen or panel. For example, in order to create an instance of
UserActionDetailsPanel that is located in ActionPanels folder which is a subfolder of UserPanels in LearnUI project, it
may be necessary to use its full name (depending on the current scope):

LearnUI.UserPanels.ActionPanels.UserActionDetailsPanel detailsPanel = new


LearnUI.UserPanels.ActionPanels.UserActionDetailsPanel();

AMP™ Studio Developer Guide 100


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Models
Models refer to data models assigned to various panels and UI controls. The following models are included when a
callback is available for it.

■ Bar Chart
■ Browser
■ Calendar
■ Chart
■ Check Box
■ Choice
■ Date
■ Date Format
■ Image
■ Multi-Model
■ Number Format
■ Pie Chart
■ Table
■ Text Format
■ Text
■ Time Format
■ Time
■ Timestamp
■ Timestamp Format

There is a row change event callback available for these models.

Text Format Model


The following is a sample code snippet for the Text Format model:

TextFormatModel txtFmtMdlPeers = new TextFormatModel();

txtFmtMdlPeers.addField(vrpcGetThemeDataCallBack.Instrument.Name);

txtFmtMdlPeers.addField(vrpcGetThemeDataCallBack.Instrument.Ticker);

txtFmtMdlPeers.setFormat("{0} {1}");

AMP™ Studio Developer Guide 101


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Table Model
The following is a sample code snippet for the Table model:

Table tbl = new Table();

TableModel tblMdl = new TableModel();

tbl.setColumnCount(2);

tblMdl.addStringColumn("EMPID", dp.MYEMP.EMPID);

tblMdl.addStringColumn("EMPNAME", dp.MYEMP.EMPNAME);

tblMdl.setRows(dp.MYEMP.getAll());

tbl.setColumnWidth(0, Sizing.PERCENTS, 50);

tbl.setColumnWidth(1, Sizing.PERCENTS, 50);

tbl.setGridLineStyle(1);

tbl.setDataModel(tblMdl);

add(tbl,"hfill=fill,vfill=fill,valign=top");

BarChart Model
The following is a sample code snippet for the BarChart model:

BarChart barChart = new BarChart ();

BarChartModel barModel = new BarChartModel();

barChart.setBarBorderDrawn(true);

barChart.setBarLabelShown(true);

barModel.setRows(dp.MYEMP.getAll());

barModel.addAttribute(dp.MYEMP. EMPSALARY);

barModel.setLabelAttribute(dp.MYEMP.EMPNAME);

barChart.setDataModel(barModel);

add(barChart,"hfill=fill,vfill=fill");

AMP™ Studio Developer Guide 102


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

PieChart Model
The following is a sample code snippet for the PieChart model:

PieChart pieChart = new PieChart ();

PieChartModel pieModel = new PieChartModel();

pieModel.setRows(dp.MYEMP.getAll());

pieModel.setDataAttribute(dp.MYEMP.EMPSALARY);

pieModel.setLabelAttribute(dp.MYEMP.EMPNAME);

pieChart.setBorderDrawn(true);

pieChart.setLabelShown(true);

pieChart.setDataModel(pieModel);

add(pieChart,"hfill=fill");

Choice Model
The following is a sample code snippet for the Choice model:

ChoiceModel empNameMdl = new ChoiceModel();

empNameMdl.setChoicesAttribute(dp.MYEMP.EMPNAME);

empNameMdl.setChoicesKeyAttribute(dp.MYEMP.EMPID);

empNameMdl.setRows(dp.MYEMP.getAll());

The ChoiceModel can be set to a Picker for an iPhone, for example:

Picker pkr = new Picker();

PickerElement pkrEl = new PickerElement();

pkrEl.setText("select one");

pkr.setDataModel(empNameMdl);

pkr.setPlaceHolder(pkrEl);

add(pkr,"valign=top,hfill=fill");

Optionally, it can be set to a ComboBox for a BlackBerry, for example:

ComboBox comboEName=new ComboBox();

comboEName.setDataModel(empNameMdl);

AMP™ Studio Developer Guide 103


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Multi Model
The following is a sample code snippet for the Multi model:

MultiModel mltMdl = new MultiModel();

Label lblEmpNameValue = new Label();

TextModel txtMdlEmpName = new TextModel();

Label lblEmpIDValue = new Label();

TextModel txtMdlEmpID = new TextModel();

mltMdl.setRow(dp.MYEMP.getFilteredByNAME("ashish").getRowSet().first());

txtMdlEmpID.addField(dp.MYEMP.EMPID);

lblEmpIDValue.setBackColor(Colors.Gainsboro);

lblEmpIDValue.setDataModel(txtMdlEmpID);

mltMdl.add(txtMdlEmpID);

add(lblEmpIDValue, "hfill=fill, vfill=fill");

txtMdlEmpName.addField(dp.MYEMP.EMPNAME);

lblEmpNameValue.setBackColor(Colors.Gainsboro);

lblEmpNameValue.setDataModel(txtMdlEmpName);

mltMdl.add(txtMdlEmpName);

add(lblEmpNameValue, "hfill=fill, vfill=fill");

Text Model
The following is a sample code snippet for the Text model:

Label lblEmpNameValue = new Label();

TextModel txtMdlEmpName = new TextModel();

txtMdlEmpID.addField(dp.MYEMP.EMPID);

txtMdlEmpID.setRow(dp.MYEMP.getFilteredByNAME("ashish").getRowSet().first());

lblEmpIDValue.setBackColor(Colors.Gainsboro);

lblEmpIDValue.setDataModel(txtMdlEmpID);

add(lblEmpIDValue, "hfill=fill, vfill=fill");

AMP™ Studio Developer Guide 104


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

TimeStamp Model
The following is a sample code snippet for the TimeStamp model:

TimestampModel tsMdlEmpDoj = new TimestampModel();

tsMdlEmpDoj.addField(dp.MYEMP.EMPDOJ);

tsMdlEmpDoj.setRow(dp.MYEMP.getFilteredByNAME("ashish").getRowSet().first());

DateBox datebox = new DateBox();

datebox.setDataModel(tsMdlEmpDoj);

add(datebox, "hfill=fill, vfill=fill");

TimestampFormat Model
The following is a sample code snippet for the TimestampFormat model:

TimestampFormatModel tsMdlEmpDoj = new TimestampFormatModel();

tsMdlEmpDoj.addField(dp.MYEMP.EMPDOJ);

tsMdlEmpDoj.setStyle(DateStyles.DATE_SHORT);
tsMdlEmpDoj.setRow(dp.MYEMP.getFilteredByNAME("ashish").getRowSet().first());

DateBox datebox = new DateBox();

datebox.setDataModel(tsMdlEmpDoj);

Time Model
The following is a sample code snippet for the Time model:

TimeModel tmMdlEmpDoj = new TimeModel();

tmMdlEmpDoj.addField(dp.MYEMP.EMPDOJ);

tmMdlEmpDoj.setRow(dp.MYEMP.getFilteredByNAME("ashish").getRowSet().first());

DateBox datebox = new DateBox();

datebox.setDataModel(tmMdlEmpDoj);

AMP™ Studio Developer Guide 105


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

TimeFormat Model
The following is a sample code snippet for the TimeFormat model:

TimeFormatModel tfMdlEmpDoj = new TimeFormatModel ();

tfMdlEmpDoj.addField(dp.MYEMP.EMPDOJ);

tfMdlEmpDoj.setStyle(DateStyles. TIME_MEDIUM);tfMdlEmpDoj.setRow
(dp.MYEMP.getFilteredByNAME("ashish").getRowSet().first());

DateBox datebox = new DateBox();

datebox.setDataModel(tfMdlEmpDoj);

NumberFormat Model
The following is a sample code snippet for the NumberFormat model:

Table tbl = new Table();

TableModel tblMdl = new TableModel();

NumberFormatModel numFmtMdl = new NumberFormatModel();

tblMdl.setRows(dp.MYEMP.getAll());

numFmtMdl.addField(dp.MYEMP.EMPID);

numFmtMdl.setShortenedDisplay(true);

numFmtMdl.setPositiveSign ( "+" );

numFmtMdl.setNegativeAsRed(true);

tblMdl.addFormattedColumn("EMPID", numFmtMdl);

tbl.setDataModel(tblMdl);

Date Model
The following is a sample code snippet for the Date model:

DateModel dtMdlEmpDoj = new DateModel();

dtMdlEmpDoj.addField(dp.MYEMP.EMPDOJ);

dtMdlEmpDoj.setRow(dp.MYEMP.getFilteredByNAME("ashish").getRowSet().first());

DateBox datebox = new DateBox();

datebox.setDataModel(dtMdlEmpDoj);

AMP™ Studio Developer Guide 106


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

DateFormat Model
The following is a sample code snippet for the DateFormat model:

DateModel dtFmtMdlEmpDoj = new DateModel();

dtFmtMdlEmpDoj.addField(dp.MYEMP.EMPDOJ);

dtFmtMdlEmpDoj.setStyle(DateStyles.TIME_SHORT);
dtFmtMdlEmpDoj.setRow(dp.MYEMP.getFilteredByNAME("ashish").getRowSet().first());

DateBox datebox = new DateBox();

datebox.setDataModel(dtFmtMdlEmpDoj);

Setting Data
There are two ways to set data in a control. One way is to set data directly using a corresponding method:

TextArea textArea = new TextArea();

textArea.setText("mScript is the secret weapon of Klingon programmers");

The second way is to use a data model and pass it to a control. A data model is a class that inherits from a DataModel.
There are several data model classes: BarChartModel, BrowserModel, CalendarDataModel, etc. Each data model class is
used with its corresponding control: BarChartModel is used with BarChart, etc. Some classes use only the direct way of
setting data as in the previous examples.

Some controls use both ways of setting data. For example, DateBox has two methods for setting data: setDate(Date) and
setDataModel(DataModel) that receives a DateModel instance.

Some classes use only data models to set data. Data models serve as a bridge between a data project and the controls in a
UI project. Data for a data model is obtained from data objects’ queries.

Example 1

Assume there is a data project named LearnDB that has a data object User. There is a query getUsersByName that returns
users sorted by name. The following example will show the results of this query in a list.

As you remember from the section about the UI project, the UI project’s mscript creates a reference to the data project:

LearnDP.VDSC dp = new LearnDP.VDSC();

Then this reference is used to obtain data from the data project:

ChoiceModel model = new ChoiceModel();

model.addField(dp.User.username);

model.setRows(dp.User.getUsersByName());

Choice choice = new Choice();

AMP™ Studio Developer Guide 107


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Choice.setDataModel(model);

The example creates a model. Then it specifies which of the User data object's fields will be shown in the list. Then it sets
rows from the query to the model. Then it creates the list and sets its model.

Now assume that a user selected a row in the list, opened a text editor and changed the value of the row, the datastore from
where the data is taken using the query can be updated. In order to do this, the code must obtain the selected row of the
list, update its value and save it:

DataRow row = model.getRow();

dp.User.username.setStringValue(newValue,row);

row.applyUpdates();

dp.startSync("Username Update");

applyUpdates stores data in the memory of a device.

startSync stores data in a file on a device and also sends it to be stored in the backend storage such as the database. The
parameter of startSync can be any text that identified the operation for logging purposes on the server.

Application Callbacks
Application callbacks provide mechanisms for device-specific runtime to communicate with the application and have it
take actions as necessary. It is not necessary to respond to all the callbacks. Runtime will invoke the callback only if it is
referenced in an application.

There are classes of callbacks for the UI application, Panels, UI controls, and, each callback outlines wherever it is
applicable. All associated Panels and UI controls are described in subsequent sections.

See On Close on page 108 for a code sample of that callback.

On Close
This callback is called when a panel or a screen is closed.

callback contentsPanel onClose ( Container source ) {

scrHome.lblStatus.setText("Returned");

AMP™ Studio Developer Guide 108


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

UI Controls
The following examples are assumed to be written inside play.mscript.

Bar Chart
This control displays business charts as groups of vertical bars.

Sample code snippet for a Bar Chart


barChart.setBarBorderDrawn(true);

barChart.setBarLabelShown(true);

barChart.setNRows(3);

barChart.setNSeries(4);

barChart.setRowLabel(0,"January");

barChart.setRowLabel(1,"February");

barChart.setRowLabel(2,"March");

barChart.setSeriesColor(0,Colors.Blue);

barChart.setSeriesColor(1,Colors.Green);

barChart.setSeriesColor(2,Colors.Yellow);

barChart.setSeriesColor(3,Colors.Red);

barChart.setValue ( 0,0, 4);

barChart.setValue ( 1,0, 8);

barChart.setValue ( 2,0, 12);

barChart.setValue ( 3,0, 16);

barChart.setValue ( 0,1, 20);

barChart.setValue ( 1,1, 24);

barChart.setValue ( 2,1, 2);

barChart.setValue ( 3,1, 6);

barChart.setValue ( 0,2, 10);

barChart.setValue ( 1,2, 14);

barChart.setValue ( 2,2, 18);

barChart.setValue ( 3,2, 22);

AMP™ Studio Developer Guide 109


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

add(barChart,"hfill=fill,vfill=fill");

The output for a Bar Chart would be:

Pie Chart
This control displays business charts as a circle divided into sections.

Sample code snippet for a Pie Chart


PieChart pieChart = new PieChart ();

pieChart.setBorderDrawn(true);

pieChart.setLabelShown(true);

pieChart.setNRows(4);

pieChart.setSectorColor(0,Colors.Blue);

pieChart.setSectorColor(1,Colors.Yellow);

pieChart.setSectorColor(2,Colors.Green);

pieChart.setSectorColor(3,Colors.Orange);

pieChart.setValue(0,25);

pieChart.setValue(1,46);

pieChart.setValue(2,14);

pieChart.setValue(3,15);

add(pieChart,"hfill=fill,vfill=fill");

AMP™ Studio Developer Guide 110


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

The output for a Pie Chart would be:

Button
A button shows an image or text.

Sample code snippet for a Button


Button button = new Button();

button.setForeColor(Colors.Yellow);

button.setBackColor(Colors.Lavender);

button.setBorderColor(Colors.Gray);

button.setText("Submit");

Sample code snipet for a Background Button


BackgroundButton bgrBtnHome = new BackgroundButton();

BackgroundButton bgrBtnChangeStore = new BackgroundButton();

BackgroundButton bgrBtnMapnDrive = new BackgroundButton();

BackgroundButton btnGo1= new BackgroundButton();

BackgroundButton btnGo2= new BackgroundButton();

Native
Button btnContinue = new Button();

btnContinue.setText("Continue");

AMP™ Studio Developer Guide 111


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

The output for a Native Background Button would be:

Full Graphic
BackgroundButton btn = new BackgroundButton();

btn.setImage(Images.image_reload.getImage());

The output for a Full graphic Background Button would be:

Tiled Graphic (single image with the left/right cap and tiled center portion)
Button bgrBtn = new Button();

bgrBtn.setText("TRADE");

bgrBtn.setBackground(Background.createHorizontalTiledImageRoundedBack-
ground(Images.image_activeBtnG.getImage(),3,3));

bgrBtn.setFocusedBackground(Background.createHorizontalTiledImageRoundedBack-

AMP™ Studio Developer Guide 112


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

ground(Images.image_activeBtnR.getImage(),3,3));

bgrBtn.setHorizontalTextAlignment(HorizontalAlignmentType.CENTER);

The output for a Tiled Graphic button would be:

CheckBox
A CheckBox uses a Boolean control. It appears as a check box on BlackBerry and Windows Mobile devices. It appears as
a Yes/No toggle field on an iPhone device.

Sample code snippet for a CheckBox


CheckBox checkBox1=new CheckBox();

CheckBox checkBox2=new CheckBox();

label1.setText("Male");

label2.setText("Female");

add(label1,"hfill=fill");

add(checkBox1,"hfill=fill,vfill=fill");

add(label2,"hfill=fill");

add(checkBox2,"hfill=fill,vfill=fill");

To see whether the checkbox is selected or not, you can use:

Boolean chk = checkBox1.getChecked();

CheckBox chkBox = new CheckBox();

Boolean b = chkBox.getChecked();

AMP™ Studio Developer Guide 113


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

The output for a CheckBox would be:

Choice
The Choice control allows a user to select a single item from multiple string choices. A choice is a vertical list where only
one line can be selected.

Sample code snippet for ChoiceModel


ChoiceModel empNameMdl = new ChoiceModel();

empNameMdl.setChoicesAttribute(dp.MYEMP.EMPNAME);

empNameMdl.setChoicesKeyAttribute(dp.MYEMP.EMPID);

empNameMdl.setRows(dp.MYEMP.getAll());

The ChoiceModel can be set to a Picker for an iPhone, for example,

Picker pkr = new Picker();

PickerElement pkrEl = new PickerElement();

pkrEl.setText("select one");

pkr.setDataModel(empNameMdl);

pkr.setPlaceHolder(pkrEl);

add(pkr,"valign=top,hfill=fill");

Optionally, it can be set to a ComboBox for a BlackBerry, for example:

ComboBox comboEName=new ComboBox();

comboEName.setDataModel(empNameMdl);

AMP™ Studio Developer Guide 114


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Combo Box
A Combo Box is a ChoiceControl with a drop-down list of choices. ComboBox, also called a drop-down list or a picklist
on many systems, combines a text field and a list. You can view a text field. When the text field is clicked, a list of choices
shows. When you select a line, the list disappears and the selected line is shown in the text field.

Sample code snippet for a Combo Box


ComboBox comboBox = new ComboBox();

You can add elements to the combobox one by one as in the following example:

comboBox.addChoice("Apple");

comboBox.addChoice("Fruit");

comboBox.addChoice("Banana");

comboBox.addChoice("Pineapple");

Or, you can populate the options in an array and then set the array to the combobox.

Array list = new Array();

list.addItem("Camel");

list.addItem("Elephant");

list.addItem("Tiger");

list.addItem("Lion");

comboBox.setChoices(list);

The output for a Combo Box would be:

AMP™ Studio Developer Guide 115


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Date Box
A DateBox is a simple date selection control.

Sample code snippet for a Date Box


DateBox dateBox = new DateBox ();

//to set the current time

dateBox.setDate(Platform.createDate());

//to set a specific date

Calendar cal = Platform.CALENDAR;

dateBox.setDate(cal.getDate(2011,11,25,0,0,0,0));

The output for a Date Box would be:

Label
A Label displays text.

Sample code snippet for a Label


Label lblName = new Label();

lblName.setText("Name");

lblName.setForeColor(Colors.Lavender);

lblName.setBackColor(Colors.Gray);

AMP™ Studio Developer Guide 116


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

The output for a Label would be:

Link

Sample code snippet for a Link


Link link = new Link();

link.setBorder(Border.createRoundedBorder(Colors.Black));

link.setText("Antenna Softwares");

Link supports onClick callback, for example,

callback link onClick ( Control c ) {

goToWebPage("www.antennasoftware.com");

The output for a Link would be:

AMP™ Studio Developer Guide 117


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Ticker

Sample code snippet for a Ticker


Screen {

TickerField tkrField = new TickerField();

int cnt = 0;

Button btnStart = new Button();

Button btnStop = new Button();

callback onCreate(Container container){

tkrField.setHeight(50);

tkrField.setInterItemGap(10);

tkrField.setIntraItemGap(5);

tkrField.setScrollInterval(100);

tkrField.setScrollType(TickerField.SCROLL_TYPE_PIXELS,10);

add(tkrField,"hfill=fill");

btnStart.setText(" Start ");

add(btnStart,"halign=center");

btnStop.setText(" Stop ");

add(btnStop,"halign=center");

callback btnStart onClick(Control c){

tkrField.startScrolling();

callback btnStop onClick(Control c){

tkrField.stopScrolling();

callback tkrField onFillFirstItem ( TickerField c , TickerItem info ) {

info.setStyle(TickerItem.TEXT_AND_IMAGE);

info.setText("London");

info.setStyle(TickerItem.TEXT_AND_IMAGE);

info.setImage(Images.image_activeBtnR.getImage());

cnt++;

AMP™ Studio Developer Guide 118


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

callback tkrField onFillNextItem ( TickerField c , TickerItem info ) {

if(cnt==1){

info.setStyle(TickerItem.TEXT_AND_IMAGE);

info.setText("Boston");

info.setImage(Images.image_activeBtnG.getImage());

else if(cnt==2){

info.setStyle(TickerItem.TEXT_AND_IMAGE);

info.setText("Toronto");

info.setImage(Images.image_activeBtnR.getImage());

else if(cnt==3){

info.setIsLast(true);

cnt++;

The output for a Ticker would be:

AMP™ Studio Developer Guide 119


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

PasswordField
A PasswordField control is a one-line text input control that masks the entered text.

Sample code snippet for a PasswordField


PasswordField passField = new PasswordField ();

passField.setTextHint("Your Password");

Label lblPwd = new Label();

lblPwd.setText("Enter Password");

passField.setLabel(lblPwd);

add(passField,"halign=center,valign=center");

The output for a PasswordField would be:

TextField
TextField textField = new TextField();

callback onCreate(Container c){

textField.setText("Type here");

callback textField onValueChange(Control c){

String value = textField.getText();

info("You have typed: " + value);

This example creates a TextField object. When the Play screen is created, the onCreate callback is called. This callback
sets text in the text field. When the text changes inside the text field, the onValueChange callback is called on textField.

You can create and customize any control using this principle.

AMP™ Studio Developer Guide 120


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Sample code snippet for a TextField


TextField txtName = new TextField();

txtName.setBorder(Border.createRoundedBorder(Colors.Black));

txtName.setForeColor(Colors.Blue);

txtName.setText("Merry Christmas");

The output for a Text field would be:

E-mailField

Sample code snippet for an E-mailField


Label label1 = new Label();

EmailField emailField = new EmailField();

label1.setText("Enter Email");

hzPanel.add(label1,"hfill=fill");

hzPanel.add(emailField,"hfill=fill");

AMP™ Studio Developer Guide 121


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

The output for an E-mailField would be:

NumericField

Sample code snippet for a NumericField


NumericField numField = new NumericField ();

label1.setText("Enter Contact:");

hzPanel.add(label1,"hfill=fill");

hzPanel.add(numField,"hfill=fill");

AMP™ Studio Developer Guide 122


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

The output for a Numeric field would be:

PinpadField

Sample code snippet for a PinpadField


PinField pinField = new PinField();

label1.setText("Enter Pin:");

hzPanel.add(label1,"hfill=fill");

hzPanel.add(pinField,"hfill=fill");

AMP™ Studio Developer Guide 123


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

The output for a Pinpad field would be:

InteractiveImageField

Sample code snippet for an InteractiveImageField


InteractiveImageField intImg = new InteractiveImageField ();

AnimationInfo ai = new AnimationInfo ();

Button btnStop = new Button ();

Button btnStart = new Button ();

btnStop.setText(" Stop ");

btnStart.setText(" Start ");

add(btnStart,null);

add(btnStop,null);

intImg.setImage(Images.back.getImage());

ai.addImage(Images.anim1.getImage());

ai.addImage(Images.anim2.getImage());

ai.addImage(Images.anim3.getImage());

ai.addImage(Images.anim4.getImage());

ai.setDuration(1000);

intImg.setAnimation(ai);

intImg.setAnimationPosition(25,25);

AMP™ Studio Developer Guide 124


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

add(intImg,null);

......

callback btnStop onClick(Control c){

intImg.stopAnimating();

callback btnStart onClick(Control c){

intImg.startAnimating();

The output for an InteractiveImage field would be:

Picture Box
A PictureBox control displays an image on a screen to the user.

Sample code snippet for Picture Box


PictureBox picBox = new PictureBox();

picBox.setImage(Images.flowers.getImage());

picBox.setBorder(Border.createRoundedBorder(Colors.Black));

AMP™ Studio Developer Guide 125


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

The output for a Picture Box would be:

Progress Bar
A ProgressBar displays the progress of a process.

Sample code snippet for SampleUIProject.mscript


UIProject {

SampleDP.VDSC dp = new SampleDP.VDSC();

PasswordField passwordField = new PasswordField("dexterra");

HomeScreen scrHome;

....

callback onStart(PushedData pushedData){

setUser("Test");

login();

messageService.start(true);

setImageBundle();

openDP(passwordField.getPassword());

dp.startFDR("MANUAL_FDR");

dp.startSync("MANUAL_SYNC");

scrHome = new HomeScreen();

scrHome.push();

callback dp onSyncEvent(SyncEvent event, String description) {

int eventType = event.getEventType();

AMP™ Studio Developer Guide 126


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

switch(eventType) {

case SyncEvent.DATADOWNLOAD_INCEND:

scrHome.prgBar.setValue(dp.getCurrentSyncSegment());

break;

case SyncEvent.DATADOWNLOAD_INCSTART:

scrHome.prgBar.setMax(dp.getTotalSyncSegments());

break;

Sample code snippet for HomeScreen.mscript


Screen {

ProgressBar prgBar = new ProgressBar();

..........

callback onCreate(Container container){

scrHome.prgBar.setMin(0);

....

The output for a Progress Bar would be:

AMP™ Studio Developer Guide 127


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Separator
A Separator is an empty control whose sole use is to create spacing between other controls.

Sample code snippet for Separator


VerticalPanel vertPanel = new VerticalPanel();

vertPanel.add(label1);

Separator separator = new Separator();

separator.setHeight(15);

separator.setWidth(50);

vertPanel.add(separator);

vertPanel.add(label2);

The output for a Separator would be:

Rich Table

Sample code snippet for a Rich Table


Screen {

RichTableModel myRichTableModel = new RichTableModel();

RichTable myRichTable = new RichTable();

TextModel headerLabel0 = new TextModel();

TextModel headerLabel1 = new TextModel();

TextModel headerLabel2 = new TextModel();

TextModel headerLabel3 = new TextModel();

TextModel component0 = new TextModel();

TextModel component1 = new TextModel();

AMP™ Studio Developer Guide 128


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

TextModel component2 = new TextModel();

TextModel component3 = new TextModel();

TablePanel tPanel = new TablePanel();

ScrollableVerticalPanel svPanel = new ScrollableVerticalPanel();

callback onCreate(Container container){

myRichTableModel.setRows(dp.MYEMP.getAll());

headerLabel0.setText("ID");

myRichTableModel.addHeaderComponent(headerLabel0,"hfill=fill,vfill=fill");

headerLabel1.setText("NAME");

myRichTableModel.addHeaderComponent(headerLabel1,"hfill=fill,vfill=fill");

headerLabel2.setText("DESIGNATION");

myRichTableModel.addHeaderComponent(headerLabel2,"hfill=fill,vfill=fill");

myRichTableModel.startNewHeaderLine();

headerLabel3.setText("DOJ");

myRichTableModel.addHeaderComponent(headerLabel3,"hfill=fill,vfill=fill");

myRichTableModel.setHeaderColumnWidth(0, Sizing.PERCENTS,40);

myRichTableModel.setHeaderColumnWidth(1, Sizing.PERCENTS,25);

myRichTableModel.setHeaderColumnWidth(2, Sizing.PERCENTS,35);

myRichTableModel.setHeaderLineHeight(0, Sizing.PIXELS,30);

myRichTableModel.setHeaderLineHeight(1, Sizing.PIXELS,30);

component0.addField(dp.MYEMP.EMPID);

component1.addField(dp.MYEMP.EMPNAME);

component2.addField(dp.MYEMP.EMPDESG);

component3.addField(dp.MYEMP.EMPDOJ);

myRichTableModel.addUIRowComponent(component0,"halign=left");

myRichTableModel.addUIRowComponent(component1,"halign=left");

myRichTableModel.addUIRowComponent(component2,"halign=left");

myRichTableModel.startNewUIRowLine();

Font font = new Font();

font.setSize(14);

component3.setFont(font);

myRichTableModel.addUIRowComponent(component3,"halign=left");

AMP™ Studio Developer Guide 129


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

myRichTableModel.setUIRowColumnWidth(0, Sizing.PERCENTS,40);

myRichTableModel.setUIRowColumnWidth(1, Sizing.PERCENTS,25);

myRichTableModel.setUIRowColumnWidth(2, Sizing.PERCENTS,35);

myRichTableModel.setUIRowLineHeight(0, Sizing.PIXELS,30);

myRichTableModel.setUIRowLineHeight(1, Sizing.PIXELS,30);

myRichTable.setDataModel(myRichTableModel);

myRichTable.setOddUIRowBackground(Background.createColorRectangleBackground
(Colors.Cornsilk,Colors.DarkOrchid,1));

myRichTable.setEvenUIRowBackground(Background.createColorRectangleBackground
(Colors.Cyan,Colors.Fuchsia,2));

myRichTable.setFocusedUIRowBackground(Background.createColorRectangleBackground
(Colors.Green,Colors.Black,3));

myRichTable.setGridLineThickness(5);

svPanel.add(myRichTable);

tPanel.setColumnWidth(0,Sizing.PERCENTS,100);

tPanel.setRowHeight(0,Sizing.PERCENTS,80);

tPanel.add(svPanel,"hfill=fill,vfill=fill");

add(tPanel,"hfill=fill,vfill=fill");

AMP™ Studio Developer Guide 130


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

The output for a Rich Table would be:

Sticky Table

Sample code snippet for a StickyTable


Screen {

StickyTable stkTable = new StickyTable();

DataRowArray arrRows = null;

int rowHeight = 50;

callback onCreate(Container container){

arrRows = new DataRowArray();

DataRowSet rsLocRows = dp.MYEMP.getAll().getRowSet();

DataRow dtRowLoc = rsLocRows.first();

while(dtRowLoc != null){

AMP™ Studio Developer Guide 131


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

arrRows.addItem(dtRowLoc);

dtRowLoc = rsLocRows.next();

stkTable.setBackColor(Colors.Cornsilk);

stkTable.setNumberOfGroups(1);

stkTable.setNumberOfCellsInGroup (0, arrRows.length());

stkTable.refresh();

stkTable.setGridLineThickness(1);

add(stkTable,"hfill=fill, vfill=fill,valign=center");

callback stkTable onHeaderConfigure(TableView c, CellConfig cell, int group)

cell.setHeight(Sizing.PIXELS, rowHeight);

cell.setWidth(Sizing.PERCENTS, 100);

callback stkTable onHeaderCreateInfo ( TableView c , TableViewPanelCreateInfo info ,


int group )

TableViewCell headerCell = new TableViewCell();

Label lblEmploye = new Label();

lblEmploye.setText("Employe Details");

headerCell.add(lblEmploye,"hfill=fill");

HorizontalPanel horzPanel = new HorizontalPanel();

Label lbl1 = new Label();

Label lbl2 = new Label();

lbl1.setText("EID");

lbl2.setText("Employe");

horzPanel.setColumnWidth(0,Sizing.PERCENTS,20);

horzPanel.setColumnWidth(1,Sizing.PERCENTS,80);

horzPanel.add(lbl1,null);

horzPanel.add(lbl2,null);

headerCell.startNewRow();

headerCell.add(horzPanel,"hfill=fill");
AMP™ Studio Developer Guide 132
ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

headerCell.setBackColor(Colors.MediumPurple);

info.setPanel(headerCell);

callback stkTable onCellCreateInfo(TableView c, TableViewCellCreateInfo info, int


group, int row)

info.setPanel(new EmployeCell());

callback stkTable onCellSize(TableView c, AbsoluteSize sizeInfo, int group, int row)

sizeInfo.setHeight(rowHeight);

To create an EmployeCell (or any other TableViewCell), do the following:

1 Right-click the project name and select Add Panel.

2 Select TableViewCell from the list.

A Panel wizard window is displayed.

AMP™ Studio Developer Guide 133


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

3 Enter the name for the TableViewCell in the Panel wizard window. (In the following example, it is
EmployeeCell.)

4 Click Finish. You can design cells for the sticky table with the EmployeeCell.mscript.

Sample code snippet for EmployeCell.mscript


TableViewCell {

HorizontalPanel hzPanel = new HorizontalPanel();

VerticalPanel vertPanel = new VerticalPanel();

Label lblEmpId = new Label();

Label lblEmpName = new Label();

PictureBox picBox = new PictureBox();

callback onCreate(Container container){

hzPanel.setColumnWidth(0, Sizing.PERCENTS, 20);

hzPanel.setColumnWidth(1, Sizing.PERCENTS, 60);

hzPanel.setColumnWidth(2, Sizing.PERCENTS, 20);

hzPanel.setPanelHeight(Sizing.PIXELS,40);

hzPanel.setBackColor(Colors.Fuchsia);

hzPanel.add(lblEmpId,null);

hzPanel.add(lblEmpName,null);

picBox.setImage(Images.minus.getImage());

hzPanel.add(picBox,"valign=center,vfill=fill");

add(hzPanel,"hfill=fill, vfill=fill,valign=center");

setBackColor(Colors.Coral);

AMP™ Studio Developer Guide 134


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

callback onCellInfo(TableViewCell cell, Cell info, int group, int row){

DataRow dtRowLoc = null;

if(scrTblView.arrRows != null)

dtRowLoc = scrTblView.arrRows.getItem(row);

if( dtRowLoc == null){

return;

}else{

String empId = dtRowLoc.getKeyString();

lblEmpId.setText(empId);

lblEmpName.setText(dtRowLoc.getString(3));

dtRowLoc = null;

The output for a Sticky Table would be:

AMP™ Studio Developer Guide 135


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Sticky Table (Grouped)

Sample code snippet for a Sticky Table (grouped)

NOTE: The two examples have been separated. The first example shows how to create a single group
(Header,Contents and Footer), while this example shows how to create multiple groups in the StickyTable. In
this example, you are checking the group number. According to the group number you are setting the header
and the contents. In the previous example, the condition was not checked, since there was one group.

Screen {

StickyTable stkTable = new StickyTable();

DataRowArray arrRows = null;

int rowHeight = 50;

callback onCreate(Container container){

arrRows = new DataRowArray();

DataRowSet rsLocRows = dp.MYEMP.getLikeNAME("AN").getRowSet();

DataRow dtRowLoc = rsLocRows.first();

while(dtRowLoc != null){

arrRows.addItem(dtRowLoc);

dtRowLoc = rsLocRows.next();

stkTable.setBackColor(Colors.Cornsilk);

stkTable.setNumberOfGroups(2);

stkTable.setNumberOfCellsInGroup (0, arrRows.length());

stkTable.setNumberOfCellsInGroup (1, arrRows.length());

stkTable.refresh();

//stkTable.setGridLineThickness(1);

add(stkTable,"hfill=fill, vfill=fill,valign=center");

callback stkTable onHeaderConfigure(TableView c, CellConfig cell, int group)

cell.setHeight(Sizing.PIXELS, rowHeight);

cell.setWidth(Sizing.PERCENTS, 100);

AMP™ Studio Developer Guide 136


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

callback stkTable onHeaderCreateInfo ( TableView c , TableViewPanelCreateInfo info ,


int group )

TableViewCell headerCell = new TableViewCell();

Label lblEmploye = new Label();

lblEmploye.setText("Employe Details");

headerCell.add(lblEmploye,"hfill=fill");

HorizontalPanel horzPanel = new HorizontalPanel();

Label lbl1 = new Label();

Label lbl2 = new Label();

if(group==0){

lbl1.setText("EID");

lbl2.setText("Employe");

else if(group==1){

lbl1.setText("DESG");

lbl2.setText("Date Of Joining");

horzPanel.setColumnWidth(0,Sizing.PERCENTS,20);

horzPanel.setColumnWidth(1,Sizing.PERCENTS,80);

horzPanel.add(lbl1,null);

horzPanel.add(lbl2,null);

headerCell.startNewRow();

headerCell.add(horzPanel,"hfill=fill");

headerCell.setBackColor(Colors.MediumPurple);

info.setPanel(headerCell);

callback stkTable onCellCreateInfo(TableView c, TableViewCellCreateInfo info, int group,


int row)

if(group==0)

info.setPanel(new EmployeCell());

AMP™ Studio Developer Guide 137


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

else if(group==1)

info.setPanel(new EmployeDetailCell());

callback stkTable onCellSize(TableView c, AbsoluteSize sizeInfo, int group, int row)

sizeInfo.setHeight(rowHeight);

NOTE: The sample code for EmployeeCell.mscript has already been provided in the section Sticky Table on
page 131.

EmployeeDetailCell.mscript
TableViewCell {

HorizontalPanel hzPanel = new HorizontalPanel();

VerticalPanel vertPanel = new VerticalPanel();

Label lblEmpDesg = new Label();

Label lblEmpDoj = new Label();

PictureBox picBox = new PictureBox();

callback onCreate(Container container){

hzPanel.setColumnWidth(0, Sizing.PERCENTS, 20);

hzPanel.setColumnWidth(1, Sizing.PERCENTS, 60);

hzPanel.setColumnWidth(2, Sizing.PERCENTS, 20);

hzPanel.setPanelHeight(Sizing.PIXELS,40);

hzPanel.setBackColor(Colors.AntiqueWhite);

hzPanel.add(lblEmpDesg,null);

hzPanel.add(lblEmpDoj,null);

picBox.setImage(Images.minus.getImage());

hzPanel.add(picBox,"valign=center,vfill=fill");

add(hzPanel,"hfill=fill, vfill=fill,valign=center");

setBackColor(Colors.Chartreuse);

callback onCellInfo(TableViewCell cell, Cell info, int group, int row){

AMP™ Studio Developer Guide 138


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

DataRow dtRowLoc = null;

if(scrTblView.arrRows != null)

dtRowLoc = scrTblView.arrRows.getItem(row);

if( dtRowLoc == null){

return;

}else{

String empDesg = dtRowLoc.getString(0);

lblEmpDesg.setText(empDesg);

lblEmpDoj.setText(dtRowLoc.getString(1));

dtRowLoc = null;

The output for a Sticky Table (Grouped) would be:

Text Controls

Sample code snippet for a Text Control


TextField txtFldSearch = new TextField();

TextArea txtAraStoreDetails = new TextArea();

AMP™ Studio Developer Guide 139


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Text Area
A TextArea is a multi-line text input control.

Sample code snippet for a Text Area


TextArea txtArea = new TextArea();

txtArea.setText("TextAre….");

The output for a Text Area would be:

ToolBar
A ToolBar is a strip that usually contains images (ToolbarButton instances). It is often called a slider. The ToolBarButton
is a button placed on a ToolBar.

Sample code snippet for a ToolBar


ToolBar toolBar = new ToolBar();

ToolBarButton btn1 = new ToolBarButton();

ToolBarButton btn2 = new ToolBarButton();

ToolBarButton btn3 = new ToolBarButton();

ToolBarButton btn4 = new ToolBarButton();

btn1.setFocusedImage(Images.plus_focused.getImage());

btn1.setImage(Images.plus.getImage());

btn1.setSelectedImage(Images.plus.getImage());

btn2.setFocusedImage(Images.minus_focused.getImage());

btn2.setImage(Images.minus.getImage());

btn2.setSelectedImage(Images.minus.getImage());

btn3.setFocusedImage(Images.multiply_focused.getImage());

AMP™ Studio Developer Guide 140


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

btn3.setImage(Images.multiply.getImage());

btn3.setSelectedImage(Images.multiply.getImage());

btn4.setFocusedImage(Images.equal_focused.getImage());

btn4.setImage(Images.equal.getImage());

btn4.setSelectedImage(Images.equal.getImage());

toolBar.addButton(btn1);

toolBar.addButton(btn2);

toolBar.addButton(btn3);

toolBar.addButton(btn4);

toolBar.setButtonSpacing(5);

toolBar.setNavigationType(ToolBar.SCROLLER);

The output for a toolbar would be:

RadioGroup
A RadioGroup is a type of toolbar that displays toolbar buttons in a "pressed" mode, indicating which ToolbarButton has
been selected.

Sample code snippet for a RadioGroup


RadioGroup rdGrpSlider = new RadioGroup();

ToolBarButton tlBrBtnSignIn = new ToolBarButton();

ToolBarButton tlBrBtnMyAccounts = new ToolBarButton();

ToolBarButton tlBrBtnTransferMoney = new ToolBarButton();

ToolBarButton tlBrBtnBillPay = new ToolBarButton();

AMP™ Studio Developer Guide 141


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

tlBrBtnSignIn.setFocusedImage(Images.sicSignIn_f.getImage());

tlBrBtnSignIn.setImage(Images.sicSignIn_u.getImage());

tlBrBtnSignIn.setSelectedImage(Images.sicSignIn_s.getImage());

tlBrBtnMyAccounts.setFocusedImage(Images.sicAccounts_f.getImage());

tlBrBtnMyAccounts.setImage(Images.sicAccounts_u.getImage());

tlBrBtnMyAccounts.setSelectedImage(Images.sicAccounts_s.getImage());

..

rdGrpSlider.setNavigationType(ToolBar.SCROLLER);

rdGrpSlider.addButton(tlBrBtnSignIn);

rdGrpSlider.addButton(tlBrBtnMyAccounts);

rdGrpSlider.addButton(tlBrBtnTransferMoney);

rdGrpSlider.addButton(tlBrBtnBillPay);

The output for a RadioGroup would be:

Browser/HTML Control
A Browser is a Web browser.

Sample code snippet for a Browser Control


Screen {

Browser browser = new Browser();

Button btnSetHtml = new Button();

Button btnSetUrl = new Button();

AMP™ Studio Developer Guide 142


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Button btnStart = new Button();

Button btnStop = new Button();

HorizontalPanel hzPanel = new HorizontalPanel();

HorizontalPanel hzPanel1 = new HorizontalPanel();

HorizontalPanel hzPanel2 = new HorizontalPanel();

VerticalPanel vertPanel = new VerticalPanel();

callback onCreate(Container container){

btnSetHtml.setText("Set Html");

btnSetUrl.setText("Set Url");

btnStart.setText("Start");

btnStop.setText("Stop");

hzPanel.setColumnWidth(0,Sizing.PERCENTS,100);

hzPanel.setPanelHeight(Sizing.PERCENTS,80);

hzPanel1.setColumnWidth(0,Sizing.PERCENTS,50);

hzPanel1.setColumnWidth(1,Sizing.PERCENTS,50);

hzPanel2.setColumnWidth(0,Sizing.PERCENTS,50);

hzPanel2.setColumnWidth(1,Sizing.PERCENTS,50);

hzPanel.add(browser,"hfill=fill,vfill=fill");

hzPanel1.add(btnSetHtml,"hfill=fill");

hzPanel1.add(btnStart,"hfill=fill");

hzPanel2.add(btnSetUrl,"hfill=fill");

hzPanel2.add(btnStop,"hfill=fill");

vertPanel.add(hzPanel);

vertPanel.add(hzPanel1);

vertPanel.add(hzPanel2);

add(vertPanel,"hfill=fill,vfill=fill");

callback btnSetHtml onClick(Control c){

browser.setHtml("<html><body><h2><font color=\"green\">Antenna Softwares</


font><h2></body></html>");

callback btnSetUrl onClick(Control c){

AMP™ Studio Developer Guide 143


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

browser.setURL("http://www.antennasoftware.com");

callback btnStart onClick(Control c){

browser.start();

callback btnStop onClick(Control c){

browser.stop();

The output for a Browser Control would be:

Title Bar Control

Sample code snippet for a Title Bar Control


Screen {

TitleBarStyle titleBarStyle = new TitleBarStyle();

Action leftAction = new Action();

Action rightAction = new Action();

........

callback onCreate(Container container){

leftAction.setText(" Close ");

AMP™ Studio Developer Guide 144


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

leftAction.setBackground(Background.createHorizontalTiledImageRoundedBackground
(Images.image_activeBtnR.getImage(),3,3));

leftAction.setFocusedBackground(Background.createHorizontalTiledImageRoundedBack
ground(Images.image_activeBtnG.getImage(),3,3));

rightAction.setText(" About ");

rightAction.setBackground(Background.createHorizontalTiledImageRoundedBackground
(Images.image_activeBtnR.getImage(),3,3));

rightAction.setFocusedBackground(Background.createHorizontalTiledImageRounded
Background(Images.image_activeBtnG.getImage(),3,3));

setTitle("Home Screen");

titleBarStyle.setBackground(Background.createHorizontalTiledImageRoundedBackgrou
nd(Images.image_Header.getImage(),2,2));

setTitleBarStyle(titleBarStyle);

setLeftTitleBarAction(leftAction);

setRightTitleBarAction(rightAction);

showTitleBar(true,false);

The output for a Title Bar Control would be:

Map Control
A Map control displays an interactive map.

Sample code snippet for a Map Control


Screen {

MapField mfield = new MapField();

Label lbllng = new Label();

AMP™ Studio Developer Guide 145


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Label lbllat = new Label();

NumericField numlng = new NumericField();

NumericField numlat = new NumericField();

Button btnFind = new Button();

HorizontalPanel headerPanel = new HorizontalPanel();

callback onCreate(Container container){

headerPanel.setColumnWidth(0,Sizing.PERCENTS,25);

headerPanel.setColumnWidth(1,Sizing.PERCENTS,25);

headerPanel.setColumnWidth(2,Sizing.PERCENTS,25);

headerPanel.setColumnWidth(3,Sizing.PERCENTS,25);

lbllng.setText(" Longitude: ");

lbllat.setText(" Lattitude: ");

headerPanel.add(lbllat,"hfill=fill");

headerPanel.add(numlat,"hfill=fill");

headerPanel.add(lbllng,"hfill=fill");

headerPanel.add(numlng,"hfill=fill");

add(headerPanel,"hfill=fill,vfill=fill");

btnFind.setText(" Find ");

add(btnFind,"halign=center");

add(mfield,"valign=top,hfill=fill,vfill=fill");

callback btnFind onClick(Control c){

mfield.clearLocations();

double longitude = Platform.parseDouble(numlng.getText());

double latitude = Platform.parseDouble(numlat.getText());

MapAnnotation mapAnot = new MapAnnotation();

mapAnot.setShowCallout(true);

mapAnot.setEnabled(true);

mapAnot.setTitle("Your Location");

mapAnot.setSubTitle("Here is it");

mapAnot.setImageType(MapAnnotation .IMAGE_TYPE_DEFAULT);

mfield.addLocation(latitude,longitude, mapAnot);

AMP™ Studio Developer Guide 146


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

The output for a Map control would be:

Animated Image Control (Customizable Animation)


This control allows a user to view animated images on a screen.

Sample code snippet for an AnimationField


Screen {

AnimatedImageList animImgList = new AnimatedImageList ();

AnimationField animField = new AnimationField();

..................

callback onCreate(Container container){

animImgList.addImage(Images.anim1.getImage());

animImgList.addImage(Images.anim2.getImage());

animImgList.addImage(Images.anim3.getImage());

animImgList.addImage(Images.anim4.getImage());

animImgList.setDuration(1000);

animImgList.setRepeatCount(10);

animField.applyImageList(animImgList);

AMP™ Studio Developer Guide 147


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

add(animField,"hfill=fill,vfill=fill");

..............

callback btnStart onClick ( Control c ){

animField.startAnimating();

callback btnStop onClick ( Control c ){

animField.stopAnimating();

callback btnStop onClick ( Control c ){

animField.stopAnimating();

The output for an Animated Image control would be:

Horizontal Page Swipe Control

Sample code snippet for a Horizontal Page Swipe Control


Screen {

PageableHorizontalPanel pgHrPnl = new PageableHorizontalPanel();

VerticalPanel vertPanel1 = new VerticalPanel();

VerticalPanel vertPanel2 = new VerticalPanel();

VerticalPanel vertPanel3 = new VerticalPanel();

VerticalPanel vertPanel4 = new VerticalPanel();

Label lbl1 = new Label();

AMP™ Studio Developer Guide 148


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Label lbl2 = new Label();

Label lbl3 = new Label();

Label lbl4 = new Label();

callback onCreate(Container container){

lbl1.setText("Beverages");

lbl1.setForeColor(Colors.White);

lbl2.setText("Jwellery");

lbl2.setForeColor(Colors.White);

lbl3.setText("Furniture");

lbl3.setForeColor(Colors.White);

lbl4.setText("Clothes");

lbl4.setForeColor(Colors.White);

vertPanel1.add(lbl1);

vertPanel2.add(lbl2);

vertPanel3.add(lbl3);

vertPanel4.add(lbl4);

vertPanel1.setBackColor(Colors.MediumOrchid);

vertPanel2.setBackColor(Colors.LightSkyBlue);

vertPanel3.setBackColor(Colors.Crimson);

vertPanel4.setBackColor(Colors.SlateGray);

pgHrPnl.setPage(vertPanel1,0);

pgHrPnl.setPage(vertPanel2,1);

pgHrPnl.setPage(vertPanel3,2);

pgHrPnetPage(vertPanel4,3);

add(pgHrPnl,"hfill=fill,vfill=fill");

AMP™ Studio Developer Guide 149


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

The output for a Horizontal Page Swipe Control would be:

Video Player

Sample code snippet for a Video Player


Screen {

MediaControl medControl = new MediaControl();

Button btnShowPrev = new Button();

Button btnLoadVideo1 = new Button();

Button btnLoadVideo2 = new Button();

Button btnPlay = new Button();

Button btnPause = new Button();

Button btnStop = new Button();

HorizontalPanel hzPanel = new HorizontalPanel();

HorizontalPanel hzPanelControls = new HorizontalPanel();

Label lblStatus = new Label();

callback onCreate(Container container){

btnLoadVideo1.setText("Video 1");

btnLoadVideo2.setText("Video 2");

btnPlay.setText("Play");

btnPause.setText("Pause");

btnStop.setText("Stop");

lblStatus.setText("Video Player");

lblStatus.setForeColor(Colors.Tomato);

hzPanel.setColumnWidth(0,Sizing.PERCENTS,50);

hzPanel.setColumnWidth(1,Sizing.PERCENTS,50);

hzPanel.add(btnLoadVideo1,"hfill=fill");

hzPanel.add(btnLoadVideo2,"hfill=fill");

AMP™ Studio Developer Guide 150


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

hzPanelControls.setColumnWidth(0,Sizing.PERCENTS,33);

hzPanelControls.setColumnWidth(1,Sizing.PERCENTS,33);

hzPanelControls.setColumnWidth(2,Sizing.PERCENTS,33);

hzPanelControls.add(btnPlay,"hfill=fill");

hzPanelControls.add(btnPause,"hfill=fill");

hzPanelControls.add(btnStop,"hfill=fill");

medControl.setAutoPlay(false);

add(hzPanel,"hfill=fill");

add(hzPanelControls,"hfill=fill");

add(lblStatus,"halign=right");

add(medControl,"hfill=fill,vfill=fill");

callback btnLoadVideo1 onClick(Control c){

medControl.setResourceContent(Videos.video_sample);

callback btnLoadVideo2 onClick(Control c){

medControl.setResourceContent(Videos.video_sample2);

callback btnPlay onClick(Control c){

boolean ready = medControl.isReadyToPlay();

if(ready==true)

medControl.play();

else

info("MediaPlayer is not Ready");

callback btnPause onClick(Control c){

medControl.pause();

callback btnStop onClick(Control c){

medControl.stop();

AMP™ Studio Developer Guide 151


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

The output for a Video Player would be:

Document Viewer

Sample code snippet for a Document Viewer


Screen {

DocumentPreview docPrev = new DocumentPreview ();

Button btnOptions = new Button();

Button btnShowPrev = new Button();

Button btnLoadPdf1 = new Button();

Button btnLoadPdf2 = new Button();

Button btnLoadPdf3 = new Button();

Button btnLoadPdf4 = new Button();

Button btnLoadUrl = new Button();

boolean flag = false;

AnchorPosition ancPos1 = new AnchorPosition ();

HorizontalPanel hzPanel = new HorizontalPanel();

Label lblStatus = new Label();

callback onCreate(Container container){

btnLoadPdf1.setText("PDF 1");

btnLoadPdf2.setText("PDF 2");

AMP™ Studio Developer Guide 152


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

btnLoadPdf3.setText("PDF 3");

btnLoadPdf4.setText("PDF 4");

btnLoadUrl.setText("Load From Url");

btnOptions.setText("Show Options");

btnShowPrev.setText("Show Document Preview");

btnShowPrev.setEnabled(false);

btnOptions.setEnabled(false);

lblStatus.setText("Document Preview");

lblStatus.setForeColor(Colors.Blue);

ancPos1.setAnchor(btnOptions);

hzPanel.setColumnWidth(0,Sizing.PERCENTS,25);

hzPanel.setColumnWidth(1,Sizing.PERCENTS,25);

hzPanel.setColumnWidth(2,Sizing.PERCENTS,25);

hzPanel.setColumnWidth(3,Sizing.PERCENTS,25);

hzPanel.add(btnLoadPdf1,"hfill=fill");

hzPanel.add(btnLoadPdf2,"hfill=fill");

hzPanel.add(btnLoadPdf3,"hfill=fill");

hzPanel.add(btnLoadPdf4,"hfill=fill");

add(hzPanel,"hfill=fill");

add(btnLoadUrl,"hfill=fill");

add(btnShowPrev,"hfill=fill");

add(btnOptions,"hfill=fill");

add(lblStatus,"halign=center");

callback btnLoadPdf1 onClick(Control c){

btnShowPrev.setEnabled(false);

btnOptions.setEnabled(false);

lblStatus.setText("");

flag = docPrev.startLoadingDocument(Documents.String_pdf);

callback btnLoadUrl onClick(Control c){

btnShowPrev.setEnabled(false);

AMP™ Studio Developer Guide 153


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

btnOptions.setEnabled(false);

lblStatus.setText("");

flag = docPrev.startLoadingDocumentFromURL("http://blog.timesunion.com/success/
files/2010
/11/success_baby.jpg");

callback btnOptions onClick(Control c){

flag = docPrev.showOptionsMenuFrom(ancPos1,true);

callback btnShowPrev onClick(Control c){

flag = show(docPrev,true);

callback docPrev onLoadStarted ( DocumentPreview c , int type , String value ) {

lblStatus.setText("Loading.....");

callback docPrev onLoadFinished( DocumentPreview c , int type , String value ) {

lblStatus.setText("--Loaded--");

btnShowPrev.setEnabled(true);

btnOptions.setEnabled(true);

callback docPrev onLoadFailed( DocumentPreview c , int type , String value ) {

lblStatus.setText("--Loading Failed !--");

AMP™ Studio Developer Guide 154


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

The output while retrieving a document resource would be:

The output while retrieving a document from a URL would be:

AMP™ Studio Developer Guide 155


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Callbacks for UI Controls


This section describes callbacks for UI Controls.

Add Visual Style


This callback is used to set a style on all UI Controls and Panels. Style refers to font, font size, foreground/background
colors, and justification (left/right/center).

On Click
Callback when a control is clicked on.

On Focus Gained
Called when a control gains focus.

On Focus Lost
Called when a control loses focus.

On Value Change
Called when a control changes its value.

Data Attributes
The following data attributes are included when a callback is available for Data:

■ Binary
■ Boolean
■ Currency
■ Date
■ Float
■ ID
■ Integer
■ String
■ Time
■ Timestamp

AMP™ Studio Developer Guide 156


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Sample code snippet for Strings:


//Strings

String selectedFeature;

String selectedFeatureID = "";

String selectedCategory;

String selectedCategoryID = "";

String txtSearched;

String NONE = "none";

StringReference fromScreen;

String SEARCH_HERE = "\t Search your product(s) here....";

//int

int selectedFeatureIndex = 0;

int selectedCategoryIndex = 0;

//boolean

boolean isproductSearched = true;

boolean isFeaturedProduct = false;

boolean isCategory = false;

Get Value
This callback is available for all Data attributes.

Row Changed
This event is generated whenever a row or rowset being used by models is changed by some other mechanism (such as
sync) or changed elsewhere within the application.

AMP™ Studio Developer Guide 157


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Panel Callbacks
This section describes callbacks that are available for all Panels:

■ On Activate
■ On Deactivate
■ On Open
■ On Close
■ On Create
■ On Click
■ On Orientation Change

On Activate
This callback is available for all panels. This is called when a panel or a screen appears on the top of a screen and some of
the child controls receive user input focus.

On DeActivate
This callback is available when a panel or a screen loses user in/out focus.

On Open
This callback is called when a panel or a screen is opened.

callback contentsPanel onOpen ( Container source ) {

Label lbl = new Label();

lbl.setText("onOpen, you can edit the panel");

contentsPanel.add(lbl);

On Close
This callback is called when a panel or a screen is closed.

callback contentsPanel onClose ( Container source ) {

scrHome.lblStatus.setText("Returned");

On Create
This callback is called when a panel or a screen is created but not yet opened or displayed.

AMP™ Studio Developer Guide 158


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

On Selection Changed
This callback is called when the selection is changed (for example, gains or loses focus).

On Orientation Change
This callback is called when a screen changes its orientation from Portrait to Landscape mode or vice versa.

Messaging Callbacks
Messaging callbacks reference integration with a native email client. The following callbacks are supported as part of
email integration.

Phone Callbacks
Phone callbacks reference integration with a native phone dialer. This callback provides information about whether the
call is incoming, outgoing, or being terminated.

Login Callbacks
The following callbacks are available in the Login screen as well as in the UI Project.

On LoggedIn
This callback is called when a user is successfully logged in.

callback onLoggedIn(){

scrHome.push();

On LoggedOut
This callback is called when a user is logged out.

callback onLoggedOut(int int_){

scrLogin.lblStatus.setText("Enter ID and Password");

scrLogin.push();

AMP™ Studio Developer Guide 159


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

On Login Completed
This callback is called when the login process is completed. (It could be successful or failed.)

callback onLoginCompleted(String string_){

scrLogin.btnLogin.setEnabled(true);

On Login Failed
This callback is called when the Login process failed.

callback onLoginFailed(int int_, String string_){

scrLogin.lblStatus.setText("Login Failed");

On Login Starting
This callback is called when the login process is started. It can be used to show activity while this has started but the
process has not been completed.

callback onLoginStarting(){

scrLogin.lblStatus.setText("Logging In....");

scrLogin.btnLogin.setEnabled(false);

Data Store Callbacks


The following callbacks are related to activities with datastore.

On Data Deleted
This callback is called when the datastore is completely deleted.

On Data Ready
This callback is called when the datastore has some data.

UIProject {

Practice1.VDSC dp = new Practice1.VDSC();

PasswordField passwordField = new PasswordField("dexterra");

int deviceWidth= Device.getScreenWidth();

int deviceHeight= Device.getScreenHeight();

//services

AMP™ Studio Developer Guide 160


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

MessageService messageService = getMessageService();

Log logger =getLog();

BarChartSample scrBar

callback onStart(PushedData pushedData){

setUser("Test");

login();

messageService.start(true);

setImageBundle();

openDP(passwordField.getPassword());

dp.startFDR("MANUAL_FDR");

dp.startSync("MANUAL_SYNC");

scrBar = new BarChartSample();

callback dp onDataReady(){

scrBar.push();

On Lease About to Expire


This callback is called when the Lease is about to expire.

On Lease Expired
This callback is called when the datastore lease has expired. No further access to datastore is allowed until the lease is
renewed.

On Lease Renewed
This callback is called when the lease is successfully renewed.

On Rowset Event
This callback is called when the rowset has been modified or has become dirty.

On Row Event
This callback is called when a specific row has been modified or has become dirty.

On Sync Event
This callback is called whenever there is a sync event. A sync event can be started by any of the following methods:

AMP™ Studio Developer Guide 161


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

■ During the synchronization process


■ Upload of each packet
■ Start of the download process
■ Receiving and processing download packet and synchronization is completed
callback dp onSyncEvent(SyncEvent event, String description) {

int eventType = event.getEventType();

switch(eventType) {

case SyncEvent.DATADOWNLOAD_INCEND:

scrHome.prgBar.setValue(dp.getCurrentSyncSegment());

break;

case SyncEvent.DATADOWNLOAD_INCSTART:

scrHome.prgBar.setMax(dp.getTotalSyncSegments());

break;

NOTE: Refer to sample code given for Progress Bar on page 126.

Mobile Web Service Callbacks (VRPC)


The following callbacks are available when a Mobile Web Service (VRPC) is initiated.

On Request Sent
This callback is called when a VRPC request has been sent.

On Request Failed
This callback is called when a request for a VRPC was not sent.

On Data Ready
This callback is called when a VRPC response has come back.

AMP™ Studio Developer Guide 162


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Message Service Callbacks


The following callbacks are available to display the status of the message service and connection to servers.

UIProject {

Practice1.VDSC dp = new Practice1.VDSC();

PasswordField passwordField = new PasswordField("dexterra");

int deviceWidth= Device.getScreenWidth();

int deviceHeight= Device.getScreenHeight();

//services

MessageService messageService = getMessageService();

Log logger =getLog();

//Status variables

String serverStatus = "";

String serverReqStatus = "";

..

callback messageService onServerAvailable(){

serverStatus = "available";

callback messageService onServerRecovering(){

serverStatus = "recovering";

callback messageService onServerStarting(){

serverStatus = "starting";

callback messageService onServerRequestAttempted(){

serverReqStatus = "attempted";

callback messageService onServerRequestFailed(int code){

serverReqStatus = "failed with code "+code;

String getServerStatus(){

return serverStatus;

AMP™ Studio Developer Guide 163


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

String getServerReqStatus(){

return serverReqStatus;

NOTE: The above two functions can be called from any screen to get the corresponding status.

On Server Available
This callback is called when the Server is available for Sync or Mobile Web Service (VRPC).

On Server Recovering
This callback is called when the client lost connection to its server and is in process of reconnecting.

On Server Unavailable
This callback is called when the server becomes unavailable and no sync or VRPC requests can be sent.

On Server Starting
This callback is called when the client is attempting to connect to the server for the first time.

On Server Request Attempted


This callback is called when the client has already attempted to make a connection to the server.

On Server Request Failed


This callback is called when a request to connect to a server has failed.

UI Project Callbacks
The following callbacks are available at the project or application level.

On Start
This callback is called when an application has started.

On Stop
This callback is called when an application is being terminated.

AMP™ Studio Developer Guide 164


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

On Day Change
This callback is called whenever a day changes on the device so you can refresh date-related screens.

The following callbacks are available at the project or application level.

UIProject {

Practice1.VDSC dp = new Practice1.VDSC();

PasswordField passwordField = new PasswordField("dexterra");

int deviceWidth= Device.getScreenWidth();

int deviceHeight= Device.getScreenHeight();

//services

MessageService messageService = getMessageService();

Log logger =getLog();

//Global variables

Date todaysDate;

..

callback onStart(PushedData pushedData){

setUser("Test");

login();

messageService.start(true);

setImageBundle();

openDP(passwordField.getPassword());

dp.startFDR("MANUAL_FDR");

dp.startSync("MANUAL_SYNC");

todaysDate = Platform.createDate();

scrHome = new HomeScreen();

scrHome.push();

callback onDayChanged(){

todaysDate = Platform.createDate();

AMP™ Studio Developer Guide 165


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Application Upgrades
This section explains how to set the properties on the server.

Version Management
For version management follow the steps below. Add the following section on the cluster config (located at
server\vas\config):

[AUTH $ APPLICATION]

CLASS = com.vaultus.auth.toolkit.apps.PropertyAppManager

[AUTH $ APPLICATION $ AppName]

LATEST_URL = www.appdownload.com/idirectory/defaultlink

LATEST_VERSION = 0.0.40

MESSAGE = Special message for this particular OS under this app name

REQUIRED_VERSION = 0.0.38

[AUTH $ APPLICATION $ AppName $ IOS]

LATEST_URL = www.appdownload.com/idirectory/iphoneos1

LATEST_VERSION = 0.0.41

MESSAGE = Special message for iphone OS

REQUIRED_VERSION = 0.0.38

[AUTH $ APPLICATION $ AppName $ android]

LATEST_URL = www.appdownload.com/idirectory/android

LATEST_VERSION = 0.0.41

MESSAGE = Special message for android OS

REQUIRED_VERSION = 0.0.38

[AUTH $ APPLICATION $ AppName $ blackberry]

LATEST_URL = www.appdownload.com/idirectory/blackberry

LATEST_VERSION = 0.0.45

MESSAGE = Special message for blackberry OS

REQUIRED_VERSION = 0.0.45

AMP™ Studio Developer Guide 166


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

The following are supporting notes for the code sample:

1 AppName represents the name of the app mentioned on the jobjar. It is the value before DP. For example,
IDIRECTORY

2 [AUTH $ APPLICATION $ AppName] - Is the section for the device that is not specified in the cluster.config

3 [AUTH $ APPLICATION $ AppName $ IOS] - Is the section for iPhone OS

4 [AUTH $ APPLICATION $ AppName $ android] - Is the section for Android

5 [AUTH $ APPLICATION $ AppName $ blackberry] - Is the section for BlackBerry

6 LATEST_URL- Is the URL where users can download the application.

7 For Mandatory Upgrade, set the REQUIRED_VERSION to an app version greater than the version that the user
has on the device.

8 For Optional Upgrade, set the LATEST_VERSION to an app version greater than the version that the user has
on the device.

9 If the app version in the device is less than the REQUIRED_VERSION specified, then the user is presented
with a message when he logs in.

Sample code snippet for application upgrade


callback messageService onServerRequestDenied(ApplicationPermission applicationPermission)
{

if (displayServerUpgradeMsg) {

if(applicationPermission.getStatus() == ApplicationPermission.STATUS_MUST_UPGRADE){

Array arOptions = new Array();

arOptions.addItem("Upgrade");

ask(false, null, applicationPermission.getMessage(), arOptions, 0);

if( Device.isBlackberry() ) shutdown();

goToWebPage(applicationPermission.getLatestUrl());

if(applicationPermission.getStatus() == ApplicationPermission.STATUS_MUST_UPGRADE){

Array arOptions = new Array();

arOptions.addItem("Upgrade");

ask(false, null, applicationPermission.getMessage(), arOptions, 0);

if( Device.isBlackberry() ) shutdown();

goToWebPage(applicationPermission.getLatestUrl());

AMP™ Studio Developer Guide 167


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

callback messageService onServerRequestGranted(ApplicationPermission


applicationPermission) {

if (displayServerUpgradeMsg) {

if(applicationPermission.getStatus() == ApplicationPermission.STATUS_CAN_UPGRADE){

Array arOptions = new Array();

arOptions.addItem("Continue");

arOptions.addItem("Upgrade");

int response = ask(false, null, applicationPermission.getMessage(), arOptions,


1);

if(response == 1) {

if(Device.isBlackberry()) shutdown();

goToWebPage(applicationPermission.getLatestUrl());

if(applicationPermission.getStatus() == ApplicationPermission.STATUS_CAN_UPGRADE){

Array arOptions = new Array();

arOptions.addItem("Continue to Login");

arOptions.addItem("Upgrade");

int response = ask(false, null, applicationPermission.getMessage(), arOptions,


1);

if(response == 1) {

if( Device.isBlackberry() ) shutdown();

goToWebPage(applicationPermission.getLatestUrl());

AMP™ Studio Developer Guide 168


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

mScript Basics

Comments
Comments are parts of code that are not executed. Comments should be written to make the code easier to understand.
There are two types of comments: single line and multiline.

Single line comment


Any text following // until the end of line is treated as a comment.

Multiline comment
Any text within /* and */ is treated as a comment across multiple lines.

Primitive Data Types


boolean, char, byte, short, int, long, float, double

boolean
A boolean can have the value of true or false.

char
A char can have a value of a single character in single quotes: 'a'

In some cases, a char must contain the value of a single quote. However, writing ''' is illegal. In this case, use '\''

\' is called an escape sequence for single quote.

Other useful escape sequences are:

\n for a new line

\t for a tab

byte
A byte has an 8-bit numeric value between the minimum value of -128 and maximum value of +127. A byte number is a
number that cannot have a decimal component. For example 1.0, 0.1, -0.2, 1.1 are not byte numbers, 1, -2 are byte
numbers.

short
A short has a 32-bit numeric value between the minimum value of -32,768 and maximum value of +32,767. A short
number cannot have a decimal component.

AMP™ Studio Developer Guide 169


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

int
An int has a 32-bit numeric value between the minimum value of -2,147,483,648 and maximum value of +2,147,483,647.
An int number cannot have a decimal component.

long
A long has a 64-bit numeric value between the minimum value of -9223372036854775808 and maximum value of +
9223372036854775807. A long number cannot have a decimal component.

float
A float has a numeric value with a decimal component. For example 0.1, -0.2, 1.0, 1.1 are float numbers. A float number
is a 32-bit number.

double
A double has a numeric value with a decimal component. A double number is a 64-bit number.

Variables
A variable declaration must contain the variable's type and name:

boolean b;

This code declares a variable named b whose type is boolean. It means that operations of other data types are invalid on b.
For example, it is invalid to write b + 1 because adding a number is a mathematical and not a boolean operation.

After a variable is declared, it can be used and its value can be changed.

NOTE: The use of a semicolon in the end of a statement is mandatory.

In order to use a variable, it must have a value. A value can be assigned during the declaration:

char c = 'b';

This line of code declares a variable c of type char with the initial value 'b'.

A declared variable can be assigned a value later:

short s;

s = 0;

AMP™ Studio Developer Guide 170


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Numeric Primitive Data Types


There are six numeric data types: byte, short, int, long, float, and double.

Four of the types are integral types: byte, short, int, long. Two types are floating point types: float and double.

When declaring a variable, choose a type best suited for the use of the variable. The first decision should be whether a
variable is a whole number or it will have a fractional part. For example, if a variable holds the number of countries, it
should be integral. If a variable holds a price, it should probably be a floating-point number.

The second decision is the range of the value of a variable. For example, if a variable holds the number of countries, it
should be short. If it holds the world population, it must be long.

Operations
This section describes the following operations:

■ Basic Numeric Operations


■ Remainder Operator %
■ Increment and Decrement Operators
■ Assignment Operators
■ Compound Assignment Operators
■ Bitwise Operations
■ Equality Operators
■ Relational Operators
■ Conditional Operators

Basic Numeric Operations


Plus (+), minus (-), division (/) and multiplication (*) can be performed on numeric types.

For example 2 + 3 is a numeric operation.

int a = 2;

int b = 3;

int result = a + b;

Several operations can be chained:

result = a * b / 6;

The commonly known rules of order of operations and grouping by parentheses are used in mScript.

AMP™ Studio Developer Guide 171


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Remainder Operator %
This returns the remainder of division. For example, 5 % 2 = 1.

Increment and Decrement Operators


The increment operator ++ is used to increment the value of a variable by 1:

int i = 0;

i++;

i++;

In this code, a variable i is created with the initial value 0 and then its value is increased by 1. As a result, its value equals
1. Then its value is increased by 1 again and equals 2.

This operator is shorthand for i = i + 1 (add 1 to i and store the resulting value in i).

The decrement operator -- is used to decrement the value of a variable by 1.

The increment/decrement operator can be placed before or after a variable. The position of the operator is important as
shown in the following examples:

int i = 0;

int j = ++i;

In this code, the value of i is increased before the assignment of its value to j. The previous code is the same as:

int i = 0;

i = i + 1;

int j = i;

The value of j is 1.

The following code behaves differently:

int i = 0;

int j = i++;

In this code, the value of i is increased after it is assigned to j. The previous code is the same as:

int i = 0;

int j = i;

i = i + 1;

The value of j is 0.

AMP™ Studio Developer Guide 172


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Assignment Operators
The basic assignment operator is =. It is used to assign a value to a variable:

int i = 6;

i = i + 8;

Compound Assignment Operators


Multiply and assign (*=), divide and assign (/= ), remainder and assign (%=), add and assign (+=), subtract and
assign (-=).

Example:

a += b is the same as a = a + b. It means add the value of b to a.

Bitwise Operations
mScript has bitwise operators (& | ^ ~), arithmetic shifts (<< >>) and logical right shift (>>>).

Equality Operators

Equals (==) returns true if the value of the left side and the value of the right side are equal.

For example:

int a = 7;

int b = 7;

boolean result = a == b;

The result will be true because both a and b have the value 7;

int a = 7;

int b = 8;

boolean result = a == b;

The result will be false because the values of a and b are not the same.

Not equal (!=) returns true if the left side and the right side are not equal.

int a = 7;

int b = 8;

boolean result = a != b;

The result will be true because a and b are not equal.

AMP™ Studio Developer Guide 173


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Relational Operators
Less than (<) , greater than (>) , less or equal (<=), greater or equal (>=)

int a = 7;

int b = 8;

boolean result = a < b;

The result will be true because a is less than b.

Conditional Operators
And (&&), or (||) compare two Boolean expressions:

boolean a = true;

boolean b = true;

boolean result = a && b;

The result will be true because both a and b are true;

Conditional operators can be chained:

result = a && b || c

In this case they are executed in the order in which they are written as in the case of algebraic expressions. So the previous
code is the same as:

boolean temp = a && b;

result = temp || c;

Conditional expressions can be grouped by parentheses:

result = a && (b || c)

This is equivalent to:

boolean temp = b || c;

result = a && c;

Where a is &&-ed with the result of b || c

AMP™ Studio Developer Guide 174


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Conditions
Conditional clauses exist to direct an algorithm in a certain direction in certain conditions. For example, you may want to
execute certain code only when the number of rows returned by a query is greater than 100:

if(rowCount > 100)

//some code

There are three forms of conditions: if, switch and the ?: expression.

if
The format of the if clause is this:

if(condition) expression;

condition is any expression whose value is true.

A condition may be a boolean variable:

boolean b = true;

if(b == true) …

In this case, you can write:

if(b)…

because the value of b is boolean (true/false) and testing if its value is true or false is unnecessary.

Relational (< > <= >=) operators also return a boolean value. Therefore it is possible to compare numeric values:

int c = 9;

int d = 10;

if(c <= d)…

Several conditions may be chained by && or ||:

boolean b = true;

int c = 9;

int d = 10;

int e = 11;

int f = 12;

if(b && (c > d || e >= f)) …

AMP™ Studio Developer Guide 175


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

The code that follows the condition is the code that is executed when this condition is true. It can be one expression:

if(a == b) i++;

Increase the value of i by 1 when a equals b.

When several expressions must follow the condition, they must be placed inside braces or curly brackets:

if(a == b){

i++;

j--;

It is a good practice to always use the curly brackets because this makes the code easier to understand and prevents
mistakes.

When a condition is not true, the algorithm may follow another path. In this situation, else may be used:

if(condition){

else{

When several conditions must be tested, use else if:

if(a){

else if(b){

else if(c){

else{

}
AMP™ Studio Developer Guide 176
ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

There can be several else if clauses.

switch
A switch statement takes an int value and tests if it is equal to a list of int numbers one by one:

switch(i){

case 0: ….

break;

case 1: ….

break;

default: …

In this case, if the value of i equals 0, the execution goes into the block of case 0. If the value of i equals 1, then the block
of case 1 is executed.

Always use a break at the end of each case block.

If none of the case conditions is met, the block of default is executed. The use of default is not mandatory, but it is a good
practice because it leaves no holes.

?:
A brief form of if-else clause is condition ? if-true : if-false

For example:

a ? 1 : 0

This expression means: if a is true return 1 else return 0.

Although compared to if-else which can have multiple else if blocks, this clause seems less powerful, this clause unlike if-
else can return a value.

For example:

int i = a ? 1 : 0;

In this case i will be equal to 1 if a is true or 0 if a is false.

The if-else clause does not return a value that can be directly assigned to a variable.

This clause may lead to unreadable code. Use it only when necessary.

Block and Scope


Code inside curly brackets is called a block. A variable declared in a block is visible only in this block.

AMP™ Studio Developer Guide 177


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

For example

if(a != b){

int i = 0;

else{

int j = i;

int k = i;

In this example, i is declared in the if block and it will be visible neither in else block nor outside the whole if-else clause.
So both j = i and k = i will throw errors.

Loops
When the same block of code must be executed sequentially a number of times, use loops. There are three types of loops:
for, while, do-while. All types of loop keep repeating their block of code until some condition is met.

for

The format is:

for(initial expression; final condition; expression performed after each loop){

expressions to execute in the loop

An initial expression is any expression that is performed before entering the first loop. Usually it is used to set the initial
value of a counter used to count the number of iterations.

When final condition equals true, the loop exits. It is usually used to check if the value of the counter reaches a certain
value. The expression performed after each loop usually serves to increase or decrease the value of the counter after each
loop. Each of the three expressions inside for() is optional and using them for the counter is not mandatory.

Here is an example of how to use a counter:

for(int i = 0; i < 10; i++){…}

This code declares a counter i with the initial value 0. Then this counter is increased by 1 after each loop. When i equals
10 the loop exits.

AMP™ Studio Developer Guide 178


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

while
The format is:

while(some condition){

The loop continues until some condition equals true.

Example:

int i = 0;

while(i < 10){

//some code

i++;

This loop will repeat until i equals 10.

do-while
The format is:

do{

}while(some condition);

The loop continues until some condition equals true.

Example:

int i = 0;

do{

//some code

i++;

}while(i < 10);

AMP™ Studio Developer Guide 179


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

break
In some cases, it is necessary to exit a loop without waiting for the loop's final condition to become true. In this case,
break can be used:

while(true){

//some code

if(some condition) break;

continue
In some cases, it is necessary to skip to the next iteration of a loop without executing the rest of the code inside the block
of the loop.

Example:

int i = 0

while(i < 100){

int remainder = i % 3;

if(remainder == 0){

i++;

continue;

//some code

i++;

When i is a multiple of three, the code will not continue and a new iteration of the loop will run.

Methods
In some cases, the same code is used in different parts of a program. For example, the code that calculates an average
number may be used in the calculation of the average age, average income, etc. The only difference is that a different list
of numbers is processed.

In order not to repeat the same code in different places, such code can be placed in a method. A method is a block of code
that can have input parameters and one return value.

AMP™ Studio Developer Guide 180


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

In the previous example, there is only one input parameter, a list of numbers and the return parameter is the average
number.

The format of a method declaration is:

return_type method_name(parameters){

code

The return type of a method is the data type of the value that this method returns. The parameters can be either one
parameter or a comma-separated list of parameters.

Example:

int positivePower(int number, int power){

if(power == 1) return number;

int result = number;

for(int i = 1; i < power; i++){

result = result * number;

return result;

The method in this example returns a positive power of a number. As the input, it takes a number and a power in which the
number must be raised. The data types of the input parameters and the output value must be declared.

The result is returned by using a return anywhere in the method. Because the variable result is declared inside this method,
it is visible only inside the method. When a method does not return anything, it should be declared void:

void power(int number, int power){

It makes sense to declare a void method when this method changes a variable declared in the scope above the method. For
example:

int result = -1;

void positivePower (int number, int power){

if(power == 0) {

result = 1;

AMP™ Studio Developer Guide 181


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

if(power == 1) {

result = number;

} else {

result = number;

for(int i = 1; i < power; i++){

result = result * number;

In this example, the method sets the value of a result that is declared not inside the method but outside on the same level
(scope) as the method.

Methods can call other methods:

float power(int number, int power){

if(power < 0) return 1 / positivePower(number, power);if(power == 0) return 0;

if(power > 1) return positivePower(number, power);

The return value of this method is float because when the power is negative, the method returns a fraction of 1.

A method can also call itself:

int m(int number, int counter){

number *= number;

counter--;

if(counter == 0) return number;

m(number, counter);

In this example, a number is multiplied by itself counter times.

It is preferable to find algorithms alternative to recursion because recursion can easily lead to memory exhaustion. For
example, the previous method can be rewritten as:

int m(int number, int counter){

for(i = 0; i < counter; i++){

number *= number;

AMP™ Studio Developer Guide 182


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

It is important to know that a change in the value of a parameter whose data type is primitive is visible inside a method
only. The following example clarifies this statement:

int a(){

int i = 0;

b(i);

return i;}

void b(int i){

i = 10;

Method a declares a variable i with the initial value 0. Then i is passed to method b. Method b changes the value of i to 10.
This change is visible inside method b only. Method a does not know that the value of i has changed and from the point of
view of method a the value of i is still 0.

This happens because when a primitive data type is passed to a method, it is copied and its copy is passed to the method.
The original copy stays inside its original scope. This rule is valid for primitive data types only.

Classes
In some cases, several variables describe the same entity. For example, country name, population size and official
language are variables that describe a country. Such variables can be grouped in a Class.

There is a way to define a class. Right-click on the UI Project and select Add Class, This is used to define variables or
methods that are used for business logic and not UI. Variables grouped in a class are called class fields.

In addition to fields, a class can contain methods related to this class and its fields. In many cases, methods hide fields, and
the only way to change the value of a field is only through its access methods. For example, in order to set or get the text
of an mScript Button, you must use the methods setText(some text) and getText(). A field that holds the text is hidden.

Objects
A class is a description of a concept. For example, a class Country with its fields countryName, population Size and
official Language just means that any country has these properties: name, population size and an official language. Each
concrete country is called an instance of this class.

In order to use a class, its instance must be created. Another name of instance is "object".

Differentiation between these terms: class versus instance/object is important.

AMP™ Studio Developer Guide 183


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

There are three ways to obtain an object of a class:

■ Using new keyword


■ Using a factory
■ Creating a string

new
One way to create an object of a class is to use new:

Button b = new Button();

This one line of code performs three actions:

■ It declares a variable of type Button: Button b


■ It creates an object of class Button: new Button()
■ Then this new object of type button is assigned to the variable b

You do not have to create an object during the variable declaration:

Button b;

Later, this variable may be assigned an object of type Button:

b = new Button();

Such coding practices should be avoided when possible because it easily leads to the situation when some code uses a
variable that has not been initialized yet.

When it is necessary to initialize a variable after its declaration, methods that use the variable should check if it is
initialized. When a variable refers to no object, its value is null. It is possible to declare a variable with null value:

Button b = null;

When necessary, check if an object is initialized:

if(b == null){

//do something

Sample code for Background Buttons:

BackgroundButton bgrBtnHome = new BackgroundButton();

BackgroundButton btnGo1= new BackgroundButton();

BackgroundButton btnFindStore = new BackgroundButton();

//Labels

Label lblStoreSearch= new Label();

AMP™ Studio Developer Guide 184


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Label lblSearchZipHeader = new Label();

Label lblSearchCityStateHeader = new Label();

Label lblZip = new Label();

Label lblCity = new Label();

Label lblState = new Label();

TextField txtZipCode = new TextField();

TextField txtCity = new TextField();

ChoiceModel chMdlStates = new ChoiceModel();

ComboBox cmbStates= new ComboBox();

Object Fields and Methods


After an object is created, it is possible to use its fields and methods:

Button b = new Button();

b. setShowFocusRectangle(true);

This code creates a button that shows a rectangle when the button gains focus.

Object Reference
As previously explained, when a variable of a primitive data type is passed to a method, its copy is created and passed to
the method, and all changes inside the called method are performed on the copy. As the result, the calling method is
unaware of the changes on the copy because it only contains the original variable.

When an object is passed to a method, the object is not copied, and both the calling and the called method have references
to the same object.

So there are two types of passing a variable: by copy and by reference.

Another thing to remember about a reference to an object is that there is an object, and there can be several references to
this object.

Button a = new Button();

This line creates an object of class Button and a reference to this object called a.

Now it is possible to create another reference to the same object:

Button b = a;

Both a and b reference the same object;

AMP™ Studio Developer Guide 185


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

If you can now call:

a.setShowFocusRectangle(true);

then

b.isFocusRectangleShown(); will return true because both methods operate on the same object.

Only an object can have several references. Primitive data types will be copied in this situation:

int a = 25;

int b = a;

b = 30;

In this example a has the value 25. Then the variable b is created with an initial value 25. This initial value is copied from
the value of a. Then b receives a new value 30. The value of a is not changed because both a and b have their own values.

The same object reference can be reused:

Button b = new Button();//line 1

b.setShowFocusRectangle(true);//line 2

b = new Button();//line 3

b.setShowFocusRectangle(false);//line 4

In the third line, a new Button object is created and b is redirected to point to this new object. The first Button object still
exists. b does not point to it any longer.

Strings
In written English, individual characters form words. In mScript, char represents one character. A data type that consists
of two or more characters is called a String. A char is represented by single quotes: 'a'. A String is represented by double
quotes: "this is a string". A string can be one character long: "a" but its data type is still String and not char.

This is how a String is created:

String s = "hello";

When a string must contain double quotes, use \"

String s = "This String contains \" ";

Other useful escape sequences are:

\n for a new line

\t for a tab

A String is not a primitive data type. It is an object. As such its value can be null:

String s = null;

AMP™ Studio Developer Guide 186


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Because String is a class, it has a number of useful methods. For example, this code concatenates two String objects:

String a = "My planet is ";

String b = "Earth";

String c = a.concat(b);

The value of c is "My planet is Earth".

Because String is an object, methods can be called directly on a quoted String:

String c = "My planet is ".concat("Earth");

There is a shortcut to concatenate Strings:

String c = "My planet is " + "Earth";

Important: a change in a String creates a new String. In this code:

String c = a.concat("Earth");

The value of a is not changed when "Earth" is appended to it. Instead, a new String object is created with a concatenated
value of a and b.

Important: Although a String is an object, it is passed by copy as a primitive type. When a String is passed to an object, its
copy is passed.

Please note that a change of a String creates a new String object.

Similarities to a primitive data type:

There is no need to create a String by using new. A String is created like a char:

String s = "my string";

Strings can be concatenated by + which resembles numeric types: "a" + "b"

A String is passed by copy.

Static Fields and Methods


A class may contain static fields or methods. In this case there is no need to create an instance of the class in order to call
a static field or a static method.

For example, the class Platform has a method toString(int) that converts an int to a String:

int i = 21;

String s = Platform.toString(i);

As you see, there is no need to create an instance of the class Platform in order to use its method toString.

An example of a class that has static fields is Colors that has predefined colors exposed as static fields: Colors.Blue,
Colors.White, Colors.Aqua, etc.

AMP™ Studio Developer Guide 187


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Usually a field is static when it serves as a constant. A method is usually static when it is a utility.

Factories
Factory is a class that creates an instance of classes. In some cases, it is possible to create an instance of a mScript class by
using new:

Button b = new Button();

Some mScript classes cannot be instantiated directly but can be created through a factory.

For example, the class Platform is used to create instances of Boolean, Calendar, Date, Float and Integer classes:

Calendar c = Platform.createCalendar(false);

This code creates a Calendar object initialized to the computer's current time.

Inheritance
A class can have a parent class. In this case, in addition to its own fields and methods, a child class has its parent's fields
and methods.

Many classes have parent classes and classes that inherit from them. All top level classes inherit from the class Object.

Polymorphism
Polymorphism is the ability of a child class to appear as and be used like its parent class.

For example, in mScript, StringAttribute inherits from DataAttribute.

It means that StringAttribute is also a DataAttribute but not vice versa.

It means that StringAttribute may be used where a DataAttribute is expected. For example, the class TableModel has a
method addStringColumn(String, DataAttribute). Because addStringColumn receives a DataAttribute, it is possible to
pass it an instance of StringAttribute.

Callbacks
Callback is a special type of method. A callback cannot be called by the mScript code. For example, a method cannot call
a callback. A callback is called by the platform that executes mScript when an event that must be handled by this callback
takes place.

For example, the class Screen has a callback onOpen. This callback is called before a Screen object is open.

Assume there is a variable:

PhoneManager phoneManager = new PhoneManager();

And a callback:

callback phoneManager onCallEvent(int type, PhoneCall call, PhoneError error) {

AMP™ Studio Developer Guide 188


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

//some code

This callback will be called when call event will occur in this instance of phoneManager.

mscript File Structure


ClassName{

//header with field declarations

//callbacks of the current class

//callbacks on fields

//methods

For example:

Screen{

//header:

Button button = new Button();

//callbacks on Screen

callback onCreate(Container c){

button.setText("Click me");

//callbacks on fields:

callback button onClick(Control c){

respond();

//methods

void respond(){

info("I know you clicked me");

This simple example shows the structure of an mscript file.

AMP™ Studio Developer Guide 189


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

It is Important to remember that the header section must contain field declarations only. Any operation will result in an
error. For example, the following line in the header section:

button.setText("Click me");

will be incorrect because it is not a declaration but an operation.

Code Reuse in mScript


This example explains how to write screen/panel code to show some DataRow or DataRowSet and be able to reuse for
different objects.

Create new class named "Fields" and add things that will be changed from screen/panel to this class:

DataAttribute FiveYearChange;

DataAttribute GainLoss;

DataAttribute NetPriceChange;

DataAttribute OneMonthChange;

DataAttribute OneYearChange;

DataAttribute PurchaseDate;

DataAttribute PurchasePrice;

DataAttribute PurchaseQuantity;

Data Attribute SymbolDesc;,

DataAttribute Symbol;

DataAttribute ThreeMonthChange;

DataAttribute ValueAttribute,

Query link;

Create one instance of this "Fields" object per every DataObject you want screen/panel to support:

Fields defaultWatchlistFields = new Fields();

defaultWatchlistFields.FiveYearChange = vrpcGetDefaultWatchlist.
SymbolDetail.FiveYearChange;

defaultWatchlistFields.GainLoss = vrpcGetDefaultWatchlist.SymbolDetail.GainLoss;

defaultWatchlistFields.NetPriceChange = vrpcGetDefaultWatchlist.SymbolDetail.
NetPriceChange;

defaultWatchlistFields.OneMonthChange = vrpcGetDefaultWatchlist.SymbolDetail.
OneMonthChange;

defaultWatchlistFields.OneYearChange = vrpcGetDefaultWatchlist.SymbolDetail.OneYearChange;

AMP™ Studio Developer Guide 190


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

defaultWatchlistFields.PurchaseDate = vrpcGetDefaultWatchlist.SymbolDetail.PurchaseDate;

defaultWatchlistFields.PurchasePrice = vrpcGetDefaultWatchlist.SymbolDetail.PurchasePrice;

defaultWatchlistFields.PurchaseQuantity = vrpcGetDefaultWatchlist.SymbolDetail.
PurchaseQuantity;

defaultWatchlistFields.SymbolDesc = vrpcGetDefaultWatchlist.SymbolDetail.SymbolDesc;

defaultWatchlistFields.Symbol = vrpcGetDefaultWatchlist.SymbolDetail.Symbol;

defaultWatchlistFields.ThreeMonthChange = vrpcGetDefaultWatchlist.SymbolDetail.
ThreeMonthChange;

defaultWatchlistFields.Value = vrpcGetDefaultWatchlist.SymbolDetail.Value;

defaultWatchlistFields.link = vrpcGetDefaultWatchlist.SymbolDetail.getSymbols
(arraySymbolKey);

NOTE: The tip is to add the Fields instance to the screen/panel and assign it to the appropriately initialized
Fields instance when the screen or panel was created and ONLY uses fields from Fields inside the mscript.

Fields fields;

cellValuesNmbrFmtMdl.addField(fields.ValueAttribute);

Best Practices for Error Handling

Login
■ onLoginFailed: Shows an error message to the user that indicates that the login to the authentication server has
failed.
■ onLoggedOut: Checks the logout code and displays the appropriate error message to the user.
— LOGGED_OUT: User is manually logged out.
— LOGGED_OUT_BY_SERVER: User was logged out from the server. For example, the user logged in
with a different device or the user was logged out by the administrator using the Antenna Management
Console.
— LOGGED_OUT_SESSION_EXPIRED
— LOGGED_OUT_LOGIN_EXPIRED

NOTE: There is a callback named onUserInactivity() that can be used to log the user out of the
authentication server after a period of inactivity. For example, you can make a VRPC call to a Web Service to
log the user out of the application.

AMP™ Studio Developer Guide 191


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

VRPC
When making a VRPC call that should only be sent if the network is available, do the following:

1 Call isNetworkAvailable().

2 If isNetworkAvailable() returns false, call isNetworkSuspended(). If it returns false, show an error message to
the user alerting the user that he/she is out of network coverage. If isNetworkSuspended() returns true, alert that
user that the data network is unavailable. (On a 2G BlackBerry, this may indicate that the user is on the phone.)

3 If the network is available, check if the MessageService is available. If it is unavailable, start the
MessageService.

if (messageService.getMessageServiceStatus() == Service.UNAVAILABLE) {

messageService.start(true);

4 If the network is available, check to see if VRPCProject.isAvailable().If this returns false, show an error, "Server
unavailable."

5 If VRPCProject.isAvailable() returns true, call VRPCRequest.setReplyTimeout(int minutes). This will set the
VRPC timeout period. If the client has not received a reply from the server in this time period, you can show an
error message to the user.

6 After setting the reply timeout, call your data project's sendVRPC() method that you created .

7 In the onRequestSent callback, display a WaitCursor to the user.

8 In the onError() callback, display an error message to the user and hide the wait cursor. This callback is called for
generic error conditions (for example, the appropriate configuration is not found).

9 In the onReplyReceived callback, first check if a VRPCError object is returned. If it is, display an error message
to the user and hide the wait cursor. Otherwise, proceed with filling the UI elements with the returned data and
hide the wait cursor.

10 The onRequestFailed callback indicates that the VRPC request was not able to be sent. In this callback, display
an error message to the user and hide the wait cursor.

11 The onRequestBounced callback indicates that the server received the VRPC request, but the response was never
sent to the client. In this callback, display an error message to the user and hide the wait cursor.

12 The onRequestTimeout callback is used in conjunction with the setReplyTimeout() method. If the client has not
received a reply from the server within the specified timeframe, this callback will be called. In this callback,
display an error message to the user and hide the wait cursor.

AMP™ Studio Developer Guide 192


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

AMP Studio Debugging Tips


■ Restart Eclipse.
■ Check your client compile properties. Are you compiling for the correct platforms?
■ Check your image bundles. Are they assigned to device types?
■ Check your server log. Maybe you need to increase the logging level.
■ Enable Errors logs.
■ Empty your simulator cache before launching a simulator.
■ Upgrade to the latest AMP Studio build.
■ Draw your screen layout first before you start coding. It will help you decide on panels, rows, columns, preferred
sizes, etc.

Eclipse.ini File Troubleshooting


1 If you start Eclipse and do not see the AMP Studio menus or buttons, make sure that you are using the SDK
version of Eclipse (recommended version is eclipse-SDK-3.4.2-win32.zip).

2 If you still do not see the menus/buttons, in Eclipse.ini, add the following lines:

-vm
C:\Program Files\java\jdk1.6.0_13\bin

This forces Eclipse to use Java 1.6.

If that does not resolve the issue, ensure that the JDK directory is in the computer's path.

3 If you receive an error about the home directory, edit the Eclipse.ini file to hard-code the home directory, for
example,

-Duser.home=C:\Documents and Settings\username

4 If Eclipse is running slow:

A Change the line that contains -xmx256m to -xmx1024m or -xmx768m

B Edit the AMP Studio shortcut and remove the -clean option.

NOTE: You only need to start Eclipse in clean mode after installing a new AMP Studio build so that all of
the updated plugins get reloaded.

AMP™ Studio Developer Guide 193


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Troubleshooting
The following are some basic troubleshooting tips for checking connectivity between the server and device.

1 Verify the client logs and ensure that there are no errors/exceptions from your UIP.

— Client logs can be accesses by using the CTRL+LGLG shortcut with the computer keyboard while focus is
on the BlackBerry home screen.
— The client log level can be set by selecting the Window menu, then Preferences, AMP Studio, Client, and
finally, Log Properties. If you want to debug, ensure that VMP_SYS is set to FINE.
— To do logging, first initialize the logger by Log logApp = getLog(); Then you can use the log such as,
logApp.log(Log.FINE, "onStart() called");

2 Verify the connectivity configurations in the device.

— In the BlackBerry Simulator, select Options, then Antenna AUTH_SERVER and check whether it is
pointing to the correct server. (The Antenna option will appear only if the application is invoked at least
once). If not, edit it to point to the correct server and restart. If Antenna is not launching, use the clean.bat
inside the simulator folder and re-try. Another option is clear all .dmp, .debug, and .cod files relevant to your
project and re-try.

3 Verify server logs.

— Server logs can be found in the server console and/or in project\com.vaultus.studio\server\vas\logs.


— Server log level can be set by selecting the Window menu, then Preferences, AMP Studio, Server, and
finally, Log Properties. If you want to debug, ensure that VMP_SYS, VMP_VRPC and/or VMP_VDSC is
set to FINE.
— Server logs for login() is attached below for reference.
11:34:50 VMP_SYS_NET <INFO > [0] Connected (nopush) to /192.168.129.169:1354

11:34:50 VMP_SYS_NET <INFO > Registered [0 nopush g1007771302


s@AUTH_SERVER:AuthJob c@test:BLACKBERRY_CLIENT:b:2100000A 8945/1054 [Default 3G
Network/=] n[1672944117] CONNECTED_UNVERIFIED C- s50/s50/130048 Q/0/50 0 Q/0/101 -1
[rtt=?/? reconn=0/?] ZLIB/PUB_ECES/SHA_256 /192.168.129.169:1354 [[Default 3G
Network 1285135490377 s=103 r=0]]]

11:34:50 VMP_SYS_NET <INFO > Opened [0 nopush g1007771302


s@AUTH_SERVER:AuthJob c@test:BLACKBERRY_CLIENT:b:2100000A 8945/1054 [Default 3G
Network/=] n[1672944117] CONNECTED_UNVERIFIED C- s50/s50/130048 Q/0/50 0 Q/1/101 -1
[rtt=?/? reconn=0/?] ZLIB/PUB_ECES/SHA_256 /192.168.129.169:1354 [[Default 3G
Network 1285135490377 s=103 r=0]]]

11:34:50 VMP_AUTH_JOB <INFO > Automatically added user: test

11:34:50 VMP_AUTH_JOB <INFO > Automatically added device type: arm-rim-


blackberry-4.6.0.92-9000

11:34:51 VMP_AUTH_JOB <WARN > Login Successful for: test; Always approved

11:34:51 VMP_AUTH_JOB <INFO > Scheduled auto-logout for test in 10800000 ms

11:34:51 VMP_AUTH_JOB <INFO > Got client request service for ADDUI from test

AMP™ Studio Developer Guide 194


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

11:34:51 VMP_VMSJOB <INFO > Pre-accepted session for cluster:


[ClusterUserState@1a29450: test g411911144 loginId=-602149543 (R -) [nopush
g411911144 s@!AUTH_CLUSTER@VVV_CLUSTER_UNIQUE@:VMSJob c@test:ADDUI.1.0.0:b:2100000A
32619/6433 [Default 3G Network/=] n[1736978566]] arm-rim-blackberry-4.6.0.92-9000]

11:34:51 VMP_AUTH_JOB <INFO > Referred test to 192.168.129.169:11011 for ADDUI

11:34:52 VMP_VMSJOB <INFO > Pre-accepted cluster session (g411911144)


assigned to: AUTH_SERVER (local server)

11:34:52 VMP_SYS_NET <INFO > Registered [1 nopush g411911144


s@!AUTH_CLUSTER@VVV_CLUSTER_UNIQUE@:VMSJob c@test:ADDUI.1.0.0:b:2100000A 32619/6433
[Default 3G Network/=] n[1736978566] DISCONNECTED C- s50/s50/130048 Q/0/50 0 Q/0/101
-1 [rtt=?/? reconn=0/?] ZLIB/PUB_ECES/SHA_256 null []]

11:34:52 VMP_SYS_NET <INFO > Opened [1 nopush g411911144


s@!AUTH_CLUSTER@VVV_CLUSTER_UNIQUE@:VMSJob c@test:ADDUI.1.0.0:b:2100000A 32619/6433
[Default 3G Network/=] n[1736978566] DISCONNECTED C- s50/s50/130048 Q/0/50 0 Q/0/101
-1 [rtt=?/? reconn=0/?] ZLIB/PUB_ECES/SHA_256 null []]

11:34:52 VMP_SYS_NET <INFO > [1] Reconnected (nopush) to /192.168.129.169:1356

11:35:04 VMP_VRPC <FINE > (b:2100000A) CMSession DeviceId: b:2100000A

11:35:04 VMP_VRPC <INFO > (b:2100000A) document key:


com.vaultus.vmsserver.VRPCDocumentKey :docName: ADDDP.1.0.0 :vrpcName: add :thread:
Thread[Job-22,5,Job]

11:35:04 VMP_VRPC <FINE > (b:2100000A) client config version: -


6991320213661335652 :server config version: -6991320213661335652

11:35:04 VMP_SYS <FINE > VRPC_VERSION: 1.0.0

AMP Studio Frequently Asked Questions (FAQs)


This section describes frequently asked questions, followed by possible resolutions.

1 I upgraded a project and my UIP node is empty.

— Exit from Eclipse and edit the UIP .model file.


— Look for the colors XML node and rename all instances of 'value' to 'color'.

For example,

<colors name="MobileTradingLightBrown" value="-1783407"/>

to

<colors name="MobileTradingLightBrown" color="-1783407"/>

— Save changes and restart Eclipse.

2 I get strange errors in the Problems panel of the Eclipse console.

— Delete the errors (and optionally) restart Eclipse.

AMP™ Studio Developer Guide 195


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

— Try deleting the code gen folders (.bb, .objc, etc.).

3 I changed or added images in the image panel and they are not showing up in the image panel and/or the
simulator.

— Try to restart Eclipse.

4 I launch the application in the simulator and I see a blank screen.

— You have not associated each image bundle with a device type.
— Your image bundle is empty (corrupt).
— Try to restart Eclipse and check the images again.

5 Results in the simulator do not reflect recent changes or there are errors.

— Try to clear out the simulator cache before launching.

6 How can I pass data between two screens?

— Try to use the following code:


callback rchTblAccounts onEnterKey(Control c, int row) {

logApp.log(Log.FINE, "Enter key on Table - Push Account Detail Screen");

pushAccountDetails();

callback actAccountDetails onRun(Action c) {

logApp.log(Log.FINE, actAccountDetails.getText() + " was clicked - Push Account


Details Screen");

pushAccountDetails();

//Method Used to show Summary Details Screen

void pushAccountDetails() {

if(rchTblMdlAccounts.hasRow()){

scrAccountDetails = getNewAccountsDetailsScreen();

DataRow dtaRowAccount = rchTblMdlAccounts.getRow();

scrAccountDetails.dtaRowAccount = dtaRowAccount;

pushScreen(scrAccountDetails);

AMP™ Studio Developer Guide 196


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

7 How can I close the existing screen and return to the previous screen with the same session data?

— Use the following code:


close();

8 How can I enable logging in the application if I am using the following?

— Use the following code:


Log logApp = getLog(); & logApp.log(Log.INFO,"my method invoked");)

— For client logs, use the following code:


Log logApp = getLog();

logApp.log(Log.FINE, "onStart() called");

… Then double-click the UIP. Set the log to FINE. From the Window menu, select Preferences and set
the client log from VMP_SYS to FINE.
… On the BlackBerry device, use the ALT-LGLG shortcut key (or use CTRL-LGLG on a computer's
keyboard) to see the log.
… For the server, you can set server log properties in the Window\Preferences screen and see the logging
in the AMP Studio server console or in project\com.vaultus.studio\server\vas\logs.

9 Where can I get the default Font and other Styles such as buttons, etc. for BlackBerry, iPhone and
Android devices?

— You can refer to the default style code snippet from any project or samples within the AMP Studio Developer
Guide.

10 Using VDSC, how can I create an Object for multiple table join conditions?

— You can use a virtual object, but it is probably easier to create a view in the DP and handle the join there.

11 Where will authentication occur in the DB? Do we need to perform any explicit authentication?

— Authentication against the AMP Server Authentication server occurs when you call login() in the UIP. The
connector may require a second level login in some cases. But for a simple DB connector, no authentication
should be required for the connector.

12 How can I integrate GPRS in BlackBerry and iPhone in AMP Studio? Is there a provision to check some
static locations using GPRS coordinates?

— AMP Studio provides GPS integration.

13 How can I set a wait cursor when the response is being delayed?

— Use the following code:


WaitCursor waitCursor = new WaitCursor();

void initWaitCursor(WaitCursor wc, String displayString) {

AMP™ Studio Developer Guide 197


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

//Dark Blue rectangle

wc.setVerticalAlignment(WaitCursor.CENTER);

wc.setHorizontalAlignment(WaitCursor.CENTER);

wc.setBackground(Background.createColorRoundedBackground(Color.create(192,0,0,0),
Colors.White, LineStyle.SOLID));

wc.setForeColor(Colors.White);

wc.setHeight(Sizing.PIXELS, giWidth/6);

wc.setWidth(Sizing.PIXELS, giWidth/2);

wc.setFont(StyDefault.fntDetails);

wc.setText(displayString);

initWaitCursor(waitCursor, "Retrieving Data...");

scrUserID.setWaitCursor(waitCursor);

— To remove the wait cursor, use the following code:


scrUserID.setWaitCursor(null);

14 Suppose I do not have table headers to my table and it contains two or more columns. How can I set
ReseultSet data (i.e. Query retrieved data) for that table?

— You can use the following code:


tblHelloWorld.setDataModel(tblMdlHelloWorld);

tblMdlHelloWorld.addStringColumn("", vrpcGetObjectRows.TEST.ID);

tblMdlHelloWorld.addStringColumn("", vrpcGetObjectRows.TEST.TEXT);

tblHelloWorld.setColumnWidth(0, Sizing.PERCENTS, 50);

tblHelloWorld.setColumnWidth(1, Sizing.PERCENTS, 50);

tblMdlHelloWorld.setRows(vrpcGetObjectRows.TEST.qryGetAll());

15 How is exception propagation performed in AMP Studio? (For example, if I received an exception in my
connector, how will I realize it? )

— It should show up in the server log.

16 I have developed a sample UI and DP. I was able to get a response from the DP, but after I restart Eclipse,
sometimes I am not getting any response from the server, i.e. the 'onReplyReceived' callback is not
invoked. How should I debug such issues? I am using the VRPC connector.

— In the Window/Preferences screen, set VMP_VRPC and VMP_SYS to FINE. Start your server. Check the
log for any errors.

17 I am experiencing some problem after initiating the AMP Server for a VDSC Data Project.

AMP™ Studio Developer Guide 198


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

— You will need to run the DB Connector installer from the build distribution. It will install the EMF jars for
you. After that, replace the DB connector that the installer put into vmsserver/connectors with the version
that you obtain from AMP Studio.
12:09:47 VMP_SYS_NET <CONFIG > Configured for client traffic via: TCP, MDS

MDS: [login= (0) pools=[[kgutala.antennasoftware.com/192.168.129.131:8080 <- [/


192.168.129.131]]]]

12:09:47 VMP_SYS <INFO > Initialized communication manager

12:09:47 VMP_SYS <CONFIG > Cluster is configured for load balancer: no

12:09:47 VMP_SYS <INFO > Initialized email service

12:09:47 VMP_AUTH_JOB <INFO > Registered JMX for job

12:09:47 VMP_AUTH_JOB <INFO > Started user statistics logging

12:09:47 VMP_AUTH_JOB <INFO > Started comm_stats carrier statistics logging

12:09:47 VMP_AUTH_JOB <INFO > Started comm_stats user statistics logging

12:09:47 VMP_AUTH_JOB <INFO > Started user session service

12:09:48 Runtime <INFO > Starting OpenJPA 2.0.0

12:09:50 VMP_AUTH_JOB <INFO > Initialized database manager

12:09:50 VMP_AUTH_JOB <INFO > Initialized application manager

12:09:50 VMP_VMSJOB <INFO > Registered JMX for job

12:09:50 VMP_VMSJOB <INFO > Started user statistics logging

12:09:50 VMP_VMSJOB <INFO > Started comm_stats carrier statistics logging

12:09:50 VMP_VMSJOB <INFO > Started comm_stats user statistics logging

12:09:50 VMP_VMSJOB <INFO > Started user session service

12:09:50 VMP_VMSJOB <INFO > Started push

12:09:50 VMP_VMSJOB <INFO > Started push JMX

12:09:50 VMP_SYS <ERROR > Cannot start server

com.vaultus.common.toolkit.bl.datasource.DataSourceException: Driver class


com.vaultus.vms.db.driver.DBDriver constructor threw an exception

at com.vaultus.vmsserver.DataSourceJob.getDriver(DataSourceJob.java:579)

at com.vaultus.vmsserver.DataSourceJob.getDriver(DataSourceJob.java:597)

at com.vaultus.vmsserver.DataSourceJob.initializeDocument(DataSourceJob.java:659)

at
com.vaultus.vmsserver.DataSourceJob.initializeAllDocuments(DataSourceJob.java:352)

at com.vaultus.vmsserver.DataSourceJob.initializeOrReload(DataSourceJob.java:263)

at com.vaultus.vmsserver.DataSourceJob.onStart(DataSourceJob.java:201)

AMP™ Studio Developer Guide 199


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

at com.vaultus.vmsserver.VRPCJob.onStart(VRPCJob.java:144)

at com.vaultus.vmsserver.core.SyncJob.onStart(SyncJob.java:122)

at com.vaultus.vmsserver.VMSJob.onStart(VMSJob.java:107)

at com.vaultus.server.core.GenericServer.startJobs(GenericServer.java:2430)

at com.vaultus.server.core.GenericServer.start(GenericServer.java:1049)

at com.vaultus.server.core.GenericServer.runUntilShutdown(GenericServer.java:1252)

at com.vaultus.server.core.GenericServer.main(GenericServer.java:2248)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:2
5)

at java.lang.reflect.Method.invoke(Method.java:597)

at com.vaultus.server.runner.ServerRunner.doMain(ServerRunner.java:208)

at com.vaultus.server.runner.AuthRunner.main(AuthRunner.java:24)

Caused by: java.lang.reflect.InvocationTargetException

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl
.java:39)

at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAcce
ssorImpl.java:27)

at java.lang.reflect.Constructor.newInstance(Constructor.java:513)

at com.vaultus.vmsserver.DataSourceJob.getDriver(DataSourceJob.java:568)

... 18 more

Caused by: java.lang.NoClassDefFoundError: org/eclipse/emf/ecore/resource/


ResourceSet

at com.vaultus.vms.db.driver.DBDriver.loadConfig(DBDriver.java:94)

at com.vaultus.vms.db.driver.DBDriver.executeDBDriverTasks(DBDriver.java:88)

at com.vaultus.vms.db.driver.DBDriver.<init>(DBDriver.java:84)

... 23 more

Caused by: java.lang.ClassNotFoundException:


org.eclipse.emf.ecore.resource.ResourceSet

at java.net.URLClassLoader$1.run(URLClassLoader.java:200)

AMP™ Studio Developer Guide 200


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:188)

at java.lang.ClassLoader.loadClass(ClassLoader.java:307)

at java.lang.ClassLoader.loadClass(ClassLoader.java:252)

at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)

... 26 more

12:09:50 VMP_VMSJOB <INFO > addDocument: key:


com.vaultus.vmsserver.VDSCDocumentKey :docName: MyDP.1.0.0

12:09:50 VMP_VMSJOB <INFO > DCVMSDB :Custom ClassLoader created: [DCVMSDB


ClassLoader ClassLoader]

12:09:50 VMP_VMSJOB <INFO > DCVMSDB :RealSyncDataConnector class:


com.vaultus.vmsserver.toolkit.bl.sync.PostProcessIDDataConnector

12:09:50 stdout <INFO > Manifest entry: DCVMSDB

12:09:50 stdout <INFO > Manifest attributes: (Vaultus-VDSC-Driver,


DCVMSDB)

12:09:50 stdout <INFO > Manifest attributes: (Vaultus-VDSC-Driver-


Classname, com.vaultus.vms.db.driver.DBDriver)

12:09:50 stdout <INFO > Manifest attributes: (Vaultus-RealSync-


DataConnector-Classname,
com.vaultus.vmsserver.toolkit.bl.sync.PostProcessIDDataConnector)

12:09:50 stdout <INFO > Manifest attributes: (Vaultus-VDSC-Driver-


Resource, /DCVMSDB.dbconfig)

12:09:50 VMP_SYS <INFO > Stopping server (due to FAILED_START_CLEANUP) ...

12:09:50 VMP_SYS <INFO > Up since 2010.09.16 12:09:42 IST Thu (0 days 0
hours 0 minutes 8 seconds)

12:09:50 VMP_SYS <INFO > Stopping communication manager ...

12:09:50 VMP_SYS <INFO > Stopping timers ...

12:09:50 VMP_SYS <INFO > Stopping thread pool Job ...

12:09:50 VMP_SYS <INFO > Stopping thread pool ClusterRpc ...

12:09:50 VMP_SYS <INFO > Stopping statistics service ...

12:09:50 VMP_SYS <INFO > Stopping jobs ...

12:09:50 VMP_AUTH_JOB <INFO > Stopping application manager ...

12:09:50 VMP_AUTH_JOB <INFO > Stopping database manager ...

12:09:50 VMP_AUTH_JOB <INFO > Stopping user statistics logging ...

12:09:50 VMP_AUTH_JOB <INFO > Stopping comm stats carrier statistics logging
...

AMP™ Studio Developer Guide 201


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

12:09:50 VMP_AUTH_JOB <INFO > Stopping user session service ...

12:09:50 VMP_AUTH_JOB <INFO > Unregistering JMX for job ...

12:09:50 VMP_VMSJOB <INFO > Stopping RealSync service ...

12:09:50 VMP_VMSJOB <INFO > Stopping DataSource drivers ...

12:09:50 VMP_VMSJOB <INFO > Stopping push JMX ...

12:09:50 VMP_VMSJOB <INFO > Stopping push ...

12:09:50 VMP_VMSJOB <INFO > Stopping user statistics logging ...

12:09:50 VMP_VMSJOB <INFO > Stopping comm stats carrier statistics logging ...

12:09:50 VMP_VMSJOB <INFO > Stopping user session service ...

12:09:50 VMP_VMSJOB <INFO > Unregistering JMX for job ...

12:09:50 VMP_SYS <INFO > Stopping database connection pool ...

12:09:50 VMP_SYS <INFO > Stopping encryption ...

12:09:50 VMP_SYS <INFO > Stopping heartbeat ...

12:09:50 VMP_SYS <INFO > Stopping threshold logging ...

12:09:50 VMP_SYS <INFO > Stopping console controller ...

12:09:50 VMP_SYS <INFO > Stopping JMX ...

12:09:50 VMP_SYS <INFO > Stopping logging ...

Coding Conventions
It is a good practice to follow some convention when you write code. It will create code that is easy to work with.

It is recommended that you review Java Code Convention and Hungarian notation and apply relevant parts to mScript.

Names
Abbreviate names only when a name is too long.

Create names that clearly describe their use.

Class Names
Each word in the names of projects, styles, screens, panels, and folders should be capitalized:

LearnDP, DefaultStyle, LoginScreen, UserListPanel

AMP™ Studio Developer Guide 202


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Variable Names
Variable and parameter names should start with a lowercase letter and each word should be capitalized:

myVariableName

Method Names
Queries, rowfilters, indexes, mappings and methods should start with a lowercase letter and each word should be
capitalized:

query qryGetAllRows<>{}

index idxID {

etc.

Indentation
Use tab indentation to create a clear hierarchy within an mscript.

Spaces
Add extra spaces to make code more readable:

int i = 35;

instead of:

int i=35;

One Liners
Write one command per line. Do not write several commands in one line:

int i = 35; int j = 36;

Do not write commands one inside the other:

dp.User.username.setStringValue(newValue, model.getRow());

Divide commands as in the following example:

DataRow row = model.getRow();

AMP™ Studio Developer Guide 203


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

dp.User.username.setStringValue(newValue, row);

It is recommended that you use the following coding conventions for building variable names using the following table:

Variable Name Conventions

Action - act

Area - ar

Array - arr

Bar - bar

Background - bck

Border - brd

Box - bx

Browser - brw

Button - btn

Calendar - cal

Chart - cht

Check - chk

Choice - ch

Combo - cmb

Data - dta

Date - dt

Edit - edt

Field - fld

Font - fnt

Form - frm

Format - fmt

Horizontal - hrz

Image - img

Images - imgs

Index - idx

AMP™ Studio Developer Guide 204


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Variable Name Conventions

Item - itm

Label - lbl

Log - log
[Exampe: Log logApp = getLog();]

Menu - mn

Model - mdl

Multi - mlt

Number - num

Numeric - num

Panel - pnl

Password - pwd

Picture - pic

Pie - pie

Progress - prg

Query - qry

Rich - rch

Screen - scr

Separator - sep

Stack - stk

Style - sty

Tabbed - tab

Table - tbl

Text - txt

Tool - tl

Vertical - vrt

AMP™ Studio Developer Guide 205


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

The following are some examples:

Variable Name Conventions

ImageModel - imgMdlSearch

TextField - txtUser

BorderPanel - brdPnlRoot

ImageModel - imgMdlImage

Label - lblHeader

MenuItem - mnItmClose

PictureBox - picBxTitle

Table - tblTable

TableModel - tblMdlSummary

TextModel - txtMdlHeader

ToolBar - tbToolbar

ToolBarButton - tlBrBtnSkiers

■ For data projects, use: dp. For example,


TravelExpenseDP.VDSC dp = new TravelExpenseDP.VDSC();

■ For strings, use:


— LBL_
— MENU_
— BTN_
— MSG_
— PROMPT_

■ For local variables, use:

Type Example

Boolean - bDataReceived

float - fValue

int - iCount

AMP™ Studio Developer Guide 206


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

Type Example

String - strName

Date - dtToday

Timestamp - tsToday

■ For global variables (UIP variables), start with g. For example: gStrGlobalVariable
■ For virtual fields (DP variables), start with v. For example,
— vFVirtualField - float field at the object level
— vStrVirtualField - String field
■ For linked fields, start with l. For example:
StringAttribute lAccountName = AID=>Accounts.AID->Accounts.Name

■ For Images, build using the following:

Images Conventions

Button - btn

Toolbar button (slider icon) - sic

KPI (key performance indicator) - kpi

Icon, column header, etc. - ico

Toolbar Background image (slider - sbg


background)

■ For Methods, use the following conventions:

Method Name Conventions Example

Setting value - set setVariable()

Getting Value - get getVariable()

Boolean return - is isTrue()

■ For code indentation, use the following convention:


callback tbl_table onCellInfo(Control c, int column, int row, boolean isSelected,
TableItem item) {

int odd = row %2;

AMP™ Studio Developer Guide 207


ANTENNA PROPRIETARY & CONFIDENTIAL AMP™ Studio Developer Guide

// if row is odd, set the back color to be Gray

if(odd == 0){

item.setBackColor((isSelected)?Color.LightGreen : Color.LightGray);

// if row is even, set the back color to be White

else {

item.setBackColor((isSelected)?Color.LightGreen : Color.WhiteSmoke);

AMP™ Studio Developer Guide 208

You might also like