enhancements on "Edit Administrators"

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@100132 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2014-09-23 14:15:36 +00:00
parent cf2a2443a3
commit a06d57950a
5 changed files with 74 additions and 52 deletions

View File

@ -143,10 +143,9 @@ import org.gcube.portlets.widgets.fileupload.client.events.FileUploadCompleteEve
import org.gcube.portlets.widgets.fileupload.client.events.FileUploadCompleteEventHandler;
import org.gcube.portlets.widgets.fileupload.client.events.FileUploadSelectedEvent;
import org.gcube.portlets.widgets.fileupload.client.events.FileUploadSelectedEventHandler;
import org.gcube.portlets.widgets.workspacesharingwidget.client.SmartConstants;
import org.gcube.portlets.widgets.workspacesharingwidget.client.WorkspaceSmartSharingController;
import org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.SmartShare;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.CredentialModel;
import org.gcube.portlets.widgets.workspacesharingwidget.client.SimpleMultiDragConstants;
import org.gcube.portlets.widgets.workspacesharingwidget.client.SimpleMultiDragWorkspaceContact;
import org.gcube.portlets.widgets.workspacesharingwidget.client.SimpleMultiDragWorkspaceContact.LOAD_CONTACTS_AS;
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.event.BaseEvent;
@ -311,7 +310,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
if(AppControllerExplorer.myLogin.compareToIgnoreCase(infoContactModel.getLogin())==0)
showAddAdministratorsDialog(file);
else
new MessageBoxAlert("Permission denied", "You have no permissions to add administrators. You are not manager of \""+file.getName()+"\"", null);
new MessageBoxAlert("Permission denied", "You have no permissions to manage administrators. You are not manager of \""+file.getName()+"\"", null);
}
});
@ -2110,60 +2109,73 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
*/
private void showAddAdministratorsDialog(final FileModel file) {
final org.gcube.portlets.widgets.workspacesharingwidget.shared.FileModel internalFile = new org.gcube.portlets.widgets.workspacesharingwidget.shared.FileModel(file.getIdentifier(), file.getName(), file.isDirectory());
SmartConstants.HEADER_TITLE = "Add Administrators to: "+file.getName();
SmartConstants.SHARE_WITH_USERS = "Manage with users";
SmartConstants.ERROR_NO_USER_SELECTED = "You must pick at least one user to add to Administrators";
SimpleMultiDragConstants.HEADING_DIALOG = "Edit Administrator/s to: "+file.getName();
SimpleMultiDragConstants.ALL_CONTACTS_LEFT_LIST = "All Contacts";
SimpleMultiDragConstants.SHARE_WITH_RIGHT_LIST = "New Administrator/s";
rpcWorkspaceService.getAdministratorsByFolderId(file.getIdentifier(), new AsyncCallback<List<InfoContactModel>>() {
final SimpleMultiDragWorkspaceContact multiDragContact = new SimpleMultiDragWorkspaceContact(LOAD_CONTACTS_AS.ADMINISTRATOR, file.getIdentifier(), true, false, true);
final Dialog multidrag = multiDragContact.getMultiDragContact();
multidrag.getButtonById(Dialog.OK).addListener(Events.Select, new Listener<BaseEvent>() {
@Override
public void onFailure(Throwable arg0) {
// TODO Auto-generated method stub
public void handleEvent(BaseEvent be) {
List<org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel> targets = multiDragContact.getTargetContactsWithMyLogin();
}
if(targets.size()==1){
MessageBox info = MessageBox.info("Any Administrator/s?", "You have not selected any Administrator, confirm exit?", null);
info.addCallback(new Listener<MessageBoxEvent>() {
@Override
public void onSuccess(List<InfoContactModel> admins) {
List<CredentialModel> alreadyAdmins = new ArrayList<CredentialModel>();
for (InfoContactModel contact : admins) {
alreadyAdmins.add(new CredentialModel(contact.getId(), contact.getLogin(), contact.isGroup()));
}
WorkspaceSmartSharingController controller = new WorkspaceSmartSharingController(internalFile, alreadyAdmins, false, false);
final SmartShare sharingWindow = controller.getSharingDialog();
sharingWindow.getButtonById(Dialog.OK).addListener(Events.Select, new Listener<BaseEvent>() {
@Override
public void handleEvent(BaseEvent be) {
if(sharingWindow.isValidForm(true)){
List<org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel> listUsers = sharingWindow.getSharedListUsers(); //@return the selected contacts (as InfoContactModel)
if(listUsers!=null && listUsers.size()>0){
List<String> logins = new ArrayList<String>(listUsers.size());
for (org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel infoContactModel : listUsers) {
logins.add(infoContactModel.getLogin());
}
doAddAdministratorToFolderId(file, logins);
public void handleEvent(MessageBoxEvent be) {
//IF NOT CANCELLED
String clickedButton = be.getButtonClicked().getItemId();
if(clickedButton.equals(Dialog.OK)){
multidrag.hide();
}
}
});
info.show();
}
if(targets.size()>1){
final List<String> logins = new ArrayList<String>(targets.size());
String names = "<ul>";
for (org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel infoContactModel : targets) {
logins.add(infoContactModel.getLogin());
names+="<li><i>"+infoContactModel.getName() +";</i></li>";
}
});
sharingWindow.show();
String tail = "</ul>as new ";
tail += logins.size()>1?"administrators":"administrator";
tail+= ", confirm?";
MessageBoxConfirm confirm = new MessageBoxConfirm("Setting new Administrator/s?", "You have selected: <br/>"+names +tail);
confirm.getMessageBoxConfirm().addCallback(new Listener<MessageBoxEvent>() {
public void handleEvent(MessageBoxEvent be) {
//IF NOT CANCELLED
String clickedButton = be.getButtonClicked().getItemId();
if(clickedButton.equals(Dialog.YES)){
doAddAdministratorToFolderId(file, logins);
multidrag.hide();
}
if(clickedButton.equals(Dialog.CANCEL)){
multidrag.hide();
}
}
});
}
}
});
multidrag.show();
}

View File

@ -317,6 +317,9 @@ public interface Icons extends ClientBundle {
@Source("icons/add_admin.png")
ImageResource addAdmin();
@Source("icons/admin_keys.png")
ImageResource manageAdmin();
@Source("icons/specialfolder2.png")
ImageResource specialFolder();

View File

@ -530,6 +530,13 @@ public class Resources {
public static AbstractImagePrototype getIconAddAdministrator() {
return AbstractImagePrototype.create(ICONS.addAdmin());
}
/**
* @return
*/
public static AbstractImagePrototype getIconManageAdministrator() {
return AbstractImagePrototype.create(ICONS.manageAdmin());
}
//ImageResources
public static ImageResource getImagePathSeparator(){

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -588,8 +588,8 @@ public class ContextMenuTree {
MenuItem addAdministrator = new MenuItem();
// addAdministrator.setId(WorkspaceOperation.ADD_ADMINISTRATOR.getId());
addAdministrator.setText("Add Administrator/s");
addAdministrator.setIcon(Resources.getIconAddAdministrator());
addAdministrator.setText("Manage Administrator/s");
addAdministrator.setIcon(Resources.getIconManageAdministrator());
addAdministrator.addSelectionListener(new SelectionListener<MenuEvent>() {
public void componentSelected(MenuEvent ce) {