// Path: src/java/com/idega/documentmanager/business/component/Button.java
// public interface Button extends Component {
// 
// 	public abstract PropertiesButton getProperties();
// }
// 
// Path: src/java/com/idega/documentmanager/business/component/ButtonArea.java
// public interface ButtonArea extends Container {
// 
// 	public abstract Button getButton(ConstButtonType button_type);
// 	
// 	public abstract Button addButton(ConstButtonType button_type, String component_after_this_id) throws NullPointerException;
// }
// 
// Path: src/java/com/idega/documentmanager/business/component/ConstButtonType.java
// public enum ConstButtonType {
// 	
// 	PREVIOUS_PAGE_BUTTON {public String toString() { return "fbc_button_previous"; }},
// 	NEXT_PAGE_BUTTON {public String toString() { return "fbc_button_next"; }},
// 	SUBMIT_FORM_BUTTON {public String toString() { return "fbc_button_submit"; }},
// 	SAVE_FORM_BUTTON {public String toString() { return "fbc_button_save"; }},
// 	RESET_FORM_BUTTON {public String toString() { return "fbc_button_reset"; }};
// 	
// 	public static Set<String> getAllTypesInStrings() {
// 		
// 		return getAllStringTypesEnumsMappings().keySet();
// 	}
// 	
// 	private static Map<String, ConstButtonType> allStringTypesEnumsMappings;
// 	
// 	private synchronized static Map<String, ConstButtonType> getAllStringTypesEnumsMappings() {
// 		
// 		if(allStringTypesEnumsMappings == null) {
// 			
// 			allStringTypesEnumsMappings = new HashMap<String, ConstButtonType>();
// 			
// 			for (ConstButtonType type : values())
// 				allStringTypesEnumsMappings.put(type.toString(), type);
// 		}
// 		
// 		return allStringTypesEnumsMappings;
// 	}
// 	
// 	public static ConstButtonType getByStringType(String type) {
// 		
// 		return getAllStringTypesEnumsMappings().get(type);
// 	}
// 	
// 	public abstract String toString();
// }
// 
// Path: src/java/com/idega/documentmanager/component/FormComponentButton.java
// public interface FormComponentButton extends FormComponent {
// 
// 	public abstract void setSiblingsAndParentPages(FormComponentPage previous, FormComponentPage next);
// 	
// 	public abstract void setLastPageId(String last_page_id);
// }
// 
// Path: src/java/com/idega/documentmanager/component/FormComponentButtonArea.java
// public interface FormComponentButtonArea extends FormComponentContainer {
// 
// 	public abstract void setButtonMapping(String button_type, String button_id);
// 	
// 	public abstract void setPageSiblings(FormComponentPage previous, FormComponentPage next);
// 	
// 	public abstract FormComponentPage getPreviousPage();
// 	
// 	public abstract FormComponentPage getNextPage();
// 	
// 	public abstract FormComponentPage getCurrentPage();
// 	
// 	public abstract void announceLastPage(String last_page_id);
// }
// 
// Path: src/java/com/idega/documentmanager/component/FormComponentPage.java
// public interface FormComponentPage extends FormComponentContainer {
// 
// 	public abstract void setButtonAreaComponentId(String button_area_id);
// 	
// 	public abstract void setPageSiblings(FormComponentPage previous, FormComponentPage next);
// 	
// 	public abstract void pagesSiblingsChanged();
// 	
// 	public abstract FormComponentPage getPreviousPage();
// 	
// 	public abstract FormComponentPage getNextPage();
// 	
// 	public abstract void announceLastPage(String last_page_id);
// 	
// 	public abstract ButtonArea getButtonArea();
// }


import java.util.HashMap;
import java.util.Map;
import com.idega.documentmanager.business.component.Button;
import com.idega.documentmanager.business.component.ButtonArea;
import com.idega.documentmanager.business.component.ConstButtonType;
import com.idega.documentmanager.component.FormComponentButton;
import com.idega.documentmanager.component.FormComponentButtonArea;
import com.idega.documentmanager.component.FormComponentPage;
package com.idega.documentmanager.component.impl;




/**
 * @author <a href="mailto:civilis@idega.com">Vytautas Čivilis</a>
 * @version $Revision: 1.4 $
 *
 * Last modified: $Date: 2008/10/26 16:47:10 $ by $Author: anton $
 */
public class FormComponentButtonAreaImpl extends FormComponentContainerImpl implements ButtonArea, FormComponentButtonArea {

	protected Map<String, String> buttons_type_id_mapping;

	public Button getButton(ConstButtonType buttonType) {

		if(buttonType == null)
			throw new NullPointerException("Button type provided null");
		
		return !getButtonsTypeIdMapping().containsKey(buttonType) ? null : 
			(Button)getContainedComponent(getButtonsTypeIdMapping().get(buttonType));
	}
	
	public Button addButton(ConstButtonType buttonType, String componentAfterThisId) throws NullPointerException {
		
		if(buttonType == null)
			throw new NullPointerException("Button type provided null");
		
		if(getButtonsTypeIdMapping().containsKey(buttonType))
			throw new IllegalArgumentException("Button by type provided: "+buttonType+" already exists in the button area, remove first");
		
		return (Button)addComponent(buttonType.toString(), componentAfterThisId);
	}
	
	protected Map<String, String> getButtonsTypeIdMapping() {
		
		if(buttons_type_id_mapping == null)
			buttons_type_id_mapping = new HashMap<String, String>();
		
		return buttons_type_id_mapping;
	}
	
	@Override
	public void render() {
		super.render();
// Path: src/java/com/idega/documentmanager/business/component/Button.java
// public interface Button extends Component {
// 
// 	public abstract PropertiesButton getProperties();
// }
// 
// Path: src/java/com/idega/documentmanager/business/component/ButtonArea.java
// public interface ButtonArea extends Container {
// 
// 	public abstract Button getButton(ConstButtonType button_type);
// 	
// 	public abstract Button addButton(ConstButtonType button_type, String component_after_this_id) throws NullPointerException;
// }
// 
// Path: src/java/com/idega/documentmanager/business/component/ConstButtonType.java
// public enum ConstButtonType {
// 	
// 	PREVIOUS_PAGE_BUTTON {public String toString() { return "fbc_button_previous"; }},
// 	NEXT_PAGE_BUTTON {public String toString() { return "fbc_button_next"; }},
// 	SUBMIT_FORM_BUTTON {public String toString() { return "fbc_button_submit"; }},
// 	SAVE_FORM_BUTTON {public String toString() { return "fbc_button_save"; }},
// 	RESET_FORM_BUTTON {public String toString() { return "fbc_button_reset"; }};
// 	
// 	public static Set<String> getAllTypesInStrings() {
// 		
// 		return getAllStringTypesEnumsMappings().keySet();
// 	}
// 	
// 	private static Map<String, ConstButtonType> allStringTypesEnumsMappings;
// 	
// 	private synchronized static Map<String, ConstButtonType> getAllStringTypesEnumsMappings() {
// 		
// 		if(allStringTypesEnumsMappings == null) {
// 			
// 			allStringTypesEnumsMappings = new HashMap<String, ConstButtonType>();
// 			
// 			for (ConstButtonType type : values())
// 				allStringTypesEnumsMappings.put(type.toString(), type);
// 		}
// 		
// 		return allStringTypesEnumsMappings;
// 	}
// 	
// 	public static ConstButtonType getByStringType(String type) {
// 		
// 		return getAllStringTypesEnumsMappings().get(type);
// 	}
// 	
// 	public abstract String toString();
// }
// 
// Path: src/java/com/idega/documentmanager/component/FormComponentButton.java
// public interface FormComponentButton extends FormComponent {
// 
// 	public abstract void setSiblingsAndParentPages(FormComponentPage previous, FormComponentPage next);
// 	
// 	public abstract void setLastPageId(String last_page_id);
// }
// 
// Path: src/java/com/idega/documentmanager/component/FormComponentButtonArea.java
// public interface FormComponentButtonArea extends FormComponentContainer {
// 
// 	public abstract void setButtonMapping(String button_type, String button_id);
// 	
// 	public abstract void setPageSiblings(FormComponentPage previous, FormComponentPage next);
// 	
// 	public abstract FormComponentPage getPreviousPage();
// 	
// 	public abstract FormComponentPage getNextPage();
// 	
// 	public abstract FormComponentPage getCurrentPage();
// 	
// 	public abstract void announceLastPage(String last_page_id);
// }
// 
// Path: src/java/com/idega/documentmanager/component/FormComponentPage.java
// public interface FormComponentPage extends FormComponentContainer {
// 
// 	public abstract void setButtonAreaComponentId(String button_area_id);
// 	
// 	public abstract void setPageSiblings(FormComponentPage previous, FormComponentPage next);
// 	
// 	public abstract void pagesSiblingsChanged();
// 	
// 	public abstract FormComponentPage getPreviousPage();
// 	
// 	public abstract FormComponentPage getNextPage();
// 	
// 	public abstract void announceLastPage(String last_page_id);
// 	
// 	public abstract ButtonArea getButtonArea();
// }


// Path: src/java/com/idega/documentmanager/component/impl/FormComponentButtonAreaImpl.java
import java.util.HashMap;
import java.util.Map;
import com.idega.documentmanager.business.component.Button;
import com.idega.documentmanager.business.component.ButtonArea;
import com.idega.documentmanager.business.component.ConstButtonType;
import com.idega.documentmanager.component.FormComponentButton;
import com.idega.documentmanager.component.FormComponentButtonArea;
import com.idega.documentmanager.component.FormComponentPage;

package com.idega.documentmanager.component.impl;




/**
 * @author <a href="mailto:civilis@idega.com">Vytautas Čivilis</a>
 * @version $Revision: 1.4 $
 *
 * Last modified: $Date: 2008/10/26 16:47:10 $ by $Author: anton $
 */
public class FormComponentButtonAreaImpl extends FormComponentContainerImpl implements ButtonArea, FormComponentButtonArea {

	protected Map<String, String> buttons_type_id_mapping;

	public Button getButton(ConstButtonType buttonType) {

		if(buttonType == null)
			throw new NullPointerException("Button type provided null");
		
		return !getButtonsTypeIdMapping().containsKey(buttonType) ? null : 
			(Button)getContainedComponent(getButtonsTypeIdMapping().get(buttonType));
	}
	
	public Button addButton(ConstButtonType buttonType, String componentAfterThisId) throws NullPointerException {
		
		if(buttonType == null)
			throw new NullPointerException("Button type provided null");
		
		if(getButtonsTypeIdMapping().containsKey(buttonType))
			throw new IllegalArgumentException("Button by type provided: "+buttonType+" already exists in the button area, remove first");
		
		return (Button)addComponent(buttonType.toString(), componentAfterThisId);
	}
	
	protected Map<String, String> getButtonsTypeIdMapping() {
		
		if(buttons_type_id_mapping == null)
			buttons_type_id_mapping = new HashMap<String, String>();
		
		return buttons_type_id_mapping;
	}
	
	@Override
	public void render() {
		super.render();
		((FormComponentPage)parent).setButtonAreaComponentId(getId());