196 lines
5.3 KiB
Java
196 lines
5.3 KiB
Java
/**
|
|
*
|
|
*/
|
|
package org.gcube.portlets.widgets.workspacesharingwidget.client;
|
|
|
|
import java.util.List;
|
|
|
|
import org.gcube.portlets.widgets.workspacesharingwidget.client.permissions.MessageBoxAlert;
|
|
import org.gcube.portlets.widgets.workspacesharingwidget.client.permissions.PanelTogglePermission;
|
|
import org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.multisuggest.DialogMultiDragContact;
|
|
import org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.multisuggest.MultiDragContact;
|
|
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
|
|
import org.gcube.portlets.widgets.workspacesharingwidget.shared.WorkspaceACL;
|
|
|
|
import com.extjs.gxt.ui.client.Style.Scroll;
|
|
import com.extjs.gxt.ui.client.event.BaseEvent;
|
|
import com.extjs.gxt.ui.client.event.Events;
|
|
import com.extjs.gxt.ui.client.event.Listener;
|
|
import com.extjs.gxt.ui.client.widget.Dialog;
|
|
import com.extjs.gxt.ui.client.widget.HorizontalPanel;
|
|
import com.extjs.gxt.ui.client.widget.Html;
|
|
import com.extjs.gxt.ui.client.widget.form.TextArea;
|
|
import com.google.gwt.core.shared.GWT;
|
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
|
|
|
|
/**
|
|
*
|
|
* A dialog to drag and edit permissions of a workspace folder
|
|
*
|
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
|
* @Jan 27, 2015
|
|
*
|
|
*/
|
|
public class MultiDragContactsEditPermissions extends SimpleMultiDragWorkspaceContact{
|
|
|
|
private PanelTogglePermission permission;
|
|
private HorizontalPanel hpPermission = new HorizontalPanel();
|
|
private DialogMultiDragContact dialog;
|
|
private Html htmlCurrentPermissions = new Html();
|
|
/**
|
|
* @param load
|
|
* @param workspaceItemId
|
|
* @param readGroupsFromHL
|
|
* @param readGroupsFromPortal
|
|
* @param hiddenMySelf
|
|
*/
|
|
public MultiDragContactsEditPermissions(LOAD_CONTACTS_AS load, final String workspaceItemId, boolean readGroupsFromHL, boolean readGroupsFromPortal, boolean hiddenMySelf) {
|
|
super(load, workspaceItemId, readGroupsFromHL, readGroupsFromPortal,hiddenMySelf);
|
|
|
|
dialog = super.getDialogMultiDragContact();
|
|
dialog.setScrollMode(Scroll.AUTOY);
|
|
|
|
// htmlCurrentPermissions.setReadOnly(true);
|
|
htmlCurrentPermissions.setWidth(MultiDragContact.WIDTH_CP);
|
|
htmlCurrentPermissions.setStyleAttribute("padding", MultiDragContact.PADDING+"px");
|
|
|
|
dialog.getLcTop().add(htmlCurrentPermissions);
|
|
// dialog.setHeight(dialog.getHeight()+100);
|
|
|
|
WorkspaceSharingController.rpcWorkspaceSharingService.getACLsDescriptionForSharedFolderId(workspaceItemId, new AsyncCallback<String>() {
|
|
|
|
@Override
|
|
public void onFailure(Throwable caught) {
|
|
// TODO Auto-generated method stub
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onSuccess(String result) {
|
|
String msg = "#<b>Current Permissions:</b> <br/>";
|
|
msg+=result;
|
|
htmlCurrentPermissions.setHtml(msg);
|
|
|
|
}
|
|
});
|
|
|
|
enableSubmit(false);
|
|
// hpPermission.setStyleAttribute("margin-top", "20px");
|
|
hpPermission.setStyleAttribute("margin-left", "165px");
|
|
// Html html = new Html("With Permission : ");
|
|
// html.setStyleAttribute("margin-left", "10px");
|
|
// hpPermission.add(html);
|
|
|
|
//TODO GET ACL FOR USER
|
|
WorkspaceSharingController.rpcWorkspaceSharingService.getACLs(new AsyncCallback<List<WorkspaceACL>>() {
|
|
|
|
@Override
|
|
public void onSuccess(List<WorkspaceACL> result) {
|
|
permission = new PanelTogglePermission(result);
|
|
hpPermission.add(permission);
|
|
hpPermission.layout();
|
|
// selectAclForFolder(workspaceItemId);
|
|
enableSubmit(true);
|
|
|
|
// dialog.unmask();
|
|
}
|
|
|
|
@Override
|
|
public void onFailure(Throwable caught) {
|
|
new MessageBoxAlert("Alert", "Sorry, an error occurred on recovering ACLs",null);
|
|
// dialog.unmask();
|
|
}
|
|
});
|
|
|
|
dialog.add(hpPermission);
|
|
|
|
dialog.addListener(Events.Render, new Listener<BaseEvent>() {
|
|
|
|
@Override
|
|
public void handleEvent(BaseEvent be) {
|
|
dialog.setHeight(dialog.getHeight()+100);
|
|
}
|
|
});
|
|
}
|
|
|
|
public void enableSubmit(boolean bool){
|
|
dialog.getButtonById(Dialog.OK).setEnabled(bool);
|
|
}
|
|
|
|
public DialogMultiDragContact getDialog() {
|
|
return dialog;
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see org.gcube.portlets.widgets.workspacesharingwidget.client.SimpleMultiDragWorkspaceContact#show()
|
|
*/
|
|
@Override
|
|
public void show() {
|
|
dialog.show();
|
|
}
|
|
|
|
/**
|
|
* The HL ID of the selected ACL
|
|
* @return
|
|
*/
|
|
public String getSelectedAclID(){
|
|
if(permission.getSelectedACL()!=null)
|
|
return permission.getSelectedACL().getId();
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
/**
|
|
* The selected ACL
|
|
* @return
|
|
*/
|
|
public WorkspaceACL getSelectedAcl(){
|
|
if(permission.getSelectedACL()!=null)
|
|
return permission.getSelectedACL();
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
private void selectAclForFolder(String itemID){
|
|
GWT.log("Loading ACL to: "+itemID);
|
|
WorkspaceSharingController.rpcWorkspaceSharingService.getACLForSharedItemId(itemID, new AsyncCallback<WorkspaceACL>() {
|
|
|
|
@Override
|
|
public void onFailure(Throwable arg0) {
|
|
GWT.log("An error occurred on selecting current ACL "+arg0);
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onSuccess(WorkspaceACL arg0) {
|
|
GWT.log("Loaded ACL "+arg0);
|
|
if(arg0!=null){
|
|
permission.selectACL(arg0);
|
|
hpPermission.layout();
|
|
}
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @return
|
|
*/
|
|
public List<InfoContactModel> getTargetContacts() {
|
|
return super.getTargetContacts();
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @return
|
|
*/
|
|
public List<InfoContactModel> getTargetContactsWithMyLogin() {
|
|
return super.getTargetContactsWithMyLogin();
|
|
}
|
|
|
|
}
|