enhancements on realizing a Simple Multi-Drag Panel to contacts

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-sharing-widget@100034 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2014-09-18 17:02:41 +00:00
parent e75c99741c
commit e4ddb99c70
10 changed files with 114 additions and 45 deletions

View File

@ -30,5 +30,8 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="lib" path="lib/log4j-1.2.17.jar"/>
<classpathentry kind="lib" path="lib/slf4j-api-1.6.4.jar"/>
<classpathentry kind="lib" path="lib/slf4j-log4j12-1.6.4.jar"/>
<classpathentry kind="output" path="target/classes"/> <classpathentry kind="output" path="target/classes"/>
</classpath> </classpath>

View File

@ -14,7 +14,7 @@
<groupId>org.gcube.portlets.widgets</groupId> <groupId>org.gcube.portlets.widgets</groupId>
<artifactId>workspace-sharing-widget</artifactId> <artifactId>workspace-sharing-widget</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<version>1.2.0-SNAPSHOT</version> <version>1.3.0-SNAPSHOT</version>
<name>gCube Workspace Sharing Widget</name> <name>gCube Workspace Sharing Widget</name>
<description> <description>
gCube Workspace Sharing Widget gCube Workspace Sharing Widget

View File

@ -23,7 +23,7 @@ public class SimpleMultiDragContact {
private UserStore userStore = new UserStore(); private UserStore userStore = new UserStore();
private LOAD_CONTACTS_AS loadContactAs; private LOAD_CONTACTS_AS loadContactAs;
public static enum LOAD_CONTACTS_AS{SHARED_USER, ADMINISTRATOR, NONE} public static enum LOAD_CONTACTS_AS{SHARED_USER, ADMINISTRATOR}
private MultiDragContact multiDragContact = new MultiDragContact(); private MultiDragContact multiDragContact = new MultiDragContact();
private List<InfoContactModel> targets = new ArrayList<InfoContactModel>(); private List<InfoContactModel> targets = new ArrayList<InfoContactModel>();
/** /**
@ -31,11 +31,33 @@ public class SimpleMultiDragContact {
*/ */
public SimpleMultiDragContact(LOAD_CONTACTS_AS load, String workspaceItemId, final boolean readGroupsFromHL, final boolean readGroupsFromPortal) { public SimpleMultiDragContact(LOAD_CONTACTS_AS load, String workspaceItemId, final boolean readGroupsFromHL, final boolean readGroupsFromPortal) {
this.loadContactAs = load; this.loadContactAs = load;
switch (loadContactAs) { switch (loadContactAs) {
case ADMINISTRATOR: case ADMINISTRATOR:
//LOADING LIST OF ALREADY SHARED USER
userStore.getAdministratorsByFolderId(workspaceItemId, new AsyncCallback<List<InfoContactModel>>() {
@Override
public void onFailure(Throwable caught) {
GWT.log("Error on loading admnistrators");
}
@Override
public void onSuccess(List<InfoContactModel> result) {
GWT.log("Returned "+result.size()+" admin/s");
for (InfoContactModel infoContactModel : result) {
if(infoContactModel.getName()!=null){
multiDragContact.addTargetContact(infoContactModel);
targets.add(infoContactModel);
}
}
loadAllContacts(readGroupsFromHL, readGroupsFromPortal);
}
});
break; break;
case SHARED_USER: case SHARED_USER:
@ -46,7 +68,7 @@ public class SimpleMultiDragContact {
@Override @Override
public void onSuccess(List<InfoContactModel> result) { public void onSuccess(List<InfoContactModel> result) {
GWT.log("Returned "+result.size()+" contact/s");
for (InfoContactModel infoContactModel : result) { for (InfoContactModel infoContactModel : result) {
if(infoContactModel.getName()!=null){ if(infoContactModel.getName()!=null){
multiDragContact.addTargetContact(infoContactModel); multiDragContact.addTargetContact(infoContactModel);
@ -66,10 +88,6 @@ public class SimpleMultiDragContact {
break; break;
case NONE:
break;
default: default:
break; break;
} }
@ -82,7 +100,6 @@ public class SimpleMultiDragContact {
} }
private void loadAllContacts(boolean readGroupsFromHL, boolean readGroupsFromPortal){ private void loadAllContacts(boolean readGroupsFromHL, boolean readGroupsFromPortal){
userStore.getListContact(addSourceContacts, false, readGroupsFromHL, readGroupsFromPortal); userStore.getListContact(addSourceContacts, false, readGroupsFromHL, readGroupsFromPortal);
} }
@ -102,5 +119,9 @@ public class SimpleMultiDragContact {
multiDragContact.addSourceContacts(exclusiveContacts); multiDragContact.addSourceContacts(exclusiveContacts);
} }
} }
}; };
public MultiDragContact getMultiDragContact() {
return multiDragContact;
}
} }

View File

@ -1,5 +1,6 @@
package org.gcube.portlets.widgets.workspacesharingwidget.client; package org.gcube.portlets.widgets.workspacesharingwidget.client;
import org.gcube.portlets.widgets.workspacesharingwidget.client.SimpleMultiDragContact.LOAD_CONTACTS_AS;
import org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.SmartShare; 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.CredentialModel;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.FileModel; import org.gcube.portlets.widgets.workspacesharingwidget.shared.FileModel;
@ -21,7 +22,7 @@ import com.google.gwt.user.client.ui.RootPanel;
*/ */
public class WorkspaceSharingWidgetEntryPoint implements EntryPoint { public class WorkspaceSharingWidgetEntryPoint implements EntryPoint {
public static String ITEMID = "3f461fcf-c60f-4243-9212-4f7c89dbf7bc"; public static String ITEMID = "3cf934a0-decf-4104-8e23-47eb64010017";
/** /**
* This is the entry point method. * This is the entry point method.
@ -47,7 +48,7 @@ public class WorkspaceSharingWidgetEntryPoint implements EntryPoint {
*/ */
FileModel file = new FileModel("123", "test", false); /*FileModel file = new FileModel("123", "test", false);
WorkspaceSmartSharingController controller = new WorkspaceSmartSharingController(file, null, false, false); WorkspaceSmartSharingController controller = new WorkspaceSmartSharingController(file, null, false, false);
SmartConstants.HEADER_TITLE = "puppa"; SmartConstants.HEADER_TITLE = "puppa";
@ -89,9 +90,29 @@ public class WorkspaceSharingWidgetEntryPoint implements EntryPoint {
} }
}); });
*/
showSimpleMultiDrag();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
private void showSimpleMultiDrag(){
final SimpleMultiDragContact multiDragContact = new SimpleMultiDragContact(LOAD_CONTACTS_AS.SHARED_USER, ITEMID, true, false);
Button openSharingWindow = new Button("Show Simple Multi Drag",
new ClickHandler() {
public void onClick(ClickEvent event) {
multiDragContact.getMultiDragContact().show();
}
});
RootPanel.get("workpacesharingwidget").add(openSharingWindow);
}
} }

View File

@ -74,8 +74,7 @@ public interface WorkspaceSharingService extends RemoteService {
* @return * @return
* @throws Exception * @throws Exception
*/ */
List<InfoContactModel> getInfoContactModelsFromCredential( List<InfoContactModel> getInfoContactModelsFromCredential(List<CredentialModel> listAlreadySharedContact) throws Exception;
List<CredentialModel> listAlreadySharedContact) throws Exception;
List<InfoContactModel> getAdministratorsByFolderId(String sharedFolderId) throws Exception; List<InfoContactModel> getAdministratorsByFolderId(String sharedFolderId) throws Exception;

View File

@ -139,7 +139,7 @@ public class UserStore implements ContactFetcher{
* @see org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.ContactFetcher#getAdministratorsByFolderId(java.lang.String, com.google.gwt.user.client.rpc.AsyncCallback) * @see org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.ContactFetcher#getAdministratorsByFolderId(java.lang.String, com.google.gwt.user.client.rpc.AsyncCallback)
*/ */
@Override @Override
public void getAdministratorsByFolderId(String sharedFolderId, AsyncCallback<List<InfoContactModel>> callback) { public void getAdministratorsByFolderId(String sharedFolderId, final AsyncCallback<List<InfoContactModel>> callback) {
if(sharedFolderId==null || sharedFolderId.isEmpty()) if(sharedFolderId==null || sharedFolderId.isEmpty())
return; return;
@ -147,13 +147,13 @@ public class UserStore implements ContactFetcher{
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
// TODO Auto-generated method stub callback.onFailure(caught);
} }
@Override @Override
public void onSuccess(List<InfoContactModel> result) { public void onSuccess(List<InfoContactModel> result) {
// TODO Auto-generated method stub callback.onSuccess(result);
} }

View File

@ -256,8 +256,7 @@ public class GWTWorkspaceSharingBuilder {
* @param listPortalLogin * @param listPortalLogin
* @return * @return
*/ */
public List<InfoContactModel> buildGxtInfoContactsFromPortalLogins( public List<InfoContactModel> buildGxtInfoContactsFromPortalLogins(List<String> listPortalLogin) {
List<String> listPortalLogin) {
List<InfoContactModel> listContact = new ArrayList<InfoContactModel>(); List<InfoContactModel> listContact = new ArrayList<InfoContactModel>();
for (String portalLogin : listPortalLogin) for (String portalLogin : listPortalLogin)
@ -271,8 +270,7 @@ public class GWTWorkspaceSharingBuilder {
* @param portalLogin * @param portalLogin
* @return * @return
*/ */
protected InfoContactModel buildGxtInfoContactFromPortalLogin( protected InfoContactModel buildGxtInfoContactFromPortalLogin(String portalLogin) {
String portalLogin) {
if (portalLogin == null) { if (portalLogin == null) {
logger.warn("portal login is null, return empty"); logger.warn("portal login is null, return empty");
@ -280,8 +278,7 @@ public class GWTWorkspaceSharingBuilder {
} }
// TODO ISGROUP // TODO ISGROUP
return new InfoContactModel(portalLogin, portalLogin, return new InfoContactModel(portalLogin, portalLogin,UserUtil.getUserFullName(portalLogin), false);
UserUtil.getUserFullName(portalLogin), false);
} }
@ -291,14 +288,14 @@ public class GWTWorkspaceSharingBuilder {
* @param listPortalLogin * @param listPortalLogin
* @return * @return
*/ */
protected List<InfoContactModel> buildGxtInfoContactFromPortalLoginTestMode( protected List<InfoContactModel> buildGxtInfoContactFromPortalLoginTestMode(List<String> listPortalLogin) {
List<String> listPortalLogin) {
List<InfoContactModel> listContact = new ArrayList<InfoContactModel>(); List<InfoContactModel> listContact = new ArrayList<InfoContactModel>();
for (String portalLogin : listPortalLogin) for (String portalLogin : listPortalLogin)
listContact.add(getHashTestUsers().get(portalLogin)); listContact.add(getHashTestUsers().get(portalLogin));
logger.trace("returning "+listContact.size()+" info contacts test");
return listContact; return listContact;
} }

View File

@ -91,21 +91,27 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
if(isTestMode()){ if(isTestMode()){
logger.warn("WORKSPACE PORTLET IS IN TEST MODE - RETURN TEST USERS AND GROUPS"); logger.warn("WORKSPACE PORTLET IS IN TEST MODE - RETURN TEST USERS AND GROUPS");
GWTWorkspaceSharingBuilder.getHashTestUsers();
List<InfoContactModel> listContactsModel = new ArrayList<InfoContactModel>(); List<InfoContactModel> listContactsModel = new ArrayList<InfoContactModel>();
// //TEST USERS for (String key : GWTWorkspaceSharingBuilder.getHashTestUsers().keySet()) {
listContactsModel.add(new InfoContactModel("federico.defaveri", "federico.defaveri", "Federico de Faveri", false)); InfoContactModel contact = GWTWorkspaceSharingBuilder.getHashTestUsers().get(key);
listContactsModel.add(new InfoContactModel("antonio.gioia", "antonio.gioia", "Antonio Gioia", false)); listContactsModel.add(contact);
listContactsModel.add(new InfoContactModel("fabio.sinibaldi", "fabio.sinibaldi", "Fabio Sinibaldi", false)); }
listContactsModel.add(new InfoContactModel("pasquale.pagano", "pasquale.pagano", "Pasquale Pagano", false));
// listContactsModel.add(new InfoContactModel(WsUtil.TEST_USER, WsUtil.TEST_USER, WsUtil.TEST_USER_FULL_NAME));
listContactsModel.add(new InfoContactModel("francesco.mangiacrapa", "francesco.mangiacrapa", "Francesco Mangiacrapa", false));
listContactsModel.add(new InfoContactModel("massimiliano.assante", "massimiliano.assante", "Massimiliano Assante", false));
listContactsModel.add(new InfoContactModel("valentina.marioli", "valentina.marioli", "Valentina Marioli", false));
listContactsModel.add(new InfoContactModel("leonardo.candela", "leonardo.candela", "Leonardo Candela", false));
listContactsModel.add(new InfoContactModel("/gube/devsec/devVRE", "/gube/devsec/devVRE", "devVRE", true)); //
// listContactsModel.add(new InfoContactModel("antonio.gioia", "antonio.gioia", "Antonio Gioia", false));
// listContactsModel.add(new InfoContactModel("fabio.sinibaldi", "fabio.sinibaldi", "Fabio Sinibaldi", false));
// listContactsModel.add(new InfoContactModel("pasquale.pagano", "pasquale.pagano", "Pasquale Pagano", false));
//// listContactsModel.add(new InfoContactModel(WsUtil.TEST_USER, WsUtil.TEST_USER, WsUtil.TEST_USER_FULL_NAME));
// listContactsModel.add(new InfoContactModel("francesco.mangiacrapa", "francesco.mangiacrapa", "Francesco Mangiacrapa", false));
// listContactsModel.add(new InfoContactModel("massimiliano.assante", "massimiliano.assante", "Massimiliano Assante", false));
// listContactsModel.add(new InfoContactModel("valentina.marioli", "valentina.marioli", "Valentina Marioli", false));
// listContactsModel.add(new InfoContactModel("leonardo.candela", "leonardo.candela", "Leonardo Candela", false));
//
// listContactsModel.add(new InfoContactModel("/gube/devsec/devVRE", "/gube/devsec/devVRE", "devVRE", true));
// listContactsModel.addAll(getFakeGroups()); // listContactsModel.addAll(getFakeGroups());
return listContactsModel; return listContactsModel;
} }
@ -491,7 +497,13 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
if(item!=null && item.getType().equals(WorkspaceItemType.SHARED_FOLDER)){ if(item!=null && item.getType().equals(WorkspaceItemType.SHARED_FOLDER)){
WorkspaceSharedFolder sharedFolder = (WorkspaceSharedFolder) item; WorkspaceSharedFolder sharedFolder = (WorkspaceSharedFolder) item;
GWTWorkspaceSharingBuilder builder = getGWTWorkspaceBuilder(); GWTWorkspaceSharingBuilder builder = getGWTWorkspaceBuilder();
return builder.buildGxtInfoContactsFromPortalLogins(sharedFolder.getAdministrators()); List<String> admins = sharedFolder.getAdministrators();
logger.info("Converting "+admins.size()+" administator/s List<InfoContactModel>");
if(isTestMode())
return builder.buildGxtInfoContactFromPortalLoginTestMode(admins);
return builder.buildGxtInfoContactsFromPortalLogins(admins);
}else }else
throw new Exception("The item is null or not instanceof "+WorkspaceItemType.SHARED_FOLDER); throw new Exception("The item is null or not instanceof "+WorkspaceItemType.SHARED_FOLDER);

View File

@ -45,10 +45,8 @@ public class UserUtil {
curr = um.getUserByScreenName(portalLogin); curr = um.getUserByScreenName(portalLogin);
} catch (UserManagementSystemException e) { } catch (UserManagementSystemException e) {
logger.error("An error occurred in getUserFullName "+e,e); logger.error("An error occurred in getUserFullName "+e,e);
} catch (UserRetrievalFault e) { } catch (UserRetrievalFault e) {
logger.error("An error occurred in getUserFullName "+e,e); logger.error("An error occurred in getUserFullName "+e,e);
} }
} catch (UserManagementPortalException ume) { } catch (UserManagementPortalException ume) {

View File

@ -9,14 +9,13 @@ import com.extjs.gxt.ui.client.data.BaseModelData;
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* *
*/ */
public class InfoContactModel extends BaseModelData implements Serializable { public class InfoContactModel extends BaseModelData implements Serializable, Comparable<InfoContactModel> {
/** /**
* *
*/ */
private static final long serialVersionUID = -4098652774574958363L; private static final long serialVersionUID = -6158514541724213534L;
protected static final String ID = "id"; protected static final String ID = "id";
public static final String FULLNAME = "fullname"; public static final String FULLNAME = "fullname";
@ -69,10 +68,10 @@ public class InfoContactModel extends BaseModelData implements Serializable {
} }
public static Comparator<InfoContactModel> COMPARATOR = new Comparator<InfoContactModel>() { public static Comparator<InfoContactModel> COMPARATORLOGINS = new Comparator<InfoContactModel>() {
// This is where the sorting happens. // This is where the sorting happens.
public int compare(InfoContactModel o1, InfoContactModel o2) { public int compare(InfoContactModel o1, InfoContactModel o2) {
return o1.getName().compareToIgnoreCase(o2.getName()); return o1.getLogin().compareToIgnoreCase(o2.getLogin());
} }
}; };
@ -91,6 +90,25 @@ public class InfoContactModel extends BaseModelData implements Serializable {
this.referenceCredential = referenceCredential; this.referenceCredential = referenceCredential;
} }
/* (non-Javadoc)
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
@Override
public int compareTo(InfoContactModel o) {
return InfoContactModel.COMPARATORLOGINS.compare(this, o);
}
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
int compare = compareTo((InfoContactModel) obj);
return compare == 0? true:false;
}
@Override @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();