GridData hierarchyData = new GridData(GridData.FILL_VERTICAL);
hierarchy.setLayoutData(hierarchyData);
// the right hand column will be scrollable
ScrolledComposite controlsScroller =
new ScrolledComposite(formContainer,
SWT.H_SCROLL | SWT.V_SCROLL);
controlsScroller.setLayout(new FillLayout());
controlsScroller.setLayoutData(new GridData(GridData.FILL_BOTH));
controlsScroller.setExpandHorizontal(true);
controlsScroller.setExpandVertical(true);
controlsScroller.setAlwaysShowScrollBars(false);
controlsScroller.setBackground(white);
// add the container for the identification section
Composite column2 =
new Composite(controlsScroller, SWT.NONE);
GridLayout column2Layout = new GridLayout();
column2Layout.marginHeight = 0;
column2Layout.marginWidth = 0;
column2Layout.verticalSpacing = VERTICAL_SPACING;
GridData column2Data = new GridData(GridData.FILL_BOTH);
column2.setLayout(column2Layout);
column2.setLayoutData(column2Data);
column2.setBackground(white);
// add the identification section
identification = new DeviceIdentificationSection(
column2,
SWT.NONE,
accessorManager);
GridData identificationData = new GridData(GridData.FILL_HORIZONTAL);
identification.setLayoutData(identificationData);
// add the policies section
devicePolicies =
new DevicePoliciesSection(column2,
SWT.NONE, accessorManager);
devicePolicies.setLayoutData(new GridData(GridData.FILL_BOTH));
final ISelectionChangedListener listener =
new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
updateSelection();
}
};
hierarchy.addSelectionChangedListener(listener);
// force selection of the hierarchy. This appears to persuade the tree
// to build its entire internal representation and therefore stops a
// large delay from occuring when the tree first obtains focus.
hierarchy.setSelection(new StructuredSelection(accessorManager.
getDeviceHierarchyDocument().getRootElement().
getChildren().get(0)));
addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent event) {
hierarchy.removeSelectionChangedListener(listener);
}
});
column2.setSize(column2.computeSize(SWT.DEFAULT, SWT.DEFAULT));
column2.layout();
controlsScroller.setMinSize(
column2.computeSize(SWT.DEFAULT, SWT.DEFAULT));
controlsScroller.setContent(column2);
layout();
}