r1661 - in trunk/src/main/java/cc/kune: core/client/state/impl gspace/client/options/general
Author: vjrj_ Date: 2012-01-12 15:45:36 +0100 (Thu, 12 Jan 2012) New Revision: 1661 Modified: trunk/src/main/java/cc/kune/core/client/state/impl/SessionDefault.java trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralPanel.java trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralPresenter.java trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralView.java Log: CLOSED - # 185: Implement email notification levels (hourly and daily) similar to Google Wave http://kune.ourproject.org/issues/ticket/185 Modified: trunk/src/main/java/cc/kune/core/client/state/impl/SessionDefault.java =================================================================== --- trunk/src/main/java/cc/kune/core/client/state/impl/SessionDefault.java 2012-01-12 14:05:46 UTC (rev 1660) +++ trunk/src/main/java/cc/kune/core/client/state/impl/SessionDefault.java 2012-01-12 14:45:36 UTC (rev 1661) @@ -258,7 +258,9 @@ if (!isLogged()) { return false; } - if (getCurrentStateToken().getGroup().equals(getCurrentUser().getShortName())) { + final StateToken currentStateToken = getCurrentStateToken(); + if (currentStateToken != null + && currentStateToken.getGroup().equals(getCurrentUser().getShortName())) { return true; } return false; Modified: trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralPanel.java =================================================================== --- trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralPanel.java 2012-01-12 14:05:46 UTC (rev 1660) +++ trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralPanel.java 2012-01-12 14:45:36 UTC (rev 1661) @@ -20,26 +20,37 @@ package cc.kune.gspace.client.options.general; import cc.kune.common.client.ui.MaskWidget; -import cc.kune.common.shared.i18n.I18nTranslationService; import cc.kune.core.client.auth.UserFieldFactory; +import cc.kune.core.client.i18n.I18nUITranslationService; import cc.kune.core.client.resources.CoreResources; +import cc.kune.core.client.ui.DefaultFormUtils; +import cc.kune.core.shared.domain.dto.EmailNotificationFrequency; import cc.kune.core.shared.dto.I18nLanguageSimpleDTO; import cc.kune.gspace.client.i18n.LanguageSelectorPanel; -import com.extjs.gxt.ui.client.widget.form.CheckBox; +import com.extjs.gxt.ui.client.widget.form.FieldSet; import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign; +import com.extjs.gxt.ui.client.widget.form.Radio; import com.extjs.gxt.ui.client.widget.form.TextField; import com.google.inject.Inject; public class UserOptGeneralPanel extends EntityOptGeneralPanel implements UserOptGeneralView { + public static final String DAILY_TYPE_ID = "k-ngp-type_daily"; + public static final String HOURLY_TYPE_ID = "k-ngp-type_hourly"; + public static final String IMMEDIATE_TYPE_ID = "k-ngp-type_immedi"; private static final String LONG_NAME_FIELD = "k-uogp-lname"; - private final CheckBox emailNotifField; + public static final String NO_TYPE_ID = "k-ngp-type_no"; + public static final String TYPEOFEMAILNOTIF_FIELD = "k-ngp-type_of_email_notif"; + private final Radio dailyRadio; + private final Radio hourlyRadio; + private final Radio immediateRadio; private final LanguageSelectorPanel langSelector; private final TextField<String> longName; + private final Radio noRadio; @Inject - public UserOptGeneralPanel(final I18nTranslationService i18n, final CoreResources res, + public UserOptGeneralPanel(final I18nUITranslationService i18n, final CoreResources res, final MaskWidget maskWidget, final LanguageSelectorPanel langSelector, final UserFieldFactory userFieldFactory) { super(maskWidget, res.emblemSystem(), i18n.t("General"), i18n.t("Change this values:")); @@ -50,12 +61,63 @@ langSelector.setLabelAlign(LabelAlign.LEFT); langSelector.setLangSeparator(":"); add(langSelector); - emailNotifField = new CheckBox(); - emailNotifField.setFieldLabel(i18n.t("Email notifications")); - add(emailNotifField); + + final FieldSet emailNotifTypeFieldSet = new FieldSet(); + emailNotifTypeFieldSet.setHeading(i18n.t("How often do you want to receive email notifications?")); + emailNotifTypeFieldSet.addStyleName("k-form-fieldset"); + emailNotifTypeFieldSet.setCollapsible(false); + emailNotifTypeFieldSet.setWidth("310px"); + emailNotifTypeFieldSet.setAutoHeight(true); + + immediateRadio = DefaultFormUtils.createRadio(emailNotifTypeFieldSet, i18n.t("almost immediately"), + TYPEOFEMAILNOTIF_FIELD, i18n.t( + "you will receive an email with any new messages in your inbox at [%s] almost immediately", + i18n.getSiteCommonName()), IMMEDIATE_TYPE_ID); + immediateRadio.setTabIndex(3); + immediateRadio.setValue(true); + + hourlyRadio = DefaultFormUtils.createRadio(emailNotifTypeFieldSet, i18n.t("at most hourly"), + TYPEOFEMAILNOTIF_FIELD, i18n.t( + "you will receive an email with any new messages in your inbox at [%s] at most hourly", + i18n.getSiteCommonName()), HOURLY_TYPE_ID); + hourlyRadio.setTabIndex(4); + hourlyRadio.setValue(false); + + dailyRadio = DefaultFormUtils.createRadio(emailNotifTypeFieldSet, i18n.t("at most daily"), + TYPEOFEMAILNOTIF_FIELD, i18n.t( + "you will receive an email with any new messages in your inbox at [%s] at most daily", + i18n.getSiteCommonName()), DAILY_TYPE_ID); + dailyRadio.setTabIndex(5); + dailyRadio.setValue(false); + + noRadio = DefaultFormUtils.createRadio( + emailNotifTypeFieldSet, + i18n.t("I don't need email notifications"), + TYPEOFEMAILNOTIF_FIELD, + i18n.t("you will no receive an email with any new messages in your inbox at [%s]", + i18n.getSiteCommonName()), NO_TYPE_ID); + noRadio.setTabIndex(6); + noRadio.setValue(false); + + add(emailNotifTypeFieldSet); } @Override + public EmailNotificationFrequency getEmailNotif() { + if (immediateRadio.getValue()) { + return EmailNotificationFrequency.immediately; + } + if (hourlyRadio.getValue()) { + return EmailNotificationFrequency.hourly; + } + if (dailyRadio.getValue()) { + return EmailNotificationFrequency.daily; + } + // if (noRadio.getValue()) + return EmailNotificationFrequency.no; + } + + @Override public I18nLanguageSimpleDTO getLanguage() { return langSelector.getLanguage(); } @@ -65,14 +127,24 @@ return longName.getValue(); } - public boolean isEmailNofifField() { - return emailNotifField.getValue(); + @Override + public void setEmailNotifChecked(final EmailNotificationFrequency freq) { + switch (freq) { + case no: + noRadio.setValue(true); + break; + case hourly: + hourlyRadio.setValue(true); + break; + case daily: + dailyRadio.setValue(true); + break; + case immediately: + immediateRadio.setValue(true); + break; + } } - public void setEmailNofifField(final boolean value) { - emailNotifField.setValue(value); - } - @Override public void setLanguage(final I18nLanguageSimpleDTO language) { langSelector.setLanguage(language); Modified: trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralPresenter.java =================================================================== --- trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralPresenter.java 2012-01-12 14:05:46 UTC (rev 1660) +++ trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralPresenter.java 2012-01-12 14:45:36 UTC (rev 1661) @@ -28,7 +28,6 @@ import cc.kune.core.client.rpcservices.UserServiceAsync; import cc.kune.core.client.state.Session; import cc.kune.core.client.state.StateManager; -import cc.kune.core.shared.domain.dto.EmailNotificationFrequency; import cc.kune.core.shared.dto.I18nLanguageSimpleDTO; import cc.kune.core.shared.dto.StateAbstractDTO; import cc.kune.core.shared.dto.UserDTO; @@ -75,8 +74,7 @@ final UserSimpleDTO currentUser = session.getCurrentUser(); userView.setLongName(currentUser.getName()); userView.setLanguage(I18nLanguageSimpleDTO.create(currentUser.getLanguage())); - userView.setEmailNofifField(currentUser.getEmailNotifFreq().equals( - EmailNotificationFrequency.immediately)); + userView.setEmailNotifChecked(currentUser.getEmailNotifFreq()); } @Override @@ -89,8 +87,7 @@ final String longName = userView.getLongName(); user.setName(longName); final I18nLanguageSimpleDTO lang = userView.getLanguage(); - user.setEmailNotifFreq(userView.isEmailNofifField() ? EmailNotificationFrequency.immediately - : EmailNotificationFrequency.no); + user.setEmailNotifFreq(userView.getEmailNotif()); userService.get().updateUser(session.getUserHash(), user, userView.getLanguage(), new AsyncCallbackSimple<StateAbstractDTO>() { @Override @@ -110,8 +107,7 @@ } }); }; - } - ); + }); } } } Modified: trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralView.java =================================================================== --- trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralView.java 2012-01-12 14:05:46 UTC (rev 1660) +++ trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralView.java 2012-01-12 14:45:36 UTC (rev 1661) @@ -19,19 +19,21 @@ */ package cc.kune.gspace.client.options.general; +import cc.kune.core.shared.domain.dto.EmailNotificationFrequency; import cc.kune.core.shared.dto.I18nLanguageSimpleDTO; public interface UserOptGeneralView extends EntityOptGeneralView { + EmailNotificationFrequency getEmailNotif(); + I18nLanguageSimpleDTO getLanguage(); String getLongName(); - boolean isEmailNofifField(); + void setEmailNotifChecked(EmailNotificationFrequency freq); - void setEmailNofifField(boolean value); - void setLanguage(I18nLanguageSimpleDTO language); void setLongName(String longName); + }
participants (1)
-
Vicente J. Ruiz Jurado