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:
Gavin Cornwell
2008-02-15 14:59:11 +00:00
parent d20d8a7007
commit a450598ecb
281 changed files with 17771 additions and 15322 deletions

View File

@@ -24,6 +24,8 @@
*/
package org.alfresco.web.action;
import java.io.Serializable;
import org.alfresco.web.bean.repository.Node;
/**
@@ -36,7 +38,7 @@ import org.alfresco.web.bean.repository.Node;
*
* @author Kevin Roast
*/
public interface ActionEvaluator
public interface ActionEvaluator extends Serializable
{
/**
* The evaluator should decide if the action precondition is valid based on the appropriate

View File

@@ -1,90 +1,92 @@
/*
* 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.action.evaluator;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.ml.MultilingualContentService;
import org.alfresco.web.app.servlet.FacesHelper;
import org.alfresco.web.bean.users.UserPreferencesBean;
import org.alfresco.web.bean.ml.MultilingualUtils;
import org.alfresco.web.bean.repository.Node;
/**
* Evaluates whether the Add Translation (with or without content) action should be visible.
*
* If the node is not already Multilingual, locked, or if a translation exists for each available
* filter language, don't allow the action.
*
* The current user can add a translation to a translation set only if he has enough right to add
* a content to the space where the pivot translation is located in.
*
* @author Yannick Pignot
*/
public class AddTranslationEvaluator extends BaseActionEvaluator
{
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
boolean isNodeMultililingal = node.hasAspect(ContentModel.ASPECT_MULTILINGUAL_DOCUMENT);
boolean isMLContainer = node.getType().equals(ContentModel.TYPE_MULTILINGUAL_CONTAINER);
// the node must be multiligual (translation or ml container)
if(isNodeMultililingal || isMLContainer)
{
FacesContext fc = FacesContext.getCurrentInstance();
// the current user must have enough right to add a content to the space
// where the pivot translation is located in
if(MultilingualUtils.canAddChildrenToPivotSpace(node, fc))
{
MultilingualContentService mlservice =
(MultilingualContentService) FacesHelper.getManagedBean(fc, "MultilingualContentService");
UserPreferencesBean userprefs =
(UserPreferencesBean) FacesHelper.getManagedBean(fc, "UserPreferencesBean");
// the number of translation of this document
int availableTranslationCount = mlservice.getTranslations(node.getNodeRef()).size();
// the total number of available languages for the translation
int contentFilterLanguagesCount = userprefs.getContentFilterLanguages(false).length;
// the number of translation must be < to the total number of available language for the content filter
return (availableTranslationCount < contentFilterLanguagesCount);
}
else
{
return false;
}
}
else
{
return false;
}
}
/*
* 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.action.evaluator;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.ml.MultilingualContentService;
import org.alfresco.web.app.servlet.FacesHelper;
import org.alfresco.web.bean.users.UserPreferencesBean;
import org.alfresco.web.bean.ml.MultilingualUtils;
import org.alfresco.web.bean.repository.Node;
/**
* Evaluates whether the Add Translation (with or without content) action should be visible.
*
* If the node is not already Multilingual, locked, or if a translation exists for each available
* filter language, don't allow the action.
*
* The current user can add a translation to a translation set only if he has enough right to add
* a content to the space where the pivot translation is located in.
*
* @author Yannick Pignot
*/
public class AddTranslationEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = -1513219397606505237L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
boolean isNodeMultililingal = node.hasAspect(ContentModel.ASPECT_MULTILINGUAL_DOCUMENT);
boolean isMLContainer = node.getType().equals(ContentModel.TYPE_MULTILINGUAL_CONTAINER);
// the node must be multiligual (translation or ml container)
if(isNodeMultililingal || isMLContainer)
{
FacesContext fc = FacesContext.getCurrentInstance();
// the current user must have enough right to add a content to the space
// where the pivot translation is located in
if(MultilingualUtils.canAddChildrenToPivotSpace(node, fc))
{
MultilingualContentService mlservice =
(MultilingualContentService) FacesHelper.getManagedBean(fc, "MultilingualContentService");
UserPreferencesBean userprefs =
(UserPreferencesBean) FacesHelper.getManagedBean(fc, "UserPreferencesBean");
// the number of translation of this document
int availableTranslationCount = mlservice.getTranslations(node.getNodeRef()).size();
// the total number of available languages for the translation
int contentFilterLanguagesCount = userprefs.getContentFilterLanguages(false).length;
// the number of translation must be < to the total number of available language for the content filter
return (availableTranslationCount < contentFilterLanguagesCount);
}
else
{
return false;
}
}
else
{
return false;
}
}
}

View File

@@ -33,6 +33,8 @@ import org.alfresco.web.bean.repository.Node;
*/
public class ApproveDocEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 2958297435415449179L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/

View File

@@ -34,6 +34,8 @@ import org.alfresco.web.bean.repository.Node;
*/
public class ApproveNonDraftDocEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = -277600395385704689L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/

View File

@@ -35,6 +35,8 @@ import org.alfresco.web.bean.repository.Node;
*/
public class CancelCheckoutDocEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = -9015403093449070254L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/

View File

@@ -45,6 +45,8 @@ import org.alfresco.web.bean.repository.User;
*/
public class CancelWorkflowEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 7663087149225546333L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/

View File

@@ -35,6 +35,8 @@ import org.alfresco.web.bean.repository.Node;
*/
public class CheckinDocEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 5398249535631219663L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/

View File

@@ -39,6 +39,8 @@ import org.alfresco.web.bean.repository.Repository;
*/
public class CheckoutDocEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 5510366635124591353L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/

View File

@@ -42,6 +42,8 @@ import org.alfresco.web.bean.repository.Repository;
*/
public class CreateFormEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 4475319627518524432L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/

View File

@@ -34,6 +34,8 @@ import org.alfresco.web.bean.repository.Node;
*/
public class CreateForumNodeEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = -5132048668011887505L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/

View File

@@ -42,6 +42,8 @@ import org.alfresco.web.bean.repository.Repository;
*/
public class CreateWebProjectEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 9061864145360361349L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/

View File

@@ -46,6 +46,8 @@ import org.alfresco.web.bean.repository.Node;
*/
public class CutNodeEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 5162681242056158214L;
public boolean evaluate(Node node)
{

View File

@@ -39,6 +39,8 @@ import org.alfresco.web.bean.repository.Node;
*/
public class DeleteDocEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 5742287199692844685L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/

View File

@@ -42,6 +42,8 @@ import org.alfresco.web.bean.repository.Repository;
*/
public class DiscussNodeEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 8754174908349998903L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/

View File

@@ -43,6 +43,8 @@ import org.alfresco.web.bean.repository.Repository;
*/
public class DiscussionCopyEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = -4080878553011296677L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/

View File

@@ -42,6 +42,8 @@ import org.alfresco.web.bean.repository.Repository;
*/
public class DiscussionCutEvaluator extends CutNodeEvaluator
{
private static final long serialVersionUID = 7260556874788184200L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/

View File

@@ -41,6 +41,8 @@ import org.alfresco.web.bean.repository.Repository;
*/
public class EditDocCIFSEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = -8988276140748731926L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/

View File

@@ -41,6 +41,8 @@ import org.alfresco.web.bean.repository.Repository;
*/
public class EditDocHttpEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = -3694679925715830430L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/

View File

@@ -41,6 +41,8 @@ import org.alfresco.web.bean.repository.Repository;
*/
public class EditDocWebDavEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 293342561997588700L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/

View File

@@ -40,6 +40,8 @@ import org.alfresco.web.bean.repository.Repository;
*/
public class EditFormEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = -509493291648778510L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/

View File

@@ -41,6 +41,8 @@ import org.alfresco.web.bean.repository.Repository;
*/
public class ForumsCheckinDocEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = -924897450989526336L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/

View File

@@ -40,6 +40,8 @@ import org.alfresco.web.bean.repository.Node;
*/
public class MakeMultilingualEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 4417014487557744219L;
public boolean evaluate(Node node)
{
FacesContext fc = FacesContext.getCurrentInstance();

View File

@@ -36,6 +36,8 @@ import org.alfresco.web.bean.repository.Node;
*/
public class MultilingualDetailsEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 1154993208046462796L;
public boolean evaluate(Node node)
{
return (node.hasAspect(ContentModel.ASPECT_MULTILINGUAL_DOCUMENT) == true);

View File

@@ -39,6 +39,8 @@ import org.alfresco.web.bean.repository.Node;
*/
public class NewEditionEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = -7511956951071280506L;
public boolean evaluate(Node node)
{
FacesContext fc = FacesContext.getCurrentInstance();

View File

@@ -43,6 +43,8 @@ import org.alfresco.web.bean.repository.Repository;
*/
public class RegenerateRenditionsEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = -3479861093052578775L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/

View File

@@ -33,6 +33,8 @@ import org.alfresco.web.bean.repository.Node;
*/
public class RejectDocEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = -7733947744617999298L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/

View File

@@ -34,6 +34,8 @@ import org.alfresco.web.bean.repository.Node;
*/
public class RejectNonDraftDocEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 6296671033469500696L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/

View File

@@ -37,6 +37,8 @@ import org.alfresco.web.bean.repository.Node;
*/
public class ShortcutNodeEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 8768692540125721144L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/

View File

@@ -38,6 +38,8 @@ import org.alfresco.web.bean.repository.Node;
*/
public class StartWorkflowEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 3110333488835027710L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/

View File

@@ -33,6 +33,8 @@ import org.alfresco.web.bean.repository.Node;
*/
public class TakeOwnershipDocEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 3966463533922521230L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/

View File

@@ -33,6 +33,8 @@ import org.alfresco.web.bean.repository.Node;
*/
public class UnlockDocEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = -7056759932698306087L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/

View File

@@ -38,6 +38,8 @@ import org.alfresco.web.bean.repository.Repository;
*/
public class UpdateDocEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 6030963610213633893L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/

View File

@@ -43,6 +43,8 @@ import org.alfresco.web.bean.wcm.WebProject;
*/
public class WCMLockEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = -816856825850017138L;
/**
* @return true if the item is not locked by another user
*/

View File

@@ -35,6 +35,8 @@ import org.alfresco.web.bean.wcm.AVMUtil;
*/
public class WCMStagingReadonlyEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 2588681368739253602L;
/**
* @return true if the item is not locked by another user
*/

View File

@@ -41,6 +41,8 @@ import org.alfresco.web.bean.wcm.AVMUtil;
*/
public class WCMWorkflowDeletedEvaluator extends WCMLockEvaluator
{
private static final long serialVersionUID = -4341942166433855200L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/

View File

@@ -41,6 +41,8 @@ import org.alfresco.web.bean.wcm.AVMUtil;
*/
public class WCMWorkflowEvaluator extends WCMLockEvaluator
{
private static final long serialVersionUID = -5847066921917855781L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/