integrated file upload panel
git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/share-updates@90200 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
72d0ecccb4
commit
c6282abab3
|
@ -1,10 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project-modules id="moduleCoreId" project-version="1.5.0">
|
||||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||
<wb-module deploy-name="${module}">
|
||||
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
||||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
|
||||
<dependent-module archiveName="fileupload-progress-bar-0.1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/fileupload-progress-bar/fileupload-progress-bar">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
|
||||
<property name="context-root" value="share-updates"/>
|
||||
</wb-module>
|
||||
|
|
18
pom.xml
18
pom.xml
|
@ -96,6 +96,24 @@
|
|||
<artifactId>pickuser-widget</artifactId>
|
||||
<version>[0.4.0-SNAPSHOT, 1.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.portlets.widgets</groupId>
|
||||
<artifactId>fileupload-progress-bar</artifactId>
|
||||
<version>[0.1.0-SNAPSHOT, 1.0.0-SNAPSHOT)</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-fileupload</groupId>
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
<version>1.2.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>1.4</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>home-library</artifactId>
|
||||
|
|
|
@ -23,5 +23,7 @@ public interface ShareUpdateService extends RemoteService {
|
|||
|
||||
LinkPreview checkLink(String linkToCheck);
|
||||
|
||||
LinkPreview checkUploadedFile(String fileName, String fileabsolutePathOnServer);
|
||||
|
||||
ArrayList<PickingUser> getPortalUsers();
|
||||
}
|
||||
|
|
|
@ -25,4 +25,7 @@ public interface ShareUpdateServiceAsync {
|
|||
void getUserSettings(AsyncCallback<UserSettings> callback);
|
||||
|
||||
void getPortalUsers(AsyncCallback<ArrayList<PickingUser>> callback);
|
||||
|
||||
void checkUploadedFile(String fileName, String fileabsolutePathOnServer,
|
||||
AsyncCallback<LinkPreview> callback);
|
||||
}
|
||||
|
|
|
@ -14,14 +14,23 @@ import org.gcube.portlets.user.shareupdates.client.ShareUpdateService;
|
|||
import org.gcube.portlets.user.shareupdates.client.ShareUpdateServiceAsync;
|
||||
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.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.Window;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
|
@ -51,12 +60,15 @@ 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 HandlerManager eventBus = new HandlerManager(null);
|
||||
|
||||
private static ShareUpdateFormUiBinder uiBinder = GWT
|
||||
.create(ShareUpdateFormUiBinder.class);
|
||||
|
||||
private LinkPreviewer myLinkPreviewer;
|
||||
|
||||
private UploadProgressPanel uploadProgress;
|
||||
|
||||
interface ShareUpdateFormUiBinder extends UiBinder<Widget, ShareUpdateForm> {
|
||||
}
|
||||
|
||||
|
@ -72,7 +84,7 @@ public class ShareUpdateForm extends Composite {
|
|||
|
||||
@UiField
|
||||
Button submitButton;
|
||||
|
||||
|
||||
@UiField
|
||||
Button attachButton;
|
||||
|
||||
|
@ -88,10 +100,10 @@ public class ShareUpdateForm extends Composite {
|
|||
public ShareUpdateForm() {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
singleton = this;
|
||||
|
||||
bind();
|
||||
avatarImage.setUrl(loading);
|
||||
shareTextArea.setText(SHARE_UPDATE_TEXT);
|
||||
|
||||
|
||||
shareupdateService.getUserSettings(new AsyncCallback<UserSettings>() {
|
||||
public void onFailure(Throwable caught) {
|
||||
avatarImage.setSize("60px", "60px");
|
||||
|
@ -114,7 +126,7 @@ public class ShareUpdateForm extends Composite {
|
|||
singleVREName = myUserInfo.getOwnVREs().get(vreId);
|
||||
privacyLevel.addItem(LISTBOX_LEVEL + singleVREName, vreId);
|
||||
}
|
||||
|
||||
|
||||
//privacyLevel.addItem("My Connections", PrivacyLevel.CONNECTION.toString());
|
||||
if (myUserInfo.isAdmin() && userSettings.isInfrastructure())
|
||||
privacyLevel.addItem("Anyone", PrivacyLevel.PORTAL.toString());
|
||||
|
@ -129,11 +141,44 @@ public class ShareUpdateForm extends Composite {
|
|||
});
|
||||
}
|
||||
|
||||
/** Used by UiBinder to instantiate UploadProgressView */
|
||||
@UiFactory
|
||||
UploadProgressPanel instatiateProgressView() {
|
||||
uploadProgress = new UploadProgressPanel(eventBus);
|
||||
uploadProgress.setVisible(false);
|
||||
return uploadProgress;
|
||||
}
|
||||
|
||||
private void bind() {
|
||||
/**
|
||||
* get the uploaded file result
|
||||
*/
|
||||
eventBus.addHandler(FileUploadCompleteEvent.TYPE, new FileUploadCompleteEventHandler() {
|
||||
@Override
|
||||
public void onUploadComplete(FileUploadCompleteEvent event) {
|
||||
String absolutePathOnServer = event.getUploadedFileInfo().getAbsolutePath();
|
||||
GWT.log("uploaded on Server here: " + absolutePathOnServer);
|
||||
checkFile(event.getUploadedFileInfo().getFilename(), absolutePathOnServer);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@UiHandler("shareTextArea")
|
||||
void onShareUpdateClick(ClickEvent e) {
|
||||
shareTextArea.removeSampleText();
|
||||
}
|
||||
|
||||
@UiHandler("attachButton")
|
||||
void onAttachClick(ClickEvent e) {
|
||||
GWT.log("aaa");
|
||||
if (myLinkPreviewer == null) {
|
||||
uploadProgress.initialize();
|
||||
uploadProgress.setVisible(true);
|
||||
} else {
|
||||
Window.alert("You cannot post two files, please remove the previous one first.");
|
||||
}
|
||||
}
|
||||
|
||||
@UiHandler("submitButton")
|
||||
void onClick(ClickEvent e) {
|
||||
shareupdateService.getUserSettings(new AsyncCallback<UserSettings>() {
|
||||
|
@ -158,6 +203,8 @@ public class ShareUpdateForm extends Composite {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param textToPost
|
||||
|
@ -285,6 +332,29 @@ public class ShareUpdateForm extends Composite {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* called when the file was correctly uploaded on server
|
||||
* @param fileName the name of the file
|
||||
* @param absolutePathOnServer the path of the file ending with its name on the server temp
|
||||
*/
|
||||
protected void checkFile(String fileName, String absolutePathOnServer) {
|
||||
preview.add(new LinkLoader());
|
||||
shareupdateService.checkUploadedFile(fileName, absolutePathOnServer, new AsyncCallback<LinkPreview>() {
|
||||
public void onFailure(Throwable caught) {
|
||||
uploadProgress.showRegisteringResult(false);
|
||||
preview.clear();
|
||||
}
|
||||
|
||||
public void onSuccess(LinkPreview result) {
|
||||
preview.clear();
|
||||
uploadProgress.setVisible(false);
|
||||
if (result != null)
|
||||
addPreview(result);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* called when pasting. it tries to avoid pasting long non spaced strings
|
||||
* @param linkToCheck
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
|
||||
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
|
||||
xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:m="urn:import:org.gcube.portlets.user.shareupdates.client.form">
|
||||
xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:m="urn:import:org.gcube.portlets.user.shareupdates.client.form" xmlns:j="urn:import:org.gcube.portlets.widgets.fileupload.client.view">
|
||||
<g:HTMLPanel ui:field="mainPanel">
|
||||
<table class="shareContainer">
|
||||
<tr>
|
||||
|
@ -24,6 +24,7 @@
|
|||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<j:UploadProgressPanel ui:field="uploadProgress"></j:UploadProgressPanel>
|
||||
<m:LinkPlaceholder ui:field="preview"></m:LinkPlaceholder>
|
||||
<table class="toolsContainer">
|
||||
<tr>
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package org.gcube.portlets.user.shareupdates.server;
|
||||
|
||||
public class FilePreviewer {
|
||||
|
||||
}
|
|
@ -309,6 +309,22 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
|||
}
|
||||
return new UserSettings();
|
||||
}
|
||||
/**
|
||||
* generate a preview of the file, upload the file on the storage and shorts the link
|
||||
*/
|
||||
@Override
|
||||
public LinkPreview checkUploadedFile(String fileName, String fileabsolutePathOnServer) {
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ArrayList<String> imagesUrl = new ArrayList<String>();
|
||||
imagesUrl.add("http://www.ask-cato.com/wp-content/uploads/2012/02/PDF5.gif");
|
||||
return new LinkPreview(fileName, "the Desc", "http://www.lalala.com", "d4science.org", imagesUrl);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* return the id as key and the names as value of the vre a user is subscribed to
|
||||
* @param username
|
||||
|
@ -714,4 +730,6 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
|||
Workspace workspace = HomeLibrary.getUserWorkspace(session.getUsername());
|
||||
return workspace;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -13,12 +13,13 @@
|
|||
name="net.eliasbalasis.tibcopagebus4gwt.testsubscriber.TestSubscriber" />
|
||||
|
||||
<!-- To Comment out -->
|
||||
<set-property name="user.agent" value="safari,gecko1_8,ie9" />
|
||||
<set-property name="user.agent" value="safari,gecko1_8,ie9" />
|
||||
|
||||
<!-- Other module inherits -->
|
||||
|
||||
<inherits name='org.gcube.portal.databook.GCubeSocialNetworking' />
|
||||
<inherits name='org.gcube.portlets.widgets.pickuser.PickUser' />
|
||||
<inherits name='org.gcube.portlets.widgets.fileupload.FileUpload' />
|
||||
<!-- Specify the app entry point class. -->
|
||||
<entry-point class='org.gcube.portlets.user.shareupdates.client.ShareUpdates' />
|
||||
|
||||
|
|
|
@ -1,3 +1,12 @@
|
|||
.FileSubmit input {
|
||||
width: 570px !important;
|
||||
}
|
||||
|
||||
.bar-container {
|
||||
width: 600px !important;
|
||||
margin: 1px !important;
|
||||
}
|
||||
|
||||
/* Superpose TextArea and Highlight DIV trick starts here */
|
||||
#supercontainer {
|
||||
position: relative;
|
||||
|
|
|
@ -1,24 +1,47 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
|
||||
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
|
||||
version="2.5"
|
||||
xmlns="http://java.sun.com/xml/ns/javaee">
|
||||
version="2.5" xmlns="http://java.sun.com/xml/ns/javaee">
|
||||
|
||||
<!-- Servlets -->
|
||||
<servlet>
|
||||
<servlet-name>shareupdateServlet</servlet-name>
|
||||
<servlet-class>org.gcube.portlets.user.shareupdates.server.ShareUpdateServiceImpl</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>shareupdateServlet</servlet-name>
|
||||
<url-pattern>/shareupdates/shareupdateServlet</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<!-- Default page to serve -->
|
||||
<welcome-file-list>
|
||||
<welcome-file>ShareUpdates.html</welcome-file>
|
||||
</welcome-file-list>
|
||||
<!-- Servlets -->
|
||||
<servlet>
|
||||
<servlet-name>shareupdateServlet</servlet-name>
|
||||
<servlet-class>org.gcube.portlets.user.shareupdates.server.ShareUpdateServiceImpl</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>shareupdateServlet</servlet-name>
|
||||
<url-pattern>/shareupdates/shareupdateServlet</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
|
||||
<servlet>
|
||||
<servlet-name>uploadprogress</servlet-name>
|
||||
<servlet-class>org.gcube.portlets.widgets.fileupload.server.UploadProgressServlet</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>uploadprogress</servlet-name>
|
||||
<url-pattern>/shareupdates/uploadprogress</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<!-- DO NOT CHANGE -->
|
||||
<servlet>
|
||||
<servlet-name>upload</servlet-name>
|
||||
<servlet-class>org.gcube.portlets.widgets.fileupload.server.UploadServlet</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>upload</servlet-name>
|
||||
<url-pattern>/FileUpload/upload</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<!-- END DO NOT CHANGE -->
|
||||
|
||||
<!-- Default page to serve -->
|
||||
<welcome-file-list>
|
||||
<welcome-file>ShareUpdates.html</welcome-file>
|
||||
</welcome-file-list>
|
||||
|
||||
</web-app>
|
||||
|
|
Loading…
Reference in New Issue