DateChooser component databinding [message #548086] |
Tue, 20 July 2010 11:35  |
Eclipse User |
|
|
|
Hi folks,
we would like to use a component which is able to bind to a java.util.Date property, has somebody a solutionion for this issue?
We tried to use the nebula's DateChooserCombo for this purpose, without success. Tell the truth, the first part of the binding works fine. So the value goes from the model object to the control, unfortunately we don't get the modified value from the control.. I guess we should use something similar solution what used at comboviewer.singleSelection...
Any Idea? Fast answer is appreciated.
Istvan
|
|
|
|
Re: DateChooser component databinding [message #548424 is a reply to message #548256] |
Wed, 21 July 2010 14:30  |
Eclipse User |
|
|
|
I know, the Nebula one works, but keep in mind, Eclipse has at least a
second set of Date/Time classes superior to java.util.Date & Co.
ICU4J with full Unicode Support and many additional calendars.
Same is created for the JDK by Joda founder Stephen Colebourne with JSR-310.
It may come a bit later to Java than E4-embraced JSR-330, but then that only
has 3 or 4 annotations, while Date/Time is MUCH more complex ;-)
Still worth to look at both those Date APIs if you're serious about working
with date and time.
Werner
|
|
|
Re: DateChooser component databinding [message #578988 is a reply to message #548086] |
Wed, 21 July 2010 05:20  |
Eclipse User |
|
|
|
One of my colleague made a workaround to solve this issue.
He created a wrapper class which is inherited from Viewer and contains a CalendarCombo (nebula widget).
<MyWidget:BindableCalendarCombo
x:Style="BORDER | COMPACT | DROP_DOWN | DATE_SHORT" name="dod"
input="{Binding Path= dod}">
<MyWidget:BindableCalendarCombo.singleSelection>
<Binding path="dod"></Binding>
</MyWidget:BindableCalendarCombo.singleSelection>
</MyWidget:BindableCalendarCombo>
public class BindableCalendarCombo extends Viewer implements ICalendarListener{
private CalendarCombo calendarCombo;
public BindableCalendarCombo(Composite parent) {
this(parent,BORDER | DROP_DOWN );
}
public BindableCalendarCombo(Composite parent, int style) {
this.calendarCombo=new CalendarCombo(parent, style);
this.calendarCombo.addCalendarListener(this);
this.calendarCombo.setDate(new Date());
}
@Override
public Control getControl() {
return this.calendarCombo.getCombo();
}
@Override
public Object getInput() {
return calendarCombo.getDate().getTime();
}
@Override
public ISelection getSelection() {
if(this.calendarCombo!=null){
Date date=calendarCombo.getDate().getTime();
if(date!=null){
StructuredSelection selection=new StructuredSelection(date);
if(selection!=null)
return selection;
}
}
return StructuredSelection.EMPTY;
}
@Override
public void refresh() {
}
@Override
public void setInput(Object input) {
this.calendarCombo.setDate((Date) input);
}
@Override
public void setSelection(ISelection selection, boolean reveal) {
if(selection instanceof Date && selection!=null){
this.updateSelection(selection);
}
}
protected void updateSelection(ISelection selection) {
SelectionChangedEvent event = new SelectionChangedEvent(this, selection);
this.fireSelectionChanged(event);
}
@Override
public void dateChanged(Calendar date) {
if(date!=null)
this.updateSelection(new StructuredSelection(date.getTime()));
}
@Override
public void dateRangeChanged(Calendar start, Calendar end) {
// TODO Auto-generated method stub
}
@Override
public void popupClosed() {
}
public void setDate(Date date){
if(date !=null )
this.calendarCombo.setDate(date);
}
}
If you have any other solution for this issue, just let me know.
Thx in advance.
Istvan
|
|
|
Re: DateChooser component databinding [message #579047 is a reply to message #548256] |
Wed, 21 July 2010 14:30  |
Eclipse User |
|
|
|
I know, the Nebula one works, but keep in mind, Eclipse has at least a
second set of Date/Time classes superior to java.util.Date & Co.
ICU4J with full Unicode Support and many additional calendars.
Same is created for the JDK by Joda founder Stephen Colebourne with JSR-310.
It may come a bit later to Java than E4-embraced JSR-330, but then that only
has 3 or 4 annotations, while Date/Time is MUCH more complex ;-)
Still worth to look at both those Date APIs if you're serious about working
with date and time.
Werner
|
|
|
Powered by
FUDForum. Page generated in 0.46451 seconds