Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Does ScrolledComposite work in Dialog?
Does ScrolledComposite work in Dialog? [message #114790] Mon, 08 December 2008 14:07 Go to next message
David Donohue is currently offline David DonohueFriend
Messages: 104
Registered: July 2009
Senior Member
Hello,
I would like a scrolling popup dialog. I have subclassed this class
org.eclipse.jface.dialogs.Dialog. My dialogs work, but nothing I try
makes them scrolling. I have successfully gotten WizardPages to scrol
using ScrolledComposite. Here is a code snippet, which creates a
ScrolledComposite, which contains "pageComposite", which contains a text
at the top, plus "formComposite". "formComposite" contains 150 form
elements.
What I see is the top of the form, but no scroll bars, and no "Save" or
"Cancel" buttons at the bottom.
Thanks!
David


@Override
protected Control createDialogArea(Composite parent) {
Shell shell = parent.getShell();
shell.setText(getTitle());

scrolledComposite = new ScrolledComposite(parent, SWT.V_SCROLL |
SWT.H_SCROLL | SWT.RESIZE);
GridLayout gl = new GridLayout(1, true);
scrolledComposite.setLayout(gl);
scrolledComposite.setExpandHorizontal(true);
scrolledComposite.setExpandVertical(true);
GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL |
GridData.GRAB_HORIZONTAL);
scrolledComposite.setLayoutData(gridData);

pageComposite = new Composite(scrolledComposite, SWT.NONE);
gl = new GridLayout(1, true);
pageComposite.setLayout(gl);
gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
pageComposite.setLayoutData(gridData);

messageText = new Text(pageComposite, SWT.WRAP | SWT.READ_ONLY);
messageText.setText(getMessage());

gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL |
GridData.GRAB_HORIZONTAL);
messageText.setLayoutData(gridData);

formComposite = new Composite(pageComposite, SWT.NONE);

scrolledComposite.addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent e) {
scrolledComposite.setMinSize(pageComposite.computeSize(SWT.D EFAULT,
SWT.DEFAULT));
}
});

//add 150 form elements to the formComposite:
addFormElements();
scrolledComposite.setContent(pageComposite);
scrolledComposite.setMinSize(pageComposite.computeSize(SWT.D EFAULT,
SWT.DEFAULT));

return scrolledComposite;
}
Re: Does ScrolledComposite work in Dialog? [message #114985 is a reply to message #114790] Tue, 09 December 2008 13:08 Go to previous message
David Donohue is currently offline David DonohueFriend
Messages: 104
Registered: July 2009
Senior Member
I found the solution for my problem with scroll bars not showing up/absent
from my Dialog. Here was the helpful post I found
http://dev.eclipse.org/newslists/news.eclipse.platform.rcp/m sg27482.html

The fix for me was to change setMinSize() of the ScrolledComposite to the
size of itself, like this
scrolledComposite.setMinSize(scrolledComposite.computeSize(S WT.DEFAULT,
SWT.DEFAULT));

Below is my code that works

@Override
protected Control createDialogArea(Composite parent) {
Composite container = (Composite) super.createDialogArea(parent);
container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
container.setLayout(new GridLayout());

Shell shell = parent.getShell();
shell.setText(getTitle());

ScrolledComposite scrolled = new ScrolledComposite(container,
SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
scrolled.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
scrolled.setLayout(new GridLayout());
scrolled.setExpandVertical(true);
scrolled.setExpandHorizontal(true);

scrolledComposite = new ScrolledComposite(container, SWT.V_SCROLL |
SWT.H_SCROLL);
GridLayout gl = new GridLayout();
scrolledComposite.setLayout(gl);
scrolledComposite.setExpandHorizontal(true);
scrolledComposite.setExpandVertical(true);
GridData gridData = new GridData(GridData.FILL_BOTH);
scrolledComposite.setLayoutData(gridData);

pageComposite = new Composite(scrolledComposite, SWT.NONE);
gl = new GridLayout(1, true);
pageComposite.setLayout(gl);
gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
pageComposite.setLayoutData(gridData);

messageText = new Text(pageComposite, SWT.WRAP | SWT.READ_ONLY);
if (getMessage() != null) {
messageText.setText(getMessage());
}
gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL |
GridData.GRAB_HORIZONTAL);
messageText.setLayoutData(gridData);

formComposite = new Composite(pageComposite, SWT.NONE);

scrolledComposite.addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent e) {

scrolledComposite.setMinSize(scrolledComposite.computeSize(S WT.DEFAULT,
SWT.DEFAULT));
}
});

addFormElements();

scrolledComposite.setContent(pageComposite);

scrolledComposite.setMinSize(scrolledComposite.computeSize(S WT.DEFAULT,
SWT.DEFAULT));

return scrolledComposite;
}
Previous Topic:CheckboxTreeViewer - Multiple Column - Right Justified Text
Next Topic:Different font in different table columns
Goto Forum:
  


Current Time: Sat Jan 28 08:11:08 GMT 2023

Powered by FUDForum. Page generated in 0.01995 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top