Ejemplo n.º 1
0
  public void init() {

    // cal.addTimeZone("Mexico", "GMT-6");
    // this.cal.addTimeZone("Germany", "GMT+1");
    // this.cal.setTimeZone("Germany=GMT+1");
    cal.setMold("default");
    cal.setFirstDayOfWeek("monday");
    cal.setDays(7);
    cal.setCurrentDate(new Date());

    btn_Show1Day.setStyle(btnOriginColor);
    btn_Show5Days.setStyle(btnOriginColor);
    btn_ShowWeek.setStyle(btnPressedColor);
    btn_ShowWeek.focus();
    btn_Show2Weeks.setStyle(btnOriginColor);
    btn_ShowMonth.setStyle(btnOriginColor);
  }
Ejemplo n.º 2
0
  public void synchronizeModel() throws ParseException {

    SimpleCalendarModel cm = null;
    MySimpleCalendarEvent sce = null;
    Date beginDate = cal.getBeginDate();
    Date endDate = cal.getEndDate();

    // first, delete old stuff
    cm = (SimpleCalendarModel) cal.getModel();

    if (cm != null) {
      cm.clear();
    }

    final SecUser user =
        ((UserImpl) SecurityContextHolder.getContext().getAuthentication().getPrincipal())
            .getSecUser();
    // List<MyCalendarEvent> list =
    // getCalendarEventService().getAllCalendarEvents(user.getId());
    List<MyCalendarEvent> list =
        getCalendarEventService().getCalendarEventsFromToDate(beginDate, endDate, user.getId());

    cm = new SimpleCalendarModel();

    for (MyCalendarEvent myCalendarEvent : list) {
      sce = new MySimpleCalendarEvent();
      sce.setId(myCalendarEvent.getId());
      sce.setUser(myCalendarEvent.getSecUser());
      sce.setVersion(myCalendarEvent.getVersion());
      sce.setBeginDate(myCalendarEvent.getBeginDate());
      sce.setContent(myCalendarEvent.getContent());
      sce.setContentColor(myCalendarEvent.getContentColor());
      sce.setEndDate(myCalendarEvent.getEndDate());
      sce.setHeaderColor(myCalendarEvent.getHeaderColor());
      sce.setLocked(myCalendarEvent.isLocked());
      sce.setTitle(myCalendarEvent.getTitle());

      cm.add(sce);
    }
    setCalModel(cm);

    cal.setModel(cm);
    cal.invalidate();
  }
Ejemplo n.º 3
0
  @Override
  public void doAfterCompose(Component window) throws Exception {
    super.doAfterCompose(window);

    setCal(cal);
    //		cal.setHflex("true");
    cal.setWidth("100%");
    cal.setWeekOfYear(true);
    // cal.setEventRender(render)
    cal.setDateFormatter(new CalendarDateFormatter());

    /**
     * 1. Set an 'alias' for this composer name to access it in the zul-file.<br>
     * 2. Set the parameter 'recurse' to 'false' to avoid problems with managing more than one
     * zul-file in one page. Otherwise it would be overridden and can ends in curious error
     * messages.
     */
    this.self.setAttribute("controller", this, false);

    init();
  }
Ejemplo n.º 4
0
  /**
   * If the onEventUpdate event is called. <br>
   * Handles the resizing or movement of an calendarEvent. Saves the new data to db.
   *
   * @param event
   */
  public void onEventUpdate$cal(CalendarsEvent evt) {

    // SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/MM/d");
    // sdf1.setTimeZone(cal.getDefaultTimeZone());

    int left = evt.getX();
    int top = evt.getY();
    if (top + 100 > evt.getDesktopHeight()) top = evt.getDesktopHeight() - 100;
    if (left + 330 > evt.getDesktopWidth()) left = evt.getDesktopWidth() - 330;

    SimpleCalendarModel m = (SimpleCalendarModel) cal.getModel();
    MySimpleCalendarEvent sce = (MySimpleCalendarEvent) evt.getCalendarEvent();
    sce.setBeginDate(evt.getBeginDate());
    sce.setEndDate(evt.getEndDate());
    // update the model
    // m.update(sce); <-- if activated, later an error occurs

    // prepare the backend Bean
    MyCalendarEvent calEvt = getCalendarEventService().getNewCalendarEvent();
    calEvt.setId(sce.getId());
    calEvt.setSecUser(sce.getUser());
    calEvt.setVersion(sce.getVersion());
    calEvt.setTitle(sce.getTitle());
    calEvt.setContent(sce.getContent());
    calEvt.setBeginDate(sce.getBeginDate());
    calEvt.setEndDate(sce.getEndDate());
    calEvt.setHeaderColor(sce.getHeaderColor());
    calEvt.setContentColor(sce.getContentColor());
    // Save the calendar event to database
    try {
      getCalendarEventService().saveOrUpdate(calEvt);
    } catch (Exception e) {
      e.printStackTrace();
    }

    try {
      synchronizeModel();
    } catch (ParseException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }