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; 017 018import com.github.gwtbootstrap.client.ui.base.DivWidget; 019import com.github.gwtbootstrap.client.ui.constants.Constants; 020import com.github.gwtbootstrap.client.ui.resources.Bootstrap; 021import com.github.gwtbootstrap.datepicker.client.ui.base.HasEndDate; 022import com.google.gwt.user.client.DOM; 023import com.google.gwt.user.client.ui.HasEnabled; 024 025//@formatter:off 026/** 027 * Tab Pane for tabbable nav. 028 * 029 * @since 2.0.4.0 030 * @author Dominik Mayer 031 */ 032//@formatter:on 033public class TabPane extends DivWidget { 034 035 private String heading; 036 037 private String href; 038 039 private boolean createTabLink = true; 040 041 public TabPane() { 042 this(""); 043 } 044 045 public TabPane(String heading) { 046 setStyleName(Bootstrap.tab_pane); 047 this.heading = heading; 048 createHref(); 049 } 050 051 public void setCreateTabLink(boolean createTabLink) { 052 this.createTabLink = createTabLink; 053 } 054 055 public boolean isCreateTabLink() { 056 return this.createTabLink; 057 } 058 059 private void createHref() { 060 setHref(DOM.createUniqueId()); 061 } 062 063 public void setHref(String href) { 064 this.href = href; 065 getElement().setId(href); 066 } 067 068 public void setActive(boolean active) { 069 if (active) { 070 addStyleName(Constants.ACTIVE); 071 } else { 072 removeStyleName(Constants.ACTIVE); 073 } 074 } 075 076 077 public String getHeading() { 078 return heading; 079 } 080 081 public void setHeading(String heading) { 082 this.heading = heading; 083 } 084 085 public String getId() { 086 return href; 087 } 088 089 public boolean isActive() { 090 return getStyleName().contains(Constants.ACTIVE); 091 } 092}