// If the ruler has a label, add it to the left of it, using an
// ItemGroup and a TableLayout. The ItemGroup needs to be created
// before the frame, otherwise layouting issues arise...
// Ideally this should be resolved, but as ADM is on its way out,
// just work around it for now.
ItemGroup group;
String label = component.getLabel();
if (label != null && !label.equals("")) {
group = new ItemGroup(dialog);
TextPane labelItem = new TextPane(dialog);
labelItem.setText(label);
// Use 3 rows, so the center one with the ruler gets centered,
// then span the label across all three.
double[][] sizes = {
new double[] { TableLayout.PREFERRED, TableLayout.FILL },
new double[] { TableLayout.FILL, TableLayout.PREFERRED,
TableLayout.FILL }
};
group.setLayout(new TableLayout(sizes));
group.add(labelItem, "0, 0, 0, 2");
group.setMarginTop(2);
} else {
group = null;
}
Frame frame = new Frame(dialog);
frame.setStyle(FrameStyle.SUNKEN);
// Margin needs to be set before changing size...
// TODO: Fix this in UI package?
int top = label != null ? 2 : 4, bottom = 4;
frame.setMargin(top, 0, bottom, 0);
// Margin is included inside size, not added. This is different
// to how things works with CSS...
// TODO: Fix this in UI package?
frame.setHeight(2 + top + bottom);
// Now finish setting up the layout group and label
if (group != null) {
group.add(frame, "1, 1, full, center");
item = group;
} else {
item = frame;
}
}