Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Nebula » [PATCH] DateTimeCellEditor
[PATCH] DateTimeCellEditor [message #10330] Thu, 31 August 2006 13:38 Go to next message
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 Go to previous messageGo to next message
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
Re: [PATCH] DateTimeCellEditor [message #10462 is a reply to message #10363] Fri, 01 September 2006 15:19 Go to previous message
Jeremy Dowdall is currently offline Jeremy Dowdall
Messages: 181
Registered: July 2009
Senior Member
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 13:43 Go to previous message
Orestis Markou is currently offline Orestis Markou
Messages: 11
Registered: July 2009
Junior Member
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 15:19 Go to previous message
Jeremy Dowdall is currently offline Jeremy Dowdall
Messages: 181
Registered: July 2009
Senior Member
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
Previous Topic:embedding GEF/draw2 viewer/figures in table/tree cell
Next Topic:embedding GEF/draw2 viewer/figures in table/tree cell
Goto Forum:
  


Current Time: Wed Sep 24 04:45:56 GMT 2014

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

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