<commit_before>package org.fedorahosted.flies.webtrans.client.ui;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DecoratorPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

public class CaptionPanel extends DecoratorPanel implements ClickHandler {

	private VerticalPanel mainPanel;
	private HorizontalPanel headPanel;
	private VerticalPanel bodyPanel;
	
	private Button collapseButton;
	private boolean collapseButtonVisible;
	
	public CaptionPanel() {
		addStyleName("gwt-CaptionPanel");
		
		// init panel
		mainPanel = new VerticalPanel();
		mainPanel.setBorderWidth(0);
		mainPanel.setHorizontalAlignment(VerticalPanel.ALIGN_LEFT);
		mainPanel.setVerticalAlignment(VerticalPanel.ALIGN_TOP);
		mainPanel.setSpacing(0);
		mainPanel.setWidth("100%");
		setWidth("100%");
		
		headPanel = new HorizontalPanel();
		bodyPanel = new VerticalPanel();
		
		collapseButton = new Button("v");
		collapseButton.addClickHandler(this);
		collapseButtonVisible = true;
	}
	
	public void addHead(String title) {
		headPanel.addStyleName("gwt-CaptionPanel-Heading");
		headPanel.setWidth("100%");
		
		Label titleWidget = new Label(title);
		
		headPanel.add(titleWidget);
		headPanel.add(collapseButton);
		
		headPanel.setCellVerticalAlignment(titleWidget, HorizontalPanel.ALIGN_MIDDLE);
		headPanel.setCellHorizontalAlignment(collapseButton, HorizontalPanel.ALIGN_RIGHT);
	}
	
	public void addBody(Widget widget) {
		bodyPanel.add(widget);
	}
	
	public void initPanel() {
		mainPanel.add(headPanel);
		mainPanel.add(bodyPanel);
		add(mainPanel);
	}
		
	public void onClick(ClickEvent event) {
		Widget sender = (Widget) event.getSource();

		if (sender == collapseButton) {
			mainPanel.getWidget(1).setVisible(!collapseButtonVisible);
			collapseButtonVisible = !collapseButtonVisible;
		}
	}
}<commit_msg>- Improved event handler of collapse button.<commit_after>package org.fedorahosted.flies.webtrans.client.ui;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DecoratorPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

public class CaptionPanel extends DecoratorPanel {

	private VerticalPanel mainPanel;
	private HorizontalPanel headPanel;
	private VerticalPanel bodyPanel;
	
	private Button collapseButton;
	private boolean collapseButtonVisible;
	
	public CaptionPanel() {
		addStyleName("gwt-CaptionPanel");
		
		// init panel
		mainPanel = new VerticalPanel();
		mainPanel.setBorderWidth(0);
		mainPanel.setHorizontalAlignment(VerticalPanel.ALIGN_LEFT);
		mainPanel.setVerticalAlignment(VerticalPanel.ALIGN_TOP);
		mainPanel.setSpacing(0);
		mainPanel.setWidth("100%");
		setWidth("100%");
		
		headPanel = new HorizontalPanel();
		bodyPanel = new VerticalPanel();
		
		collapseButtonVisible = true;
		collapseButton = new Button("v");
		collapseButton.addClickHandler(new ClickHandler() {
			@Override
			public void onClick(ClickEvent event) {
				collapseButtonVisible = !collapseButtonVisible;
				String collapseButtonIcon = collapseButtonVisible ? "v" : ">";
				collapseButton.setText(collapseButtonIcon);
				mainPanel.getWidget(1).setVisible(collapseButtonVisible);
			}
		});
		
	}
	
	public void addHead(String title) {
		headPanel.addStyleName("gwt-CaptionPanel-Heading");
		headPanel.setWidth("100%");
		
		Label titleWidget = new Label(title);
		
		headPanel.add(titleWidget);
		headPanel.add(collapseButton);
		
		headPanel.setCellVerticalAlignment(titleWidget, HorizontalPanel.ALIGN_MIDDLE);
		headPanel.setCellHorizontalAlignment(collapseButton, HorizontalPanel.ALIGN_RIGHT);
	}
	
	public void addBody(Widget widget) {
		bodyPanel.add(widget);
	}
	
	public void initPanel() {
		mainPanel.add(headPanel);
		mainPanel.add(bodyPanel);
		add(mainPanel);
	}
}
{'fraction_non_alphanumeric': 0.1109283196239718, 'fraction_numerical': 0.00564042303172738, 'mean_word_length': 5.4, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '5940364', 'n_tokens_mistral': 1448, 'n_tokens_neox': 1284, 'n_words': 218}