// a hack - based on first column more likely being wider
return setup2ColumnLayout(managedForm, 60, 40);
}
public Form2Panel setup2ColumnLayoutNotSash(IManagedForm managedForm, boolean equalWidth) {
final ScrolledForm sform = managedForm.getForm();
final Composite form = sform.getBody();
GridLayout layout = new GridLayout(2, equalWidth);
form.setLayout(layout);
form.setLayoutData(new GridData(GridData.FILL_BOTH));
leftPanel = newComposite(form);
rightPanel = newComposite(form);
// strategy for setting size hints of right and left panels
// Why set hints? Because they make the inner containing things
// scroll horiz. if they're too wide (useful for aggregates having
// long names).
// What hint to set? The hint should be the smallest size you want
// with child scrolling, before the tabbed page container itself
// gets a scroll bar.
// When in the life cycle to do this? Only need to do it once, but
// after the Grid Layout has happened. This can be the first resizing
// event (learned this by debugging)
sform.addListener(SWT.Resize, new Listener() {
public void handleEvent(Event event) {
float col1CurrentWidth = leftPanel.getSize().x;
float col2CurrentWidth = rightPanel.getSize().x;
final int minLeftPanelWidth = 250; // in pels
final int minRightPanelWidth = (int) (col2CurrentWidth * minLeftPanelWidth / col1CurrentWidth);
((GridData) leftPanel.getLayoutData()).widthHint = minLeftPanelWidth;
((GridData) rightPanel.getLayoutData()).widthHint = minRightPanelWidth;
sform.removeListener(SWT.Resize, this); // only do this one time
}
});
return new Form2Panel(form, leftPanel, rightPanel);
}