Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [e4-dev] Does that mean SWT only exist in desktop ?

> Am 06.02.10 00:33, schrieb yves.yang@xxxxxxxxxxx:
>>> On Thu, Jan 28, 2010 at 2:16 PM, Tom Schindl
>>> <tom.schindl@xxxxxxxxxxxxxxx>wrote:
>>>
>>>> Hi,
>>>>
>>>> Doing a full SWT-Port for the Web is a very hard task because some of
>>>> the concepts in SWT can't be emulated easily on the browser:
>>>>
>>>> * Event-Loop: Todays browser though HTML5 brings webworkers are still
>>>>  single threaded and so you can't e.g open blocking dialogs like you
>>>>  do in SWT => SWT would have to introduce API with callbacks so
>>>>  that one could write single-source code.
>>>>
>>>>  An example might make this clear:
>>>>
>>>>  Today:
>>>>  ----------8<----------
>>>>  MessageBox msg = new MessageBox(parent,SWT.ICON_ERROR);
>>>>  msg.setText("I'm the message");
>>>>  msg.open();  // Blocking call
>>>>  System.out.println("I'm running after dialog closed");
>>>>  ----------8<----------
>>>>
>>>>  In Future:
>>>>  ----------8<----------
>>>>  MessageBox msg = new MessageBox(parent,SWT.ICON_ERROR);
>>>>  msg.setText("I'm the message");
>>>>  msg.open(new Runnable() {
>>>>    public void run() {
>>>>      System.out.println("I'm running after dialog closed");
>>>>    }
>>>>  });
>>
>> It is exactly one of benefice of using XWT: physical separation between
>> event handling and UI. XWT can manage the both cases transparently. We
>> can
>> define the event handling policy (sync, async and delayed async) between
>> declarative UI and event handling based on Java Handling, Bundle
>> service,
>> web service etc.
>>
>
> Sorry I don't see events here? If SWT would have an API to handle button
> clicks this would be true but SWT (as well as JFace) works here with
> return values and blocking methods. So I don't get how XWT could help me
> in this case.

It is true it is not an event in SWT. But for XWT, it could be an event.
For example, "loaded" event is introduced and the state change is an event
as well.

>
> How would you code this in XWT? Please note I talked about different
> API-Concepts not about listeners who work the same in Browsers and
> Desktop-Environments.

All actions can be and should be event-triggered even it is not a SWT event.

The code could look like as following:

<MessageBox text="I'm the message" closed="onClose"/>

The onClose is handled by a method

protected void onClose(...) [{
   System.out.println("I'm running after dialog closed");
}

yves
>
> Tom
>
> --
> B e s t S o l u t i o n . a t                        EDV Systemhaus GmbH
> ------------------------------------------------------------------------
> tom schindl                                        geschaeftsfuehrer/CEO
> ------------------------------------------------------------------------
> eduard-bodem-gasse 5/1    A-6020 innsbruck      phone    ++43 512 935834
> _______________________________________________
> e4-dev mailing list
> e4-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/e4-dev
>




Back to the top