[PATCH] DateTimeCellEditor [message #564523] |
Thu, 31 August 2006 13:38 |
Orestis Markou Messages: 11 Registered: July 2009 |
Junior Member |
|
|
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;
}
}
------------------------------------------------------------ ---
|
|
|
Powered by
FUDForum. Page generated in 0.03174 seconds