enhancements

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-sharing-widget@92568 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2014-03-03 14:54:53 +00:00
parent a8377863c5
commit a82619e6ca
7 changed files with 58 additions and 29 deletions

View File

@ -16,5 +16,5 @@ public interface ConstantsSharing {
public static int WIDTH_DIALOG = 530;
public static int HEIGHT_DIALOG = 530;
public static int HEIGHT_DIALOG = 430;
}

View File

@ -31,7 +31,7 @@ public class WorkspaceSharingController {
private ACL_TYPE defaultPermission;
private Window win = null;
private DialogShareWItem sharingDialog = null;
// /**
@ -71,9 +71,9 @@ public class WorkspaceSharingController {
private void initWindow(){
win = new Window();
win.setSize(ConstantsSharing.WIDTH_DIALOG+20, ConstantsSharing.HEIGHT_DIALOG+20);
win.mask("Loading File from Workspace", ConstantsSharing.LOADINGSTYLE);
sharingDialog = new DialogShareWItem();
sharingDialog.setSize(ConstantsSharing.WIDTH_DIALOG+20, ConstantsSharing.HEIGHT_DIALOG+20);
sharingDialog.mask("Loading File from Workspace", ConstantsSharing.LOADINGSTYLE);
}
@ -83,16 +83,17 @@ public class WorkspaceSharingController {
@Override
public void onFailure(Throwable caught) {
win.unmask();
sharingDialog.unmask();
MessageBox.alert("Error", caught.getMessage(), null);
}
@Override
public void onSuccess(FileModel result) {
win.mask("File loaded", ConstantsSharing.LOADINGSTYLE);
sharingDialog.unmask();
sharingDialog.mask("File loaded", ConstantsSharing.LOADINGSTYLE);
if(showSharingDialog)
createDialog(result);
updateSharingDialog(result);
}
});
}
@ -101,13 +102,12 @@ public class WorkspaceSharingController {
*
* @param fileModel
*/
private void createDialog(FileModel fileModel){
win.unmask();
DialogShareWItem dialogShareItem = new DialogShareWItem(fileModel, shareOnlyOwner, defaultPermission);
win.add(dialogShareItem);
dialogShareItem.show();
private void updateSharingDialog(FileModel fileModel){
sharingDialog.unmask();
sharingDialog.updateSharingDialog(fileModel, shareOnlyOwner, defaultPermission);
// dialogShareItem.show();
win.layout();
sharingDialog.layout();
}
/**
@ -160,8 +160,8 @@ public class WorkspaceSharingController {
*
* @return
*/
public Window getSharingWindow() {
return win;
public Window getSharingDialog() {
return sharingDialog;
}
}

View File

@ -16,6 +16,9 @@ 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.EventType;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.widget.Dialog;
import com.extjs.gxt.ui.client.widget.HorizontalPanel;
@ -51,7 +54,16 @@ public class DialogShareWItem extends Dialog {
private TextField<String> txtOwner;
private PanelTogglePermission permission;
private HorizontalPanel hpPermission = null;
private boolean showError = false;
/**
*
*/
public DialogShareWItem() {
initLayout();
}
private List<InfoContactModel> listAlreadyShared = new ArrayList<InfoContactModel>(){
/**
@ -81,16 +93,18 @@ public class DialogShareWItem extends Dialog {
};
/**
* Use to modify a shared folder or share an existing folder
* @param fileModel
* @param type
*/
public DialogShareWItem(FileModel fileModel, final boolean shareOnlyOwner, final ACL_TYPE defaultACL) {
initLayout();
this.fileToShare = fileModel;
public void updateSharingDialog(FileModel fileModel, final boolean shareOnlyOwner, final ACL_TYPE defaultACL){
this.fileToShare = fileModel;
setButtons(Dialog.OKCANCEL);
String heading = "Share workspace";
@ -220,19 +234,32 @@ public class DialogShareWItem extends Dialog {
if(shareOnlyOwner)
enableFormDialog(false); //FORM IS DISABLED BY DEFAULT
}
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);
if(showAlert){
showError = true;
}
}else{
enableFormDialog(true);
}
}
/* (non-Javadoc)
* @see com.extjs.gxt.ui.client.widget.Window#afterShow()
*/
@Override
protected void afterShow() {
super.afterShow();
if(showError){
MessageBox.alert("Permission denied", "You have no permissions to change sharing. You are not owner of \""+txtName.getValue()+"\"", null);
}
}
private void enableFormDialog(boolean bool){
getButtonById(Dialog.OK).setEnabled(bool);
buttonMultiDrag.setEnabled(bool);

View File

@ -224,7 +224,7 @@ public class DialogShareWItemNoACL extends Dialog {
if(shareOnlyOwner)
enableFormDialog(false); //FORM IS DISABLED BY DEFAULT
this.show();
// this.show();
}
private void permissionControl(String owner, boolean showAlert){

View File

@ -62,8 +62,10 @@ public class PanelTogglePermission extends LayoutContainer {
bToggle.setAllowDepress(false);
if(defaultACLType!=null){
defaultACLType.equals(acl.getAclType());
bToggle.toggle(true);
GWT.log("comparing.. "+defaultACLType + " and "+acl.getAclType());
GWT.log(defaultACLType.equals(acl.getAclType())+"");
// defaultACLType.equals(acl.getAclType());
bToggle.toggle(defaultACLType.equals(acl.getAclType()));
}else{
bToggle.toggle(acl.getDefaultValue());
}

View File

@ -46,7 +46,7 @@ public class UserStore implements ContactFetcher{
@Override
public void onSuccess(List<InfoContactModel> result) {
GWT.log("loaded "+result.size() + " contacts from server");
GWT.log("Get all contacts loaded "+result.size() + " contacts from server");
listAllContact = result;
callback.onSuccess(listAllContact);
}
@ -73,7 +73,7 @@ public class UserStore implements ContactFetcher{
@Override
public void onSuccess(List<InfoContactModel> result) {
GWT.log("loaded "+result.size() + " contacts from server for "+sharedFolderId);
GWT.log("Get List user shared loaded "+result.size() + " contacts from server for "+sharedFolderId);
callback.onSuccess(result);
}
});

View File

@ -64,6 +64,7 @@ public class InfoContactModel extends BaseModelData implements Serializable {
}
};
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
@ -77,5 +78,4 @@ public class InfoContactModel extends BaseModelData implements Serializable {
return builder.toString();
}
}