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:
parent
9c1205118a
commit
e55eb13007
|
@ -299,8 +299,9 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
|||
// TODO Auto-generated method stub
|
||||
if(getFolderLinkEvent.getSourceFile()!=null){
|
||||
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();
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -686,7 +687,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
|||
public void onGetPublicLink(GetPublicLinkEvent getPublicLinkEvent) {
|
||||
// TODO Auto-generated method stub
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,6 +70,7 @@ public class ConstantsExplorer {
|
|||
public static final String MESSAGE_GET_INFO = "Get Info";
|
||||
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_REMOVE = "Remove Folder Link";
|
||||
public static final String LISTATTACHMENTSNAMES = "Attachments Names";
|
||||
public static final String LISTCONTACTSTOSTRING = "ListContactToString";
|
||||
public static final String STATUS = "Status";
|
||||
|
@ -216,6 +217,7 @@ public class ConstantsExplorer {
|
|||
|
||||
|
||||
|
||||
|
||||
public static native void log(String txt) /*-{
|
||||
console.log(txt)
|
||||
}-*/;
|
||||
|
|
|
@ -38,7 +38,8 @@ public enum WorkspaceOperation {
|
|||
// ADD_ADMINISTRATOR("AAD", "AAD"), // ADD_ADMINISTRATOR
|
||||
VRE_CHANGE_PERIMISSIONS("CHP", "CHP"),
|
||||
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
|
||||
|
|
|
@ -1,45 +1,63 @@
|
|||
|
||||
package org.gcube.portlets.user.workspace.client.event;
|
||||
|
||||
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
|
||||
|
||||
/**
|
||||
* The Class GetFolderLinkEvent.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Sep 13, 2016
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Sep 13, 2016
|
||||
*/
|
||||
public class GetFolderLinkEvent extends GwtEvent<GetFolderLinkEventHandler> {
|
||||
public static Type<GetFolderLinkEventHandler> TYPE = new Type<GetFolderLinkEventHandler>();
|
||||
|
||||
private FileModel targetFile = null;
|
||||
public static Type<GetFolderLinkEventHandler> TYPE =
|
||||
new Type<GetFolderLinkEventHandler>();
|
||||
private FileModel targetFile = null;
|
||||
private boolean setPublic;
|
||||
|
||||
/**
|
||||
* 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.setPublic = setPublic;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
/**
|
||||
* @return the setPublic
|
||||
*/
|
||||
public boolean isSetPublic() {
|
||||
|
||||
return setPublic;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see com.google.gwt.event.shared.GwtEvent#getAssociatedType()
|
||||
*/
|
||||
@Override
|
||||
public Type<GetFolderLinkEventHandler> getAssociatedType() {
|
||||
|
||||
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
|
||||
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
|
||||
*/
|
||||
public FileModel getSourceFile() {
|
||||
|
||||
return targetFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -439,8 +439,11 @@ public interface Icons extends ClientBundle {
|
|||
|
||||
@Source("icons/folder_public.png")
|
||||
ImageResource folderPublic();
|
||||
|
||||
|
||||
@Source("icons/folder_shared_public.png")
|
||||
ImageResource folderSharedPublic();
|
||||
|
||||
@Source("icons/folder_public_remove.png")
|
||||
ImageResource folderPublicRemove();
|
||||
}
|
||||
|
||||
|
|
|
@ -1324,6 +1324,15 @@ public class Resources {
|
|||
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.
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1004 B |
|
@ -230,13 +230,32 @@ public class ContextMenuTree {
|
|||
|
||||
for (FileModel sel : listSelectedItems) {
|
||||
if(sel.isDirectory())
|
||||
eventBus.fireEvent(new GetFolderLinkEvent(sel));
|
||||
eventBus.fireEvent(new GetFolderLinkEvent(sel, true));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
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());
|
||||
|
||||
MenuItem mnHistory = new MenuItem();
|
||||
|
@ -808,6 +827,7 @@ public class ContextMenuTree {
|
|||
contextMenu.getItemByItemId(WorkspaceOperation.REFRESH_FOLDER.getId()).setVisible(false); //refresh
|
||||
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_REMOVE.getId()).setVisible(false); //folder link remove
|
||||
// contextMenu.getItemByItemId(WorkspaceOperation.ADD_ADMINISTRATOR.getId()).setVisible(false); //public link
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.EDIT_PERMISSIONS.getId()).setVisible(false);
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.SHARE.getId()).setVisible(false); //SHARE
|
||||
|
@ -882,6 +902,9 @@ public class ContextMenuTree {
|
|||
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);
|
||||
//not supported in tree Reports
|
||||
if (hideSharing) {
|
||||
|
|
|
@ -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.widget.Dialog;
|
||||
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.form.TextField;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
|
@ -37,6 +38,7 @@ public class DialogGetLink extends Dialog {
|
|||
private int height = 210;
|
||||
private VerticalPanel vp = new VerticalPanel();
|
||||
private FileModel item;
|
||||
private boolean setAsPublic = false;
|
||||
|
||||
/**
|
||||
* The Enum Link_Type.
|
||||
|
@ -52,9 +54,11 @@ public class DialogGetLink extends Dialog {
|
|||
* @param headingTxt the heading txt
|
||||
* @param item the item
|
||||
* @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.setAsPublic = setAsPublic;
|
||||
setButtonAlign(HorizontalAlignment.CENTER);
|
||||
vp.setHorizontalAlign(HorizontalAlignment.CENTER);
|
||||
vp.setVerticalAlign(VerticalAlignment.MIDDLE);
|
||||
|
@ -128,7 +132,7 @@ public class DialogGetLink extends Dialog {
|
|||
|
||||
case FOLDER_LINK:
|
||||
|
||||
vp.mask("Getting Folder Link... checking permissions");
|
||||
vp.mask("Updating Folder Link... checking permissions");
|
||||
if(item.isShared()){
|
||||
setIcon(Resources.getIconFolderSharedPublic());
|
||||
}else
|
||||
|
@ -153,8 +157,10 @@ public class DialogGetLink extends Dialog {
|
|||
public void onSuccess(InfoContactModel result) {
|
||||
vp.unmask();
|
||||
if(result.getLogin().compareToIgnoreCase(AppControllerExplorer.myLogin)==0){
|
||||
vp.mask("Getting Folder Link... permissions granted");
|
||||
allowAccessToFolderLink(item.getIdentifier());
|
||||
String msg = DialogGetLink.this.setAsPublic?"Getting":"Removing";
|
||||
msg=msg+" Folder Link... permissions granted";
|
||||
vp.mask(msg);
|
||||
allowAccessToFolderLink(item.getIdentifier(), DialogGetLink.this.setAsPublic);
|
||||
}else
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Allow access to folder link.
|
||||
*
|
||||
* @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
|
||||
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();
|
||||
txtCompleteURL.setValue(publicLink.getCompleteURL());
|
||||
txtShortURL.setValue(publicLink.getShortURL());
|
||||
|
@ -217,8 +230,6 @@ public class DialogGetLink extends Dialog {
|
|||
new MessageBoxAlert("Error", caught.getMessage(), null);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue