Updated Multi Tab

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-share-widget@100735 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-10-15 16:50:46 +00:00 committed by Giancarlo Panichi
parent b2c7b676d1
commit 84fde911c0
1 changed files with 48 additions and 17 deletions

View File

@ -4,9 +4,11 @@ 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.exception.TDGWTIsLockedException;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
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.gwtservice.shared.tr.TabResource;
import org.gcube.portlets.user.td.sharewidget.client.util.InfoMessageBox;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.ChangeTableRequestEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
@ -40,6 +42,7 @@ public class TRShare {
private TRId trId;
private EventBus eventBus;
private TabResource tabResource;
private ShareInfo shareInfo;
public TRShare(TRId trId, EventBus eventBus) {
@ -50,25 +53,54 @@ public class TRShare {
}
protected void retrieveInfo() {
TDGWTServiceAsync.INSTANCE.getShareInfo(trId,
new AsyncCallback<ShareInfo>() {
/*
* protected void retrieveInfo() {
* TDGWTServiceAsync.INSTANCE.getShareInfo(trId, new
* AsyncCallback<ShareInfo>() {
*
* public void onFailure(Throwable caught) { if (caught instanceof
* TDGWTSessionExpiredException) { eventBus.fireEvent(new
* SessionExpiredEvent( SessionExpiredType.EXPIREDONSERVER)); } else {
* Log.debug("ShareInfo Error: " + caught.getLocalizedMessage());
* alert("Error retrienving share info", "Error retrieving share info"); } }
*
* public void onSuccess(ShareInfo result) { shareInfo = result;
* shareWindow(); }
*
* }); }
*/
public void retrieveInfo() {
TDGWTServiceAsync.INSTANCE.getTabResourceInformation(trId,
new AsyncCallback<TabResource>() {
public void onSuccess(TabResource result) {
Log.info("Retrived TR: " + result.getTrId());
tabResource = result;
shareWindow();
}
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
Log.debug("ShareInfo Error: "
+ caught.getLocalizedMessage());
alert("Error retrienving share info",
"Error retrieving share info");
}
}
if (caught instanceof TDGWTIsLockedException) {
Log.error(caught.getLocalizedMessage());
alert("Error Locked",
caught.getLocalizedMessage());
public void onSuccess(ShareInfo result) {
shareInfo = result;
shareWindow();
} else {
Log.error("Error retrienving properties: "
+ caught.getLocalizedMessage());
alert("Error",
"Retrieving tabular resource info: "
+ caught.getLocalizedMessage());
}
}
}
});
@ -79,11 +111,11 @@ public class TRShare {
*/
protected void shareWindow() {
FileModel file = new FileModel(shareInfo.getTabResource().getTrId()
.getId(), shareInfo.getTabResource().getName(), false);
FileModel file = new FileModel(tabResource.getTrId()
.getId(), tabResource.getName(), false);
List<CredentialModel> listAlreadySharedContact = new ArrayList<CredentialModel>();
for (Contacts contacts : shareInfo.getContacts()) {
for (Contacts contacts : tabResource.getContacts()) {
CredentialModel cm = new CredentialModel(null, contacts.getLogin(),
false);
listAlreadySharedContact.add(cm);
@ -120,8 +152,7 @@ public class TRShare {
cred.isGroup());
listContacts.add(cont);
}
shareInfo.setContacts(listContacts);
shareInfo=new ShareInfo(tabResource,listContacts);
TDGWTServiceAsync.INSTANCE.setShare(shareInfo,
new AsyncCallback<Void>() {