Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » WindowBuilder » Persisting WindowBuilder component properties as XML Elements in XWT
Persisting WindowBuilder component properties as XML Elements in XWT [message #1446028] Thu, 16 October 2014 08:48 Go to next message
Simon H is currently offline Simon HFriend
Messages: 2
Registered: October 2014
Junior Member
Hi all,

We are building a simple GUI based XML editor by extending the WindowBuilder XWT plugin. Essentially, controls are dragged on to the design page and are then converted to XWT by WindowBuilder. Up to now we've created a prototype version by extending the existing SWT controls (Composite, Label, Text) and adding new class members to them. These class members are then displayed as properties in the property view and are persisted as XML attributes of the respective control. The generated XWT looks something like this:

<p1:RootComponent xmlns:p1="clr-namespace:com.test.namespace" xmlns:x="http://www.eclipse.org/xwt" background="#E1E1E1" x:Name="RootName">
	<p1:ControlComponent x:Name="Control1Name" customProperty1="some property" customProperty2="someproperty" />
</p1:RootComponent>


As you can see, this solution will not scale well and does not support complex class members. I.e. Members that are objects and not just strings. We'd ideally like WindowBuilder to write simple objects to XWT as elements of the control rather than as attributes, so that the end result looks something like the following:

<p1:RootComponent xmlns:p1="clr-namespace:com.test.namespace" xmlns:x="http://www.eclipse.org/xwt">
	<p1:ControlComponent x:Name="Control1Name">
		<CustomProperty1>
			<Name></Name>
			<Value></Value>
		</CustomProperty1>
		<CustomProperty2>
			<Name></Name>
			<Value></Value>
			<SomethingElse></SomethingElse>
		</CustomProperty2>
	</p1:ControlComponent
</p1:RootComponent>


We've been able to get WindowBuilder to display custom PropertyEditors for objects, but the property is always written to XWT as an attribute of the control and not as an element.

Does anyone know how to get WindowBuilder to write objects to the XWT as elements? WindowBuilder documentation is very thin on the ground.


Many Thanks,

Simon
Re: Persisting WindowBuilder component properties as XML Elements in XWT [message #1446464 is a reply to message #1446028] Thu, 16 October 2014 22:19 Go to previous messageGo to next message
Konstantin Scheglov is currently offline Konstantin ScheglovFriend
Messages: 555
Registered: July 2009
Senior Member
If I don't miss something, WindowBuilder does it because it is where XWT expects properties to be.
So, XWT Designer (actually it was mainly done as a simple prototype of XML UIs support in WindowBuilder before implementing GWT UiBinder designer) uses org.eclipse.wb.internal.core.xml.model.property.XmlAttributeProperty, which updates element attributes.

Also, most of the properties are org.eclipse.wb.internal.core.xml.model.property.GenericPropertyImpl, and use org.eclipse.wb.internal.core.xml.model.property.accessor.ExpressionAccessor to actually update XML.
And org.eclipse.wb.internal.core.xml.model.property.accessor.ExpressionAccessor.setExpression(XmlObjectInfo, String) is also implemented to update attributes.

In theory you can add org.eclipse.wb.internal.core.xml.model.broadcast.GenericPropertySetExpression broadcast, so intercept setting expressions and create elements instead.


Konstantin Scheglov,
Google, Inc.

[Updated on: Thu, 16 October 2014 22:20]

Report message to a moderator

Re: Persisting WindowBuilder component properties as XML Elements in XWT [message #1499908 is a reply to message #1446464] Fri, 05 December 2014 14:12 Go to previous message
Simon H is currently offline Simon HFriend
Messages: 2
Registered: October 2014
Junior Member
Thanks for the reply Smile

We did end up taking the approach you suggested - intercepting the setting of the expressions and ouputting XML elements rather than attribites. This works great until it comes to copy and paste functionality. As the XML elements that we create are not 'true' children of the object and are not instances of the XMLObjectInfo class, they are not seen as elements, but as properties. This causes window builder to attempt to generate an attribute for the property when pasting the object rather than simply copying the XML of the copied object.

Do you perhaps know of any way of intercepting the pasting of the object so that we can output our XML elements rather than having WindowBuilder interpret them as attributes?
Previous Topic:The Future of WindowBuilder
Next Topic:WindowBuilder moving to Git
Goto Forum:
  


Current Time: Tue Sep 25 00:58:42 GMT 2018

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

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

Back to the top