Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » TableWrapLayout on JFace Dialog(Placing controls on Dialog using TableWrapLayout and TableWrapData)
TableWrapLayout on JFace Dialog [message #888560] Mon, 18 June 2012 09:36 Go to next message
Aravindhan Annamalai is currently offline Aravindhan AnnamalaiFriend
Messages: 89
Registered: July 2009
Location: Chennai
Member
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 #888566 is a reply to message #888560] Mon, 18 June 2012 09:47 Go to previous messageGo to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
Hi,

the parent composite you are setting TableWrapData on, has a parent with the GridLayout. Look at the createDialogArea method javadoc.
Re: TableWrapLayout on JFace Dialog [message #888626 is a reply to message #888566] Mon, 18 June 2012 11:47 Go to previous messageGo to next message
Aravindhan Annamalai is currently offline Aravindhan AnnamalaiFriend
Messages: 89
Registered: July 2009
Location: Chennai
Member
So.. That concludes that TableWrapLayout can't be used within JFace Dialog as such.
Re: TableWrapLayout on JFace Dialog [message #888694 is a reply to message #888626] Mon, 18 June 2012 13:58 Go to previous message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
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;
Previous Topic:TableViewer with custom cell editor
Next Topic:Scroll Bar in JFace Dialog
Goto Forum:
  


Current Time: Sun Jun 16 17:21:36 GMT 2024

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

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

Back to the top