Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » RWT extension
RWT extension [message #33624] Sat, 16 June 2007 00:58 Go to next message
Eclipse UserFriend
Originally posted by: nindl_go.hotmail.com

How can I extend the RWT in order to implement custom widgets and listeners?
I get a big image from the data source containing various objects. The image
is packed into a Label object. Further I have a map, which identifies the
internal objects by their x, y position when the user clicks on it.
Unfortunately Rap doesn't support low-level mouse events till release 1.0.
My second attempt was to cut the image server-side with the SWT GC library,
but it failed due to the incompatibilty or something else.

As far as I know you have to create a new Java class in the widgets/events
in the org.eclipse.swt.widgets/events of the org.eclipse.rap.rwt package. A
corresponding JavaScript class must also be created in the same subdirectory
of the js directory. The writing of a qooxdoo widget happens somewhere in a
class which implements the org.eclipse.swt.resources.IResource interface.

Another workaround would be the integration of a third party MouseListener
JavaScript. Can I just put it somewhere to wait for a call and process the
coordinates back to Rap?

Thankx for helping me, where to go from here!

Cheers, Gottfried
Re: RWT extension [message #33863 is a reply to message #33624] Mon, 18 June 2007 09:47 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rsternberg.innoopract.com

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

Hi Gottfried,

From what I understand, all you need is a mouse listener for the SWT
Label that passes the coordinates. I once wrote a "click label" (a Label
with a selection listener) as a workaround for missing mouse listeners -
maybe this can serve as a starting point for you (see attached files).
You would have to add some client- and server side code for the mouse
coordinates. However, note that this is only a hack, as SWT widgets
should not be subclassed, except for Canvas and Composite.

However, as there are many use cases for a MouseListener on a label, I
hope that we can implement it soon.

Ralf

Gottfried Nindl schrieb:
> How can I extend the RWT in order to implement custom widgets and listeners?
> I get a big image from the data source containing various objects. The image
> is packed into a Label object. Further I have a map, which identifies the
> internal objects by their x, y position when the user clicks on it.
> Unfortunately Rap doesn't support low-level mouse events till release 1.0.
> My second attempt was to cut the image server-side with the SWT GC library,
> but it failed due to the incompatibilty or something else.
>
> As far as I know you have to create a new Java class in the widgets/events
> in the org.eclipse.swt.widgets/events of the org.eclipse.rap.rwt package. A
> corresponding JavaScript class must also be created in the same subdirectory
> of the js directory. The writing of a qooxdoo widget happens somewhere in a
> class which implements the org.eclipse.swt.resources.IResource interface.
>
> Another workaround would be the integration of a third party MouseListener
> JavaScript. Can I just put it somewhere to wait for a call and process the
> coordinates back to Rap?
>
> Thankx for helping me, where to go from here!
>
> Cheers, Gottfried
>
>


--------------030700090909060605080301
Content-Type: text/plain;
name="ClickLabel.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="ClickLabel.java"

/*********************************************************** ********************
* Copyright (c) 2002-2006 Innoopract Informationssysteme GmbH.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Innoopract Informationssysteme GmbH - initial API and implementation
************************************************************ ******************/

package org.eclipse.rap.clicklabel;

import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;

public class ClickLabel extends Label {

public ClickLabel( final Composite parent, final int style ) {
super( parent, style );
}

public void addSelectionListener( final SelectionListener listener ) {
SelectionEvent.addListener( this, listener );
}

public void removeSelectionListener( final SelectionListener listener ) {
SelectionEvent.removeListener( this, listener );
}

}

--------------030700090909060605080301
Content-Type: text/plain;
name="ClickLabelLCA.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="ClickLabelLCA.java"

package org.eclipse.rap.internal.clicklabel.clicklabelkit;

import java.io.IOException;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.internal.widgets.Props;
import org.eclipse.swt.internal.widgets.labelkit.LabelLCA;
import org.eclipse.swt.lifecycle.*;
import org.eclipse.swt.widgets.Widget;

public class ClickLabelLCA extends LabelLCA {

private final static JSListenerInfo JS_LISTENER_INFO =
new JSListenerInfo( "click",
JSConst.JS_WIDGET_SELECTED,
JSListenerType.ACTION );

public void renderInitialization( Widget widget ) throws IOException
{
super.renderInitialization( widget );
JSWriter writer = JSWriter.getWriterFor( widget );
writer.set( "cursor", "pointer" );
}

public void readData( Widget widget )
{
super.readData( widget );
ControlLCAUtil.processSelection( widget, null, false );
}

public void renderChanges( Widget widget ) throws IOException
{
super.renderChanges( widget );
JSWriter writer = JSWriter.getWriterFor( widget );
writer.updateListener( JS_LISTENER_INFO,
Props.SELECTION_LISTENERS,
SelectionEvent.hasListener( widget ) );
writer.set( new String[] { "labelObject", "cursor" },
new Object[] { "pointer" } );
}

}

--------------030700090909060605080301--
Re: RWT extension [message #34070 is a reply to message #33863] Mon, 18 June 2007 16:02 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: nindl_go.hotmail.com

Hi Ralf,

thanks for your quick response. It works perfect.

Unfortunately I do not know how the the whole thing works, so I can't extend
it...

I know the ClicklabelLCA does the rendering of the JavaScript with the
JSWriter...

The JSWriter calls somehow the LabelUtil.js, where I define my Qx
MouseEvent???

I would appreciate just some tipps!

Thanks a lot!

Gottfried

"Ralf Sternberg" <rsternberg@innoopract.com> schrieb im Newsbeitrag
news:f55kb8$lb6$1@build.eclipse.org...
> Hi Gottfried,
>
> From what I understand, all you need is a mouse listener for the SWT
> Label that passes the coordinates. I once wrote a "click label" (a Label
> with a selection listener) as a workaround for missing mouse listeners -
> maybe this can serve as a starting point for you (see attached files).
> You would have to add some client- and server side code for the mouse
> coordinates. However, note that this is only a hack, as SWT widgets
> should not be subclassed, except for Canvas and Composite.
>
> However, as there are many use cases for a MouseListener on a label, I
> hope that we can implement it soon.
>
> Ralf
>
> Gottfried Nindl schrieb:
>> How can I extend the RWT in order to implement custom widgets and
>> listeners?
>> I get a big image from the data source containing various objects. The
>> image
>> is packed into a Label object. Further I have a map, which identifies the
>> internal objects by their x, y position when the user clicks on it.
>> Unfortunately Rap doesn't support low-level mouse events till release
>> 1.0.
>> My second attempt was to cut the image server-side with the SWT GC
>> library,
>> but it failed due to the incompatibilty or something else.
>>
>> As far as I know you have to create a new Java class in the
>> widgets/events
>> in the org.eclipse.swt.widgets/events of the org.eclipse.rap.rwt package.
>> A
>> corresponding JavaScript class must also be created in the same
>> subdirectory
>> of the js directory. The writing of a qooxdoo widget happens somewhere in
>> a
>> class which implements the org.eclipse.swt.resources.IResource interface.
>>
>> Another workaround would be the integration of a third party
>> MouseListener
>> JavaScript. Can I just put it somewhere to wait for a call and process
>> the
>> coordinates back to Rap?
>>
>> Thankx for helping me, where to go from here!
>>
>> Cheers, Gottfried
>>
>>
>
>


------------------------------------------------------------ --------------------


> /*********************************************************** ********************
> * Copyright (c) 2002-2006 Innoopract Informationssysteme GmbH.
> * All rights reserved. This program and the accompanying materials
> * are made available under the terms of the Eclipse Public License v1.0
> * which accompanies this distribution, and is available at
> * http://www.eclipse.org/legal/epl-v10.html
> *
> * Contributors:
> * Innoopract Informationssysteme GmbH - initial API and implementation
> ************************************************************ ******************/
>
> package org.eclipse.rap.clicklabel;
>
> import org.eclipse.swt.events.SelectionEvent;
> import org.eclipse.swt.events.SelectionListener;
> import org.eclipse.swt.widgets.Composite;
> import org.eclipse.swt.widgets.Label;
>
> public class ClickLabel extends Label {
>
> public ClickLabel( final Composite parent, final int style ) {
> super( parent, style );
> }
>
> public void addSelectionListener( final SelectionListener listener ) {
> SelectionEvent.addListener( this, listener );
> }
>
> public void removeSelectionListener( final SelectionListener listener ) {
> SelectionEvent.removeListener( this, listener );
> }
>
> }
>


------------------------------------------------------------ --------------------


> package org.eclipse.rap.internal.clicklabel.clicklabelkit;
>
> import java.io.IOException;
> import org.eclipse.swt.events.SelectionEvent;
> import org.eclipse.swt.internal.widgets.Props;
> import org.eclipse.swt.internal.widgets.labelkit.LabelLCA;
> import org.eclipse.swt.lifecycle.*;
> import org.eclipse.swt.widgets.Widget;
>
> public class ClickLabelLCA extends LabelLCA {
>
> private final static JSListenerInfo JS_LISTENER_INFO =
> new JSListenerInfo( "click",
> JSConst.JS_WIDGET_SELECTED,
> JSListenerType.ACTION );
>
> public void renderInitialization( Widget widget ) throws IOException
> {
> super.renderInitialization( widget );
> JSWriter writer = JSWriter.getWriterFor( widget );
> writer.set( "cursor", "pointer" );
> }
>
> public void readData( Widget widget )
> {
> super.readData( widget );
> ControlLCAUtil.processSelection( widget, null, false );
> }
>
> public void renderChanges( Widget widget ) throws IOException
> {
> super.renderChanges( widget );
> JSWriter writer = JSWriter.getWriterFor( widget );
> writer.updateListener( JS_LISTENER_INFO,
> Props.SELECTION_LISTENERS,
> SelectionEvent.hasListener( widget ) );
> writer.set( new String[] { "labelObject", "cursor" },
> new Object[] { "pointer" } );
> }
>
> }
>
Re: RWT extension [message #34104 is a reply to message #34070] Tue, 19 June 2007 08:31 Go to previous message
Eclipse UserFriend
Originally posted by: rsternberg.innoopract.com

Gottfried,

just some hints:

* write a JavaScript util class that contains a click listener,
like this:

my.LabelUtil.clicked : function( evt ) {
if( !org_eclipse_rap_rwt_EventUtil_suspend ) {
var wm = org.eclipse.swt.WidgetManager.getInstance();
var id = wm.findIdByWidget(this);
var req = org.eclipse.swt.Request.getInstance();
req.addEvent( "my.clickEvent", id );
req.addParameter( "my.click.x", evt.getClientX() );
req.addParameter( "my.click.y", evt.getClientY() );
req.send();
}
}

* register the JavaScript as explained in the thread before this one

* In the LCA, add this listener to the "click" event (instead of
JSConst.JS_WIDGET_SELECTED)

* In the readData method of the LCA, handle the event on your own
instead delegating to ControlLCAUtil.processSelection().

I'm sorry, but if you want to extend RAP, you have to figure out by
yourself how all the parts play together. You might want to have a look
at the RAP intro [1] and the qooxdoo API docs [2], e.g. for the qooxdoo
MouseEvent.

Hope this helps,
Ralf

[1] http://wiki.eclipse.org/index.php/WidgetToolkit
[2] http://demo.qooxdoo.org/0.7/apiviewer/#qx.event.type.MouseEv ent


Gottfried Nindl schrieb:

> Unfortunately I do not know how the the whole thing works, so I can't extend
> it...
>
> I know the ClicklabelLCA does the rendering of the JavaScript with the
> JSWriter...
>
> The JSWriter calls somehow the LabelUtil.js, where I define my Qx
> MouseEvent???
>
> I would appreciate just some tipps!
>
> Thanks a lot!
Previous Topic:New widget
Next Topic:Rap running in RCP
Goto Forum:
  


Current Time: Fri Jul 19 15:34:07 GMT 2024

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

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

Back to the top