Bug 376822 - [CLabel] Strange behavior with his client area
Summary: [CLabel] Strange behavior with his client area
Status: ASSIGNED
Alias: None
Product: RAP
Classification: RT
Component: RWT (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-04-15 09:07 EDT by zzzz CLA
Modified: 2014-04-16 07:38 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description zzzz CLA 2012-04-15 09:07:28 EDT
Build Identifier: 1.5M5 and 1.5M6

I try to create a "Text" object over an "CLabel", in a mode that the Text cover the entire label.
With SWT work fine, but with RAP 1.5M5 the "Text" has wrong position, with RAP 1.5M6 give an error.


With RAP 1.5M6 the error is:

Error: Error: Operation "create" on target "w4" of type "null" failed:
c.getChildren() is null
Properties:
parent = w3
style = LEFT,SINGLE
bounds = 6,6,288,38
tabIndex = 2
background = 255,0,0,255

Reproducible: Always

Steps to Reproduce:
Display display = new Display ();
Shell shell = new Shell(display);
shell.setSize(600,300);

CLabel label = new CLabel(shell, SWT.NONE);
label.setBounds(50,50,300,50);
label.setBackground( display.getSystemColor(SWT.COLOR_BLUE) );

Text t = new Text(label, SWT.NONE);
Rectangle r = label.getClientArea();
t.setBounds( r );
t.setBackground( display.getSystemColor(SWT.COLOR_RED) );

shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
Comment 1 Ivan Furnadjiev CLA 2012-04-17 03:20:35 EDT
I got a slightly different error, but the reason is the same - the fix for bug 373765:
..
Error: Error: Operation "create" on target "w4" of type "null" failed:
Error in property parent of class org.eclipse.rwt.widgets.Text in method setParent with incoming value '[object org.eclipse.rwt.widgets.Label]': Is invalid!
..
Before, the client-side Label/CLabel was a qx.ui.basic.Atom which extends qx.ui.core.Parent. After the re-factoring the client-side Label/CLabel now extends org.eclipse.rwt.widgets.MultiCellWidget which is *not* a qx.ui.core.Parent.
Comment 2 Ralf Sternberg CLA 2012-04-17 12:10:41 EDT
Even if it's valid SWT code, CLabel is not designed to host child widgets. I'd recommend that you create the CLabel and the Text widgets with the same parent and set both to the same bounds. The widget you created last will be on top, but you can also use Control#moveAbove() and #moveBelow() to change their z-order. This practice will also work around this JavaScript error.
Comment 3 zzzz CLA 2012-04-17 13:15:40 EDT
ok, but this workaround has other problems, for example if the CLabel is in a Composite with a layout, than the layout is wrong.

The code, however, is similar for Table and Tree, when a Text is created over a Table for editing an element
Comment 4 Ralf Sternberg CLA 2012-04-22 07:19:27 EDT
(In reply to comment #3)
> ok, but this workaround has other problems, for example if the CLabel is in a
> Composite with a layout, than the layout is wrong.
> 
> The code, however, is similar for Table and Tree, when a Text is created over a
> Table for editing an element
In this case, you could create one Composite with a StackLayout that contains the Text and the CLabel, and include this Composite in the parent instead of the CLabel.

I really believe that using the CLabel as a Composite is a misuse of the SWT API. You cannot do this with a Label, and CLabel only inherits from Composite because as a custom widget, it has to extend Canvas which in turn inherits from Composite, not because it is meant to host other widgets.