enhancements
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-sharing-widget@92426 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
1ac65af1eb
commit
540939bd7f
|
@ -5,6 +5,7 @@ package org.gcube.portlets.widgets.workspacesharingwidget.client;
|
|||
|
||||
import org.gcube.portlets.widgets.workspacesharingwidget.client.rpc.WorkspaceSharingService;
|
||||
import org.gcube.portlets.widgets.workspacesharingwidget.client.rpc.WorkspaceSharingServiceAsync;
|
||||
import org.gcube.portlets.widgets.workspacesharingwidget.shared.ACL_TYPE;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
@ -16,11 +17,41 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
|
|||
*/
|
||||
public class WorkspaceSharingController {
|
||||
|
||||
public static final WorkspaceSharingServiceAsync rpcWorkspaceSharingService = (WorkspaceSharingServiceAsync) GWT
|
||||
.create(WorkspaceSharingService.class);
|
||||
public static final WorkspaceSharingServiceAsync rpcWorkspaceSharingService = (WorkspaceSharingServiceAsync) GWT.create(WorkspaceSharingService.class);
|
||||
|
||||
public static String myLogin;
|
||||
private static String myLogin;
|
||||
|
||||
private String workspaceItemId;
|
||||
|
||||
private boolean shareOnlyOwner;
|
||||
|
||||
private ACL_TYPE defaultPermission;
|
||||
|
||||
|
||||
/**
|
||||
* This dialog doesn't show setting permissions, it use default server permissions
|
||||
* @param workspace itemId to share
|
||||
*/
|
||||
public WorkspaceSharingController(String itemId) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This dialog show setting permissions
|
||||
* @param itemId workace item id
|
||||
* @param shareOnlyOwner if true, only owner can share
|
||||
* @param defaultPermission ACL_TYPE default permission
|
||||
*/
|
||||
public WorkspaceSharingController(String itemId, boolean shareOnlyOwner, ACL_TYPE defaultPermission) {
|
||||
this.workspaceItemId = itemId;
|
||||
this.shareOnlyOwner = shareOnlyOwner;
|
||||
this.defaultPermission = defaultPermission;
|
||||
|
||||
if(shareOnlyOwner){
|
||||
loadMyLogin();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadMyLogin() {
|
||||
|
||||
rpcWorkspaceSharingService.getMyLogin(new AsyncCallback<String>() {
|
||||
|
@ -40,4 +71,28 @@ public class WorkspaceSharingController {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
public static String getMyLogin() {
|
||||
return myLogin;
|
||||
}
|
||||
|
||||
|
||||
public String getWorkspaceItemId() {
|
||||
return workspaceItemId;
|
||||
}
|
||||
|
||||
|
||||
public boolean isShareOnlyOwner() {
|
||||
return shareOnlyOwner;
|
||||
}
|
||||
|
||||
public void setWorkspaceItemId(String workspaceItemId) {
|
||||
this.workspaceItemId = workspaceItemId;
|
||||
}
|
||||
|
||||
|
||||
public void setShareOnlyOwner(boolean shareOnlyOwner) {
|
||||
this.shareOnlyOwner = shareOnlyOwner;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,22 +18,22 @@ public class WorkspaceSharingWidget implements EntryPoint {
|
|||
public void onModuleLoad() {
|
||||
|
||||
|
||||
final Label loading = new Label("loading");
|
||||
WorkspaceSharingController.rpcWorkspaceSharingService.greetServer("a",new AsyncCallback<String>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(String result) {
|
||||
loading.setText(result);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
RootPanel.get("workpacesharingwidget").add(loading);
|
||||
// final Label loading = new Label("loading");
|
||||
// WorkspaceSharingController.rpcWorkspaceSharingService.greetServer("a",new AsyncCallback<String>() {
|
||||
//
|
||||
// @Override
|
||||
// public void onSuccess(String result) {
|
||||
// loading.setText(result);
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onFailure(Throwable caught) {
|
||||
// // TODO Auto-generated method stub
|
||||
//
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// RootPanel.get("workpacesharingwidget").add(loading);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,418 @@
|
|||
package org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.widgets.workspacesharingwidget.client.WorkspaceSharingController;
|
||||
import org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.multisuggest.MultiDragContact;
|
||||
import org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.multisuggest.MultiValuePanel;
|
||||
import org.gcube.portlets.widgets.workspacesharingwidget.shared.ACL_TYPE;
|
||||
import org.gcube.portlets.widgets.workspacesharingwidget.shared.FileModel;
|
||||
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
|
||||
import org.gcube.portlets.widgets.workspacesharingwidget.shared.WorkspaceACL;
|
||||
|
||||
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
|
||||
import com.extjs.gxt.ui.client.Style.Scroll;
|
||||
import com.extjs.gxt.ui.client.Style.VerticalAlignment;
|
||||
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
||||
import com.extjs.gxt.ui.client.event.SelectionListener;
|
||||
import com.extjs.gxt.ui.client.widget.Dialog;
|
||||
import com.extjs.gxt.ui.client.widget.HorizontalPanel;
|
||||
import com.extjs.gxt.ui.client.widget.LayoutContainer;
|
||||
import com.extjs.gxt.ui.client.widget.MessageBox;
|
||||
import com.extjs.gxt.ui.client.widget.form.TextArea;
|
||||
import com.extjs.gxt.ui.client.widget.form.TextField;
|
||||
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
|
||||
import com.google.gwt.core.shared.GWT;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.event.shared.HandlerManager;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
import com.google.gwt.user.client.ui.FlexTable;
|
||||
import com.google.gwt.user.client.ui.Label;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* @Feb 27, 2014
|
||||
*
|
||||
*/
|
||||
public class DialogShareWItem extends Dialog {
|
||||
|
||||
private int widthDialog = 530;
|
||||
private int heightTextArea = 100;
|
||||
private TextField<String> txtName;
|
||||
private TextArea textAreaDescription = new TextArea();
|
||||
private FileModel fileToShare = null;
|
||||
private UserStore userStore = new UserStore();
|
||||
private MultiValuePanel suggestPanel = new MultiValuePanel(userStore);
|
||||
private Button buttonMultiDrag = new Button("Choose Contacts");
|
||||
private TextField<String> txtOwner;
|
||||
private PanelTogglePermission permission;
|
||||
private HorizontalPanel hpPermission = null;
|
||||
|
||||
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++){
|
||||
if (contact.getName().compareTo(listAlreadyShared.get(i).getName())==0)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
};
|
||||
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Use to modify a shared folder or share an existing folder
|
||||
* @param fileModel
|
||||
* @param type
|
||||
*/
|
||||
public DialogShareWItem(FileModel fileModel, HandlerManager eventBus, final boolean shareOnlyOwner, final ACL_TYPE defaultACL) {
|
||||
initLayout();
|
||||
this.fileToShare = fileModel;
|
||||
|
||||
setWidth(widthDialog);
|
||||
setButtons(Dialog.OKCANCEL);
|
||||
|
||||
String heading = "Share workspace";
|
||||
if(fileModel.isDirectory())
|
||||
heading+=" folder: ";
|
||||
else
|
||||
heading+= " item: ";
|
||||
|
||||
setHeading(heading+fileModel.getName());
|
||||
|
||||
txtName = new TextField<String>();
|
||||
txtName.setAllowBlank(false);
|
||||
txtName.setValue(fileModel.getName());
|
||||
txtName.setReadOnly(true);
|
||||
txtName.setAutoValidate(true);
|
||||
txtName.setFieldLabel("Folder Name");
|
||||
|
||||
txtOwner = new TextField<String>();
|
||||
txtOwner.setAllowBlank(true);
|
||||
txtOwner.setValue("");
|
||||
txtOwner.setReadOnly(true);
|
||||
txtOwner.setAutoValidate(false);
|
||||
txtOwner.setFieldLabel("Owner");
|
||||
|
||||
textAreaDescription.setFieldLabel("Description");
|
||||
textAreaDescription.setHeight(heightTextArea);
|
||||
textAreaDescription.setWidth(380);
|
||||
|
||||
textAreaDescription.setValue(fileModel.getDescription());
|
||||
|
||||
final LayoutContainer lc = new LayoutContainer();
|
||||
lc.setStyleAttribute("margin-top", "10px");
|
||||
lc.setStyleAttribute("margin-bottom", "10px");
|
||||
lc.setSize(480, 50);
|
||||
|
||||
final FlexTable flexTable = new FlexTable();
|
||||
flexTable.setStyleName("userssuggest");
|
||||
Label labelShareWith = new Label("Share with users");
|
||||
flexTable.setWidget(0, 0, labelShareWith);
|
||||
flexTable.setWidget(0, 1, suggestPanel);
|
||||
|
||||
buttonMultiDrag.setStyleName("wizardButton");
|
||||
|
||||
|
||||
flexTable.setWidget(1, 0, new Label("Add more"));
|
||||
flexTable.setWidget(1, 1, buttonMultiDrag);
|
||||
|
||||
Label labelDescription = new Label("Description");
|
||||
flexTable.setWidget(2, 0, labelDescription);
|
||||
flexTable.setWidget(2, 1, textAreaDescription);
|
||||
|
||||
|
||||
hpPermission = new HorizontalPanel();
|
||||
hpPermission.setVerticalAlign(VerticalAlignment.MIDDLE);
|
||||
Label labelProperty = new Label("Permissions");
|
||||
hpPermission.add(labelProperty);
|
||||
|
||||
WorkspaceSharingController.rpcWorkspaceSharingService.getACLs(new AsyncCallback<List<WorkspaceACL>>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<WorkspaceACL> result) {
|
||||
permission = new PanelTogglePermission(result,defaultACL);
|
||||
hpPermission.add(permission);
|
||||
hpPermission.layout();
|
||||
layout();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
hpPermission.add(new Label("Error on recovering ACLs"));
|
||||
hpPermission.layout();
|
||||
layout();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
lc.add(flexTable);
|
||||
if(hpPermission!=null)
|
||||
lc.add(hpPermission);
|
||||
lc.mask();
|
||||
userStore.getListSharedUserByFolderId(fileModel.getIdentifier(), new AsyncCallback<List<InfoContactModel>>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<InfoContactModel> result) {
|
||||
|
||||
for (InfoContactModel infoContactModel : result) {
|
||||
if(infoContactModel.getName()!=null){
|
||||
listAlreadyShared.add(infoContactModel);
|
||||
suggestPanel.addRecipient(infoContactModel.getName(),false);
|
||||
}
|
||||
}
|
||||
|
||||
lc.unmask();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
lc.unmask();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
userStore.getOwner(fileModel.getIdentifier(), new AsyncCallback<InfoContactModel>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
txtOwner.setValue("Error on retrieving Owner");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(InfoContactModel result) {
|
||||
txtOwner.setValue(result.getName());
|
||||
|
||||
if(shareOnlyOwner){
|
||||
permissionControl(result.getLogin(), true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
setFocusWidget(suggestPanel.getBox());
|
||||
add(txtName);
|
||||
add(txtOwner);
|
||||
add(lc);
|
||||
addListners();
|
||||
|
||||
if(shareOnlyOwner)
|
||||
enableFormDialog(false); //FORM IS DISABLED BY DEFAULT
|
||||
|
||||
this.show();
|
||||
}
|
||||
|
||||
private void permissionControl(String owner, boolean showAlert){
|
||||
GWT.log("Permission control compare between owner: "+owner +" and my login: "+WorkspaceSharingController.getMyLogin());
|
||||
|
||||
if(WorkspaceSharingController.getMyLogin().compareToIgnoreCase(owner)!=0){
|
||||
enableFormDialog(false);
|
||||
if(showAlert)
|
||||
MessageBox.alert("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);
|
||||
}
|
||||
|
||||
public FileModel getParentFolder() {
|
||||
return fileToShare;
|
||||
}
|
||||
|
||||
public void initLayout(){
|
||||
FormLayout layout = new FormLayout();
|
||||
layout.setLabelWidth(90);
|
||||
layout.setDefaultWidth(380);
|
||||
setLayout(layout);
|
||||
setModal(true);
|
||||
setScrollMode(Scroll.AUTOY);
|
||||
setBodyStyle("padding: 9px; background: none");
|
||||
setWidth(widthDialog);
|
||||
setHeight(397);
|
||||
setResizable(true);
|
||||
setButtonAlign(HorizontalAlignment.CENTER);
|
||||
setWidth(widthDialog);
|
||||
setButtons(Dialog.OKCANCEL);
|
||||
}
|
||||
|
||||
|
||||
public List<InfoContactModel> getSharedListUsers() {
|
||||
// printSelectedUser();
|
||||
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();
|
||||
multiDrag.show();
|
||||
|
||||
List<InfoContactModel> exclusiveContacts = userStore.getExclusiveContactsFromAllContact(suggestPanel.getSelectedUser());
|
||||
multiDrag.addSourceContacts(exclusiveContacts);
|
||||
|
||||
|
||||
for (InfoContactModel infoContactModel : suggestPanel.getSelectedUser()) {
|
||||
if(!listAlreadyShared.contains(infoContactModel))
|
||||
multiDrag.addTargetContact(infoContactModel);
|
||||
}
|
||||
|
||||
multiDrag.addAlreadySharedContacts(suggestPanel.getSelectedUser());
|
||||
|
||||
// multiDrag.addTargetContacts(suggestPanel.getSelectedUser());
|
||||
|
||||
multiDrag.getButtonById(Dialog.OK).addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||
|
||||
@Override
|
||||
public void componentSelected(ButtonEvent ce) {
|
||||
|
||||
initSuggestContacts();
|
||||
|
||||
for (InfoContactModel infoContactModel : multiDrag.getTargetListContact()) {
|
||||
suggestPanel.addRecipient(infoContactModel.getName(),true);
|
||||
}
|
||||
|
||||
// for (InfoContactModel infoContactModel : multiDrag.getTargetListContact()) {
|
||||
//
|
||||
// if(!listAlreadySharedContains(infoContactModel))
|
||||
// suggestPanel.addRecipient(infoContactModel.getName(),true);
|
||||
// }
|
||||
|
||||
suggestPanel.boxSetFocus();
|
||||
|
||||
// printSelectedUser();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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(){
|
||||
|
||||
System.out.println("SELETECTED USERS: ");
|
||||
for (InfoContactModel contact : suggestPanel.getSelectedUser())
|
||||
System.out.println(contact);
|
||||
}
|
||||
|
||||
private void initSuggestContacts(){
|
||||
|
||||
suggestPanel.resetItemSelected();
|
||||
|
||||
for (InfoContactModel contact : listAlreadyShared) {
|
||||
suggestPanel.addRecipient(contact.getName(), false);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
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)
|
||||
MessageBox.alert("Attention", "Name must not be empty", null);
|
||||
txtName.focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
if(getSharedListUsers().size()==0){
|
||||
if(displayAlert)
|
||||
MessageBox.alert("Attention", "You must pick at least one user with which share the folder", null);
|
||||
suggestPanel.boxSetFocus();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public WorkspaceACL getSelectedACL(){
|
||||
if(permission!=null)
|
||||
return permission.getSelectedACL();
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -32,16 +32,18 @@ import com.google.gwt.user.client.ui.FlexTable;
|
|||
import com.google.gwt.user.client.ui.Label;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* @Feb 27, 2014
|
||||
*
|
||||
*/
|
||||
public class DialogShareFolder extends Dialog {
|
||||
public class DialogShareWItemNoACL extends Dialog {
|
||||
|
||||
private int widthDialog = 530;
|
||||
private int heightTextArea = 100;
|
||||
private TextField<String> txtName;
|
||||
private TextArea textAreaDescription = new TextArea();
|
||||
private FileModel parentFolder = null;
|
||||
private FileModel fileToShare = null;
|
||||
private UserStore userStore = new UserStore();
|
||||
private MultiValuePanel suggestPanel = new MultiValuePanel(userStore);
|
||||
private Button buttonMultiDrag = new Button("Choose Contacts");
|
||||
|
@ -81,22 +83,28 @@ public class DialogShareFolder extends Dialog {
|
|||
|
||||
/**
|
||||
* Use to modify a shared folder or share an existing folder
|
||||
* @param folder
|
||||
* @param fileModel
|
||||
* @param type
|
||||
*/
|
||||
public DialogShareFolder(String folderParentName, FileModel folder, HandlerManager eventBus) {
|
||||
initLayout(folderParentName);
|
||||
this.parentFolder = folder;
|
||||
public DialogShareWItemNoACL(FileModel fileModel, HandlerManager eventBus, final boolean shareOnlyOwner) {
|
||||
initLayout();
|
||||
this.fileToShare = fileModel;
|
||||
// this.setIcon(Resources.getIconShareFolder());
|
||||
|
||||
setWidth(widthDialog);
|
||||
setButtons(Dialog.OKCANCEL);
|
||||
|
||||
setHeading("Share folder: "+folder.getName());
|
||||
String heading = "Share workspace";
|
||||
if(fileModel.isDirectory())
|
||||
heading+=" folder: ";
|
||||
else
|
||||
heading+= " item: ";
|
||||
|
||||
setHeading(heading+fileModel.getName());
|
||||
|
||||
txtName = new TextField<String>();
|
||||
txtName.setAllowBlank(false);
|
||||
txtName.setValue(folder.getName());
|
||||
txtName.setValue(fileModel.getName());
|
||||
txtName.setReadOnly(true);
|
||||
txtName.setAutoValidate(true);
|
||||
txtName.setFieldLabel("Folder Name");
|
||||
|
@ -112,7 +120,7 @@ public class DialogShareFolder extends Dialog {
|
|||
textAreaDescription.setHeight(heightTextArea);
|
||||
textAreaDescription.setWidth(380);
|
||||
|
||||
textAreaDescription.setValue(folder.getDescription());
|
||||
textAreaDescription.setValue(fileModel.getDescription());
|
||||
// textAreaDescription.setReadOnly(true);
|
||||
|
||||
final LayoutContainer lc = new LayoutContainer();
|
||||
|
@ -137,40 +145,39 @@ public class DialogShareFolder extends Dialog {
|
|||
flexTable.setWidget(2, 1, textAreaDescription);
|
||||
|
||||
|
||||
// if(!folder.isShared()){ //SETTABLE PERMISSION ONLY IF FOLDER IS NOT ALREADY SHARED
|
||||
hpPermission = new HorizontalPanel();
|
||||
hpPermission.setVerticalAlign(VerticalAlignment.MIDDLE);
|
||||
Label labelProperty = new Label("Permissions");
|
||||
hpPermission = new HorizontalPanel();
|
||||
hpPermission.setVerticalAlign(VerticalAlignment.MIDDLE);
|
||||
Label labelProperty = new Label("Permissions");
|
||||
// final ToggleButton togglePermission = new ToggleButton("Set Permissions");
|
||||
// flexTable.setWidget(3, 0, labelProperty);
|
||||
|
||||
|
||||
// flexTable.setWidget(3, 1, Resources.getIconLoading().createImage());
|
||||
hpPermission.add(labelProperty);
|
||||
|
||||
WorkspaceSharingController.rpcWorkspaceSharingService.getACLs(new AsyncCallback<List<WorkspaceACL>>() {
|
||||
hpPermission.add(labelProperty);
|
||||
|
||||
WorkspaceSharingController.rpcWorkspaceSharingService.getACLs(new AsyncCallback<List<WorkspaceACL>>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<WorkspaceACL> result) {
|
||||
permission = new PanelTogglePermission(result);
|
||||
hpPermission.add(permission);
|
||||
hpPermission.layout();
|
||||
layout();
|
||||
}
|
||||
@Override
|
||||
public void onSuccess(List<WorkspaceACL> result) {
|
||||
permission = new PanelTogglePermission(result,null);
|
||||
hpPermission.add(permission);
|
||||
hpPermission.layout();
|
||||
permission.setEnabled(false);
|
||||
layout();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
hpPermission.add(new Label("Error on recovering ACLs"));
|
||||
hpPermission.layout();
|
||||
layout();
|
||||
}
|
||||
});
|
||||
// }
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
hpPermission.add(new Label("Error on recovering ACLs"));
|
||||
hpPermission.layout();
|
||||
layout();
|
||||
}
|
||||
});
|
||||
|
||||
lc.add(flexTable);
|
||||
if(hpPermission!=null)
|
||||
lc.add(hpPermission);
|
||||
lc.mask();
|
||||
userStore.getListSharedUserByFolderId(folder.getIdentifier(), new AsyncCallback<List<InfoContactModel>>() {
|
||||
userStore.getListSharedUserByFolderId(fileModel.getIdentifier(), new AsyncCallback<List<InfoContactModel>>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<InfoContactModel> result) {
|
||||
|
@ -193,7 +200,7 @@ public class DialogShareFolder extends Dialog {
|
|||
});
|
||||
|
||||
|
||||
userStore.getOwner(folder.getIdentifier(), new AsyncCallback<InfoContactModel>() {
|
||||
userStore.getOwner(fileModel.getIdentifier(), new AsyncCallback<InfoContactModel>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
|
@ -203,7 +210,8 @@ public class DialogShareFolder extends Dialog {
|
|||
@Override
|
||||
public void onSuccess(InfoContactModel result) {
|
||||
txtOwner.setValue(result.getName());
|
||||
permissionControl(result.getLogin(), true);
|
||||
if(shareOnlyOwner)
|
||||
permissionControl(result.getLogin(), true);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -212,15 +220,17 @@ public class DialogShareFolder extends Dialog {
|
|||
add(txtOwner);
|
||||
add(lc);
|
||||
addListners();
|
||||
enableFormDialog(false); //FORM IS DISABLED BY DEFAULT
|
||||
|
||||
if(shareOnlyOwner)
|
||||
enableFormDialog(false); //FORM IS DISABLED BY DEFAULT
|
||||
|
||||
this.show();
|
||||
}
|
||||
|
||||
private void permissionControl(String owner, boolean showAlert){
|
||||
GWT.log("Permission control compare between owner: "+owner +" and my login: "+WorkspaceSharingController.myLogin);
|
||||
GWT.log("Permission control compare between owner: "+owner +" and my login: "+WorkspaceSharingController.getMyLogin());
|
||||
|
||||
if(WorkspaceSharingController.myLogin.compareToIgnoreCase(owner)!=0){
|
||||
if(WorkspaceSharingController.getMyLogin().compareToIgnoreCase(owner)!=0){
|
||||
enableFormDialog(false);
|
||||
if(showAlert)
|
||||
MessageBox.alert("Permission denied", "You have no permissions to change sharing. You are not owner of \""+txtName.getValue()+"\"", null);
|
||||
|
@ -241,10 +251,10 @@ public class DialogShareFolder extends Dialog {
|
|||
}
|
||||
|
||||
public FileModel getParentFolder() {
|
||||
return parentFolder;
|
||||
return fileToShare;
|
||||
}
|
||||
|
||||
public void initLayout(String folderParentName){
|
||||
public void initLayout(){
|
||||
FormLayout layout = new FormLayout();
|
||||
layout.setLabelWidth(90);
|
||||
layout.setDefaultWidth(380);
|
|
@ -3,6 +3,7 @@ package org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing;
|
|||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.widgets.workspacesharingwidget.client.resources.GetPermissionIconByACL;
|
||||
import org.gcube.portlets.widgets.workspacesharingwidget.shared.ACL_TYPE;
|
||||
import org.gcube.portlets.widgets.workspacesharingwidget.shared.WorkspaceACL;
|
||||
import org.gcube.portlets.widgets.workspacesharingwidget.shared.WorkspaceACL.USER_TYPE;
|
||||
|
||||
|
@ -20,14 +21,13 @@ import com.google.gwt.user.client.ui.AbstractImagePrototype;
|
|||
|
||||
public class PanelTogglePermission extends LayoutContainer {
|
||||
|
||||
protected static final String WORKSPACEACLGROUP = "WORKSPACEACLGROUP";
|
||||
// private ButtonGroup buttonGroup;
|
||||
|
||||
protected static final String WORKSPACEACLGROUP = "WORKSPACEACLGROUPSHARING";
|
||||
private HorizontalPanel hp = new HorizontalPanel();
|
||||
|
||||
private WorkspaceACL selectedAcl = null;
|
||||
private ACL_TYPE defaultACLType;
|
||||
|
||||
public PanelTogglePermission(List<WorkspaceACL> acls) {
|
||||
public PanelTogglePermission(List<WorkspaceACL> acls, ACL_TYPE defaultACL) {
|
||||
this.defaultACLType = defaultACL;
|
||||
|
||||
// setStyleAttribute("margin-top", "10px");
|
||||
setStyleAttribute("margin-bottom", "15px");
|
||||
|
@ -60,7 +60,13 @@ public class PanelTogglePermission extends LayoutContainer {
|
|||
bToggle.setScale(ButtonScale.MEDIUM);
|
||||
bToggle.setId(acl.getId());
|
||||
bToggle.setAllowDepress(false);
|
||||
bToggle.toggle(acl.getDefaultValue());
|
||||
|
||||
if(defaultACLType!=null){
|
||||
defaultACLType.equals(acl.getAclType());
|
||||
bToggle.toggle(true);
|
||||
}else{
|
||||
bToggle.toggle(acl.getDefaultValue());
|
||||
}
|
||||
|
||||
if(acl.getDefaultValue())
|
||||
selectedAcl = acl;
|
||||
|
@ -105,6 +111,7 @@ public class PanelTogglePermission extends LayoutContainer {
|
|||
GWT.log("Selected ACL is: "+selectedAcl);
|
||||
return selectedAcl;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
public List<WorkspaceACL> getCheckedGroupList() {
|
||||
|
|
|
@ -13,6 +13,7 @@ import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
|||
import org.gcube.common.homelibrary.home.workspace.accessmanager.ACLType;
|
||||
import org.gcube.portlets.widgets.workspacesharingwidget.server.util.UserUtil;
|
||||
import org.gcube.portlets.widgets.workspacesharingwidget.server.util.WsUtil;
|
||||
import org.gcube.portlets.widgets.workspacesharingwidget.shared.ACL_TYPE;
|
||||
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
|
||||
import org.gcube.portlets.widgets.workspacesharingwidget.shared.WorkspaceACL;
|
||||
import org.gcube.portlets.widgets.workspacesharingwidget.shared.WorkspaceACL.USER_TYPE;
|
||||
|
@ -158,22 +159,23 @@ public class GWTWorkspaceSharingBuilder {
|
|||
for (ACLType acl : types) {
|
||||
|
||||
switch (acl) {
|
||||
|
||||
case ADMINISTRATOR:
|
||||
acls.add(new WorkspaceACL(acl.toString(), "Admin", false, USER_TYPE.ADMINISTRATOR, ""));
|
||||
acls.add(new WorkspaceACL(acl.toString(), ACL_TYPE.ADMINISTRATOR, "Admin", false, USER_TYPE.ADMINISTRATOR, ""));
|
||||
break;
|
||||
case READ_ONLY:
|
||||
acls.add(new WorkspaceACL(acl.toString(), "Read Only", false, USER_TYPE.OTHER, "Users can read any file but cannot update/delete"));
|
||||
acls.add(new WorkspaceACL(acl.toString(), ACL_TYPE.READ_ONLY, "Read Only", false, USER_TYPE.OTHER, "Users can read any file but cannot update/delete"));
|
||||
break;
|
||||
case WRITE_OWNER:
|
||||
acls.add(new WorkspaceACL(acl.toString(), "Write Own", true, USER_TYPE.OTHER, "Users can update/delete only their files"));
|
||||
acls.add(new WorkspaceACL(acl.toString(), ACL_TYPE.WRITE_OWNER, "Write Own", true, USER_TYPE.OTHER, "Users can update/delete only their files"));
|
||||
break;
|
||||
|
||||
case WRITE_ALL:
|
||||
acls.add(new WorkspaceACL(acl.toString(), "Write Any", false, USER_TYPE.OTHER,"Any user can update/delete any file"));
|
||||
acls.add(new WorkspaceACL(acl.toString(), ACL_TYPE.WRITE_ANY, "Write Any", false, USER_TYPE.OTHER,"Any user can update/delete any file"));
|
||||
break;
|
||||
|
||||
default:
|
||||
acls.add(new WorkspaceACL(acl.toString(), acl.toString(), false, USER_TYPE.OTHER, ""));
|
||||
acls.add(new WorkspaceACL(acl.toString(), ACL_TYPE.WRITE_OWNER, acl.toString(), false, USER_TYPE.OTHER, ""));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.widgets.workspacesharingwidget.shared;
|
||||
|
||||
/**
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* @Feb 27, 2014
|
||||
*
|
||||
*/
|
||||
public enum ACL_TYPE {
|
||||
|
||||
ADMINISTRATOR,
|
||||
READ_ONLY, // "Users can read any file but cannot update/delete"
|
||||
WRITE_OWNER, //"Users can update/delete only their files"
|
||||
WRITE_ANY; //"Any user can update/delete any file"
|
||||
|
||||
}
|
|
@ -3,6 +3,7 @@ package org.gcube.portlets.widgets.workspacesharingwidget.shared;
|
|||
import java.io.Serializable;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
|
@ -25,16 +26,20 @@ public class WorkspaceACL implements Serializable{
|
|||
|
||||
private String description;
|
||||
|
||||
private ACL_TYPE aclType;
|
||||
|
||||
|
||||
public enum USER_TYPE{ADMINISTRATOR, GROUP, OWNER, OTHER};
|
||||
|
||||
public WorkspaceACL(String id, String label, boolean defaultValue, USER_TYPE userType, String description) {
|
||||
|
||||
public WorkspaceACL(String serverId, ACL_TYPE aclType, String label, boolean defaultValue, USER_TYPE userType, String description) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.id = serverId;
|
||||
this.label = label;
|
||||
this.defaultValue = defaultValue;
|
||||
this.userType = userType;
|
||||
this.description = description;
|
||||
this.aclType = aclType;
|
||||
}
|
||||
|
||||
|
||||
|
@ -82,6 +87,14 @@ public class WorkspaceACL implements Serializable{
|
|||
this.description = description;
|
||||
}
|
||||
|
||||
public ACL_TYPE getAclType() {
|
||||
return aclType;
|
||||
}
|
||||
|
||||
public void setAclType(ACL_TYPE aclType) {
|
||||
this.aclType = aclType;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
@ -96,7 +109,10 @@ public class WorkspaceACL implements Serializable{
|
|||
builder.append(userType);
|
||||
builder.append(", description=");
|
||||
builder.append(description);
|
||||
builder.append(", aclType=");
|
||||
builder.append(aclType);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue