package fr.openwide.core.basicapp.web.application.notification.component;

import org.apache.wicket.Component;
import org.apache.wicket.MarkupContainer;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.panel.GenericPanel;
import org.apache.wicket.model.IModel;

import fr.openwide.core.basicapp.web.application.config.spring.BasicApplicationWebappConfig;
import fr.openwide.core.wicket.behavior.ClassAttributeAppender;

public abstract class AbstractHtmlNotificationPanel<T> extends GenericPanel<T> {
	
	private static final long serialVersionUID = -3576134833190785445L;
	
	protected static final String CLASS_TABLE_TOP_LEFT = "top-left";
	protected static final String CLASS_TABLE_TOP_RIGHT = "top-right";
	protected static final String CLASS_TABLE_BOTTOM_LEFT = "bottom-left";
	protected static final String CLASS_TABLE_BOTTOM_RIGHT = "bottom-right";
	
	protected static final String TARGET_BLANK = "_blank";
	
	public AbstractHtmlNotificationPanel(String id) {
		this(id, null);
	}
	
	public AbstractHtmlNotificationPanel(String id, IModel<T> model) {
		super(id, model);
	}
	
	@Override
	public String getVariation() {
		return BasicApplicationWebappConfig.DEFAULT_NOTIFICATION_VARIATION;
	}
	
	protected void addTopProperty(MarkupContainer table, String headerComponentId, Component dataComponent) {
		table.add(
				createHeaderComponent(headerComponentId)
						.add(new ClassAttributeAppender(CLASS_TABLE_TOP_LEFT))
				, dataComponent
						.add(new ClassAttributeAppender(CLASS_TABLE_TOP_RIGHT))
		);
	}
	
	protected void addMiddleProperty(MarkupContainer table, String headerComponentId, Component dataComponent) {
		table.add(
				createHeaderComponent(headerComponentId)
				, dataComponent
		);
	}
	
	protected void addBottomProperty(MarkupContainer table, String headerComponentId, Component dataComponent) {
		table.add(
				createHeaderComponent(headerComponentId)
						.add(new ClassAttributeAppender(CLASS_TABLE_BOTTOM_LEFT))
				, dataComponent
						.add(new ClassAttributeAppender(CLASS_TABLE_BOTTOM_RIGHT))
		);
	}
	
	private Component createHeaderComponent(String id) {
		return new WebMarkupContainer(id);
	}
}

@@ -1458,31 +1458,30 @@
 E_TOP_LEFT))
+,
 %0A%09%09%09%09
-, 
 dataComponen
@@ -1721,23 +1721,22 @@
 onentId)
+,
 %0A%09%09%09%09
-, 
 dataComp
@@ -1986,15 +1986,14 @@
 FT))
+,
 %0A%09%09%09%09
-, 
 data

Virgules en fin de ligne. (non, ça n'a pas été fait à la main)