001/* 002 * (C) Copyright 2006-2007 Nuxeo SAS (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * Nuxeo - initial API and implementation 016 * 017 * $Id: JOOoConvertPluginImpl.java 18651 2007-05-13 20:28:53Z sfermigier $ 018 */ 019 020package org.nuxeo.ecm.platform.picture.web; 021 022import static org.jboss.seam.ScopeType.CONVERSATION; 023 024import java.io.Serializable; 025import java.util.Collections; 026import java.util.List; 027 028import javax.faces.event.ActionEvent; 029 030import org.apache.commons.logging.Log; 031import org.apache.commons.logging.LogFactory; 032import org.jboss.seam.annotations.Create; 033import org.jboss.seam.annotations.Destroy; 034import org.jboss.seam.annotations.In; 035import org.jboss.seam.annotations.Name; 036import org.jboss.seam.annotations.Observer; 037import org.jboss.seam.annotations.Scope; 038import org.jboss.seam.annotations.intercept.BypassInterceptors; 039import org.nuxeo.ecm.core.api.CoreSession; 040import org.nuxeo.ecm.core.api.DocumentModel; 041import org.nuxeo.ecm.platform.ui.web.api.NavigationContext; 042import org.nuxeo.ecm.webapp.helpers.EventNames; 043 044/** 045 * @author <a href="mailto:ldoguin@nuxeo.com">Laurent Doguin</a> 046 * @deprecated since 6.0. See NXP-15370. 047 */ 048@Name("slideShowManager") 049@Scope(CONVERSATION) 050@Deprecated 051public class SlideShowManagerBean implements SlideShowManager, Serializable { 052 053 private static final long serialVersionUID = -3281363416111697725L; 054 055 private static final Log log = LogFactory.getLog(PictureBookManagerBean.class); 056 057 @In(create = true) 058 protected CoreSession documentManager; 059 060 @In(create = true) 061 protected transient NavigationContext navigationContext; 062 063 protected List<DocumentModel> children; 064 065 protected Integer childrenSize; 066 067 protected DocumentModel child; 068 069 protected Integer index; 070 071 protected Boolean stopped; 072 073 protected Boolean repeat; 074 075 @Create 076 public void initialize() { 077 log.debug("Initializing..."); 078 index = 1; 079 childrenSize = null; 080 stopped = false; 081 repeat = false; 082 } 083 084 @Override 085 public void firstPic() { 086 index = 1; 087 } 088 089 @Override 090 public void lastPic() { 091 index = getChildren().size(); 092 } 093 094 @Destroy 095 public void destroy() { 096 log.debug("Destroy"); 097 index = null; 098 child = null; 099 childrenSize = null; 100 stopped = null; 101 repeat = null; 102 } 103 104 @Override 105 public Integer getIndex() { 106 return index; 107 } 108 109 @Override 110 public void decIndex() { 111 index--; 112 } 113 114 @Override 115 public void incIndex() { 116 index++; 117 if ((index) > getChildrenSize()) { 118 if (repeat) { 119 index = 1; 120 } else { 121 index = childrenSize; 122 } 123 } 124 } 125 126 @Override 127 public void setIndex(Integer idx) { 128 index = idx; 129 } 130 131 @Override 132 @Observer({ EventNames.DOCUMENT_SELECTION_CHANGED, EventNames.DOCUMENT_CHILDREN_CHANGED }) 133 @BypassInterceptors 134 public void resetIndex() { 135 index = 1; 136 child = null; 137 children = null; 138 childrenSize = null; 139 stopped = false; 140 repeat = false; 141 } 142 143 @Override 144 public void inputValidation(ActionEvent arg0) { 145 if (getChildrenSize() < index) { 146 index = getChildrenSize(); 147 } 148 if (index <= 0) { 149 index = 1; 150 } 151 } 152 153 @Override 154 public Integer getChildrenSize() { 155 if (childrenSize == null) { 156 childrenSize = getChildren().size(); 157 } 158 return childrenSize; 159 } 160 161 @Override 162 public DocumentModel getChild() { 163 if (index > getChildrenSize()) { 164 index = childrenSize; 165 } 166 if (!getChildren().isEmpty()) { 167 return getChildren().get(index - 1); 168 } 169 return null; 170 } 171 172 protected List<DocumentModel> getChildren() { 173 if (children == null) { 174 DocumentModel currentDoc = navigationContext.getCurrentDocument(); 175 if (currentDoc != null) { 176 children = documentManager.getChildren(currentDoc.getRef()); 177 } else { 178 children = Collections.emptyList(); 179 } 180 } 181 return children; 182 } 183 184 @Override 185 public void setChild(DocumentModel child) { 186 this.child = child; 187 } 188 189 public void togglePause() { 190 stopped = true; 191 } 192 193 public void stop() { 194 index = 1; 195 stopped = true; 196 } 197 198 public void start() { 199 stopped = false; 200 } 201 202 public Boolean getStopped() { 203 return stopped; 204 } 205 206 public void toggleRepeat() { 207 repeat = !repeat; 208 } 209 210 public void setStopped(Boolean stopped) { 211 this.stopped = stopped; 212 } 213 214 public Boolean getRepeat() { 215 return repeat; 216 } 217 218 public void setRepeat(Boolean repeat) { 219 this.repeat = repeat; 220 } 221 222}