added hide image checkbox and its handler

git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/share-updates@90121 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2014-01-14 22:44:43 +00:00
parent e941506d7b
commit 72d0ecccb4
5 changed files with 57 additions and 29 deletions

View File

@ -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<String> 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<String> imageUrls) {
this.imageUrls = imageUrls;
if (imageUrls.size() == 0) {
@ -83,13 +87,29 @@ public class ImageSwitcher extends Composite{
enableSwitch(imageUrls);
}
}
private void enableSwitch(ArrayList<String> 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);
}
}
}

View File

@ -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());

View File

@ -22,6 +22,7 @@
<div class="link-desc">
<g:HTML styleName="" ui:field="descText" />
<div class="hide-description">
<g:CheckBox ui:field="hideImageCheckBox">Hide Image</g:CheckBox>
<g:CheckBox ui:field="hideCheckBox">Hide Description</g:CheckBox>
</div>
</div>

View File

@ -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);

View File

@ -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 {