Phase one of merge of EC multilingual work

These files are their changes plus adjustments for formatting and immediate clashes
I anticipate that this will break the build, but there are too many changes coming to risk it.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5740 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2007-05-22 04:47:14 +00:00
parent ed5b547943
commit a266aab21c
48 changed files with 5780 additions and 1220 deletions

View File

@@ -0,0 +1,144 @@
/*
* 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.ui.repo.component;
import java.io.IOException;
import javax.faces.component.UISelectItems;
import javax.faces.component.UISelectOne;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.web.app.servlet.FacesHelper;
import org.alfresco.web.bean.UserPreferencesBean;
import org.alfresco.web.bean.users.SpaceUsersBean;
/**
* Component that holds a list of languages avalaiable to make a node multilingual.
*
*
* @author yanipig
*/
public class UILanguageSelector extends UISelectOne
{
public static final String COMPONENT_TYPE = "org.alfresco.faces.LanguageSelector";
public static final String COMPONENT_FAMILY = "javax.faces.SelectOne";
// If true, the langage list is filtered to return all the langages yet available in the
// MLContainer of the current node.
// An available langage is a language where any translation is set.
private boolean onlyAvailableLanguages = false;
// If true and if onlyAvailableLanguages, the list of available languages
// will be return with the language of the node.
// Used in the edit properties dialog.
private boolean returnCurrentLanguage = true;
@Override
@SuppressWarnings("unchecked")
public void encodeBegin(FacesContext context) throws IOException
{
// if the component does not have any children yet create the
// list of Languages the user can choose from as a child
// SelectItems component.
if (getChildren().size() == 0)
{
UISelectItems items = (UISelectItems) context.getApplication().
createComponent("javax.faces.SelectItems");
items.setId(this.getId() + "_items");
items.setValue(createList());
// add the child component
getChildren().add(items);
}
// do the default processing
super.encodeBegin(context);
}
/**
* Creates the list of SelectItem components to represent the list
* of Langages the user can select from
*
* @return List of SelectItem components
*/
protected SelectItem[] createList()
{
FacesContext fc = FacesContext.getCurrentInstance();
SpaceUsersBean spaceUserBean = (SpaceUsersBean) FacesHelper.getManagedBean(fc, "SpaceUsersBean");
UserPreferencesBean userPreferencesBean = (UserPreferencesBean) FacesHelper.getManagedBean(fc, "UserPreferencesBean");
// get the node ref
NodeRef nodeRef = spaceUserBean.getNode().getNodeRef();
if(this.onlyAvailableLanguages)
{
return userPreferencesBean.getAvailablesContentFilterLanguages(nodeRef, this.returnCurrentLanguage);
}
else
{
return userPreferencesBean.getContentFilterLanguages(false);
}
}
/**
* @return true if the list of languages is filtered
*/
public boolean isOnlyAvailableLanguages()
{
return onlyAvailableLanguages;
}
/**
* @param onlyAvailableLanguages the list of languages is filtered
*/
public void setOnlyAvailableLanguages(boolean onlyAvailableLanguages)
{
this.onlyAvailableLanguages = onlyAvailableLanguages;
}
/**
* @return true if the list must contain the language of the current node
*/
public boolean isReturnCurrentLanguage()
{
return returnCurrentLanguage;
}
/**
* Without effect if onlyAvailableLanguages is false
*
* @param returnCurrentLanguage the list must contain the language of the current node
*
*/
public void setReturnCurrentLanguage(boolean returnCurrentLanguage)
{
this.returnCurrentLanguage = returnCurrentLanguage;
}
}

View File

@@ -0,0 +1,86 @@
/*
* 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.ui.repo.converter;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import org.alfresco.i18n.I18NUtil;
import org.alfresco.service.cmr.ml.ContentFilterLanguagesService;
import org.alfresco.web.app.servlet.FacesHelper;
/**
* Converter class to convert a Locale into a language libelle
*
* @author yanipig
*/
public class LanguageConverter implements Converter
{
/**
* <p>The standard converter id for this converter.</p>
*/
public static final String CONVERTER_ID = "org.alfresco.faces.LanguageConverter";
/**
* @see javax.faces.convert.Converter#getAsObject(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.String)
*/
public Object getAsObject(FacesContext context, UIComponent component, String value)
{
if(value == null)
{
throw new IllegalArgumentException(I18NUtil.getMessage("error_locale_null"));
}
else
{
return value;
}
}
/**
* @see javax.faces.convert.Converter#getAsString(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.Object)
*/
public String getAsString(FacesContext context, UIComponent component, Object value)
{
if(value == null)
{
throw new IllegalArgumentException(I18NUtil.getMessage("error_locale_null"));
}
// if the component's rendrer type is javax.faces.Text, return
// the language label correponding to the received language code (as string) or the received locale
else if(component.getRendererType().equalsIgnoreCase("javax.faces.Text"))
{
ContentFilterLanguagesService contentFilterLanguagesService = (ContentFilterLanguagesService) FacesHelper.getManagedBean(FacesContext.getCurrentInstance(), "ContentFilterLanguagesService");
return contentFilterLanguagesService.getLabelByCode(value.toString());
}
// else don't modify
else
{
return value.toString();
}
}
}

View File

@@ -0,0 +1,154 @@
/*
* 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.ui.repo.tag;
import javax.faces.component.UIComponent;
import org.alfresco.web.ui.common.ComponentConstants;
import org.alfresco.web.ui.common.tag.HtmlComponentTag;
import org.alfresco.web.ui.repo.component.UILanguageSelector;
import org.alfresco.web.ui.repo.component.UIMimeTypeSelector;
/**
* Tag class for the Language selector component
*
* @author yanipig
*/
public class LanguageSelectorTag extends HtmlComponentTag
{
/** The value */
private String value;
/** Whether the component is disabled */
private String disabled;
/**
* If the value is 'true', only the missing translations of the node will be return
* Else returns all the languages
*/
private String onlyAvailable;
/**
* If the value is 'true', the language of the node will be returned.
*
* Without effect if <code>onlyAvailable</code> is 'false'
*/
private String returnCurLgge;
@Override
public String getComponentType()
{
return UILanguageSelector.COMPONENT_TYPE;
}
@Override
public String getRendererType()
{
return ComponentConstants.JAVAX_FACES_MENU;
}
@Override
protected void setProperties(UIComponent component)
{
super.setProperties(component);
setStringBindingProperty(component, "value", this.value);
setBooleanProperty(component, "disabled", this.disabled);
if(onlyAvailable != null && "true".equalsIgnoreCase(onlyAvailable))
{
UILanguageSelector lggSelector = (UILanguageSelector) getComponentInstance();
lggSelector.setOnlyAvailableLanguages(true);
if(returnCurLgge != null && "true".equalsIgnoreCase(returnCurLgge))
{
lggSelector.setReturnCurrentLanguage(true);
}
}
}
@Override
public void release()
{
super.release();
this.value = null;
this.disabled = null;
this.onlyAvailable = null;
}
/**
* Set the value
*
* @param value the value
*/
public void setValue(String value)
{
this.value = value;
}
/**
* Sets whether the component should be rendered in a disabled state
*
* @param disabled true to render the component in a disabled state
*/
public void setDisabled(String disabled)
{
this.disabled = disabled;
}
/**
* Sets whether the component should returns each language or only the available
* translations of the cuyrrent node.
*
* @param onlyAvailable
*/
public void setOnlyAvailable(String onlyAvailable)
{
this.onlyAvailable = onlyAvailable;
}
public String getOnlyAvailable()
{
return onlyAvailable;
}
public String getReturnCurLgge() {
return returnCurLgge;
}
/**
* Sets whether the component should returns the language of the node
*
* Without effect if <code>onlyAvailable</code> is false.
*
* @param returnCurLgge
*/
public void setReturnCurLgge(String returnCurLgge) {
this.returnCurLgge = returnCurLgge;
}
}