SWT.WRAP on Composite [message #808283] |
Mon, 27 February 2012 15:56 |
M. Emmerling Messages: 7 Registered: December 2011 Location: Palatinate |
Junior Member |
|
|
Hi there,
using the org.eclipse.ui.forms we faced some strange problems with the new wrap style for radiobuttons and checkboxes.
The following is a runnable demo:
package radiobuttontest;
import org.eclipse.jface.window.IShellProvider;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.forms.FormDialog;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.eclipse.ui.forms.widgets.TableWrapData;
import org.eclipse.ui.forms.widgets.TableWrapLayout;
public class LoremIpsumDialog extends FormDialog {
private static final String LOREM_IPSUM = "Lorem ipsum dolor sit amet, "
+ "consectetur adipisicing elit, sed do eiusmod tempor incididunt "
+ "ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis "
+ "nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo "
+ "consequat. Duis aute irure dolor in reprehenderit in voluptate velit "
+ "esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat "
+ "cupidatat non proident, sunt in culpa qui officia deserunt mollit "
+ "anim id est laborum.";
private FormToolkit toolkit;
public static void main(String[] args) {
Display display = Display.getDefault();
Shell shell = new Shell(display);
LoremIpsumDialog dialog = new LoremIpsumDialog(shell);
dialog.create();
dialog.getShell().setText("Lorem ipsum");
dialog.getShell().setSize(500, 500);
dialog.getShell().setLocation(100, 300);
dialog.getShell().layout();
dialog.open();
}
public LoremIpsumDialog(IShellProvider parentShellProvider) {
super(parentShellProvider);
}
public LoremIpsumDialog(Shell shell) {
super(shell);
}
@Override
protected void createFormContent(IManagedForm mform) {
mform.getForm().setText("An example of a simple form dialog");
ScrolledForm form = mform.getForm();
TableWrapLayout layout = new TableWrapLayout();
layout.leftMargin = 10;
layout.rightMargin = 10;
form.getBody().setLayout(layout);
toolkit = mform.getToolkit();
form.setText("Loremipsumdialogus");
TableWrapData td;
td = new TableWrapData();
td.align = TableWrapData.LEFT;
Composite composite = toolkit.createComposite(form.getBody());
composite.setBackground(getShell().getDisplay().getSystemColor(
SWT.COLOR_WIDGET_LIGHT_SHADOW));
createRadioButtons(composite);
mform.getToolkit().decorateFormHeading(mform.getForm().getForm());
}
private void createRadioButtons(Composite composite) {
FillLayout parent_layout = new FillLayout(SWT.VERTICAL);
composite.setLayout(parent_layout);
toolkit.createButton(composite, LOREM_IPSUM + " 1", SWT.RADIO
| SWT.WRAP);
toolkit.createButton(composite, LOREM_IPSUM + " 2", SWT.RADIO
| SWT.WRAP);
toolkit.createButton(composite, LOREM_IPSUM + " 3", SWT.RADIO
| SWT.WRAP);
toolkit.createButton(composite, LOREM_IPSUM + " 4", SWT.RADIO
| SWT.WRAP);
}
}
This dialog won't wrap the buttons as expected.
It was pure chance that we wangled it by also setting the SWT.WRAP-style for the parent composite for the buttons.
Works:
Composite composite = toolkit.createComposite(form.getBody(), SWT.WRAP);
Is this a lack in the API docs?
As I am a newbie and I wasn't sure either this is a bug or my fault, I decided to just post it in the forums. Maybe someone else has the same problem or wants to file a bug...
Kind regards,
M.
|
|
|
|
Powered by
FUDForum. Page generated in 0.03313 seconds