Cannot add a FigureCanvas

SWT Designer allows you to create the views, editors, perspectives, pref pages, composites, etc. that comprise Eclipse SWT & RCP applications and plug-ins.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

Cannot add a FigureCanvas

Postby Feng Dihai » Sun Aug 13, 2006 11:59 pm

We have created a customized component based on FigureCanvas, but failed to insert it via SWT designer.

Please help us to figure out the problem. Thank you.

Log is here:

!ENTRY com.swtdesigner 4 4 2006-08-14 16:53:00.536
!MESSAGE Designer internal error [5.0.0.2006.06.23]: Can not find constructor for org.eclipse.draw2d.FigureCanvas
!STACK 0
java.lang.IllegalArgumentException: Can not find constructor for org.eclipse.draw2d.FigureCanvas
at com.swtdesigner.model.swt.widgets.SWTBeanInfo.getNewControlCode(SWTBeanInfo.java:413)
at com.swtdesigner.model.JavaInfo.getNewControlBlockCode(JavaInfo.java:3411)
at com.swtdesigner.model.JavaInfo.addToParentBlockOrPlain(JavaInfo.java:3138)
at com.swtdesigner.model.JavaInfo.addToParent(JavaInfo.java:3104)
at com.swtdesigner.model.swing.JavaBeanInfo.addToParent(JavaBeanInfo.java:720)
at com.swtdesigner.model.swt.widgets.WidgetInfo.addToParent(WidgetInfo.java:93)
at com.swtdesigner.model.JavaInfo.addToParent(JavaInfo.java:3083)
at com.swtdesigner.model.swt.layout.grid.GridLayoutInfo.createCommand(GridLayoutInfo.java:1333)
at com.swtdesigner.gef.policy.swt.layout.grid.GridLayoutEditPolicy2$CreateCommand.execute(GridLayoutEditPolicy2.java:243)
at org.eclipse.gef.commands.CommandStack.execute(CommandStack.java:78)
at com.swtdesigner.gef.domain.DesignerEditDomain$1.execute(DesignerEditDomain.java:57)
at org.eclipse.gef.tools.AbstractTool.executeCurrentCommand(AbstractTool.java:416)
at org.eclipse.gef.tools.CreationTool.performCreation(CreationTool.java:198)
at org.eclipse.gef.tools.CreationTool.handleButtonUp(CreationTool.java:122)
at org.eclipse.gef.tools.AbstractTool.mouseUp(AbstractTool.java:1006)
at org.eclipse.gef.EditDomain.mouseUp(EditDomain.java:229)
at com.swtdesigner.gef.domain.DesignerEditDomain.mouseUp(DesignerEditDomain.java:265)
at org.eclipse.gef.ui.parts.DomainEventDispatcher.dispatchMouseReleased(DomainEventDispatcher.java:346)
at org.eclipse.draw2d.LightweightSystem$EventHandler.mouseUp(LightweightSystem.java:511)
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:419)
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(PlatformActivator.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(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(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
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)
Feng Dihai
 
Posts: 6
Joined: Sun Aug 13, 2006 11:48 pm

Re: Cannot add a FigureCanvas

Postby Eric Clayberg » Mon Aug 14, 2006 1:11 am

Feng Dihai wrote:We have created a customized component based on FigureCanvas, but failed to insert it via SWT designer.
...
java.lang.IllegalArgumentException: Can not find constructor for org.eclipse.draw2d.FigureCanvas

Make sure that your widget has a public, two argument constructor (required in order to be a valid SWT widget).

The constructor argtuments should be a Composite and an int (e.g., parent and style).
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Re: Cannot add a FigureCanvas

Postby Feng Dihai » Mon Aug 14, 2006 4:02 pm

Eric Clayberg wrote:Make sure that your widget has a public, two argument constructor (required in order to be a valid SWT widget).

The constructor argtuments should be a Composite and an int (e.g., parent and style).


Yes, we prepared a constructor like this:

Code: Select all
public MyFigureCanvas(Composite parent, int style)


The problem is we just cannot insert a org.eclipse.draw2d.FigureCanvas, which of course has a constructor like

Code: Select all
public FigureCanvas(Composite parent, int style)
Feng Dihai
 
Posts: 6
Joined: Sun Aug 13, 2006 11:48 pm

Re: Cannot add a FigureCanvas

Postby Eric Clayberg » Mon Aug 14, 2006 6:55 pm

Feng Dihai wrote:The problem is we just cannot insert a org.eclipse.draw2d.FigureCanvas, which of course has a constructor like

I'm not sure what you mean.

I would suggest that you send us an actual test case.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Re: Cannot add a FigureCanvas

Postby Feng Dihai » Tue Aug 15, 2006 4:48 pm

Eric Clayberg wrote:I'm not sure what you mean.

I would suggest that you send us an actual test case.


I prepared a test case project to show the problem, including a .log file and 2 screenshots for both design&run time under project root.

    com.foo.swt.widget.GridFigureCanvas
    The sample subclass of org.eclipse.draw2d.FigureCanvas, which drawing grids line on background of the widget

    com.foo.SampleShell
    The container shell holding a GridFigureCanvas which is inserted by WindowBuilderPro SWTDesigner. On desing time, errors occured while everything is ok on runtime.


Please check the archived project file, download it from here: FigureCanvasTestCase.zip

Thank you very much.
Feng Dihai
 
Posts: 6
Joined: Sun Aug 13, 2006 11:48 pm

Re: Cannot add a FigureCanvas

Postby Eric Clayberg » Wed Aug 16, 2006 8:06 am

Feng Dihai wrote:Please check the archived project file

Give the latest v5.0.1 daily build a try. It will no longer throw an exception and you will be able to place your GridFigureCanvas widget in Designer.

Note that any widgets that you base off of FigureCanvas will not render correctly in the Designer Design view (they will be blank) because of the way that FigureCanvas manages its own GC. They will show up correcty when you test the window.

If you want your custom widgets to render within the Designer Design view, you should subclass Canvas instead.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA


Return to SWT Designer

Who is online

Users browsing this forum: No registered users and 1 guest