Factory and methods with parameter in *.wbp-component.xml

Swing Designer allows you to quickly create the frames, panels, dialogs, applets and other UI elements that comprise Java Swing applications.

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

Factory and methods with parameter in *.wbp-component.xml

Postby mkornatzki » Mon Oct 19, 2009 12:50 am

My factory has the following constructors:
public static StringValueField createStringValueField() {...}
public static StringValueField createStringValueField(int maxLength) {...}

How should the *.wbp-component.xml look like:
if i use
Code: Select all
   <method name='createStringValueField' factory='true'>
      <name>StringValueField</name>
      <description>Eingabefeld f&#x00FC;r eine Zeichenkette
         <ul>
              <li>value = Objekt vom Typ String</li>
         </ul>
      </description>
   </method>
   
   <method name='createStringValueField(int)' factory='true'>
      <name>StringValueField(maxLength)</name>
      <description>Eingabefeld f&#x00FC;r eine Zeichenkette
         <ul>
              <li>value = Objekt vom Typ String</li>
         </ul>
         Parameter:
         <ul>
            <li>maxLength = Anzahl Zeichen</li>
         </ul>
      </description>
   </method>   

i get the following error:
Code: Select all
java.lang.ArrayIndexOutOfBoundsException: 2
        at com.instantiations.designer.core.editor.UndoManager.getObjectForPath(UndoManager.java:354)
        at com.instantiations.designer.core.editor.UndoManager.getObjectsForPaths(UndoManager.java:340)
        at com.instantiations.designer.core.editor.UndoManager.restoreSelection(UndoManager.java:242)
        at com.instantiations.designer.core.editor.UndoManager.restoreState(UndoManager.java:221)
        at com.instantiations.designer.core.editor.UndoManager.refreshDesignerEditor(UndoManager.java:452)
        at com.instantiations.designer.core.editor.DesignPage.refreshGEF(DesignPage.java:292)
        at com.instantiations.designer.core.editor.actions.RefreshAction.run(RefreshAction.java:30)
        at com.instantiations.designer.core.editor.actions.DesignPageAction.run(DesignPageAction.java:23)
        at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
        at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
        at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
        at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:452)
        at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
        at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
        at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3880)
        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3473)
        at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2405)
        at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369)
        at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
        at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
        at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
        at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493)
        at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
        at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
        at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
        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:597)
        at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
        at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
        at org.eclipse.equinox.launcher.Main.run(Main.java:1311)


In the export of the palette the methodname is name="createStringValueField()"
if i add brackets in the xml-file like <method name='createStringValueField()' factory='true'> instead of <method name='createStringValueField' factory='true'>
i get the same error.

regards,
michael
mkornatzki
 
Posts: 121
Joined: Wed Oct 15, 2008 3:57 am

Re: Factory and methods with parameter in *.wbp-component.xml

Postby Eric Clayberg » Mon Oct 19, 2009 12:56 pm

Give this a try using the latest build.
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: Factory and methods with parameter in *.wbp-factory.xml

Postby mkornatzki » Mon Oct 19, 2009 10:35 pm

Now i didn't get an error on the consoleLog but if i use brackets in the xml even whithout adding the component for the definition then the whole category is collapsed and can not get opened.

Then i tried to add the component but the "add static factory" dialog show that my factory class has no factory methods (but it has).

Sorry, i make a mistake in the subject. It should be "wbp-factory" instead of "wbp-component".

The problem for me still exists.
How do i define factory methods with parameter in the xml-file?

regards,
michael
mkornatzki
 
Posts: 121
Joined: Wed Oct 15, 2008 3:57 am

Re: Factory and methods with parameter in *.wbp-component.xml

Postby Konstantin.Scheglov » Tue Oct 20, 2009 6:03 am

See attached example.
Attachments
MyFactory2.wbp-factory.xml
Factory description.
(327 Bytes) Downloaded 50 times
MyFactory2.java
Factory class.
(238 Bytes) Downloaded 45 times
Konstantin.Scheglov
Moderator
 
Posts: 186
Joined: Tue Oct 18, 2005 8:11 pm
Location: Russian Federation, Lipetsk

Re: Factory and methods with parameter in *.wbp-component.xml

Postby mkornatzki » Wed Oct 21, 2009 10:24 pm

thank you for the example.
now i got it to work and it works great :)

regards,
michael
mkornatzki
 
Posts: 121
Joined: Wed Oct 15, 2008 3:57 am

Re: Factory and methods with parameter in *.wbp-component.xml

Postby Eric Clayberg » Thu Oct 22, 2009 4:36 am

Glad it works for you.
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 Swing Designer

Who is online

Users browsing this forum: No registered users and 1 guest