enhancements on "Simple Multi Drag Worksapce Contacts"

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-sharing-widget@100133 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2014-09-23 14:16:11 +00:00
parent c4c1cd5623
commit 5287af25b5
4 changed files with 138 additions and 12 deletions

View File

@ -0,0 +1,21 @@
/**
*
*/
package org.gcube.portlets.widgets.workspacesharingwidget.client;
/**
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* @Sep 22, 2014
*
* Defines customizable labels used by Simple MultiDrag Contant Dialog
*
* Sets following parameters to display custom labels into Dialog
*/
public abstract class SimpleMultiDragConstants {
public static String HEADING_DIALOG = "Group dragging contacts";
public static String ALL_CONTACTS_LEFT_LIST = "All Contacts";
public static String SHARE_WITH_RIGHT_LIST = "Share with...";
}

View File

@ -11,22 +11,23 @@ import org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.Use
import org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.multisuggest.MultiDragContact;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
import com.extjs.gxt.ui.client.widget.Dialog;
import com.extjs.gxt.ui.client.widget.MessageBox;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
/**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* @Jul 30, 2014
*
* A simple multi drag dialog to manage users (shared or administrators) of a workspace item
*/
public class SimpleMultiDragContact {
public class SimpleMultiDragWorkspaceContact {
private UserStore userStore = new UserStore();
private LOAD_CONTACTS_AS loadContactAs;
public static enum LOAD_CONTACTS_AS{SHARED_USER, ADMINISTRATOR}
private MultiDragContact multiDragContact = new MultiDragContact(false, false);
private MultiDragContact multiDragContact = new MultiDragContact(SimpleMultiDragConstants.HEADING_DIALOG, SimpleMultiDragConstants.ALL_CONTACTS_LEFT_LIST, SimpleMultiDragConstants.SHARE_WITH_RIGHT_LIST,false, false);
private List<InfoContactModel> targets = new ArrayList<InfoContactModel>();
private boolean readGroupsFromPortal;
private boolean readGroupsFromHL;
@ -36,14 +37,17 @@ public class SimpleMultiDragContact {
private InfoContactModel myContact;
/**
* Load administrators or shared users as contacts
* Load administrators or shared users to workspace item id
* @param load
* if LOAD_CONTACTS_AS.SHARED_USER loads target users from Shared Users
* if LOAD_CONTACTS_AS.ADMINISTRATOR loads target users from Administrators
*
* @param workspaceItemId
* @param readGroupsFromHL
* @param readGroupsFromPortal
* @param hiddenMySelf if true the login read from ASL is hidden (so it's not removable to target users), the login returned anyway among the target users
*/
public SimpleMultiDragContact(LOAD_CONTACTS_AS load, String workspaceItemId, final boolean readGroupsFromHL, final boolean readGroupsFromPortal, final boolean hiddenMySelf) {
public SimpleMultiDragWorkspaceContact(LOAD_CONTACTS_AS load, String workspaceItemId, final boolean readGroupsFromHL, final boolean readGroupsFromPortal, final boolean hiddenMySelf) {
this.loadContactAs = load;
this.readGroupsFromHL = readGroupsFromHL;
this.readGroupsFromPortal = readGroupsFromPortal;
@ -129,9 +133,22 @@ public class SimpleMultiDragContact {
});
break;
default:
loadAllContacts(readGroupsFromHL, readGroupsFromPortal);
break;
}
}
public void addTargetContact(List<InfoContactModel> listContacts){
if(listContacts!=null){
for (InfoContactModel infoContactModel : listContacts) {
multiDragContact.addTargetContact(infoContactModel);
}
}
}
/**
*
* @param result
@ -183,7 +200,29 @@ public class SimpleMultiDragContact {
}
};
public MultiDragContact getMultiDragContact() {
public Dialog getMultiDragContact() {
return multiDragContact;
}
public void show(){
multiDragContact.show();
}
/**
*
* @return
*/
public List<InfoContactModel> getTargetContacts() {
return multiDragContact.getTargetListContact();
}
/**
*
* @return
*/
public List<InfoContactModel> getTargetContactsWithMyLogin() {
List<InfoContactModel> contacts = getTargetContacts();
contacts.add(myContact);
return contacts;
}
}

View File

@ -1,6 +1,6 @@
package org.gcube.portlets.widgets.workspacesharingwidget.client;
import org.gcube.portlets.widgets.workspacesharingwidget.client.SimpleMultiDragContact.LOAD_CONTACTS_AS;
import org.gcube.portlets.widgets.workspacesharingwidget.client.SimpleMultiDragWorkspaceContact.LOAD_CONTACTS_AS;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.dom.client.ClickEvent;
@ -92,7 +92,7 @@ public class WorkspaceSharingWidgetEntryPoint implements EntryPoint {
private void showSimpleMultiDrag(){
final SimpleMultiDragContact multiDragContact = new SimpleMultiDragContact(LOAD_CONTACTS_AS.SHARED_USER, ITEMID, true, false, true);
final SimpleMultiDragWorkspaceContact multiDragContact = new SimpleMultiDragWorkspaceContact(LOAD_CONTACTS_AS.SHARED_USER, ITEMID, true, false, true);
Button openSharingWindow = new Button("Show Simple Multi Drag",
new ClickHandler() {

View File

@ -47,6 +47,10 @@ import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
public class MultiDragContact extends Dialog {
private static final String GROUP_DRAGGING_CONTACTS = "Group dragging contacts";
private static final String ALL_CONTACTS = "All Contacts";
private static final String SHARE_WITH = "Share with...";
private static final int WIDTH_CP = 597;
private static final int HEIGHT_DIALOG = 542;
private static final int WIDTH_DIALOG = 625;
@ -65,17 +69,33 @@ public class MultiDragContact extends Dialog {
private Button buttonAllRight;
private Button buttonAllLeft;
private boolean hideOnPressOkButton;
private String headTitle;
private String leftListContactsTitle;
private String rightListContactsTitle;
private Label allContacts;
private Label shareWith;
public MultiDragContact(String headTitle, String leftListContactsTitle, String rightListContactsTitle, boolean visibleAlreadyShared, boolean hideOnPressOk) {
this(visibleAlreadyShared, hideOnPressOk);
setHeadTitle(headTitle);
setLeftListContactsTitle(leftListContactsTitle);
setRightListContactsTitle(rightListContactsTitle);
}
/**
*
* @param headTitle
* @param leftListContactsTitle
* @param rightListContactsTitle
* @param visibleAlreadyShared
* @param hideOnPressOk
*/
public MultiDragContact(boolean visibleAlreadyShared, boolean hideOnPressOk) {
this.hideOnPressOkButton = hideOnPressOk;
setStyleAttribute("margin", "10px");
setSize(WIDTH_DIALOG, HEIGHT_DIALOG);
setHeading("Group dragging contacts");
setResizable(false);
setMaximizable(false);
setIcon(Resources.getIconUsers());
@ -151,7 +171,10 @@ public class MultiDragContact extends Dialog {
final VerticalPanel vpAllContacts = new VerticalPanel();
vpAllContacts.setHorizontalAlign(HorizontalAlignment.CENTER);
vpAllContacts.add(new Label("All Contacts"));
allContacts = new Label(ALL_CONTACTS);
vpAllContacts.add(allContacts);
gridAllContacts = new Grid<InfoContactModel>(storeSource,
createColumnModel());
@ -210,7 +233,10 @@ public class MultiDragContact extends Dialog {
final VerticalPanel vpShareWith = new VerticalPanel();
vpShareWith.setHorizontalAlign(HorizontalAlignment.CENTER);
vpShareWith.add(new Label("Share with..."));
shareWith = new Label(SHARE_WITH);
vpShareWith.add(shareWith);
gridShareWith = new Grid<InfoContactModel>(storeTarget,createColumnModel());
final StoreFilterField<InfoContactModel> filter2 = new StoreFilterField<InfoContactModel>() {
@ -589,4 +615,44 @@ public class MultiDragContact extends Dialog {
}
});
}
public void setHeadTitle(String headTitle){
this.headTitle = headTitle;
if(headTitle==null)
this.setHeading(GROUP_DRAGGING_CONTACTS);
else
this.setHeading(headTitle);
}
public void setLeftListContactsTitle(String leftListContactsTitle) {
this.leftListContactsTitle = leftListContactsTitle;
if(leftListContactsTitle==null)
allContacts.setText(ALL_CONTACTS);
else
allContacts.setText(leftListContactsTitle);
}
public void setRightListContactsTitle(String rightListContactsTitle) {
this.rightListContactsTitle = rightListContactsTitle;
if(rightListContactsTitle==null)
shareWith.setText(SHARE_WITH);
else
shareWith.setText(rightListContactsTitle);
}
public String getLeftListContactsTitle() {
return leftListContactsTitle;
}
public String getHeadTitle() {
return headTitle;
}
public String getRightListContactsTitle() {
return rightListContactsTitle;
}
}