Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » XWT » XWT set Datetime/Combo(set Date of Datetime and selection of Combo widget)
XWT set Datetime/Combo [message #1396510] Tue, 08 July 2014 11:55 Go to next message
Sascha Hanke is currently offline Sascha HankeFriend
Messages: 21
Registered: April 2014
Location: Germany
Junior Member
Hello there,

I think I'm the only active or the only user of XWT with a lot of questions!
My question is what do I need and how is it done.
How do I set the date of a datetime widget and how do I set the selection of a combo widget?
Can I use java date for datetime? What is needed for the Combo?

Databinding for the text widgets works fine.

Xwt code:

<Composite.layout>
		<FillLayout/>
	</Composite.layout>
	<p1:Form background="COLOR_WHITE">
		<p1:Form.body>
			<p1:Form.body.layout>
				<GridLayout numColumns="2"/>
			</p1:Form.body.layout>
			<Label text="Datum:" background="COLOR_WHITE" />
			<DateTime x:Style="BORDER | DROP_DOWN">
			</DateTime>		
			<Label  text="Betrag (in Euro):" background="COLOR_WHITE" />
			<Text x:Style="BORDER" text="{Binding path=amount}" >
				<Text.layoutData>
					<GridData horizontalAlignment="FILL" grabExcessHorizontalSpace="true"/>
				</Text.layoutData>
			</Text>
			<Label text="Steuerschlüssel:" background="COLOR_WHITE"/>
			<ComboViewer x:Style="READ_ONLY" >
				<ComboViewer.combo>
					<ComboViewer.combo.items>
						<p2:String>Vorsteuer 7%</p2:String>
						<p2:String>Vorsteuer 19%</p2:String>
						<p2:String>Umsatzsteuer 7%</p2:String>
						<p2:String>Umsatzsteuer 19%</p2:String>
					</ComboViewer.combo.items>
				</ComboViewer.combo>
			</ComboViewer>
			<Label name="belegtext" text="Belegtext:" background="COLOR_WHITE"/>
			<Text x:Style="BORDER | MULTI" text="{Binding path=belegtext}">
				<Text.layoutData>
					<GridData horizontalAlignment="FILL" grabExcessHorizontalSpace="true" heightHint="120"/>
				</Text.layoutData>
			</Text>
		</p1:Form.body>
	</p1:Form>
</Composite>




Greetings Sascha.
Re: XWT set Datetime/Combo [message #1397399 is a reply to message #1396510] Wed, 09 July 2014 17:14 Go to previous messageGo to next message
Nguyen Viet Hoa is currently offline Nguyen Viet HoaFriend
Messages: 1
Registered: July 2014
Junior Member
Hi Sascha Hanke,

If i understand your question correctly, your question is about how to create the databinding to DateTime and ComboViewer widgets?.

1. For the DateTime widget: The code snippet below shows the usage of the DateTime widget with the databinding configuration. You should use the "DataTime.value" directive to declare the databinding.
You are free to use the java.util.Date.:

<DateTime x:name="birthday" x:style="BORDER">
<DateTime.value>
<Binding path="birthday" updateSourceTrigger="PropertyChanged">
</Binding>
</DateTime.value>
<DateTime.layoutData>
<GridData horizontalAlignment="FILL"
grabExcessHorizontalSpace="true" />
</DateTime.layoutData>
</DateTime>

2. For the ComboViewer, the code snippet below represents a simple example in which we use the "input" directive to setup the input source. For the input source, you are free to use either array, a collection or an enumation:

<ComboViewer singleSelection="{Binding path=nationality}"
input="{Binding source={x:Type n:Nationality}}" >
<ComboViewer.contentProvider>
<ObservableListContentProvider />
</ComboViewer.contentProvider>
<ComboViewer.control.layoutData>
<GridData grabExcessHorizontalSpace="true"
horizontalAlignment="GridData.FILL" />
</ComboViewer.control.layoutData>
</ComboViewer>

3. What you need for the Combo widget is to set the "text" directive to the databinding's target. The following is an example:

<Combo text="{Binding Path=manager.nationality}">
<Combo.layoutData>
<GridData horizontalAlignment="FILL"
grabExcessHorizontalSpace="true"/>
</Combo.layoutData>
</Combo>
Re: XWT set Datetime/Combo [message #1397495 is a reply to message #1396510] Wed, 09 July 2014 20:25 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
Hi Sascha,
I have no direct answer (there is no test/snippet in the XWT repository that covers the DateTime widget so far), so waiting for Yves to comment on this...

In the meantime (as a workaround) you could wrap the DateTime in your own widget and provide a "selection" bean property of type 'Date' for it, so you can bind that property to your model.

BTW: it seems that you have mapped the Eclipse Forms API to a custom clr namespace 'p1':
You can use the XWTForms utility class instead of XWT to load a forms enabled XWT file, for example:

	public static void main(String[] args) {

		URL url = Form_Section.class.getResource(Form_Section.class.getSimpleName()
				+ IConstants.XWT_EXTENSION_SUFFIX);
		try {
			XWTForms.open(url);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}


Sascha Hanke wrote on Tue, 08 July 2014 13:55
Hello there,

I think I'm the only active or the only user of XWT with a lot of questions!
My question is what do I need and how is it done.
How do I set the date of a datetime widget and how do I set the selection of a combo widget?
Can I use java date for datetime? What is needed for the Combo?

Databinding for the text widgets works fine.

Xwt code:

<Composite.layout>
		<FillLayout/>
	</Composite.layout>
	<p1:Form background="COLOR_WHITE">
		<p1:Form.body>
			<p1:Form.body.layout>
				<GridLayout numColumns="2"/>
			</p1:Form.body.layout>
			<Label text="Datum:" background="COLOR_WHITE" />
			<DateTime x:Style="BORDER | DROP_DOWN">
			</DateTime>		
			<Label  text="Betrag (in Euro):" background="COLOR_WHITE" />
			<Text x:Style="BORDER" text="{Binding path=amount}" >
				<Text.layoutData>
					<GridData horizontalAlignment="FILL" grabExcessHorizontalSpace="true"/>
				</Text.layoutData>
			</Text>
			<Label text="Steuerschlüssel:" background="COLOR_WHITE"/>
			<ComboViewer x:Style="READ_ONLY" >
				<ComboViewer.combo>
					<ComboViewer.combo.items>
						<p2:String>Vorsteuer 7%</p2:String>
						<p2:String>Vorsteuer 19%</p2:String>
						<p2:String>Umsatzsteuer 7%</p2:String>
						<p2:String>Umsatzsteuer 19%</p2:String>
					</ComboViewer.combo.items>
				</ComboViewer.combo>
			</ComboViewer>
			<Label name="belegtext" text="Belegtext:" background="COLOR_WHITE"/>
			<Text x:Style="BORDER | MULTI" text="{Binding path=belegtext}">
				<Text.layoutData>
					<GridData horizontalAlignment="FILL" grabExcessHorizontalSpace="true" heightHint="120"/>
				</Text.layoutData>
			</Text>
		</p1:Form.body>
	</p1:Form>
</Composite>




Greetings Sascha.

Re: XWT set Datetime/Combo [message #1398051 is a reply to message #1397495] Thu, 10 July 2014 14:33 Go to previous messageGo to next message
Sascha Hanke is currently offline Sascha HankeFriend
Messages: 21
Registered: April 2014
Location: Germany
Junior Member
Hi Erdal,

first thank you for your answer. ATM I just use the @UI annotation for the Combo and DateTime and in this case it works fine.Let's see if Yves knows the right way.

2. I get confused everytime with XWT and XWTForms. Sometimes I just forget that both exist...

Re: XWT set Datetime/Combo [message #1399236 is a reply to message #1398051] Sat, 12 July 2014 08:17 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
The Eclipse Forms API uses a factory (FormToolkit) to create widgets.
The SWT widgets can be instantiated directly by calling their constructors.

XWT can handle both ways of constructing widgets by providing "Profiles".
The XWT helper class uses the default profile which handles SWT widgets creation.
The XWTForms helper class uses the Eclipse Forms API profile to delegate to the FormToolkit factory but extends the standard profile. If a widget cannot be created by the XWTForms profile, it will delegate to the SWT profile as fallback.


Sascha Hanke wrote on Thu, 10 July 2014 16:33
Hi Erdal,

first thank you for your answer. ATM I just use the @UI annotation for the Combo and DateTime and in this case it works fine.Let's see if Yves knows the right way.

2. I get confused everytime with XWT and XWTForms. Sometimes I just forget that both exist...


Re: XWT set Datetime/Combo [message #1403061 is a reply to message #1397399] Mon, 21 July 2014 06:30 Go to previous messageGo to next message
Sascha Hanke is currently offline Sascha HankeFriend
Messages: 21
Registered: April 2014
Location: Germany
Junior Member
Hi Nguyen Viet Hoa,

I'm sorry but I think I "overread" your comment...
Thank you for your answer I will try this today.

Greetings
Re: XWT set Datetime/Combo [message #1403619 is a reply to message #1403061] Thu, 24 July 2014 15:36 Go to previous messageGo to next message
Sascha Hanke is currently offline Sascha HankeFriend
Messages: 21
Registered: April 2014
Location: Germany
Junior Member
Hi @ all,

@Nguyen Viet Hoa
I tried your solution but 1. does not do anything for me.
2. I've got and Enum for gender but I don't know how to set this up correctly.

<ComboViewer singleSelection="{Binding path=nationality}"
input="{Binding source={x:Type n:Nationality}}" >
<ComboViewer.contentProvider>
<ObservableListContentProvider />
</ComboViewer.contentProvider>
</ComboViewer>

singleSelection I think is the attribute I reference to from my object(person EnumGender m/w) but how do I set up input="{Binding source={x:Type n:Nationality}}" ?

@Erdal Karaca
I faced a problem with XWTForms utility class. If I use XWTForms instead of XWT to load my file I can't use the @UI annotation. The value i get is always null. If I use the same classes with XWT - @UI gives me the right value.
Can I fix this myself?


btw. I had to get xwt forms from git to solve a bug with CTabFolder. There is an open bug for this. When do these things get fixed? Sorry if I should make another thread for this.
Re: XWT set Datetime/Combo [message #1720167 is a reply to message #1403619] Thu, 14 January 2016 20:41 Go to previous message
Amine Ouraiba is currently offline Amine OuraibaFriend
Messages: 1
Registered: December 2014
Junior Member
Hi @ all,
The bug of DateTime DataBinding is fixed in XWT:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=485878

So, you can use a DateTime widget and bind it with a "birthday" model property as the following :

<DateTime x:name="birthday" x:style="BORDER">
<DateTime.selection>
<Binding path="birthday" updateSourceTrigger="PropertyChanged">
</Binding>
</DateTime.selection>
</DateTime>


Greetings ,
Previous Topic:XWT cannot be installed with 3.8.2
Next Topic:In XWT can we change the tab order?
Goto Forum:
  


Current Time: Wed Apr 24 22:48:48 GMT 2024

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

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

Back to the top