ref 17169: Selection of users in the Sharing panel
https://support.d4science.org/issues/17169 Added support to workspace users discovery by VREs git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@181349 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
85d54e6051
commit
86724bc3d8
|
@ -119,7 +119,6 @@ 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.ExplorerPanel;
|
||||||
import org.gcube.portlets.user.workspace.client.view.sharing.DialogPermission;
|
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.DialogShareFolder;
|
||||||
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.tree.AsyncTreePanel;
|
||||||
import org.gcube.portlets.user.workspace.client.view.windows.DialogAddFolderAndSmart;
|
import org.gcube.portlets.user.workspace.client.view.windows.DialogAddFolderAndSmart;
|
||||||
import org.gcube.portlets.user.workspace.client.view.windows.DialogAddFolderAndSmart.AddType;
|
import org.gcube.portlets.user.workspace.client.view.windows.DialogAddFolderAndSmart.AddType;
|
||||||
|
@ -148,11 +147,11 @@ import org.gcube.portlets.user.workspace.shared.WorkspaceOperationResult;
|
||||||
import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingField;
|
import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingField;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.CloseCreationFormEvent;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.CloseCreationFormEvent;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.form.CreateDatasetForm;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.form.CreateDatasetForm;
|
||||||
import org.gcube.portlets.widgets.workspacesharingwidget.client.ConstantsSharing.LOAD_CONTACTS_AS;
|
|
||||||
import org.gcube.portlets.widgets.workspacesharingwidget.client.MultiDragConstants;
|
import org.gcube.portlets.widgets.workspacesharingwidget.client.MultiDragConstants;
|
||||||
import org.gcube.portlets.widgets.workspacesharingwidget.client.ShowPermissionsDialog;
|
|
||||||
import org.gcube.portlets.widgets.workspacesharingwidget.client.MultiDragWorkspaceContactAdmin;
|
import org.gcube.portlets.widgets.workspacesharingwidget.client.MultiDragWorkspaceContactAdmin;
|
||||||
|
import org.gcube.portlets.widgets.workspacesharingwidget.client.ShowPermissionsDialog;
|
||||||
import org.gcube.portlets.widgets.workspacesharingwidget.client.rpc.WorkspaceSharingServiceAsync;
|
import org.gcube.portlets.widgets.workspacesharingwidget.client.rpc.WorkspaceSharingServiceAsync;
|
||||||
|
import org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.UserStore;
|
||||||
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
|
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploadNotification.WorskpaceUploadNotificationListener;
|
import org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploadNotification.WorskpaceUploadNotificationListener;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.client.uploader.DialogUpload.UPLOAD_TYPE;
|
import org.gcube.portlets.widgets.workspaceuploader.client.uploader.DialogUpload.UPLOAD_TYPE;
|
||||||
|
@ -192,7 +191,8 @@ import com.google.gwt.user.client.ui.HasWidgets;
|
||||||
/**
|
/**
|
||||||
* The Class AppControllerExplorer.
|
* The Class AppControllerExplorer.
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it May 15, 2017
|
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
||||||
|
* May 15, 2017
|
||||||
*/
|
*/
|
||||||
public class AppControllerExplorer implements EventHandler, TreeAppControllerInterface {
|
public class AppControllerExplorer implements EventHandler, TreeAppControllerInterface {
|
||||||
|
|
||||||
|
@ -540,7 +540,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
// IF NOT CANCELLED
|
// IF NOT CANCELLED
|
||||||
String clickedButton = be.getButtonClicked().getItemId();
|
String clickedButton = be.getButtonClicked().getItemId();
|
||||||
if (clickedButton.equals(Dialog.YES)) {
|
if (clickedButton.equals(Dialog.YES)) {
|
||||||
GWT.log("Calling unSharedFolderByFolderSharedId for id: "+folderIdentification);
|
GWT.log("Calling unSharedFolderByFolderSharedId for id: " + folderIdentification);
|
||||||
explorerPanel.getAsycTreePanel().mask(ConstantsExplorer.UNSHARING,
|
explorerPanel.getAsycTreePanel().mask(ConstantsExplorer.UNSHARING,
|
||||||
ConstantsExplorer.LOADINGSTYLE);
|
ConstantsExplorer.LOADINGSTYLE);
|
||||||
WorkspaceSharingServiceAsync.INSTANCE.unSharedFolderByFolderSharedId(
|
WorkspaceSharingServiceAsync.INSTANCE.unSharedFolderByFolderSharedId(
|
||||||
|
@ -1687,9 +1687,10 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(caught instanceof SHUBOperationNotAllowedException) {
|
if (caught instanceof SHUBOperationNotAllowedException) {
|
||||||
MessageBox.info("Operation not allowed...", caught.getMessage(), null).show();
|
MessageBox.info("Operation not allowed...", caught.getMessage(), null)
|
||||||
}else {
|
.show();
|
||||||
|
} else {
|
||||||
new MessageBoxAlert("Error", caught.getMessage(), null);
|
new MessageBoxAlert("Error", caught.getMessage(), null);
|
||||||
}
|
}
|
||||||
explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot();
|
explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot();
|
||||||
|
@ -1752,9 +1753,10 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
|
|
||||||
explorerPanel.getAsycTreePanel().unmask();
|
explorerPanel.getAsycTreePanel().unmask();
|
||||||
|
|
||||||
if(caught instanceof SHUBOperationNotAllowedException) {
|
if (caught instanceof SHUBOperationNotAllowedException) {
|
||||||
MessageBox.info("Operation not allowed...", caught.getMessage(), null).show();
|
MessageBox.info("Operation not allowed...", caught.getMessage(), null)
|
||||||
}else {
|
.show();
|
||||||
|
} else {
|
||||||
new MessageBoxAlert("Error", caught.getMessage(), null);
|
new MessageBoxAlert("Error", caught.getMessage(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1945,12 +1947,14 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
new MessageBoxAlert("Error", caught.getMessage() + ".", null);
|
new MessageBoxAlert("Error", caught.getMessage() + ".", null);
|
||||||
|
|
||||||
// System.out.println(caught.getMessage());
|
// System.out.println(caught.getMessage());
|
||||||
// explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(
|
// explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(
|
||||||
// event.getTargetParentFileModel().getIdentifier(), false);
|
// event.getTargetParentFileModel().getIdentifier(),
|
||||||
// explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(
|
// false);
|
||||||
// event.getFileSourceModel().getParentFileModel().getIdentifier(), true);
|
// explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(
|
||||||
|
// event.getFileSourceModel().getParentFileModel().getIdentifier(),
|
||||||
|
// true);
|
||||||
|
|
||||||
//FXING THE ISSUE #16665
|
// FXING THE ISSUE #16665
|
||||||
explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot();
|
explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1961,7 +1965,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
|
|
||||||
if (result.getError() != null) {
|
if (result.getError() != null) {
|
||||||
new MessageBoxAlert("Error", result.getError(), null);
|
new MessageBoxAlert("Error", result.getError(), null);
|
||||||
//FXING THE ISSUE #16665
|
// FXING THE ISSUE #16665
|
||||||
explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot();
|
explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2736,8 +2740,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleEvent(BaseEvent be) {
|
public void handleEvent(BaseEvent be) {
|
||||||
final List<InfoContactModel> targets = multiDragContactAdmin
|
final List<InfoContactModel> targets = multiDragContactAdmin.getTargetContacts();
|
||||||
.getTargetContacts();
|
|
||||||
|
|
||||||
if (targets.size() == 1) {
|
if (targets.size() == 1) {
|
||||||
MessageBoxConfirm info = new MessageBoxConfirm("Any Administrator/s?",
|
MessageBoxConfirm info = new MessageBoxConfirm("Any Administrator/s?",
|
||||||
|
|
|
@ -0,0 +1,164 @@
|
||||||
|
package org.gcube.portlets.user.workspace.client.view.sharing;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.portlets.widgets.workspacesharingwidget.client.resources.Resources;
|
||||||
|
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
|
||||||
|
|
||||||
|
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
|
||||||
|
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.LayoutContainer;
|
||||||
|
import com.extjs.gxt.ui.client.widget.MessageBox;
|
||||||
|
import com.extjs.gxt.ui.client.widget.button.Button;
|
||||||
|
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
|
||||||
|
import com.google.gwt.core.client.GWT;
|
||||||
|
import com.google.gwt.user.client.Random;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Francesco Mangiacrapa Jan 27, 2015
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class DialogMultiDragWorkspaceContacts extends Dialog {
|
||||||
|
|
||||||
|
private static final String GROUP_DRAGGING_CONTACTS = "Group dragging contacts";
|
||||||
|
|
||||||
|
private static final int HEIGHT_DIALOG = 580;
|
||||||
|
private static final int WIDTH_DIALOG = 620;
|
||||||
|
|
||||||
|
private String txtHelp = "Drag one or more contacts from the left (All Contacts) to the right (Share with) to add users in your sharing list.";
|
||||||
|
private String titleHelp = "Group dragging action";
|
||||||
|
|
||||||
|
// private boolean hideOnPressOkButton=false;
|
||||||
|
private PanelMultiDragWorkspaceContact multiDragContactPanel;
|
||||||
|
// private boolean visibleTextArea=false;
|
||||||
|
|
||||||
|
private ToolBar toolBar;
|
||||||
|
|
||||||
|
private LayoutContainer lcTop = new LayoutContainer();
|
||||||
|
private LayoutContainer lcMiddle = new LayoutContainer();
|
||||||
|
private LayoutContainer lcBottom = new LayoutContainer();
|
||||||
|
|
||||||
|
private InfoContactModel owner;
|
||||||
|
private List<InfoContactModel> targetContact;
|
||||||
|
|
||||||
|
public DialogMultiDragWorkspaceContacts(InfoContactModel owner, List<InfoContactModel> targetContact) {
|
||||||
|
|
||||||
|
GWT.log("DialogMultiDragWorkspaceContacts()");
|
||||||
|
try {
|
||||||
|
this.owner = owner;
|
||||||
|
this.targetContact = targetContact;
|
||||||
|
init();
|
||||||
|
create();
|
||||||
|
} catch (Throwable e) {
|
||||||
|
GWT.log("Error in DialogMultiDragWorkspaceContacts()" + e.getLocalizedMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showToolBar(boolean bool) {
|
||||||
|
this.toolBar.setVisible(bool);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
GWT.log("DialogMultiDragWorkspaceContacts init");
|
||||||
|
setHeading(GROUP_DRAGGING_CONTACTS);
|
||||||
|
setId(DialogMultiDragWorkspaceContacts.class.getName() + Random.nextInt());
|
||||||
|
setSize(WIDTH_DIALOG, HEIGHT_DIALOG);
|
||||||
|
setResizable(false);
|
||||||
|
setMaximizable(false);
|
||||||
|
|
||||||
|
setIcon(Resources.getIconUsers());
|
||||||
|
setModal(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void create() {
|
||||||
|
GWT.log("DialogMultiDragWorkspaceContacts create");
|
||||||
|
// Configure Toolbar
|
||||||
|
GWT.log("DialogMultiDragWorkspaceContacts Configure Toolbar");
|
||||||
|
toolBar = new ToolBar();
|
||||||
|
Button buttonHelp = new Button();
|
||||||
|
buttonHelp.setIcon(Resources.getIconInfo());
|
||||||
|
|
||||||
|
buttonHelp.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void componentSelected(ButtonEvent ce) {
|
||||||
|
MessageBox.info(titleHelp, txtHelp, null);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
toolBar.add(buttonHelp);
|
||||||
|
setTopComponent(toolBar);
|
||||||
|
|
||||||
|
//
|
||||||
|
GWT.log("DialogMultiDragWorkspaceContacts Configure Button");
|
||||||
|
setButtonAlign(HorizontalAlignment.CENTER);
|
||||||
|
setButtons(Dialog.OKCANCEL);
|
||||||
|
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) {
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.multiDragContactPanel = new PanelMultiDragWorkspaceContact(owner, targetContact);
|
||||||
|
lcMiddle.add(multiDragContactPanel);
|
||||||
|
add(lcTop);
|
||||||
|
add(lcMiddle);
|
||||||
|
add(lcBottom);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PanelMultiDragWorkspaceContact getMultiDrag() {
|
||||||
|
return multiDragContactPanel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTxtHelp() {
|
||||||
|
return txtHelp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitleHelp() {
|
||||||
|
return titleHelp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ToolBar getToolBar() {
|
||||||
|
return toolBar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTxtHelp(String txtHelp) {
|
||||||
|
this.txtHelp = txtHelp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitleHelp(String titleHelp) {
|
||||||
|
this.titleHelp = titleHelp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setToolBar(ToolBar toolBar) {
|
||||||
|
this.toolBar = toolBar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LayoutContainer getLcTop() {
|
||||||
|
return lcTop;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LayoutContainer getLcMiddle() {
|
||||||
|
return lcMiddle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LayoutContainer getLcBottom() {
|
||||||
|
return lcBottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -157,6 +157,8 @@ public class DialogShareFolder extends Dialog {
|
||||||
|
|
||||||
lc.mask();
|
lc.mask();
|
||||||
|
|
||||||
|
|
||||||
|
//TODO
|
||||||
userStore.getOwner(folder.getIdentifier(), new AsyncCallback<InfoContactModel>() {
|
userStore.getOwner(folder.getIdentifier(), new AsyncCallback<InfoContactModel>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -461,53 +463,23 @@ public class DialogShareFolder extends Dialog {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(ClickEvent event) {
|
public void onClick(ClickEvent event) {
|
||||||
final MultiDragContact multiDrag = new MultiDragContact();
|
final DialogMultiDragWorkspaceContacts dialogMultiDrag = new DialogMultiDragWorkspaceContacts(shareOwner,suggestPanel.getSelectedUser());
|
||||||
multiDrag.show();
|
|
||||||
|
|
||||||
AsyncCallback<List<InfoContactModel>> callback=new AsyncCallback<List<InfoContactModel>>() {
|
dialogMultiDrag.getButtonById(Dialog.OK).addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {
|
|
||||||
GWT.log("Error retrieving contacts: "+caught,caught);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSuccess(List<InfoContactModel> result) {
|
|
||||||
GWT.log("Contact List retrieved: ");
|
|
||||||
multiDrag.addSourceContacts(result);
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
userStore.getExclusiveContactsFromAllContact(suggestPanel.getSelectedUser(),callback);
|
|
||||||
|
|
||||||
|
|
||||||
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
|
@Override
|
||||||
public void componentSelected(ButtonEvent ce) {
|
public void componentSelected(ButtonEvent ce) {
|
||||||
// initSuggestContacts();
|
// initSuggestContacts();
|
||||||
suggestPanel.resetItemSelected();
|
suggestPanel.resetItemSelected();
|
||||||
// SHARE OWNER IS NULL IN CASE OF NEW SHARE
|
|
||||||
if (shareOwner != null)
|
|
||||||
suggestPanel.addRecipient(shareOwner, false);
|
|
||||||
|
|
||||||
for (InfoContactModel infoContactModel : multiDrag.getTargetListContact()) {
|
for (InfoContactModel infoContactModel : dialogMultiDrag.getMultiDrag().getTargetListContactWithOwner()) {
|
||||||
suggestPanel.addRecipient(infoContactModel, true);
|
suggestPanel.addRecipient(infoContactModel, true);
|
||||||
}
|
}
|
||||||
suggestPanel.boxSetFocus();
|
suggestPanel.boxSetFocus();
|
||||||
// printSelectedUser();
|
// printSelectedUser();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
dialogMultiDrag.show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -534,7 +506,7 @@ public class DialogShareFolder extends Dialog {
|
||||||
* @param contact
|
* @param contact
|
||||||
* the contact
|
* the contact
|
||||||
* @return true, if successful
|
* @return true, if successful
|
||||||
*/
|
|
||||||
private boolean listAlreadySharedContains(InfoContactModel contact) {
|
private boolean listAlreadySharedContains(InfoContactModel contact) {
|
||||||
|
|
||||||
if (contact == null)
|
if (contact == null)
|
||||||
|
@ -546,7 +518,7 @@ public class DialogShareFolder extends Dialog {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
} */
|
||||||
|
|
||||||
// DEBUG
|
// DEBUG
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,651 +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.model.ExtendedInfoContactModel;
|
|
||||||
import org.gcube.portlets.user.workspace.client.resources.Resources;
|
|
||||||
import org.gcube.portlets.user.workspace.client.view.windows.MessageBoxConfirm;
|
|
||||||
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
|
|
||||||
|
|
||||||
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
|
|
||||||
import com.extjs.gxt.ui.client.Style.Orientation;
|
|
||||||
import com.extjs.gxt.ui.client.Style.Scroll;
|
|
||||||
import com.extjs.gxt.ui.client.Style.SortDir;
|
|
||||||
import com.extjs.gxt.ui.client.Style.VerticalAlignment;
|
|
||||||
import com.extjs.gxt.ui.client.dnd.GridDragSource;
|
|
||||||
import com.extjs.gxt.ui.client.dnd.GridDropTarget;
|
|
||||||
import com.extjs.gxt.ui.client.event.BaseEvent;
|
|
||||||
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
|
||||||
import com.extjs.gxt.ui.client.event.Events;
|
|
||||||
import com.extjs.gxt.ui.client.event.Listener;
|
|
||||||
import com.extjs.gxt.ui.client.event.MessageBoxEvent;
|
|
||||||
import com.extjs.gxt.ui.client.event.SelectionListener;
|
|
||||||
import com.extjs.gxt.ui.client.store.ListStore;
|
|
||||||
import com.extjs.gxt.ui.client.store.Store;
|
|
||||||
import com.extjs.gxt.ui.client.store.StoreSorter;
|
|
||||||
import com.extjs.gxt.ui.client.util.Margins;
|
|
||||||
import com.extjs.gxt.ui.client.widget.ContentPanel;
|
|
||||||
import com.extjs.gxt.ui.client.widget.Dialog;
|
|
||||||
import com.extjs.gxt.ui.client.widget.HorizontalPanel;
|
|
||||||
import com.extjs.gxt.ui.client.widget.Label;
|
|
||||||
import com.extjs.gxt.ui.client.widget.LayoutContainer;
|
|
||||||
import com.extjs.gxt.ui.client.widget.MessageBox;
|
|
||||||
import com.extjs.gxt.ui.client.widget.VerticalPanel;
|
|
||||||
import com.extjs.gxt.ui.client.widget.button.Button;
|
|
||||||
import com.extjs.gxt.ui.client.widget.form.StoreFilterField;
|
|
||||||
import com.extjs.gxt.ui.client.widget.form.TextArea;
|
|
||||||
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
|
|
||||||
import com.extjs.gxt.ui.client.widget.grid.ColumnData;
|
|
||||||
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
|
|
||||||
import com.extjs.gxt.ui.client.widget.grid.Grid;
|
|
||||||
import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer;
|
|
||||||
import com.extjs.gxt.ui.client.widget.layout.CenterLayout;
|
|
||||||
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
|
|
||||||
import com.extjs.gxt.ui.client.widget.layout.RowData;
|
|
||||||
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
|
|
||||||
import com.extjs.gxt.ui.client.widget.tips.QuickTip;
|
|
||||||
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Class MultiDragContact.
|
|
||||||
*
|
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
|
||||||
* Jun 1, 2016
|
|
||||||
*/
|
|
||||||
public class MultiDragContact extends Dialog {
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final int HEIGHT_CONTAINER_GRID = 395;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final int HEIGHT_CONTAINER_TEXT_AREA = 72;
|
|
||||||
private static final int HEIGHT_TEXT_AREA = 55;
|
|
||||||
private static final int WIDTH_CP = 597;
|
|
||||||
// private static final int HEIGHT_DIALOG = 542;
|
|
||||||
private static final int HEIGHT_DIALOG = 580;
|
|
||||||
private static final int WIDTH_DIALOG = 630;
|
|
||||||
// private static final int WIDTH_DIALOG = 625;
|
|
||||||
private static final int HEIGHT_GRID = 310;
|
|
||||||
|
|
||||||
private GridDropTarget dropSource;
|
|
||||||
private GridDropTarget dropTarget;
|
|
||||||
private ListStore<ExtendedInfoContactModel> storeSource = new ListStore<ExtendedInfoContactModel>();
|
|
||||||
private ListStore<ExtendedInfoContactModel> storeTarget = new ListStore<ExtendedInfoContactModel>();
|
|
||||||
private TextArea textAreaAlreadyShared;
|
|
||||||
private Grid<ExtendedInfoContactModel> gridAllContacts;
|
|
||||||
private Grid<ExtendedInfoContactModel> gridShareWith;
|
|
||||||
private ColumnConfig columnConfigDisplayName;
|
|
||||||
private Button buttonSelectedLeft;
|
|
||||||
private Button buttonSelectedRight;
|
|
||||||
private Button buttonAllRight;
|
|
||||||
private Button buttonAllLeft;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Instantiates a new multi drag contact.
|
|
||||||
*/
|
|
||||||
public MultiDragContact() {
|
|
||||||
setStyleAttribute("margin", "10px");
|
|
||||||
setSize(WIDTH_DIALOG, HEIGHT_DIALOG);
|
|
||||||
setHeading("Group dragging contacts");
|
|
||||||
setResizable(false);
|
|
||||||
setMaximizable(false);
|
|
||||||
setIcon(Resources.getIconUsers());
|
|
||||||
setModal(true);
|
|
||||||
setScrollMode(Scroll.AUTOY);
|
|
||||||
setBodyStyle("padding: 9px; background: none");
|
|
||||||
setResizable(true);
|
|
||||||
setButtonAlign(HorizontalAlignment.CENTER);
|
|
||||||
setButtons(Dialog.OKCANCEL);
|
|
||||||
// SORTING STORE
|
|
||||||
setGropUserStoreSorter(storeSource);
|
|
||||||
setGropUserStoreSorter(storeTarget);
|
|
||||||
|
|
||||||
ContentPanel cpAlreadyShared = new ContentPanel();
|
|
||||||
cpAlreadyShared.setSize(WIDTH_CP, HEIGHT_CONTAINER_TEXT_AREA);
|
|
||||||
cpAlreadyShared.setHeaderVisible(false);
|
|
||||||
cpAlreadyShared.setLayout(new FitLayout());
|
|
||||||
|
|
||||||
VerticalPanel vpShared = new VerticalPanel();
|
|
||||||
vpShared.setVerticalAlign(VerticalAlignment.MIDDLE);
|
|
||||||
vpShared.setHorizontalAlign(HorizontalAlignment.CENTER);
|
|
||||||
vpShared.setStyleAttribute("padding", "5px");
|
|
||||||
vpShared.setLayout(new FitLayout());
|
|
||||||
HorizontalPanel hpSharedContacts = new HorizontalPanel();
|
|
||||||
hpSharedContacts.setHorizontalAlign(HorizontalAlignment.CENTER);
|
|
||||||
hpSharedContacts.setVerticalAlign(VerticalAlignment.MIDDLE);
|
|
||||||
textAreaAlreadyShared = new TextArea();
|
|
||||||
// textField.setFieldLabel("Already shared with");
|
|
||||||
// textField.setHeight(30);
|
|
||||||
textAreaAlreadyShared.setWidth(501);
|
|
||||||
textAreaAlreadyShared.setHeight(HEIGHT_TEXT_AREA);
|
|
||||||
cpAlreadyShared.setStyleAttribute("padding-bottom", "5px");
|
|
||||||
textAreaAlreadyShared.setReadOnly(true);
|
|
||||||
cpAlreadyShared.add(textAreaAlreadyShared);
|
|
||||||
|
|
||||||
Label label = new Label("Already shared with");
|
|
||||||
label.setStyleAttribute("padding-right", "10px");
|
|
||||||
label.setStyleAttribute("font-size", "12px");
|
|
||||||
|
|
||||||
hpSharedContacts.add(label);
|
|
||||||
hpSharedContacts.add(textAreaAlreadyShared);
|
|
||||||
vpShared.add(hpSharedContacts);
|
|
||||||
cpAlreadyShared.add(vpShared);
|
|
||||||
add(cpAlreadyShared);
|
|
||||||
|
|
||||||
final ContentPanel cp = new ContentPanel();
|
|
||||||
cp.setSize(WIDTH_CP, HEIGHT_CONTAINER_GRID);
|
|
||||||
cp.setHeaderVisible(false);
|
|
||||||
cp.setLayout(new RowLayout(Orientation.HORIZONTAL));
|
|
||||||
|
|
||||||
ToolBar toolBar = new ToolBar();
|
|
||||||
Button buttonHelp = new Button();
|
|
||||||
buttonHelp.setIcon(Resources.getIconInfo());
|
|
||||||
|
|
||||||
buttonHelp.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void componentSelected(ButtonEvent ce) {
|
|
||||||
MessageBox.info("Group dragging action",
|
|
||||||
"Drag one or more contacts from the left (All Contacts) to the right (Share with) to add users in your sharing list.",
|
|
||||||
null);
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
toolBar.add(buttonHelp);
|
|
||||||
setTopComponent(toolBar);
|
|
||||||
|
|
||||||
final VerticalPanel vpAllContacts = new VerticalPanel();
|
|
||||||
vpAllContacts.setHorizontalAlign(HorizontalAlignment.CENTER);
|
|
||||||
vpAllContacts.add(new Label("All Contacts"));
|
|
||||||
|
|
||||||
gridAllContacts = new Grid<ExtendedInfoContactModel>(storeSource, createColumnModel());
|
|
||||||
|
|
||||||
GridCellRenderer<ExtendedInfoContactModel> displayNameCellRender = new GridCellRenderer<ExtendedInfoContactModel>() {
|
|
||||||
public String render(ExtendedInfoContactModel model, String property, ColumnData config, int rowIndex,
|
|
||||||
int colIndex, ListStore<ExtendedInfoContactModel> store, Grid<ExtendedInfoContactModel> grid) {
|
|
||||||
|
|
||||||
if (model != null) {
|
|
||||||
|
|
||||||
String value = model.get(property);
|
|
||||||
if (value != null) {
|
|
||||||
return "<span qtitle='' qtip='" + model.getLogin() + "'>" + value + "</span>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
columnConfigDisplayName.setRenderer(displayNameCellRender);
|
|
||||||
|
|
||||||
storeSource.setDefaultSort(InfoContactModel.FULLNAME, SortDir.ASC);
|
|
||||||
storeSource.sort(InfoContactModel.FULLNAME, SortDir.ASC);
|
|
||||||
|
|
||||||
storeTarget.setDefaultSort(InfoContactModel.FULLNAME, SortDir.ASC);
|
|
||||||
storeTarget.sort(InfoContactModel.FULLNAME, SortDir.ASC);
|
|
||||||
|
|
||||||
final StoreFilterField<ExtendedInfoContactModel> filter = new StoreFilterField<ExtendedInfoContactModel>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean doSelect(Store<ExtendedInfoContactModel> store, ExtendedInfoContactModel parent,
|
|
||||||
ExtendedInfoContactModel record, String property, String filter) {
|
|
||||||
|
|
||||||
String name = record.getName();
|
|
||||||
name = name.toLowerCase();
|
|
||||||
if (name.contains(filter.toLowerCase())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
filter.setEmptyText("Filter All Contacts");
|
|
||||||
HorizontalPanel hp = new HorizontalPanel();
|
|
||||||
hp.setStyleAttribute("padding-top", "5px");
|
|
||||||
hp.setStyleAttribute("padding-bottom", "5px");
|
|
||||||
hp.add(filter);
|
|
||||||
filter.bind(storeSource);
|
|
||||||
|
|
||||||
gridAllContacts.setHeight(HEIGHT_GRID);
|
|
||||||
gridAllContacts.setBorders(false);
|
|
||||||
gridAllContacts.getView().setAutoFill(true);
|
|
||||||
gridAllContacts.setBorders(true);
|
|
||||||
|
|
||||||
vpAllContacts.add(hp);
|
|
||||||
vpAllContacts.add(gridAllContacts);
|
|
||||||
|
|
||||||
RowData rowData = new RowData(.4, 1);
|
|
||||||
rowData.setMargins(new Margins(6));
|
|
||||||
cp.add(vpAllContacts, rowData);
|
|
||||||
|
|
||||||
rowData = new RowData(.2, 1);
|
|
||||||
rowData.setMargins(new Margins(6));
|
|
||||||
LayoutContainer lc = createMoveContactsContainer();
|
|
||||||
cp.add(lc, rowData);
|
|
||||||
|
|
||||||
rowData = new RowData(.4, 1);
|
|
||||||
rowData.setMargins(new Margins(6, 6, 6, 0));
|
|
||||||
|
|
||||||
final VerticalPanel vpShareWith = new VerticalPanel();
|
|
||||||
vpShareWith.setHorizontalAlign(HorizontalAlignment.CENTER);
|
|
||||||
vpShareWith.add(new Label("Share with..."));
|
|
||||||
gridShareWith = new Grid<ExtendedInfoContactModel>(storeTarget, createColumnModel());
|
|
||||||
|
|
||||||
final StoreFilterField<ExtendedInfoContactModel> filter2 = new StoreFilterField<ExtendedInfoContactModel>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean doSelect(Store<ExtendedInfoContactModel> store, ExtendedInfoContactModel parent,
|
|
||||||
ExtendedInfoContactModel record, String property, String filter) {
|
|
||||||
|
|
||||||
String name = record.getName();
|
|
||||||
name = name.toLowerCase();
|
|
||||||
if (name.contains(filter.toLowerCase())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
filter2.setEmptyText("Filter Share with");
|
|
||||||
|
|
||||||
hp = new HorizontalPanel();
|
|
||||||
hp.setStyleAttribute("padding-top", "5px");
|
|
||||||
hp.setStyleAttribute("padding-bottom", "5px");
|
|
||||||
hp.add(filter2);
|
|
||||||
filter2.bind(storeTarget);
|
|
||||||
|
|
||||||
gridShareWith.setHeight(HEIGHT_GRID);
|
|
||||||
gridShareWith.setBorders(false);
|
|
||||||
gridShareWith.getView().setAutoFill(true);
|
|
||||||
// gridShareWith.setAutoExpandColumn(InfoContactModel.FULLNAME);
|
|
||||||
gridShareWith.setBorders(true);
|
|
||||||
vpShareWith.add(hp);
|
|
||||||
vpShareWith.add(gridShareWith);
|
|
||||||
|
|
||||||
cp.add(vpShareWith, rowData);
|
|
||||||
|
|
||||||
new GridDragSource(gridAllContacts);
|
|
||||||
new GridDragSource(gridShareWith);
|
|
||||||
|
|
||||||
dropSource = new GridDropTarget(gridAllContacts);
|
|
||||||
dropSource.setAllowSelfAsSource(false);
|
|
||||||
|
|
||||||
dropTarget = new GridDropTarget(gridShareWith);
|
|
||||||
dropTarget.setAllowSelfAsSource(false);
|
|
||||||
|
|
||||||
add(cp);
|
|
||||||
|
|
||||||
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) {
|
|
||||||
List<ExtendedInfoContactModel> shareContacts = storeTarget.getModels();
|
|
||||||
|
|
||||||
if (shareContacts == null || shareContacts.isEmpty()) {
|
|
||||||
|
|
||||||
MessageBoxConfirm mbc = new MessageBoxConfirm("Confirm exit?",
|
|
||||||
"You have not selected any contact to share, confirm exit?");
|
|
||||||
|
|
||||||
mbc.getMessageBoxConfirm().addCallback(new Listener<MessageBoxEvent>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleEvent(MessageBoxEvent be) {
|
|
||||||
String clickedButton = be.getButtonClicked().getItemId();
|
|
||||||
if (clickedButton.equals(Dialog.YES)) {
|
|
||||||
hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else
|
|
||||||
hide();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// needed to enable quicktips (qtitle for the heading and qtip for the
|
|
||||||
// content) that are setup in the change GridCellRenderer
|
|
||||||
|
|
||||||
cp.addListener(Events.Render, new Listener<BaseEvent>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleEvent(BaseEvent be) {
|
|
||||||
int width = gridAllContacts.getWidth();
|
|
||||||
filter.setWidth(width - 2);
|
|
||||||
filter2.setWidth(width - 2);
|
|
||||||
gridShareWith.setWidth(width + 5);
|
|
||||||
vpShareWith.setWidth(width + 15);
|
|
||||||
gridAllContacts.setWidth(width + 5);
|
|
||||||
vpAllContacts.setWidth(width + 15);
|
|
||||||
vpShareWith.layout();
|
|
||||||
vpAllContacts.layout();
|
|
||||||
cp.layout();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
new QuickTip(gridAllContacts);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates the move contacts container.
|
|
||||||
*
|
|
||||||
* @return the layout container
|
|
||||||
*/
|
|
||||||
private LayoutContainer createMoveContactsContainer() {
|
|
||||||
|
|
||||||
LayoutContainer lc = new LayoutContainer();
|
|
||||||
lc.setLayout(new CenterLayout());
|
|
||||||
VerticalPanel vp1 = new VerticalPanel();
|
|
||||||
vp1.setHorizontalAlign(HorizontalAlignment.CENTER);
|
|
||||||
vp1.setVerticalAlign(VerticalAlignment.MIDDLE);
|
|
||||||
|
|
||||||
buttonSelectedLeft = new Button();
|
|
||||||
buttonSelectedLeft.setIcon(Resources.getSelectedLeft());
|
|
||||||
buttonSelectedLeft.setToolTip("Move selected contact/s from 'All Contact' to 'Share with'");
|
|
||||||
buttonSelectedLeft.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void componentSelected(ButtonEvent ce) {
|
|
||||||
|
|
||||||
List<ExtendedInfoContactModel> selectedItems = gridAllContacts.getSelectionModel().getSelectedItems();
|
|
||||||
|
|
||||||
if (selectedItems != null && selectedItems.size() > 0) {
|
|
||||||
|
|
||||||
for (ExtendedInfoContactModel extendedInfoContactModel : selectedItems) {
|
|
||||||
storeTarget.add(extendedInfoContactModel);
|
|
||||||
storeSource.remove(extendedInfoContactModel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
buttonSelectedRight = new Button();
|
|
||||||
buttonSelectedRight.setIcon(Resources.getSelectedRight());
|
|
||||||
buttonSelectedRight.setToolTip("Move selected contact/s from 'Share with' to 'All Contact'");
|
|
||||||
|
|
||||||
buttonSelectedRight.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void componentSelected(ButtonEvent ce) {
|
|
||||||
|
|
||||||
List<ExtendedInfoContactModel> selectedItems = gridShareWith.getSelectionModel().getSelectedItems();
|
|
||||||
|
|
||||||
if (selectedItems != null && selectedItems.size() > 0) {
|
|
||||||
|
|
||||||
for (ExtendedInfoContactModel extendedInfoContactModel : selectedItems) {
|
|
||||||
storeSource.add(extendedInfoContactModel);
|
|
||||||
storeTarget.remove(extendedInfoContactModel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
buttonAllLeft = new Button();
|
|
||||||
buttonAllLeft.setIcon(Resources.getAllLeft());
|
|
||||||
buttonAllLeft.setToolTip("Move all contact/s from 'All Contact' to 'Share with'");
|
|
||||||
|
|
||||||
buttonAllLeft.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void componentSelected(ButtonEvent ce) {
|
|
||||||
|
|
||||||
if (storeSource != null && storeSource.getCount() > 0) {
|
|
||||||
for (ExtendedInfoContactModel extendedInfoContactModel : storeSource.getModels()) {
|
|
||||||
storeTarget.add(extendedInfoContactModel);
|
|
||||||
storeSource.remove(extendedInfoContactModel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
buttonAllRight = new Button();
|
|
||||||
buttonAllRight.setIcon(Resources.getAllRight());
|
|
||||||
buttonAllRight.setToolTip("Move all contact/s from 'Share with' to 'All Contact'");
|
|
||||||
|
|
||||||
buttonAllRight.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void componentSelected(ButtonEvent ce) {
|
|
||||||
|
|
||||||
if (storeTarget != null && storeTarget.getCount() > 0) {
|
|
||||||
for (ExtendedInfoContactModel extendedInfoContactModel : storeTarget.getModels()) {
|
|
||||||
storeSource.add(extendedInfoContactModel);
|
|
||||||
storeTarget.remove(extendedInfoContactModel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
vp1.add(buttonSelectedLeft);
|
|
||||||
vp1.add(buttonAllLeft);
|
|
||||||
vp1.add(buttonSelectedRight);
|
|
||||||
vp1.add(buttonAllRight);
|
|
||||||
|
|
||||||
lc.add(vp1);
|
|
||||||
|
|
||||||
vp1.addListener(Events.Render, new Listener<BaseEvent>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleEvent(BaseEvent be) {
|
|
||||||
buttonSelectedLeft.el().setStyleAttribute("margin-top", "40px");
|
|
||||||
buttonAllLeft.el().setStyleAttribute("margin-top", "5px");
|
|
||||||
buttonSelectedRight.el().setStyleAttribute("margin-top", "20px");
|
|
||||||
buttonAllRight.el().setStyleAttribute("margin", "5px");
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return lc;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates the column model.
|
|
||||||
*
|
|
||||||
* @return the column model
|
|
||||||
*/
|
|
||||||
private ColumnModel createColumnModel() {
|
|
||||||
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
|
|
||||||
|
|
||||||
ColumnConfig icon = new ColumnConfig(ExtendedInfoContactModel.ICON, "", 25);
|
|
||||||
configs.add(icon);
|
|
||||||
|
|
||||||
columnConfigDisplayName = new ColumnConfig(ExtendedInfoContactModel.FULLNAME, "Name", 150);
|
|
||||||
configs.add(columnConfigDisplayName);
|
|
||||||
|
|
||||||
ColumnConfig type = new ColumnConfig(ExtendedInfoContactModel.ISGROUP, "Type", 50);
|
|
||||||
configs.add(type);
|
|
||||||
|
|
||||||
GridCellRenderer<ExtendedInfoContactModel> typeRender = new GridCellRenderer<ExtendedInfoContactModel>() {
|
|
||||||
@Override
|
|
||||||
public String render(ExtendedInfoContactModel model, String property, ColumnData config, int rowIndex,
|
|
||||||
int colIndex, ListStore<ExtendedInfoContactModel> store, Grid<ExtendedInfoContactModel> grid) {
|
|
||||||
Boolean isGroup = (Boolean) model.get(property);
|
|
||||||
String color = "#0F4FA8";
|
|
||||||
String val = "";
|
|
||||||
if (isGroup) {
|
|
||||||
val = "Group";
|
|
||||||
color = "#05316D";
|
|
||||||
return "<span style='font-weight: bold; color:" + color + "'>" + val + "</span>";
|
|
||||||
} else {
|
|
||||||
val = "User";
|
|
||||||
return "<span style='font-weight: bold; color:" + color + "'>" + val + "</span>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
type.setRenderer(typeRender);
|
|
||||||
return new ColumnModel(configs);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds the source contacts.
|
|
||||||
*
|
|
||||||
* @param listContact
|
|
||||||
* the list contact
|
|
||||||
*/
|
|
||||||
public void addSourceContacts(List<InfoContactModel> listContact) {
|
|
||||||
|
|
||||||
gridAllContacts.mask("", ConstantsExplorer.LOADINGSTYLE);
|
|
||||||
if (listContact != null && listContact.size() > 0) {
|
|
||||||
List<ExtendedInfoContactModel> listExtended = new ArrayList<ExtendedInfoContactModel>();
|
|
||||||
// SETTING ICONS
|
|
||||||
for (InfoContactModel infoContactModel : listContact) {
|
|
||||||
ExtendedInfoContactModel ext = new ExtendedInfoContactModel(infoContactModel.getId(),
|
|
||||||
infoContactModel.getLogin(), infoContactModel.getName(), infoContactModel.getEmailDomain(),
|
|
||||||
infoContactModel.isGroup());
|
|
||||||
ext.setIcon();
|
|
||||||
listExtended.add(ext);
|
|
||||||
}
|
|
||||||
|
|
||||||
storeSource.add(listExtended);
|
|
||||||
// GWT.log("Added sources: "+listExtended.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
gridAllContacts.unmask();
|
|
||||||
gridAllContacts.repaint();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds the already shared contacts.
|
|
||||||
*
|
|
||||||
* @param listContact
|
|
||||||
* the list contact
|
|
||||||
*/
|
|
||||||
public void addAlreadySharedContacts(List<InfoContactModel> listContact) {
|
|
||||||
|
|
||||||
gridShareWith.mask("", ConstantsExplorer.LOADINGSTYLE);
|
|
||||||
if (listContact != null && listContact.size() > 0) {
|
|
||||||
|
|
||||||
String alreadyShared = "";
|
|
||||||
for (int i = 0; i < listContact.size() - 1; i++)
|
|
||||||
alreadyShared += listContact.get(i).getName() + ", ";
|
|
||||||
|
|
||||||
alreadyShared += listContact.get(listContact.size() - 1).getName();
|
|
||||||
|
|
||||||
textAreaAlreadyShared.setValue(alreadyShared);
|
|
||||||
}
|
|
||||||
gridShareWith.unmask();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds the target contacts.
|
|
||||||
*
|
|
||||||
* @param listContact
|
|
||||||
* the list contact
|
|
||||||
*/
|
|
||||||
public void addTargetContacts(List<InfoContactModel> listContact) {
|
|
||||||
if (listContact != null && listContact.size() > 0) {
|
|
||||||
storeTarget.add(convertFromInfoContactModel(listContact));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert from info contact model.
|
|
||||||
*
|
|
||||||
* @param listContact
|
|
||||||
* the list contact
|
|
||||||
* @return the list
|
|
||||||
*/
|
|
||||||
private List<ExtendedInfoContactModel> convertFromInfoContactModel(List<InfoContactModel> listContact) {
|
|
||||||
|
|
||||||
if (listContact != null) {
|
|
||||||
List<ExtendedInfoContactModel> listExtended = new ArrayList<ExtendedInfoContactModel>(listContact.size());
|
|
||||||
// SETTING ICONS
|
|
||||||
for (InfoContactModel infoContactModel : listContact) {
|
|
||||||
listExtended.add(convertFromInfoContactModel(infoContactModel));
|
|
||||||
}
|
|
||||||
return listExtended;
|
|
||||||
}
|
|
||||||
return new ArrayList<ExtendedInfoContactModel>();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert from info contact model.
|
|
||||||
*
|
|
||||||
* @param infoContactModel
|
|
||||||
* the info contact model
|
|
||||||
* @return the extended info contact model
|
|
||||||
*/
|
|
||||||
private ExtendedInfoContactModel convertFromInfoContactModel(InfoContactModel infoContactModel) {
|
|
||||||
if (infoContactModel != null) {
|
|
||||||
String fullName = infoContactModel.getName();
|
|
||||||
if (fullName == null || fullName.isEmpty())
|
|
||||||
fullName = infoContactModel.getLogin();
|
|
||||||
|
|
||||||
ExtendedInfoContactModel ext = new ExtendedInfoContactModel(infoContactModel.getId(),
|
|
||||||
infoContactModel.getLogin(), fullName, infoContactModel.getEmailDomain(),
|
|
||||||
infoContactModel.isGroup());
|
|
||||||
ext.setIcon();
|
|
||||||
return ext;
|
|
||||||
}
|
|
||||||
return new ExtendedInfoContactModel();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds the target contact.
|
|
||||||
*
|
|
||||||
* @param contact
|
|
||||||
* the contact
|
|
||||||
*/
|
|
||||||
public void addTargetContact(InfoContactModel contact) {
|
|
||||||
if (contact != null)
|
|
||||||
storeTarget.add(convertFromInfoContactModel(contact));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the target list contact.
|
|
||||||
*
|
|
||||||
* @return the target list contact
|
|
||||||
*/
|
|
||||||
public List<InfoContactModel> getTargetListContact() {
|
|
||||||
|
|
||||||
List<? extends InfoContactModel> infoContacts = storeTarget.getModels();
|
|
||||||
return (List<InfoContactModel>) infoContacts;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the grop user store sorter.
|
|
||||||
*
|
|
||||||
* @param store
|
|
||||||
* the new grop user store sorter
|
|
||||||
*/
|
|
||||||
private void setGropUserStoreSorter(ListStore<ExtendedInfoContactModel> store) {
|
|
||||||
|
|
||||||
// Sorting files
|
|
||||||
store.setStoreSorter(new StoreSorter<ExtendedInfoContactModel>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compare(Store<ExtendedInfoContactModel> store, ExtendedInfoContactModel m1,
|
|
||||||
ExtendedInfoContactModel m2, String property) {
|
|
||||||
boolean m1Folder = m1.isGroup();
|
|
||||||
boolean m2Folder = m2.isGroup();
|
|
||||||
|
|
||||||
if (m1Folder && !m2Folder) {
|
|
||||||
return -1;
|
|
||||||
} else if (!m1Folder && m2Folder) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m1.getName().compareToIgnoreCase(m2.getName());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,706 @@
|
||||||
|
package org.gcube.portlets.user.workspace.client.view.sharing;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.portlets.widgets.workspacesharingwidget.client.ConstantsSharing;
|
||||||
|
import org.gcube.portlets.widgets.workspacesharingwidget.client.WorkspaceSharingController;
|
||||||
|
import org.gcube.portlets.widgets.workspacesharingwidget.client.resources.Resources;
|
||||||
|
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
|
||||||
|
import org.gcube.portlets.widgets.workspacesharingwidget.shared.UserVRE;
|
||||||
|
|
||||||
|
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
|
||||||
|
import com.extjs.gxt.ui.client.Style.Orientation;
|
||||||
|
import com.extjs.gxt.ui.client.Style.SortDir;
|
||||||
|
import com.extjs.gxt.ui.client.Style.VerticalAlignment;
|
||||||
|
import com.extjs.gxt.ui.client.dnd.GridDragSource;
|
||||||
|
import com.extjs.gxt.ui.client.dnd.GridDropTarget;
|
||||||
|
import com.extjs.gxt.ui.client.event.BaseEvent;
|
||||||
|
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
||||||
|
import com.extjs.gxt.ui.client.event.Events;
|
||||||
|
import com.extjs.gxt.ui.client.event.Listener;
|
||||||
|
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
|
||||||
|
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
|
||||||
|
import com.extjs.gxt.ui.client.event.SelectionListener;
|
||||||
|
import com.extjs.gxt.ui.client.store.ListStore;
|
||||||
|
import com.extjs.gxt.ui.client.store.Store;
|
||||||
|
import com.extjs.gxt.ui.client.store.StoreSorter;
|
||||||
|
import com.extjs.gxt.ui.client.util.Margins;
|
||||||
|
import com.extjs.gxt.ui.client.widget.ContentPanel;
|
||||||
|
import com.extjs.gxt.ui.client.widget.HorizontalPanel;
|
||||||
|
import com.extjs.gxt.ui.client.widget.Label;
|
||||||
|
import com.extjs.gxt.ui.client.widget.LayoutContainer;
|
||||||
|
import com.extjs.gxt.ui.client.widget.MessageBox;
|
||||||
|
import com.extjs.gxt.ui.client.widget.VerticalPanel;
|
||||||
|
import com.extjs.gxt.ui.client.widget.button.Button;
|
||||||
|
import com.extjs.gxt.ui.client.widget.form.ComboBox;
|
||||||
|
import com.extjs.gxt.ui.client.widget.form.StoreFilterField;
|
||||||
|
import com.extjs.gxt.ui.client.widget.form.TextArea;
|
||||||
|
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
|
||||||
|
import com.extjs.gxt.ui.client.widget.grid.ColumnData;
|
||||||
|
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
|
||||||
|
import com.extjs.gxt.ui.client.widget.grid.Grid;
|
||||||
|
import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer;
|
||||||
|
import com.extjs.gxt.ui.client.widget.layout.CenterLayout;
|
||||||
|
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
|
||||||
|
import com.extjs.gxt.ui.client.widget.layout.RowData;
|
||||||
|
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
|
||||||
|
import com.extjs.gxt.ui.client.widget.tips.QuickTip;
|
||||||
|
import com.google.gwt.core.client.GWT;
|
||||||
|
import com.google.gwt.user.client.Random;
|
||||||
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
import com.google.gwt.user.client.ui.FlexTable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa Jan 27, 2015
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class PanelMultiDragWorkspaceContact extends ContentPanel {
|
||||||
|
|
||||||
|
//
|
||||||
|
private InfoContactModel owner;
|
||||||
|
private List<InfoContactModel> targetContact;
|
||||||
|
|
||||||
|
//
|
||||||
|
private List<UserVRE> vresList;
|
||||||
|
private HashMap<UserVRE, List<InfoContactModel>> contactsMap;
|
||||||
|
//
|
||||||
|
private static final String ALL_CONTACTS = "All Contacts";
|
||||||
|
private static final String SHARE_WITH = "Share with...";
|
||||||
|
|
||||||
|
//
|
||||||
|
//private static final String LOADINGSTYLE = "x-mask-loading";
|
||||||
|
private static final int HEIGHT_ALREADY_SHARED_PANEL = 80;
|
||||||
|
private static final int WIDTH_ALREADY_SHARED_PANEL = 597;
|
||||||
|
private static final int HEIGHT_VRE_PANEL = 40;
|
||||||
|
private static final int WIDTH_VRE_PANEL = 597;
|
||||||
|
private static final int HEIGHT_CONTACTS_PANEL = 400;
|
||||||
|
private static final int WIDTH_CONTACTS_PANEL = 597;
|
||||||
|
|
||||||
|
private static final int WIDTH_ALREADY_SHARED_TEXT_AREA = 508;
|
||||||
|
private static final int HEIGHT_ALREADY_SHARED_TEXT_AREA = 68;
|
||||||
|
|
||||||
|
private static final int HEIGHT_GRID = 270;
|
||||||
|
|
||||||
|
private static final int PADDING = 5;
|
||||||
|
|
||||||
|
//
|
||||||
|
private GridDropTarget dropSource;
|
||||||
|
private GridDropTarget dropTarget;
|
||||||
|
private ListStore<InfoContactModel> storeSource = new ListStore<InfoContactModel>();
|
||||||
|
private ListStore<InfoContactModel> storeTarget = new ListStore<InfoContactModel>();
|
||||||
|
private Grid<InfoContactModel> gridAllContacts;
|
||||||
|
private Grid<InfoContactModel> gridShareWith;
|
||||||
|
|
||||||
|
private Button buttonSelectedLeft;
|
||||||
|
private Button buttonSelectedRight;
|
||||||
|
private Button buttonAllRight;
|
||||||
|
private Button buttonAllLeft;
|
||||||
|
|
||||||
|
private Label labelAllContacts;
|
||||||
|
private Label labelShareWith;
|
||||||
|
private ComboBox<UserVRE> vreListCombo;
|
||||||
|
private ListStore<UserVRE> vreListStore;
|
||||||
|
private TextArea textAreaAlreadyShared;
|
||||||
|
|
||||||
|
public PanelMultiDragWorkspaceContact(InfoContactModel owner, List<InfoContactModel> targetContact) {
|
||||||
|
super();
|
||||||
|
GWT.log("PanelMultiDragWorkspaceContact()");
|
||||||
|
this.owner = owner;
|
||||||
|
this.targetContact = targetContact;
|
||||||
|
this.contactsMap = new HashMap<>();
|
||||||
|
try {
|
||||||
|
init();
|
||||||
|
create();
|
||||||
|
setAlreadySharedContacts();
|
||||||
|
setTargetContacts();
|
||||||
|
retrieveVREs();
|
||||||
|
} catch (Throwable e) {
|
||||||
|
GWT.log("Error in MultiDragContact: " + e.getLocalizedMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
GWT.log("PanelMultiDragWorkspaceContact Init");
|
||||||
|
setHeaderVisible(false);
|
||||||
|
setBodyBorder(false);
|
||||||
|
setBorders(false);
|
||||||
|
// setStyleAttribute("margin", "10px");
|
||||||
|
setBodyStyle("padding: " + PADDING + "px; background: none");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setAlreadySharedContacts() {
|
||||||
|
GWT.log("PanelMultiDragWorkspaceContact Set Already Shared Contacts");
|
||||||
|
String alreadyShared = "";
|
||||||
|
|
||||||
|
if (targetContact != null && targetContact.size() > 0) {
|
||||||
|
if (owner != null) {
|
||||||
|
alreadyShared = owner.getName() + ", ";
|
||||||
|
if (targetContact.contains(owner)) {
|
||||||
|
targetContact.remove(owner);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i < targetContact.size() - 1; i++)
|
||||||
|
alreadyShared += targetContact.get(i).getName() + ", ";
|
||||||
|
|
||||||
|
alreadyShared += targetContact.get(targetContact.size() - 1).getName();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (owner != null) {
|
||||||
|
alreadyShared = owner.getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
textAreaAlreadyShared.setValue(alreadyShared);
|
||||||
|
GWT.log("PanelMultiDragWorkspaceContact TextArea Set");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setTargetContacts() {
|
||||||
|
GWT.log("PanelMultiDragWorkspaceContact Set Target Contacts");
|
||||||
|
|
||||||
|
if (targetContact != null && targetContact.size() > 0) {
|
||||||
|
storeTarget.removeAll();
|
||||||
|
storeTarget.add(targetContact);
|
||||||
|
storeTarget.commitChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void retrieveVREs() {
|
||||||
|
GWT.log("PanelMultiDragWorkspaceContact load VREs");
|
||||||
|
WorkspaceSharingController.rpcWorkspaceSharingService.getUserVREList(new AsyncCallback<List<UserVRE>>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
GWT.log("Error retrieving VRE for user: " + caught.getLocalizedMessage(), caught);
|
||||||
|
MessageBox.alert("Error",
|
||||||
|
ConstantsSharing.SERVER_ERROR + " retrieving VREs " + ConstantsSharing.TRY_AGAIN, null);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(List<UserVRE> result) {
|
||||||
|
try {
|
||||||
|
if (result != null && !result.isEmpty()) {
|
||||||
|
GWT.log("Get all VREs loaded from server: " + result.size());
|
||||||
|
vresList = result;
|
||||||
|
vreListStore.removeAll();
|
||||||
|
vreListStore.add(vresList);
|
||||||
|
vreListStore.commitChanges();
|
||||||
|
} else {
|
||||||
|
GWT.log("No VREs found from server");
|
||||||
|
vresList=new ArrayList<>();
|
||||||
|
MessageBox.alert("Attention", "No VREs found " + ConstantsSharing.TRY_AGAIN, null);
|
||||||
|
|
||||||
|
}
|
||||||
|
} catch (Throwable e) {
|
||||||
|
GWT.log("Error ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void create() {
|
||||||
|
GWT.log("PanelMultiDragWorkspaceContact Create Start");
|
||||||
|
// Already Shared
|
||||||
|
GWT.log("PanelMultiDragWorkspaceContact Already Shared Panel");
|
||||||
|
ContentPanel alreadySharedPanel = new ContentPanel();
|
||||||
|
alreadySharedPanel.setSize(WIDTH_ALREADY_SHARED_PANEL, HEIGHT_ALREADY_SHARED_PANEL);
|
||||||
|
alreadySharedPanel.setHeaderVisible(false);
|
||||||
|
alreadySharedPanel.setLayout(new FitLayout());
|
||||||
|
|
||||||
|
// VerticalPanel vpShared = new VerticalPanel();
|
||||||
|
// vpShared.setVerticalAlign(VerticalAlignment.MIDDLE);
|
||||||
|
// vpShared.setHorizontalAlign(HorizontalAlignment.CENTER);
|
||||||
|
// vpShared.setStyleAttribute("padding", "5px");
|
||||||
|
// vpShared.setLayout(new FitLayout());
|
||||||
|
HorizontalPanel hpSharedContacts = new HorizontalPanel();
|
||||||
|
hpSharedContacts.setHorizontalAlign(HorizontalAlignment.CENTER);
|
||||||
|
hpSharedContacts.setVerticalAlign(VerticalAlignment.MIDDLE);
|
||||||
|
textAreaAlreadyShared = new TextArea();
|
||||||
|
// textField.setFieldLabel("Already shared with");
|
||||||
|
// textField.setHeight(30);
|
||||||
|
textAreaAlreadyShared.setWidth(WIDTH_ALREADY_SHARED_TEXT_AREA);
|
||||||
|
textAreaAlreadyShared.setHeight(HEIGHT_ALREADY_SHARED_TEXT_AREA);
|
||||||
|
alreadySharedPanel.setStyleAttribute("padding-bottom", "5px");
|
||||||
|
textAreaAlreadyShared.setReadOnly(true);
|
||||||
|
alreadySharedPanel.add(textAreaAlreadyShared);
|
||||||
|
|
||||||
|
Label label = new Label("Already shared with");
|
||||||
|
label.setStyleAttribute("padding", "6px");
|
||||||
|
label.setStyleAttribute("font-size", "12px");
|
||||||
|
label.setStyleAttribute("width", "68px");
|
||||||
|
label.setStyleAttribute("display", "block");
|
||||||
|
|
||||||
|
hpSharedContacts.add(label);
|
||||||
|
hpSharedContacts.add(textAreaAlreadyShared);
|
||||||
|
// vpShared.add(hpSharedContacts);
|
||||||
|
// alreadySharedPanel.add(vpShared);
|
||||||
|
alreadySharedPanel.add(hpSharedContacts);
|
||||||
|
add(alreadySharedPanel);
|
||||||
|
|
||||||
|
//
|
||||||
|
GWT.log("PanelMultiDragWorkspaceContact Create VREPanel");
|
||||||
|
// VRE
|
||||||
|
final ContentPanel vrePanel = new ContentPanel();
|
||||||
|
vrePanel.setId("vre-panel-share-admin" + Random.nextInt());
|
||||||
|
vrePanel.setSize(WIDTH_VRE_PANEL, HEIGHT_VRE_PANEL);
|
||||||
|
vrePanel.setHeaderVisible(false);
|
||||||
|
vrePanel.setLayout(new RowLayout(Orientation.HORIZONTAL));
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
// VRE Select
|
||||||
|
vreListStore = new ListStore<UserVRE>();
|
||||||
|
|
||||||
|
vreListCombo = new ComboBox<UserVRE>();
|
||||||
|
vreListCombo.setStore(vreListStore);
|
||||||
|
vreListCombo.setDisplayField(UserVRE.GROUP_NAME);
|
||||||
|
vreListCombo.setWidth(552);
|
||||||
|
vreListCombo.setAllowBlank(false);
|
||||||
|
|
||||||
|
vreListCombo.addSelectionChangedListener(new SelectionChangedListener<UserVRE>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void selectionChanged(SelectionChangedEvent<UserVRE> selected) {
|
||||||
|
retrieveContactList(selected.getSelectedItem());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
FlexTable vreLayout = new FlexTable();
|
||||||
|
vreLayout.setCellSpacing(6);
|
||||||
|
vreLayout.setWidth("565px");
|
||||||
|
// FlexCellFormatter cellFormatter = vreLayout.getFlexCellFormatter();
|
||||||
|
Label vreLabel = new Label("VRE:");
|
||||||
|
vreLabel.setStyleAttribute("padding", "5px");
|
||||||
|
vreLayout.setWidget(0, 0, vreLabel);
|
||||||
|
vreLayout.setWidget(0, 1, vreListCombo);
|
||||||
|
vrePanel.add(vreLayout);
|
||||||
|
|
||||||
|
add(vrePanel);
|
||||||
|
|
||||||
|
//
|
||||||
|
GWT.log("PanelMultiDragWorkspaceContact Create Grids Panel");
|
||||||
|
setGropUserStoreSorter(storeSource);
|
||||||
|
setGropUserStoreSorter(storeTarget);
|
||||||
|
|
||||||
|
final ContentPanel cp = new ContentPanel();
|
||||||
|
cp.setId("All-Contacts-Share-Contacts-" + Random.nextInt());
|
||||||
|
cp.setSize(WIDTH_CONTACTS_PANEL, HEIGHT_CONTACTS_PANEL);
|
||||||
|
cp.setHeaderVisible(false);
|
||||||
|
cp.setLayout(new RowLayout(Orientation.HORIZONTAL));
|
||||||
|
|
||||||
|
final VerticalPanel vpAllContacts = new VerticalPanel();
|
||||||
|
vpAllContacts.setHorizontalAlign(HorizontalAlignment.CENTER);
|
||||||
|
|
||||||
|
labelAllContacts = new Label(ALL_CONTACTS);
|
||||||
|
vpAllContacts.add(labelAllContacts);
|
||||||
|
|
||||||
|
gridAllContacts = new Grid<InfoContactModel>(storeSource, createColumnModel());
|
||||||
|
|
||||||
|
storeSource.setDefaultSort(InfoContactModel.FULLNAME, SortDir.ASC);
|
||||||
|
storeSource.sort(InfoContactModel.FULLNAME, SortDir.ASC);
|
||||||
|
|
||||||
|
storeTarget.setDefaultSort(InfoContactModel.FULLNAME, SortDir.ASC);
|
||||||
|
storeTarget.sort(InfoContactModel.FULLNAME, SortDir.ASC);
|
||||||
|
|
||||||
|
final StoreFilterField<InfoContactModel> filter = new StoreFilterField<InfoContactModel>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean doSelect(Store<InfoContactModel> store, InfoContactModel parent, InfoContactModel record,
|
||||||
|
String property, String filter) {
|
||||||
|
|
||||||
|
String name = record.getName();
|
||||||
|
name = name.toLowerCase();
|
||||||
|
if (name.contains(filter.toLowerCase())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
filter.setEmptyText("Filter All Contacts");
|
||||||
|
HorizontalPanel hp = new HorizontalPanel();
|
||||||
|
hp.setStyleAttribute("padding-top", "5px");
|
||||||
|
hp.setStyleAttribute("padding-bottom", "5px");
|
||||||
|
hp.add(filter);
|
||||||
|
filter.bind(storeSource);
|
||||||
|
|
||||||
|
gridAllContacts.setHeight(HEIGHT_GRID);
|
||||||
|
gridAllContacts.setBorders(false);
|
||||||
|
gridAllContacts.getView().setAutoFill(true);
|
||||||
|
// gridAllContacts.setAutoExpandColumn(InfoContactModel.FULLNAME);
|
||||||
|
gridAllContacts.setBorders(true);
|
||||||
|
|
||||||
|
vpAllContacts.add(hp);
|
||||||
|
vpAllContacts.add(gridAllContacts);
|
||||||
|
|
||||||
|
RowData rowData = new RowData(.4, 1);
|
||||||
|
rowData.setMargins(new Margins(6));
|
||||||
|
cp.add(vpAllContacts, rowData);
|
||||||
|
|
||||||
|
rowData = new RowData(.2, 1);
|
||||||
|
rowData.setMargins(new Margins(6));
|
||||||
|
LayoutContainer lc = createMoveContactsContainer();
|
||||||
|
cp.add(lc, rowData);
|
||||||
|
|
||||||
|
rowData = new RowData(.4, 1);
|
||||||
|
rowData.setMargins(new Margins(6, 6, 6, 0));
|
||||||
|
|
||||||
|
final VerticalPanel vpShareWith = new VerticalPanel();
|
||||||
|
vpShareWith.setHorizontalAlign(HorizontalAlignment.CENTER);
|
||||||
|
|
||||||
|
labelShareWith = new Label(SHARE_WITH);
|
||||||
|
vpShareWith.add(labelShareWith);
|
||||||
|
|
||||||
|
gridShareWith = new Grid<InfoContactModel>(storeTarget, createColumnModel());
|
||||||
|
|
||||||
|
final StoreFilterField<InfoContactModel> filter2 = new StoreFilterField<InfoContactModel>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean doSelect(Store<InfoContactModel> store, InfoContactModel parent, InfoContactModel record,
|
||||||
|
String property, String filter) {
|
||||||
|
|
||||||
|
String name = record.getName();
|
||||||
|
name = name.toLowerCase();
|
||||||
|
if (name.contains(filter.toLowerCase())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
// filter.setFieldLabel("Filter Contacts");
|
||||||
|
// filter2.setWidth(247);
|
||||||
|
filter2.setEmptyText("Filter Share with");
|
||||||
|
|
||||||
|
hp = new HorizontalPanel();
|
||||||
|
hp.setStyleAttribute("padding-top", "5px");
|
||||||
|
hp.setStyleAttribute("padding-bottom", "5px");
|
||||||
|
hp.add(filter2);
|
||||||
|
filter2.bind(storeTarget);
|
||||||
|
|
||||||
|
gridShareWith.setHeight(HEIGHT_GRID);
|
||||||
|
gridShareWith.setBorders(false);
|
||||||
|
gridShareWith.getView().setAutoFill(true);
|
||||||
|
// gridShareWith.setAutoExpandColumn(InfoContactModel.FULLNAME);
|
||||||
|
gridShareWith.setBorders(true);
|
||||||
|
vpShareWith.add(hp);
|
||||||
|
vpShareWith.add(gridShareWith);
|
||||||
|
|
||||||
|
cp.add(vpShareWith, rowData);
|
||||||
|
|
||||||
|
new GridDragSource(gridAllContacts);
|
||||||
|
new GridDragSource(gridShareWith);
|
||||||
|
|
||||||
|
dropSource = new GridDropTarget(gridAllContacts);
|
||||||
|
dropSource.setAllowSelfAsSource(false);
|
||||||
|
|
||||||
|
dropTarget = new GridDropTarget(gridShareWith);
|
||||||
|
dropTarget.setAllowSelfAsSource(false);
|
||||||
|
|
||||||
|
add(cp);
|
||||||
|
|
||||||
|
cp.addListener(Events.Render, new Listener<BaseEvent>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleEvent(BaseEvent be) {
|
||||||
|
GWT.log("PanelMultiDragWorkspaceContact CP Render Called");
|
||||||
|
int width = gridAllContacts.getWidth();
|
||||||
|
filter.setWidth(width - 2);
|
||||||
|
filter2.setWidth(width - 2);
|
||||||
|
gridAllContacts.setWidth(width);
|
||||||
|
vpAllContacts.setWidth(width + 7);
|
||||||
|
gridShareWith.setWidth(width);
|
||||||
|
vpShareWith.setWidth(width + 10);
|
||||||
|
vpShareWith.layout();
|
||||||
|
vpAllContacts.layout();
|
||||||
|
cp.layout();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// needed to enable quicktips (qtitle for the heading and qtip for the
|
||||||
|
// content) that are setup in the change GridCellRenderer
|
||||||
|
new QuickTip(gridAllContacts);
|
||||||
|
GWT.log("PanelMultiDragWorkspaceContact view Created");
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
private void retrieveContactList(final UserVRE userVRE) {
|
||||||
|
|
||||||
|
if (!contactsMap.isEmpty() && contactsMap.containsKey(userVRE)) {
|
||||||
|
List<InfoContactModel> contacts = contactsMap.get(userVRE);
|
||||||
|
updateStoreSource(contacts);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
gridAllContacts.mask();//"", LOADINGSTYLE);
|
||||||
|
GWT.log("PanelMultiDragWorkspaceContact retrieve contacts list");
|
||||||
|
WorkspaceSharingController.rpcWorkspaceSharingService.getAllContactsByVRE(userVRE,
|
||||||
|
new AsyncCallback<List<InfoContactModel>>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable e) {
|
||||||
|
GWT.log("Error retrieving all contacts by VRE: " + e.getLocalizedMessage(), e);
|
||||||
|
MessageBox.alert("Error", ConstantsSharing.SERVER_ERROR
|
||||||
|
+ " retrieving Contacts in this VRE " + ConstantsSharing.TRY_AGAIN, null);
|
||||||
|
gridAllContacts.unmask();
|
||||||
|
gridAllContacts.repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(List<InfoContactModel> result) {
|
||||||
|
GWT.log("Contacts retrieved from server");
|
||||||
|
contactsMap.put(userVRE, result);
|
||||||
|
updateStoreSource(result);
|
||||||
|
gridAllContacts.unmask();
|
||||||
|
gridAllContacts.repaint();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateStoreSource(List<InfoContactModel> result) {
|
||||||
|
GWT.log("Update SourceStore");
|
||||||
|
storeSource.removeAll();
|
||||||
|
result.removeAll(storeTarget.getModels());
|
||||||
|
result.remove(owner);
|
||||||
|
storeSource.add(result);
|
||||||
|
storeSource.commitChanges();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private LayoutContainer createMoveContactsContainer() {
|
||||||
|
|
||||||
|
LayoutContainer lc = new LayoutContainer();
|
||||||
|
lc.setLayout(new CenterLayout());
|
||||||
|
VerticalPanel vp1 = new VerticalPanel();
|
||||||
|
vp1.setHorizontalAlign(HorizontalAlignment.CENTER);
|
||||||
|
vp1.setVerticalAlign(VerticalAlignment.MIDDLE);
|
||||||
|
|
||||||
|
buttonSelectedLeft = new Button();
|
||||||
|
buttonSelectedLeft.setIcon(Resources.getSelectedLeft());
|
||||||
|
buttonSelectedLeft.setToolTip("Move selected contact/s from 'All Contact' to 'Share with'");
|
||||||
|
buttonSelectedLeft.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void componentSelected(ButtonEvent ce) {
|
||||||
|
|
||||||
|
List<InfoContactModel> selectedItems = gridAllContacts.getSelectionModel().getSelectedItems();
|
||||||
|
|
||||||
|
if (selectedItems != null && selectedItems.size() > 0) {
|
||||||
|
|
||||||
|
for (InfoContactModel extendedInfoContactModel : selectedItems) {
|
||||||
|
storeTarget.add(extendedInfoContactModel);
|
||||||
|
storeSource.remove(extendedInfoContactModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
buttonSelectedRight = new Button();
|
||||||
|
buttonSelectedRight.setIcon(Resources.getSelectedRight());
|
||||||
|
buttonSelectedRight.setToolTip("Move selected contact/s from 'Share with' to 'All Contact'");
|
||||||
|
|
||||||
|
buttonSelectedRight.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void componentSelected(ButtonEvent ce) {
|
||||||
|
|
||||||
|
List<InfoContactModel> selectedItems = gridShareWith.getSelectionModel().getSelectedItems();
|
||||||
|
|
||||||
|
if (selectedItems != null && selectedItems.size() > 0) {
|
||||||
|
|
||||||
|
for (InfoContactModel extendedInfoContactModel : selectedItems) {
|
||||||
|
storeSource.add(extendedInfoContactModel);
|
||||||
|
storeTarget.remove(extendedInfoContactModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
buttonAllLeft = new Button();
|
||||||
|
buttonAllLeft.setIcon(Resources.getAllLeft());
|
||||||
|
buttonAllLeft.setToolTip("Move all contact/s from 'All Contact' to 'Share with'");
|
||||||
|
|
||||||
|
buttonAllLeft.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void componentSelected(ButtonEvent ce) {
|
||||||
|
|
||||||
|
if (storeSource != null && storeSource.getCount() > 0) {
|
||||||
|
for (InfoContactModel extendedInfoContactModel : storeSource.getModels()) {
|
||||||
|
storeTarget.add(extendedInfoContactModel);
|
||||||
|
storeSource.remove(extendedInfoContactModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
buttonAllRight = new Button();
|
||||||
|
buttonAllRight.setIcon(Resources.getAllRight());
|
||||||
|
buttonAllRight.setToolTip("Move all contact/s from 'Share with' to 'All Contact'");
|
||||||
|
|
||||||
|
buttonAllRight.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void componentSelected(ButtonEvent ce) {
|
||||||
|
|
||||||
|
if (storeTarget != null && storeTarget.getCount() > 0) {
|
||||||
|
for (InfoContactModel extendedInfoContactModel : storeTarget.getModels()) {
|
||||||
|
storeSource.add(extendedInfoContactModel);
|
||||||
|
storeTarget.remove(extendedInfoContactModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
vp1.add(buttonSelectedLeft);
|
||||||
|
vp1.add(buttonAllLeft);
|
||||||
|
vp1.add(buttonSelectedRight);
|
||||||
|
vp1.add(buttonAllRight);
|
||||||
|
|
||||||
|
lc.add(vp1);
|
||||||
|
|
||||||
|
vp1.addListener(Events.Render, new Listener<BaseEvent>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleEvent(BaseEvent be) {
|
||||||
|
buttonSelectedLeft.el().setStyleAttribute("margin-top", "40px");
|
||||||
|
buttonAllLeft.el().setStyleAttribute("margin-top", "5px");
|
||||||
|
buttonSelectedRight.el().setStyleAttribute("margin-top", "20px");
|
||||||
|
buttonAllRight.el().setStyleAttribute("margin", "5px");
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return lc;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ColumnModel createColumnModel() {
|
||||||
|
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
|
||||||
|
|
||||||
|
ColumnConfig icon = new ColumnConfig("Icon", "", 25);
|
||||||
|
configs.add(icon);
|
||||||
|
|
||||||
|
ColumnConfig columnConfigDisplayName = new ColumnConfig(InfoContactModel.FULLNAME, "Name", 150);
|
||||||
|
configs.add(columnConfigDisplayName);
|
||||||
|
|
||||||
|
ColumnConfig type = new ColumnConfig(InfoContactModel.ISGROUP, "Type", 50);
|
||||||
|
configs.add(type);
|
||||||
|
|
||||||
|
GridCellRenderer<InfoContactModel> iconRender = new GridCellRenderer<InfoContactModel>() {
|
||||||
|
@Override
|
||||||
|
public String render(InfoContactModel model, String property, ColumnData config, int rowIndex, int colIndex,
|
||||||
|
ListStore<InfoContactModel> store, Grid<InfoContactModel> grid) {
|
||||||
|
if (model.isGroup()) {
|
||||||
|
return Resources.getIconGroup().getHTML();
|
||||||
|
} else {
|
||||||
|
return Resources.getIconUser().getHTML();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
icon.setRenderer(iconRender);
|
||||||
|
|
||||||
|
GridCellRenderer<InfoContactModel> displayNameCellRender = new GridCellRenderer<InfoContactModel>() {
|
||||||
|
public String render(InfoContactModel model, String property, ColumnData config, int rowIndex, int colIndex,
|
||||||
|
ListStore<InfoContactModel> store, Grid<InfoContactModel> grid) {
|
||||||
|
|
||||||
|
if (model != null) {
|
||||||
|
|
||||||
|
String value = model.get(property);
|
||||||
|
if (value != null) {
|
||||||
|
return "<span qtitle='' qtip='" + model.getLogin() + "'>" + value + "</span>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
columnConfigDisplayName.setRenderer(displayNameCellRender);
|
||||||
|
|
||||||
|
GridCellRenderer<InfoContactModel> typeRender = new GridCellRenderer<InfoContactModel>() {
|
||||||
|
@Override
|
||||||
|
public String render(InfoContactModel model, String property, ColumnData config, int rowIndex, int colIndex,
|
||||||
|
ListStore<InfoContactModel> store, Grid<InfoContactModel> grid) {
|
||||||
|
Boolean isGroup = (Boolean) model.get(property);
|
||||||
|
String color = "#0F4FA8";
|
||||||
|
String val = "";
|
||||||
|
if (isGroup) {
|
||||||
|
val = "Group";
|
||||||
|
color = "#05316D";
|
||||||
|
return "<span style='font-weight: bold; color:" + color + "'>" + val + "</span>";
|
||||||
|
} else {
|
||||||
|
val = "User";
|
||||||
|
return "<span style='font-weight: bold; color:" + color + "'>" + val + "</span>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
type.setRenderer(typeRender);
|
||||||
|
return new ColumnModel(configs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<InfoContactModel> getTargetListContactWithOwner() {
|
||||||
|
List<InfoContactModel> target = new ArrayList<>();
|
||||||
|
target.addAll(storeTarget.getModels());
|
||||||
|
target.add(owner);
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setGropUserStoreSorter(ListStore<InfoContactModel> store) {
|
||||||
|
|
||||||
|
// Sorting files
|
||||||
|
store.setStoreSorter(new StoreSorter<InfoContactModel>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compare(Store<InfoContactModel> store, InfoContactModel m1, InfoContactModel m2,
|
||||||
|
String property) {
|
||||||
|
boolean m1Group = m1.isGroup();
|
||||||
|
boolean m2Group = m2.isGroup();
|
||||||
|
|
||||||
|
if (m1Group && !m2Group) {
|
||||||
|
return -1;
|
||||||
|
} else if (!m1Group && m2Group) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return m1.getName().compareToIgnoreCase(m2.getName());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLeftListContactsTitle(String leftListContactsTitle) {
|
||||||
|
if (leftListContactsTitle == null)
|
||||||
|
labelAllContacts.setText(ALL_CONTACTS);
|
||||||
|
else
|
||||||
|
labelAllContacts.setText(leftListContactsTitle);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRightListContactsTitle(String rightListContactsTitle) {
|
||||||
|
|
||||||
|
if (rightListContactsTitle == null)
|
||||||
|
labelShareWith.setText(SHARE_WITH);
|
||||||
|
else
|
||||||
|
labelShareWith.setText(rightListContactsTitle);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLeftListContactsTitle() {
|
||||||
|
return labelAllContacts.getText();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRightListContactsTitle() {
|
||||||
|
return labelShareWith.getText();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue