Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[ve-dev] ClassCastException while adding a custom widget to anther customwidget

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:PTClassInstanceCreation
" 
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.ParseTreeAllocationImpl
 at
org.eclipse.ve.internal.java.codegen.java.SimpleAttributeDecoderHelper.a
daptToCompositionModel(SimpleAttributeDecoderHelper.java:380)
 at
org.eclipse.ve.internal.java.codegen.java.AbstractExpressionDecoder.gene
rate(AbstractExpressionDecoder.java:214)
 at
org.eclipse.ve.internal.java.codegen.java.ExpressionRefFactory.parseInit
Expression(ExpressionRefFactory.java:263)
 at
org.eclipse.ve.internal.java.codegen.java.BeanPartFactory.parseInitExpre
ssion(BeanPartFactory.java:165)
 at
org.eclipse.ve.internal.java.codegen.java.BeanPartFactory.generateInitMe
thod(BeanPartFactory.java:262)
 at
org.eclipse.ve.internal.java.codegen.java.BeanPartFactory.createFromJVEM
odel(BeanPartFactory.java:663)
 at
org.eclipse.ve.internal.java.codegen.model.BeanDeclModel.lazyCreateBeanI
nstance(BeanDeclModel.java:305)
 at
org.eclipse.ve.internal.java.codegen.model.BeanDeclModel.getABean(BeanDe
clModel.java:324)
 at
org.eclipse.mtj.internal.midp.codegen.lcdui.FormDecoderHelper.generate(F
ormDecoderHelper.java:55)
 at
org.eclipse.ve.internal.java.codegen.java.AbstractExpressionDecoder.gene
rate(AbstractExpressionDecoder.java:194)
 at
org.eclipse.ve.internal.java.codegen.model.CodeExpressionRef.generateSou
rce(CodeExpressionRef.java:361)
 at
org.eclipse.ve.internal.java.codegen.java.ExpressionRefFactory.createFro
mJVEModel(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.notifyChang
ed(BeanDecoderAdapter.java:447)
 at
org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifi
erImpl.java:230)
 at
org.eclipse.emf.ecore.util.EcoreEList.dispatchNotification(EcoreEList.ja
va:234)
 at
org.eclipse.emf.common.notify.impl.NotifyingListImpl.addAllUnique(Notify
ingListImpl.java:452)
 at
org.eclipse.emf.common.notify.impl.NotifyingListImpl.addAllUnique(Notify
ingListImpl.java:396)
 at org.eclipse.emf.common.util.BasicEList.addAll(BasicEList.java:688)
 at
org.eclipse.ve.internal.cde.commands.ApplyAttributeSettingCommand.execut
e(ApplyAttributeSettingCommand.java:92)
 at
org.eclipse.ve.internal.propertysheet.common.commands.CompoundCommand.ex
ecute(CompoundCommand.java:224)
 at
org.eclipse.ve.internal.java.codegen.editorpart.JavaVisualEditorCommandS
tack$1.run(JavaVisualEditorCommandStack.java:55)
 at
org.eclipse.ve.internal.cde.core.ModelChangeController.doModelChanges(Mo
delChangeController.java:245)
 at
org.eclipse.ve.internal.java.codegen.editorpart.JavaVisualEditorCommandS
tack.execute(JavaVisualEditorCommandStack.java:52)
 at
org.eclipse.gef.tools.AbstractTool.executeCommand(AbstractTool.java:388)
 at
org.eclipse.gef.tools.AbstractTool.executeCurrentCommand(AbstractTool.ja
va:400)
 at
org.eclipse.gef.tools.CreationTool.performCreation(CreationTool.java:254
)
 at
org.eclipse.gef.tools.CreationTool.handleButtonUp(CreationTool.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.dispatchMouseReleased(Dom
ainEventDispatcher.java:374)
 at
org.eclipse.draw2d.LightweightSystem$EventHandler.mouseUp(LightweightSys
tem.java:538)
 at
org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.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.java:3348)
 at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2968)
 at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1914)
 at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1878)
 at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:4
19)
 at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
 at
org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:95)
 at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActiva
tor.java:78)
 at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplicat
ion(EclipseAppLauncher.java:92)
 at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(Eclip
seAppLauncher.java:68)
 at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:
400)
 at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.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 



________________________________


Attachment: customwidgets.png
Description: customwidgets.png


Back to the top