com.github.gwtbootstrap.client.ui.Tab Maven / Gradle / Ivy
/*
* Copyright 2012 GWT-Bootstrap
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.gwtbootstrap.client.ui;
import java.util.Iterator;
import com.github.gwtbootstrap.client.ui.base.HasIcon;
import com.github.gwtbootstrap.client.ui.base.HasStyle;
import com.github.gwtbootstrap.client.ui.base.IsResponsive;
import com.github.gwtbootstrap.client.ui.base.Style;
import com.github.gwtbootstrap.client.ui.constants.*;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.uibinder.client.UiChild;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.HasEnabled;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.Widget;
/**
* The tab widget for {@link TabPanel}.
*
*
* It's for UiBinder.
* Tab class provide easy syntax on UiBinder.
*
* Example:
*
* {@code
*
*
* Typically Tab
*
* huhuhu hahha
*
*
*
*
*
*
* CustomTab Tab
*
*
* }
*
* }
*
*
* @since 2.0.4.0
* @author ohashi keisuke
*/
public class Tab implements IsWidget, HasWidgets, HasClickHandlers, HasStyle, IsResponsive, HasIcon, HasEnabled {
TabLink link = new TabLink();
/**
* Create tmpy tab
*/
public Tab() {
TabPane tabPane = new TabPane();
tabPane.setHref(DOM.createUniqueId());
link.setTabPane(tabPane);
}
/**
* Tab as a TabLink
*/
@Override
public Widget asWidget() {
return link;
}
/**
* Returns true if the widget is enabled, false if not.
*/
@Override
public boolean isEnabled() {
return link.isEnabled();
}
/**
* Sets whether this widget is enabled.
*
* @param enabled true
to enable the widget, false
* to disable it
*/
@Override
public void setEnabled(boolean enabled) {
link.setEnabled(enabled);
}
/**
* Get Container TabPane
* @return TabPane
*/
protected TabPane getTabPane() {
return link.getTabPane();
}
/**
* Return TabLink
* @return tabLink
*/
public TabLink asTabLink() {
return link;
}
/**
* Set tab active
* @param active
*/
public void setActive(boolean active) {
link.setActive(active);
}
/**
* has active style name
* @return true:active false:deactive
*/
public boolean isActive() {
return link.isActive();
}
/**
* Set tab text
* @param text tab text
*/
public void setHeading(String text) {
link.setText(text);
}
/**
* Get Tab text
* @return tab text
*/
public String getHeading() {
return link.getText();
}
/**
* Add widget to tab pane.
*/
@Override
public void add(Widget w) {
link.getTabPane().add(w);
}
/**
* Clear tab pane children
*/
@Override
public void clear() {
link.getTabPane().clear();
}
/**
* call {@link TabPane#iterator()}
*/
@Override
public Iterator© 2015 - 2025 Weber Informatics LLC | Privacy Policy