All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jpattern.gwt.client.view.DefaultUlErrorArea Maven / Gradle / Ivy

package com.jpattern.gwt.client.view;

import java.util.List;

import com.google.gwt.user.client.ui.InlineLabel;
import com.google.gwt.user.client.ui.Panel;
import com.jpattern.gwt.client.ui.UlListPanel;
import com.jpattern.shared.result.IErrorMessage;

/**
 * Define an IErrorArea which shows the errors added in a UIList
 * @author cinafr
 *
 */
public class DefaultUlErrorArea implements IErrorArea {

	private final UlListPanel listPanel;
	private final Panel errorPanel;

	public DefaultUlErrorArea(Panel errorPanel) {
		errorPanel.setVisible(false);
		this.errorPanel = errorPanel;
		this.listPanel = new UlListPanel();
		errorPanel.add(listPanel);
	}
	
	@Override
	public void addErrorMessage(IErrorMessage errorMessage) {
		errorPanel.setVisible(true);
		listPanel.add(new InlineLabel(errorMessage.getName() + " " + errorMessage.getMessage()));
	}

	@Override
	public void addErrorMessages(List errorMessages) {
		for (IErrorMessage errorMessage : errorMessages) {
			addErrorMessage(errorMessage);
		}
	}

	@Override
	public void clear() {
		listPanel.clear();
		errorPanel.setVisible(false);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy