mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
. Fix for http://issues.alfresco.com/browse/AWC-1038 . Fix for http://issues.alfresco.com/browse/AWC-1072 . Encapsulation of NavigationBean toolbar location constants and I18N toolbar location labels git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4900 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -87,6 +87,10 @@ import org.apache.log4j.Priority;
|
||||
*/
|
||||
public class BrowseBean implements IContextListener
|
||||
{
|
||||
/** Public JSF Bean name */
|
||||
public static final String BEAN_NAME = "BrowseBean";
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Construction
|
||||
|
||||
|
@@ -35,7 +35,6 @@ import org.alfresco.service.cmr.security.AuthenticationService;
|
||||
import org.alfresco.service.cmr.security.PersonService;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.app.servlet.AuthenticationHelper;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.bean.repository.User;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
@@ -276,17 +275,8 @@ public class LoginBean
|
||||
}
|
||||
else
|
||||
{
|
||||
// setup the current location with the NavigationBean
|
||||
String location = this.preferences.getStartLocation();
|
||||
NavigationBean navBean = (NavigationBean)FacesHelper.getManagedBean(
|
||||
fc, "NavigationBean");
|
||||
if (navBean != null)
|
||||
{
|
||||
navBean.setToolbarLocation(location);
|
||||
}
|
||||
|
||||
// special case to handle jump to My Alfresco page initially
|
||||
if (NavigationBean.LOCATION_MYALFRESCO.equals(location))
|
||||
if (NavigationBean.LOCATION_MYALFRESCO.equals(this.preferences.getStartLocation()))
|
||||
{
|
||||
return "myalfresco";
|
||||
}
|
||||
|
@@ -44,7 +44,6 @@ import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.app.context.UIContextService;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.bean.repository.User;
|
||||
@@ -66,8 +65,6 @@ public class NavigationBean
|
||||
/** Public JSF Bean name */
|
||||
public static final String BEAN_NAME = "NavigationBean";
|
||||
|
||||
private static final String OUTCOME_MYALFRESCO = "myalfresco";
|
||||
private static final String OUTCOME_BROWSE = "browse";
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
@@ -190,7 +187,7 @@ public class NavigationBean
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the toolbar Location.
|
||||
* @return Returns the toolbar Location - initially set from the user preferences.
|
||||
*/
|
||||
public String getToolbarLocation()
|
||||
{
|
||||
@@ -198,17 +195,30 @@ public class NavigationBean
|
||||
{
|
||||
// if the toolbar location has not been set yet, try and get the
|
||||
// default via the user preferences object
|
||||
UserPreferencesBean prefsBean = (UserPreferencesBean)FacesHelper.getManagedBean(
|
||||
FacesContext.getCurrentInstance(), "UserPreferencesBean");
|
||||
if (prefsBean != null)
|
||||
this.toolbarLocation = this.preferences.getStartLocation();
|
||||
|
||||
// test that the user still has access to the specified location
|
||||
// the location will need to be reset if the user permissions are no longer valid
|
||||
if (NavigationBean.LOCATION_COMPANY.equals(this.toolbarLocation))
|
||||
{
|
||||
this.toolbarLocation = prefsBean.getStartLocation();
|
||||
if (getCompanyHomeVisible() == false)
|
||||
{
|
||||
this.toolbarLocation = null;
|
||||
}
|
||||
}
|
||||
else if (NavigationBean.LOCATION_GUEST.equals(this.toolbarLocation))
|
||||
{
|
||||
if (getGuestHomeVisible() == false)
|
||||
{
|
||||
this.toolbarLocation = null;
|
||||
}
|
||||
}
|
||||
|
||||
// if we still haven't found a location default to my home
|
||||
// if don't have a valid start location default to My Home
|
||||
if (this.toolbarLocation == null)
|
||||
{
|
||||
this.toolbarLocation = LOCATION_HOME;
|
||||
this.preferences.setStartLocation(this.toolbarLocation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -560,7 +570,7 @@ public class NavigationBean
|
||||
if (this.location == null)
|
||||
{
|
||||
// get the initial location from the user preferences
|
||||
processToolbarLocation(this.preferences.getStartLocation(), false);
|
||||
processToolbarLocation(getToolbarLocation(), false);
|
||||
}
|
||||
|
||||
return this.location;
|
||||
@@ -850,7 +860,14 @@ public class NavigationBean
|
||||
public static final String LOCATION_GUEST = "guesthome";
|
||||
public static final String LOCATION_MYALFRESCO = "myalfresco";
|
||||
|
||||
private static final String MSG_MYALFRESCO = "my_alfresco";
|
||||
/** constant value representing the display lables for toolbar locations */
|
||||
public static final String MSG_MYALFRESCO = "my_alfresco";
|
||||
public static final String MSG_MYHOME = "my_home";
|
||||
public static final String MSG_COMPANYHOME = "company_home";
|
||||
public static final String MSG_GUESTHOME = "guest_home";
|
||||
|
||||
private static final String OUTCOME_MYALFRESCO = "myalfresco";
|
||||
private static final String OUTCOME_BROWSE = "browse";
|
||||
|
||||
private static final String ERROR_DELETED_FOLDER = "error_deleted_folder";
|
||||
|
||||
|
@@ -28,6 +28,7 @@ import org.alfresco.config.Config;
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.i18n.I18NUtil;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.bean.repository.PreferencesService;
|
||||
import org.alfresco.web.config.LanguagesConfigElement;
|
||||
|
||||
@@ -39,10 +40,6 @@ import org.alfresco.web.config.LanguagesConfigElement;
|
||||
public class UserPreferencesBean
|
||||
{
|
||||
private static final String PREF_STARTLOCATION = "start-location";
|
||||
private static final String MSG_MYALFRESCO = "my_alfresco";
|
||||
private static final String MSG_MYHOME = "my_home";
|
||||
private static final String MSG_COMPANYHOME = "company_home";
|
||||
private static final String MSG_GUESTHOME = "guest_home";
|
||||
|
||||
private static final String PREF_CONTENTFILTERLANGUAGE = "content-filter-language";
|
||||
private static final String MSG_CONTENTALLLANGUAGES = "content_all_languages";
|
||||
@@ -53,33 +50,9 @@ public class UserPreferencesBean
|
||||
/** content language locale selection */
|
||||
private String contentFilterLanguage = null;
|
||||
|
||||
private SelectItem[] getLanguageItems(boolean includeAllLanguages)
|
||||
{
|
||||
Config config = Application.getConfigService(FacesContext.getCurrentInstance()).getConfig("Languages");
|
||||
LanguagesConfigElement langConfig = (LanguagesConfigElement)config.getConfigElement(
|
||||
LanguagesConfigElement.CONFIG_ELEMENT_ID);
|
||||
|
||||
List<String> languages = langConfig.getLanguages();
|
||||
List<SelectItem> items = new ArrayList<SelectItem>(20);
|
||||
if (includeAllLanguages)
|
||||
{
|
||||
ResourceBundle msg = Application.getBundle(FacesContext.getCurrentInstance());
|
||||
String allLanguagesStr = msg.getString(MSG_CONTENTALLLANGUAGES);
|
||||
items.add(new SelectItem(MSG_CONTENTALLLANGUAGES, allLanguagesStr));
|
||||
}
|
||||
for (String locale : languages)
|
||||
{
|
||||
// get label associated to the locale
|
||||
String label = langConfig.getLabelForLanguage(locale);
|
||||
items.add(new SelectItem(locale, label));
|
||||
}
|
||||
|
||||
SelectItem[] result = new SelectItem[items.size()];
|
||||
return items.toArray(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the available languages
|
||||
* @return the list of available languages
|
||||
*/
|
||||
public SelectItem[] getLanguages()
|
||||
{
|
||||
@@ -124,6 +97,9 @@ public class UserPreferencesBean
|
||||
Application.setLanguage(FacesContext.getCurrentInstance(), this.language);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return current content filter language
|
||||
*/
|
||||
public String getContentFilterLanguage()
|
||||
{
|
||||
if (this.contentFilterLanguage == null)
|
||||
@@ -143,7 +119,7 @@ public class UserPreferencesBean
|
||||
}
|
||||
|
||||
/**
|
||||
* @param languageStr A valid locale string or {@link #MSG_CONTENTALLLANGUAGES}
|
||||
* @param languageStr A valid locale string or {@link #MSG_CONTENTALLLANGUAGES}
|
||||
*/
|
||||
public void setContentFilterLanguage(String languageStr)
|
||||
{
|
||||
@@ -161,6 +137,9 @@ public class UserPreferencesBean
|
||||
PreferencesService.getPreferences().setValue(PREF_CONTENTFILTERLANGUAGE, language);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list of items for the content filtering language selection
|
||||
*/
|
||||
public SelectItem[] getContentFilterLanguages()
|
||||
{
|
||||
// Get the item selection list
|
||||
@@ -169,7 +148,39 @@ public class UserPreferencesBean
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to return the available language items
|
||||
*
|
||||
* @param includeAllLanguages True to include a marker item for "All Languages"
|
||||
* @return
|
||||
*/
|
||||
private static SelectItem[] getLanguageItems(boolean includeAllLanguages)
|
||||
{
|
||||
FacesContext fc = FacesContext.getCurrentInstance();
|
||||
Config config = Application.getConfigService(fc).getConfig("Languages");
|
||||
LanguagesConfigElement langConfig = (LanguagesConfigElement)config.getConfigElement(
|
||||
LanguagesConfigElement.CONFIG_ELEMENT_ID);
|
||||
|
||||
List<String> languages = langConfig.getLanguages();
|
||||
List<SelectItem> items = new ArrayList<SelectItem>(10);
|
||||
if (includeAllLanguages)
|
||||
{
|
||||
String allLanguagesStr = Application.getMessage(fc, MSG_CONTENTALLLANGUAGES);
|
||||
items.add(new SelectItem(MSG_CONTENTALLLANGUAGES, allLanguagesStr));
|
||||
}
|
||||
for (String locale : languages)
|
||||
{
|
||||
// get label associated to the locale
|
||||
String label = langConfig.getLabelForLanguage(locale);
|
||||
items.add(new SelectItem(locale, label));
|
||||
}
|
||||
|
||||
return items.toArray(new SelectItem[items.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the start location for this user (@see NavigationBean)
|
||||
*/
|
||||
public String getStartLocation()
|
||||
{
|
||||
String location = (String)PreferencesService.getPreferences().getValue(PREF_STARTLOCATION);
|
||||
@@ -181,18 +192,47 @@ public class UserPreferencesBean
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param location The current start location for this user (@see NavigationBean)
|
||||
*/
|
||||
public void setStartLocation(String location)
|
||||
{
|
||||
PreferencesService.getPreferences().setValue(PREF_STARTLOCATION, location);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the list of available start locations
|
||||
*/
|
||||
public SelectItem[] getStartLocations()
|
||||
{
|
||||
ResourceBundle msg = Application.getBundle(FacesContext.getCurrentInstance());
|
||||
return new SelectItem[] {
|
||||
new SelectItem(NavigationBean.LOCATION_MYALFRESCO, msg.getString(MSG_MYALFRESCO)),
|
||||
new SelectItem(NavigationBean.LOCATION_HOME, msg.getString(MSG_MYHOME)),
|
||||
new SelectItem(NavigationBean.LOCATION_COMPANY, msg.getString(MSG_COMPANYHOME)),
|
||||
new SelectItem(NavigationBean.LOCATION_GUEST, msg.getString(MSG_GUESTHOME))};
|
||||
FacesContext fc = FacesContext.getCurrentInstance();
|
||||
NavigationBean navigator = (NavigationBean)FacesHelper.getManagedBean(fc, "NavigationBean");
|
||||
ResourceBundle msg = Application.getBundle(fc);
|
||||
|
||||
List<SelectItem> locations = new ArrayList<SelectItem>(4);
|
||||
|
||||
// add My Alfresco location
|
||||
locations.add(new SelectItem(
|
||||
NavigationBean.LOCATION_MYALFRESCO, msg.getString(NavigationBean.MSG_MYALFRESCO)));
|
||||
|
||||
// add My Home location
|
||||
locations.add(new SelectItem(
|
||||
NavigationBean.LOCATION_HOME, msg.getString(NavigationBean.MSG_MYHOME)));
|
||||
|
||||
// add Company Home location if visible
|
||||
if (navigator.getCompanyHomeVisible())
|
||||
{
|
||||
locations.add(new SelectItem(
|
||||
NavigationBean.LOCATION_COMPANY, msg.getString(NavigationBean.MSG_COMPANYHOME)));
|
||||
}
|
||||
|
||||
// add Guest Home location if visible
|
||||
if (navigator.getGuestHomeVisible())
|
||||
{
|
||||
locations.add(new SelectItem(
|
||||
NavigationBean.LOCATION_GUEST, msg.getString(NavigationBean.MSG_GUESTHOME)));
|
||||
}
|
||||
|
||||
return locations.toArray(new SelectItem[locations.size()]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user