@Override protected Block createBlock(RaplaBlockContext blockContext, Date start, Date end) { HTMLRaplaBlock block = createBlock(); block.setIndex(index++); block.setStart(start); block.setEnd(end); block.contextualize(blockContext); int row = (int) (DateTools.getHourOfDay(start.getTime()) * m_rowsPerHour + Math.round((DateTools.getMinuteOfHour(start.getTime()) * m_rowsPerHour) / 60.0)); block.setRow(row); block.setDay(DateTools.getWeekday(start)); int endRow = (int) (DateTools.getHourOfDay(end.getTime()) * m_rowsPerHour + Math.round((DateTools.getMinuteOfHour(end.getTime()) * m_rowsPerHour) / 60.0)); int rowCount = endRow - row; block.setRowCount(rowCount); // System.out.println("Start " + start + " End " + end); // System.out.println("Block " + block.getReservation().getName(null) // + " Row: " + row + " Endrow: " + endRow + " Rowcount " + rowCount ); return block; }
public void dateChanged(DateChangeEvent evt) { if (!listenersEnabled) return; if (evt.getSource() == startDateSelection) { Date newStartDate = startDateSelection.getDate(); if (newStartDate.after(endDateSelection.getDate())) { Date endDate = DateTools.addDays(newStartDate, 1); endDateSelection.setDate(endDate); } } if (evt.getSource() == endDateSelection) { Date newEndDate = endDateSelection.getDate(); if (newEndDate.before(startDateSelection.getDate())) { Date startDate = DateTools.addDays(newEndDate, -1); startDateSelection.setDate(startDate); } } updateDates(startDateSelection.getDate(), DateTools.addDay(endDateSelection.getDate())); fireDateChange(evt.getDate()); }
public String getHtmlValue(AppointmentBlock block) { RaplaLocale raplaLocale = getRaplaLocale(); final Date date = new Date(block.getEnd()); if (block.getAppointment().isWholeDaysSet()) { String dateString = raplaLocale.formatDateLong(DateTools.addDays(date, -1)); return dateString; } else { String dateString = raplaLocale.formatDateLong(date) + " " + raplaLocale.formatTime(date); return dateString; } }
public ReservationWeekview() { builder = new SwingRaplaBuilder(getContext()); content.setLayout(new BorderLayout()); content.add(wv.getComponent(), BorderLayout.CENTER); CalendarOptions opt = getCalendarOptions(); wv.setTimeZone(DateTools.getTimeZone()); wv.setExcludeDays(opt.getExcludeDays()); wv.setWorktimeMinutes(opt.getWorktimeStartMinutes(), opt.getWorktimeEndMinutes()); wv.addBuilder(builder); // wv.setDateVisible(false); wv.addCalendarViewListener(this); }
public void testRefresh() throws Exception { changeInSecondFacade("bowling"); facade.refresh(); Reservation resAfter = findReservation(facade, "bowling"); Appointment appointment = resAfter.getAppointments()[0]; Calendar cal = Calendar.getInstance(DateTools.getTimeZone()); cal.setTime(appointment.getStart()); assertEquals(17, cal.get(Calendar.HOUR_OF_DAY)); assertEquals(Calendar.MONDAY, cal.get(Calendar.DAY_OF_WEEK)); cal.setTime(appointment.getEnd()); assertEquals(19, cal.get(Calendar.HOUR_OF_DAY)); assertEquals(Calendar.MONDAY, cal.get(Calendar.DAY_OF_WEEK)); }
public void update() { listenersEnabled = false; try { Date startDate = model.getStartDate(); startDateSelection.setDate(startDate); final PeriodModel periodModel = getPeriodModel(); periodChooser.setPeriodModel(periodModel); periodChooser.setDate(startDate); Date endDate = model.getEndDate(); periodPanel.setVisible(periodModel.getSize() > 0); endDateSelection.setDate(DateTools.subDay(endDate)); } finally { listenersEnabled = true; } }
public void testConflicts() throws Exception { Conflict[] conflicts = facade.getConflicts(); Reservation[] all = facade.getReservationsForAllocatable(null, null, null, null); facade.removeObjects(all); Reservation orig = facade.newReservation(); orig.getClassification().setValue("name", "new"); Date start = DateTools.fillDate(new Date()); Date end = getRaplaLocale().toDate(start, getRaplaLocale().toTime(12, 0, 0)); orig.addAppointment(facade.newAppointment(start, end)); orig.addAllocatable(facade.getAllocatables()[0]); Reservation clone = facade.clone(orig); facade.store(orig); facade.store(clone); Conflict[] conflictsAfter = facade.getConflicts(); assertEquals(1, conflictsAfter.length - conflicts.length); HashSet<Conflict> set = new HashSet<Conflict>(Arrays.asList(conflictsAfter)); assertTrue(set.containsAll(new HashSet<Conflict>(Arrays.asList(conflicts)))); }
@Override public Date calcPrevious(Date currentDate) { return DateTools.addMonths(currentDate, -1); }
@Override public Date calcNext(Date currentDate) { return DateTools.addMonths(currentDate, 1); }
/** * Fügt die Wiederholungen des übergebenen Appointment-Objekts dem übergebenen * Event-Objekt hinzu. * * @param appointment Ein Rapla Appointment. */ private void addRepeatings(Appointment appointment, PropertyList properties) { Repeating repeating = appointment.getRepeating(); if (repeating == null) { return; } // This returns the strings DAYLY, WEEKLY, MONTHLY, YEARLY String type = repeating.getType().toString().toUpperCase(); Recur recur; // here is evaluated, if a COUNT is set in Rapla, or an enddate is // specified if (repeating.getNumber() == -1) { recur = new Recur(type, -1); } else if (repeating.isFixedNumber()) { recur = new Recur(type, repeating.getNumber()); } else { net.fortuna.ical4j.model.Date endDate = new net.fortuna.ical4j.model.Date(repeating.getEnd()); // TODO do we need to translate the enddate in utc? recur = new Recur(type, endDate); } if (repeating.isDaily()) { // DAYLY -> settings : intervall recur.setInterval(repeating.getInterval()); } else if (repeating.isWeekly()) { // WEEKLY -> settings : every nTh Weekday recur.setInterval(repeating.getInterval()); calendar.setTime(appointment.getStart()); recur.getDayList().add(WeekDay.getWeekDay(calendar)); } else if (repeating.isMonthly()) { // MONTHLY -> settings : every nTh Weekday recur.setInterval(repeating.getInterval()); calendar.setTime(appointment.getStart()); int weekofmonth = Math.round(calendar.get(java.util.Calendar.DAY_OF_MONTH) / DateTools.DAYS_PER_WEEK) + 1; recur.getDayList().add(new WeekDay(WeekDay.getWeekDay(calendar), weekofmonth)); } else if (repeating.isYearly()) { // YEARLY -> settings : every nTh day mTh Monthname calendar.setTime(appointment.getStart()); calendar.get(java.util.Calendar.DAY_OF_YEAR); } else { getLogger().warn("Invalid data in recurrency rule!"); } properties.add(new RRule(recur)); // bugfix - if rapla has no exceptions, an empty EXDATE: element is // produced. This may bother some iCal tools if (repeating.getExceptions().length == 0) { return; } // Add exception dates // DateList dl = new DateList(Value.DATE); ExDate exDate = new ExDate(); TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry(); net.fortuna.ical4j.model.TimeZone tz = registry.getTimeZone(timeZone.getID()); // rku: use seperate EXDATE for each exception for (Iterator<Date> itExceptions = Arrays.asList(repeating.getExceptions()).iterator(); itExceptions.hasNext(); ) { // DateList dl = new DateList(Value.DATE); Date date = itExceptions.next(); // dl.add(new net.fortuna.ical4j.model.Date( date)); java.util.Calendar cal = raplaLocale.createCalendar(); cal.setTime(date); int year = cal.get(java.util.Calendar.YEAR); int day_of_year = cal.get(java.util.Calendar.DAY_OF_YEAR); cal.setTime(appointment.getStart()); cal.set(java.util.Calendar.YEAR, year); cal.set(java.util.Calendar.DAY_OF_YEAR, day_of_year); int offset = (int) (tz.getOffset(DateTools.cutDate(date).getTime()) / DateTools.MILLISECONDS_PER_HOUR); cal.add(java.util.Calendar.HOUR, -offset); Date dateToSave = cal.getTime(); net.fortuna.ical4j.model.DateTime dateTime = new net.fortuna.ical4j.model.DateTime(); dateTime.setTime(dateToSave.getTime()); exDate.getDates().add(dateTime); } exDate.setTimeZone(tz); properties.add(exDate); // properties.add(new ExDate(dl)); }
@Inject public TimeZoneConverterImpl() { zone = DateTools.getTimeZone(); TimeZone systemTimezone = TimeZone.getDefault(); importExportTimeZone = systemTimezone; }