001package gwt.material.design.client.constants; 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.Style; 024import com.google.gwt.dom.client.Style.HasCssName; 025 026/** 027 * @author chriswjones 028 */ 029public enum Display implements HasCssName { 030 FLEX("flex"), 031 NONE(Style.Display.NONE), 032 BLOCK(Style.Display.BLOCK), 033 INLINE(Style.Display.INLINE), 034 INLINE_BLOCK(Style.Display.INLINE_BLOCK), 035 INLINE_TABLE(Style.Display.INLINE_TABLE), 036 LIST_ITEM(Style.Display.LIST_ITEM), 037 RUN_IN(Style.Display.RUN_IN), 038 TABLE(Style.Display.TABLE), 039 TABLE_CAPTION(Style.Display.TABLE_CAPTION), 040 TABLE_COLUMN_GROUP(Style.Display.TABLE_COLUMN_GROUP), 041 TABLE_HEADER_GROUP(Style.Display.TABLE_HEADER_GROUP), 042 TABLE_FOOTER_GROUP(Style.Display.TABLE_FOOTER_GROUP), 043 TABLE_ROW_GROUP(Style.Display.TABLE_ROW_GROUP), 044 TABLE_CELL(Style.Display.TABLE_CELL), 045 TABLE_COLUMN(Style.Display.TABLE_COLUMN), 046 TABLE_ROW(Style.Display.TABLE_ROW), 047 INITIAL(Style.Display.INITIAL); 048 049 private final String cssName; 050 051 Display(HasCssName gwtDisplay) { 052 this.cssName = gwtDisplay.getCssName(); 053 } 054 055 Display(String cssName) { 056 this.cssName = cssName; 057 } 058 059 public Style.Display getGwtDisplay() { 060 return Style.Display.valueOf(this.name()); 061 } 062 063 public static Display parse(String display) { 064 for (Display d : Display.values()) { 065 if (d.getCssName().equals(display)){ 066 return d; 067 } 068 } 069 return null; 070 } 071 072 public static Display parse(HasCssName display) { 073 return parse(display.getCssName()); 074 } 075 076 @Override 077 public String getCssName() { 078 return cssName; 079 } 080}