Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Nebula » DateChooserComboObservableValue & databinding
DateChooserComboObservableValue & databinding [message #56508] Mon, 21 July 2008 20:59 Go to next message
Pascal Leclercq is currently offline Pascal LeclercqFriend
Messages: 7
Registered: July 2009
Junior Member
This is a multi-part message in MIME format.
--------------070800050507070305050303
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hi,

for my needs I wrote the "IObservableValue" for the DateChooserCombo widget.

It seems to work and I want to share it with the community.


Please send me your feedbacks

--------------070800050507070305050303
Content-Type: text/plain;
name="DateChooserComboObservableValue.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="DateChooserComboObservableValue.java"

package com.adeo.rcp.technique.observables;

import java.util.Date;

import org.eclipse.core.databinding.observable.Diffs;
import org.eclipse.core.databinding.observable.value.AbstractObserv ableValue;
import org.eclipse.core.databinding.observable.value.IObservableVal ue;
import org.eclipse.jface.databinding.swt.SWTObservables;
import org.eclipse.nebula.widgets.datechooser.DateChooserCombo;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;

/**
* @author Pascal Leclercq
*
*/
public class DateChooserComboObservableValue extends AbstractObservableValue implements IObservableValue {

/**
* The Control being observed here.
*/
protected final DateChooserCombo dateChooserCombo;

/**
* Flag to prevent infinite recursion in {@link #doSetValue(Object)}.
*/
protected boolean updating = false;

/**
* The "old" value before a selection event is fired.
*/

protected Date oldValue;

/**
* SWT event that on firing this observable will fire change events to its
* listeners.
*/
private final int updateEventType;

/**
* Valid types for the {@link #updateEventType}.
*/
private static final int[] validUpdateEventTypes = new int[] { SWT.Modify, SWT.FocusOut, SWT.None };

/**
* Observe the selection property of the provided DateChooserCombo control.
*
* @param dateChooserCombo
* the control to observe
*/
public DateChooserComboObservableValue(DateChooserCombo dateChooserCombo, int updateEventType) {
super(SWTObservables.getRealm(dateChooserCombo.getDisplay()) );

boolean eventValid = false;
for (int i = 0; !eventValid && i < validUpdateEventTypes.length; i++) {
eventValid = (updateEventType == validUpdateEventTypes[i]);
}
if (!eventValid) {
throw new IllegalArgumentException("UpdateEventType [" + updateEventType + "] is not supported."); //$NON-NLS-1$//$NON-NLS-2$
}
this.dateChooserCombo = dateChooserCombo;
oldValue = dateChooserCombo.getValue();
this.updateEventType = updateEventType;
if (updateEventType != SWT.None) {
dateChooserCombo.addListener(updateEventType, updateListener);
}

dateChooserCombo.addDisposeListener(disposeListener);

}

private DisposeListener disposeListener = new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
DateChooserComboObservableValue.this.dispose();
}
};

public void dispose() {
if (!dateChooserCombo.isDisposed()) {
if (updateEventType != SWT.None) {
dateChooserCombo.removeListener(updateEventType, updateListener);
}

}
super.dispose();
}


public Object getValueType() {
return Date.class;
}



protected Object doGetValue() {
return dateChooserCombo.getValue();
}

private Listener updateListener = new Listener() {
public void handleEvent(Event event) {
if (!updating) {
Date newValue = dateChooserCombo.getValue();

if (!newValue.equals(oldValue)) {
fireValueChange(Diffs.createValueDiff(oldValue, newValue));
oldValue = newValue;
}
}
}
};

protected void doSetValue(Object value) {

Date newValue;

try {
updating = true;
newValue = (Date) value;
dateChooserCombo.setValue(newValue);

if (!newValue.equals(oldValue)) {
fireValueChange(Diffs.createValueDiff(oldValue, newValue));
oldValue = newValue;
}
} finally {
updating = false;
}
}
}

--------------070800050507070305050303--
Re: DateChooserComboObservableValue & databinding [message #56916 is a reply to message #56508] Mon, 04 August 2008 09:58 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Please file a bug and attach the sources.

Tom

Pascal Leclercq schrieb:
> Hi,
>
> for my needs I wrote the "IObservableValue" for the DateChooserCombo
> widget.
>
> It seems to work and I want to share it with the community.
>
>
> Please send me your feedbacks
>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: DateChooserComboObservableValue & databinding [message #58751 is a reply to message #56916] Tue, 02 September 2008 21:23 Go to previous messageGo to next message
Pascal Leclercq is currently offline Pascal LeclercqFriend
Messages: 7
Registered: July 2009
Junior Member
Hi Tom,

it's done here :

https://bugs.eclipse.org/bugs/show_bug.cgi?id=246014.

Thanks for your great work !


Tom Schindl a écrit :
> Please file a bug and attach the sources.
>
> Tom
>
> Pascal Leclercq schrieb:
>> Hi,
>>
>> for my needs I wrote the "IObservableValue" for the DateChooserCombo
>> widget.
>>
>> It seems to work and I want to share it with the community.
>>
>>
>> Please send me your feedbacks
>>
>
>
Re: DateChooserComboObservableValue & databinding [message #58776 is a reply to message #56916] Tue, 02 September 2008 21:30 Go to previous messageGo to next message
Pascal Leclercq is currently offline Pascal LeclercqFriend
Messages: 7
Registered: July 2009
Junior Member
Hi Tom,

it's done here :

https://bugs.eclipse.org/bugs/show_bug.cgi?id=246014.

Thanks for your great work !


Tom Schindl a écrit :
> Please file a bug and attach the sources.
>
> Tom
>
> Pascal Leclercq schrieb:
>> Hi,
>>
>> for my needs I wrote the "IObservableValue" for the DateChooserCombo
>> widget.
>>
>> It seems to work and I want to share it with the community.
>>
>>
>> Please send me your feedbacks
>>
>
>
Re: DateChooserComboObservableValue & databinding [message #63030 is a reply to message #58776] Tue, 21 April 2009 09:02 Go to previous messageGo to next message
Jens Goldhammer is currently offline Jens GoldhammerFriend
Messages: 6
Registered: July 2009
Junior Member
This is a multi-part message in MIME format.
--------------060800090405050006040803
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Hello,

Pascal, thanks for your IObservableValue implementation.
IMO, the implementation does not recognize incomplete values in the
text-field.

If the user only inputs the "date" '11.11.' without a year, the
databinding will not become "active" (because the combo delivers a null
date) and we cannot validate the user input correctly.

My idea is that the implementation should return a string which can be
validated and converters will convert the string into a date and vice versa.

Is there any other solution?
Do you see any problems with that approach?

Thanks,
Jens

Am 02.09.2008 23:30, schrieb Pascal Leclercq:
> Hi Tom,
>
> it's done here :
>
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=246014.
>
> Thanks for your great work !
>
>
> Tom Schindl a
Re: DateChooserComboObservableValue & databinding [message #528071 is a reply to message #63030] Mon, 19 April 2010 08:25 Go to previous messageGo to next message
A. Scheucher is currently offline A. ScheucherFriend
Messages: 9
Registered: March 2010
Junior Member
I tried to implement the .getText() solution for validation. But the problem ist, the validate method is only called in after at least one digit for each field (day, month, year) is set. The nebula DateChooserCombo only allows to enter valid digits in the single fields. So the only sense would be the menitoned case, of half entered dates (e.g. '11.1.').

But as the validate method is not called in this case, there is nothing one can do about it.

Or do I miss something?

best regards,
Andreas
Re: DateChooserComboObservableValue & databinding [message #591424 is a reply to message #56508] Mon, 04 August 2008 09:58 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Please file a bug and attach the sources.

Tom

Pascal Leclercq schrieb:
> Hi,
>
> for my needs I wrote the "IObservableValue" for the DateChooserCombo
> widget.
>
> It seems to work and I want to share it with the community.
>
>
> Please send me your feedbacks
>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: DateChooserComboObservableValue & databinding [message #592093 is a reply to message #56916] Tue, 02 September 2008 21:23 Go to previous messageGo to next message
Pascal Leclercq is currently offline Pascal LeclercqFriend
Messages: 7
Registered: July 2009
Junior Member
Hi Tom,

it's done here :

https://bugs.eclipse.org/bugs/show_bug.cgi?id=246014

Thanks for your great work !


Tom Schindl a écrit :
> Please file a bug and attach the sources.
>
> Tom
>
> Pascal Leclercq schrieb:
>> Hi,
>>
>> for my needs I wrote the "IObservableValue" for the DateChooserCombo
>> widget.
>>
>> It seems to work and I want to share it with the community.
>>
>>
>> Please send me your feedbacks
>>
>
>
Re: DateChooserComboObservableValue & databinding [message #592099 is a reply to message #56916] Tue, 02 September 2008 21:30 Go to previous messageGo to next message
Pascal Leclercq is currently offline Pascal LeclercqFriend
Messages: 7
Registered: July 2009
Junior Member
Hi Tom,

it's done here :

https://bugs.eclipse.org/bugs/show_bug.cgi?id=246014

Thanks for your great work !


Tom Schindl a écrit :
> Please file a bug and attach the sources.
>
> Tom
>
> Pascal Leclercq schrieb:
>> Hi,
>>
>> for my needs I wrote the "IObservableValue" for the DateChooserCombo
>> widget.
>>
>> It seems to work and I want to share it with the community.
>>
>>
>> Please send me your feedbacks
>>
>
>
Re: DateChooserComboObservableValue & databinding [message #594500 is a reply to message #58776] Tue, 21 April 2009 09:02 Go to previous messageGo to next message
Jens Goldhammer is currently offline Jens GoldhammerFriend
Messages: 6
Registered: July 2009
Junior Member
This is a multi-part message in MIME format.
--------------060800090405050006040803
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Hello,

Pascal, thanks for your IObservableValue implementation.
IMO, the implementation does not recognize incomplete values in the
text-field.

If the user only inputs the "date" '11.11.' without a year, the
databinding will not become "active" (because the combo delivers a null
date) and we cannot validate the user input correctly.

My idea is that the implementation should return a string which can be
validated and converters will convert the string into a date and vice versa.

Is there any other solution?
Do you see any problems with that approach?

Thanks,
Jens

Am 02.09.2008 23:30, schrieb Pascal Leclercq:
> Hi Tom,
>
> it's done here :
>
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=246014
>
> Thanks for your great work !
>
>
> Tom Schindl a
Re: DateChooserComboObservableValue & databinding [message #599495 is a reply to message #63030] Mon, 19 April 2010 08:25 Go to previous message
A. Scheucher is currently offline A. ScheucherFriend
Messages: 9
Registered: March 2010
Junior Member
I tried to implement the .getText() solution for validation. But the problem ist, the validate method is only called in after at least one digit for each field (day, month, year) is set. The nebula DateChooserCombo only allows to enter valid digits in the single fields. So the only sense would be the menitoned case, of half entered dates (e.g. '11.1.').

But as the validate method is not called in this case, there is nothing one can do about it.

Or do I miss something?

best regards,
Andreas
Previous Topic:About Nebula XViewer
Next Topic:[CDateTime] DoubleClick to select day
Goto Forum:
  


Current Time: Fri Apr 26 00:51:13 GMT 2024

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

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

Back to the top