mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merge of all UI clustering changes originally applied to 2.2
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8292 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,202 +1,195 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.web.bean.preview;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.model.SelectItem;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.repository.FileTypeImageSize;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.TemplateImageResolver;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.BrowseBean;
|
||||
import org.alfresco.web.bean.NavigationBean;
|
||||
import org.alfresco.web.bean.TemplateSupportBean;
|
||||
import org.alfresco.web.bean.dialog.BaseDialogBean;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.data.IDataContainer;
|
||||
import org.alfresco.web.data.QuickSort;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
|
||||
/**
|
||||
* Backing bean for the Preview Document in Template action page
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public abstract class BasePreviewBean extends BaseDialogBean
|
||||
{
|
||||
/** BrowseBean instance */
|
||||
protected BrowseBean browseBean;
|
||||
|
||||
/** The NavigationBean bean reference */
|
||||
protected NavigationBean navigator;
|
||||
|
||||
/** The selected Template Id */
|
||||
protected NodeRef template;
|
||||
|
||||
|
||||
/**
|
||||
* @param browseBean The BrowseBean to set.
|
||||
*/
|
||||
public void setBrowseBean(BrowseBean browseBean)
|
||||
{
|
||||
this.browseBean = browseBean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param navigator The NavigationBean to set.
|
||||
*/
|
||||
public void setNavigator(NavigationBean navigator)
|
||||
{
|
||||
this.navigator = navigator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the node this bean is currently working with
|
||||
*
|
||||
* @return The current Node
|
||||
*/
|
||||
public abstract Node getNode();
|
||||
|
||||
/**
|
||||
* Returns the id of the current node
|
||||
*
|
||||
* @return The id
|
||||
*/
|
||||
public String getId()
|
||||
{
|
||||
return getNode().getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the current node
|
||||
*
|
||||
* @return Name of the current node
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return getNode().getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a model for use by the template on the Preview page.
|
||||
*
|
||||
* @return model containing current document/space info.
|
||||
*/
|
||||
public abstract Map getTemplateModel();
|
||||
|
||||
/** Template Image resolver helper */
|
||||
protected TemplateImageResolver imageResolver = new TemplateImageResolver()
|
||||
{
|
||||
public String resolveImagePathForName(String filename, FileTypeImageSize size)
|
||||
{
|
||||
return Utils.getFileTypeImage(FacesContext.getCurrentInstance(), filename, size);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @return the current template as a full NodeRef
|
||||
*/
|
||||
public NodeRef getTemplateRef()
|
||||
{
|
||||
return this.template;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the template Id.
|
||||
*/
|
||||
public String getTemplate()
|
||||
{
|
||||
return (this.template != null ? this.template.getId() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param template The template Id to set.
|
||||
*/
|
||||
public void setTemplate(String template)
|
||||
{
|
||||
if (template != null && template.equals(TemplateSupportBean.NO_SELECTION) == false)
|
||||
{
|
||||
this.template = new NodeRef(Repository.getStoreRef(), template);
|
||||
}
|
||||
}
|
||||
|
||||
private int findNextPreviewNode(List<Node> nodes, int start)
|
||||
{
|
||||
// search from start to end of list
|
||||
for (int i=start; i<nodes.size(); i++)
|
||||
{
|
||||
Node next = nodes.get(i);
|
||||
if (next.hasAspect(ContentModel.ASPECT_TEMPLATABLE))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
// search from zero index to start - 1 (to skip original node)
|
||||
for (int i=0; i<start - 1; i++)
|
||||
{
|
||||
Node next = nodes.get(i);
|
||||
if (next.hasAspect(ContentModel.ASPECT_TEMPLATABLE))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private int findPrevPreviewNode(List<Node> nodes, int start)
|
||||
{
|
||||
// search from start to beginning of list
|
||||
for (int i=start; i>=0; i--)
|
||||
{
|
||||
Node next = nodes.get(i);
|
||||
if (next.hasAspect(ContentModel.ASPECT_TEMPLATABLE))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
// end of list to start + 1 (to skip original node)
|
||||
for (int i=nodes.size() - 1; i>start; i--)
|
||||
{
|
||||
Node next = nodes.get(i);
|
||||
if (next.hasAspect(ContentModel.ASPECT_TEMPLATABLE))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.web.bean.preview;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.repository.FileTypeImageSize;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.TemplateImageResolver;
|
||||
import org.alfresco.web.bean.BrowseBean;
|
||||
import org.alfresco.web.bean.NavigationBean;
|
||||
import org.alfresco.web.bean.TemplateSupportBean;
|
||||
import org.alfresco.web.bean.dialog.BaseDialogBean;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
|
||||
/**
|
||||
* Backing bean for the Preview Document in Template action page
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public abstract class BasePreviewBean extends BaseDialogBean
|
||||
{
|
||||
/** BrowseBean instance */
|
||||
protected BrowseBean browseBean;
|
||||
|
||||
/** The NavigationBean bean reference */
|
||||
protected NavigationBean navigator;
|
||||
|
||||
/** The selected Template Id */
|
||||
protected NodeRef template;
|
||||
|
||||
|
||||
/**
|
||||
* @param browseBean The BrowseBean to set.
|
||||
*/
|
||||
public void setBrowseBean(BrowseBean browseBean)
|
||||
{
|
||||
this.browseBean = browseBean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param navigator The NavigationBean to set.
|
||||
*/
|
||||
public void setNavigator(NavigationBean navigator)
|
||||
{
|
||||
this.navigator = navigator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the node this bean is currently working with
|
||||
*
|
||||
* @return The current Node
|
||||
*/
|
||||
public abstract Node getNode();
|
||||
|
||||
/**
|
||||
* Returns the id of the current node
|
||||
*
|
||||
* @return The id
|
||||
*/
|
||||
public String getId()
|
||||
{
|
||||
return getNode().getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the current node
|
||||
*
|
||||
* @return Name of the current node
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return getNode().getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a model for use by the template on the Preview page.
|
||||
*
|
||||
* @return model containing current document/space info.
|
||||
*/
|
||||
public abstract Map getTemplateModel();
|
||||
|
||||
/** Template Image resolver helper */
|
||||
protected TemplateImageResolver imageResolver = new TemplateImageResolver()
|
||||
{
|
||||
public String resolveImagePathForName(String filename, FileTypeImageSize size)
|
||||
{
|
||||
return Utils.getFileTypeImage(FacesContext.getCurrentInstance(), filename, size);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @return the current template as a full NodeRef
|
||||
*/
|
||||
public NodeRef getTemplateRef()
|
||||
{
|
||||
return this.template;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the template Id.
|
||||
*/
|
||||
public String getTemplate()
|
||||
{
|
||||
return (this.template != null ? this.template.getId() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param template The template Id to set.
|
||||
*/
|
||||
public void setTemplate(String template)
|
||||
{
|
||||
if (template != null && template.equals(TemplateSupportBean.NO_SELECTION) == false)
|
||||
{
|
||||
this.template = new NodeRef(Repository.getStoreRef(), template);
|
||||
}
|
||||
}
|
||||
|
||||
private int findNextPreviewNode(List<Node> nodes, int start)
|
||||
{
|
||||
// search from start to end of list
|
||||
for (int i=start; i<nodes.size(); i++)
|
||||
{
|
||||
Node next = nodes.get(i);
|
||||
if (next.hasAspect(ContentModel.ASPECT_TEMPLATABLE))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
// search from zero index to start - 1 (to skip original node)
|
||||
for (int i=0; i<start - 1; i++)
|
||||
{
|
||||
Node next = nodes.get(i);
|
||||
if (next.hasAspect(ContentModel.ASPECT_TEMPLATABLE))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private int findPrevPreviewNode(List<Node> nodes, int start)
|
||||
{
|
||||
// search from start to beginning of list
|
||||
for (int i=start; i>=0; i--)
|
||||
{
|
||||
Node next = nodes.get(i);
|
||||
if (next.hasAspect(ContentModel.ASPECT_TEMPLATABLE))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
// end of list to start + 1 (to skip original node)
|
||||
for (int i=nodes.size() - 1; i>start; i--)
|
||||
{
|
||||
Node next = nodes.get(i);
|
||||
if (next.hasAspect(ContentModel.ASPECT_TEMPLATABLE))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user