Home » Eclipse Projects » Remote Application Platform (RAP) » Custom Widget: Composing Qooxdoo Widgets in CanvasLayout, the widget is not shown.
Custom Widget: Composing Qooxdoo Widgets in CanvasLayout, the widget is not shown. [message #513384] |
Tue, 09 February 2010 17:48 |
Nikolai Raitsev Messages: 102 Registered: July 2009 |
Senior Member |
|
|
This is a multi-part message in MIME format.
--------------060001080801000301000705
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit
Hi again,
I'm trying to create a simple Custom Widget, that composites qooxdoos
atom. The Widget is CanvasLayout based. But I have a problem, that the
widget is not shown in RAP-Application. HttpFox says me, that the widget
is created and data is setted.
I don't know, what I could do as next, please help me.
First, here the log from HttpFox
-------------------
var w = wm.newWidget( "w28", "w27", true, "custom.widgets.CanvasWidget",
'"w28", wm.findWidgetById( "w27" )' );
w.setAppearance( "composite" );
w.setOverflow( "hidden" );
w.setText( "Hallo Canvas Widget!!!" );
-------------------
what I see here is, that the ZIndex is not setted (comparing to other
composites, the CanvasWidget on Java side extends swt.Composite)
As attachment you can find the CanvasWidget.js, CanvasWidget.java and
CanvasWidgetLCA.java
I'm using it in a View in a following way:
CanvasWidget canvasWidget = new CanvasWidget(parent, SWT.NONE);
canvasWidget.setText("Hallo Canvas Widget!!!");
What should I consider when creating custom widgets?
Many thanks in advance and best regards,
Nikolai
--------------060001080801000301000705
Content-Type: text/x-java;
name="CanvasWidget.java"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="CanvasWidget.java"
cGFja2FnZSBjdXN0b20ud2lkZ2V0czsKCmltcG9ydCBvcmcuZWNsaXBzZS5z d3Qud2lkZ2V0
cy5Db21wb3NpdGU7CgpwdWJsaWMgY2xhc3MgQ2FudmFzV2lkZ2V0ICBleHRl bmRzIENvbXBv
c2l0ZSAgewoKCXByaXZhdGUgU3RyaW5nIHRleHQ7CgkKCXB1YmxpYyBDYW52 YXNXaWRnZXQo
Q29tcG9zaXRlIHBhcmVudCwgaW50IHN0eWxlKSB7CgkJc3VwZXIocGFyZW50 LCBzdHlsZSk7
Cgl9CgkKCXB1YmxpYyB2b2lkIHNldFRleHQoU3RyaW5nIHRleHQpCgl7CgkJ dGhpcy50ZXh0
ID0gdGV4dDsKCX0KCQoJcHVibGljIFN0cmluZyBnZXRUZXh0KCkKCXsKCQly ZXR1cm4gdGV4
dDsKCX0KfQ==
--------------060001080801000301000705
Content-Type: application/javascript;
name="CanvasWidget.js"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="CanvasWidget.js"
qx.Class.define("custom.widgets.CanvasWidget", {
extend : qx.ui.layout.CanvasLayout,
construct : function(id, parent) {
this.base(arguments);
this.setHtmlProperty("id", id);
this._id = id;
this._parent = parent;
this._text = "Test Text";
this._myAtomHeight = 24;
this._myAtom = new qx.ui.basic.Atom("Test");
this._myAtom.setHeight(this._myAtomHeight);
this.addEventListener("changeHeight", this._doResize, this);
this.addEventListener("changeWidth", this._doResize, this);
this._myAtom.setLabel(this._text);
this.add(this._myAtom);
this._myAtom.setShow("both");
//Adding to parent here???
//does not works in RAP, but in Qooxdoo application!
//this._parent.add(this);
},
destruct : function() {
this._disposeObjects("_myAtom");
},
members : {
setImage : function(image) {
this._image = image;
this._myAtom.setIcon(image);
},
setText : function(text) {
this._text = text;
this._myAtom.setLabel(text);
},
setAtomHeight : function(atomHeight) {
this.error("setatomHeight");
this._myAtomHeight = atomHeight;
this._myAtom.setHeight(this._myAtomHeight);
},
_doResize : function() {
qx.ui.core.Widget.flushGlobalQueues();
}
}
});
--------------060001080801000301000705
Content-Type: text/x-java;
name="CanvasWidgetLCA.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="CanvasWidgetLCA.java"
package custom.widgets.internal.canvaswidgetkit;
import java.io.IOException;
import org.eclipse.rwt.lifecycle.AbstractWidgetLCA;
import org.eclipse.rwt.lifecycle.ControlLCAUtil;
import org.eclipse.rwt.lifecycle.IWidgetAdapter;
import org.eclipse.rwt.lifecycle.JSWriter;
import org.eclipse.rwt.lifecycle.WidgetLCAUtil;
import org.eclipse.rwt.lifecycle.WidgetUtil;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Widget;
import custom.widgets.CanvasWidget;
public class CanvasWidgetLCA extends AbstractWidgetLCA {
public static final String PROP_TEXT = "text";
public static final String PROP_HEADER_HEIGHT = "myAtomHeight";
public static final Integer DEFAULT_HEADER_HEIGHT = new Integer( 24 );
public void preserveValues( final Widget widget ) {
CanvasWidget CanvasWidget = ( CanvasWidget )widget;
ControlLCAUtil.preserveValues( ( Control )widget );
IWidgetAdapter adapter = WidgetUtil.getAdapter( widget );
adapter.preserve( PROP_TEXT, CanvasWidget.getText() );
adapter.preserve( PROP_HEADER_HEIGHT, DEFAULT_HEADER_HEIGHT );
}
public void readData( final Widget widget ) {
final CanvasWidget CanvasWidget = ( CanvasWidget )widget;
//Do nothing here...
}
public void renderInitialization( final Widget widget ) throws IOException {
CanvasWidget canvasWidget = ( CanvasWidget )widget;
JSWriter writer = JSWriter.getWriterFor( canvasWidget );
String id = WidgetUtil.getId( widget );
Object[] args = new Object[]{ id, canvasWidget.getParent() };
writer.newWidget( "custom.widgets.CanvasWidget", args );
writer.set( "appearance", "composite" );
writer.set( "overflow", "hidden" );
ControlLCAUtil.writeStyleFlags( ( CanvasWidget )widget );
WidgetLCAUtil.writeCustomVariant( widget );
}
public void renderChanges( final Widget widget ) throws IOException {
CanvasWidget expandItem = ( CanvasWidget )widget;
writeText( expandItem );
}
public void renderDispose( final Widget widget ) throws IOException {
JSWriter writer = JSWriter.getWriterFor( widget );
writer.dispose();
}
////////////////////////////////////////////
// Helping methods to render JavaScript code
private static void writeText( final CanvasWidget item ) throws IOException {
String text = item.getText();
if( WidgetLCAUtil.hasChanged( item, PROP_TEXT, text ) ) {
text = WidgetLCAUtil.escapeText( text, false );
JSWriter writer = JSWriter.getWriterFor( item );
writer.set( PROP_TEXT, text );
}
}
}
--------------060001080801000301000705--
|
|
|
Re: Custom Widget: Composing Qooxdoo Widgets in CanvasLayout, the widget is not shown. [message #513431 is a reply to message #513384] |
Wed, 10 February 2010 03:24 |
Ivan Furnadjiev Messages: 2427 Registered: July 2009 Location: Sofia, Bulgaria |
Senior Member |
|
|
Hi Nikolai,
I think that the missing part is:
.....
ControlLCAUtil.writeChanges( expandItem );
....
in CanvasWidgetLCA#renderChanges. The ControlLCAUtil.writeChanges writes
to the client all common control properties like bounds, visible,
enable... Currently your custom widget is with zero bounds.
HTH,
Ivan
On 2/10/2010 12:41 AM, Nikolai Raitsev wrote:
> Hi again,
>
> I'm trying to create a simple Custom Widget, that composites qooxdoos
> atom. The Widget is CanvasLayout based. But I have a problem, that the
> widget is not shown in RAP-Application. HttpFox says me, that the
> widget is created and data is setted.
>
> I don't know, what I could do as next, please help me.
>
> First, here the log from HttpFox
> -------------------
>
> var w = wm.newWidget( "w28", "w27", true,
> "custom.widgets.CanvasWidget", '"w28", wm.findWidgetById( "w27" )' );
> w.setAppearance( "composite" );
> w.setOverflow( "hidden" );
> w.setText( "Hallo Canvas Widget!!!" );
>
> -------------------
>
> what I see here is, that the ZIndex is not setted (comparing to other
> composites, the CanvasWidget on Java side extends swt.Composite)
>
> As attachment you can find the CanvasWidget.js, CanvasWidget.java and
> CanvasWidgetLCA.java
>
> I'm using it in a View in a following way:
>
> CanvasWidget canvasWidget = new CanvasWidget(parent, SWT.NONE);
> canvasWidget.setText("Hallo Canvas Widget!!!");
>
>
> What should I consider when creating custom widgets?
>
> Many thanks in advance and best regards,
>
> Nikolai
|
|
|
Re: Custom Widget: Composing Qooxdoo Widgets in CanvasLayout, the widget is not shown. [message #513696 is a reply to message #513431] |
Wed, 10 February 2010 20:30 |
Nikolai Raitsev Messages: 102 Registered: July 2009 |
Senior Member |
|
|
Ivan, many thanks!
I knew that it is something simple! My eyes have just not seen ...
Best regards,
Nikolai
Ivan Furnadjiev schrieb:
> Hi Nikolai,
>
> I think that the missing part is:
> ....
> ControlLCAUtil.writeChanges( expandItem );
> ...
> in CanvasWidgetLCA#renderChanges. The ControlLCAUtil.writeChanges writes
> to the client all common control properties like bounds, visible,
> enable... Currently your custom widget is with zero bounds.
>
> HTH,
> Ivan
>
>
> On 2/10/2010 12:41 AM, Nikolai Raitsev wrote:
>> Hi again,
>>
>> I'm trying to create a simple Custom Widget, that composites qooxdoos
>> atom. The Widget is CanvasLayout based. But I have a problem, that the
>> widget is not shown in RAP-Application. HttpFox says me, that the
>> widget is created and data is setted.
>>
>> I don't know, what I could do as next, please help me.
>>
>> First, here the log from HttpFox
>> -------------------
>>
>> var w = wm.newWidget( "w28", "w27", true,
>> "custom.widgets.CanvasWidget", '"w28", wm.findWidgetById( "w27" )' );
>> w.setAppearance( "composite" );
>> w.setOverflow( "hidden" );
>> w.setText( "Hallo Canvas Widget!!!" );
>>
>> -------------------
>>
>> what I see here is, that the ZIndex is not setted (comparing to other
>> composites, the CanvasWidget on Java side extends swt.Composite)
>>
>> As attachment you can find the CanvasWidget.js, CanvasWidget.java and
>> CanvasWidgetLCA.java
>>
>> I'm using it in a View in a following way:
>>
>> CanvasWidget canvasWidget = new CanvasWidget(parent, SWT.NONE);
>> canvasWidget.setText("Hallo Canvas Widget!!!");
>>
>>
>> What should I consider when creating custom widgets?
>>
>> Many thanks in advance and best regards,
>>
>> Nikolai
|
|
|
Goto Forum:
Current Time: Thu Oct 10 12:06:59 GMT 2024
Powered by FUDForum. Page generated in 0.03190 seconds
|