Skip to content
Snippets Groups Projects
Commit 9e2f466e authored by juanf's avatar juanf
Browse files

SSDM-829 : Global Search: Indicate an ongoing search

SVN: 32441
parent 9eaba16c
No related branches found
No related tags found
No related merge requests found
......@@ -35,30 +35,35 @@ 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 SearchableEntity searchableEntity, final String queryText, final ActionFinish actionFinish)
{
openTab(viewContext, searchableEntity, queryText, false);
openTab(viewContext, searchableEntity, queryText, false, actionFinish);
}
/**
* 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 SearchableEntity searchableEntity, final String queryText, final ActionFinish actionFinish)
{
openTab(viewContext, searchableEntity, queryText, true);
openTab(viewContext, searchableEntity, queryText, true, actionFinish);
}
private static void openTab(final IViewContext<ICommonClientServiceAsync> viewContext,
final SearchableEntity searchableEntity, final String queryText,
final boolean openIfNoEntitiesFound)
final boolean openIfNoEntitiesFound,
final ActionFinish actionFinish)
{
final boolean useWildcardSearchMode =
......@@ -82,6 +87,10 @@ public class GlobalSearchTabItemFactory
@Override
public void postRefresh(boolean wasSuccessful)
{
if(actionFinish != null) {
actionFinish.finish();
}
if (firstCall == false)
{
return;
......@@ -102,7 +111,6 @@ public class GlobalSearchTabItemFactory
}
DispatcherHelper.dispatchNaviEvent(tabFactory);
}
});
}
......
......@@ -24,6 +24,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.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;
......@@ -63,7 +64,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();
......@@ -136,8 +137,9 @@ public final class SearchWidget extends LayoutContainer
// reset the text field
textField.setValue("");
searchButton.setEnabled(false);
SearchableEntity selectedEntity = entityChooser.getSelectedSearchableEntity();
if (viewContext.isSimpleOrEmbeddedMode())
{
// redirect to another URL
......@@ -146,10 +148,15 @@ public final class SearchWidget extends LayoutContainer
History.newItem(url);
} else
{
ActionFinish searchFinish = new ActionFinish() {
public void finish() {
searchButton.setEnabled(true);
};
};
GlobalSearchTabItemFactory.openTabIfEntitiesFound(viewContext, selectedEntity,
queryText);
queryText, searchFinish);
}
}
private static boolean hasOnlyWildcards(final String queryText)
......
......@@ -36,7 +36,7 @@ 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);
GlobalSearchTabItemFactory.openTab(viewContext, selectedSearchableEntity, queryText, null);
}
......
......@@ -124,6 +124,7 @@ public abstract class ButtonWithLoadingMask extends LayoutContainer
private final static Image createLoadingImage()
{
final Image image = new Image(LOADING_IMAGE_URL);
image.setSize("19px", "19px");
image.setVisible(false);
return image;
}
......
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