<commit_before>/*
 * Copyright (c) 2008 Haulmont Technology Ltd. All Rights Reserved.
 * Haulmont Technology proprietary and confidential.
 * Use is subject to license terms.

 * Author: <NAME>
 * Created: 05.07.2010 17:41:16
 *
 * $Id$
 */
package com.haulmont.cuba.toolkit.gwt.client.ui;

import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.Container;
import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.ui.VForm;

public class VFieldGroup extends VForm {

    protected Element captionWrapper = DOM.createDiv();
    protected Element expander = DOM.createDiv();
    protected boolean expanded;
    protected boolean collapsable;

    public VFieldGroup() {
        super();
        DOM.removeChild(legend, caption);
        DOM.appendChild(legend, captionWrapper);
        DOM.appendChild(captionWrapper, expander);
        DOM.appendChild(captionWrapper, caption);
        DOM.setElementProperty(captionWrapper, "className", CLASSNAME + "-caption");

        DOM.sinkEvents(expander, Event.ONCLICK);

        setStyleName("v-fieldgroup");
    }

    protected void renderContent(UIDL uidl, ApplicationConnection client) {
        final UIDL layoutUidl = uidl.getChildUIDL(0);
        if (layoutUidl != null) {
            Container newLo = (Container) client.getPaintable(layoutUidl);
            if (lo == null) {
                lo = newLo;
                add((Widget) lo, fieldContainer);
            } else if (lo != newLo) {
                client.unregisterPaintable(lo);
                remove((Widget) lo);
                lo = newLo;
                add((Widget) lo, fieldContainer);
            }
            lo.updateFromUIDL(layoutUidl, client);
        }
    }

    protected void renderDOM(UIDL uidl, ApplicationConnection client) {
        collapsable = uidl.getBooleanAttribute("collapsable");
        if (collapsable) {
            DOM.setStyleAttribute(expander, "display", "");
            removeStyleDependentName("nocollapsable");
        } else {
            addStyleDependentName("nocollapsable");
            DOM.setStyleAttribute(expander, "display", "none");<commit_msg>- added classname for fieldgroup style tweaking<commit_after>/*
 * Copyright (c) 2008 Haulmont Technology Ltd. All Rights Reserved.
 * Haulmont Technology proprietary and confidential.
 * Use is subject to license terms.

 * Author: <NAME>
 * Created: 05.07.2010 17:41:16
 *
 * $Id$
 */
package com.haulmont.cuba.toolkit.gwt.client.ui;

import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.Container;
import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.ui.VForm;

public class VFieldGroup extends VForm {

    protected Element captionWrapper = DOM.createDiv();
    protected Element expander = DOM.createDiv();
    protected boolean expanded;
    protected boolean collapsable;

    public VFieldGroup() {
        super();
        DOM.removeChild(legend, caption);
        DOM.appendChild(legend, captionWrapper);
        DOM.appendChild(captionWrapper, expander);
        DOM.appendChild(captionWrapper, caption);
        DOM.setElementProperty(captionWrapper, "className", CLASSNAME + "-caption");

        DOM.sinkEvents(expander, Event.ONCLICK);

        setStyleName("v-fieldgroup");
        setStyleName(fieldSet, "v-fieldgroup-fieldset");
    }

    protected void renderContent(UIDL uidl, ApplicationConnection client) {
        final UIDL layoutUidl = uidl.getChildUIDL(0);
        if (layoutUidl != null) {
            Container newLo = (Container) client.getPaintable(layoutUidl);
            if (lo == null) {
                lo = newLo;
                add((Widget) lo, fieldContainer);
            } else if (lo != newLo) {
                client.unregisterPaintable(lo);
                remove((Widget) lo);
                lo = newLo;
                add((Widget) lo, fieldContainer);
            }
            lo.updateFromUIDL(layoutUidl, client);
        }
    }

    protected void renderDOM(UIDL uidl, ApplicationConnection client) {
        collapsable = uidl.getBooleanAttribute("collapsable");
        if (collapsable) {
            DOM.setStyleAttribute(expander, "display", "");
            removeStyleDependentName("nocollapsable");
        } else {
            addStyleDependentName("nocollapsable");
            DOM.setStyleAttribute(expander, "display", "none");
{'fraction_non_alphanumeric': 0.11143633702697052, 'fraction_numerical': 0.007944804515994146, 'mean_word_length': 2.8210862619808306, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '5454216', 'n_tokens_mistral': 1436, 'n_tokens_neox': 1354, 'n_words': 285}