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.FileUploadCompleteEventHandler;
import org.gcube.portlets.widgets.fileupload.client.events.FileUploadSelectedEvent; import org.gcube.portlets.widgets.fileupload.client.events.FileUploadSelectedEvent;
import org.gcube.portlets.widgets.fileupload.client.events.FileUploadSelectedEventHandler; import org.gcube.portlets.widgets.fileupload.client.events.FileUploadSelectedEventHandler;
import org.gcube.portlets.widgets.workspacesharingwidget.client.SmartConstants; import org.gcube.portlets.widgets.workspacesharingwidget.client.SimpleMultiDragConstants;
import org.gcube.portlets.widgets.workspacesharingwidget.client.WorkspaceSmartSharingController; import org.gcube.portlets.widgets.workspacesharingwidget.client.SimpleMultiDragWorkspaceContact;
import org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.SmartShare; import org.gcube.portlets.widgets.workspacesharingwidget.client.SimpleMultiDragWorkspaceContact.LOAD_CONTACTS_AS;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.CredentialModel;
import com.extjs.gxt.ui.client.Registry; import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.event.BaseEvent; 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) if(AppControllerExplorer.myLogin.compareToIgnoreCase(infoContactModel.getLogin())==0)
showAddAdministratorsDialog(file); showAddAdministratorsDialog(file);
else 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) { 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()); SimpleMultiDragConstants.HEADING_DIALOG = "Edit Administrator/s to: "+file.getName();
SimpleMultiDragConstants.ALL_CONTACTS_LEFT_LIST = "All Contacts";
SimpleMultiDragConstants.SHARE_WITH_RIGHT_LIST = "New Administrator/s";
SmartConstants.HEADER_TITLE = "Add Administrators to: "+file.getName(); final SimpleMultiDragWorkspaceContact multiDragContact = new SimpleMultiDragWorkspaceContact(LOAD_CONTACTS_AS.ADMINISTRATOR, file.getIdentifier(), true, false, true);
SmartConstants.SHARE_WITH_USERS = "Manage with users"; final Dialog multidrag = multiDragContact.getMultiDragContact();
SmartConstants.ERROR_NO_USER_SELECTED = "You must pick at least one user to add to Administrators";
rpcWorkspaceService.getAdministratorsByFolderId(file.getIdentifier(), new AsyncCallback<List<InfoContactModel>>() { multidrag.getButtonById(Dialog.OK).addListener(Events.Select, new Listener<BaseEvent>() {
@Override
public void onFailure(Throwable arg0) {
// TODO Auto-generated method stub
}
@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 @Override
public void handleEvent(BaseEvent be) { public void handleEvent(BaseEvent be) {
List<org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel> targets = multiDragContact.getTargetContactsWithMyLogin();
if(sharingWindow.isValidForm(true)){ if(targets.size()==1){
MessageBox info = MessageBox.info("Any Administrator/s?", "You have not selected any Administrator, confirm exit?", null);
List<org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel> listUsers = sharingWindow.getSharedListUsers(); //@return the selected contacts (as InfoContactModel) info.addCallback(new Listener<MessageBoxEvent>() {
if(listUsers!=null && listUsers.size()>0){ public void handleEvent(MessageBoxEvent be) {
//IF NOT CANCELLED
String clickedButton = be.getButtonClicked().getItemId();
if(clickedButton.equals(Dialog.OK)){
multidrag.hide();
}
}
});
List<String> logins = new ArrayList<String>(listUsers.size()); info.show();
}
for (org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel infoContactModel : listUsers) { 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()); logins.add(infoContactModel.getLogin());
names+="<li><i>"+infoContactModel.getName() +";</i></li>";
} }
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); doAddAdministratorToFolderId(file, logins);
multidrag.hide();
} }
if(clickedButton.equals(Dialog.CANCEL)){
multidrag.hide();
} }
} }
}); });
sharingWindow.show(); }
} }
}); });
multidrag.show();
} }

View File

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

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

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