001package gwt.material.design.addins.client.subheader; 002 003/* 004 * #%L 005 * GwtMaterial 006 * %% 007 * Copyright (C) 2015 GwtMaterialDesign 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.dom.client.Document; 024import com.google.gwt.dom.client.Element; 025import gwt.material.design.addins.client.MaterialAddins; 026import gwt.material.design.client.MaterialDesignBase; 027import gwt.material.design.client.base.AbstractIconButton; 028 029//@formatter:off 030 031/** 032 * SubHeaders are special list tiles that delineate distinct sections of a list or grid list and are typically related 033 * to the current filtering or sorting criteria. Subheader tiles are either displayed inline with tiles or can be 034 * associated with content, for example, in an adjacent column. 035 * 036 * <h3>XML Namespace Declaration</h3> 037 * <pre> 038 * {@code 039 * xmlns:ma='urn:import:gwt.material.design.addins.client' 040 * } 041 * </pre> 042 * 043 * <h3>UiBinder Usage:</h3> 044 * <pre> 045 * {@code 046 * <ma:subheader.MaterialSubHeader text="Subheader" textColor="pink" /> 047 * } 048 * </pre> 049 * @see <a href="http://gwtmaterialdesign.github.io/gwt-material-demo/#subheaders">Material Subheader</a> 050 * @author kevzlou7979 051 */ 052//@formatter:on 053public class MaterialSubHeader extends AbstractIconButton{ 054 055 private static boolean resourcesLoaded = false; 056 static { 057 loadResources(); 058 } 059 060 static void loadResources() { 061 if(!resourcesLoaded) { 062 if (MaterialAddins.isDebug()) { 063 MaterialDesignBase.injectDebugJs(MaterialSubHeaderDebugClientBundle.INSTANCE.subheaderJsDebug()); 064 MaterialDesignBase.injectCss(MaterialSubHeaderDebugClientBundle.INSTANCE.subheaderCssDebug()); 065 } else { 066 MaterialDesignBase.injectJs(MaterialSubHeaderClientBundle.INSTANCE.subheaderJs()); 067 MaterialDesignBase.injectCss(MaterialSubHeaderClientBundle.INSTANCE.subheaderCss()); 068 } 069 resourcesLoaded = true; 070 } 071 } 072 073 public MaterialSubHeader() { 074 super("subheader"); 075 } 076 077 @Override 078 protected Element createElement() { 079 return Document.get().createDivElement(); 080 } 081}