From fe70c83f94fe6047d372292535fd73099301a511 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Mon, 22 Jul 2019 12:51:27 +0000 Subject: [PATCH] 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 --- .../client/AppControllerExplorer.java | 4 +- .../client/view/sharing/ContactFetcher.java | 16 - .../{permissions => }/DialogPermission.java | 5 +- .../view/sharing/DialogShareFolder.java | 710 ------------------ .../{multisuggest => }/MultiDragContact.java | 2 +- .../client/view/sharing/PanelPermission.java | 59 -- .../view/sharing/PanelTogglePermission.java | 106 --- .../view/sharing/ToggleButtonPanel.java | 121 --- .../client/view/sharing/UserStore.java | 146 ---- .../view/sharing/multisuggest/BulletList.java | 25 - .../view/sharing/multisuggest/ListItem.java | 61 -- .../sharing/multisuggest/MultiValuePanel.java | 330 -------- .../view/sharing/multisuggest/Paragraph.java | 42 -- .../view/sharing/multisuggest/Span.java | 23 - .../user/workspace/shared/ListContact.java | 43 -- 15 files changed, 6 insertions(+), 1687 deletions(-) delete mode 100644 src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/ContactFetcher.java rename src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/{permissions => }/DialogPermission.java (97%) delete mode 100644 src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/DialogShareFolder.java rename src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/{multisuggest => }/MultiDragContact.java (99%) delete mode 100644 src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/PanelPermission.java delete mode 100644 src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/PanelTogglePermission.java delete mode 100644 src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/ToggleButtonPanel.java delete mode 100644 src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/UserStore.java delete mode 100644 src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/multisuggest/BulletList.java delete mode 100644 src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/multisuggest/ListItem.java delete mode 100644 src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/multisuggest/MultiValuePanel.java delete mode 100644 src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/multisuggest/Paragraph.java delete mode 100644 src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/multisuggest/Span.java delete mode 100644 src/main/java/org/gcube/portlets/user/workspace/shared/ListContact.java diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java b/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java index 403925a..88d8713 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java @@ -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; diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/ContactFetcher.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/ContactFetcher.java deleted file mode 100644 index 124ef31..0000000 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/ContactFetcher.java +++ /dev/null @@ -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> callback, boolean reloadList); - public void getListSharedUserByFolderId(String sharedFolderId, AsyncCallback> callback); - public List getExclusiveContactsFromAllContact(List listSharedUser); - public void getOwner(String sharedFolderId, AsyncCallback callback); - -} diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/permissions/DialogPermission.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/DialogPermission.java similarity index 97% rename from src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/permissions/DialogPermission.java rename to src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/DialogPermission.java index a9766e9..0e2023b 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/permissions/DialogPermission.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/DialogPermission.java @@ -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; diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/DialogShareFolder.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/DialogShareFolder.java deleted file mode 100644 index c93ad90..0000000 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/DialogShareFolder.java +++ /dev/null @@ -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 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 txtOwner; - private PanelTogglePermission permission; - private HorizontalPanel hpPermission = null; - private InfoContactModel shareOwner = null; - private ListContact listAlreadyShared = new ListContact(); - - /** - * 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(); - 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(); - 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>() { - - @Override - public void onSuccess(List 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() { - - @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> callback = new AsyncCallback>() { - - @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 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 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>() { - - @Override - public void onSuccess(List 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(); - 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>() { - - @Override - public void onSuccess(List 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 getSharedListUsers() { - // printSelectedUser(); - return suggestPanel.getSelectedUser(); - } - - /** - * Adds the listners. - */ - public void addListners() { - - this.getButtonById(Dialog.CANCEL).addSelectionListener(new SelectionListener() { - - @Override - public void componentSelected(ButtonEvent ce) { - hide(); - } - }); - - this.getButtonById(Dialog.OK).addSelectionListener(new SelectionListener() { - - @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 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() { - - @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() { - - @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> callback) { - - WorkspaceSharingServiceAsync.INSTANCE.getAdministratorsByFolderId(sharedFolderId, - new AsyncCallback>() { - - @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 listManagers) { - callback.onSuccess(listManagers); - - } - }); - } - - /** - * Permission control. - * - * @param listManagers - * the list managers - * @param showAlert - * the show alert - * @param folder - * the folder - */ - private void permissionControl(List 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); - } - - } - -} diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/multisuggest/MultiDragContact.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/MultiDragContact.java similarity index 99% rename from src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/multisuggest/MultiDragContact.java rename to src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/MultiDragContact.java index 2bd239b..d50ffd7 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/multisuggest/MultiDragContact.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/MultiDragContact.java @@ -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; diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/PanelPermission.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/PanelPermission.java deleted file mode 100644 index e87c9cb..0000000 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/PanelPermission.java +++ /dev/null @@ -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 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; - } -} diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/PanelTogglePermission.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/PanelTogglePermission.java deleted file mode 100644 index 4db35a4..0000000 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/PanelTogglePermission.java +++ /dev/null @@ -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 toggles; - - public PanelTogglePermission(List 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(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() { - - @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; - } - } - } -} diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/ToggleButtonPanel.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/ToggleButtonPanel.java deleted file mode 100644 index 727fdb6..0000000 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/ToggleButtonPanel.java +++ /dev/null @@ -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 handlers = new ArrayList(); - 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 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 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 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; - } - -} diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/UserStore.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/UserStore.java deleted file mode 100644 index bb466ef..0000000 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/UserStore.java +++ /dev/null @@ -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 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> 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> callback){ - loadSharedUserBySharedFolderId(sharedFolderId, callback); - } - - /** - * Load all users from server. - * - * @param callback the callback - */ - private void loadAllUsersFromServer(final AsyncCallback> callback){ - - listAllContact = new ArrayList(); - - WorkspaceSharingServiceAsync.INSTANCE.getAllContacts(new AsyncCallback>() { - - @Override - public void onSuccess(List 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> callback){ - -// comboSharedUsers.mask("Loading users"); - - WorkspaceSharingServiceAsync.INSTANCE.getListUserSharedByFolderSharedId(sharedFolderId, new AsyncCallback>() { - - @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 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 getExclusiveContactsFromAllContact(List listSharedUser){ - - List listExclusiveContact = new ArrayList(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 callback) { - - WorkspaceSharingServiceAsync.INSTANCE.getOwnerByItemId(sharedFolderId, new AsyncCallback() { - - @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); - } - }); - } -} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/multisuggest/BulletList.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/multisuggest/BulletList.java deleted file mode 100644 index 5fb8b92..0000000 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/multisuggest/BulletList.java +++ /dev/null @@ -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); - } -} - diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/multisuggest/ListItem.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/multisuggest/ListItem.java deleted file mode 100644 index a1cc4e8..0000000 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/multisuggest/ListItem.java +++ /dev/null @@ -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); - } - - -} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/multisuggest/MultiValuePanel.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/multisuggest/MultiValuePanel.java deleted file mode 100644 index f017f9c..0000000 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/multisuggest/MultiValuePanel.java +++ /dev/null @@ -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 itemsSelected = new ArrayList(); - FlowPanel panel = new FlowPanel(); -// private HandlerManager eventBus; - private HashMap users = new HashMap(); - 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() { - public void onSelection(SelectionEvent 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 getSelectedUser() { - if (users == null) - return new ArrayList(); - else { - List toReturn = new ArrayList(); - - 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 result) { - - oracle.clear(); - for (InfoContactModel wsUser : result) { - oracle.add(wsUser.getName()); - } - } - - private AsyncCallback> contacts = new AsyncCallback>() { - - - @Override - public void onFailure(Throwable caught) { - maskSuggestionPanel(false); - } - - @Override - public void onSuccess(List 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; - - } -} diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/multisuggest/Paragraph.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/multisuggest/Paragraph.java deleted file mode 100644 index d3764fa..0000000 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/multisuggest/Paragraph.java +++ /dev/null @@ -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; - } -} diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/multisuggest/Span.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/multisuggest/Span.java deleted file mode 100644 index fdd800d..0000000 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/multisuggest/Span.java +++ /dev/null @@ -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); - } -} diff --git a/src/main/java/org/gcube/portlets/user/workspace/shared/ListContact.java b/src/main/java/org/gcube/portlets/user/workspace/shared/ListContact.java deleted file mode 100644 index e9ae794..0000000 --- a/src/main/java/org/gcube/portlets/user/workspace/shared/ListContact.java +++ /dev/null @@ -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 extends ArrayList 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; - } -}