001: /**********************************************************************************
002: * $URL:https://source.sakaiproject.org/svn/osp/trunk/presentation/tool/src/java/org/theospi/portfolio/presentation/tool/DecoratedRegion.java $
003: * $Id:DecoratedRegion.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.ArrayList;
023: import java.util.List;
024:
025: import javax.faces.component.UIComponent;
026: import javax.faces.event.ActionEvent;
027:
028: import org.theospi.portfolio.presentation.component.SequenceComponent;
029: import org.theospi.portfolio.presentation.model.PresentationPageItem;
030: import org.theospi.portfolio.presentation.model.PresentationPageRegion;
031:
032: /**
033: * Created by IntelliJ IDEA.
034: * User: John Ellis
035: * Date: Jan 1, 2006
036: * Time: 5:59:36 PM
037: * To change this template use File | Settings | File Templates.
038: */
039: public class DecoratedRegion {
040:
041: private PresentationPageRegion region;
042: private int regionItemSeq = 0;
043: private RegionMap regionMap;
044: private List regionItemList = null;
045:
046: public DecoratedRegion(RegionMap regionMap,
047: PresentationPageRegion region) {
048: this .regionMap = regionMap;
049: this .region = region;
050: initRegionList();
051: }
052:
053: public DecoratedRegion(RegionSequenceMap regionMap,
054: PresentationPageRegion region, int regionItemSeq) {
055: this .region = region;
056: this .regionItemSeq = regionItemSeq;
057: }
058:
059: public PresentationPageRegion getBase() {
060: return region;
061: }
062:
063: public PresentationPageItem getItem() {
064: if (getRegion().getItems().size() <= 0) {
065: return null;
066: }
067: return (PresentationPageItem) getRegion().getItems().get(
068: regionItemSeq);
069: }
070:
071: public PresentationPageRegion getRegion() {
072: return region;
073: }
074:
075: public void setRegion(PresentationPageRegion region) {
076: this .region = region;
077: }
078:
079: public int getRegionItemSeq() {
080: return regionItemSeq;
081: }
082:
083: public void setRegionItemSeq(int regionItemSeq) {
084: this .regionItemSeq = regionItemSeq;
085: }
086:
087: public RegionMap getRegionMap() {
088: return regionMap;
089: }
090:
091: public void setRegionMap(RegionMap regionMap) {
092: this .regionMap = regionMap;
093: }
094:
095: public List getRegionItemList() {
096: return regionItemList;
097: }
098:
099: public void setRegionItemList(List regionItemList) {
100: this .regionItemList = regionItemList;
101: }
102:
103: public void initRegionList() {
104: regionItemList = new ArrayList();
105: for (int i = 0; i < getBase().getItems().size(); i++) {
106: regionItemList
107: .add(new RegionSequenceMap(getRegionMap(), i));
108: }
109: }
110:
111: public void addToSequence(ActionEvent event) {
112: UIComponent component = event.getComponent();
113:
114: while (!(component instanceof SequenceComponent)
115: && component != null) {
116: component = component.getParent();
117: }
118:
119: if (component != null) {
120: ((SequenceComponent) component).addToSequence();
121: }
122: }
123: }
|