Added code to remove a Folder Link

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@131423 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2016-09-15 16:07:32 +00:00
parent 9c1205118a
commit e55eb13007
9 changed files with 96 additions and 27 deletions

View File

@ -299,8 +299,9 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
// TODO Auto-generated method stub // TODO Auto-generated method stub
if(getFolderLinkEvent.getSourceFile()!=null){ if(getFolderLinkEvent.getSourceFile()!=null){
GWT.log("getFolderLinkEvent.getSourceFile() "+getFolderLinkEvent.getSourceFile()); GWT.log("getFolderLinkEvent.getSourceFile() "+getFolderLinkEvent.getSourceFile());
DialogGetLink dialog = new DialogGetLink("Copy to clipboard Folder Link: Ctrl+C", getFolderLinkEvent.getSourceFile(), Link_Type.FOLDER_LINK); DialogGetLink dialog = new DialogGetLink("Copy to clipboard Folder Link: Ctrl+C", getFolderLinkEvent.getSourceFile(), Link_Type.FOLDER_LINK, getFolderLinkEvent.isSetPublic());
dialog.show(); dialog.show();
} }
} }
}); });
@ -686,7 +687,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
public void onGetPublicLink(GetPublicLinkEvent getPublicLinkEvent) { public void onGetPublicLink(GetPublicLinkEvent getPublicLinkEvent) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
if(getPublicLinkEvent.getSourceFile()!=null){ if(getPublicLinkEvent.getSourceFile()!=null){
DialogGetLink dialog = new DialogGetLink("Copy to clipboard Public Link: Ctrl+C", getPublicLinkEvent.getSourceFile(), Link_Type.PUBLIC_LINK); DialogGetLink dialog = new DialogGetLink("Copy to clipboard Public Link: Ctrl+C", getPublicLinkEvent.getSourceFile(), Link_Type.PUBLIC_LINK, false);
dialog.show(); dialog.show();
} }
} }

View File

@ -70,6 +70,7 @@ public class ConstantsExplorer {
public static final String MESSAGE_GET_INFO = "Get Info"; public static final String MESSAGE_GET_INFO = "Get Info";
public static final String MESSAGE_PUBLIC_LINK = "Get Public Link"; public static final String MESSAGE_PUBLIC_LINK = "Get Public Link";
public static final String MESSAGE_FOLDER_LINK = "Get Folder Link"; public static final String MESSAGE_FOLDER_LINK = "Get Folder Link";
public static final String MESSAGE_FOLDER_LINK_REMOVE = "Remove Folder Link";
public static final String LISTATTACHMENTSNAMES = "Attachments Names"; public static final String LISTATTACHMENTSNAMES = "Attachments Names";
public static final String LISTCONTACTSTOSTRING = "ListContactToString"; public static final String LISTCONTACTSTOSTRING = "ListContactToString";
public static final String STATUS = "Status"; public static final String STATUS = "Status";
@ -216,6 +217,7 @@ public class ConstantsExplorer {
public static native void log(String txt) /*-{ public static native void log(String txt) /*-{
console.log(txt) console.log(txt)
}-*/; }-*/;

View File

@ -38,7 +38,8 @@ public enum WorkspaceOperation {
// ADD_ADMINISTRATOR("AAD", "AAD"), // ADD_ADMINISTRATOR // ADD_ADMINISTRATOR("AAD", "AAD"), // ADD_ADMINISTRATOR
VRE_CHANGE_PERIMISSIONS("CHP", "CHP"), VRE_CHANGE_PERIMISSIONS("CHP", "CHP"),
EDIT_PERMISSIONS("EDP", "EDP"), //EDIT PERMISSIONS EDIT_PERMISSIONS("EDP", "EDP"), //EDIT PERMISSIONS
FOLDER_LINK("FRL", "FRL"); //FOLDER LINK FOLDER_LINK("FRL", "FRL"), //FOLDER LINK
FOLDER_LINK_REMOVE("FPR","FPR"); //FOLDER LINK REMOVE
private String id; // ID CONTEXT MENU private String id; // ID CONTEXT MENU

View File

@ -1,45 +1,63 @@
package org.gcube.portlets.user.workspace.client.event; package org.gcube.portlets.user.workspace.client.event;
import org.gcube.portlets.user.workspace.client.model.FileModel; import org.gcube.portlets.user.workspace.client.model.FileModel;
import com.google.gwt.event.shared.GwtEvent; import com.google.gwt.event.shared.GwtEvent;
/** /**
* The Class GetFolderLinkEvent. * The Class GetFolderLinkEvent.
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Sep 13, 2016
* Sep 13, 2016
*/ */
public class GetFolderLinkEvent extends GwtEvent<GetFolderLinkEventHandler> { public class GetFolderLinkEvent extends GwtEvent<GetFolderLinkEventHandler> {
public static Type<GetFolderLinkEventHandler> TYPE = new Type<GetFolderLinkEventHandler>();
public static Type<GetFolderLinkEventHandler> TYPE =
new Type<GetFolderLinkEventHandler>();
private FileModel targetFile = null; private FileModel targetFile = null;
private boolean setPublic;
/** /**
* Instantiates a new gets the folder link event. * Instantiates a new gets the folder link event.
* *
* @param target the target * @param target
* the target
*/ */
public GetFolderLinkEvent(FileModel target) { public GetFolderLinkEvent(FileModel target, boolean setPublic) {
this.targetFile = target; this.targetFile = target;
this.setPublic = setPublic;
} }
/* (non-Javadoc)
/**
* @return the setPublic
*/
public boolean isSetPublic() {
return setPublic;
}
/*
* (non-Javadoc)
* @see com.google.gwt.event.shared.GwtEvent#getAssociatedType() * @see com.google.gwt.event.shared.GwtEvent#getAssociatedType()
*/ */
@Override @Override
public Type<GetFolderLinkEventHandler> getAssociatedType() { public Type<GetFolderLinkEventHandler> getAssociatedType() {
return TYPE; return TYPE;
} }
/* (non-Javadoc) /*
* @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler) * (non-Javadoc)
* @see
* com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared
* .EventHandler)
*/ */
@Override @Override
protected void dispatch(GetFolderLinkEventHandler handler) { protected void dispatch(GetFolderLinkEventHandler handler) {
handler.onGetFolderLink(this);
handler.onGetFolderLink(this);
} }
/** /**
@ -48,6 +66,7 @@ public class GetFolderLinkEvent extends GwtEvent<GetFolderLinkEventHandler> {
* @return the source file * @return the source file
*/ */
public FileModel getSourceFile() { public FileModel getSourceFile() {
return targetFile; return targetFile;
} }
} }

View File

@ -442,5 +442,8 @@ public interface Icons extends ClientBundle {
@Source("icons/folder_shared_public.png") @Source("icons/folder_shared_public.png")
ImageResource folderSharedPublic(); ImageResource folderSharedPublic();
@Source("icons/folder_public_remove.png")
ImageResource folderPublicRemove();
} }

View File

@ -1324,6 +1324,15 @@ public class Resources {
return AbstractImagePrototype.create(ICONS.permissions()); return AbstractImagePrototype.create(ICONS.permissions());
} }
/**
* Gets the icon folder public remove.
*
* @return the icon folder public remove
*/
public static AbstractImagePrototype getIconFolderPublicRemove() {
return AbstractImagePrototype.create(ICONS.folderPublicRemove());
}
/** /**
* Gets the icon add administrator. * Gets the icon add administrator.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1004 B

View File

@ -230,13 +230,32 @@ public class ContextMenuTree {
for (FileModel sel : listSelectedItems) { for (FileModel sel : listSelectedItems) {
if(sel.isDirectory()) if(sel.isDirectory())
eventBus.fireEvent(new GetFolderLinkEvent(sel)); eventBus.fireEvent(new GetFolderLinkEvent(sel, true));
} }
} }
}); });
contextMenu.add(mnFolderLink); contextMenu.add(mnFolderLink);
//FOLDER LINK REMOVE
MenuItem mnFolderLinkRemove = new MenuItem();
mnFolderLinkRemove.setId(WorkspaceOperation.FOLDER_LINK_REMOVE.getId());
mnFolderLinkRemove.setText(ConstantsExplorer.MESSAGE_FOLDER_LINK_REMOVE);
mnFolderLinkRemove.setIcon(Resources.getIconFolderPublicRemove());
mnFolderLinkRemove.addSelectionListener(new SelectionListener<MenuEvent>() {
public void componentSelected(MenuEvent ce) {
for (FileModel sel : listSelectedItems) {
if(sel.isDirectory())
eventBus.fireEvent(new GetFolderLinkEvent(sel, false));
}
}
});
contextMenu.add(mnFolderLinkRemove);
contextMenu.add(new SeparatorMenuItem()); contextMenu.add(new SeparatorMenuItem());
MenuItem mnHistory = new MenuItem(); MenuItem mnHistory = new MenuItem();
@ -808,6 +827,7 @@ public class ContextMenuTree {
contextMenu.getItemByItemId(WorkspaceOperation.REFRESH_FOLDER.getId()).setVisible(false); //refresh contextMenu.getItemByItemId(WorkspaceOperation.REFRESH_FOLDER.getId()).setVisible(false); //refresh
contextMenu.getItemByItemId(WorkspaceOperation.PUBLIC_LINK.getId()).setVisible(false); //public link contextMenu.getItemByItemId(WorkspaceOperation.PUBLIC_LINK.getId()).setVisible(false); //public link
contextMenu.getItemByItemId(WorkspaceOperation.FOLDER_LINK.getId()).setVisible(false); //folder link contextMenu.getItemByItemId(WorkspaceOperation.FOLDER_LINK.getId()).setVisible(false); //folder link
contextMenu.getItemByItemId(WorkspaceOperation.FOLDER_LINK_REMOVE.getId()).setVisible(false); //folder link remove
// contextMenu.getItemByItemId(WorkspaceOperation.ADD_ADMINISTRATOR.getId()).setVisible(false); //public link // contextMenu.getItemByItemId(WorkspaceOperation.ADD_ADMINISTRATOR.getId()).setVisible(false); //public link
contextMenu.getItemByItemId(WorkspaceOperation.EDIT_PERMISSIONS.getId()).setVisible(false); contextMenu.getItemByItemId(WorkspaceOperation.EDIT_PERMISSIONS.getId()).setVisible(false);
contextMenu.getItemByItemId(WorkspaceOperation.SHARE.getId()).setVisible(false); //SHARE contextMenu.getItemByItemId(WorkspaceOperation.SHARE.getId()).setVisible(false); //SHARE
@ -882,6 +902,9 @@ public class ContextMenuTree {
contextMenu.getItemByItemId(WorkspaceOperation.UNSHARE.getId()).setVisible(false); //UNSHARE contextMenu.getItemByItemId(WorkspaceOperation.UNSHARE.getId()).setVisible(false); //UNSHARE
} }
if(selectedItem.isPublic())
contextMenu.getItemByItemId(WorkspaceOperation.FOLDER_LINK_REMOVE.getId()).setVisible(true); //folder link
GWT.log("HideSharing = " + hideSharing); GWT.log("HideSharing = " + hideSharing);
//not supported in tree Reports //not supported in tree Reports
if (hideSharing) { if (hideSharing) {

View File

@ -16,6 +16,7 @@ import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.SelectionListener; import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.widget.Dialog; import com.extjs.gxt.ui.client.widget.Dialog;
import com.extjs.gxt.ui.client.widget.Label; import com.extjs.gxt.ui.client.widget.Label;
import com.extjs.gxt.ui.client.widget.MessageBox;
import com.extjs.gxt.ui.client.widget.VerticalPanel; import com.extjs.gxt.ui.client.widget.VerticalPanel;
import com.extjs.gxt.ui.client.widget.form.TextField; import com.extjs.gxt.ui.client.widget.form.TextField;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
@ -37,6 +38,7 @@ public class DialogGetLink extends Dialog {
private int height = 210; private int height = 210;
private VerticalPanel vp = new VerticalPanel(); private VerticalPanel vp = new VerticalPanel();
private FileModel item; private FileModel item;
private boolean setAsPublic = false;
/** /**
* The Enum Link_Type. * The Enum Link_Type.
@ -52,9 +54,11 @@ public class DialogGetLink extends Dialog {
* @param headingTxt the heading txt * @param headingTxt the heading txt
* @param item the item * @param item the item
* @param type the type * @param type the type
* @param setAsPublic the set as public
*/ */
public DialogGetLink(String headingTxt, final FileModel item, Link_Type type) { public DialogGetLink(String headingTxt, final FileModel item, Link_Type type, boolean setAsPublic) {
this.item = item; this.item = item;
this.setAsPublic = setAsPublic;
setButtonAlign(HorizontalAlignment.CENTER); setButtonAlign(HorizontalAlignment.CENTER);
vp.setHorizontalAlign(HorizontalAlignment.CENTER); vp.setHorizontalAlign(HorizontalAlignment.CENTER);
vp.setVerticalAlign(VerticalAlignment.MIDDLE); vp.setVerticalAlign(VerticalAlignment.MIDDLE);
@ -128,7 +132,7 @@ public class DialogGetLink extends Dialog {
case FOLDER_LINK: case FOLDER_LINK:
vp.mask("Getting Folder Link... checking permissions"); vp.mask("Updating Folder Link... checking permissions");
if(item.isShared()){ if(item.isShared()){
setIcon(Resources.getIconFolderSharedPublic()); setIcon(Resources.getIconFolderSharedPublic());
}else }else
@ -153,8 +157,10 @@ public class DialogGetLink extends Dialog {
public void onSuccess(InfoContactModel result) { public void onSuccess(InfoContactModel result) {
vp.unmask(); vp.unmask();
if(result.getLogin().compareToIgnoreCase(AppControllerExplorer.myLogin)==0){ if(result.getLogin().compareToIgnoreCase(AppControllerExplorer.myLogin)==0){
vp.mask("Getting Folder Link... permissions granted"); String msg = DialogGetLink.this.setAsPublic?"Getting":"Removing";
allowAccessToFolderLink(item.getIdentifier()); msg=msg+" Folder Link... permissions granted";
vp.mask(msg);
allowAccessToFolderLink(item.getIdentifier(), DialogGetLink.this.setAsPublic);
}else }else
new MessageBoxAlert("Permission Denied", "You have not permission to get Folder Link, you must be owner or administrator to the folder", null); new MessageBoxAlert("Permission Denied", "You have not permission to get Folder Link, you must be owner or administrator to the folder", null);
@ -186,19 +192,26 @@ public class DialogGetLink extends Dialog {
add(vp); add(vp);
} }
/** /**
* Allow access to folder link. * Allow access to folder link.
* *
* @param folderId the folder id * @param folderId the folder id
* @param setIsPublic the set is public
*/ */
private void allowAccessToFolderLink(String folderId){ protected void allowAccessToFolderLink(String folderId, final boolean setIsPublic){
AppControllerExplorer.rpcWorkspaceService.markFolderAsPublicForFolderItemId(folderId, true, new AsyncCallback<PublicLink>() { AppControllerExplorer.rpcWorkspaceService.markFolderAsPublicForFolderItemId(folderId, setIsPublic, new AsyncCallback<PublicLink>() {
@Override @Override
public void onSuccess(PublicLink publicLink) { public void onSuccess(PublicLink publicLink) {
if(!setIsPublic && publicLink==null){
DialogGetLink.this.hide();
MessageBox.info("Folder Link Removed", "Folder Link to the folder: "+item.getName()+ " removed correctly", null);
AppControllerExplorer.getEventBus().fireEvent(new RefreshFolderEvent(item.getParentFileModel(), true, false, false));
return;
}
vp.unmask(); vp.unmask();
txtCompleteURL.setValue(publicLink.getCompleteURL()); txtCompleteURL.setValue(publicLink.getCompleteURL());
txtShortURL.setValue(publicLink.getShortURL()); txtShortURL.setValue(publicLink.getShortURL());
@ -217,8 +230,6 @@ public class DialogGetLink extends Dialog {
new MessageBoxAlert("Error", caught.getMessage(), null); new MessageBoxAlert("Error", caught.getMessage(), null);
} }
}); });
} }
/** /**