001: /**********************************************************************************
002: * $URL:https://source.sakaiproject.org/svn/osp/trunk/presentation/tool/src/java/org/theospi/portfolio/presentation/tool/RegionSequenceMap.java $
003: * $Id:RegionSequenceMap.java 9134 2006-05-08 20:28:42Z chmaurer@iupui.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2005, 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.theospi.portfolio.presentation.tool;
021:
022: import java.util.Hashtable;
023: import java.util.Iterator;
024: import java.util.List;
025:
026: import javax.faces.context.FacesContext;
027: import javax.faces.el.ValueBinding;
028: import javax.faces.event.ActionEvent;
029:
030: import org.theospi.portfolio.presentation.model.PresentationPage;
031: import org.theospi.portfolio.presentation.model.PresentationPageItem;
032: import org.theospi.portfolio.presentation.model.PresentationPageRegion;
033:
034: /**
035: * Created by IntelliJ IDEA.
036: * User: John Ellis
037: * Date: Jan 2, 2006
038: * Time: 2:45:03 AM
039: * To change this template use File | Settings | File Templates.
040: */
041: public class RegionSequenceMap extends Hashtable {
042:
043: private PresentationPage page;
044: private int regionSeqNo = 0;
045: private List childRegions;
046:
047: public RegionSequenceMap(RegionMap map, int regionSeqNo) {
048: this .page = map.getPage();
049: setRegionSeqNo(regionSeqNo);
050: for (Iterator i = map.getPage().getRegions().iterator(); i
051: .hasNext();) {
052: PresentationPageRegion region = (PresentationPageRegion) i
053: .next();
054: put(region.getRegionId(), new DecoratedRegion(this , region,
055: regionSeqNo));
056: }
057: }
058:
059: public void remove(ActionEvent event) {
060: for (Iterator i = getChildRegions().iterator(); i.hasNext();) {
061: ValueBinding binding = (ValueBinding) i.next();
062: DecoratedRegion region = (DecoratedRegion) binding
063: .getValue(FacesContext.getCurrentInstance());
064: ;
065: removeItem(region.getBase());
066: region.setRegionItemList(null);
067: region.initRegionList();
068: }
069: }
070:
071: protected void removeItem(PresentationPageRegion region) {
072: for (Iterator i = region.getItems().iterator(); i.hasNext();) {
073: PresentationPageItem item = (PresentationPageItem) i.next();
074: if (item.getRegionItemSeq() == getRegionSeqNo()) {
075: i.remove();
076: }
077: }
078:
079: region.reorderItems();
080: }
081:
082: public List getChildRegions() {
083: return childRegions;
084: }
085:
086: public void setChildRegions(List childRegions) {
087: this .childRegions = childRegions;
088: }
089:
090: public PresentationPage getPage() {
091: return page;
092: }
093:
094: public void setPage(PresentationPage page) {
095: this .page = page;
096: }
097:
098: public int getRegionSeqNo() {
099: return regionSeqNo;
100: }
101:
102: public void setRegionSeqNo(int regionSeqNo) {
103: this .regionSeqNo = regionSeqNo;
104: }
105:
106: public synchronized Object get(Object key) {
107: return super.get(key);
108: }
109:
110: }
|