Update the list of shared classes with the sharing widget

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@181283 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2019-07-22 12:51:27 +00:00
parent 6d598f3b60
commit fe70c83f94
15 changed files with 6 additions and 1687 deletions

View File

@ -117,9 +117,9 @@ import org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceServiceAsync;
import org.gcube.portlets.user.workspace.client.util.RequestBuilderWorkspaceValidateItem;
import org.gcube.portlets.user.workspace.client.util.WindowOpenParameter;
import org.gcube.portlets.user.workspace.client.view.ExplorerPanel;
import org.gcube.portlets.user.workspace.client.view.sharing.DialogPermission;
import org.gcube.portlets.user.workspace.client.view.sharing.DialogShareFolder;
import org.gcube.portlets.user.workspace.client.view.sharing.UserStore;
import org.gcube.portlets.user.workspace.client.view.sharing.permissions.DialogPermission;
import org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.UserStore;
import org.gcube.portlets.user.workspace.client.view.tree.AsyncTreePanel;
import org.gcube.portlets.user.workspace.client.view.windows.DialogAddFolderAndSmart;
import org.gcube.portlets.user.workspace.client.view.windows.DialogAddFolderAndSmart.AddType;

View File

@ -1,16 +0,0 @@
package org.gcube.portlets.user.workspace.client.view.sharing;
import java.util.List;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
import com.google.gwt.user.client.rpc.AsyncCallback;
public interface ContactFetcher {
public void getListContact(AsyncCallback<List<InfoContactModel>> callback, boolean reloadList);
public void getListSharedUserByFolderId(String sharedFolderId, AsyncCallback<List<InfoContactModel>> callback);
public List<InfoContactModel> getExclusiveContactsFromAllContact(List<InfoContactModel> listSharedUser);
public void getOwner(String sharedFolderId, AsyncCallback<InfoContactModel> callback);
}

View File

@ -1,4 +1,4 @@
package org.gcube.portlets.user.workspace.client.view.sharing.permissions;
package org.gcube.portlets.user.workspace.client.view.sharing;
import java.util.List;
@ -6,9 +6,10 @@ import org.gcube.portlets.user.workspace.client.AppControllerExplorer;
import org.gcube.portlets.user.workspace.client.event.UpdatedVREPermissionEvent;
import org.gcube.portlets.user.workspace.client.model.FileModel;
import org.gcube.portlets.user.workspace.client.resources.Resources;
import org.gcube.portlets.user.workspace.client.view.sharing.PanelTogglePermission;
import org.gcube.portlets.user.workspace.client.view.windows.InfoDisplay;
import org.gcube.portlets.user.workspace.client.view.windows.MessageBoxAlert;
import org.gcube.portlets.widgets.workspacesharingwidget.client.permissions.PanelTogglePermission;
import org.gcube.portlets.widgets.workspacesharingwidget.client.rpc.WorkspaceSharingServiceAsync;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.WorkspaceACL;

View File

@ -1,710 +0,0 @@
package org.gcube.portlets.user.workspace.client.view.sharing;
import java.util.List;
import org.gcube.portlets.user.workspace.client.AppControllerExplorer;
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
import org.gcube.portlets.user.workspace.client.model.FileModel;
import org.gcube.portlets.user.workspace.client.resources.Resources;
import org.gcube.portlets.user.workspace.client.view.sharing.multisuggest.MultiDragContact;
import org.gcube.portlets.user.workspace.client.view.sharing.multisuggest.MultiValuePanel;
import org.gcube.portlets.user.workspace.client.view.windows.MessageBoxAlert;
import org.gcube.portlets.user.workspace.shared.ListContact;
import org.gcube.portlets.widgets.workspacesharingwidget.client.rpc.WorkspaceSharingServiceAsync;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.WorkspaceACL;
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.Style.VerticalAlignment;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.widget.Dialog;
import com.extjs.gxt.ui.client.widget.HorizontalPanel;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.form.TextArea;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
import com.google.gwt.core.shared.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.Label;
/**
* The Class DialogShareFolder.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it Jul 10, 2017
*/
public class DialogShareFolder extends Dialog {
private int widthDialog = 535;
private int heightTextArea = 100;
private TextField<String> txtName;
private TextArea textAreaDescription = new TextArea();
private FileModel parentFolder = null;
private UserStore userStore;
private MultiValuePanel suggestPanel;
private Button buttonMultiDrag = new Button("Choose Contacts");
private TextField<String> txtOwner;
private PanelTogglePermission permission;
private HorizontalPanel hpPermission = null;
private InfoContactModel shareOwner = null;
private ListContact<InfoContactModel> listAlreadyShared = new ListContact<InfoContactModel>();
/**
* Use to modify a shared folder or share an existing folder.
*
* @param folderParentName
* the folder parent name
* @param folder
* the folder
* @param eventBus
* the event bus
* @param userStore
* the user store
*/
public DialogShareFolder(String folderParentName, final FileModel folder, HandlerManager eventBus,
UserStore userStore) {
initUserStore(userStore);
initLayout(folderParentName);
this.parentFolder = folder;
this.setIcon(Resources.getIconShareFolder());
setWidth(widthDialog);
setButtons(Dialog.OKCANCEL);
setHeading("Share folder: " + folder.getName());
txtName = new TextField<String>();
txtName.setAllowBlank(false);
txtName.setValue(folder.getName());
txtName.setReadOnly(true);
txtName.setAutoValidate(true);
txtName.setFieldLabel("Folder Name");
txtName.getMessages().setRegexText(ConstantsExplorer.REGEX_WSFOLDER_NAME_ALERT_MSG);
txtName.setRegex(ConstantsExplorer.REGEX_TO_WSFOLDER_NAME);
txtOwner = new TextField<String>();
txtOwner.setAllowBlank(true);
txtOwner.setValue("");
txtOwner.setReadOnly(true);
txtOwner.setAutoValidate(false);
txtOwner.setFieldLabel("Owner");
textAreaDescription.setFieldLabel(ConstantsExplorer.DIALOG_DESCRIPTION);
textAreaDescription.setHeight(heightTextArea);
textAreaDescription.setWidth(380);
textAreaDescription.setValue(folder.getDescription());
final LayoutContainer lc = new LayoutContainer();
lc.setStyleAttribute("margin-top", "10px");
lc.setStyleAttribute("margin-bottom", "10px");
lc.setSize(480, 50);
final FlexTable flexTable = new FlexTable();
flexTable.setStyleName("userssuggest");
Label labelShareWith = new Label("Share with users");
flexTable.setWidget(0, 0, labelShareWith);
flexTable.setWidget(0, 1, suggestPanel);
buttonMultiDrag.setStyleName("wizardButton");
flexTable.setWidget(1, 0, new Label("Add more"));
flexTable.setWidget(1, 1, buttonMultiDrag);
Label labelDescription = new Label("Description");
flexTable.setWidget(2, 0, labelDescription);
flexTable.setWidget(2, 1, textAreaDescription);
hpPermission = new HorizontalPanel();
hpPermission.setVerticalAlign(VerticalAlignment.MIDDLE);
Label labelProperty = new Label("Permissions");
hpPermission.add(labelProperty);
WorkspaceSharingServiceAsync.INSTANCE.getACLs(new AsyncCallback<List<WorkspaceACL>>() {
@Override
public void onSuccess(List<WorkspaceACL> result) {
permission = new PanelTogglePermission(result);
// ONLY IF FOLDER IS ALREADY SHARED, LOOADING CURRENT ACL FROM
// HL
if (folder.isShared())
selectAclForFolder(folder);
hpPermission.add(permission);
hpPermission.layout();
layout();
}
@Override
public void onFailure(Throwable caught) {
hpPermission.add(new Label("Error on recovering ACLs"));
hpPermission.layout();
layout();
}
});
lc.add(flexTable);
if (hpPermission != null)
lc.add(hpPermission);
lc.mask();
userStore.getOwner(folder.getIdentifier(), new AsyncCallback<InfoContactModel>() {
@Override
public void onFailure(Throwable caught) {
txtOwner.setValue("Error on retrieving Owner");
}
@Override
public void onSuccess(InfoContactModel result) {
GWT.log("getOwner returned: " + result);
shareOwner = result;
if (shareOwner != null)
txtOwner.setValue(shareOwner.getName());
// IF THE FOLDER IS NOT SHARED, CHECKS PERMISSIONS
if (!folder.isShared())
permissionControl(result.getLogin(), true);
fillRecipientAlreadyShared(folder.getIdentifier(), lc);
}
});
AsyncCallback<List<InfoContactModel>> callback = new AsyncCallback<List<InfoContactModel>>() {
@Override
public void onFailure(Throwable caught) {
new MessageBoxAlert("Alert", "Sorry, an error occurred during on getting Managers from server", null);
enableFormDialog(false);
hpPermission.unmask();
}
@Override
public void onSuccess(List<InfoContactModel> listManagers) {
permissionControl(listManagers, true, folder);
hpPermission.unmask();
}
};
if (folder.isShared())
getUsersManagers(folder.getIdentifier(), callback);
setFocusWidget(suggestPanel.getBox());
add(txtName);
add(txtOwner);
add(lc);
addListners();
enableFormDialog(false); // FORM IS DISABLED BY DEFAULT
this.show();
}
/**
* Inits the user store.
*
* @param userStore
* the user store
*/
private void initUserStore(UserStore userStore) {
this.userStore = userStore;
this.suggestPanel = new MultiValuePanel(userStore);
}
/**
* Update recipient of share.
*
* @param listContacts
* the list contacts
*/
private void updateRecipientOfShare(List<InfoContactModel> listContacts) {
suggestPanel.resetItemSelected();
for (InfoContactModel contact : listContacts) {
if (contact != null && contact.getName() != null) {
if (!isShareOwner(contact)) // skip owner
suggestPanel.addRecipient(contact.getName(), true);
else
suggestPanel.addRecipient(contact.getName(), false); // owner
// is
// not
// deletable
}
}
}
/**
* Fill recipient already shared.
*
* @param folderId
* the folder id
* @param lc
* the lc
*/
private void fillRecipientAlreadyShared(String folderId, final LayoutContainer lc) {
userStore.getListSharedUserByFolderId(folderId, new AsyncCallback<List<InfoContactModel>>() {
@Override
public void onSuccess(List<InfoContactModel> listContacts) {
if (listContacts != null) {
listAlreadyShared.addAll(listContacts);
updateRecipientOfShare(listContacts);
}
lc.unmask();
}
@Override
public void onFailure(Throwable caught) {
lc.unmask();
}
});
}
/**
* Permission control.
*
* @param owner
* the owner
* @param showAlert
* the show alert
*/
private void permissionControl(String owner, boolean showAlert) {
GWT.log("Permission control compare between owner: " + owner + " and my login: "
+ AppControllerExplorer.myLogin);
if (AppControllerExplorer.myLogin.compareToIgnoreCase(owner) != 0) {
enableFormDialog(false);
if (showAlert)
new MessageBoxAlert("Permission denied",
"You have no permissions to change sharing. You are not owner of \"" + txtName.getValue()
+ "\"",
null);
} else {
enableFormDialog(true);
}
}
/**
* Enable form dialog.
*
* @param bool
* the bool
*/
private void enableFormDialog(boolean bool) {
getButtonById(Dialog.OK).setEnabled(bool);
buttonMultiDrag.setEnabled(bool);
textAreaDescription.setEnabled(bool);
if (permission != null)
permission.setEnabled(bool);
}
/**
* Gets the parent folder.
*
* @return the parent folder
*/
public FileModel getParentFolder() {
return parentFolder;
}
/**
* Inits the layout.
*
* @param folderParentName
* the folder parent name
*/
public void initLayout(String folderParentName) {
FormLayout layout = new FormLayout();
layout.setLabelWidth(90);
layout.setDefaultWidth(380);
setLayout(layout);
setModal(true);
setScrollMode(Scroll.AUTOY);
setBodyStyle("padding: 9px; background: none");
setWidth(widthDialog);
setHeight(ConstantsExplorer.HEIGHT_DIALOG_SHARE_FOLDER);
setResizable(true);
setButtonAlign(HorizontalAlignment.CENTER);
setButtons(Dialog.OKCANCEL);
}
/**
* Use to create a new shared folder.
*
* @param folderParentName
* the folder parent name
* @param eventBus
* the event bus
* @param userStore
* the user store
*/
public DialogShareFolder(String folderParentName, HandlerManager eventBus, UserStore userStore) {
initUserStore(userStore);
initLayout(folderParentName);
this.setIcon(Resources.getIconSharedFolder());
setHeading("Create a new shared folder in: " + folderParentName);
setHeight(ConstantsExplorer.HEIGHT_DIALOG_SHARE_FOLDER - 25);
setWidth(widthDialog);
setButtons(Dialog.OKCANCEL);
txtName = new TextField<String>();
txtName.setAllowBlank(false);
txtName.setAutoValidate(true);
txtName.setFieldLabel("Folder Name");
txtName.getMessages().setRegexText(ConstantsExplorer.REGEX_WSFOLDER_NAME_ALERT_MSG);
txtName.setRegex(ConstantsExplorer.REGEX_TO_WSFOLDER_NAME);
// txtName.setRegex("^[^.<>\\|?/*%$]+[^\\/]*$");
textAreaDescription.setFieldLabel(ConstantsExplorer.DIALOG_DESCRIPTION);
textAreaDescription.setHeight(heightTextArea);
textAreaDescription.setWidth(380);
final LayoutContainer lc = new LayoutContainer();
lc.setStyleAttribute("margin-top", "10px");
lc.setStyleAttribute("margin-bottom", "10px");
lc.setSize(480, 50);
final FlexTable flexTable = new FlexTable();
flexTable.setStyleName("userssuggest");
Label lableShareWith = new Label("Share with users");
flexTable.setWidget(0, 0, lableShareWith);
flexTable.setWidget(0, 1, suggestPanel);
buttonMultiDrag.setStyleName("wizardButton");
flexTable.setWidget(1, 0, new Label("Add more"));
flexTable.setWidget(1, 1, buttonMultiDrag);
Label labelDescription = new Label("Description");
flexTable.setWidget(2, 0, labelDescription);
flexTable.setWidget(2, 1, textAreaDescription);
hpPermission = new HorizontalPanel();
hpPermission.setVerticalAlign(VerticalAlignment.MIDDLE);
Label labelProperty = new Label("Permissions");
hpPermission.add(labelProperty);
WorkspaceSharingServiceAsync.INSTANCE.getACLs(new AsyncCallback<List<WorkspaceACL>>() {
@Override
public void onSuccess(List<WorkspaceACL> result) {
permission = new PanelTogglePermission(result);
hpPermission.add(permission);
hpPermission.layout();
layout();
}
@Override
public void onFailure(Throwable caught) {
hpPermission.add(new Label("Error on recovering ACLs"));
hpPermission.layout();
layout();
}
});
lc.add(flexTable);
lc.add(hpPermission);
setFocusWidget(txtName);
add(txtName);
add(lc);
addListners();
this.show();
}
/**
* Gets the shared list users.
*
* @return the shared list users
*/
public List<InfoContactModel> getSharedListUsers() {
// printSelectedUser();
return suggestPanel.getSelectedUser();
}
/**
* Adds the listners.
*/
public void addListners() {
this.getButtonById(Dialog.CANCEL).addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
hide();
}
});
this.getButtonById(Dialog.OK).addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
if (isValidForm(false))
hide();
}
});
buttonMultiDrag.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final MultiDragContact multiDrag = new MultiDragContact();
multiDrag.show();
List<InfoContactModel> exclusiveContacts = userStore
.getExclusiveContactsFromAllContact(suggestPanel.getSelectedUser());
multiDrag.addSourceContacts(exclusiveContacts);
for (InfoContactModel infoContactModel : suggestPanel.getSelectedUser()) {
// if(!listAlreadyShared.contains(infoContactModel))
if (!isShareOwner(infoContactModel))
multiDrag.addTargetContact(infoContactModel);
}
multiDrag.addAlreadySharedContacts(listAlreadyShared);
multiDrag.getButtonById(Dialog.OK).addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
// initSuggestContacts();
suggestPanel.resetItemSelected();
// SHARE OWNER IS NULL IN CASE OF NEW SHARE
if (shareOwner != null)
suggestPanel.addRecipient(shareOwner.getName(), false);
for (InfoContactModel infoContactModel : multiDrag.getTargetListContact()) {
suggestPanel.addRecipient(infoContactModel.getName(), true);
}
suggestPanel.boxSetFocus();
// printSelectedUser();
}
});
}
});
}
/**
* Checks if is share owner.
*
* @param infoContactModel
* the info contact model
* @return true, if is share owner
*/
public boolean isShareOwner(InfoContactModel infoContactModel) {
if (infoContactModel != null && shareOwner != null
&& InfoContactModel.COMPARATORLOGINS.compare(infoContactModel, shareOwner) == 0)
return true;
return false;
}
/**
* List already shared contains.
*
* @param contact
* the contact
* @return true, if successful
*/
private boolean listAlreadySharedContains(InfoContactModel contact) {
if (contact == null)
return false;
for (InfoContactModel ct : listAlreadyShared) {
if (InfoContactModel.COMPARATORLOGINS.compare(ct, contact) == 0)
// if(ct.getLogin().compareTo(contact.getLogin())==0)
return true;
}
return false;
}
// DEBUG
/**
* Prints the selected user.
*/
@SuppressWarnings("unused")
private void printSelectedUser() {
System.out.println("SELETECTED USERS: ");
for (InfoContactModel contact : suggestPanel.getSelectedUser())
System.out.println(contact);
}
/**
* Inits the suggest contacts.
*/
@SuppressWarnings("unused")
private void initSuggestContacts() {
suggestPanel.resetItemSelected();
for (InfoContactModel contact : listAlreadyShared)
suggestPanel.addRecipient(contact.getName(), false);
}
/**
* Gets the name.
*
* @return the name
*/
public String getName() {
return txtName.getValue().trim();
}
/**
* Gets the description.
*
* @return the description
*/
public String getDescription() {
if (textAreaDescription.getValue() == null)
return "";
return textAreaDescription.getValue();
}
/**
* Checks if is valid form.
*
* @param displayAlert
* the display alert
* @return true, if is valid form
*/
public boolean isValidForm(boolean displayAlert) {
if (!txtName.isValid()) {
if (displayAlert)
new MessageBoxAlert("Attention", "Name must not be empty", null);
txtName.focus();
return false;
}
if (getSharedListUsers().size() == 0) {
if (displayAlert)
new MessageBoxAlert("Attention", "You must pick at least one user with which share the folder", null);
suggestPanel.boxSetFocus();
return false;
}
return true;
}
/**
* Gets the selected acl.
*
* @return the selected acl
*/
public WorkspaceACL getSelectedACL() {
if (permission != null)
return permission.getSelectedACL();
return null;
}
/**
* Select acl for folder.
*
* @param folder
* the folder
*/
private void selectAclForFolder(FileModel folder) {
GWT.log("Loading ACL to: " + folder);
WorkspaceSharingServiceAsync.INSTANCE.getACLsForSharedFolderId(folder.getIdentifier(),
new AsyncCallback<WorkspaceACL>() {
@Override
public void onFailure(Throwable arg0) {
GWT.log("An error occurred on selecting current ACL " + arg0);
}
@Override
public void onSuccess(WorkspaceACL arg0) {
GWT.log("Loaded ACL " + arg0);
permission.selectACL(arg0);
hpPermission.layout();
layout();
}
});
}
/**
* Gets the users managers.
*
*
* @param sharedFolderId
* share folder id
* @param callback
* list of contacts
*/
public void getUsersManagers(final String sharedFolderId, final AsyncCallback<List<InfoContactModel>> callback) {
WorkspaceSharingServiceAsync.INSTANCE.getAdministratorsByFolderId(sharedFolderId,
new AsyncCallback<List<InfoContactModel>>() {
@Override
public void onFailure(Throwable arg0) {
GWT.log("an error occured in getting user managers by Id " + sharedFolderId + " "
+ arg0.getMessage());
new MessageBoxAlert("Alert",
"Sorry, an error occurred on getting users managers, try again later", null);
}
@Override
public void onSuccess(List<InfoContactModel> listManagers) {
callback.onSuccess(listManagers);
}
});
}
/**
* Permission control.
*
* @param listManagers
* the list managers
* @param showAlert
* the show alert
* @param folder
* the folder
*/
private void permissionControl(List<InfoContactModel> listManagers, boolean showAlert, FileModel folder) {
boolean permissionsOk = false;
for (InfoContactModel infoContactModel : listManagers) {
GWT.log("DialogPermission control compare between : " + infoContactModel.getLogin() + " and my login: "
+ AppControllerExplorer.myLogin);
if (AppControllerExplorer.myLogin.compareToIgnoreCase(infoContactModel.getLogin()) == 0) {
permissionsOk = true;
break;
}
}
if (permissionsOk) {
enableFormDialog(true);
} else {
enableFormDialog(false);
if (showAlert)
new MessageBoxAlert("Permission denied",
"You have no permissions to change sharing. You are not manager of \"" + folder.getName()
+ "\"",
null);
}
}
}

View File

@ -1,4 +1,4 @@
package org.gcube.portlets.user.workspace.client.view.sharing.multisuggest;
package org.gcube.portlets.user.workspace.client.view.sharing;
import java.util.ArrayList;
import java.util.List;

View File

@ -1,59 +0,0 @@
package org.gcube.portlets.user.workspace.client.view.sharing;
import java.util.List;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.WorkspaceACL;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.WorkspaceACL.USER_TYPE;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.form.Radio;
import com.extjs.gxt.ui.client.widget.form.RadioGroup;
import com.extjs.gxt.ui.client.widget.tips.ToolTipConfig;
public class PanelPermission extends LayoutContainer {
protected static final String WORKSPACEACL = "WORKSPACEACL";
private RadioGroup radioGroup = new RadioGroup();
public PanelPermission(List<WorkspaceACL> acls) {
setStyleAttribute("margin-top", "10px");
setStyleAttribute("margin-bottom", "10px");
setSize(350, 30);
radioGroup.mask("Loading ACLs");
for (WorkspaceACL acl : acls) {
if(acl.getUserType().equals(USER_TYPE.OTHER)){
Radio radio = createRadio(acl);
radioGroup.add(radio);
}
}
radioGroup.unmask();
add(radioGroup);
}
private Radio createRadio(WorkspaceACL acl) {
Radio radio = new Radio();
// check.setId(dsm.getId());
// check.setBoxLabel(dsm.getName() + " ("+property+")");
radio.setBoxLabel(acl.getLabel());
radio.setValueAttribute(acl.getLabel());
radio.setData(WORKSPACEACL, acl);
radio.setToolTip(new ToolTipConfig(acl.getDescription()));
radio.setValue(acl.getDefaultValue());
return radio;
}
public WorkspaceACL getSelectedACL() {
if (radioGroup.getValue()!=null)
return (WorkspaceACL) radioGroup.getValue().getData(WORKSPACEACL);
return null;
}
}

View File

@ -1,106 +0,0 @@
package org.gcube.portlets.user.workspace.client.view.sharing;
import java.util.ArrayList;
import java.util.List;
import org.gcube.portlets.user.workspace.client.util.GetPermissionIconByACL;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.WorkspaceACL;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.WorkspaceACL.USER_TYPE;
import com.extjs.gxt.ui.client.Style.ButtonScale;
import com.extjs.gxt.ui.client.Style.IconAlign;
import com.extjs.gxt.ui.client.Style.VerticalAlignment;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.widget.HorizontalPanel;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.button.ToggleButton;
import com.extjs.gxt.ui.client.widget.tips.ToolTipConfig;
import com.google.gwt.core.shared.GWT;
import com.google.gwt.user.client.ui.AbstractImagePrototype;
public class PanelTogglePermission extends LayoutContainer {
protected static final String WORKSPACEACLGROUP = "WORKSPACEACLGROUP";
private HorizontalPanel hp = new HorizontalPanel();
private WorkspaceACL selectedAcl = null;
private List<ToggleButton> toggles;
public PanelTogglePermission(List<WorkspaceACL> acls) {
// setStyleAttribute("margin-top", "10px");
setStyleAttribute("margin-bottom", "15px");
setSize(350, 40);
hp.mask("Loading ACLs");
hp.setVerticalAlign(VerticalAlignment.MIDDLE);
hp.setStyleAttribute("padding-left", "35px");
toggles = new ArrayList<ToggleButton>(acls.size());
for (WorkspaceACL acl : acls) {
if(acl.getUserType().equals(USER_TYPE.OTHER)){
ToggleButton toggle = createToggle(acl);
toggle.setToggleGroup(WORKSPACEACLGROUP);
toggle.setStyleAttribute("margin-right", "10px");
toggles.add(toggle);
hp.add(toggle);
}
}
hp.unmask();
add(hp);
layout();
}
private ToggleButton createToggle(final WorkspaceACL acl) {
final ToggleButton bToggle = new ToggleButton(acl.getLabel());
bToggle.setScale(ButtonScale.MEDIUM);
bToggle.setId(acl.getId());
bToggle.setAllowDepress(false);
bToggle.toggle(acl.getDefaultValue());
if(acl.getDefaultValue())
selectedAcl = acl;
bToggle.setIconAlign(IconAlign.TOP);
bToggle.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
if(bToggle.isPressed()){
selectedAcl = acl;
}
}
});
bToggle.setToolTip(new ToolTipConfig(acl.getDescription()));
AbstractImagePrototype img = GetPermissionIconByACL.getImage(acl);
if(img!=null)
bToggle.setIcon(img);
return bToggle;
}
public WorkspaceACL getSelectedACL() {
GWT.log("Selected ACL is: "+selectedAcl);
return selectedAcl;
}
public void selectACL(WorkspaceACL acl){
for (ToggleButton toogle : toggles) {
GWT.log("Comparing toogle.getId(): "+toogle.getId() +" and acl.getId(): "+acl.getId());
if(toogle.getId().compareTo(acl.getId())==0){
GWT.log("Toogle: "+acl);
toogle.toggle(true);
selectedAcl = acl;
return;
}
}
}
}

View File

@ -1,121 +0,0 @@
package org.gcube.portlets.user.workspace.client.view.sharing;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.ToggleButton;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
/**
*
* @author francesco
*
*/
public class ToggleButtonPanel extends Composite implements HasWidgets, HasClickHandlers {
private List<ClickHandler> handlers = new ArrayList<ClickHandler>();
private final Panel panel;
public ToggleButtonPanel() {
this(new VerticalPanel());
}
public ToggleButtonPanel(Panel panel) {
this.panel = panel;
initWidget(panel);
}
@Override
public void add(Widget w) {
if (w instanceof ToggleButton) {
ToggleButton button = (ToggleButton) w;
button.addClickHandler(handler);
}
panel.add(w);
}
@Override
public void clear() {
panel.clear();
}
@Override
public Iterator<Widget> iterator() {
return panel.iterator();
}
@Override
public boolean remove(Widget w) {
return panel.remove(w);
}
@Override
public void setWidth(String width) {
panel.setWidth(width);
};
@Override
public void setHeight(String height) {
panel.setHeight(height);
}
private ClickHandler handler = new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
Iterator<Widget> itr = panel.iterator();
while (itr.hasNext()) {
Widget w = itr.next();
if (w instanceof ToggleButton) {
ToggleButton button = (ToggleButton) w;
button.setDown(false);
if (event.getSource().equals(button)) {
button.setDown(true);
}
}
}
for (ClickHandler h : handlers) {
h.onClick(event);
}
}
};
@Override
public HandlerRegistration addClickHandler(final ClickHandler handler) {
handlers.add(handler);
return new HandlerRegistration() {
@Override
public void removeHandler() {
handlers.remove(handler);
}
};
}
public ToggleButton getDown(){
Iterator<Widget> it = iterator();
while (it!=null && it.hasNext()) {
Widget w = (Widget) it.next();
if (w instanceof ToggleButton) {
ToggleButton t = (ToggleButton) w;
if(t.isDown())
return t;
}
}
return null;
}
}

View File

@ -1,146 +0,0 @@
package org.gcube.portlets.user.workspace.client.view.sharing;
import java.util.ArrayList;
import java.util.List;
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
import org.gcube.portlets.user.workspace.client.view.windows.MessageBoxAlert;
import org.gcube.portlets.widgets.workspacesharingwidget.client.rpc.WorkspaceSharingServiceAsync;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
/**
* The Class UserStore.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
*/
public class UserStore implements ContactFetcher{
public static List<InfoContactModel> listAllContact = null;
// public boolean syncronizeCleanSharedUser = false;
/**
* Instantiates a new user store.
*/
public UserStore() {
loadAllUsersFromServer(null);
}
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.view.sharing.ContactFetcher#getListContact(com.google.gwt.user.client.rpc.AsyncCallback, boolean)
*/
@Override
public void getListContact(AsyncCallback<List<InfoContactModel>> callback, boolean reloadList){
if(reloadList || listAllContact==null || listAllContact.size()==0)
loadAllUsersFromServer(callback);
else
callback.onSuccess(listAllContact);
}
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.view.sharing.ContactFetcher#getListSharedUserByFolderId(java.lang.String, com.google.gwt.user.client.rpc.AsyncCallback)
*/
@Override
public void getListSharedUserByFolderId(String sharedFolderId, AsyncCallback<List<InfoContactModel>> callback){
loadSharedUserBySharedFolderId(sharedFolderId, callback);
}
/**
* Load all users from server.
*
* @param callback the callback
*/
private void loadAllUsersFromServer(final AsyncCallback<List<InfoContactModel>> callback){
listAllContact = new ArrayList<InfoContactModel>();
WorkspaceSharingServiceAsync.INSTANCE.getAllContacts(new AsyncCallback<List<InfoContactModel>>() {
@Override
public void onSuccess(List<InfoContactModel> result) {
GWT.log("loaded "+result.size() + " contacts from server");
listAllContact = result;
if(callback!=null)
callback.onSuccess(listAllContact);
}
@Override
public void onFailure(Throwable caught) {
//TODO TEMPORARY SOLUTION
//new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR +" retrieving user " + ConstantsExplorer.TRY_AGAIN, null);
if(callback!=null)
callback.onFailure(caught);
}
});
}
/**
* Load shared user by shared folder id.
*
* @param sharedFolderId the shared folder id
* @param callback the callback
*/
private void loadSharedUserBySharedFolderId(final String sharedFolderId, final AsyncCallback<List<InfoContactModel>> callback){
// comboSharedUsers.mask("Loading users");
WorkspaceSharingServiceAsync.INSTANCE.getListUserSharedByFolderSharedId(sharedFolderId, new AsyncCallback<List<InfoContactModel>>() {
@Override
public void onFailure(Throwable caught) {
new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR +" retrieving user. " + ConstantsExplorer.TRY_AGAIN, null);
if(callback!=null)
callback.onFailure(caught);
}
@Override
public void onSuccess(List<InfoContactModel> result) {
GWT.log("loaded "+result.size() + " contacts from server for "+sharedFolderId);
if(callback!=null)
callback.onSuccess(result);
}
});
}
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.view.sharing.ContactFetcher#getExclusiveContactsFromAllContact(java.util.List)
*/
@Override
public List<InfoContactModel> getExclusiveContactsFromAllContact(List<InfoContactModel> listSharedUser){
List<InfoContactModel> listExclusiveContact = new ArrayList<InfoContactModel>(listAllContact);
for (InfoContactModel contact : listSharedUser) {
if(listAllContact.contains(contact)){
GWT.log("Removing not eclusive contact "+contact);
listExclusiveContact.remove(contact);
}
}
return listExclusiveContact;
}
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.view.sharing.ContactFetcher#getOwner(java.lang.String, com.google.gwt.user.client.rpc.AsyncCallback)
*/
@Override
public void getOwner(final String sharedFolderId,final AsyncCallback<InfoContactModel> callback) {
WorkspaceSharingServiceAsync.INSTANCE.getOwnerByItemId(sharedFolderId, new AsyncCallback<InfoContactModel>() {
@Override
public void onFailure(Throwable caught) {
GWT.log("an error occured in get Owner by Id "+sharedFolderId + " "+caught.getMessage());
}
@Override
public void onSuccess(InfoContactModel result) {
if(callback!=null)
callback.onSuccess(result);
}
});
}
}

View File

@ -1,25 +0,0 @@
package org.gcube.portlets.user.workspace.client.view.sharing.multisuggest;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.ComplexPanel;
import com.google.gwt.user.client.ui.Widget;
/**
*
* @author Massimiliano Assante, ISTI-CNR
* @version 0.1 Sep 2012
*
*/
public class BulletList extends ComplexPanel {
public BulletList() {
setElement(DOM.createElement("ul"));
}
public void add(Widget w) {
super.add(w, getElement());
}
public void insert(Widget w, int beforeIndex) {
super.insert(w, getElement(), beforeIndex, true);
}
}

View File

@ -1,61 +0,0 @@
package org.gcube.portlets.user.workspace.client.view.sharing.multisuggest;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyDownEvent;
import com.google.gwt.event.dom.client.KeyDownHandler;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.ComplexPanel;
import com.google.gwt.user.client.ui.Widget;
/**
*
* @author Massimiliano Assante, ISTI-CNR
* @version 0.1 Sep 2012
*
*/
public class ListItem extends ComplexPanel {
HandlerRegistration clickHandler;
public HandlerRegistration addKeyDownHandler(KeyDownHandler handler) {
return addDomHandler(handler, KeyDownEvent.getType());
}
public HandlerRegistration addClickHandler(ClickHandler handler) {
return addDomHandler(handler, ClickEvent.getType());
}
public String getHTML() {
return DOM.getInnerHTML(getElement());
}
public void setHTML(String html) {
DOM.setInnerHTML(getElement(), (html == null) ? "" : html);
}
public ListItem() {
setElement(DOM.createElement("li"));
}
public void setId(String id) {
DOM.setElementAttribute(getElement(), "id", id);
}
public void add(Widget w) {
super.add(w, getElement());
}
public void insert(Widget w, int beforeIndex) {
super.insert(w, getElement(), beforeIndex, true);
}
public String getText() {
return DOM.getInnerText(getElement());
}
public void setText(String text) {
DOM.setInnerText(getElement(), (text == null) ? "" : text);
}
}

View File

@ -1,330 +0,0 @@
package org.gcube.portlets.user.workspace.client.view.sharing.multisuggest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.gcube.portlets.user.workspace.client.util.MaskPanel;
import org.gcube.portlets.user.workspace.client.view.sharing.ContactFetcher;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyDownEvent;
import com.google.gwt.event.dom.client.KeyDownHandler;
import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.gwt.user.client.Random;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.MultiWordSuggestOracle;
import com.google.gwt.user.client.ui.SuggestBox;
import com.google.gwt.user.client.ui.SuggestOracle;
import com.google.gwt.user.client.ui.TextBox;
/**
* The Class MultiValuePanel.
*
* @author Massimiliano Assante, ISTI-CNR
* @version 0.2 Gen 2013 modified by Francesco Mangiacrapa
* @version 0.3 Gen 2017 modified by Francesco Mangiacrapa
* Facebook style autocompleter
*/
public class MultiValuePanel extends Composite {
// private final WsMailServiceAsync mailingService = GWT.create(WsMailService.class);
private List<String> itemsSelected = new ArrayList<String>();
FlowPanel panel = new FlowPanel();
// private HandlerManager eventBus;
private HashMap<String, InfoContactModel> users = new HashMap<String, InfoContactModel>();
private BulletList listBullet = new BulletList();
private SuggestBox box;
private ContactFetcher userFetch;
private MultiWordSuggestOracle oracle = new MultiWordSuggestOracle();
private MaskPanel mask = new MaskPanel("Loading Contacts...");
/**
* Instantiates a new multi value panel.
*
* @param userFetch the ContactFetcher
*/
public MultiValuePanel(ContactFetcher userFetch) {
this.userFetch = userFetch;
initWidget(panel);
this.getElement().setId("MultiValuePanel_"+Random.nextInt());
panel.setWidth("100%");
listBullet.setStyleName("multivalue-panel-suggest");
final ListItem item = new ListItem();
final TextBox itemBox = new TextBox();
itemBox.getElement().setAttribute("autocomplete", "off");
itemBox.getElement().setAttribute("style", "outline-color: -moz-use-text-color; outline-style: none; outline-width: medium; border: none;");
maskSuggestionPanel(true);
box = new SuggestBox(getSuggestions(), itemBox);
item.add(box);
listBullet.add(item);
// needed to be set on the itemBox instead of the box, otherwise backspace gets executed twice
itemBox.addKeyDownHandler(new KeyDownHandler() {
public void onKeyDown(KeyDownEvent event) {
// handle backspace
if (event.getNativeKeyCode() == KeyCodes.KEY_BACKSPACE) {
if ("".equals(itemBox.getValue().trim())) {
if(listBullet.getWidgetCount()>2){
ListItem li = (ListItem) listBullet.getWidget(listBullet.getWidgetCount() - 2);
if(li.getWidget(0) instanceof Paragraph){
Paragraph p = (Paragraph) li.getWidget(0);
// GWT.log("p "+p.getText() +" is removable : " + p.isRemovable());
if (itemsSelected.contains(p.getText()) && p.isRemovable()==true) {
itemsSelected.remove(p.getText());
GWT.log("Removing selected item: " + p.getText() + "'");
listBullet.remove(li);
}
itemBox.setFocus(true);
}
}
}
}
}
});
box.addSelectionHandler(new SelectionHandler<SuggestOracle.Suggestion>() {
public void onSelection(SelectionEvent<SuggestOracle.Suggestion> selectionEvent) {
chosenContactItem(itemBox, listBullet);
}
});
panel.add(listBullet);
box.getElement().setId("suggestion_box"); //needed for the focus on click
panel.getElement().setAttribute("onclick", "document.getElementById('suggestion_box').focus()");
}
/**
* Box set focus.
*/
public void boxSetFocus(){
box.getElement().focus();
box.setFocus(true);
}
/**
* Gets the flow panel.
*
* @return the flow panel
*/
public FlowPanel getFlowPanel(){
return panel;
}
private void maskSuggestionPanel(boolean bool){
try{
if(bool){
GWT.log("Disabling panel suggestion");
this.getElement().addClassName("disabledDIV");
panel.add(mask);
}else{
GWT.log("Enabling panel suggestion");
this.getElement().removeClassName("disabledDIV");
panel.remove(mask);
}
}catch(Exception e){
GWT.log("error: "+e.getMessage());
}
}
/**
* actually insert the contact in the flow panel.
*
* @param itemBox the item box
* @param list the list
*/
private void chosenContactItem(final TextBox itemBox, final BulletList list) {
if (itemBox.getValue() != null && !"".equals(itemBox.getValue().trim())) {
final ListItem displayItem = new ListItem();
displayItem.setStyleName("multivalue-panel-token-ws");
Paragraph p = new Paragraph(itemBox.getValue());
Span span = new Span("x");
span.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
removeListItem(displayItem, list);
}
});
displayItem.add(p);
displayItem.add(span);
//original value of the item selected
GWT.log("Adding selected item '" + itemBox.getValue());
itemsSelected.add(itemBox.getValue());
GWT.log("Total: " + itemsSelected);
list.insert(displayItem, list.getWidgetCount() - 1);
itemBox.setValue("");
itemBox.setFocus(true);
}
}
/**
* Gets the selected user.
*
* @return the selected contacts (user logins e.g. pino.pini)
*/
public List<InfoContactModel> getSelectedUser() {
if (users == null)
return new ArrayList<InfoContactModel>();
else {
List<InfoContactModel> toReturn = new ArrayList<InfoContactModel>();
for (String login : itemsSelected) {
InfoContactModel wsuser = users.get(login);
if(wsuser!= null && !toReturn.contains(wsuser)){
toReturn.add(wsuser);
}
}
return toReturn;
}
}
/**
* Removes the list item.
*
* @param displayItem the display item
* @param list the list
*/
private void removeListItem(ListItem displayItem, BulletList list) {
GWT.log("Removing: " + displayItem.getWidget(0).getElement().getInnerHTML(), null);
itemsSelected.remove(displayItem.getWidget(0).getElement().getInnerHTML());
list.remove(displayItem);
}
/**
* Gets the suggestions.
*
* @return names of possible contacts
*/
private MultiWordSuggestOracle getSuggestions() {
userFetch.getListContact(contacts, false);
return oracle;
}
/**
* Update suggestions.
*
* @param result the result
*/
public void updateSuggestions(List<InfoContactModel> result) {
oracle.clear();
for (InfoContactModel wsUser : result) {
oracle.add(wsUser.getName());
}
}
private AsyncCallback<List<InfoContactModel>> contacts = new AsyncCallback<List<InfoContactModel>>() {
@Override
public void onFailure(Throwable caught) {
maskSuggestionPanel(false);
}
@Override
public void onSuccess(List<InfoContactModel> result) {
maskSuggestionPanel(false);
users.clear();
for (InfoContactModel wsUser : result) {
oracle.add(wsUser.getName());
users.put(wsUser.getName(), wsUser);
}
}
};
/**
* Reset item selected.
*/
public void resetItemSelected(){
listBullet.clear();
itemsSelected.clear();
ListItem item = new ListItem();
item.add(box);
listBullet.add(item);
}
/**
* Adds the recipient.
*
* @param fullName the full name
* @param displayRemoveItem the display remove item
*/
public void addRecipient(String fullName, boolean displayRemoveItem) {
if (fullName != null) {
TextBox itemBox = new TextBox();
itemBox.setText(fullName);
itemBox.setValue(fullName);
final ListItem displayItem = new ListItem();
Paragraph p = new Paragraph(fullName);
displayItem.add(p);
if(displayRemoveItem){
displayItem.setStyleName("multivalue-panel-token-ws");
p.setRemovable(true);
Span span = new Span("x");
span.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
removeListItem(displayItem, listBullet);
}
});
displayItem.add(span);
}
else{
displayItem.setStyleName("multivalue-panel-token-ws-notselectable");
p.setRemovable(false);
}
GWT.log("Adding selected wp item '" + itemBox.getValue());
itemsSelected.add(itemBox.getValue());
GWT.log("Total: " + itemsSelected);
listBullet.insert(displayItem, listBullet.getWidgetCount()-1);
itemBox.setValue("");
itemBox.setFocus(true);
}
}
/**
* Clear list.
*/
public void clearList() {
listBullet.clear();
}
/**
* Gets the box.
*
* @return the box
*/
public SuggestBox getBox() {
return box;
}
}

View File

@ -1,42 +0,0 @@
package org.gcube.portlets.user.workspace.client.view.sharing.multisuggest;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.HasText;
import com.google.gwt.user.client.ui.Widget;
/**
*
* @author Massimiliano Assante, ISTI-CNR
* @version 0.1 Sep 2012
* changed by Francesco Mangiacrapa
*
*/
public class Paragraph extends Widget implements HasText {
boolean isRemovable = true;
public Paragraph() {
setElement(DOM.createElement("p"));
}
public Paragraph(String text) {
this();
setText(text);
}
public String getText() {
return getElement().getInnerText();
}
public void setText(String text) {
getElement().setInnerText(text);
}
public boolean isRemovable(){
return isRemovable;
}
public void setRemovable(boolean isRemovable) {
this.isRemovable = isRemovable;
}
}

View File

@ -1,23 +0,0 @@
package org.gcube.portlets.user.workspace.client.view.sharing.multisuggest;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasText;
/**
*
* @author Massimiliano Assante, ISTI-CNR
* @version 0.1 Sep 2012
*
*/
public class Span extends HTML implements HasText {
public Span() {
super(DOM.createElement("span"));
}
public Span(String text) {
this();
setText(text);
}
}

View File

@ -1,43 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.workspace.shared;
import java.io.Serializable;
import java.util.ArrayList;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
/**
*
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
* Nov 4, 2015
*/
public class ListContact<T extends InfoContactModel> extends ArrayList<T> implements Serializable{
private static final long serialVersionUID = 544202687567940083L;
public ListContact() {
}
public boolean contains(InfoContactModel infoContactModel) {
if(infoContactModel==null)
return false;
if(infoContactModel.getLogin()==null)
return false;
for (int i = 0; i < this.size(); i++){
InfoContactModel log = get(i);
if (log.getLogin()!=null && log.getLogin().compareTo(infoContactModel.getLogin())==0)
return true;
}
return false;
}
}