added search by item id functionality
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace@76830 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
830c452d93
commit
6100c10cf5
|
@ -55,6 +55,8 @@ import org.gcube.portlets.user.workspace.client.event.SaveSmartFolderEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.SaveSmartFolderEventHandler;
|
import org.gcube.portlets.user.workspace.client.event.SaveSmartFolderEventHandler;
|
||||||
import org.gcube.portlets.user.workspace.client.event.ScopeChangeEvent;
|
import org.gcube.portlets.user.workspace.client.event.ScopeChangeEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.ScopeChangeEventHandler;
|
import org.gcube.portlets.user.workspace.client.event.ScopeChangeEventHandler;
|
||||||
|
import org.gcube.portlets.user.workspace.client.event.SearchItemByIdEvent;
|
||||||
|
import org.gcube.portlets.user.workspace.client.event.SearchItemByIdEventHandler;
|
||||||
import org.gcube.portlets.user.workspace.client.event.SearchTextEvent;
|
import org.gcube.portlets.user.workspace.client.event.SearchTextEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.SearchTextEventHandler;
|
import org.gcube.portlets.user.workspace.client.event.SearchTextEventHandler;
|
||||||
import org.gcube.portlets.user.workspace.client.event.SendMessageEvent;
|
import org.gcube.portlets.user.workspace.client.event.SendMessageEvent;
|
||||||
|
@ -421,7 +423,7 @@ public class AppController implements SubscriberInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
System.out.println("Failure search RPC");
|
// System.out.println("Failure search RPC");
|
||||||
new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " searching item. " +ConstantsExplorer.TRY_AGAIN, null);
|
new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " searching item. " +ConstantsExplorer.TRY_AGAIN, null);
|
||||||
wsPortlet.getGridGroupContainer().unmask();
|
wsPortlet.getGridGroupContainer().unmask();
|
||||||
|
|
||||||
|
@ -437,6 +439,53 @@ public class AppController implements SubscriberInterface {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
eventBus.addHandler(SearchItemByIdEvent.TYPE, new SearchItemByIdEventHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSearchItemById(SearchItemByIdEvent searchItemByIdEvent) {
|
||||||
|
|
||||||
|
if(searchItemByIdEvent.getItemId()!=null && !searchItemByIdEvent.getItemId().isEmpty()){
|
||||||
|
|
||||||
|
wsPortlet.getSearchAndFilterContainer().setSearchActive(true); //ADDED 06-04-12
|
||||||
|
appContrExplorer.searching(true);
|
||||||
|
doSearchItemById(searchItemByIdEvent.getItemId());
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
appContrExplorer.searching(false);
|
||||||
|
wsPortlet.getGridGroupContainer().setBorderAsOnSearch(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doSearchItemById(String itemId) {
|
||||||
|
|
||||||
|
wsPortlet.getGridGroupContainer().setBorderAsOnSearch(true);
|
||||||
|
wsPortlet.getGridGroupContainer().mask(ConstantsExplorer.LOADING,ConstantsExplorer.LOADINGSTYLE);
|
||||||
|
|
||||||
|
appContrExplorer.getRpcWorkspaceService().getItemForFileGrid(itemId, new AsyncCallback<FileGridModel>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
// System.out.println("Failure search RPC");
|
||||||
|
new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " searching item. " +ConstantsExplorer.TRY_AGAIN, null);
|
||||||
|
wsPortlet.getGridGroupContainer().unmask();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(FileGridModel result) {
|
||||||
|
|
||||||
|
List<FileGridModel> listResult = new ArrayList<FileGridModel>();
|
||||||
|
listResult.add(result);
|
||||||
|
wsPortlet.getGridGroupContainer().updateStore(listResult);
|
||||||
|
wsPortlet.getGridGroupContainer().unmask();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
eventBus.addHandler(PathElementSelectedEvent.TYPE, new PathElementSelectedEventHandler() {
|
eventBus.addHandler(PathElementSelectedEvent.TYPE, new PathElementSelectedEventHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -646,11 +695,17 @@ public class AppController implements SubscriberInterface {
|
||||||
public void go(final HasWidgets rootPanel) {
|
public void go(final HasWidgets rootPanel) {
|
||||||
|
|
||||||
final String searchParameter = Window.Location.getParameter(ConstantsPortlet.GET_SEARCH_PARAMETER);
|
final String searchParameter = Window.Location.getParameter(ConstantsPortlet.GET_SEARCH_PARAMETER);
|
||||||
|
final String idParameter = Window.Location.getParameter(ConstantsPortlet.GET_ITEMID_PARAMETER);
|
||||||
|
|
||||||
|
GWT.log("GET PARAMETER: searchParameter "+searchParameter);
|
||||||
|
GWT.log("GET PARAMETER: idParameter "+idParameter);
|
||||||
|
|
||||||
final boolean instanceWithGrouping = readCookieWorkspaceGridViewSetting();
|
final boolean instanceWithGrouping = readCookieWorkspaceGridViewSetting();
|
||||||
|
|
||||||
System.out.println("Cookie "+ConstantsPortlet.GCUBE_COOKIE_WORKSPACE_GRID_VIEW_SETTING + " return "+instanceWithGrouping);
|
System.out.println("Cookie "+ConstantsPortlet.GCUBE_COOKIE_WORKSPACE_GRID_VIEW_SETTING + " return "+instanceWithGrouping);
|
||||||
|
|
||||||
boolean isSearch = false;
|
boolean isSearch = false;
|
||||||
|
boolean isSearchForItemId = false;
|
||||||
// Log.trace("Start Workspace Portlet");
|
// Log.trace("Start Workspace Portlet");
|
||||||
if (this.appContrExplorer == null){
|
if (this.appContrExplorer == null){
|
||||||
this.wsPortlet = new WorskpacePortlet(instanceWithGrouping);
|
this.wsPortlet = new WorskpacePortlet(instanceWithGrouping);
|
||||||
|
@ -660,10 +715,19 @@ public class AppController implements SubscriberInterface {
|
||||||
if(searchParameter!=null && !searchParameter.isEmpty())
|
if(searchParameter!=null && !searchParameter.isEmpty())
|
||||||
isSearch = true;
|
isSearch = true;
|
||||||
|
|
||||||
|
if(idParameter!=null && !idParameter.isEmpty()){
|
||||||
|
isSearch = true;
|
||||||
|
isSearchForItemId = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
this.wsPortlet = new WorskpacePortlet(this.appContrExplorer.getPanel(true, false, !isSearch), instanceWithGrouping);
|
this.wsPortlet = new WorskpacePortlet(this.appContrExplorer.getPanel(true, false, !isSearch), instanceWithGrouping);
|
||||||
eventBus.fireEvent(new LoadAllScopeEvent()); //LOAD ALL SCOPE EVENT
|
eventBus.fireEvent(new LoadAllScopeEvent()); //LOAD ALL SCOPE EVENT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
System.out.println("isSearch "+isSearch);
|
||||||
|
System.out.println("isSearchForItemId "+isSearchForItemId);
|
||||||
|
|
||||||
rootPanel.add(wsPortlet.getBorderLayoutContainer());
|
rootPanel.add(wsPortlet.getBorderLayoutContainer());
|
||||||
|
|
||||||
//SET TOGGLE BUTTON GRID VIEW
|
//SET TOGGLE BUTTON GRID VIEW
|
||||||
|
@ -675,17 +739,24 @@ public class AppController implements SubscriberInterface {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//If is SEARCH - fire event search text
|
//IF IS SEARCH and IS NOT SEARCH FOR ITEM ID - fire event search text
|
||||||
if(searchParameter!=null && !searchParameter.isEmpty())
|
if(searchParameter!=null && !searchParameter.isEmpty() && !isSearchForItemId){
|
||||||
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
// wsPortlet.getGxtCardLayoutResultPanel().getToolBarItem().activeAllButtonWithoutGroupView(false);
|
|
||||||
wsPortlet.getSearchAndFilterContainer().searchText(searchParameter);
|
wsPortlet.getSearchAndFilterContainer().searchText(searchParameter);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else if(idParameter!=null && !idParameter.isEmpty()){ //SEARCH FOR ITEM ID
|
||||||
|
|
||||||
|
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
AppController.getEventBus().fireEvent(new SearchItemByIdEvent(idParameter));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,10 @@ public class ConstantsPortlet {
|
||||||
public static final String DOWNLOADITEM = "Download";
|
public static final String DOWNLOADITEM = "Download";
|
||||||
public static final String UPLOADARCHIVE = "Upload Archive";
|
public static final String UPLOADARCHIVE = "Upload Archive";
|
||||||
|
|
||||||
|
//USED IN HTTP GET AS PARAMETERS
|
||||||
public static final String GET_SEARCH_PARAMETER ="search";
|
public static final String GET_SEARCH_PARAMETER ="search";
|
||||||
|
public static final String GET_ITEMID_PARAMETER ="itemid";
|
||||||
|
|
||||||
// Div Gwt
|
// Div Gwt
|
||||||
public static final String WORKSPACEDIV = "workspaceDiv";
|
public static final String WORKSPACEDIV = "workspaceDiv";
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
package org.gcube.portlets.user.workspace.client.event;
|
||||||
|
|
||||||
|
import com.google.gwt.event.shared.GwtEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
|
* @Jun 6, 2013
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SearchItemByIdEvent extends GwtEvent<SearchItemByIdEventHandler> {
|
||||||
|
public static Type<SearchItemByIdEventHandler> TYPE = new Type<SearchItemByIdEventHandler>();
|
||||||
|
|
||||||
|
private String itemId;
|
||||||
|
|
||||||
|
public SearchItemByIdEvent(String itemId) {
|
||||||
|
this.itemId = itemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Type<SearchItemByIdEventHandler> getAssociatedType() {
|
||||||
|
return TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void dispatch(SearchItemByIdEventHandler handler) {
|
||||||
|
handler.onSearchItemById(this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getItemId() {
|
||||||
|
return itemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItemId(String itemId) {
|
||||||
|
this.itemId = itemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package org.gcube.portlets.user.workspace.client.event;
|
||||||
|
|
||||||
|
import com.google.gwt.event.shared.EventHandler;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
|
* @Jun 6, 2013
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface SearchItemByIdEventHandler extends EventHandler {
|
||||||
|
/**
|
||||||
|
* @param searchItemByIdEvent
|
||||||
|
*/
|
||||||
|
void onSearchItemById(SearchItemByIdEvent searchItemByIdEvent);
|
||||||
|
}
|
|
@ -83,7 +83,7 @@ public class GxtSeachAndFilterPanel extends LayoutContainer {
|
||||||
|
|
||||||
hp.setStyleAttribute("padding", "2px");
|
hp.setStyleAttribute("padding", "2px");
|
||||||
|
|
||||||
this.cbViewScope.setStyleAttribute("margin-left", "132px");
|
|
||||||
// this.cbViewScope.setStyleAttribute("margin-right", "70px");
|
// this.cbViewScope.setStyleAttribute("margin-right", "70px");
|
||||||
|
|
||||||
seVisibleButtonsCancelSave(false);
|
seVisibleButtonsCancelSave(false);
|
||||||
|
@ -116,11 +116,16 @@ public class GxtSeachAndFilterPanel extends LayoutContainer {
|
||||||
//hp2.add(txtViewScope);
|
//hp2.add(txtViewScope);
|
||||||
hp2.add(cbViewScope);
|
hp2.add(cbViewScope);
|
||||||
|
|
||||||
|
cbViewScope.setStyleAttribute("margin-left", "132px");
|
||||||
cbViewScope.setStyleAttribute("margin-top", "2px");
|
cbViewScope.setStyleAttribute("margin-top", "2px");
|
||||||
|
|
||||||
|
|
||||||
hpMain.add(hp);
|
hpMain.add(hp);
|
||||||
|
|
||||||
|
//SOLUTION FOR SCOPE INVISIBLE
|
||||||
|
cbViewScope.setVisible(false);
|
||||||
|
|
||||||
hpMain.add(hp2);
|
hpMain.add(hp2);
|
||||||
|
|
||||||
cp.add(hpMain);
|
cp.add(hpMain);
|
||||||
|
|
||||||
this.addListeners();
|
this.addListeners();
|
||||||
|
@ -145,7 +150,12 @@ public class GxtSeachAndFilterPanel extends LayoutContainer {
|
||||||
RootPanel workspace = RootPanel.get(ConstantsPortlet.WORKSPACEDIV);
|
RootPanel workspace = RootPanel.get(ConstantsPortlet.WORKSPACEDIV);
|
||||||
int leftBorder = workspace.getAbsoluteLeft();
|
int leftBorder = workspace.getAbsoluteLeft();
|
||||||
int rootWidth = Window.getClientWidth() - 2* leftBorder; //- rightScrollBar;
|
int rootWidth = Window.getClientWidth() - 2* leftBorder; //- rightScrollBar;
|
||||||
hp.setWidth(rootWidth - 500);
|
|
||||||
|
//SOLUTION FOR SCOPE INVISIBLE
|
||||||
|
hp.setWidth(rootWidth);
|
||||||
|
|
||||||
|
// ORIGINAL CODE
|
||||||
|
// hp.setWidth(rootWidth - 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void searchText(String value){
|
public void searchText(String value){
|
||||||
|
|
Loading…
Reference in New Issue