Scrolledcomposite eating up more than half of the inner composite. [message #771923] |
Wed, 28 December 2011 09:43  |
Eclipse User |
|
|
|
I know this problem have been mentioned and solved before in this forum but nothing working out for me.
I am using a ScrolledComposite in a JFace Dialog. I need to create a Template selection dialog box which displays Images and number of images will be read from a file.
The problem I am facing is that ScrolledComposite is eating up all the more than half of the inner composite. Scrolled Composite is not able to read the complete content and hence not scrolling the complete content. I have tried adding ReSize listener but no use. After adding listener, I need to resize the dialog to see fulll content and after it, it scroll complete content.
Link to Dialog BluePrint: 
Code I have written is:
========================================
public void createChildSection (Composite parent, Component element)
{
List<Component> childTemplates = element.getChildren();
createSeparator(parent);
createLabelText(parent, element);
Composite child = new Composite (parent, 0);
GridLayout childLayout = new GridLayout(5, true);
childLayout.marginBottom = 5;
childLayout.marginTop = 5;
childLayout.marginLeft = 10;
childLayout.marginRight = 10;
childLayout.makeColumnsEqualWidth = true;
childLayout.horizontalSpacing = 20;
childLayout.verticalSpacing = 15;
child.setLayout(childLayout);
child.setBackground(new Color(getShell().getDisplay(), 255, 255, 255));
for (int i=0; i<childTemplates.size(); ++i)
{
Component template = childTemplates.get(i);
createImage(child, template);
}
}
public void createDialogSection(Composite parent, ArrayList<Component> templates)
{
List<Component> totalTemplateType = templates.get(0).getChildren();
parent.setLayout(new GridLayout());
parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
parent.setBackground(new Color(getShell().getDisplay(), 255, 255, 255));
for ( int i=0; i<totalTemplateType.size(); ++i )
{
Component childTemplate = totalTemplateType.get(i);
createChildSection(parent, childTemplate);
}
}
protected Control createDialogArea(Composite parent) {
Composite composite = new Composite(parent, 0);
getShell().setText("Select Template");
setDialogSizeAndLocation();
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 2;
composite.setLayout(gridLayout);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
// Creating Scrollable composite
final ScrolledComposite scrolledComposite = new ScrolledComposite(composite, SWT.V_SCROLL | SWT.BORDER);
scrolledComposite.setExpandVertical(true);
scrolledComposite.setExpandHorizontal(true);
final Composite parentSection = new Composite(scrolledComposite, 0);
scrolledComposite.setMinSize(IMAGE_SECTION_WIDTH, IMAGE_SECTION_HEIGHT);
parentSection.addListener(SWT.Resize, new Listener() {
int width = -1;
public void handleEvent(Event e) {
int newWidth = parentSection.getSize().y;
if (newWidth != width) {
scrolledComposite.setMinHeight(parentSection.computeSize(IMAGE_SECTION_WIDTH, newWidth).y);
width = newWidth;
}
}
});
scrolledComposite.setContent(parentSection);
scrolledComposite.setAlwaysShowScrollBars(true);
scrolledComposite.setLayout(new GridLayout());
scrolledComposite.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, true, true));
createDialogSection(parentSection, (ArrayList<Component>) getTableInput());
applyDialogFont(composite);
return composite;
}
========================================
|
|
|
|
Powered by
FUDForum. Page generated in 0.04605 seconds