<commit_before>/*
 * This is part of Geomajas, a GIS framework, http://www.geomajas.org/.
 *
 * Copyright 2008-2011 Geosparc nv, http://www.geosparc.com/, Belgium.
 *
 * The program is available in open source according to the GNU Affero
 * General Public License. All contributions in this program are covered
 * by the Geomajas Contributors License Agreement. For full licensing
 * details, see LICENSE.txt in the project root.
 */
package org.geomajas.gwt.client.widget;

import java.util.HashMap;

import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.layout.VLayout;

/**
 * Layout behaving like a deck of cards. Only one card visible at a time.
 * 
 * @author <NAME>
 */
//@Api or should this move to plugin-widget-utility
public class CardLayout extends VLayout {

	private HashMap<String, Canvas> cards = new HashMap<String, Canvas>();

	private Canvas currentCard;

	/**
	 * Add a card to the deck and associate it with the specified key.
	 * 
	 * @param key key associated to the card
	 * @param card the card
	 */
	public void addCard(String key, Canvas card) {
		addMember(card);
		cards.put(key, card);
		showCard(key);
	}

	/**
	 * Show the card associated with the specified key.
	 * 
	 * @param key key associated to the card that should be shown
	 */
	public void showCard(String key) {
		Canvas newCurrent = cards.get(key);
		if (null != newCurrent) {
			if (newCurrent != currentCard && null != currentCard) {
				currentCard.hide();
			}
			currentCard = newCurrent;
			currentCard.show();
		}
	}

	/**
	 * Returns the current card.
	 * 
	 * @return the current card.
	 */
	public Canvas getCurrentCard() {
		return currentCard;
	}
}<commit_msg>GWT-267: postpone show() so it can be called after drawing<commit_after>/*
 * This is part of Geomajas, a GIS framework, http://www.geomajas.org/.
 *
 * Copyright 2008-2011 Geosparc nv, http://www.geosparc.com/, Belgium.
 *
 * The program is available in open source according to the GNU Affero
 * General Public License. All contributions in this program are covered
 * by the Geomajas Contributors License Agreement. For full licensing
 * details, see LICENSE.txt in the project root.
 */
package org.geomajas.gwt.client.widget;

import java.util.HashMap;

import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.layout.VLayout;

/**
 * Layout behaving like a deck of cards. Only one card visible at a time.
 * 
 * @author <NAME>
 */
//@Api or should this move to plugin-widget-utility
public class CardLayout extends VLayout {

	private HashMap<String, Canvas> cards = new HashMap<String, Canvas>();

	private Canvas currentCard;

	/**
	 * Add a card to the deck and associate it with the specified key.
	 * 
	 * @param key key associated to the card
	 * @param card the card
	 */
	public void addCard(String key, Canvas card) {
		if (currentCard != null) {
			currentCard.hide();
		}
		addMember(card);
		currentCard = card;
		cards.put(key, card);
	}

	/**
	 * Show the card associated with the specified key.
	 * 
	 * @param key key associated to the card that should be shown
	 */
	public void showCard(String key) {
		Canvas newCurrent = cards.get(key);
		if (null != newCurrent) {
			if (newCurrent != currentCard && null != currentCard) {
				currentCard.hide();
			}
			currentCard = newCurrent;
			currentCard.show();
		}
	}

	/**
	 * Returns the current card.
	 * 
	 * @return the current card.
	 */
	public Canvas getCurrentCard() {
		return currentCard;
	}
}
{'fraction_non_alphanumeric': 0.10591274397244546, 'fraction_numerical': 0.0054535017221584384, 'mean_word_length': 3.411392405063291, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '6748302', 'n_tokens_mistral': 1149, 'n_tokens_neox': 1032, 'n_words': 384}