Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » XWT and GUI related classes in a third-party jar
XWT and GUI related classes in a third-party jar [message #1103] Sat, 25 July 2009 12:37 Go to next message
No real name is currently offline No real name
Messages: 113
Registered: July 2009
Senior Member
I have a third party OSGi enabled jar. It exports a layout class. Its a
modified MigLayout jar.

I was creating a XWT declarative GUI. After defining the namespace and
adding the layout to my composite, I am unable to get the MigLayout
class to be found by the XWT engine and I keep getting a class not found
error. Most of the demos use classes defined in the same jar as the .xwt
file itself, but MigLayout is another jar altogether, the XWT bundle
cannot find the layout class. Any ideas on resolving this? Or do I have
something else potentially wrong? It looks like a standard class loading
problem but its not clear how to resolve it using the usual tricks (no
eclipse-buddy mechanism can be added to xwt and I cannot declare
everything in an application to be a fragment). Also, the XWT visual
editor does not use the layout dynamically (I have added the mig jar so
it is found by my application plugin of course).
Re: XWT and GUI related classes in a third-party jar [message #479894 is a reply to message #1103] Wed, 12 August 2009 22:50 Go to previous messageGo to next message
Yves YANG is currently offline Yves YANG
Messages: 687
Registered: July 2009
Senior Member
You can find an example here:
http://wiki.eclipse.org/E4/XWT#Extensibility_and_Re-usabilit y
<Composite xmlns="http://www.eclipse.org/xwt/presentation"
xmlns:x="http://www.eclipse.org/xwt"
xmlns:y="cls-namespace:ui">
<Composite.layout>
<y:MyGridLayout numColumns="2"/>
</Composite.layout>
<Label text="Hello, world"/>
<Text x:style="BORDER">
<Text.layoutData>
<GridData horizontalAlignment="FILL"
grabExcessHorizontalSpace="true"/>
</Text.layoutData>
</Text>
</Composite>You need to: 1. define a namespace corresponds to your java
package, which contains your MigLayout. 2. Use your Layout with the
created namespace's prefix.If you still have the problem of class loading,
it is the problem of class loader.Best regardsYves YANG --
http://www.soyatec.com"aappddeevv" <aappddeevv@verizon.net> wrote in message
news:h4euac$pe$1@build.eclipse.org...>I have a third party OSGi enabled jar.
It exports a layout class. Its a
> modified MigLayout jar.
>
> I was creating a XWT declarative GUI. After defining the namespace and
> adding the layout to my composite, I am unable to get the MigLayout class
> to be found by the XWT engine and I keep getting a class not found error.
> Most of the demos use classes defined in the same jar as the .xwt file
> itself, but MigLayout is another jar altogether, the XWT bundle cannot
> find the layout class. Any ideas on resolving this? Or do I have something
> else potentially wrong? It looks like a standard class loading problem but
> its not clear how to resolve it using the usual tricks (no eclipse-buddy
> mechanism can be added to xwt and I cannot declare everything in an
> application to be a fragment). Also, the XWT visual editor does not use
> the layout dynamically (I have added the mig jar so it is found by my
> application plugin of course).
Re: XWT and GUI related classes in a third-party jar [message #479899 is a reply to message #1103] Wed, 12 August 2009 23:23 Go to previous messageGo to next message
Yves YANG is currently offline Yves YANG
Messages: 687
Registered: July 2009
Senior Member
To resolve the class loader, use the following code:
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(Activator.class .getClassLoader());
root = XWT.load(url, dataContext);
} finally {
Thread.currentThread().setContextClassLoader(classLoader);
}

Activator chould be a class which is in the name bundle as MigLayout.

yves
"aappddeevv" <aappddeevv@verizon.net> wrote in message
news:h4euac$pe$1@build.eclipse.org...
>I have a third party OSGi enabled jar. It exports a layout class. Its a
>modified MigLayout jar.
>
> I was creating a XWT declarative GUI. After defining the namespace and
> adding the layout to my composite, I am unable to get the MigLayout class
> to be found by the XWT engine and I keep getting a class not found error.
> Most of the demos use classes defined in the same jar as the .xwt file
> itself, but MigLayout is another jar altogether, the XWT bundle cannot
> find the layout class. Any ideas on resolving this? Or do I have something
> else potentially wrong? It looks like a standard class loading problem but
> its not clear how to resolve it using the usual tricks (no eclipse-buddy
> mechanism can be added to xwt and I cannot declare everything in an
> application to be a fragment). Also, the XWT visual editor does not use
> the layout dynamically (I have added the mig jar so it is found by my
> application plugin of course).
Re: XWT and GUI related classes in a third-party jar [message #480611 is a reply to message #479894] Mon, 17 August 2009 21:31 Go to previous messageGo to next message
No real name is currently offline No real name
Messages: 113
Registered: July 2009
Senior Member
I did do this in terms of the xmlns cls-namespace specification.
However, when using the XWT visual gui, there is no way to inform it
about which classloader to use for that stringized version of the class
specification. I'll play with it more, perhaps I had an error somewhere,
however, I am concerned that underneath, the XWT editor does not pull in
the right class loader to load the class in the 3rd party jar so it
can't use it during visual design. I think the examples all work because
the additional element (such as MyGridLayout) is in the plugin that
defines the ui element to begin with. But MigLayout is another plugin
that is not the UI plugin that I am creating.


Yves YANG wrote:
> You can find an example here:
> http://wiki.eclipse.org/E4/XWT#Extensibility_and_Re-usabilit y
> <Composite xmlns="http://www.eclipse.org/xwt/presentation"
> xmlns:x="http://www.eclipse.org/xwt"
> xmlns:y="cls-namespace:ui">
> <Composite.layout>
> <y:MyGridLayout numColumns="2"/>
> </Composite.layout>
> <Label text="Hello, world"/>
> <Text x:style="BORDER">
> <Text.layoutData>
> <GridData horizontalAlignment="FILL"
> grabExcessHorizontalSpace="true"/>
> </Text.layoutData>
> </Text>
> </Composite>You need to: 1. define a namespace corresponds to your java
> package, which contains your MigLayout. 2. Use your Layout with the
> created namespace's prefix.If you still have the problem of class loading,
> it is the problem of class loader.Best regardsYves YANG --
> http://www.soyatec.com"aappddeevv" <aappddeevv@verizon.net> wrote in message
> news:h4euac$pe$1@build.eclipse.org...>I have a third party OSGi enabled jar.
> It exports a layout class. Its a
>> modified MigLayout jar.
>>
>> I was creating a XWT declarative GUI. After defining the namespace and
>> adding the layout to my composite, I am unable to get the MigLayout class
>> to be found by the XWT engine and I keep getting a class not found error.
>> Most of the demos use classes defined in the same jar as the .xwt file
>> itself, but MigLayout is another jar altogether, the XWT bundle cannot
>> find the layout class. Any ideas on resolving this? Or do I have something
>> else potentially wrong? It looks like a standard class loading problem but
>> its not clear how to resolve it using the usual tricks (no eclipse-buddy
>> mechanism can be added to xwt and I cannot declare everything in an
>> application to be a fragment). Also, the XWT visual editor does not use
>> the layout dynamically (I have added the mig jar so it is found by my
>> application plugin of course).
>
>
Re: XWT and GUI related classes in a third-party jar [message #480919 is a reply to message #480611] Tue, 18 August 2009 22:37 Go to previous message
Yves YANG is currently offline Yves YANG
Messages: 687
Registered: July 2009
Senior Member
XWT editor has already setup a class loader. It should work if the thrid
part jar is referenced by the project that contains the XWT file.

Regards
yves
"aappddeevv" <aappddeevv@verizon.net> wrote in message
news:h6ci7l$7jp$1@build.eclipse.org...
>I did do this in terms of the xmlns cls-namespace specification. However,
>when using the XWT visual gui, there is no way to inform it about which
>classloader to use for that stringized version of the class specification.
>I'll play with it more, perhaps I had an error somewhere, however, I am
>concerned that underneath, the XWT editor does not pull in the right class
>loader to load the class in the 3rd party jar so it can't use it during
>visual design. I think the examples all work because the additional element
>(such as MyGridLayout) is in the plugin that defines the ui element to
>begin with. But MigLayout is another plugin that is not the UI plugin that
>I am creating.
>
>
> Yves YANG wrote:
>> You can find an example here:
>> http://wiki.eclipse.org/E4/XWT#Extensibility_and_Re-usabilit y
>> <Composite xmlns="http://www.eclipse.org/xwt/presentation"
>> xmlns:x="http://www.eclipse.org/xwt"
>> xmlns:y="cls-namespace:ui">
>> <Composite.layout>
>> <y:MyGridLayout numColumns="2"/>
>> </Composite.layout>
>> <Label text="Hello, world"/>
>> <Text x:style="BORDER">
>> <Text.layoutData>
>> <GridData horizontalAlignment="FILL"
>> grabExcessHorizontalSpace="true"/>
>> </Text.layoutData>
>> </Text>
>> </Composite>You need to: 1. define a namespace corresponds to your
>> java package, which contains your MigLayout. 2. Use your Layout with
>> the created namespace's prefix.If you still have the problem of class
>> loading, it is the problem of class loader.Best regardsYves YANG --
>> http://www.soyatec.com"aappddeevv" <aappddeevv@verizon.net> wrote in
>> message news:h4euac$pe$1@build.eclipse.org...>I have a third party OSGi
>> enabled jar. It exports a layout class. Its a
>>> modified MigLayout jar.
>>>
>>> I was creating a XWT declarative GUI. After defining the namespace and
>>> adding the layout to my composite, I am unable to get the MigLayout
>>> class to be found by the XWT engine and I keep getting a class not found
>>> error. Most of the demos use classes defined in the same jar as the .xwt
>>> file itself, but MigLayout is another jar altogether, the XWT bundle
>>> cannot find the layout class. Any ideas on resolving this? Or do I have
>>> something else potentially wrong? It looks like a standard class loading
>>> problem but its not clear how to resolve it using the usual tricks (no
>>> eclipse-buddy mechanism can be added to xwt and I cannot declare
>>> everything in an application to be a fragment). Also, the XWT visual
>>> editor does not use the layout dynamically (I have added the mig jar so
>>> it is found by my application plugin of course).
>>
Re: XWT and GUI related classes in a third-party jar [message #562333 is a reply to message #1103] Wed, 12 August 2009 22:50 Go to previous message
Yves YANG is currently offline Yves YANG
Messages: 687
Registered: July 2009
Senior Member
You can find an example here:
http://wiki.eclipse.org/E4/XWT#Extensibility_and_Re-usabilit y
<Composite xmlns="http://www.eclipse.org/xwt/presentation"
xmlns:x="http://www.eclipse.org/xwt"
xmlns:y="cls-namespace:ui">
<Composite.layout>
<y:MyGridLayout numColumns="2"/>
</Composite.layout>
<Label text="Hello, world"/>
<Text x:style="BORDER">
<Text.layoutData>
<GridData horizontalAlignment="FILL"
grabExcessHorizontalSpace="true"/>
</Text.layoutData>
</Text>
</Composite>You need to: 1. define a namespace corresponds to your java
package, which contains your MigLayout. 2. Use your Layout with the
created namespace's prefix.If you still have the problem of class loading,
it is the problem of class loader.Best regardsYves YANG --
http://www.soyatec.com"aappddeevv" <aappddeevv@verizon.net> wrote in message
news:h4euac$pe$1@build.eclipse.org...>I have a third party OSGi enabled jar.
It exports a layout class. Its a
> modified MigLayout jar.
>
> I was creating a XWT declarative GUI. After defining the namespace and
> adding the layout to my composite, I am unable to get the MigLayout class
> to be found by the XWT engine and I keep getting a class not found error.
> Most of the demos use classes defined in the same jar as the .xwt file
> itself, but MigLayout is another jar altogether, the XWT bundle cannot
> find the layout class. Any ideas on resolving this? Or do I have something
> else potentially wrong? It looks like a standard class loading problem but
> its not clear how to resolve it using the usual tricks (no eclipse-buddy
> mechanism can be added to xwt and I cannot declare everything in an
> application to be a fragment). Also, the XWT visual editor does not use
> the layout dynamically (I have added the mig jar so it is found by my
> application plugin of course).
Re: XWT and GUI related classes in a third-party jar [message #562382 is a reply to message #1103] Wed, 12 August 2009 23:23 Go to previous message
Yves YANG is currently offline Yves YANG
Messages: 687
Registered: July 2009
Senior Member
To resolve the class loader, use the following code:
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(Activator.class .getClassLoader());
root = XWT.load(url, dataContext);
} finally {
Thread.currentThread().setContextClassLoader(classLoader);
}

Activator chould be a class which is in the name bundle as MigLayout.

yves
"aappddeevv" <aappddeevv@verizon.net> wrote in message
news:h4euac$pe$1@build.eclipse.org...
>I have a third party OSGi enabled jar. It exports a layout class. Its a
>modified MigLayout jar.
>
> I was creating a XWT declarative GUI. After defining the namespace and
> adding the layout to my composite, I am unable to get the MigLayout class
> to be found by the XWT engine and I keep getting a class not found error.
> Most of the demos use classes defined in the same jar as the .xwt file
> itself, but MigLayout is another jar altogether, the XWT bundle cannot
> find the layout class. Any ideas on resolving this? Or do I have something
> else potentially wrong? It looks like a standard class loading problem but
> its not clear how to resolve it using the usual tricks (no eclipse-buddy
> mechanism can be added to xwt and I cannot declare everything in an
> application to be a fragment). Also, the XWT visual editor does not use
> the layout dynamically (I have added the mig jar so it is found by my
> application plugin of course).
Re: XWT and GUI related classes in a third-party jar [message #562407 is a reply to message #479894] Mon, 17 August 2009 21:31 Go to previous message
No real name is currently offline No real name
Messages: 113
Registered: July 2009
Senior Member
I did do this in terms of the xmlns cls-namespace specification.
However, when using the XWT visual gui, there is no way to inform it
about which classloader to use for that stringized version of the class
specification. I'll play with it more, perhaps I had an error somewhere,
however, I am concerned that underneath, the XWT editor does not pull in
the right class loader to load the class in the 3rd party jar so it
can't use it during visual design. I think the examples all work because
the additional element (such as MyGridLayout) is in the plugin that
defines the ui element to begin with. But MigLayout is another plugin
that is not the UI plugin that I am creating.


Yves YANG wrote:
> You can find an example here:
> http://wiki.eclipse.org/E4/XWT#Extensibility_and_Re-usabilit y
> <Composite xmlns="http://www.eclipse.org/xwt/presentation"
> xmlns:x="http://www.eclipse.org/xwt"
> xmlns:y="cls-namespace:ui">
> <Composite.layout>
> <y:MyGridLayout numColumns="2"/>
> </Composite.layout>
> <Label text="Hello, world"/>
> <Text x:style="BORDER">
> <Text.layoutData>
> <GridData horizontalAlignment="FILL"
> grabExcessHorizontalSpace="true"/>
> </Text.layoutData>
> </Text>
> </Composite>You need to: 1. define a namespace corresponds to your java
> package, which contains your MigLayout. 2. Use your Layout with the
> created namespace's prefix.If you still have the problem of class loading,
> it is the problem of class loader.Best regardsYves YANG --
> http://www.soyatec.com"aappddeevv" <aappddeevv@verizon.net> wrote in message
> news:h4euac$pe$1@build.eclipse.org...>I have a third party OSGi enabled jar.
> It exports a layout class. Its a
>> modified MigLayout jar.
>>
>> I was creating a XWT declarative GUI. After defining the namespace and
>> adding the layout to my composite, I am unable to get the MigLayout class
>> to be found by the XWT engine and I keep getting a class not found error.
>> Most of the demos use classes defined in the same jar as the .xwt file
>> itself, but MigLayout is another jar altogether, the XWT bundle cannot
>> find the layout class. Any ideas on resolving this? Or do I have something
>> else potentially wrong? It looks like a standard class loading problem but
>> its not clear how to resolve it using the usual tricks (no eclipse-buddy
>> mechanism can be added to xwt and I cannot declare everything in an
>> application to be a fragment). Also, the XWT visual editor does not use
>> the layout dynamically (I have added the mig jar so it is found by my
>> application plugin of course).
>
>
Re: XWT and GUI related classes in a third-party jar [message #562513 is a reply to message #480611] Tue, 18 August 2009 22:37 Go to previous message
Yves YANG is currently offline Yves YANG
Messages: 687
Registered: July 2009
Senior Member
XWT editor has already setup a class loader. It should work if the thrid
part jar is referenced by the project that contains the XWT file.

Regards
yves
"aappddeevv" <aappddeevv@verizon.net> wrote in message
news:h6ci7l$7jp$1@build.eclipse.org...
>I did do this in terms of the xmlns cls-namespace specification. However,
>when using the XWT visual gui, there is no way to inform it about which
>classloader to use for that stringized version of the class specification.
>I'll play with it more, perhaps I had an error somewhere, however, I am
>concerned that underneath, the XWT editor does not pull in the right class
>loader to load the class in the 3rd party jar so it can't use it during
>visual design. I think the examples all work because the additional element
>(such as MyGridLayout) is in the plugin that defines the ui element to
>begin with. But MigLayout is another plugin that is not the UI plugin that
>I am creating.
>
>
> Yves YANG wrote:
>> You can find an example here:
>> http://wiki.eclipse.org/E4/XWT#Extensibility_and_Re-usabilit y
>> <Composite xmlns="http://www.eclipse.org/xwt/presentation"
>> xmlns:x="http://www.eclipse.org/xwt"
>> xmlns:y="cls-namespace:ui">
>> <Composite.layout>
>> <y:MyGridLayout numColumns="2"/>
>> </Composite.layout>
>> <Label text="Hello, world"/>
>> <Text x:style="BORDER">
>> <Text.layoutData>
>> <GridData horizontalAlignment="FILL"
>> grabExcessHorizontalSpace="true"/>
>> </Text.layoutData>
>> </Text>
>> </Composite>You need to: 1. define a namespace corresponds to your
>> java package, which contains your MigLayout. 2. Use your Layout with
>> the created namespace's prefix.If you still have the problem of class
>> loading, it is the problem of class loader.Best regardsYves YANG --
>> http://www.soyatec.com"aappddeevv" <aappddeevv@verizon.net> wrote in
>> message news:h4euac$pe$1@build.eclipse.org...>I have a third party OSGi
>> enabled jar. It exports a layout class. Its a
>>> modified MigLayout jar.
>>>
>>> I was creating a XWT declarative GUI. After defining the namespace and
>>> adding the layout to my composite, I am unable to get the MigLayout
>>> class to be found by the XWT engine and I keep getting a class not found
>>> error. Most of the demos use classes defined in the same jar as the .xwt
>>> file itself, but MigLayout is another jar altogether, the XWT bundle
>>> cannot find the layout class. Any ideas on resolving this? Or do I have
>>> something else potentially wrong? It looks like a standard class loading
>>> problem but its not clear how to resolve it using the usual tricks (no
>>> eclipse-buddy mechanism can be added to xwt and I cannot declare
>>> everything in an application to be a fragment). Also, the XWT visual
>>> editor does not use the layout dynamically (I have added the mig jar so
>>> it is found by my application plugin of course).
>>
Previous Topic:Contributing UI Components from other Plug-ins
Next Topic:CSS styling - Border (e4 contacts demo)
Goto Forum:
  


Current Time: Sun Oct 26 01:24:09 GMT 2014

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

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