first version of public link is completed
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@77840 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
084947fcb9
commit
f7e6efb2bb
|
@ -42,6 +42,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.GetPublicLinkEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.GetPublicLinkEventHandler;
|
||||
import org.gcube.portlets.user.workspace.client.event.GetShareLinkEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.GetSharedLinkEventHandler;
|
||||
import org.gcube.portlets.user.workspace.client.event.ImagePreviewEvent;
|
||||
|
@ -106,6 +108,7 @@ import org.gcube.portlets.user.workspace.client.view.windows.DialogAddFolderAndS
|
|||
import org.gcube.portlets.user.workspace.client.view.windows.DialogAddFolderAndSmart.AddType;
|
||||
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.DialogPublicLink;
|
||||
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;
|
||||
|
@ -441,7 +444,20 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
eventBus.addHandler(GetPublicLinkEvent.TYPE, new GetPublicLinkEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onGetPublicLink(GetPublicLinkEvent getPublicLinkEvent) {
|
||||
// TODO Auto-generated method stub
|
||||
if(getPublicLinkEvent.getSourceFile()!=null){
|
||||
DialogPublicLink dialog = new DialogPublicLink("Copy to clipboard Public Link: Ctrl+C", getPublicLinkEvent.getSourceFile().getIdentifier());
|
||||
dialog.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
eventBus.addHandler(RefreshFolderEvent.TYPE, new RefreshItemEventHandler() {
|
||||
|
||||
|
|
|
@ -61,6 +61,7 @@ public class ConstantsExplorer {
|
|||
public static final String PASTEITEM = "Paste";
|
||||
public static final String MESSAGE_REFRESH_FOLDER = "Refresh Folder";
|
||||
public static final String MESSAGE_GET_INFO = "Get Info";
|
||||
public static final String MESSAGE_PUBLIC_LINK = "Get Public Link";
|
||||
public static final String LISTATTACHMENTSNAMES = "Attachments Names";
|
||||
public static final String LISTCONTACTSTOSTRING = "ListContactToString";
|
||||
public static final String STATUS = "Status";
|
||||
|
@ -205,4 +206,5 @@ public class ConstantsExplorer {
|
|||
public static final String UPLOAD_TYPE = "uploadType";
|
||||
public static final String ID_FOLDER = "idFolder";
|
||||
public static final String UPLOAD_FORM_ELEMENT = "uploadFormElement";
|
||||
|
||||
}
|
||||
|
|
|
@ -32,7 +32,8 @@ public enum WorkspaceOperation {
|
|||
GET_INFO("GTI", "GTI"), // GET INFO
|
||||
HISTORY("HST", "HST"), //HISTORY
|
||||
ACCREAD("ACR", "ACR"), //ACCOUNTING READ
|
||||
SHARE_LINK("SLK", "SLK"); //SHARE URL LINK
|
||||
SHARE_LINK("SLK", "SLK"), //SHARE URL LINK
|
||||
PUBLIC_LINK("PLK", "PLK"); //PUBLIC LINK
|
||||
|
||||
|
||||
// //ID CONTEXT MENU
|
||||
|
|
|
@ -280,5 +280,8 @@ public interface Icons extends ClientBundle {
|
|||
|
||||
@Source("icons/sharelink.png")
|
||||
ImageResource shareLink();
|
||||
|
||||
@Source("icons/public-link.png")
|
||||
ImageResource publicLink();
|
||||
}
|
||||
|
||||
|
|
|
@ -410,6 +410,10 @@ public class Resources {
|
|||
return AbstractImagePrototype.create(ICONS.replyMail());
|
||||
}
|
||||
|
||||
public static AbstractImagePrototype getIconPublicLink() {
|
||||
return AbstractImagePrototype.create(ICONS.publicLink());
|
||||
}
|
||||
|
||||
public static AbstractImagePrototype getIconReplyAllMail() {
|
||||
return AbstractImagePrototype.create(ICONS.replyAllMail());
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 913 B |
|
@ -17,6 +17,7 @@ import org.gcube.portlets.user.workspace.client.event.FileDownloadEvent.Download
|
|||
import org.gcube.portlets.user.workspace.client.event.FileUploadEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.FileUploadEvent.UploadType;
|
||||
import org.gcube.portlets.user.workspace.client.event.GetInfoEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.GetPublicLinkEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.GetShareLinkEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.ImagePreviewEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.OpenReportsEvent;
|
||||
|
@ -184,6 +185,24 @@ public class ContextMenuTree {
|
|||
});
|
||||
|
||||
contextMenu.add(mnGetLink);
|
||||
contextMenu.add(new SeparatorMenuItem());
|
||||
|
||||
//PUBLIC LINK
|
||||
MenuItem mnPublicLink = new MenuItem();
|
||||
mnPublicLink.setId(WorkspaceOperation.PUBLIC_LINK.getId());
|
||||
mnPublicLink.setText(ConstantsExplorer.MESSAGE_PUBLIC_LINK);
|
||||
mnPublicLink.setIcon(Resources.getIconPublicLink());
|
||||
|
||||
mnPublicLink.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||
public void componentSelected(MenuEvent ce) {
|
||||
|
||||
for (FileModel sel : listSelectedItems) {
|
||||
eventBus.fireEvent(new GetPublicLinkEvent(sel));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
contextMenu.add(mnPublicLink);
|
||||
|
||||
contextMenu.add(new SeparatorMenuItem());
|
||||
|
||||
|
@ -655,7 +674,7 @@ public class ContextMenuTree {
|
|||
contextMenu.getItemByItemId(WorkspaceOperation.OPEN_REPORT_TEMPLATE.getId()).setVisible(false); //open report template
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.PASTE.getId()).setEnabled(false); //paste
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.REFRESH_FOLDER.getId()).setVisible(false); //refresh
|
||||
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.PUBLIC_LINK.getId()).setVisible(false); //public link
|
||||
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.SHARE.getId()).setVisible(false); //SHARE
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.UNSHARE.getId()).setVisible(false); //UNSHARE
|
||||
|
@ -710,10 +729,13 @@ public class ContextMenuTree {
|
|||
|
||||
case EXTERNAL_IMAGE:
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.PREVIEW.getId()).setVisible(true);
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.PUBLIC_LINK.getId()).setVisible(true); //public link
|
||||
break;
|
||||
case EXTERNAL_FILE:
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.PUBLIC_LINK.getId()).setVisible(true); //public link
|
||||
break;
|
||||
case EXTERNAL_PDF_FILE:
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.PUBLIC_LINK.getId()).setVisible(true); //public link
|
||||
break;
|
||||
case EXTERNAL_URL:
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.LINK.getId()).setVisible(true);
|
||||
|
|
|
@ -0,0 +1,107 @@
|
|||
package org.gcube.portlets.user.workspace.client.view.windows;
|
||||
|
||||
import org.gcube.portlets.user.workspace.client.AppControllerExplorer;
|
||||
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;
|
||||
import com.extjs.gxt.ui.client.event.SelectionListener;
|
||||
import com.extjs.gxt.ui.client.widget.Dialog;
|
||||
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.google.gwt.dom.client.Style.Unit;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
||||
/**
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
*/
|
||||
public class DialogPublicLink extends Dialog {
|
||||
|
||||
private TextField<String> txt;
|
||||
private int widht = 450;
|
||||
private int height = 150;
|
||||
private VerticalPanel vp = new VerticalPanel();
|
||||
// private Label label = new Label();
|
||||
|
||||
public DialogPublicLink(String headingTxt, final String itemId) {
|
||||
setButtonAlign(HorizontalAlignment.CENTER);
|
||||
setIcon(Resources.getIconShareLink());
|
||||
vp.setHorizontalAlign(HorizontalAlignment.CENTER);
|
||||
vp.setVerticalAlign(VerticalAlignment.MIDDLE);
|
||||
vp.getElement().getStyle().setPadding(1, Unit.PX);
|
||||
setHeading(headingTxt);
|
||||
setModal(true);
|
||||
setBodyStyle("padding: 3px; background: none");
|
||||
setWidth(widht);
|
||||
setHeight(height);
|
||||
setResizable(false);
|
||||
setButtons(Dialog.CLOSE);
|
||||
|
||||
// label.setText(msgTitle);
|
||||
// label.setStyleName("myWebDavStyle");
|
||||
|
||||
txt = new TextArea();
|
||||
// txt.setStyleAttribute("padding-top", "3px");
|
||||
txt.setWidth(widht-20);
|
||||
txt.setHeight(height-74);
|
||||
// txt.setFieldLabel(msgTitle);
|
||||
|
||||
txt.setReadOnly(true);
|
||||
|
||||
|
||||
txt.mask("Shorting link...");
|
||||
|
||||
if(itemId!=null && !itemId.isEmpty()){
|
||||
AppControllerExplorer.rpcWorkspaceService.getPublicLinkForFolderItemId(itemId, true, new AsyncCallback<String>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(String url) {
|
||||
txt.unmask();
|
||||
txt.setValue(url);
|
||||
selectTxt();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
txt.unmask();
|
||||
new MessageBoxAlert("Error", caught.getMessage(), null);
|
||||
}
|
||||
});
|
||||
|
||||
}else{
|
||||
txt.unmask();
|
||||
new MessageBoxAlert("Error", "The item identifier is null", null);
|
||||
}
|
||||
|
||||
this.getButtonById(Dialog.CLOSE).addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||
|
||||
@Override
|
||||
public void componentSelected(ButtonEvent ce) {
|
||||
hide();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
// vp.add(label);
|
||||
vp.add(txt);
|
||||
|
||||
setFocusWidget(txt);
|
||||
add(vp);
|
||||
}
|
||||
|
||||
public String getTxtValue() {
|
||||
|
||||
return txt.getValue();
|
||||
}
|
||||
|
||||
public void selectTxt(){
|
||||
|
||||
if(txt.getValue()!=null)
|
||||
txt.select(0, txt.getValue().length());
|
||||
}
|
||||
}
|
|
@ -52,6 +52,7 @@ import org.gcube.portlets.user.workspace.server.notifications.NotificationsProdu
|
|||
import org.gcube.portlets.user.workspace.server.notifications.NotificationsUtil;
|
||||
import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameter;
|
||||
import org.gcube.portlets.user.workspace.server.shortener.UrlShortener;
|
||||
import org.gcube.portlets.user.workspace.server.util.StringUtil;
|
||||
import org.gcube.portlets.user.workspace.server.util.UserUtil;
|
||||
import org.gcube.portlets.user.workspace.server.util.WsUtil;
|
||||
import org.gcube.portlets.user.workspace.server.util.scope.ScopeUtilFilter;
|
||||
|
@ -2253,7 +2254,12 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|||
String uriRequest = "";
|
||||
|
||||
if(uriResolver!=null && uriResolver.isAvailable()){
|
||||
uriRequest = uriResolver.resolveAsUriRequest(smpUri, folderItem.getName(), folderItem.getMimeType(), true);
|
||||
|
||||
String itemName = StringUtil.removeSpecialCharacters(folderItem.getName());
|
||||
|
||||
itemName = StringUtil.replaceAllWhiteSpace(itemName, "_");
|
||||
uriRequest = uriResolver.resolveAsUriRequest(smpUri, itemName, folderItem.getMimeType(), true);
|
||||
|
||||
if(shortenUrl)
|
||||
return getShortUrl(uriRequest);
|
||||
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.workspace.server.util;
|
||||
|
||||
/**
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* @Jul 9, 2013
|
||||
*
|
||||
*/
|
||||
public class StringUtil {
|
||||
|
||||
public static String regx = ",@+^'?!\"%&$£/#()";
|
||||
|
||||
|
||||
public static String removeSpecialCharacters(String input) {
|
||||
|
||||
char[] ca = regx.toCharArray();
|
||||
for (char c : ca) {
|
||||
input = input.replace(""+c, "");
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String input = "Just to clarify, Iì13ì? will have strings of varying "
|
||||
+ "lengths. I want to strip characters from it, the exact "
|
||||
+ "ones to be determined at !\"%&$£/ runtime, and return the "
|
||||
+ "resulting string...";
|
||||
|
||||
input = removeSpecialCharacters(input);
|
||||
System.out.println(input);
|
||||
System.out.println(replaceAllWhiteSpace(input, "_"));
|
||||
|
||||
}
|
||||
|
||||
public static String replaceAllWhiteSpace(String input, String replacement){
|
||||
return input.replaceAll("\\s",replacement);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue