diff --git a/src/main/java/org/gcube/portlets/user/shareupdates/client/form/ImageSwitcher.java b/src/main/java/org/gcube/portlets/user/shareupdates/client/form/ImageSwitcher.java index b708aff..8ccf694 100644 --- a/src/main/java/org/gcube/portlets/user/shareupdates/client/form/ImageSwitcher.java +++ b/src/main/java/org/gcube/portlets/user/shareupdates/client/form/ImageSwitcher.java @@ -3,9 +3,9 @@ package org.gcube.portlets.user.shareupdates.client.form; import java.util.ArrayList; import com.google.gwt.core.client.GWT; +import com.google.gwt.dom.client.Style.Visibility; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; -import com.google.gwt.uibinder.client.UiHandler; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HasHorizontalAlignment; @@ -13,7 +13,9 @@ import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.Image; import com.google.gwt.user.client.ui.VerticalPanel; -public class ImageSwitcher extends Composite{ +public class ImageSwitcher extends Composite { + + public static final String blank_image_url = GWT.getModuleBaseURL() + "../images/white-grad.gif"; private ArrayList imageUrls; private VerticalPanel mainPanel = new VerticalPanel(); @@ -23,6 +25,8 @@ public class ImageSwitcher extends Composite{ private HTML label = new HTML("1 of 1"); private HTML next = new HTML(" >> "); private int currentIndex = 0; + + private boolean visible = true; public ImageSwitcher() { super(); @@ -30,21 +34,21 @@ public class ImageSwitcher extends Composite{ mainPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); mainPanel.setPixelSize(100, 100); mainPanel.add(image); - + controlPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); controlPanel.add(prev); controlPanel.add(label); controlPanel.add(next); mainPanel.add(controlPanel); - + prev.setStyleName("small-text-arrow"); label.setStyleName("small-text"); next.setStyleName("small-text-arrow"); - - + + initWidget(mainPanel); - + next.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (imageUrls != null && currentIndex < imageUrls.size()) { @@ -54,7 +58,7 @@ public class ImageSwitcher extends Composite{ } } }); - + prev.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (imageUrls != null && currentIndex > 0) { @@ -66,8 +70,8 @@ public class ImageSwitcher extends Composite{ }); } - - + + protected void setImages(ArrayList imageUrls) { this.imageUrls = imageUrls; if (imageUrls.size() == 0) { @@ -83,13 +87,29 @@ public class ImageSwitcher extends Composite{ enableSwitch(imageUrls); } } - + private void enableSwitch(ArrayList imageUrls) { label.setHTML("1 of " + imageUrls.size()); currentIndex = 0; } - + protected String getSelectedImageURL() { + if (!visible) + image.setUrl(blank_image_url); return image.getUrl(); } + /** + * because i don't want it to me removed from DOM + */ + public void setVisible(boolean visible) { + this.visible = visible; + if (visible) { + image.getElement().getStyle().setVisibility(Visibility.VISIBLE); + controlPanel.getElement().getStyle().setVisibility(Visibility.VISIBLE); + } + else { + image.getElement().getStyle().setVisibility(Visibility.HIDDEN); + controlPanel.getElement().getStyle().setVisibility(Visibility.HIDDEN); + } + } } diff --git a/src/main/java/org/gcube/portlets/user/shareupdates/client/form/LinkPreviewer.java b/src/main/java/org/gcube/portlets/user/shareupdates/client/form/LinkPreviewer.java index fefa3ee..7a3f1a1 100644 --- a/src/main/java/org/gcube/portlets/user/shareupdates/client/form/LinkPreviewer.java +++ b/src/main/java/org/gcube/portlets/user/shareupdates/client/form/LinkPreviewer.java @@ -23,6 +23,20 @@ public class LinkPreviewer extends Composite { private ShareUpdateForm parent; private LinkPreview toShow; + + @UiField HTML closeImage; + @UiField ImageSwitcher switcher; + + @UiField + HTML titleArea; + @UiField + HTML urlText; + @UiField + HTML descText; + @UiField + CheckBox hideCheckBox; + @UiField + CheckBox hideImageCheckBox; public LinkPreviewer(ShareUpdateForm parent, LinkPreview toShow) { initWidget(uiBinder.createAndBindUi(this)); @@ -39,17 +53,8 @@ public class LinkPreviewer extends Composite { switcher.setImages(toShow.getImageUrls()); } - @UiField HTML closeImage; - @UiField ImageSwitcher switcher; - - @UiField - HTML titleArea; - @UiField - HTML urlText; - @UiField - HTML descText; - @UiField - CheckBox hideCheckBox; + + public ImageSwitcher getSwitcher() { return switcher; @@ -60,6 +65,11 @@ public class LinkPreviewer extends Composite { parent.cancelPreview(); } + @UiHandler("hideImageCheckBox") + void onHideImageClick(ClickEvent e) { + switcher.setVisible(!hideImageCheckBox.getValue()); + } + @UiHandler("hideCheckBox") void onClick(ClickEvent e) { descText.setVisible(!hideCheckBox.getValue()); diff --git a/src/main/java/org/gcube/portlets/user/shareupdates/client/form/LinkPreviewer.ui.xml b/src/main/java/org/gcube/portlets/user/shareupdates/client/form/LinkPreviewer.ui.xml index 1242154..2b5b2c1 100644 --- a/src/main/java/org/gcube/portlets/user/shareupdates/client/form/LinkPreviewer.ui.xml +++ b/src/main/java/org/gcube/portlets/user/shareupdates/client/form/LinkPreviewer.ui.xml @@ -22,6 +22,7 @@ diff --git a/src/main/java/org/gcube/portlets/user/shareupdates/client/form/ShareUpdateForm.java b/src/main/java/org/gcube/portlets/user/shareupdates/client/form/ShareUpdateForm.java index 6e0ae2d..7939495 100644 --- a/src/main/java/org/gcube/portlets/user/shareupdates/client/form/ShareUpdateForm.java +++ b/src/main/java/org/gcube/portlets/user/shareupdates/client/form/ShareUpdateForm.java @@ -18,9 +18,6 @@ import org.jsonmaker.gwt.client.Jsonizer; import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.Document; -import com.google.gwt.dom.client.Style.FontStyle; -import com.google.gwt.dom.client.Style.FontWeight; -import com.google.gwt.dom.client.Style.TextDecoration; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; @@ -29,7 +26,6 @@ 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.Composite; -import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTMLPanel; import com.google.gwt.user.client.ui.Image; import com.google.gwt.user.client.ui.ListBox; @@ -55,6 +51,7 @@ public class ShareUpdateForm extends Composite { public static final String loading = GWT.getModuleBaseURL() + "../images/avatarLoader.gif"; public static final String avatar_default = GWT.getModuleBaseURL() + "../images/Avatar_default.png"; + private static ShareUpdateFormUiBinder uiBinder = GWT .create(ShareUpdateFormUiBinder.class); diff --git a/src/main/java/org/gcube/portlets/user/shareupdates/server/ShareUpdateServiceImpl.java b/src/main/java/org/gcube/portlets/user/shareupdates/server/ShareUpdateServiceImpl.java index cf57ccc..ff36768 100644 --- a/src/main/java/org/gcube/portlets/user/shareupdates/server/ShareUpdateServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/shareupdates/server/ShareUpdateServiceImpl.java @@ -113,8 +113,8 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar if (user == null) { _log.warn("USER IS NULL setting test.user and Running OUTSIDE PORTAL"); user = "test.user"; -// user = "massimiliano.assante"; -// SessionManager.getInstance().getASLSession(sessionID, user).setScope("/gcube/devsec/devVRE"); + user = "massimiliano.assante"; + SessionManager.getInstance().getASLSession(sessionID, user).setScope("/gcube/devsec/devVRE"); withinPortal = false; } else {