2013-06-05 18:45:10 +02:00
|
|
|
package org.gcube.portlets.user.notifications.client.view.templates;
|
|
|
|
|
2013-06-06 18:53:28 +02:00
|
|
|
import org.gcube.portlets.user.gcubewidgets.client.elements.Span;
|
|
|
|
import org.gcube.portlets.user.gcubewidgets.client.switchbutton.SwitchButton;
|
2013-06-05 18:45:10 +02:00
|
|
|
import org.gcube.portlets.user.notifications.shared.NotificationPreference;
|
|
|
|
|
|
|
|
import com.google.gwt.core.client.GWT;
|
2013-06-06 18:53:28 +02:00
|
|
|
import com.google.gwt.event.logical.shared.ValueChangeEvent;
|
|
|
|
import com.google.gwt.event.logical.shared.ValueChangeHandler;
|
2013-06-05 18:45:10 +02:00
|
|
|
import com.google.gwt.uibinder.client.UiBinder;
|
|
|
|
import com.google.gwt.uibinder.client.UiField;
|
|
|
|
import com.google.gwt.user.client.ui.CheckBox;
|
|
|
|
import com.google.gwt.user.client.ui.Composite;
|
|
|
|
import com.google.gwt.user.client.ui.Widget;
|
|
|
|
|
2013-06-06 18:53:28 +02:00
|
|
|
import static com.google.gwt.query.client.GQuery.*;
|
|
|
|
import static com.google.gwt.query.client.css.CSS.*;
|
|
|
|
|
2013-06-05 18:45:10 +02:00
|
|
|
public class NotificationPreferenceView extends Composite {
|
|
|
|
|
|
|
|
private static NotificationPreferenceUiBinder uiBinder = GWT
|
|
|
|
.create(NotificationPreferenceUiBinder.class);
|
|
|
|
|
|
|
|
interface NotificationPreferenceUiBinder extends
|
2013-06-06 18:53:28 +02:00
|
|
|
UiBinder<Widget, NotificationPreferenceView> {
|
2013-06-05 18:45:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@UiField Span prefType;
|
|
|
|
@UiField Span prefDesc;
|
|
|
|
|
|
|
|
@UiField CheckBox portalCheckbox;
|
|
|
|
@UiField CheckBox emailCheckbox;
|
2013-06-06 18:53:28 +02:00
|
|
|
@UiField SwitchButton switchButton;
|
|
|
|
|
2013-06-05 18:45:10 +02:00
|
|
|
public NotificationPreferenceView(NotificationPreference toDisplay) {
|
|
|
|
initWidget(uiBinder.createAndBindUi(this));
|
|
|
|
prefType.setHTML(toDisplay.getTypeLabel());
|
2013-06-06 18:53:28 +02:00
|
|
|
prefDesc.setHTML("("+toDisplay.getTypeDesc()+")");
|
|
|
|
switchButton.setValue(true);
|
|
|
|
|
|
|
|
switchButton.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
|
|
|
|
@Override
|
|
|
|
public void onValueChange(ValueChangeEvent<Boolean> event) {
|
|
|
|
if (event.getValue()) {
|
|
|
|
portalCheckbox.setValue(true);
|
|
|
|
emailCheckbox.setValue(true);
|
|
|
|
$(portalCheckbox).fadeIn(300);
|
|
|
|
$(emailCheckbox).fadeIn(300);
|
|
|
|
} else {
|
|
|
|
portalCheckbox.setValue(false);
|
|
|
|
emailCheckbox.setValue(false);
|
|
|
|
$(portalCheckbox).fadeOut(300);
|
|
|
|
$(emailCheckbox).fadeOut(300);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
2013-06-05 18:45:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|