|
|
|
@ -3,50 +3,36 @@ package org.gcube.portlets.user.notifications.client.view;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.LinkedHashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.TreeMap;
|
|
|
|
|
|
|
|
|
|
import org.gcube.portal.databook.shared.NotificationChannelType;
|
|
|
|
|
import org.gcube.portal.databook.shared.NotificationType;
|
|
|
|
|
import org.gcube.portlets.user.gcubewidgets.client.popup.GCubeDialog;
|
|
|
|
|
import org.gcube.portlets.user.notifications.client.NotificationsServiceAsync;
|
|
|
|
|
import org.gcube.portlets.user.notifications.client.view.templates.CategoryWrapper;
|
|
|
|
|
import org.gcube.portlets.user.notifications.client.view.templates.NotificationPreferenceView;
|
|
|
|
|
import org.gcube.portlets.user.notifications.shared.NotificationPreference;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.github.gwtbootstrap.client.ui.Modal;
|
|
|
|
|
import com.github.gwtbootstrap.client.ui.ModalFooter;
|
|
|
|
|
import com.google.gwt.core.client.GWT;
|
|
|
|
|
import com.google.gwt.dom.client.Style.Unit;
|
|
|
|
|
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
|
|
import com.google.gwt.event.dom.client.ClickHandler;
|
|
|
|
|
import com.google.gwt.user.client.DOM;
|
|
|
|
|
import com.google.gwt.user.client.Timer;
|
|
|
|
|
import com.google.gwt.user.client.Window;
|
|
|
|
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
|
|
|
import com.google.gwt.user.client.ui.Button;
|
|
|
|
|
import com.google.gwt.user.client.ui.CheckBox;
|
|
|
|
|
import com.github.gwtbootstrap.client.ui.Button;
|
|
|
|
|
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
|
|
|
|
|
import com.google.gwt.user.client.ui.HTML;
|
|
|
|
|
import com.google.gwt.user.client.ui.HasAlignment;
|
|
|
|
|
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
|
|
|
|
|
import com.google.gwt.user.client.ui.HasVerticalAlignment;
|
|
|
|
|
import com.google.gwt.user.client.ui.HorizontalPanel;
|
|
|
|
|
import com.google.gwt.user.client.ui.Image;
|
|
|
|
|
import com.google.gwt.user.client.ui.Label;
|
|
|
|
|
import com.google.gwt.user.client.ui.ScrollPanel;
|
|
|
|
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
|
|
|
|
import com.google.gwt.user.client.ui.Widget;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author Massimiliano Assante ISTI-CNR
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
public class NotificationSettingsDialog extends GCubeDialog {
|
|
|
|
|
public class NotificationSettingsDialog extends Modal {
|
|
|
|
|
|
|
|
|
|
private VerticalPanel mainPanel = new VerticalPanel();
|
|
|
|
|
private VerticalPanel container = new VerticalPanel();
|
|
|
|
|
private HorizontalPanel buttonsContainerPanel = new HorizontalPanel();
|
|
|
|
|
private HorizontalPanel buttonsPanel = new HorizontalPanel();
|
|
|
|
|
|
|
|
|
|
public static final String loading = GWT.getModuleBaseURL() + "../images/feeds-loader.gif";
|
|
|
|
|
public static final String mailSentOK = GWT.getModuleBaseURL() + "../images/yes.png";
|
|
|
|
@ -59,32 +45,22 @@ public class NotificationSettingsDialog extends GCubeDialog {
|
|
|
|
|
|
|
|
|
|
public NotificationSettingsDialog(LinkedHashMap<String, ArrayList<NotificationPreference>> preferences, final NotificationsServiceAsync notificationService) {
|
|
|
|
|
super();
|
|
|
|
|
ScrollPanel scroller = new ScrollPanel();
|
|
|
|
|
scroller.setWidth("890px");
|
|
|
|
|
scroller.setHeight("500px");
|
|
|
|
|
buttonsPanel.setWidth("100%");
|
|
|
|
|
buttonsPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
|
|
|
|
|
|
|
|
|
|
container.setStyleName("user-notification");
|
|
|
|
|
container.setWidth("850px");
|
|
|
|
|
|
|
|
|
|
setAnimation(true);
|
|
|
|
|
//container.setStyleName("user-notification");
|
|
|
|
|
setWidth(950);
|
|
|
|
|
for (String category : preferences.keySet()) {
|
|
|
|
|
CategoryWrapper cat = new CategoryWrapper(category, preferences.get(category));
|
|
|
|
|
container.add(cat);
|
|
|
|
|
add(cat);
|
|
|
|
|
myCategories.add(cat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
buttonsContainerPanel.add(cancel);
|
|
|
|
|
buttonsContainerPanel.add(save);
|
|
|
|
|
buttonsPanel.add(buttonsContainerPanel);
|
|
|
|
|
//container.add(buttonsPanel);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setText("Notification Settings");
|
|
|
|
|
scroller.add(container);
|
|
|
|
|
mainPanel.add(scroller);
|
|
|
|
|
mainPanel.add(buttonsPanel);
|
|
|
|
|
setWidget(mainPanel);
|
|
|
|
|
setTitle("Notification Settings");
|
|
|
|
|
|
|
|
|
|
ModalFooter footer = new ModalFooter();
|
|
|
|
|
save.setType(ButtonType.PRIMARY);
|
|
|
|
|
footer.add(save);
|
|
|
|
|
footer.add(cancel);
|
|
|
|
|
add(footer);
|
|
|
|
|
|
|
|
|
|
save.addClickHandler(new ClickHandler() {
|
|
|
|
|
@Override
|
|
|
|
@ -126,12 +102,12 @@ public class NotificationSettingsDialog extends GCubeDialog {
|
|
|
|
|
mainPanel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER);
|
|
|
|
|
mainPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
|
|
|
|
|
if (success) {
|
|
|
|
|
setText("Notifications Settings Saved");
|
|
|
|
|
setTitle("Notifications Settings Saved");
|
|
|
|
|
mainPanel.add(new HTML("<span style=\"font-size: 24px;\">Notifications Settings correctly saved.</span>"));
|
|
|
|
|
mainPanel.add(new Image(mailSentOK));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
setText("Notifications Settings Saving Error");
|
|
|
|
|
setTitle("Notifications Settings Saving Error");
|
|
|
|
|
mainPanel.add(new Image(mailSentNOK));
|
|
|
|
|
mainPanel.add(new HTML("There were problems contacting the server, please try again in a short while."));
|
|
|
|
|
Button close = new Button("Close");
|
|
|
|
|