Skip to content
Snippets Groups Projects
Commit 59bb6e83 authored by pkupczyk's avatar pkupczyk
Browse files

SSDM-947 - Global Search: Indicate an ongoing search - Take 2 - made it work...

SSDM-947 - Global Search: Indicate an ongoing search - Take 2 - made it work for both normal and simple modes

SVN: 32534
parent b95d0561
No related branches found
No related tags found
No related merge requests found
......@@ -16,10 +16,12 @@
package ch.systemsx.cisd.openbis.generic.client.web.client.application;
import com.extjs.gxt.ui.client.mvc.Dispatcher;
import com.extjs.gxt.ui.client.widget.MessageBox;
import ch.systemsx.cisd.openbis.generic.client.web.client.ICommonClientServiceAsync;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.framework.AbstractTabItemFactory;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.framework.AppEvents;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.framework.DefaultTabItem;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.framework.DispatcherHelper;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.framework.ITabItem;
......@@ -35,36 +37,32 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.dto.SearchableEntity;
public class GlobalSearchTabItemFactory
{
static class ActionFinish {
public void finish() {}
}
/**
* opens a new tab if there are search results.
*/
public static void openTabIfEntitiesFound(
final IViewContext<ICommonClientServiceAsync> viewContext,
final SearchableEntity searchableEntity, final String queryText, final ActionFinish actionFinish)
final SearchableEntity searchableEntity, final String queryText)
{
openTab(viewContext, searchableEntity, queryText, false, actionFinish);
openTab(viewContext, searchableEntity, queryText, false);
}
/**
* always opens a new tab, regardless if there were any search entities found.
*/
public static void openTab(final IViewContext<ICommonClientServiceAsync> viewContext,
final SearchableEntity searchableEntity, final String queryText, final ActionFinish actionFinish)
final SearchableEntity searchableEntity, final String queryText)
{
openTab(viewContext, searchableEntity, queryText, true, actionFinish);
openTab(viewContext, searchableEntity, queryText, true);
}
private static void openTab(final IViewContext<ICommonClientServiceAsync> viewContext,
final SearchableEntity searchableEntity, final String queryText,
final boolean openIfNoEntitiesFound,
final ActionFinish actionFinish)
final boolean openIfNoEntitiesFound)
{
Dispatcher.get().fireEvent(AppEvents.GLOBAL_SEARCH_STARTED_EVENT);
final boolean useWildcardSearchMode =
viewContext.getDisplaySettingsManager().isUseWildcardSearchMode();
......@@ -87,10 +85,8 @@ public class GlobalSearchTabItemFactory
@Override
public void postRefresh(boolean wasSuccessful)
{
if(actionFinish != null) {
actionFinish.finish();
}
Dispatcher.get().fireEvent(AppEvents.GLOBAL_SEARCH_FINISHED_EVENT);
if (firstCall == false)
{
return;
......@@ -99,8 +95,8 @@ public class GlobalSearchTabItemFactory
if (matchingEntitiesGrid.getRowNumber() == 0)
{
Object[] msgParameters = (useWildcardSearchMode == true) ? new String[]
{ queryText, "", "off", } : new String[]
{ queryText, "not", "on" };
{ queryText, "", "off", } : new String[]
{ queryText, "not", "on" };
MessageBox.alert(viewContext.getMessage(Dict.MESSAGEBOX_WARNING),
viewContext.getMessage(Dict.NO_MATCH, msgParameters), null);
......
......@@ -16,6 +16,9 @@
package ch.systemsx.cisd.openbis.generic.client.web.client.application;
import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.mvc.Dispatcher;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.MessageBox;
import com.extjs.gxt.ui.client.widget.form.TextField;
......@@ -24,7 +27,7 @@ import com.google.gwt.user.client.History;
import ch.systemsx.cisd.common.shared.basic.string.StringUtils;
import ch.systemsx.cisd.openbis.generic.client.web.client.ICommonClientServiceAsync;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.GlobalSearchTabItemFactory.ActionFinish;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.framework.AppEvents;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.locator.GlobalSearchLocatorResolver;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.locator.ViewLocator;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.EnterKeyListener;
......@@ -64,7 +67,7 @@ public final class SearchWidget extends LayoutContainer
private final ButtonWithLoadingMask searchButton;
private final EnterKeyListener enterKeyListener;
public SearchWidget(final IViewContext<ICommonClientServiceAsync> viewContext)
{
final TableRowLayout tableRowLayout = createLayout();
......@@ -89,6 +92,25 @@ public final class SearchWidget extends LayoutContainer
add(entityChooser);
add(textField);
add(searchButton);
Dispatcher.get().addListener(AppEvents.GLOBAL_SEARCH_STARTED_EVENT, new Listener<BaseEvent>()
{
@Override
public void handleEvent(BaseEvent be)
{
searchButton.setEnabled(false);
}
});
Dispatcher.get().addListener(AppEvents.GLOBAL_SEARCH_FINISHED_EVENT, new Listener<BaseEvent>()
{
@Override
public void handleEvent(BaseEvent be)
{
searchButton.setEnabled(true);
}
});
layout();
}
......@@ -138,7 +160,7 @@ public final class SearchWidget extends LayoutContainer
// reset the text field
textField.setValue("");
SearchableEntity selectedEntity = entityChooser.getSelectedSearchableEntity();
if (viewContext.isSimpleOrEmbeddedMode())
{
// redirect to another URL
......@@ -147,15 +169,8 @@ public final class SearchWidget extends LayoutContainer
History.newItem(url);
} else
{
searchButton.setEnabled(false);
ActionFinish searchFinish = new ActionFinish() {
public void finish() {
searchButton.setEnabled(true);
};
};
GlobalSearchTabItemFactory.openTabIfEntitiesFound(viewContext, selectedEntity,
queryText, searchFinish);
queryText);
}
}
......
......@@ -24,8 +24,7 @@ import com.google.gwt.user.client.Event;
/**
* Additional event codes.
* <p>
* Make sure that values assigned to constants declared here are unique and different than events
* declared in {@link Event} and {@link Events}.
* Make sure that values assigned to constants declared here are unique and different than events declared in {@link Event} and {@link Events}.
* </p>
*
* @author Izabela Adamczyk
......@@ -34,10 +33,8 @@ public class AppEvents
{
/**
* Useful links: <a href=
* "http://google-web-toolkit.googlecode.com/svn/javadoc/1.5/index.html?overview-summary.html"
* >GWT event constants</a>, <a href="http://extjs.com/deploy/gxtdocs/constant-values.html">GXT
* event constants</a>
* Useful links: <a href= "http://google-web-toolkit.googlecode.com/svn/javadoc/1.5/index.html?overview-summary.html" >GWT event constants</a>, <a
* href="http://extjs.com/deploy/gxtdocs/constant-values.html">GXT event constants</a>
*/
private final static int STARTING_VALUE = 10;
......@@ -52,6 +49,10 @@ public class AppEvents
public static final EventType CloseViewer = new EventType(STARTING_VALUE + 70);
public static final EventType GLOBAL_SEARCH_STARTED_EVENT = new EventType(STARTING_VALUE + 80);
public static final EventType GLOBAL_SEARCH_FINISHED_EVENT = new EventType(STARTING_VALUE + 90);
// opens a new browser window with a specified URL
public static class OpenUrlEvent extends AppEvent
{
......
......@@ -21,14 +21,12 @@ public class GlobalSearchLocatorResolver extends AbstractViewLocatorResolver
public final static String QUERY_PARAMETER_KEY = "query";
public GlobalSearchLocatorResolver(IViewContext<ICommonClientServiceAsync> viewContext)
{
super(GLOBAL_SEARCH_ACTION);
this.viewContext = viewContext;
}
@Override
public void resolve(ViewLocator locator) throws UserFailureException
{
......@@ -36,10 +34,9 @@ public class GlobalSearchLocatorResolver extends AbstractViewLocatorResolver
// TODO KE: 2011-02-16 we should parse queries that can contain spaces
final String queryText = getMandatoryParameter(locator, QUERY_PARAMETER_KEY);
GlobalSearchTabItemFactory.openTab(viewContext, selectedSearchableEntity, queryText, null);
GlobalSearchTabItemFactory.openTab(viewContext, selectedSearchableEntity, queryText);
}
private SearchableEntity getSearchableEntity(ViewLocator locator)
{
SearchableEntity result = null;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment