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) {
final String query = saveSmartFolderEvent.getSearchText();
final String parentId = saveSmartFolderEvent.getParentId();
final DialogAddFolderAndSmart dialogAddSmartFolder = new DialogAddFolderAndSmart("", AddType.SMARTFOLDER);
dialogAddSmartFolder.getButtonById(Dialog.OK).addListener(Events.Select, new Listener<BaseEvent>() {
@ -1332,7 +1332,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
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
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;
/**
* The Class AddSmartFolderEvent.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Oct 9, 2015
*/
public class AddSmartFolderEvent extends GwtEvent<AddSmartFolderEventHandler>{
public static Type<AddSmartFolderEventHandler> TYPE = new Type<AddSmartFolderEventHandler>();
@ -9,54 +15,103 @@ public class AddSmartFolderEvent extends GwtEvent<AddSmartFolderEventHandler>{
private String searchText;
private String workpaceFolderId;
private String description;
private String parentId;
// public AddSmartFolderEvent(String smartFolderName, String searchText, String workpaceFolderId) {
//
// this.smartFolderName = smartFolderName;
// this.searchText = searchText;
// this.workpaceFolderId = workpaceFolderId;
// }
public AddSmartFolderEvent(String searchText) {
this.searchText = searchText;
/**
* @return the parentId
*/
public String getParentId() {
return parentId;
}
/**
* 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
public Type<AddSmartFolderEventHandler> getAssociatedType() {
return TYPE;
}
/* (non-Javadoc)
* @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler)
*/
@Override
protected void dispatch(AddSmartFolderEventHandler handler) {
handler.onSaveSmartFolder(this);
}
/**
* Gets the smart folder name.
*
* @return the smart folder name
*/
public String getSmartFolderName() {
return smartFolderName;
}
/**
* Gets the search text.
*
* @return the search text
*/
public String getSearchText() {
return searchText;
}
/**
* Gets the workpace folder id.
*
* @return the workpace folder id
*/
public String getWorkpaceFolderId() {
return workpaceFolderId;
}
/**
* Sets the smart folder name.
*
* @param smartFolderName the new smart folder name
*/
public void setSmartFolderName(String smartFolderName) {
this.smartFolderName = smartFolderName;
}
/**
* Sets the workpace folder id.
*
* @param workpaceFolderId the new workpace folder id
*/
public void setWorkpaceFolderId(String workpaceFolderId) {
this.workpaceFolderId = workpaceFolderId;
}
/**
* Gets the description.
*
* @return the description
*/
public String getDescription() {
return description;
}
/**
* Sets the description.
*
* @param description the new description
*/
public void setDescription(String description) {
this.description = description;
}

View File

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

View File

@ -686,6 +686,18 @@ public class Resources {
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.
*

View File

@ -132,16 +132,8 @@ public interface GWTWorkspaceService extends RemoteService{
*/
public List<FileGridModel> getSmartFolderResultsByCategory(String category) throws Exception;
/**
* Creates the smart folder.
*
* @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;
SmartFolderModel createSmartFolder(String name, String description,
String query, String parentId) throws Exception;
/**
* 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;
/**
* 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;
List<FileGridModel> getItemsBySearchName(String text, String folderId) throws Exception;
/**
* Move item.

View File

@ -143,7 +143,7 @@ public interface GWTWorkspaceServiceAsync {
* @param callback the callback
* @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.
@ -162,7 +162,7 @@ public interface GWTWorkspaceServiceAsync {
* @param query the query
* @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.

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)
*/
@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 {
Workspace workspace = getWorkspace();
workspaceLogger.info("Calling search HL..");
List<SearchItem> listSearchItems = workspace.searchByName(text);
if(folderId==null || folderId.isEmpty()){
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("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)
*/
@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 {
@ -1149,7 +1152,14 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
workspaceLogger.trace("create smart folder by name: "+name);
workspaceLogger.trace("description " + description);
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());
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
return builder.buildGXTSmartFolderModel(wsSmartFolder,query);

View File

@ -52,7 +52,7 @@ public class SearchTextTest {
// List<SearchItem> listSearchItems = ws.searchByName(text);
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("Converting "+listSearchItems.size()+" items");