Home » Eclipse Projects » Remote Application Platform (RAP) » Prevent horizontal scrolling in Form for long Text Content
Prevent horizontal scrolling in Form for long Text Content [message #521639] |
Thu, 18 March 2010 11:21 |
Arnaud MERGEY Messages: 243 Registered: March 2010 Location: France |
Senior Member |
|
|
Hi,
I'm currently studying rap for an application.
I have currently a small issue with layout in form.
In Section I would like to have my Text to fill available space in the editor, but without exceed the space available in the editor for long value displayed in Text.
Currently my long Text stretched the whole form, so I have horizontal scrollbar, I'd prefer to have to "browse" the long text inside the text itself.
For example I'd like to have similar behavior than PDE plugin.xml editor. If you fill a long value in Text like ID, the text doesn't grow and the whole form don't become scrollable.
I had a look on the code in order to implement similar layout, but I cannot find how.
above a simple sample FormPage that show my issue
Not sure if it is related to RAP, so sorry if it is not.
Thanks
public class TestLayoutPage extends FormPage {
private int nbPanel=2;
private int sectionPerPanel=2;
public TestLayoutPage(FormEditor pEditor) {
super(pEditor, "test.lyout.id", "Test Layout");
}
/**
* @see org.eclipse.ui.forms.editor.FormPage#createFormContent(org.e clipse.ui.forms.IManagedForm)
*/
@Override
protected void createFormContent(IManagedForm pManagedForm) {
pManagedForm.getForm().setText("test layout in form");
Composite body = pManagedForm.getForm().getBody();
body.setLayout(FormLayoutFactory.createFormTableWrapLayout(t rue, 2));
for(int i=1;i<=nbPanel;i++) {
createPanel(pManagedForm.getToolkit(), body);
}
}
private void createPanel(FormToolkit pFormToolkit,Composite pParent) {
Composite panel = pFormToolkit.createComposite(pParent);
panel.setLayout(FormLayoutFactory.createFormPaneTableWrapLay out(false, 1));
panel.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
for(int i=1;i<=sectionPerPanel;i++) {
createSection(pFormToolkit, panel);
}
}
private void createSection(FormToolkit pFormToolkit,Composite pParent) {
Section section=pFormToolkit.createSection(pParent, Section.TWISTIE | Section.TITLE_BAR | Section.EXPANDED);
section.setText("Section title");
section.setLayout(FormLayoutFactory.createClearTableWrapLayo ut(false, 1));
TableWrapData data = new TableWrapData(TableWrapData.FILL_GRAB);
section.setLayoutData(data);
Composite client = pFormToolkit.createComposite(section);
client.setLayout(FormLayoutFactory.createSectionClientTableW rapLayout(false, 2));
section.setClient(client);
createText(pFormToolkit, client, "label", false);
createText(pFormToolkit, client, "another label", true);
}
private void createText(FormToolkit pFormToolkit,Composite pParent,String pLabel,boolean pLongText) {
Label swtLabel=pFormToolkit.createLabel(pParent, pLabel);
TableWrapData td= new TableWrapData();
td.valign = TableWrapData.MIDDLE;
swtLabel.setLayoutData(td);
Text swtText=pFormToolkit.createText(pParent, null);
td = new TableWrapData(TableWrapData.FILL);
td.grabHorizontal = true;
td.valign = TableWrapData.MIDDLE;
swtText.setLayoutData(td);
if(pLongText) {
swtText.setText("This is a very very long text, that should not expand the form as we don't want to scroll the wall form This is a very very long text, that should not expand the form as we don't want to scroll the wall form This is a very very long text, that should not expand the form as we don't want to scroll the wall form This is a very very long text, that should not expand the form as we don't want to scroll the wall form This is a very very long text, that should not expand the form as we don't want to scroll the wall form");
} else{
swtText.setText("value");
}
}
}
[Updated on: Thu, 18 March 2010 13:25] Report message to a moderator
|
|
|
Re: Prevent vertical scrolling in Form for long Text Content [message #522210 is a reply to message #521639] |
Sun, 21 March 2010 10:10 |
|
Hi Arnaud,
you should try to create your text widget with the SWT.WRAP style flag
like so:
Text swtText = pFormToolkit.createText( pParent, null, SWT.MULTI |
SWT.WRAP );
Hope this helps,
Ralf
Arnaud MERGEY wrote:
> Hi,
>
> I'm currently studying rap for an application.
>
> I have currently a small issue with layout in form.
> In Section I would like to have my Text to fill available space in the
> editor, but without exceed the space available in the editor for long
> value displayed in Text. Currently my long Text stretched the whole
> form, so I have vertical scrollbar, I'd prefer to have to "browse" the
> long text inside the text itself.
> For example I'd like to have similar behavior than PDE plugin.xml
> editor. If you fill a long value in Text like ID, the text doesn't grow
> and the whole form don't become scrollable.
>
> I had a look on the code in order to implement similar layout, but I
> cannot find how.
> above a simple sample FormPage that show my issue
>
> Not sure if it is related to RAP, so sorry if it is not.
> Thanks
>
> public class TestLayoutPage extends FormPage {
> private int nbPanel=2;
> private int sectionPerPanel=2;
>
> public TestLayoutPage(FormEditor pEditor) {
> super(pEditor, "test.lyout.id", "Test Layout");
> }
>
> /**
> * @see
> org.eclipse.ui.forms.editor.FormPage#createFormContent(org.e
> clipse.ui.forms.IManagedForm)
> */
> @Override
> protected void createFormContent(IManagedForm pManagedForm) {
> pManagedForm.getForm().setText("test layout in form");
>
> Composite body = pManagedForm.getForm().getBody();
> body.setLayout(FormLayoutFactory.createFormTableWrapLayout(t
> rue, 2));
>
> for(int i=1;i<=nbPanel;i++) {
> createPanel(pManagedForm.getToolkit(), body);
> }
> }
>
> private void createPanel(FormToolkit pFormToolkit,Composite pParent) {
> Composite panel = pFormToolkit.createComposite(pParent);
> panel.setLayout(FormLayoutFactory.createFormPaneTableWrapLay
> out(false, 1));
> panel.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
>
> for(int i=1;i<=sectionPerPanel;i++) {
> createSection(pFormToolkit, panel);
> }
> }
>
> private void createSection(FormToolkit pFormToolkit,Composite
> pParent) {
> Section section=pFormToolkit.createSection(pParent,
> Section.TWISTIE | Section.TITLE_BAR | Section.EXPANDED);
> section.setText("Section title");
> section.setLayout(FormLayoutFactory.createClearTableWrapLayo
> ut(false, 1));
> TableWrapData data = new TableWrapData(TableWrapData.FILL_GRAB);
> section.setLayoutData(data);
>
> Composite client = pFormToolkit.createComposite(section);
> client.setLayout(FormLayoutFactory.createSectionClientTableW
> rapLayout(false, 2));
> section.setClient(client);
>
> createText(pFormToolkit, client, "label", false);
> createText(pFormToolkit, client, "another label", true);
> }
>
> private void createText(FormToolkit pFormToolkit,Composite
> pParent,String pLabel,boolean pLongText) {
> Label swtLabel=pFormToolkit.createLabel(pParent, pLabel);
>
> TableWrapData td= new TableWrapData();
> td.valign = TableWrapData.MIDDLE;
> swtLabel.setLayoutData(td);
>
> Text swtText=pFormToolkit.createText(pParent, null);
>
> td = new TableWrapData(TableWrapData.FILL);
> td.grabHorizontal = true;
> td.valign = TableWrapData.MIDDLE;
> swtText.setLayoutData(td);
>
> if(pLongText) {
> swtText.setText("This is a very very long text, that should
> not expand the form as we don't want to scroll the wall form This is a
> very very long text, that should not expand the form as we don't want to
> scroll the wall form This is a very very long text, that should not
> expand the form as we don't want to scroll the wall form This is a very
> very long text, that should not expand the form as we don't want to
> scroll the wall form This is a very very long text, that should not
> expand the form as we don't want to scroll the wall form");
> } else{
> swtText.setText("value");
> }
> }
> }
|
|
|
Goto Forum:
Current Time: Sat Oct 12 17:05:47 GMT 2024
Powered by FUDForum. Page generated in 0.04485 seconds
|