<commit_before>/*
 * #%L
 * GwtMaterial
 * %%
 * Copyright (C) 2015 - 2016 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.user.client.ui.Widget;
import gwt.material.design.client.base.HasPosition;
import gwt.material.design.client.base.mixin.CssNameMixin;
import gwt.material.design.client.constants.HideOn;
import gwt.material.design.client.constants.Position;
import gwt.material.design.client.ui.html.ListItem;
import gwt.material.design.client.ui.html.UnorderedList;

//@formatter:off

/**
 * <p>Material NavSection is a child of MaterialNavBar that will contain toolbar items such as link, icon and other components
 * <h3>UiBinder Usage:</h3>
 * <p>
 * <pre>
 * {@code
 * <m:MaterialNavSection align="RIGHT">
 *     <m:MaterialLink  iconType="ACCOUNT_CIRCLE" iconPosition="LEFT" text="Account"  textColor="WHITE" waves="LIGHT"/>
 *     <m:MaterialLink  iconType="AUTORENEW" iconPosition="LEFT" text="Refresh" textColor="WHITE" waves="LIGHT"/>
 *     <m:MaterialLink  iconType="SEARCH" tooltip="Menu" textColor="WHITE" waves="LIGHT"/>
 *     <m:MaterialLink  iconType="MORE_VERT" tooltip="Starter" textColor="WHITE" waves="LIGHT"/>
 * </m:MaterialNavSection>
 * }
 * </pre>
 * </p>
 *
 * @author kevzlou7979
 * @author <NAME>
 * @see <a href="http://gwtmaterialdesign.github.io/gwt-material-demo/#navbar">Material NavSection</a>
 */
//@formatter:on
public class MaterialNavSection extends UnorderedList implements HasPosition {

    private final CssNameMixin<MaterialNavSection, Position> posMixin = new CssNameMixin<>(this);

    /**
     * Container for App Toolbar and App Sidebar, contains Material
     * Links, Icons or any other material components.
     */
    public MaterialNavSection() {
        super();
        setHideOn(HideOn.HIDE_ON_MED_DOWN);
    }

    @Override
    public void add(Widget child) {
        super.add(new ListItem(child));
    }

    @Override
    public Position getPosition() {
        return posMixin.getCssName();
    }

    @Override
    public void setPosition(Position position) {
        posMixin.setCssName(position);
    }
}<commit_msg>MaterialNavSection - Added ValueChange Event to set Active item state.<commit_after>/*
 * #%L
 * GwtMaterial
 * %%
 * Copyright (C) 2015 - 2016 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.event.logical.shared.HasValueChangeHandlers;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.ui.Widget;
import gwt.material.design.client.base.HasPosition;
import gwt.material.design.client.base.mixin.CssNameMixin;
import gwt.material.design.client.constants.HideOn;
import gwt.material.design.client.constants.Position;
import gwt.material.design.client.ui.html.ListItem;
import gwt.material.design.client.ui.html.UnorderedList;

import java.util.ArrayList;
import java.util.List;

//@formatter:off

/**
 * <p>Material NavSection is a child of MaterialNavBar that will contain toolbar items such as link, icon and other components
 * <h3>UiBinder Usage:</h3>
 * <p>
 * <pre>
 * {@code
 * <m:MaterialNavSection align="RIGHT">
 *     <m:MaterialLink  iconType="ACCOUNT_CIRCLE" iconPosition="LEFT" text="Account"  textColor="WHITE" waves="LIGHT"/>
 *     <m:MaterialLink  iconType="AUTORENEW" iconPosition="LEFT" text="Refresh" textColor="WHITE" waves="LIGHT"/>
 *     <m:MaterialLink  iconType="SEARCH" tooltip="Menu" textColor="WHITE" waves="LIGHT"/>
 *     <m:MaterialLink  iconType="MORE_VERT" tooltip="Starter" textColor="WHITE" waves="LIGHT"/>
 * </m:MaterialNavSection>
 * }
 * </pre>
 * </p>
 *
 * @author kevzlou7979
 * @author <NAME>
 * @see <a href="http://gwtmaterialdesign.github.io/gwt-material-demo/#navbar">Material NavSection</a>
 */
//@formatter:on
public class MaterialNavSection extends UnorderedList implements HasPosition, HasValueChangeHandlers<Integer> {

    private final CssNameMixin<MaterialNavSection, Position> posMixin = new CssNameMixin<>(this);
    private List<HandlerRegistration> handlers = new ArrayList<>();

    /**
     * Container for App Toolbar and App Sidebar, contains Material
     * Links, Icons or any other material components.
     */
    public MaterialNavSection() {
        super();
        setHideOn(HideOn.HIDE_ON_MED_DOWN);
    }

    @Override
    public void add(Widget child) {
        super.add(new ListItem(child));
    }

    @Override
    protected void onLoad() {
        super.onLoad();
        for (Widget widget : getChildren()) {
            if (widget instanceof ListItem) {
                handlers.add(((ListItem) widget).addClickHandler(clickEvent -> ValueChangeEvent.fire(this, getWidgetIndex(widget))));
            }
        }
    }

    @Override
    protected void onUnload() {
        super.onUnload();

        handlers.clear();
    }

    @Override
    public Position getPosition() {
        return posMixin.getCssName();
    }

    @Override
    public void setPosition(Position position) {
        posMixin.setCssName(position);
    }

    @Override
    public HandlerRegistration addValueChangeHandler(ValueChangeHandler<Integer> valueChangeHandler) {
        return addHandler(valueChangeHandler, ValueChangeEvent.getType());
    }
}
{'fraction_non_alphanumeric': 0.1183011583011583, 'fraction_numerical': 0.0055598455598455596, 'mean_word_length': 3.891238670694864, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 44, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6443297', 'n_tokens_mistral': 1972, 'n_tokens_neox': 1917, 'n_words': 491}