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