#1504 add copy link, implemented
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@76867 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
47ecdfd3e6
commit
c40b026dc3
|
@ -41,6 +41,8 @@ import org.gcube.portlets.user.workspace.client.event.FilterScopeEvent;
|
|||
import org.gcube.portlets.user.workspace.client.event.FilterScopeEventHandler;
|
||||
import org.gcube.portlets.user.workspace.client.event.GetInfoEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.GetInfoEventHandler;
|
||||
import org.gcube.portlets.user.workspace.client.event.GetShareLinkEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.GetLinkEventHandler;
|
||||
import org.gcube.portlets.user.workspace.client.event.ImagePreviewEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.ImagePreviewEventHandler;
|
||||
import org.gcube.portlets.user.workspace.client.event.MoveItemEvent;
|
||||
|
@ -99,9 +101,9 @@ import org.gcube.portlets.user.workspace.client.view.tree.AsyncTreePanel;
|
|||
import org.gcube.portlets.user.workspace.client.view.windows.BulkCreatorWindow;
|
||||
import org.gcube.portlets.user.workspace.client.view.windows.DialogAddFolderAndSmart;
|
||||
import org.gcube.portlets.user.workspace.client.view.windows.DialogAddFolderAndSmart.AddType;
|
||||
import org.gcube.portlets.user.workspace.client.view.windows.accounting.WindowAccountingInfo;
|
||||
import org.gcube.portlets.user.workspace.client.view.windows.DialogAddUrl;
|
||||
import org.gcube.portlets.user.workspace.client.view.windows.DialogGetInfo;
|
||||
import org.gcube.portlets.user.workspace.client.view.windows.DialogShareLink;
|
||||
import org.gcube.portlets.user.workspace.client.view.windows.DialogText;
|
||||
import org.gcube.portlets.user.workspace.client.view.windows.DialogUpload;
|
||||
import org.gcube.portlets.user.workspace.client.view.windows.DialogWebDavUrl;
|
||||
|
@ -111,6 +113,7 @@ import org.gcube.portlets.user.workspace.client.view.windows.MessageBoxConfirm;
|
|||
import org.gcube.portlets.user.workspace.client.view.windows.MessageBoxInfo;
|
||||
import org.gcube.portlets.user.workspace.client.view.windows.WindowImagePreview;
|
||||
import org.gcube.portlets.user.workspace.client.view.windows.WindowOpenUrl;
|
||||
import org.gcube.portlets.user.workspace.client.view.windows.accounting.WindowAccountingInfo;
|
||||
import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceItem;
|
||||
import org.gcube.portlets.user.workspace.client.workspace.folder.item.GWTExternalImage;
|
||||
import org.gcube.portlets.user.workspace.client.workspace.folder.item.GWTExternalUrl;
|
||||
|
@ -403,6 +406,33 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
|||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
eventBus.addHandler(GetShareLinkEvent.TYPE, new GetLinkEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onGetLink(GetShareLinkEvent getLinkEvent) {
|
||||
|
||||
if(getLinkEvent.getSourceFile()!=null){
|
||||
|
||||
String currentUrl = portalURL();
|
||||
|
||||
int lastChar = currentUrl.lastIndexOf("?");
|
||||
|
||||
currentUrl = lastChar>-1?currentUrl.substring(0, lastChar):currentUrl; //IF EXISTS - REMOVE STRING AFTER ? (? INLCUSE)
|
||||
|
||||
// int last = currentUrl.lastIndexOf("/");
|
||||
// String shareLinkUrl = currentUrl.substring(0,last+1) + "?" +ConstantsExplorer.GET_ITEMID_PARAMETER+"="+getLinkEvent.getSourceFile().getIdentifier();
|
||||
String shareLinkUrl = currentUrl+ "?" +ConstantsExplorer.GET_ITEMID_PARAMETER+"="+getLinkEvent.getSourceFile().getIdentifier();
|
||||
|
||||
|
||||
DialogShareLink dialog = new DialogShareLink("Copy to clipboard Share Link: Ctrl+C", shareLinkUrl);
|
||||
dialog.show();
|
||||
dialog.selectTxt();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
eventBus.addHandler(RefreshFolderEvent.TYPE, new RefreshItemEventHandler() {
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ public class ConstantsExplorer {
|
|||
public static final String MESSAGE_ERROR_OCCURED = "Sorry an error has occurred while processing your request";
|
||||
public static final String INFO = "Info";
|
||||
public static final String MESSAGE_SEND_TO_OK = "Your message has been successfully delivered";
|
||||
public static final String MESSAGE_SHARE_LINK = "Share Link";
|
||||
public static final String COPYITEM = "Copy";
|
||||
public static final String PASTEITEM = "Paste";
|
||||
public static final String MESSAGE_REFRESH_FOLDER = "Refresh Folder";
|
||||
|
@ -184,7 +185,8 @@ public class ConstantsExplorer {
|
|||
public static final NumberFormat numberFormatterKB = NumberFormat.getFormat("#,##0 KB;(#,##0 KB)");
|
||||
|
||||
|
||||
|
||||
//USED IN HTTP GET AS PARAMETER
|
||||
public static final String GET_ITEMID_PARAMETER ="itemid";
|
||||
|
||||
|
||||
public enum ViewSwitchType {Tree, SmartFolder, Messages};
|
||||
|
|
|
@ -31,7 +31,8 @@ public enum WorkspaceOperation {
|
|||
WEBDAV_URL("WDV", "WDV"), // WebDav
|
||||
GET_INFO("GTI", "GTI"), // GET INFO
|
||||
HISTORY("HST", "HST"), //HISTORY
|
||||
ACCREAD("ACR", "ACR"); //ACCOUNTING READ
|
||||
ACCREAD("ACR", "ACR"), //ACCOUNTING READ
|
||||
SHARE_LINK("SLK", "SLK"); //SHARE URL LINK
|
||||
|
||||
|
||||
// //ID CONTEXT MENU
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
package org.gcube.portlets.user.workspace.client.event;
|
||||
|
||||
import com.google.gwt.event.shared.EventHandler;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
*/
|
||||
public interface GetLinkEventHandler extends EventHandler {
|
||||
/**
|
||||
* @param getLinkEvent
|
||||
*/
|
||||
void onGetLink(GetShareLinkEvent getLinkEvent);
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package org.gcube.portlets.user.workspace.client.event;
|
||||
|
||||
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
*/
|
||||
public class GetShareLinkEvent extends GwtEvent<GetLinkEventHandler> {
|
||||
public static Type<GetLinkEventHandler> TYPE = new Type<GetLinkEventHandler>();
|
||||
|
||||
private FileModel targetFile = null;
|
||||
|
||||
public GetShareLinkEvent(FileModel target) {
|
||||
this.targetFile = target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type<GetLinkEventHandler> getAssociatedType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dispatch(GetLinkEventHandler handler) {
|
||||
handler.onGetLink(this);
|
||||
|
||||
}
|
||||
|
||||
public FileModel getSourceFile() {
|
||||
return targetFile;
|
||||
}
|
||||
}
|
|
@ -277,5 +277,8 @@ public interface Icons extends ClientBundle {
|
|||
|
||||
@Source("icons/new_create.png")
|
||||
ImageResource createNew();
|
||||
|
||||
@Source("icons/sharelink.png")
|
||||
ImageResource shareLink();
|
||||
}
|
||||
|
||||
|
|
|
@ -44,6 +44,11 @@ public class Resources {
|
|||
return AbstractImagePrototype.create(ICONS.table());
|
||||
}
|
||||
|
||||
public static AbstractImagePrototype getIconShareLink(){
|
||||
|
||||
return AbstractImagePrototype.create(ICONS.shareLink());
|
||||
}
|
||||
|
||||
public static AbstractImagePrototype getIconCreateNew(){
|
||||
|
||||
return AbstractImagePrototype.create(ICONS.createNew());
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 495 B |
|
@ -28,6 +28,7 @@ import org.gcube.portlets.user.workspace.client.event.UnShareFolderEvent;
|
|||
import org.gcube.portlets.user.workspace.client.event.WebDavUrlEvent;
|
||||
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||
import org.gcube.portlets.user.workspace.client.resources.Resources;
|
||||
import org.gcube.portlets.user.workspace.client.event.GetShareLinkEvent;
|
||||
|
||||
import com.extjs.gxt.ui.client.event.MenuEvent;
|
||||
import com.extjs.gxt.ui.client.event.SelectionListener;
|
||||
|
@ -166,6 +167,24 @@ public class ContextMenuTree {
|
|||
|
||||
contextMenu.add(mnGetInfo);
|
||||
|
||||
|
||||
//SHARE LINK
|
||||
MenuItem mnGetLink = new MenuItem();
|
||||
mnGetLink.setId(WorkspaceOperation.SHARE_LINK.getId());
|
||||
mnGetLink.setText(ConstantsExplorer.MESSAGE_SHARE_LINK);
|
||||
mnGetLink.setIcon(Resources.getIconShareLink());
|
||||
|
||||
mnGetLink.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||
public void componentSelected(MenuEvent ce) {
|
||||
|
||||
for (FileModel sel : listSelectedItems) {
|
||||
eventBus.fireEvent(new GetShareLinkEvent(sel));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
contextMenu.add(mnGetLink);
|
||||
|
||||
contextMenu.add(new SeparatorMenuItem());
|
||||
|
||||
MenuItem mnHistory = new MenuItem();
|
||||
|
@ -624,7 +643,6 @@ public class ContextMenuTree {
|
|||
contextMenu.getItemByItemId(WorkspaceOperation.UPLOAD_ARCHIVE.getId()).setVisible(true);
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.ADD_URL.getId()).setVisible(true);
|
||||
|
||||
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.PREVIEW.getId()).setVisible(false); //preview image
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.LINK.getId()).setVisible(false); //open link
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.SHOW.getId()).setVisible(false); //show
|
||||
|
@ -635,6 +653,8 @@ public class ContextMenuTree {
|
|||
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.SHARE.getId()).setVisible(false); //SHARE
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.UNSHARE.getId()).setVisible(false); //UNSHARE
|
||||
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.SHARE_LINK.getId()).setVisible(false); //SHARE
|
||||
|
||||
//ACCOUNTINGS
|
||||
if(selectedItem.isMarkAsRead()){
|
||||
|
@ -646,13 +666,22 @@ public class ContextMenuTree {
|
|||
mnRead.setIcon(Resources.getIconNotRead());
|
||||
}
|
||||
|
||||
if(selectedItem.isShared()){ //SHARE LINK ON SHARED ITEM
|
||||
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.SHARE_LINK.getId()).setVisible(true);
|
||||
}
|
||||
|
||||
if(selectedItem.isDirectory()){
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.SHARE.getId()).setVisible(true); //SHARE
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.SHOW.getId()).setVisible(false); //show
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.REFRESH_FOLDER.getId()).setVisible(true); //refresh
|
||||
if(selectedItem.isShared() && selectedItem.isShareable()){ //IS SHARED and SHARABLE
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.INSERT_SHARED_FOLDER.getId()).setVisible(false); //insert shared folder
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.UNSHARE.getId()).setVisible(true);
|
||||
if(selectedItem.isShared()){//IS SHARED
|
||||
|
||||
if(selectedItem.isShareable()){ //IS SHARABLE
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.INSERT_SHARED_FOLDER.getId()).setVisible(false); //insert shared folder
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.UNSHARE.getId()).setVisible(true);
|
||||
}
|
||||
|
||||
}else if(selectedItem.isRoot()){ //IS ROOT
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.SHARE.getId()).setVisible(false); //SHARE
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.INSERT_SHARED_FOLDER.getId()).setVisible(true); //insert shared folder
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.gcube.portlets.user.workspace.client.view.windows;
|
||||
|
||||
import org.gcube.portlets.user.workspace.client.resources.Resources;
|
||||
|
||||
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
|
||||
import com.extjs.gxt.ui.client.Style.VerticalAlignment;
|
||||
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
||||
|
@ -14,32 +16,36 @@ import com.google.gwt.dom.client.Style.Unit;
|
|||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
*/
|
||||
public class DialogGetLink extends Dialog {
|
||||
public class DialogShareLink extends Dialog {
|
||||
|
||||
private TextField<String> txt;
|
||||
private int widht = 500;
|
||||
private int height = 200;
|
||||
private int widht = 450;
|
||||
private int height = 150;
|
||||
private VerticalPanel vp = new VerticalPanel();
|
||||
// private Label label = new Label();
|
||||
|
||||
public DialogGetLink(String headingTxt, String msgTitle, String urlValue) {
|
||||
|
||||
public DialogShareLink(String headingTxt, String urlValue) {
|
||||
setButtonAlign(HorizontalAlignment.CENTER);
|
||||
|
||||
setIcon(Resources.getIconShareLink());
|
||||
vp.setHorizontalAlign(HorizontalAlignment.CENTER);
|
||||
vp.setVerticalAlign(VerticalAlignment.MIDDLE);
|
||||
vp.getElement().getStyle().setPadding(5, Unit.PX);
|
||||
vp.getElement().getStyle().setPadding(1, Unit.PX);
|
||||
setHeading(headingTxt);
|
||||
setModal(true);
|
||||
setBodyStyle("padding: 9px; background: none");
|
||||
setBodyStyle("padding: 3px; background: none");
|
||||
setWidth(widht);
|
||||
setHeight(height);
|
||||
setResizable(false);
|
||||
setButtons(Dialog.OK);
|
||||
|
||||
// label.setText(msgTitle);
|
||||
// label.setStyleName("myWebDavStyle");
|
||||
|
||||
txt = new TextArea();
|
||||
txt.setStyleAttribute("padding-top", "20px");
|
||||
txt.setWidth(widht-30);
|
||||
txt.setFieldLabel(msgTitle);
|
||||
// txt.setStyleAttribute("padding-top", "3px");
|
||||
txt.setWidth(widht-20);
|
||||
txt.setHeight(height-74);
|
||||
// txt.setFieldLabel(msgTitle);
|
||||
txt.setValue(urlValue);
|
||||
txt.setReadOnly(true);
|
||||
|
||||
|
@ -52,14 +58,12 @@ public class DialogGetLink extends Dialog {
|
|||
|
||||
});
|
||||
|
||||
setFocusWidget(txt);
|
||||
txt.selectAll();
|
||||
|
||||
|
||||
// vp.add(label);
|
||||
vp.add(txt);
|
||||
|
||||
setFocusWidget(txt);
|
||||
add(vp);
|
||||
|
||||
this.show();
|
||||
}
|
||||
|
||||
public String getTxtValue() {
|
Loading…
Reference in New Issue