Merged with branch version at 119580

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@119610 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2015-10-12 13:30:59 +00:00
parent e2c64c4eff
commit 804df66079
8 changed files with 105 additions and 40 deletions

View File

@ -1321,8 +1321,8 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
private void doSaveSmartFolder(final AddSmartFolderEvent saveSmartFolderEvent) { private void doSaveSmartFolder(final AddSmartFolderEvent saveSmartFolderEvent) {
final String query = saveSmartFolderEvent.getSearchText(); final String query = saveSmartFolderEvent.getSearchText();
final String parentId = saveSmartFolderEvent.getParentId();
final DialogAddFolderAndSmart dialogAddSmartFolder = new DialogAddFolderAndSmart("", AddType.SMARTFOLDER); final DialogAddFolderAndSmart dialogAddSmartFolder = new DialogAddFolderAndSmart("", AddType.SMARTFOLDER);
dialogAddSmartFolder.getButtonById(Dialog.OK).addListener(Events.Select, new Listener<BaseEvent>() { dialogAddSmartFolder.getButtonById(Dialog.OK).addListener(Events.Select, new Listener<BaseEvent>() {
@ -1332,7 +1332,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
if(dialogAddSmartFolder.isValidForm()) if(dialogAddSmartFolder.isValidForm())
rpcWorkspaceService.createSmartFolder(dialogAddSmartFolder.getName(), dialogAddSmartFolder.getDescription(), query, new AsyncCallback<SmartFolderModel>() { rpcWorkspaceService.createSmartFolder(dialogAddSmartFolder.getName(), dialogAddSmartFolder.getDescription(), query, parentId, new AsyncCallback<SmartFolderModel>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {

View File

@ -2,6 +2,12 @@ package org.gcube.portlets.user.workspace.client.event;
import com.google.gwt.event.shared.GwtEvent; import com.google.gwt.event.shared.GwtEvent;
/**
* The Class AddSmartFolderEvent.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Oct 9, 2015
*/
public class AddSmartFolderEvent extends GwtEvent<AddSmartFolderEventHandler>{ public class AddSmartFolderEvent extends GwtEvent<AddSmartFolderEventHandler>{
public static Type<AddSmartFolderEventHandler> TYPE = new Type<AddSmartFolderEventHandler>(); public static Type<AddSmartFolderEventHandler> TYPE = new Type<AddSmartFolderEventHandler>();
@ -9,54 +15,103 @@ public class AddSmartFolderEvent extends GwtEvent<AddSmartFolderEventHandler>{
private String searchText; private String searchText;
private String workpaceFolderId; private String workpaceFolderId;
private String description; private String description;
private String parentId;
// public AddSmartFolderEvent(String smartFolderName, String searchText, String workpaceFolderId) { /**
// * @return the parentId
// this.smartFolderName = smartFolderName; */
// this.searchText = searchText; public String getParentId() {
// this.workpaceFolderId = workpaceFolderId; return parentId;
// }
public AddSmartFolderEvent(String searchText) {
this.searchText = searchText;
} }
/**
* Instantiates a new adds the smart folder event.
*
* @param searchText the search text
* @param parentId the parent id
*/
public AddSmartFolderEvent(String searchText, String parentId) {
this.searchText = searchText;
this.parentId = parentId;
}
/* (non-Javadoc)
* @see com.google.gwt.event.shared.GwtEvent#getAssociatedType()
*/
@Override @Override
public Type<AddSmartFolderEventHandler> getAssociatedType() { public Type<AddSmartFolderEventHandler> getAssociatedType() {
return TYPE; return TYPE;
} }
/* (non-Javadoc)
* @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler)
*/
@Override @Override
protected void dispatch(AddSmartFolderEventHandler handler) { protected void dispatch(AddSmartFolderEventHandler handler) {
handler.onSaveSmartFolder(this); handler.onSaveSmartFolder(this);
} }
/**
* Gets the smart folder name.
*
* @return the smart folder name
*/
public String getSmartFolderName() { public String getSmartFolderName() {
return smartFolderName; return smartFolderName;
} }
/**
* Gets the search text.
*
* @return the search text
*/
public String getSearchText() { public String getSearchText() {
return searchText; return searchText;
} }
/**
* Gets the workpace folder id.
*
* @return the workpace folder id
*/
public String getWorkpaceFolderId() { public String getWorkpaceFolderId() {
return workpaceFolderId; return workpaceFolderId;
} }
/**
* Sets the smart folder name.
*
* @param smartFolderName the new smart folder name
*/
public void setSmartFolderName(String smartFolderName) { public void setSmartFolderName(String smartFolderName) {
this.smartFolderName = smartFolderName; this.smartFolderName = smartFolderName;
} }
/**
* Sets the workpace folder id.
*
* @param workpaceFolderId the new workpace folder id
*/
public void setWorkpaceFolderId(String workpaceFolderId) { public void setWorkpaceFolderId(String workpaceFolderId) {
this.workpaceFolderId = workpaceFolderId; this.workpaceFolderId = workpaceFolderId;
} }
/**
* Gets the description.
*
* @return the description
*/
public String getDescription() { public String getDescription() {
return description; return description;
} }
/**
* Sets the description.
*
* @param description the new description
*/
public void setDescription(String description) { public void setDescription(String description) {
this.description = description; this.description = description;
} }

View File

@ -88,6 +88,9 @@ public interface Icons extends ClientBundle {
@Source("icons/mime/search16.png") @Source("icons/mime/search16.png")
ImageResource search(); ImageResource search();
@Source("icons/mime/search.png")
ImageResource search2();
@Source("icons/mime/harddisk.png") @Source("icons/mime/harddisk.png")
ImageResource hardDisk(); ImageResource hardDisk();

View File

@ -686,6 +686,18 @@ public class Resources {
return AbstractImagePrototype.create(ICONS.search()); return AbstractImagePrototype.create(ICONS.search());
} }
/**
* Gets the icon search ws.
*
* @return the icon search ws
*/
public static AbstractImagePrototype getIconSearchWs() {
return AbstractImagePrototype.create(ICONS.search2());
}
/** /**
* Gets the icon links. * Gets the icon links.
* *

View File

@ -132,16 +132,8 @@ public interface GWTWorkspaceService extends RemoteService{
*/ */
public List<FileGridModel> getSmartFolderResultsByCategory(String category) throws Exception; public List<FileGridModel> getSmartFolderResultsByCategory(String category) throws Exception;
/** SmartFolderModel createSmartFolder(String name, String description,
* Creates the smart folder. String query, String parentId) throws Exception;
*
* @param name the name
* @param description the description
* @param query the query
* @return the smart folder model
* @throws Exception the exception
*/
public SmartFolderModel createSmartFolder(String name, String description, String query) throws Exception;
/** /**
* Gets the smart folder results by id. * Gets the smart folder results by id.
@ -203,14 +195,7 @@ public interface GWTWorkspaceService extends RemoteService{
*/ */
public void setValueInSession(String name, String value) throws Exception; public void setValueInSession(String name, String value) throws Exception;
/** List<FileGridModel> getItemsBySearchName(String text, String folderId) throws Exception;
* Gets the items by search name.
*
* @param text the text
* @return the items by search name
* @throws Exception the exception
*/
public List<FileGridModel> getItemsBySearchName(String text) throws Exception;
/** /**
* Move item. * Move item.

View File

@ -143,7 +143,7 @@ public interface GWTWorkspaceServiceAsync {
* @param callback the callback * @param callback the callback
* @return the items by search name * @return the items by search name
*/ */
void getItemsBySearchName(String text, AsyncCallback<List<FileGridModel>> callback); void getItemsBySearchName(String text, String folderId, AsyncCallback<List<FileGridModel>> callback);
/** /**
* Gets the smart folder results by category. * Gets the smart folder results by category.
@ -162,7 +162,7 @@ public interface GWTWorkspaceServiceAsync {
* @param query the query * @param query the query
* @param callback the callback * @param callback the callback
*/ */
void createSmartFolder(String name, String description, String query, AsyncCallback<SmartFolderModel> callback); void createSmartFolder(String name, String description, String query, String parentId, AsyncCallback<SmartFolderModel> callback);
/** /**
* Gets the smart folder results by id. * Gets the smart folder results by id.

View File

@ -278,14 +278,17 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getItemsBySearchName(java.lang.String) * @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getItemsBySearchName(java.lang.String)
*/ */
@Override @Override
public List<FileGridModel> getItemsBySearchName(String text) throws Exception { public List<FileGridModel> getItemsBySearchName(String text, String folderId) throws Exception {
workspaceLogger.info("searching by name: "+text);
try { try {
Workspace workspace = getWorkspace(); Workspace workspace = getWorkspace();
workspaceLogger.info("Calling search HL.."); if(folderId==null || folderId.isEmpty()){
List<SearchItem> listSearchItems = workspace.searchByName(text); workspaceLogger.trace("searching folderId is null, settings root Id");
folderId = workspace.getRoot().getId();
}
workspaceLogger.info("searching by name: "+text +" in "+folderId);
List<SearchItem> listSearchItems = workspace.searchByName(text, folderId);
workspaceLogger.info("HL search returning "+listSearchItems.size()+" items"); workspaceLogger.info("HL search returning "+listSearchItems.size()+" items");
workspaceLogger.info("Converting "+listSearchItems.size()+" items"); workspaceLogger.info("Converting "+listSearchItems.size()+" items");
@ -1141,7 +1144,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#createSmartFolder(java.lang.String, java.lang.String, java.lang.String) * @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#createSmartFolder(java.lang.String, java.lang.String, java.lang.String)
*/ */
@Override @Override
public SmartFolderModel createSmartFolder(String name, String description, String query) throws Exception { public SmartFolderModel createSmartFolder(String name, String description, String query, String parentId) throws Exception {
try { try {
@ -1149,7 +1152,14 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
workspaceLogger.trace("create smart folder by name: "+name); workspaceLogger.trace("create smart folder by name: "+name);
workspaceLogger.trace("description " + description); workspaceLogger.trace("description " + description);
workspaceLogger.trace("query " + query); workspaceLogger.trace("query " + query);
WorkspaceSmartFolder wsSmartFolder = workspace.createSmartFolder(name, description, query); //create Smart Folder from workspace workspaceLogger.trace("parentId " + parentId);
if(parentId==null || parentId.isEmpty()){
workspaceLogger.trace("parent id is null using root id");
parentId = workspace.getRoot().getId();
}
WorkspaceSmartFolder wsSmartFolder = workspace.createSmartFolder(name, description, query, parentId); //create Smart Folder from workspace
workspaceLogger.trace("create : " +wsSmartFolder.getName() + " id "+ wsSmartFolder.getId()); workspaceLogger.trace("create : " +wsSmartFolder.getName() + " id "+ wsSmartFolder.getId());
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder(); GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
return builder.buildGXTSmartFolderModel(wsSmartFolder,query); return builder.buildGXTSmartFolderModel(wsSmartFolder,query);

View File

@ -52,7 +52,7 @@ public class SearchTextTest {
// List<SearchItem> listSearchItems = ws.searchByName(text); // List<SearchItem> listSearchItems = ws.searchByName(text);
logger.info("Calling search HL.."); logger.info("Calling search HL..");
List<SearchItem> listSearchItems = workspace.searchByName(text); List<SearchItem> listSearchItems = workspace.searchByName(text, workspace.getRoot().getId());
logger.info("HL search returning "+listSearchItems.size()+" items"); logger.info("HL search returning "+listSearchItems.size()+" items");
logger.info("Converting "+listSearchItems.size()+" items"); logger.info("Converting "+listSearchItems.size()+" items");