How does <constructors> in *.wbp-component.xml work?

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

How does <constructors> in *.wbp-component.xml work?

Postby mkornatzki » Wed Oct 14, 2009 1:55 am

Hello,

i have a *.wbp-component.xml for my component and i can see the description and preferred properties in swingdesigner.
The content of the file is:

Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<component xmlns="http://www.instantiations.com/D2/WBPComponent">
    <description>Eingabefeld f&#x00FC;r ein Zeichen
    <ul>
      <li>value = Objekt vom Typ Character</li>
   </ul>
    </description>
       
    <!-- PROPERTIES -->
    <properties-preferred names="backgroundText nullAllowed value" />
    <properties-hidden names="text" />
</component>

My Class has multiple Constructors.
public CharacterValueField()
public CharacterValueField(boolean newNullAllowed)

I add the following to the *.wbp-component.xml file:

Code: Select all
    <!-- CONSTRUCTORS -->
    <constructors>
       <constructor>
          <parameter type="boolean" property"setNullAllowed(boolean)"/>
       </constructor>   
    </constructors>

If i now refresh my palette i get the following error:

Code: Select all
Unable to load *.wbp-component.xml description.
Stack trace:
com.instantiations.designer.core.utils.exception.DesignerException: 502 (Unable to load *.wbp-component.xml description.). de.parcit.guibase.swing.text.valuefield.CharacterValueField
   at com.instantiations.designer.core.model.description.helpers.ComponentDescriptionHelper.getDescription0(ComponentDescriptionHelper.java:411)
   at com.instantiations.designer.core.model.description.helpers.ComponentDescriptionHelper.getDescription0(ComponentDescriptionHelper.java:259)
   at com.instantiations.designer.core.model.description.helpers.ComponentDescriptionHelper.getDescription(ComponentDescriptionHelper.java:233)
   at com.instantiations.designer.core.model.JavaInfoUtils.createJavaInfo(JavaInfoUtils.java:354)
   at com.instantiations.designer.core.parser.AbstractParseFactory.createInstance(AbstractParseFactory.java:598)
   at com.instantiations.designer.core.parser.AbstractParseFactory.create(AbstractParseFactory.java:161)
   at com.instantiations.designer.swing.parser.ParseFactory.create(ParseFactory.java:153)
   at com.instantiations.designer.core.parser.JavaInfoParser$ExecutionFlowParseVisitor.endVisit(JavaInfoParser.java:521)
   at org.eclipse.jdt.core.dom.ClassInstanceCreation.accept0(ClassInstanceCreation.java:337)
   at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2480)
   at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:2528)
   at org.eclipse.jdt.core.dom.VariableDeclarationFragment.accept0(VariableDeclarationFragment.java:225)
   at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2480)
   at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2551)
   at org.eclipse.jdt.core.dom.VariableDeclarationStatement.accept0(VariableDeclarationStatement.java:273)
   at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2480)
   at com.instantiations.designer.core.eval.ExecutionFlowUtils.visitStatement0(ExecutionFlowUtils.java:338)
   at com.instantiations.designer.core.eval.ExecutionFlowUtils.visitStatement(ExecutionFlowUtils.java:256)
   at com.instantiations.designer.core.eval.ExecutionFlowUtils.visitStatement0(ExecutionFlowUtils.java:275)
   at com.instantiations.designer.core.eval.ExecutionFlowUtils.visitStatement(ExecutionFlowUtils.java:256)
   at com.instantiations.designer.core.eval.ExecutionFlowUtils.visitStatement0(ExecutionFlowUtils.java:275)
   at com.instantiations.designer.core.eval.ExecutionFlowUtils.visitStatement(ExecutionFlowUtils.java:256)
   at com.instantiations.designer.core.eval.ExecutionFlowUtils.visit(ExecutionFlowUtils.java:214)
   at com.instantiations.designer.core.eval.ExecutionFlowUtils.visit(ExecutionFlowUtils.java:193)
   at com.instantiations.designer.core.eval.ExecutionFlowUtils.visit(ExecutionFlowUtils.java:162)
   at com.instantiations.designer.core.parser.JavaInfoParser.parseRootMethods(JavaInfoParser.java:259)
   at com.instantiations.designer.core.parser.JavaInfoParser.parse(JavaInfoParser.java:233)
   at com.instantiations.designer.core.parser.JavaInfoParser.access$000(JavaInfoParser.java:117)
   at com.instantiations.designer.core.parser.JavaInfoParser$1.runObject(JavaInfoParser.java:139)
   at com.instantiations.designer.core.parser.JavaInfoParser$1.runObject(JavaInfoParser.java:138)
   at com.instantiations.designer.core.utils.execution.ExecutionUtils.runDesignTime(ExecutionUtils.java:99)
   at com.instantiations.designer.core.parser.JavaInfoParser.parse(JavaInfoParser.java:137)
   at com.instantiations.designer.core.editor.DesignPage.internal_refreshGEF_withProgress(DesignPage.java:408)
   at com.instantiations.designer.core.editor.DesignPage.access$800(DesignPage.java:57)
   at com.instantiations.designer.core.editor.DesignPage$7$1.run(DesignPage.java:316)
   at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:179)
   at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:150)
   at org.eclipse.swt.widgets.Display.syncExec(Display.java:4312)
   at com.instantiations.designer.core.editor.DesignPage$7.run(DesignPage.java:313)
   at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:464)
   at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:372)
   at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:507)
   at com.instantiations.designer.core.editor.DesignPage.internal_refreshGEF(DesignPage.java:334)
   at com.instantiations.designer.core.editor.UndoManager.refreshDesignerEditor(UndoManager.java:444)
   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)

Full context stack trace:
com.instantiations.designer.core.utils.exception.DesignerException: 0 (Wrapper).
   at com.instantiations.designer.core.parser.JavaInfoParser$ExecutionFlowParseVisitor.endVisit(JavaInfoParser.java:538)
   at org.eclipse.jdt.core.dom.ClassInstanceCreation.accept0(ClassInstanceCreation.java:337)
   at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2480)
   at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:2528)
   at org.eclipse.jdt.core.dom.VariableDeclarationFragment.accept0(VariableDeclarationFragment.java:225)
   at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2480)
   at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2551)
   at org.eclipse.jdt.core.dom.VariableDeclarationStatement.accept0(VariableDeclarationStatement.java:273)
   at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2480)
   at com.instantiations.designer.core.eval.ExecutionFlowUtils.visitStatement0(ExecutionFlowUtils.java:338)
   at com.instantiations.designer.core.eval.ExecutionFlowUtils.visitStatement(ExecutionFlowUtils.java:256)
   at com.instantiations.designer.core.eval.ExecutionFlowUtils.visitStatement0(ExecutionFlowUtils.java:275)
   at com.instantiations.designer.core.eval.ExecutionFlowUtils.visitStatement(ExecutionFlowUtils.java:256)
   at com.instantiations.designer.core.eval.ExecutionFlowUtils.visitStatement0(ExecutionFlowUtils.java:275)
   at com.instantiations.designer.core.eval.ExecutionFlowUtils.visitStatement(ExecutionFlowUtils.java:256)
   at com.instantiations.designer.core.eval.ExecutionFlowUtils.visit(ExecutionFlowUtils.java:214)
   at com.instantiations.designer.core.eval.ExecutionFlowUtils.visit(ExecutionFlowUtils.java:193)
   at com.instantiations.designer.core.eval.ExecutionFlowUtils.visit(ExecutionFlowUtils.java:162)
   at com.instantiations.designer.core.parser.JavaInfoParser.parseRootMethods(JavaInfoParser.java:259)
   at com.instantiations.designer.core.parser.JavaInfoParser.parse(JavaInfoParser.java:233)
   at com.instantiations.designer.core.parser.JavaInfoParser.access$000(JavaInfoParser.java:117)
   at com.instantiations.designer.core.parser.JavaInfoParser$1.runObject(JavaInfoParser.java:139)
   at com.instantiations.designer.core.parser.JavaInfoParser$1.runObject(JavaInfoParser.java:138)
   at com.instantiations.designer.core.utils.execution.ExecutionUtils.runDesignTime(ExecutionUtils.java:99)
   at com.instantiations.designer.core.parser.JavaInfoParser.parse(JavaInfoParser.java:137)
   at com.instantiations.designer.core.editor.DesignPage.internal_refreshGEF_withProgress(DesignPage.java:408)
   at com.instantiations.designer.core.editor.DesignPage.access$800(DesignPage.java:57)
   at com.instantiations.designer.core.editor.DesignPage$7$1.run(DesignPage.java:316)
   at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:179)
   at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:150)
   at org.eclipse.swt.widgets.Display.syncExec(Display.java:4312)
   at com.instantiations.designer.core.editor.DesignPage$7.run(DesignPage.java:313)
   at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:464)
   at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:372)
   at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:507)
   at com.instantiations.designer.core.editor.DesignPage.internal_refreshGEF(DesignPage.java:334)
   at com.instantiations.designer.core.editor.UndoManager.refreshDesignerEditor(UndoManager.java:444)
   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)
Caused by: com.instantiations.designer.core.utils.exception.DesignerException: 502 (Unable to load *.wbp-component.xml description.). de.parcit.guibase.swing.text.valuefield.CharacterValueField
   at com.instantiations.designer.core.model.description.helpers.ComponentDescriptionHelper.getDescription0(ComponentDescriptionHelper.java:411)
   at com.instantiations.designer.core.model.description.helpers.ComponentDescriptionHelper.getDescription0(ComponentDescriptionHelper.java:259)
   at com.instantiations.designer.core.model.description.helpers.ComponentDescriptionHelper.getDescription(ComponentDescriptionHelper.java:233)
   at com.instantiations.designer.core.model.JavaInfoUtils.createJavaInfo(JavaInfoUtils.java:354)
   at com.instantiations.designer.core.parser.AbstractParseFactory.createInstance(AbstractParseFactory.java:598)
   at com.instantiations.designer.core.parser.AbstractParseFactory.create(AbstractParseFactory.java:161)
   at com.instantiations.designer.swing.parser.ParseFactory.create(ParseFactory.java:153)
   at com.instantiations.designer.core.parser.JavaInfoParser$ExecutionFlowParseVisitor.endVisit(JavaInfoParser.java:521)
   ... 67 more

Can you please have a look on my definition (maybe i missed a char somewhere?) or do i misunderstand the <constructor>-parameter?

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

Re: How does <constructors> in *.wbp-component.xml work?

Postby Eric Clayberg » Wed Oct 14, 2009 5:30 am

mkornatzki wrote:I add the following to the *.wbp-component.xml file:

Code: Select all
    <!-- CONSTRUCTORS -->
    <constructors>
       <constructor>
          <parameter type="boolean" property"setNullAllowed(boolean)"/>
       </constructor>   
    </constructors>

At first glance, the above is not valid XML, so it looks like a simple XML parse failure.
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: How does <constructors> in *.wbp-component.xml work?

Postby mkornatzki » Wed Oct 14, 2009 5:47 am

thank you very much. i will use an xml-validator in future.

now it makes no error but what is it good for?

i guessed that if i have an empty default constructor and a constructor with a boolean for nullAllowed then i define the constructors in the xml-file and if i set the property "nullAllowed" in the properties-view then the second constructor gets used in sourcecode.
Am i wrong?

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

Re: How does <constructors> in *.wbp-component.xml work?

Postby Eric Clayberg » Wed Oct 14, 2009 12:35 pm

mkornatzki wrote:now it makes no error but what is it good for?

It allows you to associate specific constructor parameters with specific properties (something that the normal JavaBean spec doesn't provide for). In the property view, you can change either the constructor parameter or the associated property to have the same effect.

Note that you don't need to declare all the constructors of you component. You need to do this only if you want to tell Swing Designer something useful about the constructor. For example, to specify that some parameter is bound to some property, or to specify the default value of the parameter (used when user presses the DEL key on the «constructor/parameter» property).
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: How does <constructors> in *.wbp-component.xml work?

Postby mkornatzki » Wed Oct 14, 2009 11:54 pm

That sounds good and i want it;)

but i can not see the constructor/parameter. do i have something overlooked?
Normal Properties:
Image

Advanced Properties:
Image Image

My class:
Code: Select all
   public CharacterValueField() {
      this(true);
   }

   public CharacterValueField(
      boolean newNullAllowed) {
      this(newNullAllowed, false);
   }


The xml-file:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<component xmlns="http://www.instantiations.com/D2/WBPComponent">
    <description>Eingabefeld f&#x00FC;r ein Zeichen
    <ul>
      <li>value = Objekt vom Typ Character</li>
      <li>Nur ein Zeichen kann eingegeben werden</li>
   </ul>
    </description>
   
    <!-- CONSTRUCTORS -->
    <constructors>
       <constructor>
          <parameter type="boolean" property="setNullAllowed(boolean)"/>
       </constructor>   
    </constructors>
   
    <!-- PROPERTIES -->
    <properties-preferred names="backgroundText nullAllowed value" />
    <properties-hidden names="text" />
</component>


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

Re: How does <constructors> in *.wbp-component.xml work?

Postby Eric Clayberg » Thu Oct 15, 2009 4:44 am

Constructor parameters are only shown for widgets that have been created with constructor parameters in the source. If you want your newly dropped widget to be created with a constructor parameter, you need to add a <creation> element to your *.wbp-component.xml file. Here's an example from JLabel...

Code: Select all
   <!-- CREATION -->
   <creation>
      <source><![CDATA[new javax.swing.JLabel("New label")]]></source>
   </creation>
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: How does <constructors> in *.wbp-component.xml work?

Postby mkornatzki » Thu Oct 15, 2009 5:21 am

superb.

thank you thats what i'm looking for.

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

Re: How does <constructors> in *.wbp-component.xml work?

Postby Eric Clayberg » Thu Oct 15, 2009 5:39 am

Good. Glad I could help.
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