Enhanced globalization support, added documentation.

git-svn-id: https://svn.libreccm.org/ccm/trunk@2388 8810af33-2d31-482b-a856-94f89814c4df
master
pb 2013-10-27 18:23:17 +00:00
parent 28834f8c6b
commit 6145059e25
18 changed files with 183 additions and 122 deletions

View File

@ -54,7 +54,7 @@ public class ThreadPageBuilder implements PageBuilder, Constants {
Page threadPage = PageFactory.buildPage(Constants.FORUM_XML_PREFIX, Page threadPage = PageFactory.buildPage(Constants.FORUM_XML_PREFIX,
"Threads", "forumThreadPage"); "Threads", "forumThreadPage");
//Output the title in an easy to find place //Output the forum title and introduction test in an easy to find place
threadPage.add(new SimpleComponent(){ threadPage.add(new SimpleComponent(){
@Override @Override

View File

@ -18,6 +18,7 @@
*/ */
package com.arsdigita.forum.ui; package com.arsdigita.forum.ui;
import com.arsdigita.forum.util.GlobalizationUtil;
import java.io.File; import java.io.File;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
@ -63,13 +64,14 @@ import com.arsdigita.util.Assert;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
/** /**
* @author Chris Gilbert <a href="mailto:chris.gilbert@westsussex.gov.uk">chris.gilbert@westsussex.gov.uk</a> * Wizard step to attach files to a post. This step may be bypassed if a forum
* * administrator changes the forum settings on the UI.
* Wizard step to attach files to a post. This step may be bypassed
* if a forum administrator changes the forum settings on the UI
* *
* nb - a simpler reuseable generic wizard file attachments step has been created * nb - a simpler reuseable generic wizard file attachments step has been created
* forum will be refactored to use it in the future. see ccm-wsx-wizard-steps in contrib * forum will be refactored to use it in the future.
* see ccm-wsx-wizard-steps in contrib
*
* @author Chris Gilbert <a href="mailto:chris.gilbert@westsussex.gov.uk">chris.gilbert@westsussex.gov.uk</a>
*/ */
public class AttachedFilesStep public class AttachedFilesStep
extends FormStep extends FormStep
@ -104,7 +106,7 @@ public class AttachedFilesStep
m_upload = new FileUpload("file", true); m_upload = new FileUpload("file", true);
m_upload.addValidationListener(new NotEmptyValidationListener( m_upload.addValidationListener(new NotEmptyValidationListener(
Text GlobalizationUtil
.gz("forum.ui.validation.file_null")) { .gz("forum.ui.validation.file_null")) {
public void validate(ParameterEvent e) { public void validate(ParameterEvent e) {
// don't fire validation if the next or previous button of the wizard has been pressed // don't fire validation if the next or previous button of the wizard has been pressed
@ -121,12 +123,10 @@ public class AttachedFilesStep
m_description = new TextArea("fileDescription"); m_description = new TextArea("fileDescription");
m_description.setCols(20); m_description.setCols(20);
m_description.setRows(5); m_description.setRows(5);
m_description.addValidationListener(new StringInRangeValidationListener(
m_description
.addValidationListener(new StringInRangeValidationListener(
0, 0,
4000, 4000,
Text.gz("forum.ui.validation.file_description_too_long")) { GlobalizationUtil.gz("forum.ui.validation.file_description_too_long")) {
public void validate(ParameterEvent e) public void validate(ParameterEvent e)
throws FormProcessException { throws FormProcessException {
// don't fire validation if the next or previous button of the wizard has been pressed // don't fire validation if the next or previous button of the wizard has been pressed
@ -209,9 +209,8 @@ public class AttachedFilesStep
if (!m_addFile.isSelected(state) if (!m_addFile.isSelected(state)
&& StringUtils.isNotBlank((String) m_upload.getValue(state))) { && StringUtils.isNotBlank((String) m_upload.getValue(state))) {
throw new FormProcessException( throw new FormProcessException(
(String) Text (String) GlobalizationUtil.gzAsStr(
.gz("forum.ui.validation.file_not_uploaded") "forum.ui.validation.file_not_uploaded"));
.localize());
} }
} }
@ -304,6 +303,7 @@ public class AttachedFilesStep
} }
@Override
public void register(Page p) { public void register(Page p) {
super.register(p); super.register(p);

View File

@ -18,6 +18,7 @@
*/ */
package com.arsdigita.forum.ui; package com.arsdigita.forum.ui;
import com.arsdigita.forum.util.GlobalizationUtil;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.Label; import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.event.PrintEvent; import com.arsdigita.bebop.event.PrintEvent;
@ -58,7 +59,7 @@ public class CategoryWidget extends SingleSelect implements Constants {
if (forum.noCategoryPostsAllowed()) { if (forum.noCategoryPostsAllowed()) {
target.addOption(new Option( target.addOption(new Option(
TOPIC_NONE.toString(), TOPIC_NONE.toString(),
new Label(Text.gz("forum.ui.topic.none")))); new Label(GlobalizationUtil.gz("forum.ui.topic.none"))));
} }
final Category root = forum.getRootCategory(); final Category root = forum.getRootCategory();
if (root != null) { if (root != null) {

View File

@ -18,6 +18,7 @@
*/ */
package com.arsdigita.forum.ui; package com.arsdigita.forum.ui;
import com.arsdigita.forum.util.GlobalizationUtil;
import com.arsdigita.forum.ForumContext; import com.arsdigita.forum.ForumContext;
import com.arsdigita.forum.Post; import com.arsdigita.forum.Post;
import com.arsdigita.forum.ThreadSubscription; import com.arsdigita.forum.ThreadSubscription;
@ -81,7 +82,7 @@ public class DiscussionThreadSimpleView extends ModalContainer implements Consta
private ACSObjectSelectionModel m_postModel; private ACSObjectSelectionModel m_postModel;
/** /**
* Default Constructor creates the component of the discussio view. * Default Constructor creates the component of the discussion view.
* The discussion page contains three components: a MessageList, * The discussion page contains three components: a MessageList,
* a ThreadEdit component, and a ThreadReply component. * a ThreadEdit component, and a ThreadReply component.
* *
@ -94,7 +95,7 @@ public class DiscussionThreadSimpleView extends ModalContainer implements Consta
} }
/** /**
* Internal helper method for constructor * Internal helper method for constructor.
* Add the thread components to the modal container and maintain * Add the thread components to the modal container and maintain
* references for event manipulation purposes. * references for event manipulation purposes.
*/ */
@ -117,7 +118,8 @@ public class DiscussionThreadSimpleView extends ModalContainer implements Consta
Constants.FORUM_XML_NS); Constants.FORUM_XML_NS);
// Offer links to return to index or control alerts. // Offer links to return to index or control alerts.
Link returnLink = new Link(new Label(Text.gz("forum.ui.thread.viewAll")), Link returnLink = new Link(new Label(GlobalizationUtil.gz(
"forum.ui.thread.viewAll")),
"index.jsp"); "index.jsp");
returnLink.setClassAttr("actionLink"); returnLink.setClassAttr("actionLink");
linksPanel.add(returnLink); linksPanel.add(returnLink);
@ -166,7 +168,6 @@ public class DiscussionThreadSimpleView extends ModalContainer implements Consta
/** /**
* Creates the component for viewing a thread. * Creates the component for viewing a thread.
*/ */
private final void addForm(final Form form) { private final void addForm(final Form form) {
add(form); add(form);
form.addCompletionListener(new ActionListener() { form.addCompletionListener(new ActionListener() {
@ -190,9 +191,13 @@ public class DiscussionThreadSimpleView extends ModalContainer implements Consta
/**
*
* @return
*/
private Component createThreadSubscribeLink() { private Component createThreadSubscribeLink() {
ActionLink subscribeLink = new ActionLink( ActionLink subscribeLink = new ActionLink(
new Label(Text.gz("forum.ui.thread.subscribe"))) { new Label(GlobalizationUtil.gz("forum.ui.thread.subscribe"))) {
public boolean isVisible(PageState s) { public boolean isVisible(PageState s) {
Party party = Kernel.getContext().getParty(); Party party = Kernel.getContext().getParty();
@ -223,9 +228,13 @@ public class DiscussionThreadSimpleView extends ModalContainer implements Consta
return subscribeLink; return subscribeLink;
} }
/**
*
* @return
*/
private Component createThreadUnsubscribeLink() { private Component createThreadUnsubscribeLink() {
ActionLink unsubscribeLink = new ActionLink( ActionLink unsubscribeLink = new ActionLink(
new Label(Text.gz("forum.ui.thread.unsubscribe"))) { new Label(GlobalizationUtil.gz("forum.ui.thread.unsubscribe"))) {
@Override @Override
public boolean isVisible(PageState s) { public boolean isVisible(PageState s) {
Party party = Kernel.getContext().getParty(); Party party = Kernel.getContext().getParty();
@ -259,10 +268,19 @@ public class DiscussionThreadSimpleView extends ModalContainer implements Consta
return unsubscribeLink; return unsubscribeLink;
} }
/**
*
* @return
*/
private final ACSObjectSelectionModel getPostModel() { private final ACSObjectSelectionModel getPostModel() {
return m_postModel; return m_postModel;
} }
/**
*
* @param state
* @return
*/
private MessageThread getCurrentMessage(PageState state) { private MessageThread getCurrentMessage(PageState state) {
return ForumContext.getContext(state).getMessageThread(); return ForumContext.getContext(state).getMessageThread();
} }

View File

@ -19,6 +19,7 @@
package com.arsdigita.forum.ui; package com.arsdigita.forum.ui;
import com.arsdigita.forum.util.GlobalizationUtil;
import com.arsdigita.bebop.ColumnPanel; import com.arsdigita.bebop.ColumnPanel;
import com.arsdigita.bebop.Component; import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.Form; import com.arsdigita.bebop.Form;
@ -85,19 +86,19 @@ class ForumAlertsView extends SimpleContainer implements Constants {
Form alertsForm = new Form("instantAlerts", new ColumnPanel(2)); Form alertsForm = new Form("instantAlerts", new ColumnPanel(2));
final RadioGroup instant = new RadioGroup("instant"); final RadioGroup instant = new RadioGroup("instant");
instant.addOption(new Option(Text.gzAsStr("forum.ui.yes"))); instant.addOption(new Option(GlobalizationUtil.gzAsStr("forum.ui.yes")));
instant.addOption(new Option(Text.gzAsStr("forum.ui.no"))); instant.addOption(new Option(GlobalizationUtil.gzAsStr("forum.ui.no")));
alertsForm.add(new Label(Text.gz("forum.ui.receive_instant_alerts"))); alertsForm.add(new Label(GlobalizationUtil.gz("forum.ui.receive_instant_alerts")));
alertsForm.add(instant); alertsForm.add(instant);
final RadioGroup daily = new RadioGroup("daily"); final RadioGroup daily = new RadioGroup("daily");
daily.addOption(new Option(Text.gzAsStr("forum.ui.yes"))); daily.addOption(new Option(GlobalizationUtil.gzAsStr("forum.ui.yes")));
daily.addOption(new Option(Text.gzAsStr("forum.ui.no"))); daily.addOption(new Option(GlobalizationUtil.gzAsStr("forum.ui.no")));
alertsForm.add(new Label(Text.gz("forum.ui.receive_daily_summary"))); alertsForm.add(new Label(GlobalizationUtil.gz("forum.ui.receive_daily_summary")));
alertsForm.add(daily); alertsForm.add(daily);
alertsForm.add(new Label("")); alertsForm.add(new Label(""));
alertsForm.add(new Submit(Text.gz("forum.ui.save"))); alertsForm.add(new Submit(GlobalizationUtil.gz("forum.ui.save")));
alertsForm.addInitListener(new FormInitListener() { alertsForm.addInitListener(new FormInitListener() {
public void init(FormSectionEvent e) { public void init(FormSectionEvent e) {
@ -109,17 +110,17 @@ class ForumAlertsView extends SimpleContainer implements Constants {
ForumSubscription fSub = ForumSubscription fSub =
ForumSubscription.getFromForum(forum); ForumSubscription.getFromForum(forum);
if (fSub.isSubscribed(party)) { if (fSub.isSubscribed(party)) {
instant.setValue(s,Text.gzAsStr("forum.ui.yes")); instant.setValue(s,GlobalizationUtil.gzAsStr("forum.ui.yes"));
} else { } else {
instant.setValue(s, Text.gzAsStr("forum.ui.no")); instant.setValue(s, GlobalizationUtil.gzAsStr("forum.ui.no"));
} }
DailySubscription dSub = (DailySubscription) DailySubscription dSub = (DailySubscription)
DailySubscription.getFromForum(forum); DailySubscription.getFromForum(forum);
if (dSub.isSubscribed(party)) { if (dSub.isSubscribed(party)) {
daily.setValue(s,Text.gzAsStr("forum.ui.yes")); daily.setValue(s,GlobalizationUtil.gzAsStr("forum.ui.yes"));
} else { } else {
daily.setValue(s, Text.gzAsStr("forum.ui.no")); daily.setValue(s, GlobalizationUtil.gzAsStr("forum.ui.no"));
} }
} }
}); });
@ -138,9 +139,9 @@ class ForumAlertsView extends SimpleContainer implements Constants {
DailySubscription dSub = (DailySubscription) DailySubscription dSub = (DailySubscription)
DailySubscription.getFromForum(forum); DailySubscription.getFromForum(forum);
if (data.get("instant").equals(Text.gzAsStr("forum.ui.yes"))) { if (data.get("instant").equals(GlobalizationUtil.gzAsStr("forum.ui.yes"))) {
fSub.subscribe(party); fSub.subscribe(party);
} else if (data.get("instant").equals(Text.gzAsStr("forum.ui.no"))) { } else if (data.get("instant").equals(GlobalizationUtil.gzAsStr("forum.ui.no"))) {
fSub.unsubscribe(party); fSub.unsubscribe(party);
} else { } else {
throw new FormProcessException( throw new FormProcessException(
@ -149,9 +150,9 @@ class ForumAlertsView extends SimpleContainer implements Constants {
} }
fSub.save(); fSub.save();
if (data.get("daily").equals(Text.gzAsStr("forum.ui.yes"))) { if (data.get("daily").equals(GlobalizationUtil.gzAsStr("forum.ui.yes"))) {
dSub.subscribe(party); dSub.subscribe(party);
} else if (data.get("daily").equals(Text.gzAsStr("forum.ui.no"))) { } else if (data.get("daily").equals(GlobalizationUtil.gzAsStr("forum.ui.no"))) {
dSub.unsubscribe(party); dSub.unsubscribe(party);
} else { } else {
throw new FormProcessException( throw new FormProcessException(
@ -180,7 +181,7 @@ class ForumAlertsView extends SimpleContainer implements Constants {
new ArrayParameter(new BigDecimalParameter("delete"))); new ArrayParameter(new BigDecimalParameter("delete")));
form.add(boxes); form.add(boxes);
form.add(new Submit(Text.gz("forum.ui.delete")), form.add(new Submit(GlobalizationUtil.gz("forum.ui.delete")),
FULL_WIDTH | RIGHT); FULL_WIDTH | RIGHT);
form.addProcessListener(new DeleteProcesser()); form.addProcessListener(new DeleteProcesser());

View File

@ -18,6 +18,7 @@
*/ */
package com.arsdigita.forum.ui; package com.arsdigita.forum.ui;
import com.arsdigita.forum.util.GlobalizationUtil;
import java.io.IOException; import java.io.IOException;
import javax.servlet.ServletException; import javax.servlet.ServletException;
@ -265,42 +266,42 @@ public class ForumUserCompactView extends ModalContainer implements Constants {
// jensp 2011-10-02: Additional logic added // jensp 2011-10-02: Additional logic added
if (forum.isPublic()) { if (forum.isPublic()) {
generateModeXML(state, content, MODE_THREADS, generateModeXML(state, content, MODE_THREADS,
Text.gz("forum.ui.modeThreads")); GlobalizationUtil.gz("forum.ui.modeThreads"));
} else { } else {
if (PermissionService.checkPermission(readPermission)) { if (PermissionService.checkPermission(readPermission)) {
generateModeXML(state, content, MODE_THREADS, generateModeXML(state, content, MODE_THREADS,
Text.gz("forum.ui.modeThreads")); GlobalizationUtil.gz("forum.ui.modeThreads"));
} }
} }
// topics panel is always shown as well if not restricted to admins. // topics panel is always shown as well if not restricted to admins.
if (!Forum.getConfig().topicCreationByAdminOnly()) { if (!Forum.getConfig().topicCreationByAdminOnly()) {
generateModeXML(state, content, MODE_TOPICS, generateModeXML(state, content, MODE_TOPICS,
Text.gz("forum.ui.modeTopics")); GlobalizationUtil.gz("forum.ui.modeTopics"));
} }
// alerts panel is always shown as well, no private read access avail. // alerts panel is always shown as well, no private read access avail.
generateModeXML(state, content, MODE_ALERTS, generateModeXML(state, content, MODE_ALERTS,
Text.gz("forum.ui.modeAlerts")); GlobalizationUtil.gz("forum.ui.modeAlerts"));
// admin section // admin section
if (PermissionService.checkPermission(adminPermission)) { if (PermissionService.checkPermission(adminPermission)) {
// generateModeXML(state, content, MODE_MODERATION, // generateModeXML(state, content, MODE_MODERATION,
// Text.gz("forum.ui.modeAlerts")); // GlobalizationUtil.gz("forum.ui.modeAlerts"));
if (Forum.getConfig().showNewTabs()) { if (Forum.getConfig().showNewTabs()) {
generateModeXML(state, content, MODE_SETUP, generateModeXML(state, content, MODE_SETUP,
Text.gz("forum.ui.modeSetup")); GlobalizationUtil.gz("forum.ui.modeSetup"));
generateModeXML(state, content, MODE_PERMISSIONS, generateModeXML(state, content, MODE_PERMISSIONS,
Text.gz("forum.ui.modePermissions")); GlobalizationUtil.gz("forum.ui.modePermissions"));
} else { } else {
// Generate old moderation panel instead of setup // Generate old moderation panel instead of setup
generateModeXML(state, content, MODE_MODERATION, generateModeXML(state, content, MODE_MODERATION,
Text.gz("forum.ui.modeAlerts")); GlobalizationUtil.gz("forum.ui.modeAlerts"));
} }
// In case topic creation is bound to admin (and therefore not // In case topic creation is bound to admin (and therefore not
// created above) we must create xml here. // created above) we must create xml here.
if (Forum.getConfig().topicCreationByAdminOnly()) { if (Forum.getConfig().topicCreationByAdminOnly()) {
generateModeXML(state, content, MODE_TOPICS, generateModeXML(state, content, MODE_TOPICS,
Text.gz("forum.ui.modeTopics")); GlobalizationUtil.gz("forum.ui.modeTopics"));
} }
} }
} }

View File

@ -18,6 +18,7 @@
*/ */
package com.arsdigita.forum.ui; package com.arsdigita.forum.ui;
import com.arsdigita.forum.util.GlobalizationUtil;
import java.io.File; import java.io.File;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
@ -101,7 +102,7 @@ public class ImagesStep
m_upload = new FileUpload("image", true); m_upload = new FileUpload("image", true);
m_upload m_upload
.addValidationListener(new NotEmptyValidationListener( .addValidationListener(new NotEmptyValidationListener(
Text GlobalizationUtil
.gz("forum.ui.validation.image_file_null")) { .gz("forum.ui.validation.image_file_null")) {
public void validate(ParameterEvent e) { public void validate(ParameterEvent e) {
if (m_addImage.isSelected(e.getPageState())) { if (m_addImage.isSelected(e.getPageState())) {
@ -126,7 +127,7 @@ public class ImagesStep
m_description.setRows(5); m_description.setRows(5);
m_description m_description
.addValidationListener(new NotEmptyValidationListener( .addValidationListener(new NotEmptyValidationListener(
Text GlobalizationUtil
.gz("forum.ui.validation.image_description_null")) { .gz("forum.ui.validation.image_description_null")) {
public void validate(ParameterEvent e) { public void validate(ParameterEvent e) {
if (m_addImage.isSelected(e.getPageState())) { if (m_addImage.isSelected(e.getPageState())) {
@ -138,7 +139,7 @@ public class ImagesStep
.addValidationListener(new StringInRangeValidationListener( .addValidationListener(new StringInRangeValidationListener(
0, 0,
4000, 4000,
Text.gz("forum.ui.validation.image_description_too_long")) { GlobalizationUtil.gz("forum.ui.validation.image_description_too_long")) {
public void validate(ParameterEvent e) public void validate(ParameterEvent e)
throws FormProcessException { throws FormProcessException {
if (m_addImage.isSelected(e.getPageState())) { if (m_addImage.isSelected(e.getPageState())) {
@ -218,7 +219,7 @@ public class ImagesStep
if (!m_addImage.isSelected(state) if (!m_addImage.isSelected(state)
&& StringUtils.isNotBlank((String) m_upload.getValue(state))) { && StringUtils.isNotBlank((String) m_upload.getValue(state))) {
throw new FormProcessException( throw new FormProcessException(
(String) Text (String) GlobalizationUtil
.gz("forum.ui.validation.image_not_uploaded") .gz("forum.ui.validation.image_not_uploaded")
.localize()); .localize());
} }

View File

@ -18,6 +18,7 @@
*/ */
package com.arsdigita.forum.ui; package com.arsdigita.forum.ui;
import com.arsdigita.forum.util.GlobalizationUtil;
import java.text.DateFormat; import java.text.DateFormat;
import java.util.Date; import java.util.Date;
@ -81,7 +82,7 @@ public abstract class PostTextStep extends FormStep implements Constants {
m_subject = new TextField(new StringParameter("subject")); m_subject = new TextField(new StringParameter("subject"));
m_subject.addValidationListener( m_subject.addValidationListener(
new NotEmptyValidationListener( new NotEmptyValidationListener(
Text.gz("forum.ui.validation.subject_null"))); GlobalizationUtil.gz("forum.ui.validation.subject_null")));
m_subject.setMaxLength(250); m_subject.setMaxLength(250);
m_subject.setSize(60); m_subject.setSize(60);
add(m_subject); add(m_subject);
@ -114,7 +115,7 @@ public abstract class PostTextStep extends FormStep implements Constants {
m_body.addValidationListener( m_body.addValidationListener(
new NotEmptyValidationListener( new NotEmptyValidationListener(
Text.gz("forum.ui.validation.body_null"))); GlobalizationUtil.gz("forum.ui.validation.body_null")));
add(m_body); add(m_body);

View File

@ -18,6 +18,7 @@
*/ */
package com.arsdigita.forum.ui; package com.arsdigita.forum.ui;
import com.arsdigita.forum.util.GlobalizationUtil;
import com.arsdigita.bebop.Component; import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.Container; import com.arsdigita.bebop.Container;
// import com.arsdigita.bebop.Form; // import com.arsdigita.bebop.Form;
@ -143,7 +144,7 @@ public class ThreadsPanel extends SimpleContainer
Container forumOptions = new SimpleContainer( Container forumOptions = new SimpleContainer(
FORUM_XML_PREFIX + ":forumOptions", Constants.FORUM_XML_NS); FORUM_XML_PREFIX + ":forumOptions", Constants.FORUM_XML_NS);
// XXX APLAWS standard theme currently (2010-09) does not use the label! // XXX APLAWS standard theme currently (2010-09) does not use the label!
m_newThreadLink = new ToggleLink(new Label(Text.gz("forum.ui.thread.newPost"))); m_newThreadLink = new ToggleLink(new Label(GlobalizationUtil.gz("forum.ui.thread.newPost")));
m_newThreadLink.setClassAttr("actionLink"); m_newThreadLink.setClassAttr("actionLink");
// chris.gilbert@westsussex.gov.uk - security container added // chris.gilbert@westsussex.gov.uk - security container added

View File

@ -20,6 +20,7 @@
package com.arsdigita.forum.ui; package com.arsdigita.forum.ui;
import com.arsdigita.forum.util.GlobalizationUtil;
import com.arsdigita.bebop.Form; import com.arsdigita.bebop.Form;
import com.arsdigita.bebop.FormData; import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.FormProcessException; import com.arsdigita.bebop.FormProcessException;
@ -72,12 +73,12 @@ public class TopicAddForm extends Form {
super("categoryAdd"); super("categoryAdd");
setRedirecting(true); // clear form and redirect back setRedirecting(true); // clear form and redirect back
add(new Label(Text.gz("forum.ui.topic.name"))); add(new Label(GlobalizationUtil.gz("forum.ui.topic.name")));
m_name = new TextField("name"); m_name = new TextField("name");
m_name.addValidationListener(new NotNullValidationListener()); m_name.addValidationListener(new NotNullValidationListener());
add(m_name); add(m_name);
add(new Label(Text.gz("forum.ui.topic.description"))); add(new Label(GlobalizationUtil.gz("forum.ui.topic.description")));
m_description = new TextArea("description"); m_description = new TextArea("description");
m_description.setRows(5); m_description.setRows(5);
m_description.setCols(60); m_description.setCols(60);
@ -87,8 +88,8 @@ public class TopicAddForm extends Form {
// Cancel button added cg // Cancel button added cg
// Would have used a saveCancel section but this would make existing // Would have used a saveCancel section but this would make existing
// stylesheets for legacy forums miss the buttons // stylesheets for legacy forums miss the buttons
Submit submit = new Submit(Text.gz("forum.ui.topic.save")); Submit submit = new Submit(GlobalizationUtil.gz("forum.ui.topic.save"));
final Submit cancel = new Submit(Text.gz("forum.ui.cancel")); final Submit cancel = new Submit(GlobalizationUtil.gz("forum.ui.cancel"));
add(submit); add(submit);
add(cancel); add(cancel);
addSubmissionListener(new FormSubmissionListener(){ addSubmissionListener(new FormSubmissionListener(){

View File

@ -18,6 +18,7 @@
*/ */
package com.arsdigita.forum.ui; package com.arsdigita.forum.ui;
import com.arsdigita.forum.util.GlobalizationUtil;
import com.arsdigita.bebop.Component; import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.Container; import com.arsdigita.bebop.Container;
import com.arsdigita.bebop.Form; import com.arsdigita.bebop.Form;
@ -131,7 +132,7 @@ public class TopicsPanel extends SimpleContainer
Constants.FORUM_XML_PREFIX + ":topicOptions", Constants.FORUM_XML_PREFIX + ":topicOptions",
Constants.FORUM_XML_NS); Constants.FORUM_XML_NS);
m_addNewTopicLink = new ToggleLink( m_addNewTopicLink = new ToggleLink(
new Label(Text.gz("forum.ui.topic.newTopic"))); new Label(GlobalizationUtil.gz("forum.ui.topic.newTopic")));
m_addNewTopicLink.setClassAttr("actionLink"); m_addNewTopicLink.setClassAttr("actionLink");
linksPanel.add(m_addNewTopicLink); linksPanel.add(m_addNewTopicLink);
// add to component // add to component

View File

@ -31,7 +31,7 @@ import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.forum.Forum; import com.arsdigita.forum.Forum;
import com.arsdigita.forum.ForumContext; import com.arsdigita.forum.ForumContext;
import com.arsdigita.forum.ui.Text; import com.arsdigita.forum.util.GlobalizationUtil;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
@ -59,24 +59,24 @@ public class ModerationFormSection extends FormSection {
public void addWidgets() { public void addWidgets() {
add(new Label( add(new Label(
Text.gz("forum.ui.moderate.label"))); GlobalizationUtil.gz("forum.ui.moderate.label")));
m_statusOn = new Label( m_statusOn = new Label(
Text.gz("forum.ui.moderate.status.on")); GlobalizationUtil.gz("forum.ui.moderate.status.on"));
m_statusOff = new Label( m_statusOff = new Label(
Text.gz("forum.ui.moderate.status.off")); GlobalizationUtil.gz("forum.ui.moderate.status.off"));
add(m_statusOn); add(m_statusOn);
add(m_statusOff); add(m_statusOff);
m_switchOn = new Submit( m_switchOn = new Submit(
Text.gz("forum.ui.moderate.switch.on")); GlobalizationUtil.gz("forum.ui.moderate.switch.on"));
m_switchOff = new Submit( m_switchOff = new Submit(
Text.gz("forum.ui.moderate.switch.off")); GlobalizationUtil.gz("forum.ui.moderate.switch.off"));
add(m_switchOn); add(m_switchOn);
add(m_switchOff); add(m_switchOff);
m_warning = new Label( m_warning = new Label(
Text.gz("forum.ui.moderate.warning")); GlobalizationUtil.gz("forum.ui.moderate.warning"));
add(m_warning, ColumnPanel.FULL_WIDTH); add(m_warning, ColumnPanel.FULL_WIDTH);
} }

View File

@ -31,7 +31,7 @@ import com.arsdigita.bebop.form.TextField;
import com.arsdigita.bebop.parameters.IntegerParameter; import com.arsdigita.bebop.parameters.IntegerParameter;
import com.arsdigita.forum.Forum; import com.arsdigita.forum.Forum;
import com.arsdigita.forum.ForumContext; import com.arsdigita.forum.ForumContext;
import com.arsdigita.forum.ui.Text; import com.arsdigita.forum.util.GlobalizationUtil;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
@ -60,27 +60,27 @@ public class NoticeboardFormSection extends FormSection {
public void addWidgets() { public void addWidgets() {
add(new Label( add(new Label(
Text.gz("forum.ui.noticeboard.label"))); GlobalizationUtil.gz("forum.ui.noticeboard.label")));
m_statusOn = new Label( m_statusOn = new Label(
Text.gz("forum.ui.noticeboard.status.on")); GlobalizationUtil.gz("forum.ui.noticeboard.status.on"));
m_statusOff = new Label( m_statusOff = new Label(
Text.gz("forum.ui.noticeboard.status.off")); GlobalizationUtil.gz("forum.ui.noticeboard.status.off"));
add(m_statusOn); add(m_statusOn);
add(m_statusOff); add(m_statusOff);
m_switchOn = new Submit( m_switchOn = new Submit(
Text.gz("forum.ui.noticeboard.switch.on")); GlobalizationUtil.gz("forum.ui.noticeboard.switch.on"));
m_switchOff = new Submit( m_switchOff = new Submit(
Text.gz("forum.ui.noticeboard.switch.off")); GlobalizationUtil.gz("forum.ui.noticeboard.switch.off"));
add(m_switchOn); add(m_switchOn);
add(m_switchOff); add(m_switchOff);
m_expiryLabel = new Label( m_expiryLabel = new Label(
Text.gz("forum.ui.noticeboard.expiry_after")); GlobalizationUtil.gz("forum.ui.noticeboard.expiry_after"));
m_expiry = new TextField(new IntegerParameter("expiry")); m_expiry = new TextField(new IntegerParameter("expiry"));
m_changeExpiry = new Submit( m_changeExpiry = new Submit(
Text.gz("forum.ui.noticeboard.change_expiry")); GlobalizationUtil.gz("forum.ui.noticeboard.change_expiry"));
add(m_expiryLabel); add(m_expiryLabel);
add(m_expiry); add(m_expiry);
add(m_changeExpiry); add(m_changeExpiry);

View File

@ -45,19 +45,18 @@ import com.arsdigita.bebop.parameters.StringInRangeValidationListener;
import com.arsdigita.forum.Forum; import com.arsdigita.forum.Forum;
import com.arsdigita.forum.ForumContext; import com.arsdigita.forum.ForumContext;
import com.arsdigita.forum.ui.Constants; import com.arsdigita.forum.ui.Constants;
import com.arsdigita.forum.ui.Text; import com.arsdigita.forum.util.GlobalizationUtil;
import com.arsdigita.web.Application; import com.arsdigita.web.Application;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
* form that allows forum admin to set options * Form that allows forum admin to set options
* that apply to this forum instance * that apply to this forum instance
*/ */
public class SetupView public class SetupView extends Form
extends Form implements FormInitListener, FormSubmissionListener,
implements FormInitListener, FormSubmissionListener, FormProcessListener, FormProcessListener, Constants {
Constants {
private static final Logger s_log = Logger.getLogger(SetupView.class); private static final Logger s_log = Logger.getLogger(SetupView.class);
// values for checkboxes // values for checkboxes
@ -69,65 +68,84 @@ public class SetupView
private static final String AUTOSUBSCRIBE_THREAD_STARTERS = "autosubscribe"; private static final String AUTOSUBSCRIBE_THREAD_STARTERS = "autosubscribe";
private static final String NO_CATEGORY_POSTS_ALLOWED = "nocategory"; private static final String NO_CATEGORY_POSTS_ALLOWED = "nocategory";
private static final String ANONYMOUS_POSTS_ALLOWED = "anonymous"; private static final String ANONYMOUS_POSTS_ALLOWED = "anonymous";
private CheckboxGroup m_settings; private CheckboxGroup m_settings;
private TextField m_expiry; private TextField m_expiry;
private SaveCancelSection m_saveCancel; private SaveCancelSection m_saveCancel;
private TextArea m_introduction; private TextArea m_introduction;
private TextField m_title; private TextField m_title;
/**
* Constructor to create the setup panel.
*/
public SetupView() { public SetupView() {
super("setupForm", new SimpleContainer("forum:setup", FORUM_XML_NS)); super("setupForm", new SimpleContainer("forum:setup", FORUM_XML_NS));
// preliminary step 1: Create a group of options to determine various
// properties of this forum
m_settings = new CheckboxGroup("settings"); m_settings = new CheckboxGroup("settings");
m_settings.addOption(
new Option(
MODERATED,
(String) Text.gz("forum.ui.settings.moderated").localize()));
m_settings.addOption(
new Option(PUBLIC,
(String) Text.gz("forum.ui.settings.public").localize()));
m_settings.addOption(
new Option(
NOTICEBOARD,
(String) Text.gz("forum.ui.settings.noticeboard").
localize()));
m_settings.addOption(
new Option(
ALLOW_FILES,
(String) Text.gz("forum.ui.settings.allowFiles").localize()));
m_settings.addOption(
new Option(
ALLOW_IMAGES,
(String) Text.gz("forum.ui.settings.allowImages").localize()));
m_settings.addOption(
new Option(
AUTOSUBSCRIBE_THREAD_STARTERS,
(String) Text.gz("forum.ui.settings.autosubscribe").localize()));
m_settings.addOption(
new Option(
NO_CATEGORY_POSTS_ALLOWED,
(String) Text.gz("forum.ui.settings.noCategoryPosts").localize()));
m_settings.addOption(
new Option(
ANONYMOUS_POSTS_ALLOWED,
(String) Text.gz("forum.ui.settings.anonymousPosts").localize()));
m_settings.addOption(new Option(MODERATED,
new Label(GlobalizationUtil.gz(
"forum.ui.settings.moderated"))
));
m_settings.addOption(new Option(PUBLIC,
new Label( GlobalizationUtil.gz(
"forum.ui.settings.public"))
));
m_settings.addOption(new Option(NOTICEBOARD,
new Label(GlobalizationUtil.gz(
"forum.ui.settings.noticeboard"))
));
m_settings.addOption(new Option(ALLOW_FILES,
new Label(GlobalizationUtil.gz(
"forum.ui.settings.allowFiles"))
));
m_settings.addOption(new Option(ALLOW_IMAGES,
new Label(GlobalizationUtil.gz(
"forum.ui.settings.allowImages"))
));
m_settings.addOption(new Option(AUTOSUBSCRIBE_THREAD_STARTERS,
new Label(GlobalizationUtil.gz(
"forum.ui.settings.autosubscribe"))
));
m_settings.addOption(new Option(NO_CATEGORY_POSTS_ALLOWED,
new Label(GlobalizationUtil.gz(
"forum.ui.settings.noCategoryPosts"))
));
m_settings.addOption(new Option(ANONYMOUS_POSTS_ALLOWED,
new Label(GlobalizationUtil.gz(
"forum.ui.settings.anonymousPosts"))
));
// preliminary step 2: Create a widget to determin the expiration limit
// for the forum GUI
m_expiry = new TextField(new IntegerParameter("expiry")); m_expiry = new TextField(new IntegerParameter("expiry"));
m_expiry.setMetaDataAttribute("label", (String) Text.gz( m_expiry.setMetaDataAttribute("label", (String) GlobalizationUtil.gz(
"forum.ui.noticeboard.expiry_after").localize()); "forum.ui.noticeboard.expiry_after").localize());
// preliminary step 3: Create a Save - Discard widget for the pane
m_saveCancel = new SaveCancelSection(); m_saveCancel = new SaveCancelSection();
m_saveCancel.getSaveButton().setButtonLabel(Text.gz( m_saveCancel.getSaveButton().setButtonLabel(GlobalizationUtil.gz(
"forum.ui.settings.save")); "forum.ui.settings.save"));
// ////////////////////////////////////////////////////////////////////
// Create the pane
// ////////////////////////////////////////////////////////////////////
/* Introductory text fiel */
m_introduction = new TextArea("introduction", 8, 60, TextArea.SOFT); m_introduction = new TextArea("introduction", 8, 60, TextArea.SOFT);
m_introduction.addValidationListener(new StringInRangeValidationListener( m_introduction.addValidationListener(
0, 4000, Text.gz("forum.ui.validation.introduction_too_long"))); new StringInRangeValidationListener(0, 4000,
m_introduction.setMetaDataAttribute("label", (String) Text.gz( GlobalizationUtil.gz(
"forum.ui.validation.introduction_too_long")
));
m_introduction.setMetaDataAttribute("label", (String) GlobalizationUtil.gz(
"forum.ui.settings.introduction").localize()); "forum.ui.settings.introduction").localize());
m_title = new TextField("title"); m_title = new TextField("title");
m_title.setMetaDataAttribute("label", (String) Text.gz( m_title.setMetaDataAttribute("label", (String) GlobalizationUtil.gz(
"forum.ui.settings.title").localize()); "forum.ui.settings.title").localize());
m_title.setSize(70); m_title.setSize(70);

View File

@ -16,28 +16,45 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
*/ */
package com.arsdigita.forum.ui; package com.arsdigita.forum.util;
import com.arsdigita.globalization.GlobalizedMessage; import com.arsdigita.globalization.GlobalizedMessage;
/** /**
* Contains methods to simplify globalizing keys. * Compilation of methods to simplify the handling of globalizing keys.
* Basically it adds the name of package's resource bundle files to the
* globalize methods and forwards to GlobalizedMessage, shortening the
* method invocation in the various application classes.
*
* *
* @author Daniel Berrange * @author Daniel Berrange
*/ */
public class Text { public class GlobalizationUtil {
/** Name of Java resource files to handle Forum's globalisation. */
private static final String BUNDLE_NAME = private static final String BUNDLE_NAME =
"com.arsdigita.forum.ui.ForumResources"; "com.arsdigita.forum.ForumResources";
/**
* Returns a globalized message using the appropriate bundle.
*/
public static GlobalizedMessage gz(String key) { public static GlobalizedMessage gz(String key) {
return new GlobalizedMessage(key, BUNDLE_NAME); return new GlobalizedMessage(key, BUNDLE_NAME);
} }
/**
* Returns a String, aplying the loclize() method on the globalized message
* using the appropriate bundle.
*/
public static String gzAsStr(String key) { public static String gzAsStr(String key) {
return (String) new GlobalizedMessage(key, BUNDLE_NAME).localize(); return (String) new GlobalizedMessage(key, BUNDLE_NAME).localize();
} }
/**
* Returns a globalized message object, using the approprate bundle,
* takeing in an Object[] of arguments to interpolate into the retrieved
* message using the MessageFormat class.
*/
public static GlobalizedMessage gz(String key, Object[] args) { public static GlobalizedMessage gz(String key, Object[] args) {
return new GlobalizedMessage(key, BUNDLE_NAME, args); return new GlobalizedMessage(key, BUNDLE_NAME, args);
} }