file upload stylish, still missing file parsing stuff

git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/share-updates@90219 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2014-01-19 23:23:08 +00:00
parent 6d9d3b47d3
commit 729ce52282
7 changed files with 35 additions and 28 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/share-updates-1.0.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<classpathentry kind="src" output="target/share-updates-1.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
@ -31,5 +31,5 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/share-updates-1.0.0-SNAPSHOT/WEB-INF/classes"/>
<classpathentry kind="output" path="target/share-updates-1.1.0-SNAPSHOT/WEB-INF/classes"/>
</classpath>

View File

@ -1,5 +1,5 @@
eclipse.preferences.version=1
jarsExcludedFromWebInfLib=
lastWarOutDir=/Users/massi/Documents/workspace/share-updates/target/share-updates-1.0.0-SNAPSHOT
lastWarOutDir=/Users/massi/Documents/workspace/share-updates/target/share-updates-1.1.0-SNAPSHOT
warSrcDir=src/main/webapp
warSrcDirIsOutput=false

View File

@ -13,7 +13,7 @@
<groupId>org.gcube.portlets.user</groupId>
<artifactId>share-updates</artifactId>
<packaging>war</packaging>
<version>1.0.0-SNAPSHOT</version>
<version>1.1.0-SNAPSHOT</version>
<name>gCube Share Updates Portlet</name>
<description>

View File

@ -16,25 +16,26 @@ import org.gcube.portlets.user.shareupdates.shared.LinkPreview;
import org.gcube.portlets.user.shareupdates.shared.UserSettings;
import org.gcube.portlets.widgets.fileupload.client.events.FileUploadCompleteEvent;
import org.gcube.portlets.widgets.fileupload.client.events.FileUploadCompleteEventHandler;
import org.gcube.portlets.widgets.fileupload.client.view.FileSubmit;
import org.gcube.portlets.widgets.fileupload.client.view.UploadProgressDialog;
import org.gcube.portlets.widgets.fileupload.client.view.UploadProgressPanel;
import org.gcube.portlets.widgets.fileupload.client.view.UploadProgressView;
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.Display;
import com.google.gwt.dom.client.Style.Visibility;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiFactory;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Element;
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.FileUpload;
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;
@ -59,6 +60,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";
public static final String attach = GWT.getModuleBaseURL() + "../images/attach.png";
private HandlerManager eventBus = new HandlerManager(null);
@ -86,7 +88,7 @@ public class ShareUpdateForm extends Composite {
Button submitButton;
@UiField
Button attachButton;
HTML attachButton;
@UiField
Image avatarImage;
@ -103,7 +105,11 @@ public class ShareUpdateForm extends Composite {
bind();
avatarImage.setUrl(loading);
shareTextArea.setText(SHARE_UPDATE_TEXT);
attachButton.getElement().getStyle().setDisplay(Display.INLINE);
attachButton.setHTML("<span style=\"padding: 5px 1px; background: url('"+attach+"') 50% 50% no-repeat;\">&nbsp;&nbsp;&nbsp;&nbsp;</span>");
shareupdateService.getUserSettings(new AsyncCallback<UserSettings>() {
public void onFailure(Throwable caught) {
avatarImage.setSize("60px", "60px");
@ -140,7 +146,7 @@ public class ShareUpdateForm extends Composite {
}
});
}
/** Used by UiBinder to instantiate UploadProgressView */
@UiFactory
UploadProgressPanel instatiateProgressView() {
@ -170,15 +176,24 @@ public class ShareUpdateForm extends Composite {
@UiHandler("attachButton")
void onAttachClick(ClickEvent e) {
GWT.log("aaa");
if (myLinkPreviewer == null) {
uploadProgress.initialize();
FileUpload up = uploadProgress.initialize();
up.setVisible(false);
fileBrowse(up.getElement());
uploadProgress.setVisible(true);
attachButton.setVisible(false);
attachButton.getElement().getStyle().setVisibility(Visibility.HIDDEN); //beacuse otherwise it looses the other properties setting
} else {
Window.alert("You cannot post two files, please remove the previous one first.");
}
}
/**
* this simulates the click on the hidden native GWT FileUpload Button
* @param el
*/
public static native void fileBrowse(Element el) /*-{
el.click();
}-*/;
@UiHandler("submitButton")
void onClick(ClickEvent e) {
@ -344,7 +359,7 @@ public class ShareUpdateForm extends Composite {
public void onFailure(Throwable caught) {
uploadProgress.showRegisteringResult(false);
preview.clear();
attachButton.setVisible(true);
attachButton.getElement().getStyle().setVisibility(Visibility.VISIBLE); //beacuse otherwise it looses the other properties setting
}
public void onSuccess(LinkPreview result) {
@ -389,6 +404,6 @@ public class ShareUpdateForm extends Composite {
protected void cancelPreview() {
preview.clear();
myLinkPreviewer = null;
attachButton.setVisible(true);
attachButton.getElement().getStyle().setVisibility(Visibility.VISIBLE); //beacuse otherwise it looses the other properties setting
}
}

View File

@ -39,9 +39,8 @@
</td>
<td valign="middle"></td>
<td valign="middle">
<div class="buttonDiv">
<!-- TODO: "Attach a Link" /> -->
<g:Button ui:field="attachButton" width="90px" text="Attach" />
<div class="buttonDiv">
<g:HTML ui:field="attachButton" styleName="gwt-Button"/>
<g:Button ui:field="submitButton" styleName="shareButton" width="90px" text="Share" />
</div>
</td>

View File

@ -1,11 +1,3 @@
.FileSubmit input {
width: 570px !important;
}
.bar-container {
width: 600px !important;
margin: 1px !important;
}
/* Superpose TextArea and Highlight DIV trick starts here */
#supercontainer {
@ -78,6 +70,7 @@
.gwt-Button {
text-shadow: none;
font-weight: normal;
padding: 5px 15px !important;
}
.darker-color {
@ -100,7 +93,7 @@
font-size: 12px;
text-shadow: 0 -1px 1px rgba(0, 0, 0, 0.25);
cursor: pointer;
padding: 3px 15px;
padding: 5px 15px;
}
.shareButton:hover, .shareButton:focus {

Binary file not shown.

After

Width:  |  Height:  |  Size: 558 B