|
Re: Integration of XWT in an e4 application [message #716632 is a reply to message #711969] |
Wed, 17 August 2011 23:21 |
Missing name Mising name Messages: 43 Registered: July 2011 |
Member |
|
|
Hi, I'm also curious about this topic.
I used XWT like following code in my App.
This works but I'm not sure whether this is the right way.
I'm just new to e4 application, so please correct me if I'm wrong.
In MyPart.java:
private final Composite parent;
@Inject
public MyPart(Composite parent) {
this.parent = parent;
}
@PostConstruct
public void buildUI(){
parent.setLayout(new FillLayout());
IOUtil.XWTload(getClass(), parent, "MyPart.xwt", ItemHolder.getInstance());
}
In IOUtil.java:
public static void changeCurrentThreadClassLoader(Class clazz){
Thread.currentThread().setContextClassLoader(clazz.getClassLoader());
}
public static void revertCurrentThreadClassLoader(){
Thread.currentThread().setContextClassLoader(CONST.INITIAL_CLASS_LOADER);
}
public static Object XWTload(Class clazz,Composite parent, String xwtFile, Object dataContext){
ClassLoader myLoader = clazz.getClassLoader();
Object loadModule = null;
try {
changeCurrentThreadClassLoader(clazz);
if(dataContext==null){
loadModule = XWT.load(parent,clazz.getResource(xwtFile));
} else {
loadModule = XWT.load(parent,clazz.getResource(xwtFile),dataContext);
}
} catch (Exception e) {
e.printStackTrace();
} finally{
revertCurrentThreadClassLoader();
}
return loadModule;
}
I put "MyPart.xwt" and "MyPart.java" in the same directory.
Regards,
[Updated on: Sun, 15 January 2012 23:16] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03682 seconds