001package gwt.material.design.client.ui; 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 gwt.material.design.client.base.MaterialWidget; 024import gwt.material.design.client.base.HasIcon; 025import gwt.material.design.client.base.HasTitle; 026import gwt.material.design.client.constants.IconPosition; 027import gwt.material.design.client.constants.IconSize; 028import gwt.material.design.client.constants.IconType; 029import gwt.material.design.client.constants.TextAlign; 030import gwt.material.design.client.ui.html.Div; 031 032import com.google.gwt.dom.client.Document; 033import com.google.gwt.dom.client.Style.Unit; 034 035//@formatter:off 036/** 037* 038* <p>Material No result is a component that will have to display once content is empty. 039* <h3>UiBinder Usage:</h3> 040* 041* <pre> 042* {@code 043<m:MaterialNoResult iconType="POLYMER" title="No Inbox" description="You dont have new message" backgroundColor="blue"/> 044} 045</pre> 046* </p> 047* 048* @author kevzlou7979 049* @author Ben Dol 050* @see <a href="http://gwt-material-demo.herokuapp.com/#no-result">Material No Result</a> 051*/ 052//@formatter:on 053public class MaterialNoResult extends MaterialWidget implements HasIcon, HasTitle{ 054 055 056 private MaterialIcon icon = new MaterialIcon(); 057 private MaterialTitle title = new MaterialTitle(); 058 private Div div = new Div(); 059 060 public MaterialNoResult() { 061 super(Document.get().createDivElement(), "valign-wrapper"); 062 setTextAlign(TextAlign.CENTER); 063 setHeight("100%"); 064 add(div); 065 div.setWidth("100%"); 066 div.setStyleName("valign center"); 067 div.add(title); 068 icon.setIconSize(IconSize.LARGE); 069 title.insert(icon, 0); 070 } 071 072 public MaterialNoResult(String bgColor, String textColor, IconType iconType, String title, String description) { 073 this(); 074 setBackgroundColor(bgColor); 075 setTextColor(textColor); 076 setIconType(iconType); 077 setTitle(title); 078 setDescription(description); 079 } 080 081 @Override 082 public void setDescription(String description) { 083 title.setDescription(description); 084 } 085 086 @Override 087 public void setTitle(String titleText) { 088 title.setTitle(titleText); 089 } 090 091 @Override 092 public MaterialIcon getIcon() { 093 return icon; 094 } 095 096 @Override 097 public void setIconType(IconType iconType) { 098 icon.setIconType(iconType); 099 } 100 101 @Override 102 public void setIconPosition(IconPosition position) { 103 icon.setIconPosition(position); 104 } 105 106 @Override 107 public void setIconSize(IconSize size) { 108 icon.setIconSize(size); 109 } 110 111 @Override 112 public void setIconFontSize(double size, Unit unit) { 113 icon.setIconFontSize(size, unit); 114 } 115 116 @Override 117 public void setIconColor(String iconColor) { 118 icon.setIconColor(iconColor); 119 } 120 121 @Override 122 public void setIconPrefix(boolean prefix) { 123 icon.setIconPrefix(prefix); 124 } 125 126 @Override 127 public boolean isIconPrefix() { 128 return icon.isIconPrefix(); 129 } 130}