Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Visual Editor (VE) » ClassCastException while adding a customwidget to another customwidget
ClassCastException while adding a customwidget to another customwidget [message #132131] Wed, 11 October 2006 10:14
Varun Balakrishnan is currently offline Varun BalakrishnanFriend
Messages: 17
Registered: July 2009
Junior Member
Hi,
I have a custom widget named TextField(extends JPanel and contains
JTextField and JLabel). When I drop this widget from the palette, I need to
get something like this
textField = new TextField("text", "label", 50, 0);

I was able to generate this code using allocation mechanism.
My TextField.xmi file is shown below.

<lcdui:TextField xmi:id="TextField_1">
<allocation
xsi:type="org.eclipse.jem.internal.instantiation:ParseTreeAllocation ">
<expression
xsi:type=" org.eclipse.jem.internal.instantiation:PTClassInstanceCreati on "
type="javax.microedition.lcdui.TextField">
<arguments
xsi:type="org.eclipse.jem.internal.instantiation:PTStringLiteral "
literalValue="text"/>
<arguments
xsi:type="org.eclipse.jem.internal.instantiation:PTStringLiteral "
literalValue="label"/>
<arguments
xsi:type="org.eclipse.jem.internal.instantiation:PTNumberLiteral "
token="50"/>
<arguments
xsi:type="org.eclipse.jem.internal.instantiation:PTNumberLiteral "
token="0"/>
</expression>
</allocation>
</lcdui:TextField>

I have a decoder, decoderhelper, containmenthandler and graphical
edit part associated with my customwidget.
My GraphicalEditPart is not doing much, decoderhelper is used to prevent
generation of setBounds() for customwidget.
ContainmentHandler is used to control adding of custom widget to other
containers.
But when I drop my custom widget the below mentioned exception is
thrown by VE. Custom widget is getting added to the parent(even though
exception
is thrown by VE) but when I try to change the values inside the constructor
call - textField = new TextField("text", "label", 50, 0); - another custom
widget is created and added to the Editor.

Please see the attachment.
Someone please tell me what is going wrong. Any help would be good
for me.

java.lang.ClassCastException:
org.eclipse.jem.internal.instantiation.impl.ParseTreeAllocat ionImpl
at
org.eclipse.ve.internal.java.codegen.java.SimpleAttributeDec oderHelper.adaptToCompositionModel(SimpleAttributeDecoderHel per.java:380)
at
org.eclipse.ve.internal.java.codegen.java.AbstractExpression Decoder.generate(AbstractExpressionDecoder.java:214)
at
org.eclipse.ve.internal.java.codegen.java.ExpressionRefFacto ry.parseInitExpression(ExpressionRefFactory.java:263)
at
org.eclipse.ve.internal.java.codegen.java.BeanPartFactory.pa rseInitExpression(BeanPartFactory.java:165)
at
org.eclipse.ve.internal.java.codegen.java.BeanPartFactory.ge nerateInitMethod(BeanPartFactory.java:262)
at
org.eclipse.ve.internal.java.codegen.java.BeanPartFactory.cr eateFromJVEModel(BeanPartFactory.java:663)
at
org.eclipse.ve.internal.java.codegen.model.BeanDeclModel.laz yCreateBeanInstance(BeanDeclModel.java:305)
at
org.eclipse.ve.internal.java.codegen.model.BeanDeclModel.get ABean(BeanDeclModel.java:324)
at
org.eclipse.mtj.internal.midp.codegen.lcdui.FormDecoderHelpe r.generate(FormDecoderHelper.java:55)
at
org.eclipse.ve.internal.java.codegen.java.AbstractExpression Decoder.generate(AbstractExpressionDecoder.java:194)
at
org.eclipse.ve.internal.java.codegen.model.CodeExpressionRef .generateSource(CodeExpressionRef.java:361)
at
org.eclipse.ve.internal.java.codegen.java.ExpressionRefFacto ry.createFromJVEModel(ExpressionRefFactory.java:102)
at
org.eclipse.ve.internal.java.codegen.java.BeanDecoderAdapter .addElement(BeanDecoderAdapter.java:390)
at
org.eclipse.ve.internal.java.codegen.java.BeanDecoderAdapter .notifyChanged(BeanDecoderAdapter.java:447)
at
org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:230)
at
org.eclipse.emf.ecore.util.EcoreEList.dispatchNotification(E coreEList.java:234)
at
org.eclipse.emf.common.notify.impl.NotifyingListImpl.addAllU nique(NotifyingListImpl.java:452)
at
org.eclipse.emf.common.notify.impl.NotifyingListImpl.addAllU nique(NotifyingListImpl.java:396)
at org.eclipse.emf.common.util.BasicEList.addAll(BasicEList.jav a:688)
at
org.eclipse.ve.internal.cde.commands.ApplyAttributeSettingCo mmand.execute(ApplyAttributeSettingCommand.java:92)
at
org.eclipse.ve.internal.propertysheet.common.commands.Compou ndCommand.execute(CompoundCommand.java:224)
at
org.eclipse.ve.internal.java.codegen.editorpart.JavaVisualEd itorCommandStack$1.run(JavaVisualEditorCommandStack.java:55)
at
org.eclipse.ve.internal.cde.core.ModelChangeController.doMod elChanges(ModelChangeController.java:245)
at
org.eclipse.ve.internal.java.codegen.editorpart.JavaVisualEd itorCommandStack.execute(JavaVisualEditorCommandStack.java:5 2)
at org.eclipse.gef.tools.AbstractTool.executeCommand(AbstractTo ol.java:388)
at
org.eclipse.gef.tools.AbstractTool.executeCurrentCommand(Abs tractTool.java:400)
at
org.eclipse.gef.tools.CreationTool.performCreation(CreationT ool.java:254)
at org.eclipse.gef.tools.CreationTool.handleButtonUp(CreationTo ol.java:178)
at org.eclipse.gef.tools.AbstractTool.mouseUp(AbstractTool.java :1053)
at org.eclipse.gef.EditDomain.mouseUp(EditDomain.java:259)
at
org.eclipse.gef.ui.parts.DomainEventDispatcher.dispatchMouse Released(DomainEventDispatcher.java:374)
at
org.eclipse.draw2d.LightweightSystem$EventHandler.mouseUp(Li ghtweightSystem.java:538)
at
org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:137)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:928)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3348)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2968)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:1914)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1878)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:419)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplicatio n.java:95)
at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:78)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:92)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:68)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:400)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336 )
at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
at org.eclipse.core.launcher.Main.run(Main.java:977)
at org.eclipse.core.launcher.Main.main(Main.java:952)


Regards,
Varun


Previous Topic:Distributing VE-developed standalone SWT application
Next Topic:ClassCastException while adding a customwidget to another customwidget
Goto Forum:
  


Current Time: Thu Apr 25 13:47:27 GMT 2024

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

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

Back to the top