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.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.google.gwt.core.client.GWT; 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.ui.Button; import com.google.gwt.user.client.ui.CheckBox; 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; import com.google.gwt.query.client.GQuery; import com.google.gwt.query.client.Function; import com.google.gwt.query.client.Selector; import com.google.gwt.query.client.Selectors; import com.google.gwt.query.client.css.CSS; import com.google.gwt.query.client.css.RGBColor; import static com.google.gwt.query.client.GQuery.*; import static com.google.gwt.query.client.css.CSS.*; import static com.google.gwt.query.client.plugins.Effects.Effects; import static com.google.gwt.query.client.GQuery.$; /** * @author Massimiliano Assante ISTI-CNR * */ public class NotificationSettings extends GCubeDialog { 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"; public static final String mailSentNOK = GWT.getModuleBaseURL() + "../images/warning_blue.png"; private Button cancel = new Button("Cancel"); private Button save = new Button("Save"); private LinkedHashMap> preferences; public NotificationSettings(LinkedHashMap> preferences, final NotificationsServiceAsync notificationService) { super(); ScrollPanel scroller = new ScrollPanel(); scroller.setWidth("1000px"); scroller.setHeight("500px"); this.preferences = preferences; buttonsPanel.setWidth("100%"); buttonsPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); container.setStyleName("user-notification"); container.setWidth("950px"); for (String category : preferences.keySet()) { container.add(new CategoryWrapper(category)); for (NotificationPreference pref : preferences.get(category)) { container.add(new NotificationPreferenceView(pref)); } } buttonsContainerPanel.add(cancel); buttonsContainerPanel.add(save); buttonsPanel.add(buttonsContainerPanel); container.add(buttonsPanel); setText("Notification Settings"); scroller.add(container); setWidget(scroller); Label label = new Label("test"); DOM.setElementProperty(label.getElement(), "id", "myId"); buttonsContainerPanel.add(label); Timer t = new Timer() { @Override public void run() { $("#myId").css(CSS.BACKGROUND_COLOR.with(RGBColor.RED)); $("#myId").click(new Function() { @Override public void f(Widget w) { Window.alert("Ciao"); //fade out the button $(w).fadeOut(1000); } }); } }; t.schedule(1000); // save.addClickHandler(new ClickHandler() { // @Override // public void onClick(ClickEvent event) { // // } // }); cancel.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { hide(); } }); } private void showDeliveryResult(boolean success) { container.clear(); container.setHorizontalAlignment(HasAlignment.ALIGN_CENTER); container.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); if (success) { setText("Notifications Settings Saved"); container.add(new Image(mailSentOK)); } else { setText("Notifications Settings Saving Error"); container.add(new Image(mailSentNOK)); container.add(new HTML("There were problems contacting the server, please try again in a short while.")); Button close = new Button("Close"); close.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { hide(); } }); } Button close = new Button("Close"); close.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { hide(); } }); container.add(close); } }