Try OpenEdge Now
skip to main content
Application Developer's Guide
Using the Rule Wizard framework : Controlling the layout
 

Controlling the layout

The second example uses the automatic layout of editor components provided by the Rule Wizard. To customize the layout, you can use the <constraints> and <label-constraints> tags within the <editor> tags. This leads to the third example:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE template SYSTEM "resources/ruleTemplate.dtd" >
<template name="ex3">
<screen number="10">
    <editor macro="aggregate">
        <editor macro="text" label="Text">
            <parameter name="columns" value="30"/>
            <label-constraints fill="HORIZONTAL" insets="2,2,2,2"
                weightx="1" gridx="0" gridy="0"/>
            <constraints fill="NONE" insets="2,2,2,2" weightx="2"
                gridx="1" gridy="0" anchor="WEST"/>
        </editor>
        <editor macro="list" label="List">
        <label-constraints fill="HORIZONTAL" insets="2,2,2,2" weightx="1"
            gridx="0" gridy="1"/>
        <constraints fill="NONE" insets="2,2,2,2" weightx="2" gridx="1"
            gridy="1" anchor="WEST"/>
        </editor>
    </editor>
</screen>
<macro name="aggregate" type="composite">
    <macro name="text" type="varname"/>
    <macro name="list" type="combo-box">
        <vector-property name="listLabels">
            <vector-elem>Option A</vector-elem>
            <vector-elem>Option B</vector-elem>
            <vector-elem>Option C</vector-elem>
        </vector-property>
        <vector-property name="listValues">
            <vector-elem>option_a</vector-elem>
            <vector-elem>option_b</vector-elem>
            <vector-elem>option_c</vector-elem>
        </vector-property>
        <property name="listSelectedValue">option_b</property>
    </macro>
</macro>
<text>
Value of text is $aggregate.getMacro("text").
Value of list is $aggregate.getMacro("list").selectedValue.
</text>
</template>
Notice how the controls are aligned to the left, as shown in Figure 25.
Figure 25. Rule wizard example 3
The composite editor uses a GridBagLayout. You can specify the GridBagConstraints for each label and for each editor using the <constraints> and <label-constraints> tags. Any property you set in a GridBagConstraints object can be specified as an attribute of one of these tags. Introduce constants defined by the GridBagConstraints class to use their symbolic name (such as HORIZONTAL).