Package org.projectforge.web.timesheet

Examples of org.projectforge.web.timesheet.TimesheetEditPage


        @Override
        public void onClick()
        {
          final PageParameters params = new PageParameters();
          params.add(TimesheetEditPage.PARAMETER_KEY_TASK_ID, id);
          final TimesheetEditPage timesheetEditPage = new TimesheetEditPage(params);
          timesheetEditPage.setReturnToPage(TaskEditPage.this);
          setResponsePage(timesheetEditPage);
        };
      }, getString("task.menu.addTimesheet"));
      addContentMenuEntry(menu);
View Full Code Here


            .setStopTime(DateHelper.getDateTimeAsMillis(range.getEnd()));
          }
          if (filter.getTimesheetUserId() != null) {
            timesheetDao.setUser(timesheet, filter.getTimesheetUserId());
          }
          final TimesheetEditPage timesheetEditPage = new TimesheetEditPage(timesheet);
          timesheetEditPage.setReturnToPage((WebPage) getPage());
          setResponsePage(timesheetEditPage);
        } else {
          onDateRangeSelectedHook(filter.getSelectedCalendar(), range, response);
        }
      }

      /**
       * Event was moved, a new start time was chosen.
       * @see net.ftlines.wicket.fullcalendar.FullCalendar#onEventDropped(net.ftlines.wicket.fullcalendar.callback.DroppedEvent,
       *      net.ftlines.wicket.fullcalendar.CalendarResponse)
       */
      @Override
      protected boolean onEventDropped(final DroppedEvent event, final CalendarResponse response)
      {
        // default mode is move and edit
        CalendarDropMode dropMode = CalendarDropMode.MOVE_EDIT;
        final StringValue parameterValue = RequestCycle.get().getRequest().getQueryParameters().getParameterValue("which");
        if (parameterValue != null) {
          try {
            dropMode = CalendarDropMode.fromAjaxTarget(parameterValue.toString());
          } catch (final Exception ex) {
            log.warn("Unable to get calendar drop mode for given value, using default mode. Given mode: " + parameterValue.toString());
          }
        }
        if (log.isDebugEnabled() == true) {
          log.debug("Event drop. eventId: "
              + event.getEvent().getId()
              + " eventClass"
              + event.getEvent().getClassName()
              + " sourceId: "
              + event.getSource().getUuid()
              + " dayDelta: "
              + event.getDaysDelta()
              + " minuteDelta: "
              + event.getMinutesDelta()
              + " allDay: "
              + event.isAllDay());
          log.debug("Original start time: " + event.getEvent().getStart() + ", original end time: " + event.getEvent().getEnd());
          log.debug("New start time: " + event.getNewStartTime() + ", new end time: " + event.getNewEndTime());
        }
        modifyEvent(event.getEvent(), event.getNewStartTime(), event.getNewEndTime(), dropMode, response);
        return false;
      }

      @Override
      protected boolean onEventResized(final ResizedEvent event, final CalendarResponse response)
      {
        if (log.isDebugEnabled() == true) {
          log.debug("Event resized. eventId: "
              + event.getEvent().getId()
              + " eventClass"
              + event.getEvent().getClassName()
              + " sourceId: "
              + event.getSource().getUuid()
              + " dayDelta: "
              + event.getDaysDelta()
              + " minuteDelta: "
              + event.getMinutesDelta());
        }
        modifyEvent(event.getEvent(), null, event.getNewEndTime(), CalendarDropMode.MOVE_EDIT, response);
        return false;
      }

      @Override
      protected void onEventClicked(final ClickedEvent clickedEvent, final CalendarResponse response)
      {
        final Event event = clickedEvent.getEvent();
        final String eventId = event != null ? event.getId() : null;
        final String eventClassName = event != null ? event.getClassName() : null;
        if (log.isDebugEnabled() == true) {
          log.debug("Event clicked. eventId: "
              + eventId
              + " eventClass"
              + event.getClassName()
              + ", sourceId: "
              + clickedEvent.getSource().getUuid());
        }
        if (eventId != null && eventClassName != null) {
          if (TimesheetEventsProvider.EVENT_CLASS_NAME.startsWith(eventClassName) == true) {
            // User clicked on a time sheet, show the time sheet:
            final Integer id = NumberHelper.parseInteger(eventId);
            final PageParameters parameters = new PageParameters();
            parameters.add(AbstractEditPage.PARAMETER_KEY_ID, id);
            final TimesheetEditPage timesheetEditPage = new TimesheetEditPage(parameters);
            timesheetEditPage.setReturnToPage((WebPage) getPage());
            setResponsePage(timesheetEditPage);
            return;
          } else if (TimesheetEventsProvider.BREAK_EVENT_CLASS_NAME.startsWith(eventClassName) == true) {
            // User clicked on a break (between time sheets), create new time sheet with times of the break:
            final TimesheetDO breaksTimesheet = timesheetEventsProvider.getBreakTimesheet(eventId);
            final TimesheetEditPage timesheetEditPage = new TimesheetEditPage(breaksTimesheet);
            timesheetEditPage.setReturnToPage((WebPage) getPage());
            setResponsePage(timesheetEditPage);
            return;
          } else if (BirthdayEventsProvider.EVENT_CLASS_NAME.startsWith(eventClassName) == true) {
            // User clicked on birthday, show the address:
            final Integer id = NumberHelper.parseInteger(eventId);
View Full Code Here

        }
        if (CalendarDropMode.MOVE_SAVE.equals(dropMode) == true) {
          timesheetDao.update(timesheet);
          setResponsePage(getPage());
        } else {
          setResponsePage(new TimesheetEditPage(timesheet).setReturnToPage((WebPage) getPage()));
        }
        return;
      }
      // Copy this time sheet:
      timesheet.setId(null);
      timesheet.setDeleted(false);
      timesheetDao.setUser(timesheet, loggedInUser.getId()); // Copy for own user.
      if (CalendarDropMode.COPY_SAVE.equals(dropMode) == true) {
        if (timesheetDao.hasInsertAccess(loggedInUser, timesheet, false) == false) {
          // User has no insert access, therefore ignore this request...
          return;
        }
        timesheetDao.save(timesheet);
        setResponsePage(getPage());
        return;
      } else if (CalendarDropMode.COPY_EDIT.equals(dropMode) == true) {
        setResponsePage(new TimesheetEditPage(timesheet).setReturnToPage((WebPage) getPage()));
      } else {
        // CANCEL -> should be handled through javascript now
        setResponsePage(getPage());
      }
    } else {
View Full Code Here

            buf.append("\n").append(note);
          }
          timesheet.setDescription(buf.toString());
          final TimesheetDao timesheetDao = Registry.instance().getDao(TimesheetDao.class);
          timesheetDao.setUser(timesheet, getUserId());
          final TimesheetEditPage timesheetEditPage = new TimesheetEditPage(timesheet);
          timesheetEditPage.setReturnToPage(getReturnToPage());
          setResponsePage(timesheetEditPage);
        };
      }, getString("plugins.teamcal.event.convert2Timesheet"));
      addContentMenuEntry(menu);
    }
    if (isNew() == true) {
      @SuppressWarnings("serial")
      final ContentMenuEntryPanel menu = new ContentMenuEntryPanel(getNewContentMenuChildId(), new SubmitLink(
          ContentMenuEntryPanel.LINK_ID, form) {
        @Override
        public void onSubmit()
        {
          final TeamEventDO event = getData();
          final TimesheetDO timesheet = new TimesheetDO();
          if (event != null) {
            timesheet.setStartDate(event.getStartDate());
            timesheet.setStopTime(event.getEndDate());
          }
          if (returnToPage == null) {
            returnToPage = new TeamCalCalendarPage(new PageParameters());
          }
          setResponsePage(new TimesheetEditPage(timesheet).setReturnToPage(returnToPage));
        };
      }.setDefaultFormProcessing(false), getString("plugins.teamcal.switchToTimesheetButton"));
      addContentMenuEntry(menu);
    }
  }
View Full Code Here

  protected void createTimesheet()
  {
    final PageParameters parameters = new PageParameters();
    parameters.add(TimesheetEditPage.PARAMETER_KEY_START_DATE_IN_MILLIS, getData().getDate().getTime());
    parameters.add(TimesheetEditPage.PARAMETER_KEY_DESCRIPTION, getData().getMessage());
    final TimesheetEditPage timesheetEditPage = new TimesheetEditPage(parameters);
    timesheetEditPage.setReturnToPage(this);
    setResponsePage(timesheetEditPage);
  }
View Full Code Here

TOP

Related Classes of org.projectforge.web.timesheet.TimesheetEditPage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.