List of usage examples for com.google.gwt.user.datepicker.client CalendarUtil addMonthsToDate
@SuppressWarnings("deprecation") public static void addMonthsToDate(Date date, int months)
From source file:cc.kune.events.client.viewer.CalendarViewerPresenter.java
License:GNU Affero Public License
/** * Increment date./*w w w . j ava 2 s .co m*/ * * @param positive * the positive */ private void incrementDate(final boolean positive) { final Date date = getDate(); switch (currentCalView) { case DAY: case AGENDA: CalendarUtil.addDaysToDate(date, currentDaysView * (positive ? 1 : -1)); break; case MONTH: CalendarUtil.addMonthsToDate(date, (positive ? 1 : -1)); break; } setDate(date); updateTitle(); }
From source file:cimav.client.data.domain.Empleado.java
public Empleado() { super();/* w ww. j a v a 2s .c o m*/ // this.status = EStatusEmpleado.SABATICO; this.tipoEmpleado = ETipoEmpleado.NORMAL; this.tipoContrato = ETipoContrato.DETERMINADO; Date today = new Date(); this.fechaIngreso = today; this.fechaInicioContrato = today; Date oneYear = new Date(); // un ao despus CalendarUtil.addMonthsToDate(oneYear, 12); this.fechaFinContrato = oneYear; this.tipoAntiguedad = ETipoAntiguedad.ADMINISTRATIVA; this.tipoSNI = ETipoSNI.NO_APLICA; // this.sede = ESede.CHIHUAHUA; this.porcenSegSeparacionInd = 0.00; }
From source file:cl.uai.client.MarkingInterface.java
License:Open Source License
/** /**//from w ww . j a v a 2 s .c o m * */ public MarkingInterface() { // The timer will check if no other resize events have been called in the last 200 ms resizeTimer = new Timer() { @Override public void run() { Date now = new Date(); long diff = now.getTime() - resizeTime.getTime(); // The last resize was in less than 200 ms if (diff < 200) { resizeTimer.schedule(200); } else { // More than 200 ms, we accept no more resize is being done resizeTimeout = false; Date oneyear = new Date(); CalendarUtil.addMonthsToDate(oneyear, 12); Cookies.setCookie("emarking_width", Integer.toString(Window.getClientWidth()), oneyear); EMarkingWeb.markingInterface.loadSubmissionData(); } } }; // Focus panel to catch key events focusPanel = new FocusPanel(); // Main panel has two rows: Toolbar and Marking panel mainPanel = new VerticalPanel(); mainPanel.addStyleName(Resources.INSTANCE.css().interfaceMainPanel()); focusPanel.setWidget(mainPanel); // Toolbar goes up toolbar = new MarkingToolBar(); mainPanel.add(toolbar); focusPanel.addKeyDownHandler(new MarkingInterfaceKeyDownHandler(toolbar)); // Marking panel containing the marking interface interfacePanel = new SplitLayoutPanel() { @Override public void onResize() { super.onResize(); markingPagesInterface.resizePage(this.getCenterWidth()); }; }; interfacePanel.animate(180); interfacePanel.addStyleName(Resources.INSTANCE.css().interfacepanel()); loadingMessage = new HTML(messages.Loading() + " " + EMarkingConfiguration.getMoodleUrl()); bubbleButtons = new ArrayList<BubbleButton>(); bubbleButtons.add(new ShowRubricButton(Window.getClientWidth() - 40, 0, 0)); bubbleButtons.add(new ShowChatButton(Window.getClientWidth() - 40, 45, NodeChat.SOURCE_CHAT)); bubbleButtons.add(new ShowWallButton(Window.getClientWidth() - 40, 90, NodeChat.SOURCE_WALL)); bubbleButtons.add(new ShowHelpButton(Window.getClientWidth() - 40, 135, NodeChat.SOURCE_SOS)); interfacePanel.add(loadingMessage); // interfacePanel.setCellHorizontalAlignment(loadingMessage, HasAlignment.ALIGN_CENTER); markingPanel = new AbsolutePanel(); markingPanel.add(interfacePanel); for (BubbleButton b : bubbleButtons) { markingPanel.add(b); } mainPanel.add(markingPanel); // Timer for pinging system timer = new Timer() { @Override public void run() { // If there are ticks to wait before trying again, update message and update ticks if (ticksUntilTrying > 0) { loadingMessage.setHTML(messages.CantReachServerRetrying(ticksUntilTrying)); ticksUntilTrying--; } else { // Updating next trial for one more second and trying onLoad again timerWaitingTurns++; ticksUntilTrying = Math.min(timerWaitingTurns, 60); loadingMessage.setHTML(messages.Loading() + " " + EMarkingConfiguration.getMoodleUrl()); onLoad(); } } }; heartBeatTimer = new Timer() { @Override public void run() { String extradata = ""; if (submissionData != null) extradata = "&marker=" + submissionData.getMarkerid() + "&draft=" + submissionData.getId(); final String requestUrl = extradata; AjaxRequest.ajaxRequest("action=heartbeat" + extradata, new AsyncCallback<AjaxData>() { @Override public void onSuccess(AjaxData result) { logger.info("Heartbeat! " + requestUrl); } @Override public void onFailure(Throwable caught) { logger.warning("Failure on heartbeat"); } }); } }; // Drag and Drop controller attached to marking panel dragController = new PickupDragController(markingPanel, false); waitDialog = new DialogBox(false, true); waitDialog.setGlassEnabled(true); waitDialog.addStyleName(Resources.INSTANCE.css().commentdialog()); waitDialog.setHTML(MarkingInterface.messages.Loading()); ProgressBar pbar = new ProgressBar(ProgressBarBase.Style.STRIPED); pbar.setActive(true); pbar.setPercent(100); waitDialog.setWidget(pbar); this.initWidget(focusPanel); }
From source file:cl.uai.client.MarkingInterface.java
License:Open Source License
public void setColoredRubric(boolean colored) { Date oneyear = new Date(); CalendarUtil.addMonthsToDate(oneyear, 12); Cookies.setCookie("emarking_showcolors", colored ? "1" : "0", oneyear); EMarkingConfiguration.setColoredRubric(colored); EMarkingWeb.markingInterface.loadInterface(); }
From source file:cl.uai.client.rubric.RubricInterface.java
License:Open Source License
@Override public void setVisible(boolean visible) { super.setVisible(visible); Date oneyear = new Date(); CalendarUtil.addMonthsToDate(oneyear, 12); Cookies.setCookie("emarking_showrubric", visible ? "1" : "0", oneyear); EMarkingConfiguration.setShowRubricOnLoad(visible); EMarkingWeb.markingInterface.getMarkingPagesInterface().loadInterface(); EMarkingWeb.markingInterface.setShowRubricButtonVisible(visible); }
From source file:com.google.gwt.sample.stockwatcher.server.CurrencyServiceImpl.java
private String calculateRatesUrl() { String pattern = "yyyy-MM-dd"; DefaultDateTimeFormatInfo info = new DefaultDateTimeFormatInfo(); DateTimeFormat dtf = new DateTimeFormat(pattern, info) { };//from ww w.jav a2s .co m Date d = new Date(); CalendarUtil.addMonthsToDate(d, -1); return "http://api.fixer.io/" + dtf.format(d) + "?base=HKD"; }
From source file:edu.cimav.rhglass.client.db.domain.Empleado.java
public Empleado() { this.setStatus(EStatusEmpleado.ACTIVO); this.setTipoEmpleado(ETipoEmpleado.NORMAL); this.setTipoContrato(ETipoContrato.DETERMINADO); Date today = new Date(); this.setFechaIngreso(today); this.setFechaInicioContrato(today); Date oneYear = new Date(); // un ao despus CalendarUtil.addMonthsToDate(oneYear, 12); this.setFechaFinContrato(oneYear); this.setTipoAntiguedad(ETipoAntiguedad.ADMINISTRATIVA); this.setTipoSNI(ETipoSNI.NO_APLICA); }
From source file:fr.putnami.pwt.core.widget.client.InputDatePicker.java
License:Open Source License
private void redrawCalendarPicker() { this.monthPicker.getStyle().setDisplay(Display.NONE); this.calendarTable.getStyle().clearDisplay(); this.calendatBody.removeAllChildren(); int firstDayOfWeek = InputDatePicker.DATE_TIME_FORMAT_INFO.firstDayOfTheWeek(); int lastDayOfWeek = (firstDayOfWeek + InputDatePicker.DAYS_IN_WEEK) % InputDatePicker.DAYS_IN_WEEK; /* Display month */ this.monthPickerButton.setInnerHTML( InputDatePicker.MONTH_YEAR_FORMAT.format(this.cursor) + "<span class=\"caret\"></span>"); Date lastMonth = new Date(this.cursor.getTime()); CalendarUtil.addMonthsToDate(lastMonth, -1); this.pagePreviusMonthLi.setAttribute(InputDatePicker.ATTRIBUTE_DATA_CURSOR, InputDatePicker.ATTRIBUTE_DATE_FORMAT.format(lastMonth)); this.pageTodayLi.setAttribute(InputDatePicker.ATTRIBUTE_DATA_CURSOR, InputDatePicker.ATTRIBUTE_DATE_FORMAT.format(this.today)); Date nextMonth = new Date(this.cursor.getTime()); CalendarUtil.addMonthsToDate(nextMonth, 1); this.pageNextMonthLi.setAttribute(InputDatePicker.ATTRIBUTE_DATA_CURSOR, InputDatePicker.ATTRIBUTE_DATE_FORMAT.format(nextMonth)); /* Draw daypicker */ Date dateToDrow = new Date(this.cursor.getTime()); int selectedMonth = dateToDrow.getMonth(); int firstMonthToDisplay = (selectedMonth + 11) % 12; int lastMonthToDisplay = (selectedMonth + 13) % 12; do {/* www .ja v a 2s. c o m*/ CalendarUtil.addDaysToDate(dateToDrow, -1); } while (firstMonthToDisplay != dateToDrow.getMonth() || dateToDrow.getDay() != firstDayOfWeek); // drow calendarTable TableRowElement headRow = null; while (dateToDrow.getMonth() != lastMonthToDisplay || dateToDrow.getDay() != lastDayOfWeek || dateToDrow.getDate() == 1 && dateToDrow.getDay() == firstDayOfWeek) { if (headRow == null || dateToDrow.getDay() == firstDayOfWeek) { headRow = Document.get().createTRElement(); this.calendatBody.appendChild(headRow); } TableCellElement td = Document.get().createTDElement(); headRow.appendChild(td); DivElement div = Document.get().createDivElement(); td.appendChild(div); div.setInnerText(String.valueOf(dateToDrow.getDate())); div.setAttribute(InputDatePicker.ATTRIBUTE_DATA_DATE, InputDatePicker.ATTRIBUTE_DATE_FORMAT.format(dateToDrow)); if (dateToDrow.getMonth() != selectedMonth) { StyleUtils.addStyle(td, InputDatePicker.STYLE_MUTED); } if (dateToDrow.equals(this.cursor)) { StyleUtils.addStyle(td, InputDatePicker.STYLE_SELECTED); } if (this.today.equals(dateToDrow)) { StyleUtils.addStyle(td, InputDatePicker.STYLE_TODAY); } Event.sinkEvents(div, Event.ONCLICK); CalendarUtil.addDaysToDate(dateToDrow, 1); } }
From source file:fr.putnami.pwt.core.widget.client.InputDatePicker.java
License:Open Source License
private boolean handleKeyPress(int keyCode) { if (KeyEventUtils.isModifierKeyDown(Event.getCurrentEvent())) { return false; }//ww w. j a v a2 s . co m boolean handleKey = false; switch (keyCode) { case KeyCodes.KEY_LEFT: CalendarUtil.addDaysToDate(this.cursor, -1); handleKey = true; break; case KeyCodes.KEY_RIGHT: CalendarUtil.addDaysToDate(this.cursor, 1); handleKey = true; break; case KeyCodes.KEY_UP: CalendarUtil.addDaysToDate(this.cursor, -7); handleKey = true; break; case KeyCodes.KEY_DOWN: CalendarUtil.addDaysToDate(this.cursor, 7); handleKey = true; break; case KeyCodes.KEY_PAGEUP: CalendarUtil.addMonthsToDate(this.cursor, -1); handleKey = true; break; case KeyCodes.KEY_PAGEDOWN: CalendarUtil.addMonthsToDate(this.cursor, 1); handleKey = true; break; case KeyCodes.KEY_ENTER: this.setValue(this.cursor, true); handleKey = true; break; case KeyCodes.KEY_ESCAPE: this.setValue(this.value); this.setFocus(false); handleKey = true; break; default: break; } if (handleKey) { this.redraw(); } return handleKey; }
From source file:org.jbpm.console.ng.gc.client.util.DateUtils.java
License:Apache License
/** * Returns a {@link DateRange} starting on first day of month in which the specified date is and ending on last day of that * month./*w w w. j a v a2s .co m*/ * * @param date date from which to get the month date range * @return {@link DateRange} representing the month in which the specified date is */ @SuppressWarnings("deprecation") public static DateRange getMonthDateRange(Date date) { Date startDate = new Date(date.getTime()); CalendarUtil.setToFirstDayOfMonth(startDate); // the above method will set hours to 12 startDate.setHours(0); Date endDate = new Date(date.getTime()); CalendarUtil.setToFirstDayOfMonth(endDate); CalendarUtil.addMonthsToDate(endDate, 1); CalendarUtil.addDaysToDate(endDate, -1); endDate.setHours(0); return new DateRange(startDate, endDate, CalendarUtil.getDaysBetween(startDate, endDate)); }