Home » Eclipse Projects » Remote Application Platform (RAP) » GridLayout difference with RCP
GridLayout difference with RCP [message #121876] |
Wed, 18 February 2009 11:24  |
Eclipse User |
|
|
|
Hi all,
Like almost everybody, I want to use the same code in RAP and RCP.
I'm working on a editor with Forms, Section and Table using GridLayout and
I do not have the same display in RCP and RAP (RCP result is the one I
also want on RAP).
Am I missing something ?
Thanks,
Loïc
Here is the code :
public class LayoutEditor extends EditorPart
{
private ManagedForm managedForm;
@Override
public void createPartControl(Composite parent)
{
FormToolkit toolkit = new FormToolkit(parent.getDisplay());
managedForm = new ManagedForm(toolkit, toolkit
.createScrolledForm(parent));
managedForm.getForm().setText("Title");
GridLayout layout = new GridLayout();
layout.marginWidth = 2;
managedForm.getForm().getBody().setLayout(layout);
Section paramSection = toolkit.createSection(managedForm.getForm()
.getBody(), Section.TITLE_BAR | Section.TWISTIE
| Section.CLIENT_INDENT);
paramSection.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false,
false));
paramSection.setText("param section");
paramSection.addExpansionListener(new ExpansionAdapter()
{
@Override
public void expansionStateChanged(ExpansionEvent e)
{
managedForm.getForm().reflow(true);
}
});
Composite paramSectionClient =
toolkit.createComposite(paramSection,
SWT.NONE);
paramSection.setClient(paramSectionClient);
paramSectionClient.setLayout(new GridLayout());
Section resultSection = toolkit.createSection(managedForm.getForm()
.getBody(), Section.TITLE_BAR | Section.TWISTIE
| Section.CLIENT_INDENT);
resultSection.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false,
false));
resultSection.setText("result section");
resultSection.addExpansionListener(new ExpansionAdapter()
{
@Override
public void expansionStateChanged(ExpansionEvent e)
{
managedForm.getForm().reflow(true);
}
});
toolkit = new FormToolkit(resultSection.getDisplay());
Composite sectionClient = toolkit.createComposite(resultSection,
SWT.NONE);
resultSection.setClient(sectionClient);
sectionClient.setLayout(new GridLayout());
final Tree tree = new Tree(paramSectionClient, SWT.BORDER);
tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
for (int i = 0; i < 4; i++)
{
TreeItem iItem = new TreeItem(tree, 0);
iItem.setText("TreeItem (0) -" + i);
for (int j = 0; j < 4; j++)
{
TreeItem jItem = new TreeItem(iItem, 0);
jItem.setText("TreeItem (1) -" + j);
for (int k = 0; k < 4; k++)
{
TreeItem kItem = new TreeItem(jItem, 0);
kItem.setText("TreeItem (2) -" + k);
for (int l = 0; l < 4; l++)
{
TreeItem lItem = new TreeItem(kItem, 0);
lItem.setText("TreeItem (3) -" + l);
for (int m = 0; m < 4; m++)
{
TreeItem mItem = new TreeItem(lItem, 0);
mItem.setText("TreeItem (3) -" + l);
}
}
}
}
}
Composite gridComposite = toolkit.createComposite(sectionClient,
SWT.NONE);
gridComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false,
false));
gridComposite.setLayout(new GridLayout(1, true));
final ScrolledForm form =
toolkit.createScrolledForm(gridComposite);
form.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
form.getBody().setLayout(new GridLayout());
Section section = toolkit.createSection(form.getBody(),
Section.TITLE_BAR | Section.TWISTIE | Section.CLIENT_INDENT
| Section.EXPANDED);
section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false,
false));
section.addExpansionListener(new ExpansionAdapter()
{
public void expansionStateChanged(ExpansionEvent e)
{
form.reflow(true);
managedForm.getForm().reflow(true);
}
});
Composite composite = toolkit.createComposite(section, SWT.NONE);
composite.setLayout(new GridLayout(1, true));
section.setClient(composite);
Composite gridTableComposite = toolkit.createComposite(composite,
SWT.NONE);
gridTableComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL,
false, false));
gridTableComposite.setLayout(new GridLayout(1, true));
Composite borderComp = new Composite(gridTableComposite, SWT.NONE);
borderComp.setBackground(IhmUtilHolder.getIhmUtil().getColor (
borderComp, 0, 0, 0));
borderComp
.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false,
false));
GridLayout gridLayout = new GridLayout();
gridLayout.marginBottom = -3;
gridLayout.marginTop = -3;
gridLayout.marginLeft = -3;
gridLayout.marginRight = -3;
borderComp.setLayout(gridLayout);
Table table = new Table(borderComp, SWT.MULTI | SWT.BORDER
| SWT.FULL_SELECTION);
table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false,
false));
table.setLinesVisible(true);
table.setHeaderVisible(true);
String[] titles =
{ " ", "C", "!", "Description", "Resource", "In Folder",
"Location",
"Location", "Location" };
for (int i = 0; i < titles.length; i++)
{
TableColumn column = new TableColumn(table, SWT.NONE);
column.setText(titles[i]);
}
for (int i = 0; i < 100; i++)
{
TableItem item = new TableItem(table, SWT.NONE);
item.setText(0, "x");
item.setText(1, "y");
item.setText(2, "!");
item.setText(3, "this stuff behaves the way I expect");
item.setText(4, "almost everywhere");
item.setText(5, "some.folder");
item.setText(6, "line " + i + " in nowhere");
item.setText(7, "line " + i + " in nowhere");
item.setText(8, "line " + i + " in nowhere");
}
for (int i = 0; i < titles.length; i++)
{
table.getColumn(i).pack();
}
}
@Override
public void doSave(IProgressMonitor monitor)
{
// TODO Auto-generated method stub
}
@Override
public void doSaveAs()
{
// TODO Auto-generated method stub
}
@Override
public void init(IEditorSite site, IEditorInput input)
throws PartInitException
{
setSite(site);
setInput(input);
}
@Override
public boolean isDirty()
{
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isSaveAsAllowed()
{
// TODO Auto-generated method stub
return false;
}
@Override
public void setFocus()
{
// TODO Auto-generated method stub
}
}
|
|
|
Re: GridLayout difference with RCP [message #121927 is a reply to message #121876] |
Wed, 18 February 2009 14:54   |
Eclipse User |
|
|
|
Hi Loïc,
Loïc Bertholet wrote:
> Like almost everybody, I want to use the same code in RAP and RCP.
> I'm working on a editor with Forms, Section and Table using GridLayout
> and I do not have the same display in RCP and RAP (RCP result is the one
> I also want on RAP).
I guess it is unlikely that anyone reading here has the time to analyze
your code to find out what exactly the problem is you experience. You
should rather try to describe the difference and/or provide screenshots.
In general, there is no difference between layouts in RAP and in RCP -
in fact, it's the exact same code. What might cause a different
appearance is that certain widgets may have slightly different preferred
sizes, due to different font sizes etc. Anyway, you should try to narrow
down the problem.
Best regards,
Ralf
> Here is the code :
>
> public class LayoutEditor extends EditorPart
> {
> private ManagedForm managedForm;
>
> @Override
> public void createPartControl(Composite parent)
> {
> FormToolkit toolkit = new FormToolkit(parent.getDisplay());
> managedForm = new ManagedForm(toolkit, toolkit
> .createScrolledForm(parent));
>
> managedForm.getForm().setText("Title");
> GridLayout layout = new GridLayout();
> layout.marginWidth = 2;
>
> managedForm.getForm().getBody().setLayout(layout);
>
> Section paramSection = toolkit.createSection(managedForm.getForm()
> .getBody(), Section.TITLE_BAR | Section.TWISTIE
> | Section.CLIENT_INDENT);
>
> paramSection.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false,
> false));
>
> paramSection.setText("param section");
>
> paramSection.addExpansionListener(new ExpansionAdapter()
> {
> @Override
> public void expansionStateChanged(ExpansionEvent e)
> {
> managedForm.getForm().reflow(true);
> }
> });
>
> Composite paramSectionClient = toolkit.createComposite(paramSection,
> SWT.NONE);
> paramSection.setClient(paramSectionClient);
> paramSectionClient.setLayout(new GridLayout());
>
> Section resultSection = toolkit.createSection(managedForm.getForm()
> .getBody(), Section.TITLE_BAR | Section.TWISTIE
> | Section.CLIENT_INDENT);
>
> resultSection.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false,
> false));
>
> resultSection.setText("result section");
>
> resultSection.addExpansionListener(new ExpansionAdapter()
> {
> @Override
> public void expansionStateChanged(ExpansionEvent e)
> {
> managedForm.getForm().reflow(true);
> }
> });
>
> toolkit = new FormToolkit(resultSection.getDisplay());
> Composite sectionClient = toolkit.createComposite(resultSection,
> SWT.NONE);
> resultSection.setClient(sectionClient);
> sectionClient.setLayout(new GridLayout());
>
> final Tree tree = new Tree(paramSectionClient, SWT.BORDER);
> tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
> for (int i = 0; i < 4; i++)
> {
> TreeItem iItem = new TreeItem(tree, 0);
> iItem.setText("TreeItem (0) -" + i);
> for (int j = 0; j < 4; j++)
> {
> TreeItem jItem = new TreeItem(iItem, 0);
> jItem.setText("TreeItem (1) -" + j);
> for (int k = 0; k < 4; k++)
> {
> TreeItem kItem = new TreeItem(jItem, 0);
> kItem.setText("TreeItem (2) -" + k);
> for (int l = 0; l < 4; l++)
> {
> TreeItem lItem = new TreeItem(kItem, 0);
> lItem.setText("TreeItem (3) -" + l);
> for (int m = 0; m < 4; m++)
> {
> TreeItem mItem = new TreeItem(lItem, 0);
> mItem.setText("TreeItem (3) -" + l);
> }
>
> }
> }
> }
> }
>
> Composite gridComposite = toolkit.createComposite(sectionClient,
> SWT.NONE);
>
> gridComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false,
> false));
>
> gridComposite.setLayout(new GridLayout(1, true));
>
> final ScrolledForm form = toolkit.createScrolledForm(gridComposite);
> form.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
> form.getBody().setLayout(new GridLayout());
>
> Section section = toolkit.createSection(form.getBody(),
> Section.TITLE_BAR | Section.TWISTIE | Section.CLIENT_INDENT
> | Section.EXPANDED);
>
> section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false,
> false));
> section.addExpansionListener(new ExpansionAdapter()
> {
> public void expansionStateChanged(ExpansionEvent e)
> {
> form.reflow(true);
> managedForm.getForm().reflow(true);
> }
> });
>
> Composite composite = toolkit.createComposite(section, SWT.NONE);
>
> composite.setLayout(new GridLayout(1, true));
> section.setClient(composite);
>
> Composite gridTableComposite = toolkit.createComposite(composite,
> SWT.NONE);
>
> gridTableComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL,
> false, false));
>
> gridTableComposite.setLayout(new GridLayout(1, true));
>
> Composite borderComp = new Composite(gridTableComposite, SWT.NONE);
> borderComp.setBackground(IhmUtilHolder.getIhmUtil().getColor (
> borderComp, 0, 0, 0));
> borderComp
> .setLayoutData(new GridData(SWT.FILL, SWT.FILL, false,
> false));
> GridLayout gridLayout = new GridLayout();
> gridLayout.marginBottom = -3;
> gridLayout.marginTop = -3;
> gridLayout.marginLeft = -3;
> gridLayout.marginRight = -3;
> borderComp.setLayout(gridLayout);
>
> Table table = new Table(borderComp, SWT.MULTI | SWT.BORDER
> | SWT.FULL_SELECTION);
> table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
> table.setLinesVisible(true);
> table.setHeaderVisible(true);
>
> String[] titles =
> { " ", "C", "!", "Description", "Resource", "In Folder", "Location",
> "Location", "Location" };
> for (int i = 0; i < titles.length; i++)
> {
> TableColumn column = new TableColumn(table, SWT.NONE);
> column.setText(titles[i]);
> }
>
> for (int i = 0; i < 100; i++)
> {
> TableItem item = new TableItem(table, SWT.NONE);
> item.setText(0, "x");
> item.setText(1, "y");
> item.setText(2, "!");
> item.setText(3, "this stuff behaves the way I expect");
> item.setText(4, "almost everywhere");
> item.setText(5, "some.folder");
> item.setText(6, "line " + i + " in nowhere");
> item.setText(7, "line " + i + " in nowhere");
> item.setText(8, "line " + i + " in nowhere");
> }
>
> for (int i = 0; i < titles.length; i++)
> {
> table.getColumn(i).pack();
> }
>
> }
>
> @Override
> public void doSave(IProgressMonitor monitor)
> {
> // TODO Auto-generated method stub
>
> }
>
> @Override
> public void doSaveAs()
> {
> // TODO Auto-generated method stub
>
> }
>
> @Override
> public void init(IEditorSite site, IEditorInput input)
> throws PartInitException
> {
> setSite(site);
> setInput(input);
>
> }
>
> @Override
> public boolean isDirty()
> {
> // TODO Auto-generated method stub
> return false;
> }
>
> @Override
> public boolean isSaveAsAllowed()
> {
> // TODO Auto-generated method stub
> return false;
> }
>
> @Override
> public void setFocus()
> {
> // TODO Auto-generated method stub
>
> }
>
> }
>
>
|
|
|
Re: GridLayout difference with RCP [message #121940 is a reply to message #121927] |
Wed, 18 February 2009 17:46   |
Eclipse User |
|
|
|
Thanks Ralf for your answer.
First, how can I add screenshot via the Eclipse NewsPortal ?
Then I will try to describe the differences :
I have a ScrolledForm with a Section. Everybody have GridLayout / GridData
with SWT.FILL and Grab excess to false.
In the Section I have a Table with several rows and columns.
In RCP the table is well displayed with scrollbar on the editor to see all
of it.
In RAP the table is really small, the same width as the section title (so
only one column can be see) and the height to see one row. I have
scrollbar on the table to see other columns / rows.
It may be more explicit with screenshot (if someone can help me to provide
them...)
Thanks,
Loïc
Ralf Sternberg wrote:
> Hi Loïc,
> Loïc Bertholet wrote:
>> Like almost everybody, I want to use the same code in RAP and RCP.
>> I'm working on a editor with Forms, Section and Table using GridLayout
>> and I do not have the same display in RCP and RAP (RCP result is the one
>> I also want on RAP).
> I guess it is unlikely that anyone reading here has the time to analyze
> your code to find out what exactly the problem is you experience. You
> should rather try to describe the difference and/or provide screenshots.
> In general, there is no difference between layouts in RAP and in RCP -
> in fact, it's the exact same code. What might cause a different
> appearance is that certain widgets may have slightly different preferred
> sizes, due to different font sizes etc. Anyway, you should try to narrow
> down the problem.
> Best regards,
> Ralf
|
|
| | |
Re: GridLayout difference with RCP [message #122003 is a reply to message #121991] |
Thu, 19 February 2009 04:47   |
Eclipse User |
|
|
|
Hi,
have you tried to replace
new GridData(SWT.FILL, SWT.FILL, false, false));
with
new GridData(SWT.FILL, SWT.FILL, true, true));
when creating the table and its parent composites?
However, if exactly the same code layouts different in RCP and RAP, this
is probably a bug.
Regards,
Stefan.
Loïc Bertholet schrieb:
> Unfortunately, I can't use Thunderbird or other news reader... I only
> have Eclipse NewsPortal.
>
> Here are two link with screenshots :
>
> RCP : http://f.imagehost.org/0869/RCP.jpg
> RAP : http://g.imagehost.org/0004/RAP.jpg
>
> Stefan Roeck wrote:
>
>> You can simply add it to your Newsgroup posting as many others did
>> before (e.g. MenuBar property "menuBarShellClientArea" not preserved)
>
>> This works fine with Thunderbird, for instance.
>
>> Regards,
>> Stefan.
>
>
|
|
|
Re: GridLayout difference with RCP [message #122015 is a reply to message #122003] |
Thu, 19 February 2009 05:02   |
Eclipse User |
|
|
|
Thanks you for looking at my screenshots.
Yes, it's exactly the same code. Is it possible to consider this bug ?
I've tried with grabExcess to true like you say and in RAP the table take
indeed all the editor available space. However, if there is not enough
space, the horizontal scrollbar is created on the table (instead of on the
editor in RCP).
Moreover in RCP, when I increase the editor horizontally, the table also
increase its last column width to fill all the space (and I want my table
to always keep its minimum size).
Regards,
Loïc
Stefan Roeck wrote:
> Hi,
> have you tried to replace
> new GridData(SWT.FILL, SWT.FILL, false, false));
> with
> new GridData(SWT.FILL, SWT.FILL, true, true));
> when creating the table and its parent composites?
> However, if exactly the same code layouts different in RCP and RAP, this
> is probably a bug.
> Regards,
> Stefan.
|
|
|
Re: GridLayout difference with RCP [message #122042 is a reply to message #122015] |
Thu, 19 February 2009 05:19   |
Eclipse User |
|
|
|
Hi Loïc,
> Thanks you for looking at my screenshots.
>
> Yes, it's exactly the same code. Is it possible to consider this bug ?
>
> I've tried with grabExcess to true like you say and in RAP the table
> take indeed all the editor available space. However, if there is not
> enough space, the horizontal scrollbar is created on the table (instead
> of on the editor in RCP).
>
> Moreover in RCP, when I increase the editor horizontally, the table also
> increase its last column width to fill all the space (and I want my
> table to always keep its minimum size).
The problem is that the Table#computeSize() method obviously returns the
default 64x64 px (plus some px for the border). With this shortcoming,
it's not possible to get the "minimum" size for the Table. You'll have
to find a workaround, like Stefan suggested. Sorry for that.
I reopened bug 223895: [Table] Revise Table#computeSize()
https://bugs.eclipse.org/bugs/show_bug.cgi?id=223895
Regards, Ralf
|
|
| | | | | |
Re: GridLayout difference with RCP [message #122172 is a reply to message #122159] |
Fri, 20 February 2009 11:11   |
Eclipse User |
|
|
|
Originally posted by: benjamin.wolff.web.de
Hi,
just a little comment, you should consider checking http://www.eclipse.org/rap/noteworthy/ regularly. there you can see what the milestones bring with them and the fixed bugs, then you'll see why it
is most recommendable to use the latest milestone release :).
Greetings,
Ben
Loïc Bertholet schrieb:
> Great, thank you Ivan, it works perfectly !
> I should have tried last milestone sooner...
>
> Regards,
>
> Loïc
>
> Ivan Furnadjiev wrote:
>
>> Hi Loïc,
>
>> the reason for your problems is using the RAP version 1.1.1. The bug
>> 223895: [Table] Revise Table#computeSize()
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=223895
>> that Ralf reopened is marked as fixed in 1.2M2.
>> Use the target platform 1.2M2 or higher. Latest target platform is
>> 1.2M5 and can download it from:
>> http://www.eclipse.org/rap/downloads/
>
>> Best,
>> Ivan
>
|
|
|
Re: GridLayout difference with RCP [message #122197 is a reply to message #122172] |
Fri, 20 February 2009 12:34  |
Eclipse User |
|
|
|
Yes, I'm sorry, I should have tried with the lastest milestone.
However I won't use it because my application may be released soon and I
need a stable version. I hope it won't be so soon so I could integrated
1.2.0 final version in June.
Loïc
Ben W. wrote:
> Hi,
> just a little comment, you should consider checking
http://www.eclipse.org/rap/noteworthy/ regularly. there you can see what the
milestones bring with them and the fixed bugs, then you'll see why it
> is most recommendable to use the latest milestone release :).
> Greetings,
> Ben
|
|
|
Goto Forum:
Current Time: Mon May 05 06:14:01 EDT 2025
Powered by FUDForum. Page generated in 0.06276 seconds
|