integrated CLARIN Switchboard

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@171440 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2018-09-13 15:56:23 +00:00
parent 48b24a8116
commit 94df00cc01
10 changed files with 131 additions and 47 deletions

View File

@ -15,6 +15,8 @@ import com.google.gwt.i18n.client.NumberFormat;
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
*/
public class ConstantsExplorer {
public static final String CLARIN_SWITCHBOARD_ENDPOINT = "https://weblicht.sfs.uni-tuebingen.de/clrs/#/d4science/";
public static final String PARTHENOS_GATEWAY_HOST_NAME = "parthenos.d4science.org";
// public static final String FILE_SERVICE = GWT.getModuleBaseURL() + "fileservice";
public static final String RPC_WORKSPACE_SERVICE = GWT.getModuleBaseURL() + "rpcWorkspace";
@ -44,7 +46,8 @@ public class ConstantsExplorer {
public static final String MESSAGE_ADD_FOLDER = "New Folder";
public static final String MESSAGE_ADD_SHARED_FOLDER = "New Shared Folder";
public static final String MESSAGE_DATA_CATALOGUE_PUBLISH = "Publish on Catalogue";
public static final String MESSAGE_THREDDS_PUBLISH = "Sync with Thredds";
public static final String MESSAGE_THREDDS_PUBLISH = "Sync with THREDDS";
public static final String MESSAGE_CLARIN_SWITCHBOARD = "Send to Switchboard";
public static final String MESSAGE_ADD = "Add";
public static final String MESSAGE_ADD_FOLDER_IN = "Create a new folder in: ";
public static final String MESSAGE_ITEM_NAME = "Item Name";

View File

@ -0,0 +1,23 @@
package org.gcube.portlets.user.workspace.client;
import com.google.gwt.core.client.JavaScriptObject;
public class MyWindow extends JavaScriptObject {
// All types that extend JavaScriptObject must have a protected,
// no-args constructor.
protected MyWindow() {}
public final static native MyWindow open(String url, String target, String options) /*-{
return $wnd.open(url, target, options);
}-*/;
public final native void close() /*-{
this.close();
}-*/;
public final native void setUrl(String url) /*-{
if (this.location) {
this.location = url;
}
}-*/;
}

View File

@ -36,7 +36,8 @@ public enum WorkspaceOperation {
FOLDER_LINK("FRL", "FRL"), // FOLDER LINK
FOLDER_LINK_REMOVE("FPR", "FPR"),
VERSIONING("VRN", "VRN"), // VERSIONING
EXECUTE_DM_TASK("EDT", "EDT"); //EXECUTE DM TASK
EXECUTE_DM_TASK("EDT", "EDT"), //EXECUTE DM TASK
SEND_TO_SWITCHBOARD("SDSB", "SDSB"); //SEND_TO_SWITCHBOARD
private String id; // ID CONTEXT MENU
private String name;

View File

@ -4,7 +4,9 @@ import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.ImageResource;
public interface Icons extends ClientBundle {
@Source("icons/CLARIN_SB.png")
ImageResource switchboard();
@Source("icons/table.png")
ImageResource table();
@ -437,7 +439,7 @@ public interface Icons extends ClientBundle {
/**
* @return
*/
@Source("icons/thredds.gif")
@Source("icons/THREDDS.png")
ImageResource thredds();
/**

View File

@ -90,6 +90,16 @@ public class Resources {
return AbstractImagePrototype.create(ICONS.datacataloguepublish());
}
/**
* Gets the data catalogue publish.
*
* @return the data catalogue publish
*/
public static AbstractImagePrototype getIconSendToSwitchboard(){
return AbstractImagePrototype.create(ICONS.switchboard());
}
/**

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 749 B

View File

@ -6,6 +6,7 @@ import java.util.List;
import org.gcube.portlets.user.workspace.client.AppControllerExplorer;
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
import org.gcube.portlets.user.workspace.client.ConstantsExplorer.WS_UPLOAD_TYPE;
import org.gcube.portlets.user.workspace.client.MyWindow;
import org.gcube.portlets.user.workspace.client.constant.WorkspaceOperation;
import org.gcube.portlets.user.workspace.client.event.AccountingHistoryEvent;
import org.gcube.portlets.user.workspace.client.event.AccountingReadersEvent;
@ -30,6 +31,7 @@ import org.gcube.portlets.user.workspace.client.event.PasteItemEvent;
import org.gcube.portlets.user.workspace.client.event.PublishOnDataCatalogueEvent;
import org.gcube.portlets.user.workspace.client.event.RefreshFolderEvent;
import org.gcube.portlets.user.workspace.client.event.RenameItemEvent;
import org.gcube.portlets.user.workspace.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.workspace.client.event.SyncWithThreddsCatalogueEvent;
import org.gcube.portlets.user.workspace.client.event.UnShareFolderEvent;
import org.gcube.portlets.user.workspace.client.event.VRESettingPermissionEvent;
@ -38,7 +40,11 @@ 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.util.FileModelUtils;
import org.gcube.portlets.user.workspace.client.util.RequestBuilderWorkspaceValidateItem;
import org.gcube.portlets.user.workspace.client.view.tree.CutCopyAndPaste.OperationType;
import org.gcube.portlets.user.workspace.client.view.windows.MessageBoxAlert;
import org.gcube.portlets.user.workspace.shared.PublicLink;
import org.gcube.portlets.user.workspace.shared.SessionExpiredException;
import org.gcube.portlets.user.workspace.shared.WorkspaceVersioningOperation;
import com.extjs.gxt.ui.client.event.MenuEvent;
@ -49,6 +55,8 @@ import com.extjs.gxt.ui.client.widget.menu.MenuItem;
import com.extjs.gxt.ui.client.widget.menu.SeparatorMenuItem;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.http.client.RequestBuilder;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
/**
@ -65,7 +73,8 @@ public class ContextMenuTree {
private MenuItem mnRead = new MenuItem();
private boolean hideSharing = false;
//tells if you're on PARTHENOS Gateway or not
private boolean showCLARINSwitchBoardOption = false;
/**
* Instantiates a new context menu tree.
*/
@ -73,7 +82,6 @@ public class ContextMenuTree {
this.contextMenu.setWidth(200);
this.listSelectedItems = new ArrayList<FileModel>();
createContextMenu();
}
@ -81,6 +89,12 @@ public class ContextMenuTree {
* Creates the context menu.
*/
private void createContextMenu() {
//PARTHENOS GATEWAY CASE Show CLARIN SwitchBoard
if (ConstantsExplorer.PARTHENOS_GATEWAY_HOST_NAME.compareToIgnoreCase(Window.Location.getHostName()) == 0) {
showCLARINSwitchBoardOption = true;
}
//SPECIFIC OPERATION
//Preview Image
@ -313,6 +327,36 @@ public class ContextMenuTree {
});
contextMenu.add(createShareFolder);
//Add Url
MenuItem addUrl = new MenuItem();
addUrl.setId(WorkspaceOperation.ADD_URL.getId());
addUrl.setText(ConstantsExplorer.MESSAGE_ADD_URL);
addUrl.setIcon(Resources.getIconAddUrl());
addUrl.addSelectionListener(new SelectionListener<MenuEvent>() {
public void componentSelected(MenuEvent ce) {
FileModel selected = listSelectedItems.get(0);
FileModel parent = selected.getParentFileModel();
if(parent==null){
if(selected.isDirectory()){
parent = selected;
}
}
//FileModel parent = getDirectoryOrParent(selected);
if(parent!=null){
eventBus.fireEvent(new CreateUrlEvent(null, parent));
}
}
});
contextMenu.add(addUrl);
contextMenu.add(new SeparatorMenuItem());
// publish on data catalogue
MenuItem publishOnDataCatalogue = new MenuItem();
publishOnDataCatalogue.setId(WorkspaceOperation.PUBLISH_ON_DATA_CATALOGUE.getId());
@ -349,7 +393,7 @@ public class ContextMenuTree {
publishOnThredds.setVisible(false);
contextMenu.add(publishOnThredds);
// publish on data catalogue
// executre DM task
MenuItem executeDMTask = new MenuItem();
executeDMTask.setId(WorkspaceOperation.EXECUTE_DM_TASK.getId());
executeDMTask.setText(ConstantsExplorer.MESSAGE_EXECUTE_DM_TASK);
@ -367,6 +411,41 @@ public class ContextMenuTree {
executeDMTask.setVisible(false);
contextMenu.add(executeDMTask);
//send to Switchboard
MenuItem sendToSwitchboard = new MenuItem();
sendToSwitchboard.setId(WorkspaceOperation.SEND_TO_SWITCHBOARD.getId());
sendToSwitchboard.setText(ConstantsExplorer.MESSAGE_CLARIN_SWITCHBOARD);
sendToSwitchboard.setIcon(Resources.getIconSendToSwitchboard());
sendToSwitchboard.addSelectionListener(new SelectionListener<MenuEvent>() {
public void componentSelected(MenuEvent ce) {
FileModel sourceFileModel = listSelectedItems.get(0);
if (sourceFileModel != null) {
final MyWindow window = MyWindow.open(null, "_blank", null);
AppControllerExplorer.rpcWorkspaceService.getPublicLinkForFolderItemId(sourceFileModel.getIdentifier(), true, new AsyncCallback<PublicLink>() {
@Override
public void onSuccess(PublicLink publicLink) {
String encodedURI = com.google.gwt.http.client.URL.encodeQueryString(publicLink.getCompleteURL());
//Window.open(ConstantsExplorer.CLARIN_SWITCHBOARD_ENDPOINT+encodedURI,"_blank","");
window.setUrl(ConstantsExplorer.CLARIN_SWITCHBOARD_ENDPOINT+encodedURI);
}
@Override
public void onFailure(Throwable caught) {
if(caught instanceof SessionExpiredException){
GWT.log("Session expired");
AppControllerExplorer.getEventBus().fireEvent(new SessionExpiredEvent());
return;
}
new MessageBoxAlert("Error", caught.getMessage(), null);
window.close();
}
});
}
}
});
sendToSwitchboard.setVisible(false);
contextMenu.add(sendToSwitchboard);
MenuItem editPermissions = new MenuItem();
editPermissions.setId(WorkspaceOperation.EDIT_PERMISSIONS.getId());
@ -386,33 +465,6 @@ public class ContextMenuTree {
contextMenu.add(editPermissions);
//Add Url
MenuItem addUrl = new MenuItem();
addUrl.setId(WorkspaceOperation.ADD_URL.getId());
addUrl.setText(ConstantsExplorer.MESSAGE_ADD_URL);
addUrl.setIcon(Resources.getIconAddUrl());
addUrl.addSelectionListener(new SelectionListener<MenuEvent>() {
public void componentSelected(MenuEvent ce) {
FileModel selected = listSelectedItems.get(0);
FileModel parent = selected.getParentFileModel();
if(parent==null){
if(selected.isDirectory()){
parent = selected;
}
}
//FileModel parent = getDirectoryOrParent(selected);
if(parent!=null){
eventBus.fireEvent(new CreateUrlEvent(null, parent));
}
}
});
contextMenu.add(addUrl);
contextMenu.add(new SeparatorMenuItem());
MenuItem copy = new MenuItem();
@ -765,18 +817,6 @@ public class ContextMenuTree {
contextMenu.showAt(posX, posY);
}
/**
* Prints the selected.
*/
private void printSelected(){
for (FileModel sel: listSelectedItems) {
GWT.log("selected " +sel.getName() );
}
}
/**
* switch visible operation on context menu according to selected item.
*
@ -891,7 +931,12 @@ public class ContextMenuTree {
else{
contextMenu.getItemByItemId(WorkspaceOperation.SHOW.getId()).setVisible(true);
contextMenu.getItemByItemId(WorkspaceOperation.EXECUTE_DM_TASK.getId()).setVisible(true);
/*
* we show the send to CLARIN SwitchBoard if and only if the file is a txt file and showCLARINSwitchBoardOption is true
*/
contextMenu.getItemByItemId(WorkspaceOperation.SEND_TO_SWITCHBOARD.getId()).setVisible(selectedItem.getName().endsWith(".txt") && showCLARINSwitchBoardOption);
switch(selectedItem.getGXTFolderItemType()){
case EXTERNAL_IMAGE: