* The system settings to use when preloading the form.
*/
private void generateForm(final SystemSettings systemSettingValues)
{
this.clear();
final FormBuilder form = new FormBuilder("", SystemSettingsModel.getInstance(), Method.UPDATE);
Session.getInstance()
.getEventBus()
.addObserver(UpdatedSystemSettingsResponseEvent.class,
new Observer<UpdatedSystemSettingsResponseEvent>()
{
public void update(final UpdatedSystemSettingsResponseEvent arg1)
{
form.onSuccess();
Session.getInstance()
.getEventBus()
.notifyObservers(new ShowNotificationEvent(new Notification("Settings saved")));
clearRetainedValues();
}
});
form.setOnCancelHistoryToken(Session.getInstance().generateUrl(new CreateUrlRequest(Page.START)));
form.turnOffChangeCheck();
hideableSiteLabel = new HideableTextAreaFormElement(MAX_SITELABEL, "Site Labeling", "siteLabel",
systemSettingValues.getSiteLabel(), "I would like to add a label to the system.",
"The site label will be displayed above the global navigation bar and below the "
+ "footer on all pages in the system. If disabled, no label area will "
+ "appear on your pages.", true);
hideablePluginWarning = new HideableRichTextAreaFormElement("Plugin Configuration Warning", "pluginWarning",
systemSettingValues.getPluginWarning(),
"I would like to setup a plugin configuration warning for the system.",
"This text will be displayed everytime a user configures a plugin for an individual or group", true);
hideableContentWarning = new HideableTextAreaFormElement(MAX_CONTENT_WARNING, "Content Warning",
"contentWarningText", systemSettingValues.getContentWarningText(),
"I would like to add a warning to Activity Stream post boxes.",
"This text will be displayed on the Activity Stream post boxes throughout the system.", true);
activityExp = new ActivityExpirationFormElement(systemSettingValues.getContentExpiration(),
"contentExpiration", true);
tosElement = new HideableRichTextAreaFormElement("Terms Of Service", "termsOfService",
systemSettingValues.getTermsOfService(), "I would like to setup the Terms of Service for the system.",
"Users will be prompted to agree or disagree with a Terms of Service message "
+ "on an interval of your choice. You can also add a link to the full "
+ "Terms of Service document.", true);
tosElement.addStyleName(StaticResourceBundle.INSTANCE.coreCss().hideableTextarea());
form.addFormElement(new PersonModelViewLookupFormElement("Eureka Administrators", "Add Administrator", "",
"admins", systemSettingValues.getSystemAdministrators(), true));
form.addFormDivider();
Integer promptVal = systemSettingValues.getTosPromptInterval();
if (null == promptVal)
{
promptVal = 1;
}
promptInterval = new TermsOfServicePromptIntervalFormElement(promptVal, "tosPromptInterval");
form.addFormElement(new UserAssociationFormElement(systemSettingValues));
BasicCheckBoxFormElement sendEmails = new BasicCheckBoxFormElement("", "sendWelcomeEmails",
"Send email invitations to new users as their accounts are created.", false,
systemSettingValues.getSendWelcomeEmails());
sendEmails.addStyleName(StaticResourceBundle.INSTANCE.coreCss().welcomeEmailCheckbox());
membershipRefreshButton = initializeRefreshButton();
FlowPanel clearPanel = new FlowPanel();
clearPanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().clear());
sendEmails.add(membershipRefreshButton);
form.addFormElement(sendEmails);
form.addFormDivider();
form.addWidget(new SendNotificationWidget());
form.addFormDivider();
form.addFormElement(hideableSiteLabel);
form.addFormDivider();
form.addFormElement(hideableContentWarning);
form.addFormDivider();
form.addFormElement(hideablePluginWarning);
form.addFormDivider();
form.addFormElement(tosElement);
form.addFormElement(promptInterval);
form.addFormDivider();
// Help Page
form.addFormElement(new BasicTextBoxFormElement(MAX_GROUP_NAME, false, "Support Stream",
"supportStreamGroupShortName", systemSettingValues.getSupportStreamGroupShortName(),
"Enter the name of the stream you want to display on the help page", false));
form.addFormDivider();
form.addFormElement(activityExp);
form.addFormDivider();
BasicCheckBoxFormElement groupCreationPolicy = new BasicCheckBoxFormElement("New Group Moderation",
"allUsersCanCreateGroups", "Enable Moderation.",
"By enabling moderation, system administrators will be required to review new group requests. "
+ "Groups pending approval will be listed under the pending tab of system settings.", false,
!systemSettingValues.getAllUsersCanCreateGroups());
// The key is true for "allowing group creation" and the checkbox displays "allowing moderation". Since
// these are opposites, the value needs to be reversed when the form gets submitted.
groupCreationPolicy.setReverseValue(true);
form.addFormElement(groupCreationPolicy);
form.addFormDivider();
if (!tosElement.isChecked())
{
promptInterval.setVisible(false);
}