I am trying to implement a scrolled composite for one of the composite (top composite as shown in the picture). My intention is to add a scroll bar for the upper composite only, because when the window gets resized then save button becomes invisible sometimes.
I have tried with scrolled composite implementation for the upper composite. But when I try to resize it then I am not getting a scroll bar for it even if I have set the minimum size for the scrolledComposite.
Also when I specify scrolledComposite.setAlwaysShowScrollBars(true)
, I am able to see only the placeholder for the scrollbar which is in disabled mode.
Below is my code snippet.
public void init() {
setFocus();
preInit();
createCaseGroup(this);
//Here "this" is the parent composite
Composite childComp = new Composite(this, SWT.None);
childComp.setLayout(new GridLayout(2, true));
childComp.setLayoutData(new GridData(GridData.FILL_BOTH));
final ScrolledComposite scrolledComposite = new ScrolledComposite(childComp,
SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
final Composite Comp = new Composite(scrolledComposite, SWT.NONE);
Comp.setLayout(new GridLayout(2, true));
Comp.setLayoutData(new GridData(GridData.FILL_BOTH));
scrolledComposite.setContent(Comp);
scrolledComposite.setExpandHorizontal(true);
scrolledComposite.setExpandVertical(true);
// scrolledComposite.setMinSize(Comp.computeSize(400, 400) );
scrolledComposite.setMinSize(400, 400);
scrolledComposite.setAlwaysShowScrollBars(true);
objectComposite = new GUIObjectComposite(Comp, SWT.NONE, true);
objectComposite.setLayout(new GridLayout(3, false));
objectComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
objectComposite.init();
objectComposite.isNullSelectionAllowed(false);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
gridData.heightHint = 130;
gridData.horizontalSpan = 2;
objectComposite.setLayoutData(gridData);
GridLayout layout = new GridLayout(1, false);
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.verticalSpacing = 0;
objectComposite.setLayout(layout);
// Group for Define interaction(s)
Group defineInteractionGroup = new Group(childComp, SWT.NONE);
GridData defineInteractionGridData = new GridData(SWT.FILL, SWT.FILL, true, true);
defineInteractionGridData.horizontalSpan = 2;
defineInteractionGroup.setLayoutData(defineInteractionGridData);
GridLayout defineInteractionLayout = new GridLayout(1, true);
defineInteractionLayout.marginHeight = 0;
defineInteractionLayout.marginWidth = 0;
defineInteractionLayout.verticalSpacing = 0;
defineInteractionGroup.setLayout(defineInteractionLayout);
defineInteractionGroup
.setText(ResourceAssistant.getString(InteractionExpandedComposite.class, "defineInteraction")); //$NON-NLS-1$
// Composite for Define interaction(s)
Composite interactionComposite = new Composite(defineInteractionGroup, SWT.NONE);
interactionComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
GridLayout interactionCompositeLayout = new GridLayout(11, true);
interactionCompositeLayout.marginHeight = 10;
interactionCompositeLayout.verticalSpacing = 0;
interactionComposite.setLayout(interactionCompositeLayout);
Composite actionsComposite = new Composite(interactionComposite, SWT.NONE);
GridData actionsCompositeGridData = new GridData(SWT.FILL, SWT.FILL, true, true);
actionsCompositeGridData.horizontalSpan = 2;
actionsComposite.setLayoutData(actionsCompositeGridData);
ActionsFormProvider actionsFormProvider = new ActionsFormProvider();
List<IFormItem> actionFormItems = actionsFormProvider.generateFormItems();
for (IFormItem actionItem : actionFormItems) {
actionItem.create(actionsComposite);
}
IWorkbenchWindow iWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPartSite activePartSite = iWorkbenchWindow.getActivePage().getActivePart().getSite();
activePartSite.setSelectionProvider(objectComposite.getViewer());
ISelectionService selectionService = iWorkbenchWindow.getSelectionService();
if (selectionService instanceof AbstractSelectionService) {
AbstractSelectionService abstractSelectionService = (AbstractSelectionService) selectionService;
abstractSelectionService.setActivePart(null);
abstractSelectionService.setActivePart(getExpandedView());
}
}