Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Again GridLayout difference with RCP (1.2 M5)
Again GridLayout difference with RCP (1.2 M5) [message #122392] Tue, 24 February 2009 11:47 Go to next message
Eclipse UserFriend
Originally posted by: bjoern.bjoernfischer.de

This is a multi-part message in MIME format.
--------------050002080606000408060809
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit

Hi everybody,
today I encountered a rendering difference between RAP and RCP
GridLayouting (using RAP 1.2 M5).

I am building a view that displays data only through labels. These
labels are layouted by a GridLayout. The first column contains a defined
caption, the second column will contain labels with the actual data but
the labels are empty on startup.

The screenshot rcp_gridLayout.png shows the view in RCP. The content
labels are colored blue. (The last row "Responsible" has a composite in
the second column that is layouted by a gridLayout itself).

When the view is opened in RAP, the labels are shortened to a minimun.
This is shown in rap_gridLayout.png.

I don't know where to locate this bug, maybe it is the Label that gives
a wrong size or something. I would appreciate any help to make the
labels look like the ones in RCP.

Regards,
Bj
Re: Again GridLayout difference with RCP (1.2 M5) [message #122403 is a reply to message #122392] Tue, 24 February 2009 12:25 Go to previous messageGo to next message
Ralf Sternberg is currently offline Ralf SternbergFriend
Messages: 1313
Registered: July 2009
Senior Member

Hi Björn,

can you provide a small code snippet that shows how your form is created?

Ralf

Björn Fischer wrote:
> Hi everybody,
> today I encountered a rendering difference between RAP and RCP
> GridLayouting (using RAP 1.2 M5).
>
> I am building a view that displays data only through labels. These
> labels are layouted by a GridLayout. The first column contains a defined
> caption, the second column will contain labels with the actual data but
> the labels are empty on startup.
>
> The screenshot rcp_gridLayout.png shows the view in RCP. The content
> labels are colored blue. (The last row "Responsible" has a composite in
> the second column that is layouted by a gridLayout itself).
>
> When the view is opened in RAP, the labels are shortened to a minimun.
> This is shown in rap_gridLayout.png.
>
> I don't know where to locate this bug, maybe it is the Label that gives
> a wrong size or something. I would appreciate any help to make the
> labels look like the ones in RCP.
>
> Regards,
> Björn
>
> ------------------------------------------------------------ ------------
>
>
> ------------------------------------------------------------ ------------
>
Re: Again GridLayout difference with RCP (1.2 M5) [message #122425 is a reply to message #122403] Tue, 24 February 2009 12:53 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bjoern.bjoernfischer.de

Ralf Sternberg schrieb:
> Hi Björn,
>
> can you provide a small code snippet that shows how your form is created?
>
> Ralf

Sure, here is the createPartControl of the view:

----------------------------------------------------
@Override
public void createPartControl(Composite parent) {

Display display = parent.getDisplay();

// register as SelectionListener to the View OrderssSummary
getSite().getPage().addSelectionListener(this);

final Form orderDetailsForm = toolkit.createForm(parent);
final Composite body = orderDetailsForm.getBody();
final GridLayout gridLayout = new GridLayout();
body.setLayout(gridLayout);

final Composite composite = new Composite(body, SWT.NONE);
final GridLayout gridLayout_1 = new GridLayout();
gridLayout_1.numColumns = 2;
composite.setLayout(gridLayout_1);
final GridData gd_composite = new GridData(SWT.LEFT, SWT.TOP, true, false);
gd_composite.heightHint = 106;
composite.setLayoutData(gd_composite);
toolkit.adapt(composite);

final Label orderLabel = toolkit.createLabel(composite, "Order", SWT.NONE);

dataOrder = toolkit.createLabel(composite, "new Forms Label", SWT.NONE);
dataOrder.setBackground(ColorManager.getInstance(display).ge tColor( "#5050FF"));
dataOrder.setRedraw(true);
dataOrder.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));

final Label statusLabel = toolkit.createLabel(composite, "Status",
SWT.NONE);

dataStatus = toolkit.createLabel(composite, "new Forms Label", SWT.NONE);
dataStatus.setRedraw(true);
dataStatus.setBackground(ColorManager.getInstance(display).g etColor( "#5050FF"));
dataStatus.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));

final Label labelPriority = toolkit.createLabel(composite, "Priority",
SWT.NONE);

dataPriority = toolkit.createLabel(composite, "new Forms Label", SWT.NONE);
dataPriority.setRedraw(true);
dataPriority.setBackground(ColorManager.getInstance(display) .getColor( "#5050FF"));
final GridData gd_dataPriority = new GridData(SWT.FILL, SWT.CENTER,
false, false);
dataPriority.setLayoutData(gd_dataPriority);

final Label offerLabel = toolkit.createLabel(composite, "Offer", SWT.NONE);

dataOffer = toolkit.createLabel(composite, "new Forms Label", SWT.NONE);
dataOffer.setRedraw(true);
dataOffer.setBackground(ColorManager.getInstance(display).ge tColor( "#5050FF"));
dataOffer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));

final Label labelResponsible = toolkit.createLabel(composite,
"Responsible", SWT.NONE);

final Composite composite_1 = new Composite(composite, SWT.NONE);
composite_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false,
false));
final GridLayout gridLayout_2 = new GridLayout();
gridLayout_2.marginWidth = 0;
gridLayout_2.marginHeight = 0;
gridLayout_2.numColumns = 2;
composite_1.setLayout(gridLayout_2);
toolkit.adapt(composite_1);

dataResponsible1 = toolkit.createLabel(composite_1, "new Forms Label",
SWT.NONE);
dataResponsible1.setBackground(ColorManager.getInstance(disp lay).getColor( "#5050FF"));
dataResponsible1.setLayoutData(new GridData());

dataResponsible2 = toolkit.createLabel(composite_1, "new Forms Label",
SWT.NONE);
dataResponsible2.setBackground(ColorManager.getInstance(disp lay).getColor( "#5050FF"));
dataResponsible2.setLayoutData(new GridData());
final Composite composite_2 = new Composite(body, SWT.NONE);
composite_2.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
composite_2.setLayout(new GridLayout());
toolkit.adapt(composite_2);
// toolkit.paintBordersFor(body);
orderDetailsForm.setText("Overview");
m_bindingContext = initDataBindings();
}
--------------------------------------------------

Regards,
Björn
Re: Again GridLayout difference with RCP (1.2 M5) [message #122453 is a reply to message #122425] Tue, 24 February 2009 16:02 Go to previous messageGo to next message
Ralf Sternberg is currently offline Ralf SternbergFriend
Messages: 1313
Registered: July 2009
Senior Member

Björn,

for me it looks as if the problem is not the layout of the form itself
but the size of the enclosing Composite. You could simply add a
background color to the composite that contains all the labels to be
able to see its size. If it turns out to be too way too small, you
should be able to create a simplified snippet with only one single label
that shows the same effect. This way you could narrow down the problem.
Could you try this?

Thanks, Ralf


Björn Fischer wrote:
> Ralf Sternberg schrieb:
>> Hi Björn,
>>
>> can you provide a small code snippet that shows how your form is created?
>>
>> Ralf
>
> Sure, here is the createPartControl of the view:
>
> ----------------------------------------------------
> @Override
> public void createPartControl(Composite parent) {
>
> Display display = parent.getDisplay();
>
> // register as SelectionListener to the View OrderssSummary
> getSite().getPage().addSelectionListener(this);
>
> final Form orderDetailsForm = toolkit.createForm(parent);
> final Composite body = orderDetailsForm.getBody();
> final GridLayout gridLayout = new GridLayout();
> body.setLayout(gridLayout);
>
> final Composite composite = new Composite(body, SWT.NONE);
> final GridLayout gridLayout_1 = new GridLayout();
> gridLayout_1.numColumns = 2;
> composite.setLayout(gridLayout_1);
> final GridData gd_composite = new GridData(SWT.LEFT, SWT.TOP, true,
> false);
> gd_composite.heightHint = 106;
> composite.setLayoutData(gd_composite);
> toolkit.adapt(composite);
>
> final Label orderLabel = toolkit.createLabel(composite, "Order",
> SWT.NONE);
>
> dataOrder = toolkit.createLabel(composite, "new Forms Label",
> SWT.NONE);
> dataOrder.setBackground(ColorManager.getInstance(display).ge tColor( "#5050FF"));
>
> dataOrder.setRedraw(true);
> dataOrder.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false,
> false));
>
> final Label statusLabel = toolkit.createLabel(composite, "Status",
> SWT.NONE);
>
> dataStatus = toolkit.createLabel(composite, "new Forms Label",
> SWT.NONE);
> dataStatus.setRedraw(true);
> dataStatus.setBackground(ColorManager.getInstance(display).g etColor( "#5050FF"));
>
> dataStatus.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false,
> false));
>
> final Label labelPriority = toolkit.createLabel(composite,
> "Priority", SWT.NONE);
>
> dataPriority = toolkit.createLabel(composite, "new Forms Label",
> SWT.NONE);
> dataPriority.setRedraw(true);
> dataPriority.setBackground(ColorManager.getInstance(display) .getColor( "#5050FF"));
>
> final GridData gd_dataPriority = new GridData(SWT.FILL, SWT.CENTER,
> false, false);
> dataPriority.setLayoutData(gd_dataPriority);
>
> final Label offerLabel = toolkit.createLabel(composite, "Offer",
> SWT.NONE);
>
> dataOffer = toolkit.createLabel(composite, "new Forms Label",
> SWT.NONE);
> dataOffer.setRedraw(true);
> dataOffer.setBackground(ColorManager.getInstance(display).ge tColor( "#5050FF"));
>
> dataOffer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false,
> false));
>
> final Label labelResponsible = toolkit.createLabel(composite,
> "Responsible", SWT.NONE);
>
> final Composite composite_1 = new Composite(composite, SWT.NONE);
> composite_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false,
> false));
> final GridLayout gridLayout_2 = new GridLayout();
> gridLayout_2.marginWidth = 0;
> gridLayout_2.marginHeight = 0;
> gridLayout_2.numColumns = 2;
> composite_1.setLayout(gridLayout_2);
> toolkit.adapt(composite_1);
>
> dataResponsible1 = toolkit.createLabel(composite_1, "new Forms
> Label", SWT.NONE);
> dataResponsible1.setBackground(ColorManager.getInstance(disp lay).getColor( "#5050FF"));
>
> dataResponsible1.setLayoutData(new GridData());
>
> dataResponsible2 = toolkit.createLabel(composite_1, "new Forms
> Label", SWT.NONE);
> dataResponsible2.setBackground(ColorManager.getInstance(disp lay).getColor( "#5050FF"));
>
> dataResponsible2.setLayoutData(new GridData());
> final Composite composite_2 = new Composite(body, SWT.NONE);
> composite_2.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true,
> false));
> composite_2.setLayout(new GridLayout());
> toolkit.adapt(composite_2);
> // toolkit.paintBordersFor(body);
> orderDetailsForm.setText("Overview");
> m_bindingContext = initDataBindings();
> }
> --------------------------------------------------
>
> Regards,
> Björn
Re: Again GridLayout difference with RCP (1.2 M5) [message #122624 is a reply to message #122453] Wed, 25 February 2009 14:38 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bjoern.bjoernfischer.de

Hi Ralf,
I narrowed the problem down a little bit. While testing I had the
feeling that this difference is somehow connected to data binding.

Anway, I rebuilt the whole View using text filds rather than Labels so
that this is not an issue for me anymore. If you want to have a further
look at this it would be nice, but to me it is not critical anymore. I
attached the source after the message.

Thanks for your help!

Regards,
Björn

P.S.: Here is the source that is rendered differently in RAP:
-------------------------------
package com.tp.lisa.navigator.ui.views;

import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.beans.BeansObservables;
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.core.databinding.observable.value.IObservableVal ue;
import org.eclipse.core.databinding.observable.value.WritableValue;
import org.eclipse.jface.databinding.swt.SWTObservables;
import org.eclipse.jface.resource.ColorRegistry;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.RGB;
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.ui.forms.widgets.Form;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.part.ViewPart;

public class OrderDetails extends ViewPart {
class Order {
public String orderId;
public Order() {
orderId = "";
}
public String getOrderId() {
return orderId;
}
public void setOrderId(String orderId) {
this.orderId = orderId;
}
}

private Label dataOrder;
public static final String ID =
"com.tp.lisa.navigator.ui.views.orderdetails";
private Order order = new Order();

private FormToolkit toolkit = new FormToolkit(Display.getCurrent());
private WritableValue orderValue;

public OrderDetails() {
orderValue = new WritableValue(order, Order.class);
}

@Override
public void createPartControl(Composite parent) {
Display display = parent.getDisplay();
ColorRegistry cr = new ColorRegistry(display);
cr.put("red", new RGB(255,0,0));
cr.put("green", new RGB(0,255,0));
cr.put("blue", new RGB(187,187,255));

final Form orderDetailsForm = toolkit.createForm(parent);
final Composite body = orderDetailsForm.getBody();
body.setBackground(cr.get("red"));
final GridLayout gridLayout = new GridLayout();
body.setLayout(gridLayout);

final Composite composite = new Composite(body, SWT.NONE);
composite.setBackground(cr.get("green"));

final GridLayout gridLayout_1 = new GridLayout();
gridLayout_1.numColumns = 2;
composite.setLayout(gridLayout_1);
final GridData gd_composite = new GridData(SWT.LEFT, SWT.TOP, true,
false);
gd_composite.heightHint = 200;
composite.setLayoutData(gd_composite);
toolkit.adapt(composite);

final Label orderLabel = toolkit.createLabel(composite, "Order",
SWT.NONE);

dataOrder = toolkit.createLabel(composite, "label", SWT.NONE);
dataOrder.setRedraw(true);
dataOrder.setBackground(cr.get("blue"));
dataOrder.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

orderDetailsForm.setText("Overview");
initDataBindings();
}

@Override
public void setFocus() {
}

protected DataBindingContext initDataBindings() {
IObservableValue dataOrderTextObserveWidget =
SWTObservables.observeText(dataOrder);
IObservableValue orderValueOrderIdObserveDetailValue =
BeansObservables.observeDetailValue(Realm.getDefault(), orderValue,
"orderId", java.lang.String.class);

DataBindingContext bindingContext = new DataBindingContext();

bindingContext.bindValue(dataOrderTextObserveWidget,
orderValueOrderIdObserveDetailValue, null, null);

return bindingContext;
}

}




Ralf Sternberg schrieb:
> Björn,
>
> for me it looks as if the problem is not the layout of the form itself
> but the size of the enclosing Composite. You could simply add a
> background color to the composite that contains all the labels to be
> able to see its size. If it turns out to be too way too small, you
> should be able to create a simplified snippet with only one single label
> that shows the same effect. This way you could narrow down the problem.
> Could you try this?
>
> Thanks, Ralf
Re: Again GridLayout difference with RCP (1.2 M5) [message #123131 is a reply to message #122624] Thu, 26 February 2009 10:06 Go to previous message
Ralf Sternberg is currently offline Ralf SternbergFriend
Messages: 1313
Registered: July 2009
Senior Member

Hi Björn,

your snippet renders almost the same in RAP and RCP. I guess your
problem is that you do not force the main composite to have full size
(e.g. by setting a FillLayout on the parent) and you do not set
appropriate layout data on the inner composites, but I do not see any
difference between RAP and RCP here.

Ralf

Björn Fischer wrote:
> Hi Ralf,
> I narrowed the problem down a little bit. While testing I had the
> feeling that this difference is somehow connected to data binding.
>
> Anway, I rebuilt the whole View using text filds rather than Labels so
> that this is not an issue for me anymore. If you want to have a further
> look at this it would be nice, but to me it is not critical anymore. I
> attached the source after the message.
>
> Thanks for your help!
>
> Regards,
> Björn
>
> P.S.: Here is the source that is rendered differently in RAP:
> -------------------------------
> package com.tp.lisa.navigator.ui.views;
>
> import org.eclipse.core.databinding.DataBindingContext;
> import org.eclipse.core.databinding.beans.BeansObservables;
> import org.eclipse.core.databinding.observable.Realm;
> import org.eclipse.core.databinding.observable.value.IObservableVal ue;
> import org.eclipse.core.databinding.observable.value.WritableValue;
> import org.eclipse.jface.databinding.swt.SWTObservables;
> import org.eclipse.jface.resource.ColorRegistry;
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.graphics.RGB;
> 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.ui.forms.widgets.Form;
> import org.eclipse.ui.forms.widgets.FormToolkit;
> import org.eclipse.ui.part.ViewPart;
>
> public class OrderDetails extends ViewPart {
> class Order {
> public String orderId;
> public Order() {
> orderId = "";
> }
> public String getOrderId() {
> return orderId;
> }
> public void setOrderId(String orderId) {
> this.orderId = orderId;
> }
> }
>
> private Label dataOrder;
> public static final String ID =
> "com.tp.lisa.navigator.ui.views.orderdetails";
> private Order order = new Order();
>
> private FormToolkit toolkit = new FormToolkit(Display.getCurrent());
> private WritableValue orderValue;
>
> public OrderDetails() {
> orderValue = new WritableValue(order, Order.class);
> }
>
> @Override
> public void createPartControl(Composite parent) {
> Display display = parent.getDisplay();
> ColorRegistry cr = new ColorRegistry(display);
> cr.put("red", new RGB(255,0,0));
> cr.put("green", new RGB(0,255,0));
> cr.put("blue", new RGB(187,187,255));
>
> final Form orderDetailsForm = toolkit.createForm(parent);
> final Composite body = orderDetailsForm.getBody();
> body.setBackground(cr.get("red"));
> final GridLayout gridLayout = new GridLayout();
> body.setLayout(gridLayout);
>
> final Composite composite = new Composite(body, SWT.NONE);
> composite.setBackground(cr.get("green"));
>
> final GridLayout gridLayout_1 = new GridLayout();
> gridLayout_1.numColumns = 2;
> composite.setLayout(gridLayout_1);
> final GridData gd_composite = new GridData(SWT.LEFT, SWT.TOP,
> true, false);
> gd_composite.heightHint = 200;
> composite.setLayoutData(gd_composite);
> toolkit.adapt(composite);
>
> final Label orderLabel = toolkit.createLabel(composite, "Order",
> SWT.NONE);
>
> dataOrder = toolkit.createLabel(composite, "label", SWT.NONE);
> dataOrder.setRedraw(true);
> dataOrder.setBackground(cr.get("blue"));
> dataOrder.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
> false));
>
> orderDetailsForm.setText("Overview");
> initDataBindings();
> }
>
> @Override
> public void setFocus() {
> }
>
> protected DataBindingContext initDataBindings() {
> IObservableValue dataOrderTextObserveWidget =
> SWTObservables.observeText(dataOrder);
> IObservableValue orderValueOrderIdObserveDetailValue =
> BeansObservables.observeDetailValue(Realm.getDefault(), orderValue,
> "orderId", java.lang.String.class);
>
> DataBindingContext bindingContext = new DataBindingContext();
>
> bindingContext.bindValue(dataOrderTextObserveWidget,
> orderValueOrderIdObserveDetailValue, null, null);
>
> return bindingContext;
> }
>
> }
>
>
>
>
> Ralf Sternberg schrieb:
>> Björn,
>>
>> for me it looks as if the problem is not the layout of the form itself
>> but the size of the enclosing Composite. You could simply add a
>> background color to the composite that contains all the labels to be
>> able to see its size. If it turns out to be too way too small, you
>> should be able to create a simplified snippet with only one single label
>> that shows the same effect. This way you could narrow down the problem.
>> Could you try this?
>>
>> Thanks, Ralf
Previous Topic:Changing thread group of UIThread
Next Topic:Read data from custom widget.
Goto Forum:
  


Current Time: Thu Feb 02 22:28:48 GMT 2023

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

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

Back to the top