added get info completed
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@71690 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
bc643e20c2
commit
95a8de8def
|
@ -35,6 +35,8 @@ import org.gcube.portlets.user.workspace.client.event.FileUploadEvent.UploadType
|
|||
import org.gcube.portlets.user.workspace.client.event.FileUploadEventHandler;
|
||||
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.ImagePreviewEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.ImagePreviewEventHandler;
|
||||
import org.gcube.portlets.user.workspace.client.event.MoveItemEvent;
|
||||
|
@ -94,6 +96,7 @@ 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.DialogAddUrl;
|
||||
import org.gcube.portlets.user.workspace.client.view.windows.DialogGetInfo;
|
||||
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;
|
||||
|
@ -200,6 +203,14 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
|||
}
|
||||
});
|
||||
|
||||
eventBus.addHandler(GetInfoEvent.TYPE, new GetInfoEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onGetInfo(GetInfoEvent getInfoEvent) {
|
||||
new DialogGetInfo(getInfoEvent.getSourceFile());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
eventBus.addHandler(CreateSharedFolderEvent.TYPE, new CreateSharedFolderEventHandler() {
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.gcube.portlets.user.workspace.client;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.i18n.client.NumberFormat;
|
||||
|
||||
/**
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
|
@ -53,6 +54,7 @@ public class ConstantsExplorer {
|
|||
public static final String COPYITEM = "Copy";
|
||||
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 LISTATTACHMENTSNAMES = "Attachments Names";
|
||||
public static final String LISTCONTACTSTOSTRING = "ListContactToString";
|
||||
public static final String STATUS = "Status";
|
||||
|
@ -146,6 +148,7 @@ public class ConstantsExplorer {
|
|||
public static final String RFH = "RFH"; //Refresh
|
||||
public static final String WDV = "WDV"; //WebDav
|
||||
public static final String CNM = "CNM"; //Create new message
|
||||
public static final String GTI = "GTI"; //GET INFO
|
||||
|
||||
//ID CONTEXT MENU IN GRID
|
||||
public static final String OPM = "OPM"; //Open message
|
||||
|
@ -194,6 +197,7 @@ public class ConstantsExplorer {
|
|||
public static final Object NONE = "None";
|
||||
public static final String ABSTRACTICON = "Abstract Icon";
|
||||
|
||||
public static final NumberFormat numberFormatterKB = NumberFormat.getFormat("#,##0 KB;(#,##0 KB)");
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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 GetInfoEvent extends GwtEvent<GetInfoEventHandler> {
|
||||
public static Type<GetInfoEventHandler> TYPE = new Type<GetInfoEventHandler>();
|
||||
|
||||
private FileModel targetFile = null;
|
||||
|
||||
public GetInfoEvent(FileModel target) {
|
||||
this.targetFile = target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type<GetInfoEventHandler> getAssociatedType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dispatch(GetInfoEventHandler handler) {
|
||||
handler.onGetInfo(this);
|
||||
|
||||
}
|
||||
|
||||
public FileModel getSourceFile() {
|
||||
return targetFile;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
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 GetInfoEventHandler extends EventHandler {
|
||||
void onGetInfo(GetInfoEvent getInfoEvent);
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package org.gcube.portlets.user.workspace.client.rpc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.user.workspace.client.model.BulkCreatorModel;
|
||||
|
@ -121,4 +122,8 @@ public interface GWTWorkspaceService extends RemoteService{
|
|||
List<InfoContactModel> getListUserSharedBySharedItem(String sharedItemId)
|
||||
throws Exception;
|
||||
|
||||
Date getItemCreationDateById(String itemId) throws Exception;
|
||||
|
||||
Long loadSizeByItemId(String itemId) throws Exception;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.gcube.portlets.user.workspace.client.rpc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.user.workspace.client.model.BulkCreatorModel;
|
||||
|
@ -128,5 +129,10 @@ public interface GWTWorkspaceServiceAsync {
|
|||
void getListUserSharedBySharedItem(String sharedItemId,
|
||||
AsyncCallback<List<InfoContactModel>> callback);
|
||||
|
||||
void getItemCreationDateById(String itemId,
|
||||
AsyncCallback<Date> asyncCallback);
|
||||
|
||||
void loadSizeByItemId(String itemId, AsyncCallback<Long> asyncCallback);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import org.gcube.portlets.user.workspace.client.event.FileDownloadEvent;
|
|||
import org.gcube.portlets.user.workspace.client.event.FileDownloadEvent.DownloadType;
|
||||
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.ImagePreviewEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.OpenReportsEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.OpenUrlEvent;
|
||||
|
@ -25,8 +26,12 @@ 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 com.extjs.gxt.ui.client.Style.ButtonArrowAlign;
|
||||
import com.extjs.gxt.ui.client.Style.ButtonScale;
|
||||
import com.extjs.gxt.ui.client.Style.IconAlign;
|
||||
import com.extjs.gxt.ui.client.event.MenuEvent;
|
||||
import com.extjs.gxt.ui.client.event.SelectionListener;
|
||||
import com.extjs.gxt.ui.client.widget.button.Button;
|
||||
import com.extjs.gxt.ui.client.widget.menu.Menu;
|
||||
import com.extjs.gxt.ui.client.widget.menu.MenuItem;
|
||||
import com.extjs.gxt.ui.client.widget.menu.SeparatorMenuItem;
|
||||
|
@ -75,6 +80,7 @@ public class ContextMenuTree {
|
|||
|
||||
contextMenu.add(previewImage);
|
||||
|
||||
|
||||
//Open Url
|
||||
MenuItem openUrl = new MenuItem();
|
||||
openUrl.setId(ConstantsExplorer.LNK);
|
||||
|
@ -446,6 +452,22 @@ public class ContextMenuTree {
|
|||
contextMenu.add(new SeparatorMenuItem());
|
||||
|
||||
|
||||
MenuItem mnGetInfo = new MenuItem();
|
||||
mnGetInfo.setId(ConstantsExplorer.GTI);
|
||||
mnGetInfo.setText(ConstantsExplorer.MESSAGE_GET_INFO);
|
||||
mnGetInfo.setIcon(Resources.getIconInfo());
|
||||
|
||||
mnGetInfo.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||
public void componentSelected(MenuEvent ce) {
|
||||
|
||||
for (FileModel sel : listSelectedItems) {
|
||||
eventBus.fireEvent(new GetInfoEvent(sel));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
contextMenu.add(mnGetInfo);
|
||||
|
||||
MenuItem refreshItem = new MenuItem();
|
||||
refreshItem.setId(ConstantsExplorer.RFH);
|
||||
refreshItem.setText(ConstantsExplorer.MESSAGE_REFRESH_FOLDER);
|
||||
|
|
|
@ -0,0 +1,250 @@
|
|||
package org.gcube.portlets.user.workspace.client.view.windows;
|
||||
|
||||
import java.util.Date;
|
||||
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.model.FileGridModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.InfoContactModel;
|
||||
|
||||
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
|
||||
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.form.TextArea;
|
||||
import com.extjs.gxt.ui.client.widget.form.TextField;
|
||||
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.i18n.client.NumberFormat;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
||||
/**
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
*/
|
||||
public class DialogGetInfo extends Dialog {
|
||||
|
||||
private int widthDialog = 450;
|
||||
private int heightTextArea = 50;
|
||||
private TextField<String> txtName = new TextField<String>();
|
||||
private TextField<String> txtType = new TextField<String>();
|
||||
private TextField<String> txtCategory = new TextField<String>();
|
||||
private TextField<String> txtOwner = new TextField<String>();
|
||||
|
||||
private TextField<String> txtCreated = new TextField<String>();
|
||||
private TextField<String> txtSize = new TextField<String>();
|
||||
private TextField<String> txtLocation = new TextField<String>();
|
||||
private TextField<String> txtShared = new TextField<String>();
|
||||
private TextArea textAreaSharedWith = new TextArea();
|
||||
private final NumberFormat number = ConstantsExplorer.numberFormatterKB;
|
||||
|
||||
|
||||
public DialogGetInfo(FileModel fileModel) {
|
||||
|
||||
FormLayout layout = new FormLayout();
|
||||
layout.setLabelWidth(90);
|
||||
layout.setDefaultWidth(300);
|
||||
setLayout(layout);
|
||||
|
||||
setIcon(fileModel.getAbstractPrototypeIcon());
|
||||
setHeading(fileModel.getName() + " Properties");
|
||||
|
||||
setButtonAlign(HorizontalAlignment.RIGHT);
|
||||
setModal(true);
|
||||
// setBodyBorder(true);
|
||||
setBodyStyle("padding: 9px; background: none");
|
||||
setWidth(widthDialog);
|
||||
setResizable(false);
|
||||
setButtons(Dialog.OK);
|
||||
|
||||
txtName = new TextField<String>();
|
||||
txtName.setFieldLabel("Name");
|
||||
txtName.setReadOnly(true);
|
||||
textFieldSetValue(txtName,fileModel.getName());
|
||||
add(txtName);
|
||||
|
||||
txtType = new TextField<String>();
|
||||
txtType.setFieldLabel("Type");
|
||||
txtType.setReadOnly(true);
|
||||
textFieldSetValue(txtType,fileModel.getType());
|
||||
add(txtType);
|
||||
|
||||
txtCategory = new TextField<String>();
|
||||
txtCategory.setFieldLabel("Category");
|
||||
txtCategory.setReadOnly(true);
|
||||
textFieldSetValue(txtCategory,fileModel.getShortcutCategory());
|
||||
add(txtCategory);
|
||||
|
||||
txtOwner = new TextField<String>();
|
||||
txtOwner.setFieldLabel("Owner");
|
||||
txtOwner.setReadOnly(true);
|
||||
loadOwner(fileModel.getIdentifier());
|
||||
add(txtOwner);
|
||||
|
||||
txtCreated = new TextField<String>();
|
||||
txtCreated.setFieldLabel("Created");
|
||||
txtCreated.setReadOnly(true);
|
||||
if(fileModel instanceof FileGridModel)
|
||||
textFieldSetValue(txtCreated, ((FileGridModel) fileModel).getCreationDate().toString());
|
||||
else
|
||||
loadCreationDate(fileModel.getIdentifier());
|
||||
add(txtCreated);
|
||||
|
||||
txtSize = new TextField<String>();
|
||||
txtSize.setFieldLabel("Size");
|
||||
txtSize.setReadOnly(true);
|
||||
|
||||
if(fileModel instanceof FileGridModel)
|
||||
textFieldSetValue(txtSize,getFormattedSize(((FileGridModel) fileModel).getSize()));
|
||||
else
|
||||
loadSize(fileModel.getIdentifier());
|
||||
|
||||
add(txtSize);
|
||||
|
||||
|
||||
txtShared = new TextField<String>();
|
||||
txtShared.setFieldLabel("Shared");
|
||||
txtShared.setReadOnly(true);
|
||||
textFieldSetValue(txtShared,fileModel.isShared()+"");
|
||||
add(txtShared);
|
||||
|
||||
|
||||
if(fileModel.isShared()){
|
||||
|
||||
textAreaSharedWith.setFieldLabel("Shared with");
|
||||
textAreaSharedWith.setHeight(heightTextArea);
|
||||
textAreaSharedWith.setReadOnly(true);
|
||||
getListSharedContacts(fileModel.getIdentifier());
|
||||
add(textAreaSharedWith);
|
||||
}
|
||||
|
||||
|
||||
this.getButtonById(Dialog.OK).addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||
|
||||
@Override
|
||||
public void componentSelected(ButtonEvent ce) {
|
||||
hide();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
this.show();
|
||||
}
|
||||
|
||||
private void textFieldSetValue(TextField<String> field, String value){
|
||||
|
||||
if(value==null || value.isEmpty())
|
||||
field.setValue("unknown");
|
||||
else
|
||||
field.setValue(value);
|
||||
}
|
||||
|
||||
private void loadOwner(final String itemId){
|
||||
|
||||
txtOwner.mask();
|
||||
AppControllerExplorer.rpcWorkspaceService.getOwnerByItemId(itemId, new AsyncCallback<InfoContactModel>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
GWT.log("an error occured in get Owner by Id "+itemId + " "+caught.getMessage());
|
||||
txtOwner.unmask();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(InfoContactModel result) {
|
||||
textFieldSetValue(txtOwner,result.getName());
|
||||
txtOwner.unmask();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void loadSize(final String itemId){
|
||||
|
||||
txtSize.mask();
|
||||
AppControllerExplorer.rpcWorkspaceService.loadSizeByItemId(itemId, new AsyncCallback<Long>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
GWT.log("an error occured in load creation date by Id "+itemId + " "+caught.getMessage());
|
||||
txtSize.unmask();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Long result) {
|
||||
textFieldSetValue(txtSize,getFormattedSize(result));
|
||||
txtSize.unmask();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void loadCreationDate(final String itemId){
|
||||
|
||||
txtCreated.mask();
|
||||
AppControllerExplorer.rpcWorkspaceService.getItemCreationDateById(itemId, new AsyncCallback<Date>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
GWT.log("an error occured in load creation date by Id "+itemId + " "+caught.getMessage());
|
||||
txtCreated.unmask();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Date result) {
|
||||
if(result!=null)
|
||||
textFieldSetValue(txtCreated,result.toString());
|
||||
|
||||
txtCreated.unmask();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void getListSharedContacts(String sharedId){
|
||||
|
||||
textAreaSharedWith.mask();
|
||||
|
||||
AppControllerExplorer.rpcWorkspaceService.getListUserSharedBySharedItem(sharedId, new AsyncCallback<List<InfoContactModel>>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
textAreaSharedWith.unmask();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<InfoContactModel> result) {
|
||||
|
||||
String users = "";
|
||||
|
||||
for (int i = 0; i < result.size()-1; i++) {
|
||||
users+= result.get(i).getName() + ", ";
|
||||
}
|
||||
|
||||
if(result.size()>1)
|
||||
users += result.get(result.size()-1).getName();
|
||||
|
||||
textAreaSharedWith.setValue(users);
|
||||
|
||||
textAreaSharedWith.unmask();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private String getFormattedSize(long value){
|
||||
|
||||
if(value>0){
|
||||
double kb = value/1024;
|
||||
if(kb<1)
|
||||
kb=1;
|
||||
return number.format(kb);
|
||||
}else
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,7 +1,9 @@
|
|||
package org.gcube.portlets.user.workspace.server;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
@ -28,6 +30,7 @@ import org.gcube.portlets.user.homelibrary.home.workspace.folder.FolderItem;
|
|||
import org.gcube.portlets.user.homelibrary.home.workspace.folder.FolderItemType;
|
||||
import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ExternalUrl;
|
||||
import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ts.TimeSeries;
|
||||
import org.gcube.portlets.user.homelibrary.home.workspace.search.SearchFolderItem;
|
||||
import org.gcube.portlets.user.homelibrary.home.workspace.search.SearchItem;
|
||||
import org.gcube.portlets.user.homelibrary.home.workspace.sharing.WorkspaceMessage;
|
||||
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
||||
|
@ -1853,4 +1856,53 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|||
throw new Exception(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getItemCreationDateById(String itemId) throws Exception {
|
||||
workspaceLogger.trace("get Item Creation Date By ItemId "+ itemId);
|
||||
try {
|
||||
|
||||
Workspace workspace = getWorkspace();
|
||||
|
||||
WorkspaceItem wsItem = workspace.getItem(itemId);
|
||||
|
||||
Calendar cl = wsItem.getCreationTime();
|
||||
|
||||
if(cl!=null)
|
||||
return cl.getTime();
|
||||
|
||||
return null;
|
||||
|
||||
} catch (Exception e) {
|
||||
workspaceLogger.error("get Item Creation Date By ItemId ", e);
|
||||
throw new Exception(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long loadSizeByItemId(String itemId) throws Exception {
|
||||
|
||||
workspaceLogger.trace("get Size By ItemId "+ itemId);
|
||||
try {
|
||||
|
||||
Workspace workspace = getWorkspace();
|
||||
|
||||
WorkspaceItem wsItem = workspace.getItem(itemId);
|
||||
|
||||
Long size = new Long(-1);
|
||||
|
||||
if(wsItem instanceof FolderItem){
|
||||
|
||||
FolderItem folderItem = (FolderItem) wsItem;
|
||||
|
||||
size = new Long(folderItem.getLength());
|
||||
}
|
||||
|
||||
return size;
|
||||
|
||||
} catch (Exception e) {
|
||||
workspaceLogger.error("get Size By ItemId ", e);
|
||||
throw new Exception(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue