Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Recurrence (Read 4783 times)
Ionut Murarasu
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 10
Joined: May 4th, 2017
Recurrence
Jul 3rd, 2017 at 1:53pm
Print Post  
Hello,

I need some help with a problem.
I want to add some recurrence appointments in my calendar.
After I added an appointment with recurrence in the calendar, in the appointment an icon with two circular arrows appears, that means my appointment was added as recurrence.
But after I made a change in the appointment, like name or change the capacity of the interval those two arrows are underline and my modifications are made only for the appointment from my current day not the entire recurrence period.

For example my appointment has recurrence for every Monday, but if I try to change the name, it's change only for the current day, not for every Monday.

I need some help with this problem, please.

This is the way how I added a recurrence when I created the appointment:

Recurrence recurrencae = new Recurrence();
recurrence.setPattern(RecurrencePattern.Daily);
recurrence.setOccurrence(Occurrence.First);
recurrence.setDays(7);
recurrence.setStartDate(date);
recurrence.setRecurrenceEnd(RecurrenceEnd.Never);
app.setRecurrence(recurrence);

  

recurrence.JPG ( 69 KB | 179 Downloads )
recurrence.JPG
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Recurrence
Reply #1 - Jul 3rd, 2017 at 2:13pm
Print Post  
Hi,

Modifying a recurring appointment modifies the instance only (not the master) and causes an exception to be automatically created. If you want to apply the modification to the master (and to all the occurrences), handle the itemModifed event:

Code
Select All
calendar.addCalendarListener(new CalendarAdapter() {
	@Override
	public void itemModified(ItemModifiedEvent e) {
		// TODO Auto-generated method stub
		super.itemModified(e);

		if (e.getItem().getRecurrenceState() == RecurrenceState.Exception)
		{
			Item master = e.getItem().getRecurrence().getMaster();
			master.setStartTime(e.getItem().getStartTime());
			master.setEndTime(e.getItem().getEndTime());
			e.getItem().getRecurrence().removeException(e.getItem());
		}
	}
} 


Regards,
Meppy
  
Back to top
 
IP Logged
 
Ionut Murarasu
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 10
Joined: May 4th, 2017
Re: Recurrence
Reply #2 - Jul 3rd, 2017 at 2:26pm
Print Post  
Thanks !

I will try.
  
Back to top
 
IP Logged
 
Ionut Murarasu
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 10
Joined: May 4th, 2017
Re: Recurrence
Reply #3 - Jul 4th, 2017 at 7:28am
Print Post  
Hello again,

First time I want to thank you for your help!
It works when I try to change the change the interval and remains recurring, but I can't move the appointment to another day.
I can't  drag the item from today to tomorrow.
Why is this happening ?
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Recurrence
Reply #4 - Jul 4th, 2017 at 11:11am
Print Post  
Hi,

If you want to adjust the start of the recurrence, you can do this through the Recurrence.setStartDate method. In your case you can detect if the user moved an item to another day and adjust the recurrence pattern appropriately:

Code
Select All
int fromDay = (int)((e.getOldStartTime().getTicks() - e.getOldStartTime().getTimeOfDay().getTicks()) / Duration.TicksPerDay);
int toDay = (int)((e.getItem().getStartTime().getTicks() - e.getItem().getStartTime().getTimeOfDay().getTicks()) / Duration.TicksPerDay);
if (fromDay != toDay)
	e.getItem().getRecurrence().setStartDate(e.getItem().getRecurrence().getStartDate().addDays(toDay - fromDay)); 


I hope this help.

Regards,
Meppy
  
Back to top
 
IP Logged
 
Ionut Murarasu
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 10
Joined: May 4th, 2017
Re: Recurrence
Reply #5 - Jul 4th, 2017 at 1:10pm
Print Post  
Thanks for your answer.

I have one more little problem. When I try to remove a recurring appointment, all items are removed without the first one from where series started.

See print screen in the attachment.

In the first image I tried to remove the second appointment but almost all was removed without the first one. Also in the first item the recurring icon was removed and become non recurring.

Can you help me please with a solution to remove the entire series ?

I added this code to remove the recurring

@Override
public void itemDeleted(ItemEvent e) {
     super.itemDeleted(e);
     
     if (e.getItem().getRecurrenceState() == RecurrenceState.Exception) {
           Item master = e.getItem().getRecurrence().getMaster();
           master.setRecurrence(null);
     }
}
  

rec1.JPG ( 40 KB | 176 Downloads )
rec1.JPG
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Recurrence
Reply #6 - Jul 5th, 2017 at 6:04am
Print Post  
Hi,

You need to also remove the master item from the schedule:

Code
Select All
calendar.getSchedule().getItems().remove(master); 


Regards,
Meppy
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint