updated sharing window with already shared contacts

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@76889 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2013-06-07 15:32:53 +00:00
parent 6536e60e3e
commit 2aaff0b61b
2 changed files with 82 additions and 3 deletions

View File

@ -295,6 +295,8 @@ public class DialogShareFolder extends Dialog {
multiDrag.addTargetContact(infoContactModel);
}
multiDrag.addAlreadySharedContacts(suggestPanel.getSelectedUser());
// multiDrag.addTargetContacts(suggestPanel.getSelectedUser());
multiDrag.show();
@ -309,6 +311,12 @@ public class DialogShareFolder extends Dialog {
suggestPanel.addRecipient(infoContactModel.getName(),true);
}
// for (InfoContactModel infoContactModel : multiDrag.getTargetListContact()) {
//
// if(!listAlreadySharedContains(infoContactModel))
// suggestPanel.addRecipient(infoContactModel.getName(),true);
// }
suggestPanel.boxSetFocus();
// printSelectedUser();
@ -318,6 +326,24 @@ public class DialogShareFolder extends Dialog {
});
}
private boolean listAlreadySharedContains(InfoContactModel contact){
if(contact==null)
return false;
for (InfoContactModel ct : listAlreadyShared) {
if(ct.getLogin().compareTo(contact.getLogin())==0){
return true;
}
}
return false;
}
//DEBUG
private void printSelectedUser(){

View File

@ -9,6 +9,7 @@ import org.gcube.portlets.user.workspace.client.resources.Resources;
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.VerticalAlignment;
import com.extjs.gxt.ui.client.dnd.GridDragSource;
import com.extjs.gxt.ui.client.dnd.GridDropTarget;
import com.extjs.gxt.ui.client.event.ButtonEvent;
@ -17,13 +18,16 @@ import com.extjs.gxt.ui.client.store.ListStore;
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.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.TextArea;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
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.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.toolbar.ToolBar;
@ -34,10 +38,11 @@ public class MultiDragContact extends Dialog {
private GridDropTarget dropTarget;
private ListStore<InfoContactModel> storeSource = new ListStore<InfoContactModel>();
private ListStore<InfoContactModel> storeTarget = new ListStore<InfoContactModel>();
private TextArea textAreaAlreadyShared;
public MultiDragContact() {
setStyleAttribute("margin", "10px");
setSize(563, 452);
setSize(563, 502);
setHeading("Group dragging contacts");
setIcon(Resources.getIconUsers());
setModal(true);
@ -47,6 +52,39 @@ public class MultiDragContact extends Dialog {
setButtonAlign(HorizontalAlignment.CENTER);
setButtons(Dialog.OKCANCEL);
ContentPanel cpAlreadyShared = new ContentPanel();
cpAlreadyShared.setSize(530, 50);
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(401);
textAreaAlreadyShared.setHeight(33);
cpAlreadyShared.setStyleAttribute("padding-bottom", "5px");
textAreaAlreadyShared.setReadOnly(true);
cpAlreadyShared.add(textAreaAlreadyShared);
Label label = new Label("Already shared with");
label.setStyleAttribute("padding-right", "10px");
hpSharedContacts.add(label);
hpSharedContacts.add(textAreaAlreadyShared);
vpShared.add(hpSharedContacts);
cpAlreadyShared.add(vpShared);
add(cpAlreadyShared);
ContentPanel cp = new ContentPanel();
cp.setSize(530, 340);
cp.setHeaderVisible(false);
@ -60,7 +98,7 @@ public class MultiDragContact extends Dialog {
@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 contacts) to add users in your sharing list.", null);
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);
}
});
@ -85,7 +123,7 @@ public class MultiDragContact extends Dialog {
vp = new VerticalPanel();
vp.setHorizontalAlign(HorizontalAlignment.CENTER);
vp.add(new Label("Share with contacts..."));
vp.add(new Label("Share with..."));
Grid<InfoContactModel> grid2 = new Grid<InfoContactModel>(storeTarget, createColumnModel());
grid2.setSize(250, 300);
grid2.setBorders(false);
@ -150,6 +188,21 @@ public class MultiDragContact extends Dialog {
storeSource.add(listContact);
}
public void addAlreadySharedContacts(List<InfoContactModel> listContact){
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);
}
}
public void addTargetContacts(List<InfoContactModel> listContact){
if(listContact!=null && listContact.size()>0)
storeTarget.add(listContact);