001package org.gwtbootstrap3.extras.fullcalendar.client.ui; 002 003/* 004 * #%L 005 * GwtBootstrap3 006 * %% 007 * Copyright (C) 2013 - 2014 GwtBootstrap3 008 * %% 009 * Licensed under the Apache License, Version 2.0 (the "License"); 010 * you may not use this file except in compliance with the License. 011 * You may obtain a copy of the License at 012 * 013 * http://www.apache.org/licenses/LICENSE-2.0 014 * 015 * Unless required by applicable law or agreed to in writing, software 016 * distributed under the License is distributed on an "AS IS" BASIS, 017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 018 * See the License for the specific language governing permissions and 019 * limitations under the License. 020 * #L% 021 */ 022 023import com.google.gwt.core.client.JavaScriptObject; 024 025import java.util.Map; 026 027/** 028 * @author Jeff Isenhart 029 */ 030public class TitleFormat extends AbstractViewOptionFormat implements IsJavaScriptObject { 031 private JavaScriptObject format; 032 033 public TitleFormat() { 034 this(null); 035 } 036 037 public TitleFormat(Map<ViewOptionHash, String> options) { 038 newInstance(); 039 if (options == null) { 040 options = getDefaultOptions(); 041 } 042 for (final ViewOptionHash option : options.keySet()) { 043 setFormat(option.name(), options.get(option)); 044 } 045 } 046 047 @Override 048 /** 049 * @see http://arshaw.com/fullcalendar/docs/text/titleFormat/ 050 */ 051 protected void populateDefaultOptions(final Map<ViewOptionHash, String> options) { 052 options.put(ViewOptionHash.month, "MMMM yyyy"); 053 options.put(ViewOptionHash.week, "MMM d[ yyyy]{ '—'[ MMM] d yyyy}"); 054 options.put(ViewOptionHash.day, "dddd, MMM d, yyyy"); 055 } 056 057 private native void newInstance() /*-{ 058 var theInstance = this; 059 theInstance.@org.gwtbootstrap3.extras.fullcalendar.client.ui.TitleFormat::format = {}; 060 theInstance.@org.gwtbootstrap3.extras.fullcalendar.client.ui.TitleFormat::format.titleFormat = {}; 061 }-*/; 062 063 private native void setFormat(String format, String viewOption) /*-{ 064 var theInstance = this; 065 theInstance.@org.gwtbootstrap3.extras.fullcalendar.client.ui.TitleFormat::format.titleFormat[viewOption] = format; 066 }-*/; 067 068 @Override 069 public JavaScriptObject toJavaScript() { 070 return format; 071 } 072}