001/* 002 * (C) Copyright 2006-2007 Nuxeo SAS <http://nuxeo.com> and others 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the Eclipse Public License v1.0 006 * which accompanies this distribution, and is available at 007 * http://www.eclipse.org/legal/epl-v10.html 008 * 009 * Contributors: 010 * Jean-Marc Orliaguet, Chalmers 011 * 012 * $Id$ 013 */ 014 015package org.nuxeo.theme.html.filters.standalone; 016 017import org.nuxeo.theme.elements.Element; 018import org.nuxeo.theme.fragments.Fragment; 019import org.nuxeo.theme.perspectives.PerspectiveType; 020import org.nuxeo.theme.rendering.RenderingInfo; 021import org.nuxeo.theme.rendering.StandaloneFilter; 022import org.nuxeo.theme.themes.ThemeManager; 023 024public final class FragmentVisibility extends StandaloneFilter { 025 026 @Override 027 public RenderingInfo process(final RenderingInfo info, final boolean cache) { 028 final Element element = info.getElement(); 029 if (element.getElementType().getTypeName().equals("fragment")) { 030 final Fragment fragment = (Fragment) element; 031 final PerspectiveType perspective = ThemeManager.getPerspectiveByUrl(info.getThemeUrl()); 032 if (perspective != null) { 033 if (!fragment.isVisibleInPerspective(perspective)) { 034 return null; 035 } 036 } 037 } 038 return info; 039 } 040 041}