Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How do you wrap text for an RTC extension UI without excess white space?

 I've been following Lab 5 in the RTC Extension workshop trying to create an aspect editor for m extension. I've got all the functionality working but when I try to create long text or labels to describe sections of the ui for the user, I've been having trouble with the text wrapping.


Section textSection = toolkit.createSection(parent, ExpandableComposite.TITLE_BAR);
Composite textComp = toolkit.createComposite(textSection);

textSection.setClient(textComp);
textSection.setText("Text Title");

Text textLine = new Text(textComp, SWT.SINGLE);
textLine.setText(Long text entry);

GridLayoutFactory layoutFactory = GridLayoutFactory.fillDefaults().spacing(HORZ_SPAC, VERT_SPAC).numColumns(1);
layoutFactory.generateLayout(textComp);

This previous code got me one line that extended off screen,

Text textLine = new Text(textComp, SWT.WRAP);
textLine.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
textLine.setText(Long text entry);

With this, I still got one line, but I could scroll horizontally to see all the text. When I removed the GridData line, the text would wrap normally like I want it to, but it has twice the height as needed with a ton of extra white space between the text and the next UI object. How can I wrap this text without having extra white space between the UI objects?

0 votes



One answer

Permanent link

Try:
GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(textLine);

0 votes

Comments

 I added this but it resulted in one line that extended off the page with a horizontal scrollbar.

Text textLine = new Text(textComp, SWT.WRAP);
textLine.setText(Long text entry);

GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(textLine);

GridLayoutFactory layoutFactory = GridLayoutFactory.fillDefaults().spacing(HORZ_SPAC, VERT_SPAC).numColumns(1);

Sounds like the Text is doing what it should per the GridData given to it. It appears the parent is too wide, so either the Composite, the Section, or the secton's parent (but the entire code is not available so it's hard to say.)

You could give the Text a .Hint to limit the width though.

Also, this question really should be in an Eclipse/SWT forum as it has nothing to do with any of the CLM products.

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938

Question asked: Jan 16 '20, 10:39 a.m.

Question was seen: 1,168 times

Last updated: Jan 16 '20, 1:47 p.m.

Confirmation Cancel Confirm