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,169 +1,174 @@
|
||||
/*
|
||||
* 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.ml;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.model.SelectItem;
|
||||
|
||||
import org.alfresco.i18n.I18NUtil;
|
||||
import org.alfresco.service.cmr.ml.MultilingualContentService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.users.UserPreferencesBean;
|
||||
import org.alfresco.web.bean.content.AddContentDialog;
|
||||
|
||||
/**
|
||||
* Dialog bean to upload a new document and to add it to an existing MLContainer.
|
||||
*
|
||||
* @author yanipig
|
||||
*/
|
||||
public class AddTranslationDialog extends AddContentDialog
|
||||
{
|
||||
private static final String MSG_OK = "ok";
|
||||
|
||||
private MultilingualContentService multilingualContentService;
|
||||
private UserPreferencesBean userPreferencesBean;
|
||||
|
||||
// the multilingual container where to add this translation
|
||||
protected NodeRef mlTranslation;
|
||||
|
||||
// Locale of the new translation
|
||||
private String language;
|
||||
|
||||
// languages available in the ML container yet
|
||||
private SelectItem[] unusedLanguages;
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.web.bean.content.AddContentDialog#init(java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public void init(Map<String, String> parameters)
|
||||
{
|
||||
super.init(parameters);
|
||||
|
||||
this.language = null;
|
||||
this.mlTranslation = this.browseBean.getDocument().getNodeRef();
|
||||
setFileName(null);
|
||||
unusedLanguages = null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.web.bean.content.AddContentDialog#finishImpl(javax.faces.context.FacesContext, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome) throws Exception
|
||||
{
|
||||
// add the new file to the repository
|
||||
outcome = super.finishImpl(context, outcome);
|
||||
|
||||
// add a new translation
|
||||
multilingualContentService.addTranslation(this.createdNode, this.mlTranslation, I18NUtil.parseLocale(this.language));
|
||||
|
||||
return "dialog:close:browse";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String cancel()
|
||||
{
|
||||
super.cancel();
|
||||
|
||||
return getDefaultFinishOutcome();
|
||||
}
|
||||
|
||||
public boolean getFinishButtonDisabled()
|
||||
{
|
||||
return author == null || author.length() < 1 || language == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the locale of this new translation
|
||||
*/
|
||||
public String getLanguage()
|
||||
{
|
||||
return language;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param language the locale of this new translation
|
||||
*/
|
||||
public void setLanguage(String language)
|
||||
{
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param unusedLanguages
|
||||
*/
|
||||
public void setUnusedLanguages(SelectItem[] unusedLanguages)
|
||||
{
|
||||
this.unusedLanguages = unusedLanguages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method calls by the dialog to limit the list of languages.
|
||||
*
|
||||
* @return the list of availables translation in the MLContainer
|
||||
*/
|
||||
|
||||
public SelectItem[] getUnusedLanguages()
|
||||
{
|
||||
if(unusedLanguages == null)
|
||||
{
|
||||
unusedLanguages = userPreferencesBean.getAvailablesContentFilterLanguages(this.mlTranslation, false);
|
||||
}
|
||||
|
||||
return unusedLanguages;
|
||||
}
|
||||
|
||||
public MultilingualContentService getMultilingualContentService()
|
||||
{
|
||||
return multilingualContentService;
|
||||
}
|
||||
|
||||
public void setMultilingualContentService(MultilingualContentService multilingualContentService)
|
||||
{
|
||||
this.multilingualContentService = multilingualContentService;
|
||||
}
|
||||
|
||||
public UserPreferencesBean getUserPreferencesBean()
|
||||
{
|
||||
return userPreferencesBean;
|
||||
}
|
||||
|
||||
public void setUserPreferencesBean(UserPreferencesBean userPreferencesBean)
|
||||
{
|
||||
this.userPreferencesBean = userPreferencesBean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFinishButtonLabel()
|
||||
{
|
||||
|
||||
return Application.getMessage(FacesContext.getCurrentInstance(), MSG_OK);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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.ml;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.model.SelectItem;
|
||||
|
||||
import org.alfresco.i18n.I18NUtil;
|
||||
import org.alfresco.service.cmr.ml.MultilingualContentService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.users.UserPreferencesBean;
|
||||
import org.alfresco.web.bean.content.AddContentDialog;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
|
||||
/**
|
||||
* Dialog bean to upload a new document and to add it to an existing MLContainer.
|
||||
*
|
||||
* @author yanipig
|
||||
*/
|
||||
public class AddTranslationDialog extends AddContentDialog
|
||||
{
|
||||
private static final long serialVersionUID = 5588241907778464543L;
|
||||
private static final String MSG_OK = "ok";
|
||||
|
||||
transient private MultilingualContentService multilingualContentService;
|
||||
private UserPreferencesBean userPreferencesBean;
|
||||
|
||||
// the multilingual container where to add this translation
|
||||
protected NodeRef mlTranslation;
|
||||
|
||||
// Locale of the new translation
|
||||
private String language;
|
||||
|
||||
// languages available in the ML container yet
|
||||
private SelectItem[] unusedLanguages;
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.web.bean.content.AddContentDialog#init(java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public void init(Map<String, String> parameters)
|
||||
{
|
||||
super.init(parameters);
|
||||
|
||||
this.language = null;
|
||||
this.mlTranslation = this.browseBean.getDocument().getNodeRef();
|
||||
setFileName(null);
|
||||
unusedLanguages = null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.web.bean.content.AddContentDialog#finishImpl(javax.faces.context.FacesContext, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome) throws Exception
|
||||
{
|
||||
// add the new file to the repository
|
||||
outcome = super.finishImpl(context, outcome);
|
||||
|
||||
// add a new translation
|
||||
getMultilingualContentService().addTranslation(this.createdNode, this.mlTranslation, I18NUtil.parseLocale(this.language));
|
||||
|
||||
return "dialog:close:browse";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String cancel()
|
||||
{
|
||||
super.cancel();
|
||||
|
||||
return getDefaultFinishOutcome();
|
||||
}
|
||||
|
||||
public boolean getFinishButtonDisabled()
|
||||
{
|
||||
return author == null || author.length() < 1 || language == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the locale of this new translation
|
||||
*/
|
||||
public String getLanguage()
|
||||
{
|
||||
return language;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param language the locale of this new translation
|
||||
*/
|
||||
public void setLanguage(String language)
|
||||
{
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param unusedLanguages
|
||||
*/
|
||||
public void setUnusedLanguages(SelectItem[] unusedLanguages)
|
||||
{
|
||||
this.unusedLanguages = unusedLanguages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method calls by the dialog to limit the list of languages.
|
||||
*
|
||||
* @return the list of availables translation in the MLContainer
|
||||
*/
|
||||
|
||||
public SelectItem[] getUnusedLanguages()
|
||||
{
|
||||
if(unusedLanguages == null)
|
||||
{
|
||||
unusedLanguages = userPreferencesBean.getAvailablesContentFilterLanguages(this.mlTranslation, false);
|
||||
}
|
||||
|
||||
return unusedLanguages;
|
||||
}
|
||||
|
||||
public MultilingualContentService getMultilingualContentService()
|
||||
{
|
||||
if (multilingualContentService == null)
|
||||
{
|
||||
multilingualContentService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getMultilingualContentService();
|
||||
}
|
||||
return multilingualContentService;
|
||||
}
|
||||
|
||||
public void setMultilingualContentService(MultilingualContentService multilingualContentService)
|
||||
{
|
||||
this.multilingualContentService = multilingualContentService;
|
||||
}
|
||||
|
||||
public UserPreferencesBean getUserPreferencesBean()
|
||||
{
|
||||
return userPreferencesBean;
|
||||
}
|
||||
|
||||
public void setUserPreferencesBean(UserPreferencesBean userPreferencesBean)
|
||||
{
|
||||
this.userPreferencesBean = userPreferencesBean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFinishButtonLabel()
|
||||
{
|
||||
return Application.getMessage(FacesContext.getCurrentInstance(), MSG_OK);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user