gwt.material.design.client.ui.MaterialNavBar Maven / Gradle / Ivy
/*
* #%L
* GwtMaterial
* %%
* Copyright (C) 2015 - 2017 GwtMaterialDesign
* %%
* 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.
* #L%
*/
package gwt.material.design.client.ui;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Style;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.Widget;
import gwt.material.design.client.base.HasActivates;
import gwt.material.design.client.base.HasProgress;
import gwt.material.design.client.base.mixin.ActivatesMixin;
import gwt.material.design.client.base.mixin.ProgressMixin;
import gwt.material.design.client.constants.*;
import gwt.material.design.client.ui.html.Div;
import gwt.material.design.client.ui.html.Nav;
import static gwt.material.design.jquery.client.api.JQuery.$;
//@formatter:off
/**
* Material NavBar represents as a app tool bar, that contains NavBrand,
* NavSection and initialize Material SideNav.
*
*
UiBinder Usage:
*
* {@code
*
*
*
*
*
*
*
*
*
* }
*
* @author kevzlou7979
* @author Ben Dol
* @see Material Nav Bar
* @see Material Design Specification
* @see Pattern Default
* @see Pattern Fixed
* @see Pattern Tall
* @see Pattern Extend
* @see Pattern Tabs
*/
//@formatter:on
public class MaterialNavBar extends Nav implements HasActivates, HasProgress {
private Div navWrapper = new Div();
private MaterialLink navMenu = new MaterialLink(IconType.MENU);
private ActivatesMixin activatesMixin;
private ProgressMixin progressMixin;
@Override
protected void onLoad() {
super.onLoad();
navWrapper.insert(navMenu,0);
navWrapper.setStyleName(CssName.NAV_WRAPPER);
super.add(navWrapper);
navMenu.setFontSize(2.7, Style.Unit.EM);
navMenu.addStyleName(CssName.BUTTON_COLLAPSE);
navMenu.getElement().getStyle().clearDisplay();
navMenu.setCircle(true);
navMenu.setWaves(WavesType.LIGHT);
navMenu.setWidth("64px");
navMenu.setTextAlign(TextAlign.CENTER);
navMenu.setIconPosition(IconPosition.NONE);
// Check whether the SideNav is attached or not. If not attached Hide the NavMenu
Element sideNavElement = $(DOM.getElementById(getActivatesMixin().getActivates())).asElement();
navMenu.setDisplay(sideNavElement == null ? Display.NONE : Display.INITIAL);
}
@Override
public void add(Widget child) {
navWrapper.add(child);
}
@Override
public void clear() {
navWrapper.clear();
}
@Override
public void showProgress(ProgressType type) {
getProgressMixin().showProgress(type);
}
@Override
public void setPercent(double percent) {
getProgressMixin().setPercent(percent);
}
@Override
public void hideProgress() {
getProgressMixin().hideProgress();
}
@Override
public MaterialProgress getProgress() {
return getProgressMixin().getProgress();
}
@Override
public void setActivates(String activates) {
getActivatesMixin().setActivates(activates);
}
@Override
public String getActivates() {
return getActivatesMixin().getActivates();
}
public MaterialLink getNavMenu() {
return navMenu;
}
public Div getNavWrapper() {
return navWrapper;
}
protected ActivatesMixin getActivatesMixin() {
if (activatesMixin == null) {
activatesMixin = new ActivatesMixin<>(navMenu);
}
return activatesMixin;
}
protected ProgressMixin getProgressMixin() {
if (progressMixin == null) {
progressMixin = new ProgressMixin<>(this);
}
return progressMixin;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy