diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/readonly.png b/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/readonly.png index eeb30c4..3ac2530 100644 Binary files a/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/readonly.png and b/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/readonly.png differ diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/writeall.png b/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/writeall.png index 799acc1..4bf3501 100644 Binary files a/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/writeall.png and b/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/writeall.png differ diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/writeown.png b/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/writeown.png index 5562d5f..692722a 100644 Binary files a/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/writeown.png and b/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/writeown.png differ diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java index d2d796b..0fde68e 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java @@ -201,4 +201,6 @@ public interface GWTWorkspaceService extends RemoteService{ String getMyLogin(); + void setACLForVRE(String folderId, String aclType) throws Exception; + } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java index 0ab0222..0c3b7b4 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java @@ -179,4 +179,7 @@ public interface GWTWorkspaceServiceAsync { void getMyLogin(AsyncCallback callback); + void setACLForVRE(String folderId, String aclType, + AsyncCallback callback); + } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/DialogPermission.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/DialogPermission.java deleted file mode 100644 index 0a1f433..0000000 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/DialogPermission.java +++ /dev/null @@ -1,157 +0,0 @@ -package org.gcube.portlets.user.workspace.client.view.sharing; - -import java.util.ArrayList; -import java.util.List; - -import org.gcube.portlets.user.workspace.client.AppControllerExplorer; -import org.gcube.portlets.user.workspace.client.model.FileModel; -import org.gcube.portlets.user.workspace.client.model.InfoContactModel; -import org.gcube.portlets.user.workspace.client.resources.Resources; -import org.gcube.portlets.user.workspace.client.view.sharing.multisuggest.MultiValuePanel; -import org.gcube.portlets.user.workspace.shared.WorkspaceACL; - -import com.extjs.gxt.ui.client.Style.HorizontalAlignment; -import com.extjs.gxt.ui.client.Style.Scroll; -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.layout.FormLayout; -import com.google.gwt.event.shared.HandlerManager; -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.gwt.user.client.ui.Label; - -/** - * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it - * - */ -public class DialogPermission extends Dialog { - - private int widthDialog = 530; - private FileModel parentFolder = null; - private UserStore userStore = new UserStore(); - private MultiValuePanel suggestPanel = new MultiValuePanel(userStore); - private PanelPermission panelPermission; - private DialogPermission INSTANCE = this; - private List listAlreadyShared = new ArrayList(){ - - /** - * - */ - 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; - - }; - - - }; - - - public FileModel getParentFolder() { - return parentFolder; - } - - public void initLayout(String folderParentName){ - 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(200); - setResizable(true); - setButtonAlign(HorizontalAlignment.CENTER); - setWidth(widthDialog); - setButtons(Dialog.OKCANCEL); - } - - /** - * Use to create a new shared folder - */ - public DialogPermission(String folderParentName, HandlerManager eventBus) { - - AppControllerExplorer.rpcWorkspaceService.getACLs(new AsyncCallback>() { - - @Override - public void onSuccess(List result) { - panelPermission = new PanelPermission(result); - INSTANCE.layout(true); - } - - @Override - public void onFailure(Throwable caught) { - - INSTANCE.add(new Label("Error on recovering ACLs")); - } - }); - - initLayout(folderParentName); - this.setIcon(Resources.getIconSharedFolder()); - setHeading("Set permission to folder: "+folderParentName); - - setWidth(widthDialog); - setButtons(Dialog.OKCANCEL); - - add(panelPermission); - addListners(); - } - - public void addListners(){ - - this.getButtonById(Dialog.CANCEL).addSelectionListener(new SelectionListener() { - - @Override - public void componentSelected(ButtonEvent ce) { - hide(); - } - }); - - - this.getButtonById(Dialog.OK).addSelectionListener(new SelectionListener() { - - @Override - public void componentSelected(ButtonEvent ce) { - if(isValidForm(false)) - hide(); - } - }); - - } - - /** - * - * @param displayAlert - * @return - */ - public boolean isValidForm(boolean displayAlert){ - - /* - if(getSharedListUsers().size()==0){ - if(displayAlert) - new MessageBoxAlert("Attention", "You must pick at least one user with which share the folder", null); - suggestPanel.boxSetFocus(); - return false; - }*/ - - return true; - - } -} diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/DialogShareFolder.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/DialogShareFolder.java index ff3bcab..9cad4bd 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/DialogShareFolder.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/DialogShareFolder.java @@ -15,10 +15,13 @@ import org.gcube.portlets.user.workspace.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.VerticalPanel; 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; @@ -46,8 +49,9 @@ public class DialogShareFolder extends Dialog { private MultiValuePanel suggestPanel = new MultiValuePanel(userStore); private Button buttonMultiDrag = new Button("Choose Contacts"); private TextField txtOwner; - private PanelPermission permission; - + private PanelTogglePermission permission; + private HorizontalPanel vpPermission = null; + private List listAlreadyShared = new ArrayList(){ /** @@ -138,33 +142,44 @@ public class DialogShareFolder extends Dialog { flexTable.setWidget(2, 0, labelDescription); flexTable.setWidget(2, 1, textAreaDescription); - + if(!folder.isShared()){ //SETTABLE PERMISSION ONLY IF FOLDER IS NOT ALREADY SHARED + vpPermission = new HorizontalPanel(); + vpPermission.setVerticalAlign(VerticalAlignment.MIDDLE); Label labelProperty = new Label("Permissions"); -// final ToggleButton togglePermission = new ToggleButton("Set Permissions"); - flexTable.setWidget(3, 0, labelProperty); +// final ToggleButton togglePermission = new ToggleButton("Set Permissions"); +// flexTable.setWidget(3, 0, labelProperty); - flexTable.setWidget(3, 1, Resources.getIconLoading().createImage()); +// flexTable.setWidget(3, 1, Resources.getIconLoading().createImage()); + vpPermission.add(labelProperty); AppControllerExplorer.rpcWorkspaceService.getACLs(new AsyncCallback>() { @Override public void onSuccess(List result) { - permission = new PanelPermission(result); - flexTable.setWidget(3, 1, permission); - lc.layout(); + permission = new PanelTogglePermission(result); +// flexTable.setWidget(3, 1, permission); +// lc.layout(); + vpPermission.add(permission); + vpPermission.layout(); + layout(); } @Override public void onFailure(Throwable caught) { - flexTable.setWidget(3, 1, new Label("Error on recovering ACLs")); +// flexTable.setWidget(3, 1, new Label("Error on recovering ACLs")); + + vpPermission.add(new Label("Error on recovering ACLs")); + vpPermission.layout(); + layout(); } }); } lc.add(flexTable); - + if(vpPermission!=null) + lc.add(vpPermission); lc.mask(); userStore.getListSharedUserByFolderId(folder.getIdentifier(), new AsyncCallback>() { @@ -301,34 +316,45 @@ public class DialogShareFolder extends Dialog { flexTable.setWidget(2, 1, textAreaDescription); + vpPermission = new HorizontalPanel(); + vpPermission.setVerticalAlign(VerticalAlignment.MIDDLE); Label labelProperty = new Label("Permissions"); // final ToggleButton togglePermission = new ToggleButton("Set Permissions"); - flexTable.setWidget(3, 0, labelProperty); +// flexTable.setWidget(3, 0, labelProperty); - flexTable.setWidget(3, 1, Resources.getIconLoading().createImage()); +// flexTable.setWidget(3, 1, Resources.getIconLoading().createImage()); + vpPermission.add(labelProperty); AppControllerExplorer.rpcWorkspaceService.getACLs(new AsyncCallback>() { @Override public void onSuccess(List result) { - permission = new PanelPermission(result); - flexTable.setWidget(3, 1, permission); - lc.layout(); + permission = new PanelTogglePermission(result); +// flexTable.setWidget(3, 1, permission); +// lc.layout(); + vpPermission.add(permission); + vpPermission.layout(); + layout(); } @Override public void onFailure(Throwable caught) { - flexTable.setWidget(3, 1, new Label("Error on recovering ACLs")); +// flexTable.setWidget(3, 1, new Label("Error on recovering ACLs")); + + vpPermission.add(new Label("Error on recovering ACLs")); + vpPermission.layout(); + layout(); } }); lc.add(flexTable); - + setFocusWidget(txtName); add(txtName); add(lc); + addListners(); this.show(); diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/PanelTogglePermission.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/PanelTogglePermission.java index 5792444..9ce6748 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/PanelTogglePermission.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/PanelTogglePermission.java @@ -1,5 +1,6 @@ package org.gcube.portlets.user.workspace.client.view.sharing; +import java.util.ArrayList; import java.util.List; import org.gcube.portlets.user.workspace.client.resources.Resources; @@ -8,6 +9,7 @@ import org.gcube.portlets.user.workspace.shared.WorkspaceACL.USER_TYPE; import com.extjs.gxt.ui.client.Style.ButtonScale; import com.extjs.gxt.ui.client.Style.IconAlign; +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.HorizontalPanel; @@ -27,38 +29,38 @@ public class PanelTogglePermission extends LayoutContainer { public PanelTogglePermission(List acls) { - setStyleAttribute("margin-top", "10px"); - setStyleAttribute("margin-bottom", "10px"); - setSize(350, 30); +// setStyleAttribute("margin-top", "10px"); + setStyleAttribute("margin-bottom", "15px"); + setSize(350, 40); -// buttonGroup = new ButtonGroup(acls.size()); - -// buttonGroup.mask("Loading ACLs"); hp.mask("Loading ACLs"); - + hp.setVerticalAlign(VerticalAlignment.MIDDLE); + hp.setStyleAttribute("padding-left", "35px"); + for (WorkspaceACL acl : acls) { - if(acl.getUserType().equals(USER_TYPE.OTHER)){ ToggleButton toggle = createToggle(acl); toggle.setToggleGroup(WORKSPACEACLGROUP); - toggle.setStyleAttribute("margin-right", "5px"); + toggle.setStyleAttribute("margin-right", "10px"); // buttonGroup.add(toggle); +// listToogle.add(toggle); +// add(toggle); hp.add(toggle); } } hp.unmask(); -// buttonGroup.unmask(); add(hp); + layout(); } private ToggleButton createToggle(final WorkspaceACL acl) { final ToggleButton bToggle = new ToggleButton(acl.getLabel()); - bToggle.setScale(ButtonScale.LARGE); + bToggle.setScale(ButtonScale.MEDIUM); bToggle.setId(acl.getId()); bToggle.toggle(acl.getDefaultValue()); - bToggle.setIconAlign(IconAlign.BOTTOM); + bToggle.setIconAlign(IconAlign.TOP); bToggle.addSelectionListener(new SelectionListener() { @Override diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/ToggleButtonPanel.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/ToggleButtonPanel.java new file mode 100644 index 0000000..727fdb6 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/ToggleButtonPanel.java @@ -0,0 +1,121 @@ +package org.gcube.portlets.user.workspace.client.view.sharing; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.event.dom.client.HasClickHandlers; +import com.google.gwt.event.shared.HandlerRegistration; +import com.google.gwt.user.client.ui.Composite; +import com.google.gwt.user.client.ui.HasWidgets; +import com.google.gwt.user.client.ui.Panel; +import com.google.gwt.user.client.ui.ToggleButton; +import com.google.gwt.user.client.ui.VerticalPanel; +import com.google.gwt.user.client.ui.Widget; + +/** + * + * @author francesco + * + */ +public class ToggleButtonPanel extends Composite implements HasWidgets, HasClickHandlers { + + private List handlers = new ArrayList(); + private final Panel panel; + + public ToggleButtonPanel() { + this(new VerticalPanel()); + } + + public ToggleButtonPanel(Panel panel) { + this.panel = panel; + initWidget(panel); + } + + @Override + public void add(Widget w) { + if (w instanceof ToggleButton) { + ToggleButton button = (ToggleButton) w; + button.addClickHandler(handler); + } + panel.add(w); + } + + @Override + public void clear() { + panel.clear(); + } + + @Override + public Iterator iterator() { + return panel.iterator(); + } + + @Override + public boolean remove(Widget w) { + return panel.remove(w); + } + + @Override + public void setWidth(String width) { + panel.setWidth(width); + }; + + @Override + public void setHeight(String height) { + panel.setHeight(height); + } + + + private ClickHandler handler = new ClickHandler() { + @Override + public void onClick(ClickEvent event) { + Iterator itr = panel.iterator(); + while (itr.hasNext()) { + Widget w = itr.next(); + if (w instanceof ToggleButton) { + ToggleButton button = (ToggleButton) w; + button.setDown(false); + if (event.getSource().equals(button)) { + button.setDown(true); + } + } + } + + for (ClickHandler h : handlers) { + h.onClick(event); + } + } + }; + + + + @Override + public HandlerRegistration addClickHandler(final ClickHandler handler) { + handlers.add(handler); + return new HandlerRegistration() { + + @Override + public void removeHandler() { + handlers.remove(handler); + } + }; + } + + public ToggleButton getDown(){ + + Iterator it = iterator(); + while (it!=null && it.hasNext()) { + Widget w = (Widget) it.next(); + if (w instanceof ToggleButton) { + ToggleButton t = (ToggleButton) w; + if(t.isDown()) + return t; + } + } + return null; + } + +} diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java index 9f8c49f..ca28e50 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java @@ -2553,4 +2553,41 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT ASLSession asl = WsUtil.getAslSession(this.getThreadLocalRequest().getSession()); return asl.getUsername(); } + + /** + * + * @param folderId + * @param listUserIds + * @param aclType + * @throws Exception + */ + @Override + public void setACLForVRE(String folderId, String aclType) throws Exception{ + try { + + if(folderId == null) + throw new Exception("Folder id is null"); + + List listLogins = new ArrayList(); + listLogins.add(getMyLogin()); + + workspaceLogger.trace("Setting ACL for VRE FOLDER id: "+folderId); + workspaceLogger.trace("ACL type is: "+aclType); + + Workspace workspace = getWorkspace(); + WorkspaceItem wsItem = workspace.getItem(folderId); + + if(wsItem.isShared() && (wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER))){ + WorkspaceSharedFolder ite = (WorkspaceSharedFolder) workspace.getItemByPath(wsItem.getPath()); + ite.setACL(listLogins, ACLType.valueOf(aclType)); + }else + throw new Exception("Source item is not shared or shared folder"); + + workspaceLogger.trace("Setting ACL completed, retuning"); + } catch (Exception e) { + workspaceLogger.error("Error in set ACLs", e); + String error = ConstantsExplorer.SERVER_ERROR +" setting permissions. "+e.getMessage(); + throw new Exception(error); + } + } }