Added Share
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-share-widget@92867 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
7bde26acbf
commit
235299f9c4
|
@ -1,12 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/tabular-data-share-widget-1.0.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<classpathentry kind="src" output="target/tabular-data-share-widget-0.0.1-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/tabular-data-share-widget-1.0.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
||||
<classpathentry excluding="**" kind="src" output="target/tabular-data-share-widget-0.0.1-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
|
@ -30,8 +30,7 @@
|
|||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/tabular-data-share-widget-1.0.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
<classpathentry kind="output" path="target/tabular-data-share-widget-0.0.1-SNAPSHOT/WEB-INF/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
eclipse.preferences.version=1
|
||||
lastWarOutDir=/home/giancarlo/workspace/tabular-data-share-widget/target/tabular-data-share-widget-1.0.0-SNAPSHOT
|
||||
lastWarOutDir=/home/giancarlo/workspace/tabular-data-share-widget/target/tabular-data-share-widget-0.0.1-SNAPSHOT
|
||||
warSrcDir=src/main/webapp
|
||||
warSrcDirIsOutput=false
|
||||
|
|
6
pom.xml
6
pom.xml
|
@ -180,17 +180,12 @@
|
|||
<artifactId>gwt-log</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- JUNIT -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
|
@ -356,5 +351,4 @@
|
|||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<packaging>war</packaging>
|
||||
</project>
|
||||
|
|
|
@ -2,14 +2,22 @@ package org.gcube.portlets.user.td.sharewidget.client;
|
|||
|
||||
|
||||
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.core.client.EntryPoint;
|
||||
import com.google.web.bindery.event.shared.EventBus;
|
||||
import com.google.web.bindery.event.shared.SimpleEventBus;
|
||||
|
||||
public class ShareWidgetEntry implements EntryPoint {
|
||||
|
||||
|
||||
public void onModuleLoad() {
|
||||
TRShare trShare=new TRShare();
|
||||
TRId trId=new TRId("1");
|
||||
EventBus eventBus=new SimpleEventBus();
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
TRShare trShare=new TRShare(trId,eventBus);
|
||||
Log.info("Hello!");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,32 +1,87 @@
|
|||
package org.gcube.portlets.user.td.sharewidget.client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.share.Contacts;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.share.ShareInfo;
|
||||
import org.gcube.portlets.user.td.sharewidget.client.util.InfoMessageBox;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
import org.gcube.portlets.widgets.workspacesharingwidget.client.WorkspaceSmartSharingController;
|
||||
import org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.SmartShare;
|
||||
import org.gcube.portlets.widgets.workspacesharingwidget.shared.CredentialModel;
|
||||
import org.gcube.portlets.widgets.workspacesharingwidget.shared.FileModel;
|
||||
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.extjs.gxt.ui.client.event.BaseEvent;
|
||||
import com.extjs.gxt.ui.client.event.Events;
|
||||
import com.extjs.gxt.ui.client.event.Listener;
|
||||
import com.extjs.gxt.ui.client.widget.Dialog;
|
||||
|
||||
|
||||
public class TRShare {
|
||||
public TRShare() {
|
||||
FileModel file = new FileModel("id", "filename", false);
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.web.bindery.event.shared.EventBus;
|
||||
import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
|
||||
import com.sencha.gxt.widget.core.client.event.HideEvent;
|
||||
import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
|
||||
|
||||
/**
|
||||
* This controller instance the smart sharing dialog
|
||||
*
|
||||
* @param file
|
||||
* - a fake file to display the field name ("filename") into
|
||||
* dialog
|
||||
* @param listAlreadySharedContact
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class TRShare {
|
||||
private TRId trId;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private EventBus eventBus;
|
||||
private ShareInfo shareInfo;
|
||||
|
||||
public TRShare(TRId trId, EventBus eventBus) {
|
||||
this.trId = trId;
|
||||
this.eventBus = eventBus;
|
||||
|
||||
retrieveInfo();
|
||||
|
||||
}
|
||||
|
||||
protected void retrieveInfo() {
|
||||
TDGWTServiceAsync.INSTANCE.getShareInfo(trId,
|
||||
new AsyncCallback<ShareInfo>() {
|
||||
|
||||
public void onFailure(Throwable caught) {
|
||||
Log.debug("ShareInfo Error: "
|
||||
+ caught.getLocalizedMessage());
|
||||
alert("Error retrienving share info",
|
||||
"Error retrieving share info");
|
||||
|
||||
}
|
||||
|
||||
public void onSuccess(ShareInfo result) {
|
||||
shareInfo = result;
|
||||
shareWindow();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Call Window
|
||||
*/
|
||||
protected void shareWindow() {
|
||||
|
||||
FileModel file = new FileModel(shareInfo.getTabResource().getTrId()
|
||||
.getId(), shareInfo.getTabResource().getName(), false);
|
||||
|
||||
List<CredentialModel> listAlreadySharedContact = new ArrayList<CredentialModel>();
|
||||
for (Contacts contacts : shareInfo.getContacts()) {
|
||||
CredentialModel cm = new CredentialModel(null, contacts.getLogin(),
|
||||
false);
|
||||
listAlreadySharedContact.add(cm);
|
||||
}
|
||||
|
||||
WorkspaceSmartSharingController controller = new WorkspaceSmartSharingController(
|
||||
file, null);
|
||||
file, listAlreadySharedContact);
|
||||
|
||||
final SmartShare sharingWindow = controller.getSharingDialog();
|
||||
|
||||
|
@ -39,29 +94,8 @@ public class TRShare {
|
|||
public void handleEvent(BaseEvent be) {
|
||||
|
||||
if (sharingWindow.isValidForm(true)) {
|
||||
// THAT'S OK
|
||||
|
||||
sharingWindow.getSharedListUsers(); // @return the
|
||||
// selected
|
||||
// contacts (as
|
||||
// InfoContactModel)
|
||||
|
||||
sharingWindow.getSharedListUsersCredential(); // @return
|
||||
// the
|
||||
// selected
|
||||
// contacts
|
||||
// (as
|
||||
// CredentialModel)
|
||||
|
||||
for (InfoContactModel contact : sharingWindow
|
||||
.getSharedListUsers()) {
|
||||
System.out.println(contact);
|
||||
}
|
||||
|
||||
for (CredentialModel credential : sharingWindow
|
||||
.getSharedListUsersCredential()) {
|
||||
System.out.println(credential);
|
||||
}
|
||||
shareCall(sharingWindow
|
||||
.getSharedListUsersCredential());
|
||||
|
||||
}
|
||||
|
||||
|
@ -70,4 +104,62 @@ public class TRShare {
|
|||
|
||||
}
|
||||
|
||||
protected void shareCall(List<CredentialModel> credentials) {
|
||||
ArrayList<Contacts> listContacts = new ArrayList<Contacts>();
|
||||
for (CredentialModel cred : credentials) {
|
||||
Contacts cont = new Contacts(cred.getId(), cred.getLogin(),
|
||||
cred.isGroup());
|
||||
listContacts.add(cont);
|
||||
}
|
||||
|
||||
shareInfo.setContacts(listContacts);
|
||||
|
||||
TDGWTServiceAsync.INSTANCE.setShare(shareInfo,
|
||||
new AsyncCallback<Void>() {
|
||||
|
||||
public void onFailure(Throwable caught) {
|
||||
Log.debug("Share Error: "
|
||||
+ caught.getLocalizedMessage());
|
||||
alert("Error sharing tabular resource",
|
||||
"Error shareing tabular resource");
|
||||
|
||||
}
|
||||
|
||||
public void onSuccess(Void result) {
|
||||
Log.debug("Tabular Resource Shared: "
|
||||
+ shareInfo.getTabResource().getTrId()
|
||||
.toString());
|
||||
info("Shared",
|
||||
"Tabular Resource is shared");
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void alert(String title, String message) {
|
||||
final AlertMessageBox d = new AlertMessageBox(title, message);
|
||||
d.addHideHandler(new HideHandler() {
|
||||
|
||||
public void onHide(HideEvent event) {
|
||||
|
||||
}
|
||||
});
|
||||
d.show();
|
||||
|
||||
}
|
||||
|
||||
private void info(String title, String message) {
|
||||
final InfoMessageBox d = new InfoMessageBox(title, message);
|
||||
d.addHideHandler(new HideHandler() {
|
||||
|
||||
public void onHide(HideEvent event) {
|
||||
|
||||
}
|
||||
});
|
||||
d.show();
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package org.gcube.portlets.user.td.sharewidget.client.util;
|
||||
|
||||
import com.sencha.gxt.widget.core.client.box.MessageBox;
|
||||
|
||||
public class InfoMessageBox extends MessageBox {
|
||||
|
||||
/**
|
||||
* Creates a message box with an info icon and the specified title and
|
||||
* message.
|
||||
*
|
||||
* @param title
|
||||
* the message box title
|
||||
* @param message
|
||||
* the message displayed in the message box
|
||||
*/
|
||||
public InfoMessageBox(String title, String message) {
|
||||
super(title, message);
|
||||
|
||||
setIcon(ICONS.info());
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue