package com.inepex.ineFrame.client.page;

import java.util.Map;

import com.google.gwt.user.client.ui.Widget;
import com.inepex.ineFrame.client.misc.HandlerAwareLayoutPanel;
import com.inepex.ineFrame.client.navigation.InePlace;

/**
 * render page contents in {@link #onShow(boolean)}
 * optionally clean up resources in {@link #onUnload()}
 * override {@link #setUrlParameters(Map, com.inepex.ineFrame.client.page.InePage.UrlParamsParsedCallback)} 
 * to handle url params
 *
 */
public abstract class LayoutPanelBasedPage extends HandlerAwareLayoutPanel implements InePage{

	protected InePlace currentPlace;
	private Boolean isFirstShow = true;
	
	public LayoutPanelBasedPage() {}
	
	@Override
	public void setCurrentPlace(InePlace place) {
		this.currentPlace = place;
	}

	/**
	 * override to handle url parameters
	 */
	@Override
	public void setUrlParameters(Map<String, String> urlParams,
			UrlParamsParsedCallback callback) throws Exception {
		callback.onUrlParamsParsed();
	}

	@Override
	public final void onShow() {
		if(isFirstShow){
			isFirstShow = false;
			onShow(true);
		}else{
			onShow(false);
		}
		
	}

	@Override
	public Widget asWidget() {
		return this;
	}

	public InePlace getCurrentPlace() {
		return currentPlace;
	}
	
	
	public abstract void onShow(boolean isfirstShow);
}

@@ -661,19 +661,62 @@
  true;%0D%0A
+%09protected Map%3CString, String%3E urlParams;%0D%0A
 %09%0D%0A
-
 %09public 
@@ -847,16 +847,105 @@
 %0D%0A%09/**%0D%0A
+%09 * onShow called only after %7B@link UrlParamsParsedCallback#onUrlParamsParsed()%7D called%0D%0A
 %09 * over
@@ -1112,16 +1112,47 @@
 tion %7B%0D%0A
+%09%09this.urlParams = urlParams;%0D%0A
 %09%09callba
@@ -1461,17 +1461,89 @@
 e;%0D%0A%09%7D%0D%0A
-
 %09
+%09%0D%0A%09public Map%3CString, String%3E getUrlParams() %7B%0D%0A%09%09return urlParams;%0D%0A%09%7D
 %0D%0A%09%0D%0A%09pu

add urlParams attribute to LayoutPanelBasedPage