2014-03-04 16:56:16 +01:00
|
|
|
package org.gcube.portlets.user.td.sharewidget.client;
|
|
|
|
|
2014-03-04 19:24:52 +01:00
|
|
|
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.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;
|
|
|
|
|
2014-03-04 16:56:16 +01:00
|
|
|
|
|
|
|
public class TRShare {
|
|
|
|
public TRShare() {
|
2014-03-04 19:24:52 +01:00
|
|
|
FileModel file = new FileModel("id", "filename", false);
|
2014-03-04 16:56:16 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This controller instance the smart sharing dialog
|
|
|
|
*
|
|
|
|
* @param file
|
|
|
|
* - a fake file to display the field name ("filename") into
|
|
|
|
* dialog
|
|
|
|
* @param listAlreadySharedContact
|
|
|
|
*/
|
2014-03-04 19:24:52 +01:00
|
|
|
|
2014-03-04 16:56:16 +01:00
|
|
|
WorkspaceSmartSharingController controller = new WorkspaceSmartSharingController(
|
|
|
|
file, null);
|
|
|
|
|
2014-03-04 19:24:52 +01:00
|
|
|
final SmartShare sharingWindow = controller.getSharingDialog();
|
2014-03-04 16:56:16 +01:00
|
|
|
|
2014-03-04 19:24:52 +01:00
|
|
|
sharingWindow.show();
|
2014-03-04 16:56:16 +01:00
|
|
|
|
|
|
|
sharingWindow.getButtonById(Dialog.OK).addListener(Events.Select,
|
|
|
|
new Listener<BaseEvent>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void handleEvent(BaseEvent be) {
|
|
|
|
|
2014-03-04 19:24:52 +01:00
|
|
|
if (sharingWindow.isValidForm(true)) {
|
2014-03-04 16:56:16 +01:00
|
|
|
// 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);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
2014-03-04 19:24:52 +01:00
|
|
|
|
2014-03-04 16:56:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|