001/* 002 * Copyright 2012 GWT-Bootstrap 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package com.github.gwtbootstrap.client.ui.incubator; 017 018import com.github.gwtbootstrap.client.ui.base.ComplexWidget; 019import com.github.gwtbootstrap.client.ui.constants.Constants; 020import com.google.gwt.user.client.ui.Widget; 021 022//@formatter:off 023/** 024 * Wrapper for an HTML Table. 025 * 026 * @since 2.0.4.0 027 * 028 * @author Dominik Mayer 029 * 030 * @see <a href="http://twitter.github.com/bootstrap/base-css.html#tables">Bootstrap documentation</a> 031 */ 032//@formatter:on 033public class Table extends ComplexWidget { 034 035 private Header header = new Header(); 036 037 public Table() { 038 super("table"); 039 super.add(header); 040 setStylePrimaryName(Constants.TABLE); 041 } 042 043 /** 044 * Prints the rows in two different colors. Does not work in IE7 - IE8. 045 * 046 * @param striped 047 */ 048 public void setStriped(boolean striped) { 049 setStyleDependentName(Constants.STRIPED, striped); 050 } 051 052 @Override 053 public void add(Widget w) { 054 if (w instanceof TableHeader) 055 header.add(w); 056 else 057 super.add(w); 058 } 059 060 private class Header extends ComplexWidget { 061 062 public Header() { 063 super("thead"); 064 } 065 } 066}