[PATCH] DateTimeCellEditor [message #10330] |
Thu, 31 August 2006 13: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 #10363 is a reply to message #10330] |
Thu, 31 August 2006 13:43 |
Eclipse User |
|
|
|
Originally posted by: orestis.orestis.gr
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
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04207 seconds