001: /**********************************************************************************
002: * $URL:https://source.sakaiproject.org/svn/osp/trunk/wizard/tool/src/java/org/theospi/portfolio/wizard/tool/DecoratedCompletedCategory.java $
003: * $Id:DecoratedCompletedCategory.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.wizard.tool;
021:
022: import java.util.ArrayList;
023: import java.util.Iterator;
024: import java.util.List;
025:
026: import org.theospi.portfolio.wizard.WizardFunctionConstants;
027: import org.theospi.portfolio.wizard.model.CompletedWizardCategory;
028: import org.theospi.portfolio.wizard.model.CompletedWizardPage;
029: import org.theospi.portfolio.wizard.model.Wizard;
030:
031: /**
032: * Created by IntelliJ IDEA.
033: * User: John Ellis
034: * Date: Jan 24, 2006
035: * Time: 9:06:23 AM
036: * To change this template use File | Settings | File Templates.
037: */
038: public class DecoratedCompletedCategory {
039:
040: private WizardTool parent;
041: private DecoratedCategory category;
042: private CompletedWizardCategory base;
043:
044: private List categoryPageList = null;
045:
046: public DecoratedCompletedCategory() {
047: }
048:
049: public DecoratedCompletedCategory(WizardTool parent,
050: DecoratedCategory category, CompletedWizardCategory base) {
051: this .parent = parent;
052: this .category = category;
053: this .base = base;
054: }
055:
056: public WizardTool getParent() {
057: return parent;
058: }
059:
060: public void setParent(WizardTool parent) {
061: this .parent = parent;
062: }
063:
064: public DecoratedCategory getCategory() {
065: return category;
066: }
067:
068: public void setCategory(DecoratedCategory category) {
069: this .category = category;
070: }
071:
072: public CompletedWizardCategory getBase() {
073: return base;
074: }
075:
076: public void setBase(CompletedWizardCategory base) {
077: this .base = base;
078: }
079:
080: public List getCategoryPageList() {
081: if (categoryPageList == null) {
082: categoryPageList = new ArrayList();
083: addCategoriesPages(categoryPageList);
084: }
085: return categoryPageList;
086: }
087:
088: public void setCategoryPageList(List categoryPageList) {
089: this .categoryPageList = categoryPageList;
090: }
091:
092: protected List addCategoriesPages(List categoryPages) {
093: if (getParent().getCurrent().getBase().getType().equals(
094: WizardFunctionConstants.WIZARD_TYPE_HIERARCHICAL)) {
095: for (Iterator i = getBase().getChildCategories().iterator(); i
096: .hasNext();) {
097: CompletedWizardCategory category = (CompletedWizardCategory) i
098: .next();
099: DecoratedCategory decoratedCategory = new DecoratedCategory(
100: this .getCategory(), category.getCategory(),
101: getParent(), getCategory().getIndent() + 1);
102: DecoratedCompletedCategory completed = new DecoratedCompletedCategory(
103: getParent(), decoratedCategory, category);
104: categoryPages.add(completed);
105: if (category.isExpanded()) {
106: completed.addCategoriesPages(categoryPages);
107: }
108: }
109: }
110:
111: for (Iterator i = getBase().getChildPages().iterator(); i
112: .hasNext();) {
113: CompletedWizardPage page = (CompletedWizardPage) i.next();
114: DecoratedWizardPage decoratedPage = new DecoratedWizardPage(
115: this .getCategory(), page.getWizardPageDefinition(),
116: getParent(), getCategory().getIndent() + 1);
117: DecoratedCompletedPage completedPage = new DecoratedCompletedPage(
118: getParent(), decoratedPage, page);
119: categoryPages.add(completedPage);
120: }
121: return categoryPages;
122: }
123:
124: public DecoratedCategoryChild getCategoryChild() {
125: return (DecoratedCategoryChild) category;
126: }
127:
128: public String processActionExpandToggle() {
129: getBase().setExpanded(!getBase().isExpanded());
130: getParent().getCurrent().getRunningWizard().getRootCategory()
131: .setCategoryPageList(null);
132: return null;
133: }
134: }
|