001/* 002 * #%L 003 * GwtMaterial 004 * %% 005 * Copyright (C) 2015 - 2017 GwtMaterialDesign 006 * %% 007 * Licensed under the Apache License, Version 2.0 (the "License"); 008 * you may not use this file except in compliance with the License. 009 * You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 * #L% 019 */ 020package gwt.material.design.client.constants; 021 022import com.google.gwt.dom.client.Style; 023import com.google.gwt.dom.client.Style.HasCssName; 024 025/** 026 * @author chriswjones 027 */ 028public enum Display implements HasCssName { 029 FLEX("flex"), 030 NONE(Style.Display.NONE), 031 BLOCK(Style.Display.BLOCK), 032 INLINE(Style.Display.INLINE), 033 INLINE_BLOCK(Style.Display.INLINE_BLOCK), 034 INLINE_TABLE(Style.Display.INLINE_TABLE), 035 LIST_ITEM(Style.Display.LIST_ITEM), 036 RUN_IN(Style.Display.RUN_IN), 037 TABLE(Style.Display.TABLE), 038 TABLE_CAPTION(Style.Display.TABLE_CAPTION), 039 TABLE_COLUMN_GROUP(Style.Display.TABLE_COLUMN_GROUP), 040 TABLE_HEADER_GROUP(Style.Display.TABLE_HEADER_GROUP), 041 TABLE_FOOTER_GROUP(Style.Display.TABLE_FOOTER_GROUP), 042 TABLE_ROW_GROUP(Style.Display.TABLE_ROW_GROUP), 043 TABLE_CELL(Style.Display.TABLE_CELL), 044 TABLE_COLUMN(Style.Display.TABLE_COLUMN), 045 TABLE_ROW(Style.Display.TABLE_ROW), 046 INITIAL(Style.Display.INITIAL); 047 048 private final String cssName; 049 050 Display(HasCssName gwtDisplay) { 051 this.cssName = gwtDisplay.getCssName(); 052 } 053 054 Display(String cssName) { 055 this.cssName = cssName; 056 } 057 058 public Style.Display getGwtDisplay() { 059 return Style.Display.valueOf(this.name()); 060 } 061 062 public static Display parse(String display) { 063 for (Display d : Display.values()) { 064 if (d.getCssName().equals(display)) { 065 return d; 066 } 067 } 068 return null; 069 } 070 071 public static Display parse(HasCssName display) { 072 return parse(display.getCssName()); 073 } 074 075 @Override 076 public String getCssName() { 077 return cssName; 078 } 079}