2013-02-06 15:40:17 +01:00
|
|
|
package org.gcube.portlets.user.workspace.client.view.sharing;
|
|
|
|
|
2013-02-25 19:03:53 +01:00
|
|
|
import java.util.ArrayList;
|
2013-02-06 15:40:17 +01:00
|
|
|
import java.util.List;
|
|
|
|
|
2014-02-11 16:41:56 +01:00
|
|
|
import org.gcube.portlets.user.workspace.client.AppControllerExplorer;
|
2013-02-06 15:40:17 +01:00
|
|
|
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
2013-02-12 16:02:00 +01:00
|
|
|
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
2013-02-06 15:40:17 +01:00
|
|
|
import org.gcube.portlets.user.workspace.client.model.InfoContactModel;
|
|
|
|
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;
|
2014-02-11 16:41:56 +01:00
|
|
|
import org.gcube.portlets.user.workspace.shared.WorkspaceACL;
|
2013-02-06 15:40:17 +01:00
|
|
|
|
|
|
|
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
|
|
|
|
import com.extjs.gxt.ui.client.Style.Scroll;
|
|
|
|
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.form.TextArea;
|
|
|
|
import com.extjs.gxt.ui.client.widget.form.TextField;
|
|
|
|
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
|
2014-02-12 12:49:07 +01:00
|
|
|
import com.google.gwt.core.shared.GWT;
|
2013-02-06 15:40:17 +01:00
|
|
|
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;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public class DialogShareFolder extends Dialog {
|
|
|
|
|
|
|
|
private int widthDialog = 530;
|
|
|
|
private int heightTextArea = 100;
|
|
|
|
private TextField<String> txtName;
|
|
|
|
private TextArea textAreaDescription = new TextArea();
|
2013-02-12 16:02:00 +01:00
|
|
|
private FileModel parentFolder = null;
|
2013-02-06 15:40:17 +01:00
|
|
|
private UserStore userStore = new UserStore();
|
|
|
|
private MultiValuePanel suggestPanel = new MultiValuePanel(userStore);
|
|
|
|
private Button buttonMultiDrag = new Button("Choose Contacts");
|
2013-02-25 19:03:53 +01:00
|
|
|
private TextField<String> txtOwner;
|
2014-02-11 16:41:56 +01:00
|
|
|
private PanelPermission permission;
|
2013-02-25 19:03:53 +01:00
|
|
|
|
|
|
|
private List<InfoContactModel> listAlreadyShared = new ArrayList<InfoContactModel>(){
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Compare Login
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public boolean contains(Object o) {
|
|
|
|
|
|
|
|
if(o==null)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
InfoContactModel contact = (InfoContactModel) o;
|
|
|
|
|
|
|
|
for (int i = 0; i < listAlreadyShared.size(); i++){
|
2013-03-11 19:06:56 +01:00
|
|
|
if (contact.getName().compareTo(listAlreadyShared.get(i).getName())==0)
|
2013-02-25 19:03:53 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
};
|
2013-02-06 15:40:17 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Use to modify a shared folder or share an existing folder
|
|
|
|
* @param folder
|
|
|
|
* @param type
|
|
|
|
*/
|
2013-02-12 16:02:00 +01:00
|
|
|
public DialogShareFolder(String folderParentName, FileModel folder, HandlerManager eventBus) {
|
2013-02-06 15:40:17 +01:00
|
|
|
initLayout(folderParentName);
|
2013-02-12 16:02:00 +01:00
|
|
|
this.parentFolder = folder;
|
2013-02-06 15:40:17 +01:00
|
|
|
this.setIcon(Resources.getIconShareFolder());
|
|
|
|
|
|
|
|
setWidth(widthDialog);
|
|
|
|
setButtons(Dialog.OKCANCEL);
|
|
|
|
|
|
|
|
setHeading("Share folder: "+folder.getName());
|
|
|
|
|
|
|
|
txtName = new TextField<String>();
|
|
|
|
txtName.setAllowBlank(false);
|
|
|
|
txtName.setValue(folder.getName());
|
|
|
|
txtName.setReadOnly(true);
|
|
|
|
txtName.setAutoValidate(true);
|
|
|
|
txtName.setFieldLabel("Folder Name");
|
2013-02-25 19:03:53 +01:00
|
|
|
|
|
|
|
txtOwner = new TextField<String>();
|
|
|
|
txtOwner.setAllowBlank(true);
|
|
|
|
txtOwner.setValue("");
|
|
|
|
txtOwner.setReadOnly(true);
|
|
|
|
txtOwner.setAutoValidate(false);
|
|
|
|
txtOwner.setFieldLabel("Owner");
|
2013-02-06 15:40:17 +01:00
|
|
|
|
|
|
|
textAreaDescription.setFieldLabel(ConstantsExplorer.DIALOG_DESCRIPTION);
|
|
|
|
textAreaDescription.setHeight(heightTextArea);
|
|
|
|
textAreaDescription.setWidth(380);
|
2013-06-04 14:38:21 +02:00
|
|
|
|
|
|
|
//TODO REMOVE
|
|
|
|
// System.out.println("folder description: "+folder.getDescription());
|
|
|
|
|
2013-02-25 19:03:53 +01:00
|
|
|
textAreaDescription.setValue(folder.getDescription());
|
2013-05-29 14:09:11 +02:00
|
|
|
// textAreaDescription.setReadOnly(true);
|
2013-02-06 15:40:17 +01:00
|
|
|
|
|
|
|
final LayoutContainer lc = new LayoutContainer();
|
|
|
|
lc.setStyleAttribute("margin-top", "10px");
|
|
|
|
lc.setStyleAttribute("margin-bottom", "10px");
|
|
|
|
lc.setSize(480, 50);
|
|
|
|
|
2014-02-11 16:41:56 +01:00
|
|
|
final FlexTable flexTable = new FlexTable();
|
2013-02-06 15:40:17 +01:00
|
|
|
flexTable.setStyleName("userssuggest");
|
|
|
|
Label labelShareWith = new Label("Share with users");
|
|
|
|
flexTable.setWidget(0, 0, labelShareWith);
|
|
|
|
flexTable.setWidget(0, 1, suggestPanel);
|
|
|
|
|
|
|
|
buttonMultiDrag.setStyleName("wizardButton");
|
|
|
|
|
|
|
|
// buttonMultiDrag.setIcon(Resources.getIconUsers());
|
2013-02-27 19:17:22 +01:00
|
|
|
flexTable.setWidget(1, 0, new Label("Add more"));
|
2013-02-06 15:40:17 +01:00
|
|
|
flexTable.setWidget(1, 1, buttonMultiDrag);
|
|
|
|
|
|
|
|
Label labelDescription = new Label("Description");
|
|
|
|
flexTable.setWidget(2, 0, labelDescription);
|
|
|
|
flexTable.setWidget(2, 1, textAreaDescription);
|
|
|
|
|
2013-02-25 19:03:53 +01:00
|
|
|
|
2014-02-11 12:53:10 +01:00
|
|
|
if(!folder.isShared()){ //SETTABLE PERMISSION ONLY IF FOLDER IS NOT ALREADY SHARED
|
2014-02-11 16:41:56 +01:00
|
|
|
Label labelProperty = new Label("Permissions");
|
|
|
|
// final ToggleButton togglePermission = new ToggleButton("Set Permissions");
|
2014-02-11 12:53:10 +01:00
|
|
|
flexTable.setWidget(3, 0, labelProperty);
|
2014-02-11 16:41:56 +01:00
|
|
|
|
|
|
|
flexTable.setWidget(3, 1, Resources.getIconLoading().createImage());
|
|
|
|
|
|
|
|
AppControllerExplorer.rpcWorkspaceService.getACLs(new AsyncCallback<List<WorkspaceACL>>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSuccess(List<WorkspaceACL> result) {
|
|
|
|
permission = new PanelPermission(result);
|
|
|
|
flexTable.setWidget(3, 1, permission);
|
|
|
|
lc.layout();
|
|
|
|
}
|
|
|
|
|
2014-02-11 12:53:10 +01:00
|
|
|
@Override
|
2014-02-11 16:41:56 +01:00
|
|
|
public void onFailure(Throwable caught) {
|
2014-02-11 12:53:10 +01:00
|
|
|
|
2014-02-11 16:41:56 +01:00
|
|
|
flexTable.setWidget(3, 1, new Label("Error on recovering ACLs"));
|
2014-02-11 12:53:10 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
lc.add(flexTable);
|
|
|
|
|
|
|
|
lc.mask();
|
|
|
|
userStore.getListSharedUserByFolderId(folder.getIdentifier(), new AsyncCallback<List<InfoContactModel>>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSuccess(List<InfoContactModel> result) {
|
2013-02-08 17:31:14 +01:00
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
for (InfoContactModel infoContactModel : result) {
|
2014-02-12 12:49:07 +01:00
|
|
|
if(infoContactModel.getName()!=null){
|
|
|
|
listAlreadyShared.add(infoContactModel);
|
|
|
|
suggestPanel.addRecipient(infoContactModel.getName(),false);
|
|
|
|
}
|
2013-02-06 15:40:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
lc.unmask();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
lc.unmask();
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
2013-02-25 19:03:53 +01:00
|
|
|
|
|
|
|
|
|
|
|
userStore.getOwner(folder.getIdentifier(), new AsyncCallback<InfoContactModel>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFailure(Throwable caught) {
|
2014-02-12 12:49:07 +01:00
|
|
|
txtOwner.setValue("Error on retrieving Owner");
|
2013-02-25 19:03:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSuccess(InfoContactModel result) {
|
2013-03-11 19:06:56 +01:00
|
|
|
txtOwner.setValue(result.getName());
|
2014-02-12 12:49:07 +01:00
|
|
|
permissionControl(result.getName(), true);
|
2013-02-25 19:03:53 +01:00
|
|
|
}
|
|
|
|
});
|
2013-02-06 15:40:17 +01:00
|
|
|
|
2013-02-08 17:31:14 +01:00
|
|
|
setFocusWidget(suggestPanel.getBox());
|
2013-02-06 15:40:17 +01:00
|
|
|
add(txtName);
|
2013-02-25 19:03:53 +01:00
|
|
|
add(txtOwner);
|
2013-02-06 15:40:17 +01:00
|
|
|
add(lc);
|
|
|
|
addListners();
|
2014-02-12 12:49:07 +01:00
|
|
|
enableFormDialog(false); //FORM IS DISABLED BY DEFAULT
|
2013-02-06 15:40:17 +01:00
|
|
|
|
|
|
|
this.show();
|
|
|
|
}
|
|
|
|
|
2014-02-12 12:49:07 +01:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void enableFormDialog(boolean bool){
|
|
|
|
getButtonById(Dialog.OK).setEnabled(bool);
|
|
|
|
buttonMultiDrag.setEnabled(bool);
|
|
|
|
textAreaDescription.setEnabled(bool);
|
|
|
|
if(permission!=null)
|
|
|
|
permission.setEnabled(bool);
|
|
|
|
|
|
|
|
// setEnabled(bool);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-02-12 16:02:00 +01:00
|
|
|
public FileModel getParentFolder() {
|
|
|
|
return parentFolder;
|
2013-02-06 15:40:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2014-02-11 16:41:56 +01:00
|
|
|
setHeight(397);
|
2013-02-06 15:40:17 +01:00
|
|
|
setResizable(true);
|
|
|
|
setButtonAlign(HorizontalAlignment.CENTER);
|
|
|
|
setWidth(widthDialog);
|
|
|
|
setButtons(Dialog.OKCANCEL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Use to create a new shared folder
|
|
|
|
*/
|
|
|
|
public DialogShareFolder(String folderParentName, HandlerManager eventBus) {
|
|
|
|
|
|
|
|
initLayout(folderParentName);
|
|
|
|
this.setIcon(Resources.getIconSharedFolder());
|
|
|
|
setHeading("Create a new shared folder in: "+folderParentName);
|
2014-02-11 16:41:56 +01:00
|
|
|
setHeight(375);
|
2013-02-06 15:40:17 +01:00
|
|
|
setWidth(widthDialog);
|
|
|
|
setButtons(Dialog.OKCANCEL);
|
|
|
|
|
|
|
|
txtName = new TextField<String>();
|
|
|
|
txtName.setAllowBlank(false);
|
|
|
|
txtName.setAutoValidate(true);
|
|
|
|
txtName.setFieldLabel("Folder Name");
|
2013-11-27 14:34:43 +01:00
|
|
|
txtName.getMessages().setRegexText(ConstantsExplorer.REGEX_FOLDER_NAME+": .<>\\|?/*%$ or contains / or \\");
|
|
|
|
txtName.setRegex("^[^.<>\\|?/*%$]+[^\\/]*$");
|
2013-02-06 15:40:17 +01:00
|
|
|
|
|
|
|
textAreaDescription.setFieldLabel(ConstantsExplorer.DIALOG_DESCRIPTION);
|
|
|
|
textAreaDescription.setHeight(heightTextArea);
|
|
|
|
textAreaDescription.setWidth(380);
|
|
|
|
|
2014-02-11 16:41:56 +01:00
|
|
|
final LayoutContainer lc = new LayoutContainer();
|
2013-02-06 15:40:17 +01:00
|
|
|
lc.setStyleAttribute("margin-top", "10px");
|
|
|
|
lc.setStyleAttribute("margin-bottom", "10px");
|
|
|
|
lc.setSize(480, 50);
|
|
|
|
|
2014-02-11 16:41:56 +01:00
|
|
|
final FlexTable flexTable = new FlexTable();
|
2013-02-06 15:40:17 +01:00
|
|
|
flexTable.setStyleName("userssuggest");
|
|
|
|
Label lableShareWith = new Label("Share with users");
|
|
|
|
flexTable.setWidget(0, 0, lableShareWith);
|
|
|
|
flexTable.setWidget(0, 1, suggestPanel);
|
|
|
|
|
|
|
|
buttonMultiDrag.setStyleName("wizardButton");
|
|
|
|
|
|
|
|
// buttonMultiDrag.setIcon(Resources.getIconUsers());
|
2013-02-27 19:17:22 +01:00
|
|
|
flexTable.setWidget(1, 0, new Label("Add more"));
|
2013-02-06 15:40:17 +01:00
|
|
|
flexTable.setWidget(1, 1, buttonMultiDrag);
|
|
|
|
|
|
|
|
Label labelDescription = new Label("Description");
|
|
|
|
flexTable.setWidget(2, 0, labelDescription);
|
|
|
|
flexTable.setWidget(2, 1, textAreaDescription);
|
|
|
|
|
2014-02-11 16:41:56 +01:00
|
|
|
|
|
|
|
Label labelProperty = new Label("Permissions");
|
|
|
|
// final ToggleButton togglePermission = new ToggleButton("Set Permissions");
|
|
|
|
flexTable.setWidget(3, 0, labelProperty);
|
|
|
|
|
|
|
|
flexTable.setWidget(3, 1, Resources.getIconLoading().createImage());
|
|
|
|
|
|
|
|
AppControllerExplorer.rpcWorkspaceService.getACLs(new AsyncCallback<List<WorkspaceACL>>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSuccess(List<WorkspaceACL> result) {
|
|
|
|
permission = new PanelPermission(result);
|
|
|
|
flexTable.setWidget(3, 1, permission);
|
|
|
|
lc.layout();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
|
|
|
|
flexTable.setWidget(3, 1, new Label("Error on recovering ACLs"));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
lc.add(flexTable);
|
|
|
|
|
|
|
|
setFocusWidget(txtName);
|
|
|
|
add(txtName);
|
|
|
|
add(lc);
|
|
|
|
addListners();
|
|
|
|
|
|
|
|
this.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<InfoContactModel> getSharedListUsers() {
|
2013-03-12 12:39:09 +01:00
|
|
|
// printSelectedUser();
|
2013-02-06 15:40:17 +01:00
|
|
|
return suggestPanel.getSelectedUser();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void addListners(){
|
|
|
|
|
|
|
|
this.getButtonById(Dialog.CANCEL).addSelectionListener(new SelectionListener<ButtonEvent>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void componentSelected(ButtonEvent ce) {
|
|
|
|
hide();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
this.getButtonById(Dialog.OK).addSelectionListener(new SelectionListener<ButtonEvent>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void componentSelected(ButtonEvent ce) {
|
|
|
|
if(isValidForm(false))
|
|
|
|
hide();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
buttonMultiDrag.addClickHandler(new ClickHandler() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onClick(ClickEvent event) {
|
|
|
|
final MultiDragContact multiDrag = new MultiDragContact();
|
2013-06-12 16:30:45 +02:00
|
|
|
multiDrag.show();
|
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
List<InfoContactModel> exclusiveContacts = userStore.getExclusiveContactsFromAllContact(suggestPanel.getSelectedUser());
|
|
|
|
multiDrag.addSourceContacts(exclusiveContacts);
|
2013-02-25 19:03:53 +01:00
|
|
|
|
|
|
|
|
|
|
|
for (InfoContactModel infoContactModel : suggestPanel.getSelectedUser()) {
|
|
|
|
if(!listAlreadyShared.contains(infoContactModel))
|
|
|
|
multiDrag.addTargetContact(infoContactModel);
|
|
|
|
}
|
|
|
|
|
2013-06-07 17:32:53 +02:00
|
|
|
multiDrag.addAlreadySharedContacts(suggestPanel.getSelectedUser());
|
|
|
|
|
2013-02-25 19:03:53 +01:00
|
|
|
// multiDrag.addTargetContacts(suggestPanel.getSelectedUser());
|
2013-06-12 16:30:45 +02:00
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
multiDrag.getButtonById(Dialog.OK).addSelectionListener(new SelectionListener<ButtonEvent>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void componentSelected(ButtonEvent ce) {
|
2013-02-08 17:31:14 +01:00
|
|
|
|
2013-02-25 19:03:53 +01:00
|
|
|
initSuggestContacts();
|
2013-02-08 17:31:14 +01:00
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
for (InfoContactModel infoContactModel : multiDrag.getTargetListContact()) {
|
2013-03-11 19:06:56 +01:00
|
|
|
suggestPanel.addRecipient(infoContactModel.getName(),true);
|
2013-02-06 15:40:17 +01:00
|
|
|
}
|
2013-02-08 17:31:14 +01:00
|
|
|
|
2013-06-07 17:32:53 +02:00
|
|
|
// for (InfoContactModel infoContactModel : multiDrag.getTargetListContact()) {
|
|
|
|
//
|
|
|
|
// if(!listAlreadySharedContains(infoContactModel))
|
|
|
|
// suggestPanel.addRecipient(infoContactModel.getName(),true);
|
|
|
|
// }
|
|
|
|
|
2013-02-08 17:31:14 +01:00
|
|
|
suggestPanel.boxSetFocus();
|
2013-02-27 19:17:22 +01:00
|
|
|
|
2013-03-12 12:39:09 +01:00
|
|
|
// printSelectedUser();
|
2013-02-06 15:40:17 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2013-02-25 19:03:53 +01:00
|
|
|
|
2013-06-07 17:32:53 +02:00
|
|
|
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;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-02-27 19:17:22 +01:00
|
|
|
//DEBUG
|
|
|
|
private void printSelectedUser(){
|
|
|
|
|
|
|
|
System.out.println("SELETECTED USERS: ");
|
|
|
|
for (InfoContactModel contact : suggestPanel.getSelectedUser())
|
|
|
|
System.out.println(contact);
|
|
|
|
}
|
|
|
|
|
2013-02-25 19:03:53 +01:00
|
|
|
private void initSuggestContacts(){
|
|
|
|
|
|
|
|
suggestPanel.resetItemSelected();
|
|
|
|
|
|
|
|
for (InfoContactModel contact : listAlreadyShared) {
|
2013-03-11 19:06:56 +01:00
|
|
|
suggestPanel.addRecipient(contact.getName(), false);
|
2013-02-25 19:03:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2013-02-06 15:40:17 +01:00
|
|
|
|
|
|
|
public String getName() {
|
|
|
|
return txtName.getValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getDescription() {
|
|
|
|
if(textAreaDescription.getValue()==null)
|
|
|
|
return "";
|
|
|
|
|
|
|
|
return textAreaDescription.getValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param displayAlert
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
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;
|
|
|
|
|
|
|
|
}
|
2014-02-11 16:41:56 +01:00
|
|
|
|
|
|
|
public WorkspaceACL getSelectedACL(){
|
|
|
|
if(permission!=null)
|
|
|
|
return permission.getSelectedACL();
|
|
|
|
return null;
|
|
|
|
}
|
2013-02-06 15:40:17 +01:00
|
|
|
}
|