001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (https://www.alkacon.com) 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * For further information about Alkacon Software, please see the 018 * company website: https://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: https://www.opencms.org 022 * 023 * You should have received a copy of the GNU Lesser General Public 024 * License along with this library; if not, write to the Free Software 025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 026 */ 027 028package org.opencms.acacia.client.widgets.serialdate; 029 030import org.opencms.acacia.shared.I_CmsSerialDateValue.Month; 031import org.opencms.acacia.shared.I_CmsSerialDateValue.WeekDay; 032import org.opencms.acacia.shared.I_CmsSerialDateValue.WeekOfMonth; 033 034import com.google.gwt.user.client.Command; 035 036/** Controller for the yearly pattern panel. */ 037public class CmsPatternPanelYearlyController extends A_CmsPatternPanelController { 038 039 /** The controlled view. */ 040 private final CmsPatternPanelYearlyView m_view; 041 042 /** 043 * Constructor for the yearly pattern panel controller 044 * @param model the model to read data from. 045 * @param changeHandler the value change handler. 046 */ 047 CmsPatternPanelYearlyController(CmsSerialDateValue model, I_ChangeHandler changeHandler) { 048 049 super(model, changeHandler); 050 m_view = new CmsPatternPanelYearlyView(this, m_model); 051 } 052 053 /** 054 * @see org.opencms.acacia.client.widgets.serialdate.A_CmsPatternPanelController#getView() 055 */ 056 @Override 057 public I_CmsSerialDatePatternView getView() { 058 059 return m_view; 060 } 061 062 /** 063 * Set the month. 064 * @param monthStr the month to set. 065 */ 066 public void setMonth(String monthStr) { 067 068 final Month month = Month.valueOf(monthStr); 069 if ((m_model.getMonth() == null) || !m_model.getMonth().equals(monthStr)) { 070 removeExceptionsOnChange(new Command() { 071 072 public void execute() { 073 074 m_model.setMonth(month); 075 onValueChange(); 076 077 } 078 }); 079 } 080 } 081 082 /** 083 * Set the pattern scheme. 084 * @param isWeekDayBased flag, indicating if the week day based scheme should be set. 085 */ 086 public void setPatternScheme(final boolean isWeekDayBased) { 087 088 if (isWeekDayBased ^ (null != m_model.getWeekDay())) { 089 removeExceptionsOnChange(new Command() { 090 091 public void execute() { 092 093 if (isWeekDayBased) { 094 m_model.setWeekDay(getPatternDefaultValues().getWeekDay()); 095 m_model.setWeekOfMonth(getPatternDefaultValues().getWeekOfMonth()); 096 } else { 097 m_model.setWeekDay(null); 098 m_model.setWeekOfMonth(null); 099 } 100 m_model.setMonth(getPatternDefaultValues().getMonth()); 101 m_model.setDayOfMonth(getPatternDefaultValues().getDayOfMonth()); 102 m_model.setInterval(getPatternDefaultValues().getInterval()); 103 onValueChange(); 104 } 105 }); 106 } 107 } 108 109 /** 110 * Set the week day. 111 * @param weekDayStr the week day to set. 112 */ 113 public void setWeekDay(String weekDayStr) { 114 115 final WeekDay weekDay = WeekDay.valueOf(weekDayStr); 116 if ((m_model.getWeekDay() != null) || !m_model.getWeekDay().equals(weekDay)) { 117 removeExceptionsOnChange(new Command() { 118 119 public void execute() { 120 121 m_model.setWeekDay(weekDay); 122 onValueChange(); 123 } 124 }); 125 126 } 127 128 } 129 130 /** 131 * Set the week of month. 132 * @param weekOfMonthStr the week of month to set. 133 */ 134 public void setWeekOfMonth(String weekOfMonthStr) { 135 136 final WeekOfMonth weekOfMonth = WeekOfMonth.valueOf(weekOfMonthStr); 137 if ((null == m_model.getWeekOfMonth()) || !m_model.getWeekOfMonth().equals(weekOfMonth)) { 138 removeExceptionsOnChange(new Command() { 139 140 public void execute() { 141 142 m_model.setWeekOfMonth(weekOfMonth); 143 onValueChange(); 144 } 145 }); 146 } 147 148 } 149 150}