diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 3cb6dd5..505c604 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -5,6 +5,9 @@ + + uses + diff --git a/pom.xml b/pom.xml index 6d37331..d05e612 100644 --- a/pom.xml +++ b/pom.xml @@ -69,6 +69,11 @@ gcube-widgets provided + + org.gcube.portlets.widgets + switch-button-widget + [1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT) + org.gcube.portal custom-portal-handler @@ -79,6 +84,11 @@ aslcore provided + + org.gcube.core + common-scope-maps + [1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT) + com.liferay.portal portal-service diff --git a/src/main/java/org/gcube/portlets/user/notifications/client/view/switchbutton/SwitchButton.java b/src/main/java/org/gcube/portlets/user/notifications/client/view/switchbutton/SwitchButton.java deleted file mode 100644 index 9bb5b2e..0000000 --- a/src/main/java/org/gcube/portlets/user/notifications/client/view/switchbutton/SwitchButton.java +++ /dev/null @@ -1,137 +0,0 @@ -package org.gcube.portlets.user.notifications.client.view.switchbutton; - -import static com.google.gwt.query.client.GQuery.$; - -import org.gcube.portlets.user.gcubewidgets.client.elements.Div; -import org.gcube.portlets.user.gcubewidgets.client.elements.Span; - -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.event.logical.shared.ValueChangeEvent; -import com.google.gwt.event.logical.shared.ValueChangeHandler; -import com.google.gwt.event.shared.HandlerRegistration; -import com.google.gwt.query.client.Function; -import com.google.gwt.query.client.css.CSS; -import com.google.gwt.query.client.css.Length; -import com.google.gwt.query.client.css.RGBColor; -import com.google.gwt.uibinder.client.UiBinder; -import com.google.gwt.uibinder.client.UiField; -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.CheckBox; -import com.google.gwt.user.client.ui.Composite; -import com.google.gwt.user.client.ui.FocusPanel; -import com.google.gwt.user.client.ui.HasName; -import com.google.gwt.user.client.ui.HasValue; -import com.google.gwt.user.client.ui.Widget; - -public class SwitchButton extends Composite implements HasName, HasValue{ - - private static SwitchButtonUiBinder uiBinder = GWT - .create(SwitchButtonUiBinder.class); - - interface SwitchButtonUiBinder extends UiBinder { - } - @UiField FocusPanel switchContainer; - @UiField Div switcherButton; - @UiField Span labelOff; - @UiField Span labelOn; - private String name; - private Boolean value; - private Boolean valueChangeHandlerInitialized = Boolean.FALSE; - - public SwitchButton() { - name = DOM.createUniqueId(); - initWidget(uiBinder.createAndBindUi(this)); - value = false; - $(switcherButton).css(CSS.LEFT.with(Length.px(-1))); - ensureDomEventHandlers(); - } - - public SwitchButton(boolean initialValue) { - this(); - setValue(initialValue); - } - - @Override - public HandlerRegistration addValueChangeHandler(ValueChangeHandler handler) { - // Is this the first value change handler? If so, time to add handlers - if (!valueChangeHandlerInitialized) { - valueChangeHandlerInitialized = true; - } - return addHandler(handler, ValueChangeEvent.getType()); - } - - @Override - public Boolean getValue() { - return value; - } - /** - * Checks or unchecks the switch button box, firing {@link ValueChangeEvent} if - * appropriate. - *

- * Note that this does not set the value property of the checkbox - * input element wrapped by this widget. For access to that property, see - * {@link #setFormValue(String)} - * - * @param value true to set on, false to set off; null value implies false - */ - @Override - public void setValue(Boolean value) { - if (value == null) { - value = Boolean.FALSE; - } - - Boolean oldValue = getValue(); - if (value.equals(oldValue)) { - return; - } - this.value = value; - if (!value) { - $(switcherButton).animate("left: -1", 250); - labelOff.setStyleName("switch-button-label on"); - labelOn.setStyleName("switch-button-label off"); - } else { - $(switcherButton).animate("left: 12", 250); - labelOff.setStyleName("switch-button-label off"); - labelOn.setStyleName("switch-button-label on"); - } - } - /** - * Checks or unchecks the switch button box, firing {@link ValueChangeEvent} if - * appropriate. - *

- * - * @param value true to set on, false to set off; null value implies false - * @param fireEvents If true, and value has changed, fire a - * {@link ValueChangeEvent} - */ - @Override - public void setValue(Boolean value, boolean fireEvents) { - setValue(value); - if (fireEvents) { - ValueChangeEvent.fire(this, value); - } - } - - protected void ensureDomEventHandlers() { - switchContainer.addClickHandler(new ClickHandler() { - public void onClick(ClickEvent event) { - setValue(!value); - ValueChangeEvent.fire(SwitchButton.this, getValue()); - } - }); - } - - @Override - public void setName(String name) { - this.name = name; - } - - @Override - public String getName() { - return name; - } -} diff --git a/src/main/java/org/gcube/portlets/user/notifications/client/view/switchbutton/SwitchButton.ui.xml b/src/main/java/org/gcube/portlets/user/notifications/client/view/switchbutton/SwitchButton.ui.xml deleted file mode 100644 index 0f7241f..0000000 --- a/src/main/java/org/gcube/portlets/user/notifications/client/view/switchbutton/SwitchButton.ui.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - OFF - - - - ON -

- - \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/CategoryWrapper.java b/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/CategoryWrapper.java index 1cda6e3..35d7ce7 100644 --- a/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/CategoryWrapper.java +++ b/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/CategoryWrapper.java @@ -8,8 +8,8 @@ import java.util.HashMap; import org.gcube.portal.databook.shared.NotificationChannelType; import org.gcube.portal.databook.shared.NotificationType; import org.gcube.portlets.user.gcubewidgets.client.elements.Span; -import org.gcube.portlets.user.notifications.client.view.switchbutton.SwitchButton; import org.gcube.portlets.user.notifications.shared.NotificationPreference; +import org.gcube.portlets.widgets.switchbutton.client.SwitchButton; import com.google.gwt.core.client.GWT; import com.google.gwt.event.logical.shared.ValueChangeEvent; diff --git a/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/CategoryWrapper.ui.xml b/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/CategoryWrapper.ui.xml index 16e7722..372f145 100644 --- a/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/CategoryWrapper.ui.xml +++ b/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/CategoryWrapper.ui.xml @@ -1,6 +1,6 @@ diff --git a/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/NotificationPreferenceView.java b/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/NotificationPreferenceView.java index 2456fc5..1b976d0 100644 --- a/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/NotificationPreferenceView.java +++ b/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/NotificationPreferenceView.java @@ -7,8 +7,8 @@ import java.util.ArrayList; import org.gcube.portal.databook.shared.NotificationChannelType; import org.gcube.portal.databook.shared.NotificationType; import org.gcube.portlets.user.gcubewidgets.client.elements.Span; -import org.gcube.portlets.user.notifications.client.view.switchbutton.SwitchButton; import org.gcube.portlets.user.notifications.shared.NotificationPreference; +import org.gcube.portlets.widgets.switchbutton.client.SwitchButton; import com.google.gwt.core.client.GWT; import com.google.gwt.event.logical.shared.ValueChangeEvent; diff --git a/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/NotificationPreferenceView.ui.xml b/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/NotificationPreferenceView.ui.xml index 9e139f7..9fda583 100644 --- a/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/NotificationPreferenceView.ui.xml +++ b/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/NotificationPreferenceView.ui.xml @@ -1,7 +1,7 @@ diff --git a/src/main/resources/org/gcube/portlets/user/notifications/Notifications.gwt.xml b/src/main/resources/org/gcube/portlets/user/notifications/Notifications.gwt.xml index 85fee8a..c48e90f 100644 --- a/src/main/resources/org/gcube/portlets/user/notifications/Notifications.gwt.xml +++ b/src/main/resources/org/gcube/portlets/user/notifications/Notifications.gwt.xml @@ -9,10 +9,10 @@ - +