<commit_before>/**
 * 
 */
package org.pentaho.ui.xul.swing.tags;

import java.awt.GridBagLayout;

import javax.swing.AbstractButton;
import javax.swing.ButtonGroup;
import javax.swing.JPanel;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.pentaho.ui.xul.XulComponent;
import org.pentaho.ui.xul.XulDomContainer;
import org.pentaho.ui.xul.components.XulRadioGroup;
import org.pentaho.ui.xul.swing.SwingElement;
import org.pentaho.ui.xul.util.Orient;

/**
 * @author aphillips
 *
 */
public class SwingRadioGroup extends SwingElement implements XulRadioGroup {
	private static final Log logger = LogFactory.getLog(SwingRadioGroup.class);
	private ButtonGroup buttonGroup = new ButtonGroup();

  public SwingRadioGroup(XulComponent parent, XulDomContainer domContainer, String tagName) {
    super("radiogroup");
    container = new JPanel(new GridBagLayout());
    
    managedObject = container;
    
    resetContainer();
  }

  @Override
  public void addComponent(XulComponent c) {
    addComponentToButtonGroup(c);

    super.addComponent(c);
  }
  
  protected void addComponentToButtonGroup(XulComponent c) {
    for(XulComponent child : c.getChildNodes()) {
      addComponentToButtonGroup(child);
    }
    if(AbstractButton.class.isAssignableFrom(c.getManagedObject().getClass())) {
      this.buttonGroup.add((AbstractButton)c.getManagedObject());
    }
  }
  
  @Override
  public Orient getOrientation() {
    return Orient.VERTICAL;
  }
}  
  <commit_msg>fixed layouting problem with swing radiogroup<commit_after>/**
 * 
 */
package org.pentaho.ui.xul.swing.tags;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

import javax.swing.AbstractButton;
import javax.swing.ButtonGroup;
import javax.swing.JPanel;

import org.pentaho.ui.xul.XulComponent;
import org.pentaho.ui.xul.XulDomContainer;
import org.pentaho.ui.xul.XulDomException;
import org.pentaho.ui.xul.components.XulRadioGroup;
import org.pentaho.ui.xul.swing.SwingElement;
import org.pentaho.ui.xul.util.Orient;

/**
 * @author aphillips
 *
 */
public class SwingRadioGroup extends SwingElement implements XulRadioGroup {

	private ButtonGroup buttonGroup = new ButtonGroup();

	public SwingRadioGroup(XulComponent parent, XulDomContainer domContainer,
			String tagName) {
		super("radiogroup");

		this.orientation = Orient.VERTICAL;

		container = new JPanel(new GridBagLayout());

		managedObject = container;

		resetContainer();
	}

	@Override
	public void addComponent(XulComponent c) {
		addComponentToButtonGroup(c);

		super.addComponent(c);
	}

	protected void addComponentToButtonGroup(XulComponent c) {
		for (XulComponent child : c.getChildNodes()) {
			addComponentToButtonGroup(child);
		}
		if (AbstractButton.class.isAssignableFrom(c.getManagedObject()
				.getClass())) {
			this.buttonGroup.add((AbstractButton) c.getManagedObject());
		}
	}

	public void resetContainer() {

		container.removeAll();

		gc = new GridBagConstraints();
		gc.gridy = GridBagConstraints.RELATIVE;
		gc.gridx = 0;
		gc.gridheight = 1;
		gc.gridwidth = GridBagConstraints.REMAINDER;
		gc.insets = new Insets(2, 2, 2, 2);
		gc.fill = GridBagConstraints.HORIZONTAL;
		gc.anchor = GridBagConstraints.NORTHWEST;
		gc.weightx = 1;

	}

	@Override
	public void replaceChild(XulComponent oldElement, XulComponent newElement)
			throws XulDomException {
		this.resetContainer();
		super.replaceChild(oldElement, newElement);
	}
}  
  
{'fraction_non_alphanumeric': 0.10945558739255014, 'fraction_numerical': 0.0020057306590257878, 'mean_word_length': 4.667207792207792, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '932312', 'n_tokens_mistral': 1186, 'n_tokens_neox': 1122, 'n_words': 206}