TableWrapLayout on JFace Dialog [message #888560] |
Mon, 18 June 2012 05:36  |
Eclipse User |
|
|
|
Hi,
I have a button which should open up a dialog when the user clicks on it.
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
TestDialog testDialog = new TestDialog(container.getShell());
testDialog.setPolicy(policy);
testDialog.open();
}
});
I am trying to use TableWrapLayout inside TestDialog, like below
@Override
protected Control createDialogArea(Composite parent) {
//Composite composite = new Composite(parent, 0); NOT WORKING
TableWrapLayout tableWrapLayout = new TableWrapLayout();
tableWrapLayout.numColumns = 3;
tableWrapLayout.verticalSpacing = 1;
tableWrapLayout.horizontalSpacing = 1;
TableWrapData twd = new TableWrapData(TableWrapData.FILL_GRAB);
parent.setLayout(tableWrapLayout);
parent.setLayoutData(twd);
Button button = new Button(parent, SWT.NONE);
button.setText("test");
return parent;
}
which gives me a ClassCastException... org.eclipse.ui.forms.widgets.TableWrapData
cannot be cast to org.eclipse.swt.layout.GridData
Am I missing something here?
Regards,
Aravind
|
|
|
|
|
Re: TableWrapLayout on JFace Dialog [message #888694 is a reply to message #888626] |
Mon, 18 June 2012 09:58  |
Eclipse User |
|
|
|
No, just the composite returned from the createDialogArea must have the GridData as a layout data. This composite itself can use whatever layout you need. Something like that:
Composite composite = (Composite) super.createDialogArea(parent);
TableWrapLayout tableWrapLayout = new TableWrapLayout();
tableWrapLayout.numColumns = 3;
tableWrapLayout.verticalSpacing = 1;
tableWrapLayout.horizontalSpacing = 1;
composite.setLayout(tableWrapLayout);
Composite content = new Composite(composite, SWT.NONE);
TableWrapData twd = new TableWrapData(TableWrapData.FILL_GRAB);
content.setLayout(new FillLayout());
content.setLayoutData(twd);
Button button = new Button(parent, SWT.NONE);
button.setText("test");
return composite;
|
|
|
Powered by
FUDForum. Page generated in 0.59268 seconds