[PATCH] DateTimeCellEditor [message #10330] |
Thu, 31 August 2006 09:38  |
Eclipse User |
|
|
|
Originally posted by: orestis.orestis.gr
I needed to create a JFace CellEditor that uses the CDatePicker widget.
Here is the code in case someone else needs it. It is only tested on
Windows though I suppose it doesn't matter. It assumes that the values
passed are java.util.Date, under different input it will blow up with
ClassCastException. If this gets added to the CVS I'll clean it up a bit.
Jeremy please let me know if this a stupid way to do stuff.
-------------------------
import java.util.Date;
import org.aspencloud.widgets.ACW;
import org.aspencloud.widgets.cdatepicker.CDatepickerCombo;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Table;
public class DateTimeCellEditor extends CellEditor
{
Date value;
private CDatepickerCombo cdc;
private int acwstyle;
public DateTimeCellEditor(Table table2,int acwstyle)
{
super(table2);
this.acwstyle = acwstyle;
}
@Override
protected Control createControl(Composite parent)
{
Composite comp = new Composite(parent, SWT.NONE);
cdc = new CDatepickerCombo(comp, ACW.DROP_DOWN | acwstyle);
return cdc;
}
@Override
protected Object doGetValue()
{
return cdc.getCDatepicker().getSelection();
}
@Override
protected void doSetFocus()
{
cdc.setSelection(value);
cdc.popUp(true);
}
@Override
protected void doSetValue(Object theValue)
{
this.value = (Date) theValue;
}
}
------------------------------------------------------------ ---
|
|
|
|
Re: [PATCH] DateTimeCellEditor [message #10462 is a reply to message #10363] |
Fri, 01 September 2006 11:19  |
Eclipse User |
|
|
|
Orestis,
Thanks for sharing your code, though you're right that CDatepicker is
not a part of Nebula - perhaps it should be... time permitting, I'll try
to start some discussion on a Nebula "Calendar Widget Suite" on the
developer list.
In the mean-time, if you would like to submit your code (the whole file
- with copyright notice, licensed under EPL) via a Feature Request on
Sourceforge I'd like to include it with the distribution of
CDatepicker/Combo.
Orestis Markou wrote:
> Ooops. The CDatePicker widget isn't in nebula, is it ? Sorry if I
> confused someone. This is for an ordinary JFace TableViewer, not for
> CTableTree (maybe it can be used too - I don't know).
>
> Orestis
|
|
|
Re: [PATCH] DateTimeCellEditor [message #564570 is a reply to message #10330] |
Thu, 31 August 2006 09:43  |
Eclipse User |
|
|
|
Orestis Markou wrote:
> I needed to create a JFace CellEditor that uses the CDatePicker widget.
>
> Here is the code in case someone else needs it. It is only tested on
> Windows though I suppose it doesn't matter. It assumes that the values
> passed are java.util.Date, under different input it will blow up with
> ClassCastException. If this gets added to the CVS I'll clean it up a bit.
>
> Jeremy please let me know if this a stupid way to do stuff.
>
>
>
>
> -------------------------
>
> import java.util.Date;
>
> import org.aspencloud.widgets.ACW;
> import org.aspencloud.widgets.cdatepicker.CDatepickerCombo;
> import org.eclipse.jface.viewers.CellEditor;
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.widgets.Composite;
> import org.eclipse.swt.widgets.Control;
> import org.eclipse.swt.widgets.Table;
>
> public class DateTimeCellEditor extends CellEditor
> {
>
>
> Date value;
> private CDatepickerCombo cdc;
> private int acwstyle;
> public DateTimeCellEditor(Table table2,int acwstyle)
> {
> super(table2);
> this.acwstyle = acwstyle;
> }
>
> @Override
> protected Control createControl(Composite parent)
> {
> Composite comp = new Composite(parent, SWT.NONE);
> cdc = new CDatepickerCombo(comp, ACW.DROP_DOWN | acwstyle);
> return cdc;
> }
>
> @Override
> protected Object doGetValue()
> {
> return cdc.getCDatepicker().getSelection();
> }
>
> @Override
> protected void doSetFocus()
> {
> cdc.setSelection(value);
> cdc.popUp(true);
>
>
> }
>
> @Override
> protected void doSetValue(Object theValue)
> {
> this.value = (Date) theValue;
>
> }
> }
>
> ------------------------------------------------------------ ---
Ooops. The CDatePicker widget isn't in nebula, is it ? Sorry if I
confused someone. This is for an ordinary JFace TableViewer, not for
CTableTree (maybe it can be used too - I don't know).
Orestis
|
|
|
Re: [PATCH] DateTimeCellEditor [message #564642 is a reply to message #10363] |
Fri, 01 September 2006 11:19  |
Eclipse User |
|
|
|
Orestis,
Thanks for sharing your code, though you're right that CDatepicker is
not a part of Nebula - perhaps it should be... time permitting, I'll try
to start some discussion on a Nebula "Calendar Widget Suite" on the
developer list.
In the mean-time, if you would like to submit your code (the whole file
- with copyright notice, licensed under EPL) via a Feature Request on
Sourceforge I'd like to include it with the distribution of
CDatepicker/Combo.
Orestis Markou wrote:
> Ooops. The CDatePicker widget isn't in nebula, is it ? Sorry if I
> confused someone. This is for an ordinary JFace TableViewer, not for
> CTableTree (maybe it can be used too - I don't know).
>
> Orestis
|
|
|
Powered by
FUDForum. Page generated in 0.03064 seconds