Solutions for Exercise 1: Column Alignment and Colors
1A: Icon and text alignment.
The alignment of text and icon is specified in the enumeration block on a value-by-value basis:
<enumeration value="Canada" title="Canada" icon="images/flags/canada.gif" horizontalAlignment="leading" horizontalTextPosition="trailing"/>
1B: Changing the header background color to blue.
One possible solution is:
<header background="cyan"/>
1C: Changing the background colors of the data rows to yellow and orange.
You can use hexidecimal:<highlighters> <alternateRowHighlighter oddRowBackground="#FFFF00" evenRowBackground="#FF9900"/> </highlighters>or the SVG color name:<highlighters> <alternateRowHighlighter oddRowBackground="yellow" evenRowBackground="orange"/> </highlighters>
2A: Changing the text color to red for countries that begin with B or M.
Add apatternHighlighteron the country column:<highlighters> <alternateRowHighlighter oddRowBackground="#EEEEFF" evenRowBackground="#CCCCFF"/> <patternHighlighter expression="[B,M].*" testColumn="COUNTRY" foreground="red"/> </highlighters>
2B: Changing the text color to blue for Canadian rows.
Add apatternHighlighteron the country column:<highlighters> <alternateRowHighlighter oddRowBackground="#EEEEFF" evenRowBackground="#CCCCFF"/> <patternHighlighter expression="Canada" testColumn="COUNTRY" foreground="blue"/> </highlighters>
<filters>
<sorter testColumn="TEMPERATURE"/>
</filters>
3B: Sorting in descending order:
<filters>
<sorter testColumn="TEMPERATURE" direction="descending"/>
</filters>
3C: Adding a secondary sort on latitude:
<filters> <sorter testColumn="TEMPERATURE"/> <sorter testColumn="LATITUDE"/> </filters>The order of thesortertags determines sorting precedence, with the first tag specifying the primary criteria. The latitude column must be added to the view, inside thecolumnsblock:<columns> ... <column title="Latitude" binding="LATITUDE" horizontalAlignment="center"/> ... </columns>
<filters>
<patternFilter expression="['A'-'J'].*" match="caseInsensitive unicodeCase"
testColumn="COUNTRY"/>
</filters>
4B: Filter out samples not from Airport stations:
Searching on the "Air" substring will also find all Airparks, Airfields and
Air Stations:
<filters>
<patternFilter expression=".*Air.*" match="caseInsensitive unicodeCase"
testColumn="STATION"/>
</filters>
<filters>
<patternFilter xml:id="stationFilter" testColumn="STATION"/>
</filters>
<toolBar>
<searchPanel patternFilter="#stationFilter"/>
</toolBar>
The8B: Adding New and Open to the Menus:smallIconattribute is added to the "find" action:<action xml:id="find" name="Find" mnemonic="F" smallIcon="/toolbarButtonGraphics/general/Find16.gif" icon="/toolbarButtonGraphics/general/Find24.gif" accelerator="control F" description="Find an item"/>The Find menu item is added to the Edit submenu:<menuBar> <menu action="#file-menu"> ... </menu> <menu name="Edit" mnemonic="E" description="Edit Commands"> <action actionRef="#cut-to-clipboard"/> <action actionRef="#copy-to-clipboard"/> <action actionRef="#paste-from-clipboard"/> <separator/> <action actionRef="#find"/> </menu> <menu name="Format" mnemonic="O" description="Text Formatting Commands"> <i>...</i> </menu> </menuBar>And also to the popup menu:<popupMenu> <action actionRef="#cut-to-clipboard"/> <action actionRef="#copy-to-clipboard"/> <action actionRef="#paste-from-clipboard"/> <separator/> <action actionRef="#find"/> <separator/> <action actionRef="#font-bold"/> <action actionRef="#font-italic"/> <action actionRef="#font-underline"/> <separator/> <group xml:id="align"> <action actionRef="#left-justify"/> <action actionRef="#center-justify"/> <action actionRef="#right-justify"/> </group> </popupMenu>
Originally, the new and open actions were specified in the File8C: Adding a Refresh Action:menublock. They must be moved to thedefsblock in order to be reused. A 24x24 tool bar icon is also added to theactiontag:<om:defs> <!-- Custom actions --> <action xml:id="new-command" title="New" mnemonic="N" accelerator="control N" smallIcon="/toolbarButtonGraphics/general/New16.gif" icon="/toolbarButtonGraphics/general/New24.gif" description="Create a new document"/> <action xml:id="open-command" title="Open" mnemonic="O" accelerator="control O" smallIcon="/toolbarButtonGraphics/general/Open16.gif" icon="/toolbarButtonGraphics/general/Open24.gif" description="Open an existing document"/> ... </om:defs>The File menu declaration is simplified:<menu action="#file-menu"> <action actionRef="#new-command"/> <action actionRef="#open-command"/> </menu>The New and Open actions are added to the tool bar:<toolBar> <action actionRef="#new-command"/> <action actionRef="#open-command"/> <separator/> ... </toolBar>The New and Open actions are also added to the popup menu:<popupMenu> <action actionRef="#new-command"/> <action actionRef="#open-command"/> <separator/> ... </popupMenu>
A Refresh action is added to thedefsblock. The icons are specified from the Java Look and Feel Graphics Repository:<om:defs> ... <action xml:id="refresh" title="Refresh" smallIcon="/toolbarButtonGraphics/general/Refresh16.gif" icon="/toolbarButtonGraphics/general/Refresh24.gif"/> ... </om:defs>Add the action to the menu, popup menu and tool bar. All declarations will be the same:<action actionRef="#refresh"/>