diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/AppController.java b/src/main/java/org/gcube/portlets/user/workspace/client/AppController.java index 124f78a..b021cc4 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/AppController.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/AppController.java @@ -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.ScopeChangeEvent; 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.SearchTextEventHandler; import org.gcube.portlets.user.workspace.client.event.SendMessageEvent; @@ -421,7 +423,7 @@ public class AppController implements SubscriberInterface { @Override 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); wsPortlet.getGridGroupContainer().unmask(); @@ -436,6 +438,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() { + + @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 listResult = new ArrayList(); + listResult.add(result); + wsPortlet.getGridGroupContainer().updateStore(listResult); + wsPortlet.getGridGroupContainer().unmask(); + } + }); + } + }); eventBus.addHandler(PathElementSelectedEvent.TYPE, new PathElementSelectedEventHandler() { @@ -646,11 +695,17 @@ public class AppController implements SubscriberInterface { public void go(final HasWidgets rootPanel) { 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(); System.out.println("Cookie "+ConstantsPortlet.GCUBE_COOKIE_WORKSPACE_GRID_VIEW_SETTING + " return "+instanceWithGrouping); boolean isSearch = false; + boolean isSearchForItemId = false; // Log.trace("Start Workspace Portlet"); if (this.appContrExplorer == null){ this.wsPortlet = new WorskpacePortlet(instanceWithGrouping); @@ -659,11 +714,20 @@ public class AppController implements SubscriberInterface { if(searchParameter!=null && !searchParameter.isEmpty()) isSearch = true; + + if(idParameter!=null && !idParameter.isEmpty()){ + isSearch = true; + isSearchForItemId = true; + } + this.wsPortlet = new WorskpacePortlet(this.appContrExplorer.getPanel(true, false, !isSearch), instanceWithGrouping); eventBus.fireEvent(new LoadAllScopeEvent()); //LOAD ALL SCOPE EVENT } + System.out.println("isSearch "+isSearch); + System.out.println("isSearchForItemId "+isSearchForItemId); + rootPanel.add(wsPortlet.getBorderLayoutContainer()); //SET TOGGLE BUTTON GRID VIEW @@ -675,17 +739,24 @@ public class AppController implements SubscriberInterface { } }); - //If is SEARCH - fire event search text - if(searchParameter!=null && !searchParameter.isEmpty()) + //IF IS SEARCH and IS NOT SEARCH FOR ITEM ID - fire event search text + if(searchParameter!=null && !searchParameter.isEmpty() && !isSearchForItemId){ + Scheduler.get().scheduleDeferred(new ScheduledCommand() { + @Override + public void execute() { + wsPortlet.getSearchAndFilterContainer().searchText(searchParameter); + } + }); + } else if(idParameter!=null && !idParameter.isEmpty()){ //SEARCH FOR ITEM ID + Scheduler.get().scheduleDeferred(new ScheduledCommand() { - @Override public void execute() { -// wsPortlet.getGxtCardLayoutResultPanel().getToolBarItem().activeAllButtonWithoutGroupView(false); - wsPortlet.getSearchAndFilterContainer().searchText(searchParameter); - + AppController.getEventBus().fireEvent(new SearchItemByIdEvent(idParameter)); } }); + + } } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/ConstantsPortlet.java b/src/main/java/org/gcube/portlets/user/workspace/client/ConstantsPortlet.java index 3a345a8..aed5b57 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/ConstantsPortlet.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/ConstantsPortlet.java @@ -15,7 +15,10 @@ public class ConstantsPortlet { public static final String DOWNLOADITEM = "Download"; 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_ITEMID_PARAMETER ="itemid"; + // Div Gwt public static final String WORKSPACEDIV = "workspaceDiv"; diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/event/SearchItemByIdEvent.java b/src/main/java/org/gcube/portlets/user/workspace/client/event/SearchItemByIdEvent.java new file mode 100644 index 0000000..97612cc --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/workspace/client/event/SearchItemByIdEvent.java @@ -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 { + public static Type TYPE = new Type(); + + private String itemId; + + public SearchItemByIdEvent(String itemId) { + this.itemId = itemId; + } + + @Override + public Type 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; + } + +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/event/SearchItemByIdEventHandler.java b/src/main/java/org/gcube/portlets/user/workspace/client/event/SearchItemByIdEventHandler.java new file mode 100644 index 0000000..e682cfd --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/workspace/client/event/SearchItemByIdEventHandler.java @@ -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); +} diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/panels/GxtSeachAndFilterPanel.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/panels/GxtSeachAndFilterPanel.java index 17352bf..0845d78 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/panels/GxtSeachAndFilterPanel.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/panels/GxtSeachAndFilterPanel.java @@ -83,7 +83,7 @@ public class GxtSeachAndFilterPanel extends LayoutContainer { hp.setStyleAttribute("padding", "2px"); - this.cbViewScope.setStyleAttribute("margin-left", "132px"); + // this.cbViewScope.setStyleAttribute("margin-right", "70px"); seVisibleButtonsCancelSave(false); @@ -116,11 +116,16 @@ public class GxtSeachAndFilterPanel extends LayoutContainer { //hp2.add(txtViewScope); hp2.add(cbViewScope); + cbViewScope.setStyleAttribute("margin-left", "132px"); cbViewScope.setStyleAttribute("margin-top", "2px"); - - + hpMain.add(hp); + + //SOLUTION FOR SCOPE INVISIBLE + cbViewScope.setVisible(false); + hpMain.add(hp2); + cp.add(hpMain); this.addListeners(); @@ -145,7 +150,12 @@ public class GxtSeachAndFilterPanel extends LayoutContainer { RootPanel workspace = RootPanel.get(ConstantsPortlet.WORKSPACEDIV); int leftBorder = workspace.getAbsoluteLeft(); 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){