Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » How to change Time in DateCellEditor Cell
How to change Time in DateCellEditor Cell [message #1730200] Fri, 22 April 2016 09:40 Go to next message
Rashmi Tr is currently offline Rashmi TrFriend
Messages: 22
Registered: November 2011
Junior Member
In my Date Cell I have format like dd.MM.yyyy HH:mm.

I added DateCellEditor to the cell. When I click on the Cell and without changing it with tab i go the next Cell then the Date was same but the Time was changed to the current Time. To Avoid this I extended DateCellEditor like below:

@Override
public void setEditorValue(java.lang.Object value) {

if (value instanceof Calendar) {
Calendar cal = (Calendar) value;
DateTime dateTime = getEditorControl();
dateTime.setDate(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DATE));
dateTime.setTime(cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), cal.get(Calendar.SECOND));
}
}

@Override
public Object getEditorValue() {
DateTime dateTime = getEditorControl();
Calendar cal = Calendar.getInstance();
cal.set(dateTime.getYear(), dateTime.getMonth(), dateTime.getDay(), dateTime.getHours(), dateTime.getMinutes(),
dateTime.getSeconds());
return cal;
}
Then the time is not changing to the current time it is taking the previous one. Now I am having another Problem. If I change the Date through DateCellEditior the Time is taking the previous one only instead of taking the current Time.

What should I do? where I am doing wrong?
Re: How to change Time in DateCellEditor Cell [message #1730211 is a reply to message #1730200] Fri, 22 April 2016 11:26 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2903
Registered: July 2012
Senior Member
Not sure what you are trying to tell me. The DateCellEditor was created to edit a date, not a time. If you need a different behavior you need to override createEditorControl() so the DateTime is created the way you expect it to behave. And sorry, I don't have the time currently to debug into your customization. SWT DateTime has multiple issues and maybe you should think about creating a custom editor using CDateTime from Nebula.
Re: How to change Time in DateCellEditor Cell [message #1731293 is a reply to message #1730211] Wed, 04 May 2016 07:36 Go to previous messageGo to next message
Rashmi Tr is currently offline Rashmi TrFriend
Messages: 22
Registered: November 2011
Junior Member
Hi Dirk,
I wanted to be able to edit date and time both.So i extended AbstractCellEditor and in createEditorControl() i added my Control to edit Date and Time both. I added KeyListner for Enter key as well and before doing commit i checked if date value of editor is not more than 10 days from today.

This i need to check also when mouse is clicked somewhere else to close the editor . How can I do this? Do I need to add mouse listner to my control? Closing Editor through mouse click is by default?

Many Thanks in Advance,
Rashmi
Re: How to change Time in DateCellEditor Cell [message #1731297 is a reply to message #1731293] Wed, 04 May 2016 07:55 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2903
Registered: July 2012
Senior Member
Typically this is done via focuslistener. Check the existing editor implementations to get an idea.
Re: How to change Time in DateCellEditor Cell [message #1731687 is a reply to message #1731297] Mon, 09 May 2016 09:50 Go to previous message
Rashmi Tr is currently offline Rashmi TrFriend
Messages: 22
Registered: November 2011
Junior Member
Many Thanks for your Reply Dirk
Previous Topic:how to get the row position of an item?
Next Topic:NatTable Tree Grid Filtering
Goto Forum:
  


Current Time: Thu Sep 19 21:55:23 GMT 2024

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

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

Back to the top