Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » SWT.WRAP on Composite
SWT.WRAP on Composite [message #808283] Mon, 27 February 2012 15:56 Go to next message
M. Emmerling is currently offline M. EmmerlingFriend
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.
Re: SWT.WRAP on Composite [message #809879 is a reply to message #808283] Wed, 29 February 2012 11:45 Go to previous message
Lakshmi P ShanmugamFriend
Messages: 279
Registered: July 2009
Location: India
Senior Member
Hi,

SWT.WRAP style on the Button is right. May be the problem is related to TableWrapLayout. You should try asking in the Platform User Assistance(UA) forum.


Lakshmi P Shanmugam

[Updated on: Wed, 29 February 2012 11:47]

Report message to a moderator

Previous Topic:SWT import problems
Next Topic:ExpandItem Text Size won't change on Linux
Goto Forum:
  


Current Time: Fri Apr 26 01:06:15 GMT 2024

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

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

Back to the top