Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Multi line text field and TableWrapLayout
Multi line text field and TableWrapLayout [message #333784] Mon, 05 January 2009 20:48
AJ  is currently offline AJ Friend
Messages: 77
Registered: July 2009
Member
Hi there,

Why are multi-line Text fields always displayed with 1 line height when it
is used within a section contained by a form that uses a TableWrapLayout
in conjunction with TableWrapData?

However, if the form uses GridLayout + GridData, then the Text is
displayed with the correct 3 or 4 lines height. Please snippet below.

Thanks in advance!


-----------------

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.widgets.ExpandableComposite;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.eclipse.ui.forms.widgets.Section;
import org.eclipse.ui.forms.widgets.TableWrapData;
import org.eclipse.ui.forms.widgets.TableWrapLayout;

public class Test {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display, SWT.SHELL_TRIM);
shell.setLayout(new GridLayout());

FormToolkit toolkit = new FormToolkit(display);
final ScrolledForm form = toolkit.createScrolledForm(shell);
form.getBody().setLayout(new TableWrapLayout());
// form.getBody().setLayout(new GridLayout());
form.setText("Form");

Composite composite = toolkit.createComposite(form.getBody());
TableWrapData layoutData = new TableWrapData(TableWrapData.FILL_GRAB,
TableWrapData.FILL_GRAB, 2, 1);
layoutData.maxWidth = 400;

// GridData layoutData = new GridData(GridData.FILL_BOTH);
// layoutData.horizontalSpan = 2;
// layoutData.verticalSpan = 1;
// layoutData.widthHint = 400;

composite.setLayoutData(layoutData);
composite.setLayout(new GridLayout(1, true));

Section section = toolkit.createSection(composite,
ExpandableComposite.TITLE_BAR);
GridData sectionLayoutData = new GridData(SWT.FILL, SWT.FILL, true,
true);
sectionLayoutData.horizontalSpan = 2;
sectionLayoutData.verticalIndent = 6;
section.setLayoutData(sectionLayoutData);
section.setRedraw(true);
section.setText("Section title");

Composite sectionClient = toolkit.createComposite(section);
GridLayout sectionClientLayout = new GridLayout(2, false);
sectionClientLayout.verticalSpacing = 2;
sectionClientLayout.horizontalSpacing = 10;
sectionClient.setLayout(sectionClientLayout);
section.setClient(sectionClient);

Label label = toolkit.createLabel(sectionClient, "Description : ");
label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));

Text suggestTemplateText = toolkit.createText(sectionClient, "",
SWT.MULTI
| SWT.BORDER | SWT.V_SCROLL);
toolkit.adapt(suggestTemplateText, true, true);
suggestTemplateText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
true));

shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
}
Previous Topic:No solution found because the problem in /tmp/p2Encoding13004.opb is unsatisfiable.
Next Topic:How to add an action to context menu of web and ejb projects
Goto Forum:
  


Current Time: Fri Nov 08 22:52:39 GMT 2024

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

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

Back to the top