- Further work on the admin UI
- Refactored the GlobalizationHelper to use CDI for getting the current request. Also cleaned up the code.


git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@3892 8810af33-2d31-482b-a856-94f89814c4df
pull/2/head
jensp 2016-02-24 17:48:43 +00:00
parent 260978d1c1
commit 1b206fecef
22 changed files with 847 additions and 247 deletions

View File

@ -12,6 +12,9 @@
<Logger name="com.arsdigita.ui.admin.AdminServlet" <Logger name="com.arsdigita.ui.admin.AdminServlet"
level="debug"> level="debug">
</Logger> </Logger>
<Logger name="com.arsdigita.ui.admin.usersgroupsroles.UsersTable"
level="debug">
</Logger>
<Logger name="com.arsdigita.ui.login.UserLoginForm" <Logger name="com.arsdigita.ui.login.UserLoginForm"
level="debug"> level="debug">
</Logger> </Logger>

View File

@ -30,15 +30,21 @@ import com.arsdigita.bebop.parameters.ParameterData;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.Form; import com.arsdigita.bebop.Form;
import com.arsdigita.bebop.FormData; import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.parameters.*; import com.arsdigita.bebop.parameters.DateTimeParameter;
import com.arsdigita.bebop.parameters.IncompleteDateParameter;
import com.arsdigita.bebop.parameters.NotNullValidationListener;
// This interface contains the XML element name of this class // This interface contains the XML element name of this class
// in a constant which is used when generating XML // in a constant which is used when generating XML
import com.arsdigita.bebop.util.BebopConstants; import com.arsdigita.bebop.util.BebopConstants;
import com.arsdigita.globalization.GlobalizationHelper;
import com.arsdigita.bebop.util.GlobalizationUtil; import com.arsdigita.bebop.util.GlobalizationUtil;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.l10n.GlobalizationHelper;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Locale; import java.util.Locale;
@ -203,7 +209,8 @@ public class Date extends Widget implements BebopConstants {
public Date(ParameterModel model) { public Date(ParameterModel model) {
super(model); super(model);
if (!(model instanceof DateParameter || model instanceof DateTimeParameter)) { if (!(model instanceof DateParameter
|| model instanceof DateTimeParameter)) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"The Date widget " + model.getName() "The Date widget " + model.getName()
+ " must be backed by a DateParameter parmeter model"); + " must be backed by a DateParameter parmeter model");
@ -254,9 +261,12 @@ public class Date extends Widget implements BebopConstants {
// Create an empty year entry to unset a date, if either // Create an empty year entry to unset a date, if either
// a) skipYearAllowed is true // a) skipYearAllowed is true
// b) skipDayAllowed is true and skipMonthAllowed is true, to unset a date // b) skipDayAllowed is true and skipMonthAllowed is true, to unset a date
if (((IncompleteDateParameter) this.getParameterModel()).isSkipYearAllowed() if (((IncompleteDateParameter) this.getParameterModel())
|| (((IncompleteDateParameter) this.getParameterModel()).isSkipDayAllowed() .isSkipYearAllowed()
&& ((IncompleteDateParameter) this.getParameterModel()) || (((IncompleteDateParameter) this.getParameterModel())
.isSkipDayAllowed()
&& ((IncompleteDateParameter) this
.getParameterModel())
.isSkipMonthAllowed())) { .isSkipMonthAllowed())) {
m_year.addOption(new Option("", "")); m_year.addOption(new Option("", ""));
} }
@ -266,7 +276,7 @@ public class Date extends Widget implements BebopConstants {
m_year.addOption(new Option(String.valueOf(year))); m_year.addOption(new Option(String.valueOf(year)));
} }
} else { } else {
for(int year = m_year_end; year >= m_year_begin; year--) { for (int year = m_year_end; year >= m_year_begin; year--) {
m_year.addOption(new Option(String.valueOf(year))); m_year.addOption(new Option(String.valueOf(year)));
} }
} }
@ -305,8 +315,8 @@ public class Date extends Widget implements BebopConstants {
} }
/** /**
* Sets the <tt>MAXLENGTH</tt> attribute for the <tt>INPUT</tt> tag used to render this form * Sets the <tt>MAXLENGTH</tt> attribute for the <tt>INPUT</tt> tag used to
* element. * render this form element.
* *
* @param length * @param length
*/ */
@ -344,7 +354,8 @@ public class Date extends Widget implements BebopConstants {
Element date = parent.newChildElement(getElementTag(), BEBOP_XML_NS); Element date = parent.newChildElement(getElementTag(), BEBOP_XML_NS);
date.addAttribute("name", getParameterModel().getName()); date.addAttribute("name", getParameterModel().getName());
if (getLabel() != null) { if (getLabel() != null) {
date.addAttribute("label", (String) getLabel().localize(ps.getRequest())); date.addAttribute("label", (String) getLabel().localize(ps
.getRequest()));
} }
exportAttributes(date); exportAttributes(date);
generateDescriptionXML(ps, date); generateDescriptionXML(ps, date);
@ -360,7 +371,8 @@ public class Date extends Widget implements BebopConstants {
public void generateLocalizedWidget(PageState ps, Element date) { public void generateLocalizedWidget(PageState ps, Element date) {
Locale defaultLocale = Locale.getDefault(); Locale defaultLocale = Locale.getDefault();
Locale locale = GlobalizationHelper.getNegotiatedLocale(); Locale locale = CdiUtil.createCdiUtil().findBean(
GlobalizationHelper.class).getNegotiatedLocale();
// Get the current Pattern // Get the current Pattern
// XXX This is really, really, really, really, really, really bad // XXX This is really, really, really, really, really, really bad
@ -418,9 +430,9 @@ public class Date extends Widget implements BebopConstants {
} }
/** /**
* Sets the Form Object for this Widget. This method will throw an exception if the _form * Sets the Form Object for this Widget. This method will throw an exception
* pointer is already set. To explicity change the _form pointer the developer must first call * if the _form pointer is already set. To explicity change the _form
* setForm(null) * pointer the developer must first call setForm(null)
* *
* @param f the <code>Form</code> Object for this Widget. * @param f the <code>Form</code> Object for this Widget.
* *
@ -458,7 +470,8 @@ public class Date extends Widget implements BebopConstants {
private void populateMonthOptions() { private void populateMonthOptions() {
Locale locale = GlobalizationHelper.getNegotiatedLocale(); Locale locale = CdiUtil.createCdiUtil().findBean(
GlobalizationHelper.class).getNegotiatedLocale();
if (m_locale == null || (locale != null && !m_locale.equals(locale))) { if (m_locale == null || (locale != null && !m_locale.equals(locale))) {
@ -468,7 +481,8 @@ public class Date extends Widget implements BebopConstants {
m_month.clearOptions(); m_month.clearOptions();
if (this.getParameterModel() instanceof IncompleteDateParameter) { if (this.getParameterModel() instanceof IncompleteDateParameter) {
if (((IncompleteDateParameter) this.getParameterModel()).isSkipMonthAllowed()) { if (((IncompleteDateParameter) this.getParameterModel())
.isSkipMonthAllowed()) {
m_month.addOption(new Option("", "")); m_month.addOption(new Option("", ""));
} }
} }
@ -480,7 +494,8 @@ public class Date extends Widget implements BebopConstants {
m_month.addOption(new Option(String.valueOf(i), months[i])); m_month.addOption(new Option(String.valueOf(i), months[i]));
} }
} }
m_locale = GlobalizationHelper.getNegotiatedLocale(); m_locale = CdiUtil.createCdiUtil().findBean(
GlobalizationHelper.class).getNegotiatedLocale();
} }
} }

View File

@ -26,9 +26,9 @@ import com.arsdigita.bebop.parameters.ParameterData;
import com.arsdigita.bebop.parameters.ParameterModel; import com.arsdigita.bebop.parameters.ParameterModel;
import com.arsdigita.bebop.parameters.ParameterModelWrapper; import com.arsdigita.bebop.parameters.ParameterModelWrapper;
import com.arsdigita.bebop.util.BebopConstants; import com.arsdigita.bebop.util.BebopConstants;
import com.arsdigita.globalization.GlobalizationHelper;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import java.text.Collator; import java.text.Collator;
import java.util.Iterator; import java.util.Iterator;
@ -41,6 +41,8 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper; import javax.servlet.http.HttpServletRequestWrapper;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.l10n.GlobalizationHelper;
/** /**
* A class representing any widget that contains a list of options. * A class representing any widget that contains a list of options.
@ -56,13 +58,12 @@ public abstract class OptionGroup extends Widget implements BebopConstants {
private static final Logger LOGGER = Logger.getLogger(OptionGroup.class); private static final Logger LOGGER = Logger.getLogger(OptionGroup.class);
/** /**
* The XML element to be used by individual options belonging to this group. * The XML element to be used by individual options belonging to this group.
* This variable has to be initialized by every subclass of OptionGroup. * This variable has to be initialized by every subclass of OptionGroup.
* LEGACY: An abstract method would be the better design, but changing it * LEGACY: An abstract method would be the better design, but changing it
* would break the API. * would break the API.
*/ */
//protected String m_xmlElement; //protected String m_xmlElement;
// this only needs to be an ArrayList for multiple selection option groups // this only needs to be an ArrayList for multiple selection option groups
private List<String> m_selected; private List<String> m_selected;
private List<Option> m_options; private List<Option> m_options;
@ -82,20 +83,23 @@ public abstract class OptionGroup extends Widget implements BebopConstants {
// this is only used for single selection option groups // this is only used for single selection option groups
private final static String TOO_MANY_OPTIONS_SELECTED private final static String TOO_MANY_OPTIONS_SELECTED
= "Only one option may be selected by default on this option group."; = "Only one option may be selected by default on this option group.";
/**
/** request-local copy of selected elements, options */ * request-local copy of selected elements, options
*/
private final RequestLocal m_requestOptions = new RequestLocal() { private final RequestLocal m_requestOptions = new RequestLocal() {
@Override @Override
public Object initialValue(final PageState state) { public Object initialValue(final PageState state) {
return new ArrayList<Option>(); return new ArrayList<Option>();
} }
}; };
/** /**
* *
* @return * @return
*/ */
@Override @Override
public final boolean isCompound() { public final boolean isCompound() {
@ -104,6 +108,7 @@ public abstract class OptionGroup extends Widget implements BebopConstants {
/** /**
* The ParameterModel for multiple OptionGroups is always an array parameter * The ParameterModel for multiple OptionGroups is always an array parameter
*
* @param model * @param model
* *
* @param model * @param model
@ -150,9 +155,10 @@ public abstract class OptionGroup extends Widget implements BebopConstants {
public abstract String getOptionXMLElement(); public abstract String getOptionXMLElement();
/** /**
* This {@link Comparator} implementation is used to sort the list of options alphabetical. If * This {@link Comparator} implementation is used to sort the list of
* the sorting is ascending or descending depends on the selected sort mode. The Comparator * options alphabetical. If the sorting is ascending or descending depends
* needs the {@link PageState} for retrieving the localised labels from the options. * on the selected sort mode. The Comparator needs the {@link PageState} for
* retrieving the localised labels from the options.
*/ */
private class AlphabeticalSortComparator implements Comparator<Option> { private class AlphabeticalSortComparator implements Comparator<Option> {
@ -196,7 +202,8 @@ public abstract class OptionGroup extends Widget implements BebopConstants {
//Depending on the sort mode we compare label1 with label2 (ascending) or label2 with //Depending on the sort mode we compare label1 with label2 (ascending) or label2 with
//label1 (descending). //label1 (descending).
final Collator collator = Collator final Collator collator = Collator
.getInstance(GlobalizationHelper.getNegotiatedLocale()); .getInstance(CdiUtil.createCdiUtil().findBean(
GlobalizationHelper.class).getNegotiatedLocale());
if (sortMode == SortMode.ALPHABETICAL_ASCENDING) { if (sortMode == SortMode.ALPHABETICAL_ASCENDING) {
return collator.compare(label1, label2); return collator.compare(label1, label2);
} else if (sortMode == SortMode.ALPHABETICAL_DESENDING) { } else if (sortMode == SortMode.ALPHABETICAL_DESENDING) {
@ -209,8 +216,8 @@ public abstract class OptionGroup extends Widget implements BebopConstants {
} }
/** /**
* Returns an Iterator of all the default Options in this group, plus any request-specific * Returns an Iterator of all the default Options in this group, plus any
* options. * request-specific options.
* *
* @param state * @param state
* *
@ -220,7 +227,8 @@ public abstract class OptionGroup extends Widget implements BebopConstants {
List<Option> allOptions = new ArrayList<Option>(); List<Option> allOptions = new ArrayList<Option>();
allOptions.addAll(m_options); allOptions.addAll(m_options);
List<Option> requestOptions = (List<Option>) m_requestOptions.get(state); List<Option> requestOptions = (List<Option>) m_requestOptions.get(state);
for (Iterator<Option> iterator = requestOptions.iterator(); iterator.hasNext();) { for (Iterator<Option> iterator = requestOptions.iterator(); iterator
.hasNext();) {
final Option option = iterator.next(); final Option option = iterator.next();
if (!allOptions.contains(option)) { if (!allOptions.contains(option)) {
allOptions.add(option); allOptions.add(option);
@ -237,8 +245,9 @@ public abstract class OptionGroup extends Widget implements BebopConstants {
/** /**
* Adds a new option. * Adds a new option.
* *
* @param option The {@link Option} to be added. Note: the argument is modified and associated * @param option The {@link Option} to be added. Note: the argument is
* with this OptionGroup, regardless of what its group was. * modified and associated with this OptionGroup, regardless
* of what its group was.
*/ */
public void addOption(final Option option) { public void addOption(final Option option) {
addOption(option, null, false); addOption(option, null, false);
@ -246,9 +255,9 @@ public abstract class OptionGroup extends Widget implements BebopConstants {
/** /**
* Adds a new option. * Adds a new option.
* *
* @param opt * @param opt
* @param ps * @param ps
*/ */
public void addOption(final Option option, final PageState state) { public void addOption(final Option option, final PageState state) {
addOption(option, state, false); addOption(option, state, false);
@ -257,8 +266,9 @@ public abstract class OptionGroup extends Widget implements BebopConstants {
/** /**
* Adds a new option at the beginning of the list. * Adds a new option at the beginning of the list.
* *
* @param option The {@link Option} to be added. Note: the argument is modified and associated * @param option The {@link Option} to be added. Note: the argument is
* with this OptionGroup, regardless of what its group was. * modified and associated with this OptionGroup, regardless
* of what its group was.
*/ */
public void prependOption(final Option option) { public void prependOption(final Option option) {
addOption(option, null, true); addOption(option, null, true);
@ -273,15 +283,19 @@ public abstract class OptionGroup extends Widget implements BebopConstants {
} }
/** /**
* Adds a new option for the scope of the current request, or to the page * Adds a new option for the scope of the current request, or to the page as
* as a whole if there is no current request. * a whole if there is no current request.
* *
* @param option The {@link Option} to be added. Note: the argument is modified and associated * @param option The {@link Option} to be added. Note: the argument is
* with this OptionGroup, regardless of what its group was. * modified and associated with this OptionGroup, regardless
* @param state the current page state. if ps is null, adds option to the default option list. * of what its group was.
* @param prepend If true, prepend option to the list instead of appending it * @param state the current page state. if ps is null, adds option to the
* default option list.
* @param prepend If true, prepend option to the list instead of appending
* it
*/ */
public void addOption(final Option option, final PageState state, final boolean prepend) { public void addOption(final Option option, final PageState state,
final boolean prepend) {
List<Option> list = m_options; List<Option> list = m_options;
if (state == null) { if (state == null) {
Assert.isUnlocked(this); Assert.isUnlocked(this);
@ -312,11 +326,12 @@ public abstract class OptionGroup extends Widget implements BebopConstants {
} }
/** /**
* Removes the first option whose key is isEqual to the key that is * Removes the first option whose key is isEqual to the key that is passed
* passed in. * in.
*
* @param key * @param key
* @param state the current page state. if ps is null, adds option to * @param state the current page state. if ps is null, adds option to the
* the default option list. * default option list.
*/ */
public void removeOption(final String key, final PageState state) { public void removeOption(final String key, final PageState state) {
// This is not an entirely efficient technique. A more // This is not an entirely efficient technique. A more
@ -345,10 +360,12 @@ public abstract class OptionGroup extends Widget implements BebopConstants {
* *
* @param label * @param label
* @param width The width, in characters, of the "Other" entry area * @param width The width, in characters, of the "Other" entry area
* @param height The height, in characters, of the "Other" entry area. If this is 1 then a * @param height The height, in characters, of the "Other" entry area. If
* TextField is used. Otherwise a TextArea is used. * this is 1 then a TextField is used. Otherwise a TextArea is
* used.
*/ */
public void addOtherOption(final String label, final int width, final int height) { public void addOtherOption(final String label, final int width,
final int height) {
Assert.isUnlocked(this); Assert.isUnlocked(this);
final Option otherOption = new Option(OTHER_OPTION, label); final Option otherOption = new Option(OTHER_OPTION, label);
@ -383,12 +400,14 @@ public abstract class OptionGroup extends Widget implements BebopConstants {
setParameterModel(new ParameterModelWrapper(model) { setParameterModel(new ParameterModelWrapper(model) {
@Override @Override
public ParameterData createParameterData(final HttpServletRequest request, public ParameterData createParameterData(
Object defaultValue, final HttpServletRequest request,
boolean isSubmission) { Object defaultValue,
boolean isSubmission) {
final String[] values = request.getParameterValues(getName()); final String[] values = request.getParameterValues(getName());
String[] otherValues = request.getParameterValues(getName() + ".other"); String[] otherValues = request.getParameterValues(getName()
+ ".other");
String other = (null == otherValues) ? null : otherValues[0]; String other = (null == otherValues) ? null : otherValues[0];
@ -402,7 +421,8 @@ public abstract class OptionGroup extends Widget implements BebopConstants {
LOGGER.debug("createParameterData in OptionGroup"); LOGGER.debug("createParameterData in OptionGroup");
return super.createParameterData(new HttpServletRequestWrapper(request) { return super.createParameterData(new HttpServletRequestWrapper(
request) {
@Override @Override
public String[] getParameterValues(String key) { public String[] getParameterValues(String key) {
@ -426,10 +446,10 @@ public abstract class OptionGroup extends Widget implements BebopConstants {
} }
/** /**
* Make an option selected by default. Updates the parameter model for * Make an option selected by default. Updates the parameter model for the
* the option group accordingly. * option group accordingly.
* *
* @param value the value of the option to be added to the * @param value the value of the option to be added to the
* by-default-selected set. * by-default-selected set.
*/ */
public void setOptionSelected(final String value) { public void setOptionSelected(final String value) {
@ -466,13 +486,13 @@ public abstract class OptionGroup extends Widget implements BebopConstants {
} }
/** /**
* Whether this a multiple (and not single) selection option group. * Whether this a multiple (and not single) selection option group. Note
* Note that this should really be declared abstract, but we can't because * that this should really be declared abstract, but we can't because it
* it used to be in the direct subclass Select and making it abstract could * used to be in the direct subclass Select and making it abstract could
* break other subclasses that don't declare isMultiple. So we have a * break other subclasses that don't declare isMultiple. So we have a
* trivial implementation instead. * trivial implementation instead.
* *
* @return true if this OptionGroup can have more than one selected option; * @return true if this OptionGroup can have more than one selected option;
* false otherwise. * false otherwise.
*/ */
public boolean isMultiple() { public boolean isMultiple() {
@ -524,13 +544,14 @@ public abstract class OptionGroup extends Widget implements BebopConstants {
*/ */
@Override @Override
public void generateWidget(final PageState state, final Element parent) { public void generateWidget(final PageState state, final Element parent) {
final Element optionGroup = parent.newChildElement(getElementTag(), BEBOP_XML_NS); final Element optionGroup = parent.newChildElement(getElementTag(),
BEBOP_XML_NS);
optionGroup.addAttribute("name", getName()); optionGroup.addAttribute("name", getName());
optionGroup.addAttribute("class", getName().replace(".", " ")); optionGroup.addAttribute("class", getName().replace(".", " "));
// Localized title for this option group // Localized title for this option group
if (getLabel() != null) { if (getLabel() != null) {
optionGroup.addAttribute("label", (String)getLabel() optionGroup.addAttribute("label", (String) getLabel()
.localize(state.getRequest())); .localize(state.getRequest()));
} }
if (isMultiple()) { if (isMultiple()) {
optionGroup.addAttribute("multiple", "multiple"); optionGroup.addAttribute("multiple", "multiple");
@ -545,7 +566,7 @@ public abstract class OptionGroup extends Widget implements BebopConstants {
//If the sort mode is not {@code NO_SORT}, sort the the list. //If the sort mode is not {@code NO_SORT}, sort the the list.
if (sortMode != SortMode.NO_SORT) { if (sortMode != SortMode.NO_SORT) {
//If exclude first is sest to true the first option should stay on the top. //If exclude first is sest to true the first option should stay on the top.
//We simply remove the first option from our list and generate the XML for it here. //We simply remove the first option from our list and generate the XML for it here.
if (excludeFirst && !options.isEmpty()) { if (excludeFirst && !options.isEmpty()) {

View File

@ -29,9 +29,12 @@ import com.arsdigita.bebop.parameters.ParameterModel;
import com.arsdigita.bebop.parameters.TimeParameter; import com.arsdigita.bebop.parameters.TimeParameter;
import com.arsdigita.bebop.util.BebopConstants; import com.arsdigita.bebop.util.BebopConstants;
import com.arsdigita.globalization.GlobalizationHelper;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.l10n.GlobalizationHelper;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.DateFormatSymbols; import java.text.DateFormatSymbols;
@ -64,9 +67,11 @@ public class Time extends Widget implements BebopConstants {
super(name); super(name);
this.parent = parent; this.parent = parent;
if (has12HourClock()) { if (has12HourClock()) {
this.addValidationListener(new NumberInRangeValidationListener(1, 12)); this.addValidationListener(
new NumberInRangeValidationListener(1, 12));
} else { } else {
this.addValidationListener(new NumberInRangeValidationListener(1, 24)); this.addValidationListener(
new NumberInRangeValidationListener(1, 24));
} }
} }
@ -87,6 +92,7 @@ public class Time extends Widget implements BebopConstants {
return parent.getFragmentValue(ps, Calendar.HOUR_OF_DAY); return parent.getFragmentValue(ps, Calendar.HOUR_OF_DAY);
} }
} }
} }
private class MinuteFragment extends TextField { private class MinuteFragment extends TextField {
@ -96,7 +102,8 @@ public class Time extends Widget implements BebopConstants {
public MinuteFragment(String name, Time parent) { public MinuteFragment(String name, Time parent) {
super(name); super(name);
this.parent = parent; this.parent = parent;
this.addValidationListener(new NumberInRangeValidationListener(0, 59)); this.addValidationListener(
new NumberInRangeValidationListener(0, 59));
} }
@Override @Override
@ -120,6 +127,7 @@ public class Time extends Widget implements BebopConstants {
return min.toString(); return min.toString();
} }
} }
} }
private class SecondFragment extends TextField { private class SecondFragment extends TextField {
@ -129,7 +137,8 @@ public class Time extends Widget implements BebopConstants {
public SecondFragment(String name, Time parent) { public SecondFragment(String name, Time parent) {
super(name); super(name);
this.parent = parent; this.parent = parent;
this.addValidationListener(new NumberInRangeValidationListener(0, 59)); this.addValidationListener(
new NumberInRangeValidationListener(0, 59));
} }
@Override @Override
@ -153,6 +162,7 @@ public class Time extends Widget implements BebopConstants {
return sec.toString(); return sec.toString();
} }
} }
} }
private class AmPmFragment extends SingleSelect { private class AmPmFragment extends SingleSelect {
@ -177,20 +187,26 @@ public class Time extends Widget implements BebopConstants {
public Object getValue(PageState ps) { public Object getValue(PageState ps) {
return parent.getFragmentValue(ps, Calendar.AM_PM); return parent.getFragmentValue(ps, Calendar.AM_PM);
} }
} }
/** Constructor. */ /**
* Constructor.
*/
public Time(ParameterModel model) { public Time(ParameterModel model) {
this(model, false); this(model, false);
} }
/** Constructor. */ /**
* Constructor.
*/
public Time(ParameterModel model, boolean showSeconds) { public Time(ParameterModel model, boolean showSeconds) {
super(model); super(model);
if (!(model instanceof TimeParameter || model instanceof DateTimeParameter)) { if (!(model instanceof TimeParameter
|| model instanceof DateTimeParameter)) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"The Time widget " + model.getName() "The Time widget " + model.getName()
+ " must be backed by a TimeParameter parameter model"); + " must be backed by a TimeParameter parameter model");
} }
@ -232,14 +248,16 @@ public class Time extends Widget implements BebopConstants {
this(new TimeParameter(name)); this(new TimeParameter(name));
} }
/** Returns a string naming the type of this widget. */ /**
* Returns a string naming the type of this widget.
*/
public String getType() { public String getType() {
return "time"; return "time";
} }
/** /**
* Sets the <tt>MAXLENGTH</tt> attributes for the <tt>INPUT</tt> tag * Sets the <tt>MAXLENGTH</tt> attributes for the <tt>INPUT</tt> tag used to
* used to render this form element. * render this form element.
*/ */
public void setMaxLength(int length) { public void setMaxLength(int length) {
setAttribute("MAXLENGTH", String.valueOf(length)); setAttribute("MAXLENGTH", String.valueOf(length));
@ -249,7 +267,9 @@ public class Time extends Widget implements BebopConstants {
return true; return true;
} }
/** The XML tag for this derived class of Widget. */ /**
* The XML tag for this derived class of Widget.
*/
@Override @Override
protected String getElementTag() { protected String getElementTag() {
return BEBOP_TIME; return BEBOP_TIME;
@ -309,12 +329,12 @@ public class Time extends Widget implements BebopConstants {
} }
/** /**
* Sets the Form Object for this Widget. This method will throw an * Sets the Form Object for this Widget. This method will throw an exception
* exception if the _form pointer is already set. To explicity * if the _form pointer is already set. To explicity change the _form
* change the _form pointer the developer must first call * pointer the developer must first call setForm(null)
* setForm(null)
* *
* @param the <code>Form</code> Object for this Widget. * @param the <code>Form</code> Object for this Widget.
*
* @exception IllegalStateException if form already set. * @exception IllegalStateException if form already set.
*/ */
@Override @Override
@ -347,9 +367,12 @@ public class Time extends Widget implements BebopConstants {
} }
private boolean has12HourClock() { private boolean has12HourClock() {
Locale locale = GlobalizationHelper.getNegotiatedLocale(); Locale locale = CdiUtil.createCdiUtil().findBean(
DateFormat format_12Hour = DateFormat.getTimeInstance(DateFormat.SHORT, Locale.US); GlobalizationHelper.class).getNegotiatedLocale();
DateFormat format_locale = DateFormat.getTimeInstance(DateFormat.SHORT, locale); DateFormat format_12Hour = DateFormat.getTimeInstance(DateFormat.SHORT,
Locale.US);
DateFormat format_locale = DateFormat.getTimeInstance(DateFormat.SHORT,
locale);
String midnight = ""; String midnight = "";
try { try {
@ -359,4 +382,5 @@ public class Time extends Widget implements BebopConstants {
return midnight.contains("12"); return midnight.contains("12");
} }
} }

View File

@ -21,7 +21,6 @@ package com.arsdigita.bebop.page;
import com.arsdigita.bebop.BebopConfig; import com.arsdigita.bebop.BebopConfig;
import com.arsdigita.dispatcher.DispatcherHelper; import com.arsdigita.dispatcher.DispatcherHelper;
import com.arsdigita.globalization.Globalization; import com.arsdigita.globalization.Globalization;
import com.arsdigita.globalization.GlobalizationHelper;
import com.arsdigita.kernel.KernelConfig; import com.arsdigita.kernel.KernelConfig;
import com.arsdigita.templating.PresentationManager; import com.arsdigita.templating.PresentationManager;
import com.arsdigita.templating.Templating; import com.arsdigita.templating.Templating;
@ -56,6 +55,8 @@ import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamResult;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.l10n.GlobalizationHelper;
/** /**
* A class for managing and obtaining a Stylesheet based on the current * A class for managing and obtaining a Stylesheet based on the current
@ -197,7 +198,9 @@ public class PageTransformer implements PresentationManager {
@Override @Override
public String generateValue( public String generateValue(
HttpServletRequest request) { HttpServletRequest request) {
return GlobalizationHelper return CdiUtil.createCdiUtil()
.findBean(
GlobalizationHelper.class)
.getNegotiatedLocale() .getNegotiatedLocale()
.getLanguage(); .getLanguage();
} }
@ -211,8 +214,10 @@ public class PageTransformer implements PresentationManager {
public String generateValue( public String generateValue(
HttpServletRequest request) { HttpServletRequest request) {
Locale selectedLocale Locale selectedLocale
= com.arsdigita.globalization.GlobalizationHelper = CdiUtil.createCdiUtil()
.getSelectedLocale(request); .findBean(
GlobalizationHelper.class)
.getSelectedLocale();
return (selectedLocale != null) return (selectedLocale != null)
? selectedLocale ? selectedLocale
.toString() : ""; .toString() : "";

View File

@ -19,20 +19,21 @@
package com.arsdigita.bebop.parameters; package com.arsdigita.bebop.parameters;
import com.arsdigita.globalization.Globalization; import com.arsdigita.globalization.Globalization;
import com.arsdigita.globalization.GlobalizationHelper;
import com.arsdigita.util.StringUtils; import com.arsdigita.util.StringUtils;
import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.l10n.GlobalizationHelper;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.ParseException; import java.text.ParseException;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import java.util.Locale; import java.util.Locale;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
/** /**
* A class that represents the model for a time form parameter. * A class that represents the model for a time form parameter.
* *
@ -40,57 +41,58 @@ import javax.servlet.http.HttpServletRequest;
* @author Dave Turner * @author Dave Turner
* @version $Id$ * @version $Id$
*/ */
public class TimeParameter extends ParameterModel public class TimeParameter extends ParameterModel {
{
public TimeParameter ( String name ) { public TimeParameter(String name) {
super(name); super(name);
} }
/** /**
* This method returns a new Calendar object that is manipulated * This method returns a new Calendar object that is manipulated within
* within transformValue to create a Date Object. This method should * transformValue to create a Date Object. This method should be overridden
* be overridden if you wish to use a Calendar other than the * if you wish to use a Calendar other than the lenient GregorianCalendar.
* lenient GregorianCalendar.
* *
* @param request the servlet request from which Locale can be * @param request the servlet request from which Locale can be extracted if
* extracted if needed * needed
* *
* @return a new Calendar object * @return a new Calendar object
* */ *
*/
protected Calendar getCalendar(HttpServletRequest request) { protected Calendar getCalendar(HttpServletRequest request) {
return new GregorianCalendar(); return new GregorianCalendar();
} }
/** /**
* Computes a dateTime object from multiple parameters in the * Computes a dateTime object from multiple parameters in the request. This
* request. This method searches for parameters named * method searches for parameters named <code>getName() + ".hour"<code>,
* <code>getName() + ".hour"<code>,
* <code>getName() + ".minute"<code>, * <code>getName() + ".minute"<code>,
* <code>getName() + ".second"<code>, and * <code>getName() + ".second"<code>, and
* <code>getName() + ".amOrPm"<code>. * <code>getName() + ".amOrPm"<code>.
* */ *
*/
public Object transformValue(HttpServletRequest request) public Object transformValue(HttpServletRequest request)
throws IllegalArgumentException { throws IllegalArgumentException {
Calendar c = getCalendar(request); Calendar c = getCalendar(request);
c.clear(); c.clear();
String hour = Globalization.decodeParameter(request, getName()+".hour"); String hour = Globalization
String minute = Globalization.decodeParameter(request, getName()+".minute"); .decodeParameter(request, getName() + ".hour");
String second = Globalization.decodeParameter(request, getName()+".second"); String minute = Globalization.decodeParameter(request, getName()
String amOrPm = Globalization.decodeParameter(request, getName()+".amOrPm"); + ".minute");
String second = Globalization.decodeParameter(request, getName()
if (StringUtils.emptyString(hour) && + ".second");
StringUtils.emptyString(minute) && String amOrPm = Globalization.decodeParameter(request, getName()
StringUtils.emptyString(second)) { + ".amOrPm");
if (StringUtils.emptyString(hour) && StringUtils.emptyString(minute)
&& StringUtils.emptyString(second)) {
return transformSingleValue(request); return transformSingleValue(request);
} }
if (!StringUtils.emptyString(hour)) { if (!StringUtils.emptyString(hour)) {
int hourInt = Integer.parseInt(hour); int hourInt = Integer.parseInt(hour);
/* Das ist alles Blödsinn. Beim 24-Stundenformat brauchen wir das sowieso nicht. /* Das ist alles Blödsinn. Beim 24-Stundenformat brauchen wir das sowieso nicht.
Beim 12-Stunden-Formato müßte es, wenn überhaupt, anderherum sein: Aus einer Beim 12-Stunden-Formato müßte es, wenn überhaupt, anderherum sein: Aus einer
eingetragenen 0 in den Stunden muß eine 12 werden. ABER: Die Informationen eingetragenen 0 in den Stunden muß eine 12 werden. ABER: Die Informationen
werden in einem Calendar-Object gespeichert, das intern immer 24-Stunden-Format werden in einem Calendar-Object gespeichert, das intern immer 24-Stunden-Format
@ -100,7 +102,7 @@ zu 0:00 Uhr wird.
if ((hourInt == 12) && has12HourClock()) { if ((hourInt == 12) && has12HourClock()) {
hourInt = 0; hourInt = 0;
} }
*/ */
c.set(Calendar.HOUR, hourInt); c.set(Calendar.HOUR, hourInt);
} }
@ -112,35 +114,38 @@ zu 0:00 Uhr wird.
c.set(Calendar.SECOND, Integer.parseInt(second)); c.set(Calendar.SECOND, Integer.parseInt(second));
} }
if ( amOrPm != null ) { if (amOrPm != null) {
c.set(Calendar.AM_PM, Integer.parseInt(amOrPm)); c.set(Calendar.AM_PM, Integer.parseInt(amOrPm));
} }
return c.getTime(); return c.getTime();
} }
public Object unmarshal(String encoded) {
public Object unmarshal ( String encoded ) {
try { try {
return new Date(Long.parseLong(encoded)); return new Date(Long.parseLong(encoded));
} catch ( NumberFormatException ex ) { } catch (NumberFormatException ex) {
throw new IllegalArgumentException("Cannot unmarshal time '" throw new IllegalArgumentException("Cannot unmarshal time '"
+ encoded + "': " + ex.getMessage()); + encoded + "': " + ex
.getMessage());
} }
} }
public String marshal ( Object value ) { public String marshal(Object value) {
return Long.toString(((Date)value).getTime()); return Long.toString(((Date) value).getTime());
} }
public Class getValueClass () { public Class getValueClass() {
return Date.class; return Date.class;
} }
private boolean has12HourClock() { private boolean has12HourClock() {
Locale locale = GlobalizationHelper.getNegotiatedLocale(); Locale locale = CdiUtil.createCdiUtil().findBean(
DateFormat format_12Hour = DateFormat.getTimeInstance(DateFormat.SHORT, Locale.US); GlobalizationHelper.class).getNegotiatedLocale();
DateFormat format_locale = DateFormat.getTimeInstance(DateFormat.SHORT, locale); DateFormat format_12Hour = DateFormat.getTimeInstance(DateFormat.SHORT,
Locale.US);
DateFormat format_locale = DateFormat.getTimeInstance(DateFormat.SHORT,
locale);
String midnight = ""; String midnight = "";
try { try {
@ -150,4 +155,5 @@ zu 0:00 Uhr wird.
return midnight.contains("12"); return midnight.contains("12");
} }
} }

View File

@ -22,8 +22,12 @@ import java.text.MessageFormat;
import java.util.Locale; import java.util.Locale;
import java.util.MissingResourceException; import java.util.MissingResourceException;
import java.util.ResourceBundle; import java.util.ResourceBundle;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.l10n.GlobalizationHelper;
/** /**
* <p> * <p>
@ -209,8 +213,8 @@ public class GlobalizedMessage {
* GlobalizedObject? * GlobalizedObject?
*/ */
public Object localize() { public Object localize() {
return localize(com.arsdigita.globalization.GlobalizationHelper return localize(CdiUtil.createCdiUtil().findBean(
.getNegotiatedLocale()); GlobalizationHelper.class).getNegotiatedLocale());
} }
/** /**
@ -232,8 +236,8 @@ public class GlobalizedMessage {
* GlobalizedObject? * GlobalizedObject?
*/ */
public Object localize(final HttpServletRequest request) { public Object localize(final HttpServletRequest request) {
return localize(com.arsdigita.globalization.GlobalizationHelper return localize(CdiUtil.createCdiUtil().findBean(
.getNegotiatedLocale()); GlobalizationHelper.class).getNegotiatedLocale());
} }
/** /**

View File

@ -19,14 +19,17 @@ import javax.servlet.http.HttpSession;
/** /**
* *
* @deprecated Replaced by {@link org.libreccm.l10n.GlobalizationHelper}
*
* @author Sören Bernstein <quasi@quasiweb.de> * @author Sören Bernstein <quasi@quasiweb.de>
*/ */
public class GlobalizationHelper { @Deprecated
public class LegacyGlobalizationHelper {
private static final String LANG_PARAM = "lang"; private static final String LANG_PARAM = "lang";
// Don't instantiate // Don't instantiate
private GlobalizationHelper() { private LegacyGlobalizationHelper() {
} }
/** /**
@ -36,14 +39,14 @@ public class GlobalizationHelper {
* *
* @return The negotiated locale * @return The negotiated locale
*/ */
public static java.util.Locale getNegotiatedLocale() { public static Locale getNegotiatedLocale() {
final KernelConfig kernelConfig = KernelConfig.getConfig(); final KernelConfig kernelConfig = KernelConfig.getConfig();
// Set the preferedLocale to the default locale (first entry in the config parameter list) // Set the preferedLocale to the default locale (first entry in the config parameter list)
java.util.Locale preferedLocale = getPrefferedLocale(); Locale preferedLocale = getPrefferedLocale();
// The ACCEPTED_LANGUAGES from the client // The ACCEPTED_LANGUAGES from the client
Enumeration<java.util.Locale> locales = null; Enumeration<Locale> locales = null;
// Try to get the RequestContext // Try to get the RequestContext
try { try {
@ -53,7 +56,7 @@ public class GlobalizationHelper {
.getRequest()); .getRequest());
// Get the selected locale from the request, if any // Get the selected locale from the request, if any
java.util.Locale selectedLocale = getSelectedLocale(request); Locale selectedLocale = getSelectedLocale(request);
if (selectedLocale != null && kernelConfig.hasLanguage( if (selectedLocale != null && kernelConfig.hasLanguage(
selectedLocale.getLanguage())) { selectedLocale.getLanguage())) {
preferedLocale = selectedLocale; preferedLocale = selectedLocale;
@ -65,7 +68,7 @@ public class GlobalizationHelper {
while (locales.hasMoreElements()) { while (locales.hasMoreElements()) {
// Test if the current locale is listed in the supported locales list // Test if the current locale is listed in the supported locales list
java.util.Locale curLocale = (Locale) locales.nextElement(); Locale curLocale = (Locale) locales.nextElement();
if (kernelConfig.hasLanguage(curLocale.getLanguage())) { if (kernelConfig.hasLanguage(curLocale.getLanguage())) {
preferedLocale = curLocale; preferedLocale = curLocale;
break; break;
@ -82,13 +85,13 @@ public class GlobalizationHelper {
} }
} }
// public static java.util.Locale getSystemLocale() { // public static Locale getSystemLocale() {
// //
// } // }
private static Locale getPrefferedLocale() { private static Locale getPrefferedLocale() {
final KernelConfig kernelConfig = KernelConfig.getConfig(); final KernelConfig kernelConfig = KernelConfig.getConfig();
java.util.Locale preferedLocale = new java.util.Locale(kernelConfig Locale preferedLocale = new Locale(kernelConfig
.getDefaultLanguage(), "", ""); .getDefaultLanguage(), "", "");
return preferedLocale; return preferedLocale;
} }
@ -96,12 +99,12 @@ public class GlobalizationHelper {
/** /**
* Get the selected (as in fixed) locale from the ServletRequest * Get the selected (as in fixed) locale from the ServletRequest
* *
* @return the selected locale as java.util.Locale or null if not defined * @return the selected locale as Locale or null if not defined
*/ */
public static Locale getSelectedLocale(ServletRequest request) { public static Locale getSelectedLocale(ServletRequest request) {
// Return value // Return value
java.util.Locale selectedLocale = null; Locale selectedLocale = null;
// Access current HttpSession or create a new one, if none exist // Access current HttpSession or create a new one, if none exist
HttpSession session = ((HttpServletRequest) request).getSession(true); HttpSession session = ((HttpServletRequest) request).getSession(true);
@ -132,19 +135,19 @@ public class GlobalizationHelper {
* *
* @param lang A string encoded locale, as provided by browsers * @param lang A string encoded locale, as provided by browsers
* *
* @return A java.util.Locale representation of the language string * @return A Locale representation of the language string
*/ */
private static java.util.Locale scanLocale(String lang) { private static Locale scanLocale(String lang) {
// Protect against empty lang string // Protect against empty lang string
if ((lang != null) && !(lang.isEmpty())) { if ((lang != null) && !(lang.isEmpty())) {
// Split the string and create the Locale object // Split the string and create the Locale object
StringTokenizer paramValues = new StringTokenizer(lang, "_"); StringTokenizer paramValues = new StringTokenizer(lang, "_");
if (paramValues.countTokens() > 1) { if (paramValues.countTokens() > 1) {
return new java.util.Locale(paramValues.nextToken(), paramValues return new Locale(paramValues.nextToken(), paramValues
.nextToken()); .nextToken());
} else { } else {
return new java.util.Locale(paramValues.nextToken()); return new Locale(paramValues.nextToken());
} }
} }

View File

@ -64,7 +64,7 @@ public final class KernelConfig {
@Setting @Setting
private Set<String> supportedLanguages = new HashSet<>( private Set<String> supportedLanguages = new HashSet<>(
Arrays.asList(new String[]{"en"})); Arrays.asList(new String[]{"en", "de"}));
@Setting @Setting
private String defaultLanguage = "en"; private String defaultLanguage = "en";

View File

@ -18,6 +18,7 @@
*/ */
package com.arsdigita.ui.admin; package com.arsdigita.ui.admin;
import com.arsdigita.ui.admin.usersgroupsroles.UsersGroupsRolesTab;
import com.arsdigita.bebop.Label; import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.Page; import com.arsdigita.bebop.Page;
import com.arsdigita.bebop.PageFactory; import com.arsdigita.bebop.PageFactory;

View File

@ -37,7 +37,7 @@ public final class AdminUiConstants {
/** /**
* Globalisation resource for administration UI. * Globalisation resource for administration UI.
*/ */
public static final String BUNDLE_NAME public static final String ADMIN_BUNDLE
= "com.arsdigita.ui.admin.AdminResources"; = "com.arsdigita.ui.admin.AdminResources";
/** /**
@ -45,39 +45,39 @@ public final class AdminUiConstants {
*/ */
// Label MY_WORKSPACE_LABEL = new Label // Label MY_WORKSPACE_LABEL = new Label
// (new GlobalizedMessage("ui.admin.nav.workspace", // (new GlobalizedMessage("ui.admin.nav.workspace",
// BUNDLE_NAME)); // ADMIN_BUNDLE));
// Label LOG_OUT_LABEL = new Label // Label LOG_OUT_LABEL = new Label
// (new GlobalizedMessage("ui.admin.nav.logout", // (new GlobalizedMessage("ui.admin.nav.logout",
// BUNDLE_NAME)); // ADMIN_BUNDLE));
/** /**
* Administration page title * Administration page title
*/ */
public static final Label PAGE_TITLE_LABEL = new Label( public static final Label PAGE_TITLE_LABEL = new Label(
new GlobalizedMessage("ui.admin.dispatcher.title", new GlobalizedMessage("ui.admin.dispatcher.title",
BUNDLE_NAME)); ADMIN_BUNDLE));
/** /**
* Administration main tab names. * Administration main tab names.
*/ */
public static final Label USER_TAB_TITLE = new Label(new GlobalizedMessage( public static final Label USER_TAB_TITLE = new Label(new GlobalizedMessage(
"ui.admin.tab.user", "ui.admin.tab.user",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label GROUP_TAB_TITLE = new Label(new GlobalizedMessage( public static final Label GROUP_TAB_TITLE = new Label(new GlobalizedMessage(
"ui.admin.tab.group", "ui.admin.tab.group",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label APPLICATIONS_TAB_TITLE = new Label( public static final Label APPLICATIONS_TAB_TITLE = new Label(
new GlobalizedMessage("ui.admin.tab.applications", new GlobalizedMessage("ui.admin.tab.applications",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label SYSINFO_TAB_TITLE = new Label( public static final Label SYSINFO_TAB_TITLE = new Label(
new GlobalizedMessage("ui.admin.tab.sysinfo.title", BUNDLE_NAME)); new GlobalizedMessage("ui.admin.tab.sysinfo.title", ADMIN_BUNDLE));
public static final GlobalizedMessage USER_NAVBAR_TITLE public static final GlobalizedMessage USER_NAVBAR_TITLE
= new GlobalizedMessage( = new GlobalizedMessage(
"ui.admin.tab.user.navbartitle", "ui.admin.tab.user.navbartitle",
BUNDLE_NAME); ADMIN_BUNDLE);
/** /**
* Tabbed pane indices * Tabbed pane indices
@ -90,16 +90,16 @@ public final class AdminUiConstants {
*/ */
public static final Label USER_TAB_SUMMARY = new Label( public static final Label USER_TAB_SUMMARY = new Label(
new GlobalizedMessage("ui.admin.tab.user.summary", new GlobalizedMessage("ui.admin.tab.user.summary",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label USER_TAB_BROWSE = new Label(new GlobalizedMessage( public static final Label USER_TAB_BROWSE = new Label(new GlobalizedMessage(
"ui.admin.tab.user.browse", "ui.admin.tab.user.browse",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label USER_TAB_SEARCH = new Label(new GlobalizedMessage( public static final Label USER_TAB_SEARCH = new Label(new GlobalizedMessage(
"ui.admin.tab.user.search", "ui.admin.tab.user.search",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label USER_TAB_CREATE_USER = new Label( public static final Label USER_TAB_CREATE_USER = new Label(
new GlobalizedMessage("ui.admin.tab.user.createuser", new GlobalizedMessage("ui.admin.tab.user.createuser",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final int USER_TAB_SUMMARY_INDEX = 0; public static final int USER_TAB_SUMMARY_INDEX = 0;
public static final int USER_TAB_BROWSE_INDEX = 1; public static final int USER_TAB_BROWSE_INDEX = 1;
@ -123,15 +123,15 @@ public final class AdminUiConstants {
* User summary panel. * User summary panel.
*/ */
public static final Label SUMMARY_PANEL_HEADER = new Label( public static final Label SUMMARY_PANEL_HEADER = new Label(
new GlobalizedMessage("ui.admin.user.summarypanel.header", BUNDLE_NAME)); new GlobalizedMessage("ui.admin.user.summarypanel.header", ADMIN_BUNDLE));
public static final Label CREATE_USER_LABEL = new Label( public static final Label CREATE_USER_LABEL = new Label(
new GlobalizedMessage( new GlobalizedMessage(
"ui.admin.user.summarypanel.createUser", BUNDLE_NAME)); "ui.admin.user.summarypanel.createUser", ADMIN_BUNDLE));
public static final Label TOTAL_USERS_LABEL = new Label( public static final Label TOTAL_USERS_LABEL = new Label(
new GlobalizedMessage( new GlobalizedMessage(
"ui.admin.user.summarypanel.totalusers", BUNDLE_NAME)); "ui.admin.user.summarypanel.totalusers", ADMIN_BUNDLE));
/** /**
* User browse panel. * User browse panel.
@ -139,82 +139,82 @@ public final class AdminUiConstants {
public static final Label BROWSE_USER_PANEL_HEADER = new Label( public static final Label BROWSE_USER_PANEL_HEADER = new Label(
new GlobalizedMessage( new GlobalizedMessage(
"ui.admin.user.browsepanel.header", "ui.admin.user.browsepanel.header",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label USER_INFO_LABEL = new Label(new GlobalizedMessage( public static final Label USER_INFO_LABEL = new Label(new GlobalizedMessage(
"ui.admin.user.userinfo.header", "ui.admin.user.userinfo.header",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label USER_EDIT_PANEL_HEADER = new Label( public static final Label USER_EDIT_PANEL_HEADER = new Label(
new GlobalizedMessage("ui.admin.user.useredit.header", new GlobalizedMessage("ui.admin.user.useredit.header",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label USER_GROUP_PANEL_HEADER = new Label( public static final Label USER_GROUP_PANEL_HEADER = new Label(
new GlobalizedMessage( new GlobalizedMessage(
"ui.admin.user.groupmembership.header", "ui.admin.user.groupmembership.header",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label USER_DELETE_FAILED_PANEL_HEADER = new Label( public static final Label USER_DELETE_FAILED_PANEL_HEADER = new Label(
new GlobalizedMessage( new GlobalizedMessage(
"ui.admin.user.action.delete.failed.header", "ui.admin.user.action.delete.failed.header",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label USER_PASSWORD_PANEL_HEADER = new Label( public static final Label USER_PASSWORD_PANEL_HEADER = new Label(
new GlobalizedMessage( new GlobalizedMessage(
"ui.admin.user.password.header", "ui.admin.user.password.header",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label USER_ACTION_PANEL_HEADER = new Label( public static final Label USER_ACTION_PANEL_HEADER = new Label(
new GlobalizedMessage("ui.admin.user.action.header", new GlobalizedMessage("ui.admin.user.action.header",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label USER_ACTION_CONTINUE = new Label( public static final Label USER_ACTION_CONTINUE = new Label(
new GlobalizedMessage("ui.admin.user.action.continue", new GlobalizedMessage("ui.admin.user.action.continue",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label USER_DELETE_LABEL = new Label( public static final Label USER_DELETE_LABEL = new Label(
new GlobalizedMessage("ui.admin.user.delete.label", new GlobalizedMessage("ui.admin.user.delete.label",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label USER_BAN_LABEL = new Label(new GlobalizedMessage( public static final Label USER_BAN_LABEL = new Label(new GlobalizedMessage(
"ui.admin.user.ban.label", "ui.admin.user.ban.label",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label USER_UNBAN_LABEL = new Label( public static final Label USER_UNBAN_LABEL = new Label(
new GlobalizedMessage("ui.admin.user.unban.label", new GlobalizedMessage("ui.admin.user.unban.label",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final GlobalizedMessage USER_DELETE_CONFIRMATION public static final GlobalizedMessage USER_DELETE_CONFIRMATION
= new GlobalizedMessage( = new GlobalizedMessage(
"ui.admin.user.delete.confirm", BUNDLE_NAME); "ui.admin.user.delete.confirm", ADMIN_BUNDLE);
public static final GlobalizedMessage USER_BAN_CONFIRMATION public static final GlobalizedMessage USER_BAN_CONFIRMATION
= new GlobalizedMessage( = new GlobalizedMessage(
"ui.admin.user.ban.confirm", "ui.admin.user.ban.confirm",
BUNDLE_NAME); ADMIN_BUNDLE);
public static final GlobalizedMessage USER_UNBAN_CONFIRMATION public static final GlobalizedMessage USER_UNBAN_CONFIRMATION
= new GlobalizedMessage( = new GlobalizedMessage(
"ui.admin.user.unban.confirm", "ui.admin.user.unban.confirm",
BUNDLE_NAME); ADMIN_BUNDLE);
public static final GlobalizedMessage USER_DELETE_FAILED_MSG public static final GlobalizedMessage USER_DELETE_FAILED_MSG
= new GlobalizedMessage( = new GlobalizedMessage(
"ui.admin.user.delete.failed.label", BUNDLE_NAME); "ui.admin.user.delete.failed.label", ADMIN_BUNDLE);
public static final Label USER_TAB_EXTREME_ACTION_LABEL = new Label( public static final Label USER_TAB_EXTREME_ACTION_LABEL = new Label(
new GlobalizedMessage( new GlobalizedMessage(
"ui.admin.user.browsepanel.extremeaction", "ui.admin.user.browsepanel.extremeaction",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label UPDATE_USER_PASSWORD_LABEL = new Label( public static final Label UPDATE_USER_PASSWORD_LABEL = new Label(
new GlobalizedMessage( new GlobalizedMessage(
"ui.admin.user.browsepanel.updatePassword", "ui.admin.user.browsepanel.updatePassword",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label BECOME_USER_LABEL = new Label( public static final Label BECOME_USER_LABEL = new Label(
new GlobalizedMessage("ui.admin.user.browsepanel.becomeUser", new GlobalizedMessage("ui.admin.user.browsepanel.becomeUser",
BUNDLE_NAME)); ADMIN_BUNDLE));
/** /**
* Create new user panel. * Create new user panel.
@ -222,39 +222,39 @@ public final class AdminUiConstants {
public static final Label CREATE_USER_PANEL_HEADER = new Label( public static final Label CREATE_USER_PANEL_HEADER = new Label(
new GlobalizedMessage( new GlobalizedMessage(
"ui.admin.user.createpanel.header", "ui.admin.user.createpanel.header",
BUNDLE_NAME)); ADMIN_BUNDLE));
/** /**
* User search panel. * User search panel.
*/ */
public static final Label SEARCH_PANEL_HEADER = new Label( public static final Label SEARCH_PANEL_HEADER = new Label(
new GlobalizedMessage("ui.admin.user.search.header", new GlobalizedMessage("ui.admin.user.search.header",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label PASSWORD_FORM_LABEL_PASSWORD = new Label( public static final Label PASSWORD_FORM_LABEL_PASSWORD = new Label(
new GlobalizedMessage( new GlobalizedMessage(
"ui.admin.user.userpasswordform.passwordlabel", "ui.admin.user.userpasswordform.passwordlabel",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label PASSWORD_FORM_LABEL_CONFIRMATION_PASSWORD public static final Label PASSWORD_FORM_LABEL_CONFIRMATION_PASSWORD
= new Label(new GlobalizedMessage( = new Label(new GlobalizedMessage(
"ui.admin.user.userpasswordform.confirmpasswordlabel", "ui.admin.user.userpasswordform.confirmpasswordlabel",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label PASSWORD_FORM_LABEL_QUESTION = new Label( public static final Label PASSWORD_FORM_LABEL_QUESTION = new Label(
new GlobalizedMessage( new GlobalizedMessage(
"ui.admin.user.userpasswordform.question", "ui.admin.user.userpasswordform.question",
BUNDLE_NAME), false); ADMIN_BUNDLE), false);
public static final Label PASSWORD_FORM_LABEL_ANSWER = new Label( public static final Label PASSWORD_FORM_LABEL_ANSWER = new Label(
new GlobalizedMessage( new GlobalizedMessage(
"ui.admin.user.userpasswordform.answer", "ui.admin.user.userpasswordform.answer",
BUNDLE_NAME), false); ADMIN_BUNDLE), false);
public static final GlobalizedMessage PASSWORD_FORM_SUBMIT public static final GlobalizedMessage PASSWORD_FORM_SUBMIT
= new GlobalizedMessage( = new GlobalizedMessage(
"ui.admin.user.userpasswordform.submit", "ui.admin.user.userpasswordform.submit",
BUNDLE_NAME); ADMIN_BUNDLE);
/** /**
* Constants for user add/edit form. * Constants for user add/edit form.
@ -279,95 +279,95 @@ public final class AdminUiConstants {
public static final Label USER_FORM_LABEL_FIRST_NAME = new Label( public static final Label USER_FORM_LABEL_FIRST_NAME = new Label(
new GlobalizedMessage( new GlobalizedMessage(
"ui.admin.user.addeditform.firstname", "ui.admin.user.addeditform.firstname",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label USER_FORM_LABEL_LAST_NAME = new Label( public static final Label USER_FORM_LABEL_LAST_NAME = new Label(
new GlobalizedMessage( new GlobalizedMessage(
"ui.admin.user.addeditform.lastname", "ui.admin.user.addeditform.lastname",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label USER_FORM_LABEL_PASSWORD = new Label( public static final Label USER_FORM_LABEL_PASSWORD = new Label(
new GlobalizedMessage( new GlobalizedMessage(
"ui.admin.user.addeditform.password", "ui.admin.user.addeditform.password",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label USER_FORM_LABEL_PASSWORD_CONFIRMATION = new Label( public static final Label USER_FORM_LABEL_PASSWORD_CONFIRMATION = new Label(
new GlobalizedMessage( new GlobalizedMessage(
"ui.admin.user.addeditform.confirmation", "ui.admin.user.addeditform.confirmation",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label USER_FORM_LABEL_QUESTION = new Label( public static final Label USER_FORM_LABEL_QUESTION = new Label(
new GlobalizedMessage( new GlobalizedMessage(
"ui.admin.user.addeditform.question", "ui.admin.user.addeditform.question",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label USER_FORM_LABEL_ANSWER = new Label( public static final Label USER_FORM_LABEL_ANSWER = new Label(
new GlobalizedMessage( new GlobalizedMessage(
"ui.admin.user.addeditform.answer", "ui.admin.user.addeditform.answer",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label USER_FORM_LABEL_PRIMARY_EMAIL = new Label( public static final Label USER_FORM_LABEL_PRIMARY_EMAIL = new Label(
new GlobalizedMessage( new GlobalizedMessage(
"ui.admin.user.addeditform.primaryemail", "ui.admin.user.addeditform.primaryemail",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label USER_FORM_LABEL_ADDITIONAL_EMAIL = new Label( public static final Label USER_FORM_LABEL_ADDITIONAL_EMAIL = new Label(
new GlobalizedMessage( new GlobalizedMessage(
"ui.admin.user.addeditform.additionalemail", "ui.admin.user.addeditform.additionalemail",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label USER_FORM_LABEL_ADDITIONAL_EMAIL_LIST = new Label( public static final Label USER_FORM_LABEL_ADDITIONAL_EMAIL_LIST = new Label(
new GlobalizedMessage( new GlobalizedMessage(
"ui.admin.user.addeditform.additionalemaillist", "ui.admin.user.addeditform.additionalemaillist",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label USER_FORM_LABEL_SCREEN_NAME = new Label( public static final Label USER_FORM_LABEL_SCREEN_NAME = new Label(
new GlobalizedMessage( new GlobalizedMessage(
"ui.admin.user.addeditform.screenname", "ui.admin.user.addeditform.screenname",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label USER_FORM_LABEL_SSO = new Label( public static final Label USER_FORM_LABEL_SSO = new Label(
new GlobalizedMessage( new GlobalizedMessage(
"ui.admin.user.addeditform.ssologinname", "ui.admin.user.addeditform.ssologinname",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label USER_FORM_LABEL_URL = new Label( public static final Label USER_FORM_LABEL_URL = new Label(
new GlobalizedMessage("ui.admin.user.addeditform.url", new GlobalizedMessage("ui.admin.user.addeditform.url",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label USER_FORM_DELETE_ADDITIONAL_EMAIL = new Label( public static final Label USER_FORM_DELETE_ADDITIONAL_EMAIL = new Label(
new GlobalizedMessage("ui.admin.user.addeditform.deleteemail", new GlobalizedMessage("ui.admin.user.addeditform.deleteemail",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final GlobalizedMessage USER_FORM_SUBMIT public static final GlobalizedMessage USER_FORM_SUBMIT
= new GlobalizedMessage( = new GlobalizedMessage(
"ui.admin.user.addeditform.submit", "ui.admin.user.addeditform.submit",
BUNDLE_NAME); ADMIN_BUNDLE);
public static final GlobalizedMessage USER_FORM_ERROR_SCREEN_NAME_NOT_UNIQUE public static final GlobalizedMessage USER_FORM_ERROR_SCREEN_NAME_NOT_UNIQUE
= new GlobalizedMessage( = new GlobalizedMessage(
"ui.admin.user.addeditform.error.screenname.notunique", "ui.admin.user.addeditform.error.screenname.notunique",
BUNDLE_NAME); ADMIN_BUNDLE);
public static final GlobalizedMessage USER_FORM_ERROR_PRIMARY_EMAIL_NOT_UNIQUE public static final GlobalizedMessage USER_FORM_ERROR_PRIMARY_EMAIL_NOT_UNIQUE
= new GlobalizedMessage( = new GlobalizedMessage(
"ui.admin.user.addeditform.error.primaryemail.notunique", "ui.admin.user.addeditform.error.primaryemail.notunique",
BUNDLE_NAME); ADMIN_BUNDLE);
public static final GlobalizedMessage USER_FORM_ERROR_PASSWORD_NOT_MATCH public static final GlobalizedMessage USER_FORM_ERROR_PASSWORD_NOT_MATCH
= new GlobalizedMessage( = new GlobalizedMessage(
"ui.admin.user.addeditform.error.password.notmatch", "ui.admin.user.addeditform.error.password.notmatch",
BUNDLE_NAME); ADMIN_BUNDLE);
public static final GlobalizedMessage USER_FORM_ERROR_ANSWER_NULL public static final GlobalizedMessage USER_FORM_ERROR_ANSWER_NULL
= new GlobalizedMessage( = new GlobalizedMessage(
"ui.admin.user.addeditform.error.answer.null", "ui.admin.user.addeditform.error.answer.null",
BUNDLE_NAME); ADMIN_BUNDLE);
public static final GlobalizedMessage USER_FORM_ERROR_ANSWER_WHITESPACE public static final GlobalizedMessage USER_FORM_ERROR_ANSWER_WHITESPACE
= new GlobalizedMessage( = new GlobalizedMessage(
"ui.admin.user.addeditform.error.answer.whitespace", "ui.admin.user.addeditform.error.answer.whitespace",
BUNDLE_NAME); ADMIN_BUNDLE);
/** /**
* Constants for group add/edit form. * Constants for group add/edit form.
@ -380,115 +380,115 @@ public final class AdminUiConstants {
public static final Label GROUP_FORM_LABEL_NAME = new Label( public static final Label GROUP_FORM_LABEL_NAME = new Label(
new GlobalizedMessage( new GlobalizedMessage(
"ui.admin.groups.addeditform.namelabel", "ui.admin.groups.addeditform.namelabel",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label GROUP_FORM_LABEL_PRIMARY_EMAIL = new Label( public static final Label GROUP_FORM_LABEL_PRIMARY_EMAIL = new Label(
new GlobalizedMessage( new GlobalizedMessage(
"ui.admin.groups.addeditform.primaryemaillabel", "ui.admin.groups.addeditform.primaryemaillabel",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final GlobalizedMessage GROUP_FORM_SUBMIT public static final GlobalizedMessage GROUP_FORM_SUBMIT
= new GlobalizedMessage( = new GlobalizedMessage(
"ui.admin.groups.addeditform.submit", BUNDLE_NAME); "ui.admin.groups.addeditform.submit", ADMIN_BUNDLE);
/** /**
* Constants for group administration tab. * Constants for group administration tab.
*/ */
public static final Label GROUP_ACTION_CONTINUE = new Label( public static final Label GROUP_ACTION_CONTINUE = new Label(
new GlobalizedMessage("ui.admin.groups.actioncontinue", new GlobalizedMessage("ui.admin.groups.actioncontinue",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final GlobalizedMessage GROUP_DELETE_FAILED_MSG public static final GlobalizedMessage GROUP_DELETE_FAILED_MSG
= new GlobalizedMessage( = new GlobalizedMessage(
"ui.admin.groups.groupdeletefailed", "ui.admin.groups.groupdeletefailed",
BUNDLE_NAME); ADMIN_BUNDLE);
public static final Label GROUP_INFORMATION_HEADER = new Label( public static final Label GROUP_INFORMATION_HEADER = new Label(
new GlobalizedMessage( new GlobalizedMessage(
"ui.admin.groups.groupinformation", "ui.admin.groups.groupinformation",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label SUBGROUP_HEADER = new Label(new GlobalizedMessage( public static final Label SUBGROUP_HEADER = new Label(new GlobalizedMessage(
"ui.admin.groups.subgroups", "ui.admin.groups.subgroups",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label GROUP_EDIT_HEADER = new Label( public static final Label GROUP_EDIT_HEADER = new Label(
new GlobalizedMessage("ui.admin.groups.groupedit", new GlobalizedMessage("ui.admin.groups.groupedit",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label ADD_SUBGROUP_LABEL = new Label( public static final Label ADD_SUBGROUP_LABEL = new Label(
new GlobalizedMessage("ui.admin.groups.add", new GlobalizedMessage("ui.admin.groups.add",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label SUBMEMBER_HEADER = new Label( public static final Label SUBMEMBER_HEADER = new Label(
new GlobalizedMessage("ui.admin.groups.submembers", new GlobalizedMessage("ui.admin.groups.submembers",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label DELETE_GROUP_LABEL = new Label( public static final Label DELETE_GROUP_LABEL = new Label(
new GlobalizedMessage("ui.admin.groups.delete", new GlobalizedMessage("ui.admin.groups.delete",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label GROUP_EXTREME_ACTIONS_HEADER = new Label( public static final Label GROUP_EXTREME_ACTIONS_HEADER = new Label(
new GlobalizedMessage( new GlobalizedMessage(
"ui.admin.groups.extremeaction", "ui.admin.groups.extremeaction",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label GROUP_DELETE_FAILED_HEADER = new Label( public static final Label GROUP_DELETE_FAILED_HEADER = new Label(
new GlobalizedMessage( new GlobalizedMessage(
"ui.admin.groups.deletefailed", "ui.admin.groups.deletefailed",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label ADD_GROUP_LABEL = new Label(new GlobalizedMessage( public static final Label ADD_GROUP_LABEL = new Label(new GlobalizedMessage(
"ui.admin.groups.addgrouplabel", "ui.admin.groups.addgrouplabel",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label EDIT_GROUP_LABEL = new Label( public static final Label EDIT_GROUP_LABEL = new Label(
new GlobalizedMessage("ui.admin.groups.edit", new GlobalizedMessage("ui.admin.groups.edit",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label SUBGROUP_COUNT_LABEL = new Label( public static final Label SUBGROUP_COUNT_LABEL = new Label(
new GlobalizedMessage( new GlobalizedMessage(
"ui.admin.groups.subgroupcountlabel", "ui.admin.groups.subgroupcountlabel",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final String GROUP_DELETE_CONFIRMATION public static final String GROUP_DELETE_CONFIRMATION
= "Are you sure you want to delete this group?"; = "Are you sure you want to delete this group?";
public static final Label ADD_SUBMEMBER_LABEL = new Label( public static final Label ADD_SUBMEMBER_LABEL = new Label(
new GlobalizedMessage("ui.admin.groups.addsubmemberlabel", new GlobalizedMessage("ui.admin.groups.addsubmemberlabel",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label REMOVE_SUBMEMBER_LABEL = new Label( public static final Label REMOVE_SUBMEMBER_LABEL = new Label(
new GlobalizedMessage( new GlobalizedMessage(
"ui.admin.groups.removesubmemberlabel", "ui.admin.groups.removesubmemberlabel",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label ADD_EXISTING_GROUP_TO_SUBGROUPS_LABEL = new Label( public static final Label ADD_EXISTING_GROUP_TO_SUBGROUPS_LABEL = new Label(
new GlobalizedMessage( new GlobalizedMessage(
"ui.admin.groups.addExisting", "ui.admin.groups.addExisting",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label REMOVE_SUBGROUP_LABEL = new Label( public static final Label REMOVE_SUBGROUP_LABEL = new Label(
new GlobalizedMessage("ui.admin.groups.removeExisting", new GlobalizedMessage("ui.admin.groups.removeExisting",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label GROUP_SEARCH_LABEL = new Label( public static final Label GROUP_SEARCH_LABEL = new Label(
new GlobalizedMessage("ui.admin.groups.search", BUNDLE_NAME)); new GlobalizedMessage("ui.admin.groups.search", ADMIN_BUNDLE));
public static final GlobalizedMessage SEARCH_BUTTON = new GlobalizedMessage( public static final GlobalizedMessage SEARCH_BUTTON = new GlobalizedMessage(
"ui.admin.groups.button.search", "ui.admin.groups.button.search",
BUNDLE_NAME); ADMIN_BUNDLE);
public static final Label GROUP_NO_RESULTS = new Label( public static final Label GROUP_NO_RESULTS = new Label(
new GlobalizedMessage("ui.admin.groups.searchForm.noResults", new GlobalizedMessage("ui.admin.groups.searchForm.noResults",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label FOUND_GROUPS_TITLE = new Label( public static final Label FOUND_GROUPS_TITLE = new Label(
new GlobalizedMessage("ui.admin.groups.found.title", new GlobalizedMessage("ui.admin.groups.found.title",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final Label PICK_GROUPS = new Label(new GlobalizedMessage( public static final Label PICK_GROUPS = new Label(new GlobalizedMessage(
"ui.admin.groups.select.explanation", "ui.admin.groups.select.explanation",
BUNDLE_NAME)); ADMIN_BUNDLE));
public static final GlobalizedMessage SAVE_BUTTON = new GlobalizedMessage( public static final GlobalizedMessage SAVE_BUTTON = new GlobalizedMessage(
"ui.admin.save", BUNDLE_NAME); "ui.admin.save", ADMIN_BUNDLE);
public static final String SEARCH_QUERY = "query"; public static final String SEARCH_QUERY = "query";

View File

@ -0,0 +1,36 @@
/*
* Copyright (C) 2016 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.ui.admin.usersgroupsroles;
import com.arsdigita.bebop.BoxPanel;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class UserAdmin extends BoxPanel {
public UserAdmin() {
super();
//add(new Label("User Admin class"));
add(new UsersTable());
}
}

View File

@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA * MA 02110-1301 USA
*/ */
package com.arsdigita.ui.admin; package com.arsdigita.ui.admin.usersgroupsroles;
import com.arsdigita.bebop.BoxPanel; import com.arsdigita.bebop.BoxPanel;
import com.arsdigita.bebop.Component; import com.arsdigita.bebop.Component;
@ -25,6 +25,7 @@ import com.arsdigita.bebop.List;
import com.arsdigita.bebop.Page; import com.arsdigita.bebop.Page;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.Resettable; import com.arsdigita.bebop.Resettable;
import com.arsdigita.bebop.SimpleContainer;
import com.arsdigita.bebop.list.ListModel; import com.arsdigita.bebop.list.ListModel;
import com.arsdigita.bebop.list.ListModelBuilder; import com.arsdigita.bebop.list.ListModelBuilder;
import com.arsdigita.globalization.GlobalizedMessage; import com.arsdigita.globalization.GlobalizedMessage;
@ -60,8 +61,8 @@ public class UsersGroupsRolesTab extends LayoutPanel {
}); });
sections.setClassAttr("navbar"); sections.setClassAttr("navbar");
final BoxPanel usersPanel = new BoxPanel(); // final BoxPanel usersPanel = new BoxPanel();
usersPanel.add(new Label("Users Panel")); // usersPanel.add(new Label("Users Panel"));
final BoxPanel groupsPanel = new BoxPanel(); final BoxPanel groupsPanel = new BoxPanel();
groupsPanel.add(new Label("Groups Panel")); groupsPanel.add(new Label("Groups Panel"));
@ -73,25 +74,35 @@ public class UsersGroupsRolesTab extends LayoutPanel {
addSection( addSection(
new Label(new GlobalizedMessage( new Label(new GlobalizedMessage(
"ui.admin.users_groups_roles.users.title", "ui.admin.users_groups_roles.users.title",
BUNDLE_NAME)), ADMIN_BUNDLE)),
usersPanel, new UserAdmin(),
body); body);
addSection( addSection(
new Label(new GlobalizedMessage( new Label(new GlobalizedMessage(
"ui.admin.users_groups_roles.groups.title", "ui.admin.users_groups_roles.groups.title",
BUNDLE_NAME)), ADMIN_BUNDLE)),
groupsPanel, groupsPanel,
body); body);
addSection( addSection(
new Label(new GlobalizedMessage( new Label(new GlobalizedMessage(
"ui.admin.users_roles_roles.users.title", "ui.admin.users_roles_roles.users.title",
BUNDLE_NAME)), ADMIN_BUNDLE)),
rolesPanel, rolesPanel,
body); body);
setLeft(sections); setLeft(sections);
setBody(body); setBody(body);
} }
private SimpleContainer buildUserAdmin() {
final BoxPanel panel = new BoxPanel();
panel.add(new Label("User Admin"));
return panel;
}
private void addSection(final Label label, private void addSection(final Label label,
final Component component, final Component component,

View File

@ -0,0 +1,159 @@
/*
* Copyright (C) 2016 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.ui.admin.usersgroupsroles;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.Table;
import com.arsdigita.bebop.table.TableColumn;
import com.arsdigita.bebop.table.TableColumnModel;
import com.arsdigita.bebop.table.TableModel;
import com.arsdigita.bebop.table.TableModelBuilder;
import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.util.LockableImpl;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.security.User;
import org.libreccm.security.UserRepository;
import java.util.List;
import static com.arsdigita.ui.admin.AdminUiConstants.*;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class UsersTable extends Table {
private static final Logger LOGGER = LogManager.getLogger(UsersTable.class);
private static final int COL_SCREEN_NAME = 0;
private static final int COL_GIVEN_NAME = 1;
private static final int COL_FAMILY_NAME = 2;
private static final int COL_PRIMARY_EMAIL = 3;
private static final int COL_BANNED = 4;
public UsersTable() {
super();
setEmptyView(new Label(new GlobalizedMessage(
"ui.admin.users.table.no_users", ADMIN_BUNDLE)));
final TableColumnModel columnModel = getColumnModel();
columnModel.add(new TableColumn(
COL_SCREEN_NAME,
new Label(new GlobalizedMessage("ui.admin.users.table.screenname",
ADMIN_BUNDLE))));
columnModel.add(new TableColumn(
COL_GIVEN_NAME,
new Label(new GlobalizedMessage("ui.admin.users.table.givenname",
ADMIN_BUNDLE))));
columnModel.add(new TableColumn(
COL_FAMILY_NAME,
new Label(new GlobalizedMessage("ui.admin.users.table.familyname",
ADMIN_BUNDLE))));
columnModel.add(new TableColumn(
COL_PRIMARY_EMAIL,
new Label(new GlobalizedMessage(
"ui.admin.users.table.primary_email", ADMIN_BUNDLE))));
columnModel.add(new TableColumn(
COL_BANNED,
new Label(new GlobalizedMessage(
"ui.admin.users.table.banned", ADMIN_BUNDLE))));
setModelBuilder(new UsersTableModelBuilder());
}
private class UsersTableModelBuilder extends LockableImpl
implements TableModelBuilder {
@Override
public TableModel makeModel(final Table table, final PageState state) {
table.getRowSelectionModel().clearSelection(state);
return new UsersTableModel();
}
}
private class UsersTableModel implements TableModel {
private final List<User> users;
private int index = -1;
public UsersTableModel() {
LOGGER.debug("Creating UsersTableModel...");
final UserRepository userRepository = CdiUtil.createCdiUtil()
.findBean(UserRepository.class);
users = userRepository.findAll();
LOGGER.debug("Found {} users in database.", users.size());
}
@Override
public int getColumnCount() {
return 6;
}
@Override
public boolean nextRow() {
index++;
LOGGER.debug("Next row called. Index is {}", index);
return index < users.size();
// index++;
// LOGGER.debug("Result is '{}'. Index is now {}", result, index);
// return result;
}
@Override
public Object getElementAt(final int columnIndex) {
LOGGER.debug("Getting element for row {}, column {}...",
index,
columnIndex);
final User user = users.get(index);
switch (columnIndex) {
case COL_BANNED:
return Boolean.toString(user.isBanned());
case COL_FAMILY_NAME:
return user.getFamilyName();
case COL_GIVEN_NAME:
return user.getGivenName();
case COL_PRIMARY_EMAIL:
return user.getPrimaryEmailAddress().getAddress();
case COL_SCREEN_NAME:
return user.getName();
default:
throw new IllegalArgumentException(
"No a valid column index.");
}
}
@Override
public Object getKeyAt(final int columnIndex) {
LOGGER.debug("Getting key for row {}, column {}...",
index,
columnIndex);
return users.get(index).getPartyId();
}
}
}

View File

@ -0,0 +1,151 @@
/*
* Copyright (C) 2016 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.l10n;
import com.arsdigita.kernel.KernelConfig;
import org.libreccm.configuration.ConfigurationManager;
import java.util.Enumeration;
import java.util.Locale;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
/**
* Provides the locale which has been selected based on the available languages
* configured in the {@link KernelConfig}, the preferred languages of the client
* provided an the request, the (optional) {@code lang} attribute in the current
* session and the optional {@code lang} parameter in the current request.
*
* The algorithm used in the class is as follows:
*
* <ol>
* <li>
* If there is an attribute {@code lang} in the current session use that
* language.
* </li>
* <li>
* If there is a parameter {@code lang} for the current request, use that
* language <em>and</em> store the selected language in the session.
* </li>
* <li>
* Get the languages preferred by the client as transmitted in the request and
* use the first match between the languages preferred by the client and
* available languages (from the {@link KernelConfig}).
* </li>
* </ol>
*
* A historic note: This CDI bean replaces the old {@code GlobalizationHelper} class which used
* static methods and relied on the old {@code DispatcherHelper} for getting the
* current request. In a CDI environment we can simply inject the current request
* and don't need to bother with static methods etc.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RequestScoped
public class GlobalizationHelper {
private static final String LANG_PARAM = "lang";
@Inject
private HttpServletRequest request;
@Inject
private ConfigurationManager confManager;
// private final KernelConfig kernelConfig;
// public GlobalizationHelper() {
// kernelConfig = confManager.findConfiguration(KernelConfig.class);
// }
public Locale getNegotiatedLocale() {
final KernelConfig kernelConfig = confManager.findConfiguration(KernelConfig.class);
Locale preferred = new Locale(kernelConfig.getDefaultLanguage());
final Locale selectedLocale = getSelectedLocale();
if (selectedLocale == null || !kernelConfig.hasLanguage(selectedLocale
.getLanguage())) {
final Enumeration<Locale> acceptedLocales = request.getLocales();
while (acceptedLocales.hasMoreElements()) {
final Locale current = acceptedLocales.nextElement();
if (kernelConfig.hasLanguage(current.getLanguage())) {
preferred = current;
break;
}
}
} else {
preferred = selectedLocale;
}
return preferred;
}
public Locale getSelectedLocale() {
// Get the current session, create one if there is none
final HttpSession session = request.getSession(true);
// Retrieve previously selected language from session. Might be null if
// no language has been selected in a previous request.
final String langSession = (String) session.getAttribute(LANG_PARAM);
// Get value of lang parameter from request URL. Will be null
// if the parameter is not set for the current request
final String langRequest = request.getParameter(LANG_PARAM);
Locale selected = null;
if (langRequest == null) {
if (langSession != null) {
selected = scanLocale(langSession);
}
} else {
final Locale localeRequest = scanLocale(langRequest);
if (localeRequest != null) {
session.setAttribute(LANG_PARAM, langRequest);
selected = localeRequest;
}
}
return selected;
}
private Locale scanLocale(final String language) {
if (language == null || language.isEmpty()) {
return null;
} else {
final String[] tokens = language.split("_");
if (tokens.length == 1) {
return new Locale(tokens[0]);
} else if (tokens.length == 2) {
return new Locale(tokens[0], tokens[1]);
} else if (tokens.length >= 3) {
return new Locale(tokens[0], tokens[1], tokens[2]);
} else {
return null;
}
}
}
}

View File

@ -0,0 +1,123 @@
/*
* Copyright (C) 2016 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.themes;
import org.apache.commons.io.IOUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Set;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@WebServlet(urlPatterns = {"/themes/static/*"})
public class StaticThemesServlet extends HttpServlet {
private static final long serialVersionUID = -2732540547314051013L;
private static final Logger LOGGER = LogManager.getLogger(
StaticThemesServlet.class);
@Override
public void doGet(final HttpServletRequest request,
final HttpServletResponse response)
throws ServletException, IOException {
final String pathInfo = request.getPathInfo();
if (pathInfo == null) {
LOGGER.warn("Received request without path info which this Servlet "
+ "can't handle. Responding with SC_FORBIDDEN.");
response.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
}
final String resourcePath = String.join("", "/themes", pathInfo);
LOGGER.debug("Resource path is '{}'.", resourcePath);
// final InputStream inStream = getClass().getClassLoader()
// .getResourceAsStream(resourcePath);
// final URL resourceUrl = getClass().getClassLoader().getResource(
// String.format("file://%s", resourcePath));
// final MimetypesFileTypeMap mimetypesMap = new MimetypesFileTypeMap();
// final String type;
// try {
// type = mimetypesMap.getContentType(new File(resourceUrl.toURI()));
// } catch (URISyntaxException ex) {
// throw new ServletException(ex);
// }
//
// response.setContentType(type);
// if (inStream == null) {
// LOGGER.warn("Failed to get requested resource '{}'", resourcePath);
// response.sendError(HttpServletResponse.SC_NOT_FOUND);
// return;
// }
//
// IOUtils.copy(inStream, response.getOutputStream());
final ServletContext servletContext = getServletContext();
final Set<String> paths = servletContext.getResourcePaths(resourcePath);
if (paths == null) {
final InputStream inputStream = servletContext.getResourceAsStream(
resourcePath);
if (inputStream == null) {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
} else {
response.setContentType(servletContext.getMimeType(resourcePath));
IOUtils.copy(inputStream, response.getOutputStream());
}
} else {
response.setContentType("text/plain");
final PrintWriter printWriter = response.getWriter();
printWriter.append(String.format("%s%n", resourcePath));
for(int i = 0; i < resourcePath.length(); i++) {
printWriter.append('=');
}
printWriter.append(System.lineSeparator());
paths.forEach(p -> printWriter.append(String.format("%s%n", p)));
}
//IOUtils.copy(new FileInputStream(file), response.getOutputStream());
// try {
// final File file = new File(resourceURL.toURI());
// response.setContentType(getServletContext().getMimeType(resourcePath));
// IOUtils.copy(getServletContext().getResourceAsStream(resourcePath),
// response.getOutputStream());
//
// final Path path = Paths.get(resourceURL.toURI());
//
// Files.copy(path, response.getOutputStream());
// } catch (URISyntaxException ex) {
// throw new ServletException(ex);
// }
}
}

View File

@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<title>ccm-core.html</title>
</head>
<body>
<h1>ccm-core.txt</h1>
</body>
</html>

View File

@ -0,0 +1,9 @@
Dies ist ein Test.
Diese Datei liegt im Module
ccm-core
in
/themes/test/ccm-core.txt

View File

@ -160,3 +160,8 @@ ui.admin.tab.workflows.title=Workflows
ui.admin.users_groups_roles.users.title=Users ui.admin.users_groups_roles.users.title=Users
ui.admin.users_groups_roles.groups.title=Groups ui.admin.users_groups_roles.groups.title=Groups
ui.admin.users_roles_roles.users.title=Roles ui.admin.users_roles_roles.users.title=Roles
ui.admin.users.table.screenname=Username
ui.admin.users.table.givenname=Given name
ui.admin.users.table.familyname=Family name
ui.admin.users.table.primary_email=E-Mail
ui.admin.users.table.banned=Banned

View File

@ -160,3 +160,8 @@ ui.admin.tab.workflows.title=Arbeitsabl\u00e4ufe
ui.admin.users_groups_roles.users.title=Benutzer ui.admin.users_groups_roles.users.title=Benutzer
ui.admin.users_groups_roles.groups.title=Gruppen ui.admin.users_groups_roles.groups.title=Gruppen
ui.admin.users_roles_roles.users.title=Rollen ui.admin.users_roles_roles.users.title=Rollen
ui.admin.users.table.screenname=Benutzername
ui.admin.users.table.givenname=Vorname
ui.admin.users.table.familyname=Familienname
ui.admin.users.table.primary_email=E-Mail
ui.admin.users.table.banned=Gesperrt

View File

@ -133,3 +133,8 @@ ui.admin.user.userinfo.screenname=Username:
ui.admin.users_groups_roles.users.title=Users ui.admin.users_groups_roles.users.title=Users
ui.admin.users_groups_roles.groups.title=Groups ui.admin.users_groups_roles.groups.title=Groups
ui.admin.users_roles_roles.users.title=Roles ui.admin.users_roles_roles.users.title=Roles
ui.admin.users.table.screenname=Username
ui.admin.users.table.givenname=Given name
ui.admin.users.table.familyname=Family name
ui.admin.users.table.primary_email=E-Mail
ui.admin.users.table.banned=Banned

View File

@ -124,3 +124,8 @@ ui.admin.user.userinfo.screenname=Username:
ui.admin.users_groups_roles.users.title=Users ui.admin.users_groups_roles.users.title=Users
ui.admin.users_groups_roles.groups.title=Groups ui.admin.users_groups_roles.groups.title=Groups
ui.admin.users_roles_roles.users.title=Roles ui.admin.users_roles_roles.users.title=Roles
ui.admin.users.table.screenname=Username
ui.admin.users.table.givenname=Given name
ui.admin.users.table.familyname=Family name
ui.admin.users.table.primary_email=E-Mail
ui.admin.users.table.banned=Banned