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