UIWidget#getOwnerWindow() && UIWindow#getElementById(String id) feature

0 views
Skip to first unread message

Angelo zerr

unread,
Dec 11, 2008, 5:26:06 AM12/11/08
to uface
Hi,

JXpath is very powerfull and you can manage XPath id() function.
For instance if you have this XML

<input id="MyId" />

You can write XPath expression like this :

String xpath = "id(@MyId)"

And this expression do

document.getElementById("MyId");

UFace provide UIElement#getId();

So I think it shoud be cool to have this same feature.
I can implement easily the XPath function id() for UFace but I need
getElementById() function.

Into W3C DOM we have

* Element#getOwnerDocument() which returns the owner Document.
* Document#getElementById(String id) which returns the element by id.

So I think for UFace we could have :

* UIWidget#getOwnerWindow() which returns UIWindow owner of the UIWidget.
* UIWindow#getWidgetById(String id) which returns the widget by id.

The problem with this solution is that UIElement is not managed
although UIElement
has id info.

Perhaps shoud we have UIWindow#getElementById(String id) which returns
UIElement?

After we must though how implement that into JFace*?
Do we must do the same thing than UIFactory (UIWidget#getFactory())
and put the window
into SWTControl constructor?

If we consider UIWindow like DOM Document, I think it's very important
to get UIWindow
without create it at hand like JFaceDemo to add the UFace widgets into
native widgets.

Indead imagine that you want use UFace widgets into native JFace Wizard Eclipse.
Shell is created by JFace Wizard Eclipse, and after UFace must use the
Shell (or rather the SWT composite created)
of the JFace Wizard Eclipse and not create a new Shell into UIWindow.

I don't know if you understood my explanation?

Regards Angelo

Tom

unread,
Dec 11, 2008, 4:26:05 PM12/11/08
to uface
On 11 Dez., 11:26, "Angelo zerr" <angelo.z...@gmail.com> wrote:
> Hi,
>
> JXpath is very powerfull and you can manage XPath id() function.
> For instance if you have this XML
>
> <input id="MyId" />
>
> You can write XPath expression like this :
>
> String xpath = "id(@MyId)"
>
> And this expression do
>
> document.getElementById("MyId");
>
> UFace provide UIElement#getId();
>
> So I think it shoud be cool to have this same feature.
> I can implement easily the XPath function id() for UFace but I need
> getElementById() function.
>
> Into W3C DOM we have
>
> * Element#getOwnerDocument() which returns the owner Document.
> * Document#getElementById(String id) which returns the element by id.
>
> So I think for UFace we could have :
>
> * UIWidget#getOwnerWindow() which returns UIWindow owner of the UIWidget.

Yes this makes sense

> * UIWindow#getWidgetById(String id) which returns the widget by id.

Hm the Id is unique across the whole application and not across the
UIWindow. An application
can have more than one window! So you should query the
UIApplicationContext.

>
> The problem with this solution is that UIElement is not managed
> although UIElement
> has id info.
>
> Perhaps shoud we have UIWindow#getElementById(String id) which returns
> UIElement?
>
> After we must though how implement that into JFace*?
> Do we must do the same thing than UIFactory (UIWidget#getFactory())
> and put the window
> into SWTControl constructor?

Why do we need that? I can't follow.

>
> If we consider UIWindow like DOM Document, I think it's very important
> to get UIWindow
> without create it at hand like JFaceDemo to add the UFace widgets into
> native widgets.

UIWindow != DOM Document. UIApplication context can be treated as
this.

>
> Indead imagine that you want use UFace widgets into native JFace Wizard Eclipse.
> Shell is created by JFace Wizard Eclipse, and after UFace must use the
> Shell (or rather the SWT composite created)
> of the JFace Wizard Eclipse and not create a new Shell into UIWindow.

No as outlined above when one uses UFaceKit in Eclipse one adapts the
Composite given
and that's it.

Tom

Angelo zerr

unread,
Dec 15, 2008, 2:21:51 AM12/15/08
to uf...@googlegroups.com
Hi Tom,

2008/12/11 Tom <toms...@gmail.com>


On 11 Dez., 11:26, "Angelo zerr" <angelo.z...@gmail.com> wrote:
> Hi,
>
> JXpath is very powerfull and you can manage XPath id() function.
> For instance if you have this XML
>
> <input id="MyId" />
>
> You can write XPath expression like this :
>
> String xpath = "id(@MyId)"
>
> And this expression do
>
> document.getElementById("MyId");
>
> UFace provide UIElement#getId();
>
> So I think it shoud be cool to have this same feature.
> I can implement easily the XPath function id() for UFace but I need
> getElementById() function.
>
> Into W3C DOM we have
>
> * Element#getOwnerDocument() which returns the owner Document.
> * Document#getElementById(String id) which returns the element by id.
>
> So I think for UFace we could have :
>
> * UIWidget#getOwnerWindow() which returns UIWindow owner of the UIWidget.

Yes this makes sense

I have added UIWidget#getWindow(). the getWindow implementation is done into UIWidgetBean.


> * UIWindow#getWidgetById(String id) which returns the widget by id.

Hm the Id is unique across the whole application and not across the
UIWindow. An application
can have more than one window! So you should query the
UIApplicationContext.

Ok. i have seen that you have done work about that. thank a lot.
I have updated XPath UIWidgetPointer  to manage XPath id() function by calling your UIApplicationContext#getElement(String id)

But today this method returns null. Why?
I have seen that it's registerElement which register the element and update the Map of elements.
Must I call this method at hand?

For information I have updated UFackitParser to parse ID and create Attr.
So now you can see the id of UIElement into XML, JSON...


>
> The problem with this solution is that UIElement is not managed
> although UIElement
> has id info.
>
> Perhaps shoud we have UIWindow#getElementById(String id) which returns
> UIElement?
>
> After we must though how implement that into JFace*?
> Do we must do the same thing than UIFactory (UIWidget#getFactory())
> and put the window
> into SWTControl constructor?

Why do we need that? I can't follow.

Sorry for my bad explanation. Follow that.


>
> If we consider UIWindow like DOM Document, I think it's very important
> to get UIWindow
> without create it at hand like JFaceDemo to add the UFace widgets into
> native widgets.

UIWindow != DOM Document. UIApplication context can be treated as
this.
Ok.

>
> Indead imagine that you want use UFace widgets into native JFace Wizard Eclipse.
> Shell is created by JFace Wizard Eclipse, and after UFace must use the
> Shell (or rather the SWT composite created)
> of the JFace Wizard Eclipse and not create a new Shell into UIWindow.

No as outlined above when one uses UFaceKit in Eclipse one adapts the
Composite given
and that's it.

Ok, If it's possible, that's cool.

Regards Angelo

Tom


Tom Schindl

unread,
Dec 15, 2008, 4:31:00 AM12/15/08
to uf...@googlegroups.com
Angelo zerr schrieb:
> Hi Tom,
>
> 2008/12/11 Tom <toms...@gmail.com <mailto:toms...@gmail.com>>

>
>
> On 11 Dez., 11:26, "Angelo zerr" <angelo.z...@gmail.com

No - I think this feature is not finished yet.
- registerElement should be called when a widget is created (e.g.
UIWidgetBean)
- unregisterElement should be called when the widget is disposed()

I think this is the missing thing at the moment.

> For information I have updated UFackitParser to parse ID and create Attr.
> So now you can see the id of UIElement into XML, JSON...
>

ok

Tom

Reply all
Reply to author
Forward
0 new messages