notifications/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/NotificationPreferenceView....

63 lines
1.9 KiB
Java
Raw Normal View History

package org.gcube.portlets.user.notifications.client.view.templates;
import org.gcube.portlets.user.gcubewidgets.client.elements.Span;
import org.gcube.portlets.user.gcubewidgets.client.switchbutton.SwitchButton;
import org.gcube.portlets.user.notifications.shared.NotificationPreference;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
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;
import static com.google.gwt.query.client.GQuery.*;
import static com.google.gwt.query.client.css.CSS.*;
public class NotificationPreferenceView extends Composite {
private static NotificationPreferenceUiBinder uiBinder = GWT
.create(NotificationPreferenceUiBinder.class);
interface NotificationPreferenceUiBinder extends
UiBinder<Widget, NotificationPreferenceView> {
}
@UiField Span prefType;
@UiField Span prefDesc;
@UiField CheckBox portalCheckbox;
@UiField CheckBox emailCheckbox;
@UiField SwitchButton switchButton;
public NotificationPreferenceView(NotificationPreference toDisplay) {
initWidget(uiBinder.createAndBindUi(this));
prefType.setHTML(toDisplay.getTypeLabel());
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);
}
}
});
}
}