Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » XWT fails to load x:Class class
XWT fails to load x:Class class [message #576535] Fri, 21 May 2010 21:31 Go to next message
Swavek  is currently offline Swavek Friend
Messages: 20
Registered: March 2010
Junior Member
I created a small plugin project which has a simple Composite with two buttons. I created a SelectionEvent handler for one of the buttons. Without this handler the Composite appears to load fine, but as soon as I add the event handler in .xwt it fails to load. Turns out if fails to load the class containing the event handler which is specified in x:Class.

Is this a known limitation or a bug?


Here is the XWT file

<Composite xmlns="http://www.eclipse.org/xwt/presentation"
xmlns:x="http://www.eclipse.org/xwt" xmlns:c="clr-namespace:networkeditor.config.ui"
xmlns:j="clr-namespace:java.lang" x:Class="networkeditor.config.ui.MyConfigDialog"
x:DataContext="networkeditor.config.ui.MyConfigData">
<Composite.layout>
<GridLayout numColumns="2" />
</Composite.layout>
<Button x:style="SWT.PUSH" text="Push Me" SelectionEvent="performSelectionEvent"></Button>
<Button x:style="SWT.PUSH" text="Don't push me"></Button>
</Composite>

Here is the Java class.

package networkeditor.config.ui;

import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;

public class MyConfigDialog extends Composite {

public MyConfigDialog(Composite parent, int style) {
super(parent, style);
// TODO Auto-generated constructor stub
}

protected void performSelectionEvent (Event event) {
MessageDialog.openInformation(getShell(), "Title", "you pushed me");
}

}

And here is the data context class.

package networkeditor.config.ui;

public class MyConfigData {

}

Here is how I invoke it.

public void main (String [] args) {
try {
URL file = MyConfigData.class.getResource("/networkeditor/config/ui/MyConfigDialog.xwt ");
XWT.open(file);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}


BTW, When I press the Preview button in the XWT file editor (in XWT perspective) the event handler is invoked correctly. So there is something that I am not doing correctly.

I tried passing parent composite so that ILoadingContext is set differently.
I exported the package containing these classes via MANIFEST.MF.
I changed Eclipse-BuddyPolicy: global (although it shouldn't help in theory)
I checked the Eclipse-BuddyPolicy in org.eclipse.e4.xwt and it is not set so I don't know how the xwt plugin loads these classes. I am using ver 0.9.1 from 2010 04 06.

XWT simply can't load the MyConfigDialog class.

Any help will be appreciated.

Thanks,

Swavek
Re: XWT fails to load x:Class class [message #576726 is a reply to message #576535] Tue, 25 May 2010 19:42 Go to previous messageGo to next message
Swavek  is currently offline Swavek Friend
Messages: 20
Registered: March 2010
Junior Member
After looking into how the new XWT designer performs class loading, I tried to load to specify the classloader that XWT should be using. Now it works when I run within Eclipse. I used an alternative load method which takes the parent component, input stream and url to load.

Composite configPanelsContainer = new Composite(container, SWT.NONE);
StackLayout stackLayout = new StackLayout();
configPanelsContainer.setLayout(stackLayout);

URL configPanelURL = getClass().getClassLoader().getResource(configURLString);
InputStream inputStream = getClass().getClassLoader().getResourceAsStream(configURLStr ing);

// load it
configPanel = XWT.load(configPanelsContainer, inputStream, configPanelURL, getDataContext());

However when I try to run my app after exporting from Eclipse environment the loading of the xwt file doesn't work . I get this exception:

!ENTRY com.infogix.dptoolcatalog 4 1 2010-05-25 14:31:36.552
!MESSAGE my error
!STACK 0
java.io.FileNotFoundException: /my/config\MyConfigPanel.xwt
at org.eclipse.osgi.framework.internal.protocol.bundleresource. Handler.findBundleEntry(Handler.java:51)
at org.eclipse.osgi.framework.internal.core.BundleResourceHandl er.openConnection(BundleResourceHandler.java:175)
at java.net.URL.openConnection(Unknown Source)
at java.net.URL.openStream(Unknown Source)
at org.eclipse.e4.xwt.internal.xml.DocumentRoot.openStream(Docu mentRoot.java:137)
at org.eclipse.e4.xwt.internal.xml.ElementManager.load(ElementM anager.java:252)
at org.eclipse.e4.xwt.internal.core.Core.load(Core.java:643)
at org.eclipse.e4.xwt.XWTLoader.loadWithOptions(XWTLoader.java: 863)
at org.eclipse.e4.xwt.XWTLoader.load(XWTLoader.java:729)
at org.eclipse.e4.xwt.XWT.load(XWT.java:425)
at com.infogix.dptoolcatalog.export.configui.NodePropertiesDial og.getConfigPanelsMap(NodePropertiesDialog.java:289)
at com.infogix.dptoolcatalog.export.configui.NodePropertiesDial og.createDialogArea(NodePropertiesDialog.java:218)
at org.eclipse.jface.dialogs.Dialog.createContents(Dialog.java: 760)
....
Re: XWT fails to load x:Class class [message #576739 is a reply to message #576726] Wed, 26 May 2010 01:21 Go to previous message
Yves YANG is currently offline Yves YANGFriend
Messages: 688
Registered: July 2009
Senior Member
This bug is fixed in the last build: e4 1.0 M6

Best regards
Yves YANG
"Swavek" <slorenc@infogix.com> wrote in message
news:hth96a$ukj$1@build.eclipse.org...
> After looking into how the new XWT designer performs class loading, I
> tried to load to specify the classloader that XWT should be using. Now it
> works when I run within Eclipse. I used an alternative load method which
> takes the parent component, input stream and url to load.
>
> Composite configPanelsContainer = new Composite(container, SWT.NONE);
> StackLayout stackLayout = new StackLayout();
> configPanelsContainer.setLayout(stackLayout);
>
> URL configPanelURL =
> getClass().getClassLoader().getResource(configURLString);
> InputStream inputStream =
> getClass().getClassLoader().getResourceAsStream(configURLStr ing);
>
> // load it configPanel = XWT.load(configPanelsContainer, inputStream,
> configPanelURL, getDataContext());
>
> However when I try to run my app after exporting from Eclipse environment
> the loading of the xwt file doesn't work . I get this exception:
>
> !ENTRY com.infogix.dptoolcatalog 4 1 2010-05-25 14:31:36.552
> !MESSAGE my error
> !STACK 0
> java.io.FileNotFoundException: /my/config\MyConfigPanel.xwt
> at org.eclipse.osgi.framework.internal.protocol.bundleresource.
> Handler.findBundleEntry(Handler.java:51)
> at org.eclipse.osgi.framework.internal.core.BundleResourceHandl
> er.openConnection(BundleResourceHandler.java:175)
> at java.net.URL.openConnection(Unknown Source)
> at java.net.URL.openStream(Unknown Source)
> at org.eclipse.e4.xwt.internal.xml.DocumentRoot.openStream(Docu
> mentRoot.java:137)
> at org.eclipse.e4.xwt.internal.xml.ElementManager.load(ElementM
> anager.java:252)
> at org.eclipse.e4.xwt.internal.core.Core.load(Core.java:643)
> at org.eclipse.e4.xwt.XWTLoader.loadWithOptions(XWTLoader.java: 863)
> at org.eclipse.e4.xwt.XWTLoader.load(XWTLoader.java:729)
> at org.eclipse.e4.xwt.XWT.load(XWT.java:425)
> at com.infogix.dptoolcatalog.export.configui.NodePropertiesDial
> og.getConfigPanelsMap(NodePropertiesDialog.java:289)
> at com.infogix.dptoolcatalog.export.configui.NodePropertiesDial
> og.createDialogArea(NodePropertiesDialog.java:218)
> at org.eclipse.jface.dialogs.Dialog.createContents(Dialog.java: 760)
> ...
Previous Topic:Share data between XWT instances ?
Next Topic:E4 versus E3 for Eclipse applications
Goto Forum:
  


Current Time: Fri Apr 19 04:39:51 GMT 2024

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

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

Back to the top