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 * @see http://arshaw.com/fullcalendar/docs/text/columnFormat/ 030 */ 031public class ColumnFormat extends AbstractViewOptionFormat implements IsJavaScriptObject { 032 private JavaScriptObject format; 033 034 public ColumnFormat() { 035 this(null); 036 } 037 038 public ColumnFormat(Map<ViewOptionHash, String> options) { 039 newInstance(); 040 if (options == null) { 041 options = getDefaultOptions(); 042 } 043 for (final ViewOptionHash option : options.keySet()) { 044 setFormat(option.name(), options.get(option)); 045 } 046 } 047 048 @Override 049 /** 050 * @see http://arshaw.com/fullcalendar/docs/text/columnFormat/ 051 */ 052 protected void populateDefaultOptions(final Map<ViewOptionHash, String> options) { 053 options.put(ViewOptionHash.month, "ddd"); 054 options.put(ViewOptionHash.week, "ddd M/d"); 055 options.put(ViewOptionHash.day, "dddd M/d"); 056 } 057 058 private native void newInstance() /*-{ 059 var theInstance = this; 060 theInstance.@org.gwtbootstrap3.extras.fullcalendar.client.ui.ColumnFormat::format = {}; 061 theInstance.@org.gwtbootstrap3.extras.fullcalendar.client.ui.ColumnFormat::format.columnFormat = {}; 062 }-*/; 063 064 private native void setFormat(String format, String viewOption) /*-{ 065 var theInstance = this; 066 theInstance.@org.gwtbootstrap3.extras.fullcalendar.client.ui.TimeFormat::format.columnFormat[viewOption] = format; 067 }-*/; 068 069 @Override 070 public JavaScriptObject toJavaScript() { 071 return format; 072 } 073}