Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
simplify history use in SearchResultsPresenter
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmason committed Jun 7, 2012
1 parent 21c9f2e commit be08335
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Expand Up @@ -120,6 +120,10 @@ public interface Display extends WidgetDisplay

HasChangeHandlers getSearchFieldSelector();

static String SEARCH_FIELD_TARGET = "target";
static String SEARCH_FIELD_SOURCE = "source";
static String SEARCH_FIELD_BOTH = "both";

String getSelectedSearchField();

void setSearching(boolean searching);
Expand Down Expand Up @@ -280,7 +284,7 @@ public void onValueChange(ValueChangeEvent<String> event)
if (!event.getValue().equals(token.getProjectSearchReplacement()))
{
token.setProjectSearchReplacement(event.getValue());
history.newItem(token.toTokenString());
history.newItem(token);
}
}
}));
Expand Down Expand Up @@ -508,7 +512,7 @@ private void showDocInEditor(String doc, boolean runSearch)
{
token.setSearchText("");
}
history.newItem(token.toTokenString());
history.newItem(token);
}

@Override
Expand Down Expand Up @@ -1319,7 +1323,7 @@ private void refreshReplacementEventInfoList()
private void updateSearch()
{
boolean changed = false;
HistoryToken token = HistoryToken.fromTokenString(history.getToken());
HistoryToken token = history.getHistoryToken();

Boolean caseSensitive = display.getCaseSensitiveChk().getValue();
if (caseSensitive != token.getProjectSearchCaseSensitive())
Expand All @@ -1336,8 +1340,8 @@ private void updateSearch()
}

String selected = display.getSelectedSearchField();
boolean searchSource = selected.equals("source") || selected.equals("both");
boolean searchTarget = selected.equals("target") || selected.equals("both");
boolean searchSource = selected.equals(Display.SEARCH_FIELD_SOURCE) || selected.equals(Display.SEARCH_FIELD_BOTH);
boolean searchTarget = selected.equals(Display.SEARCH_FIELD_TARGET) || selected.equals(Display.SEARCH_FIELD_BOTH);
if (searchSource != token.isProjectSearchInSource())
{
token.setProjectSearchInSource(searchSource);
Expand All @@ -1351,7 +1355,7 @@ private void updateSearch()

if (changed)
{
history.newItem(token.toTokenString());
history.newItem(token);
}
}

Expand Down
Expand Up @@ -13,6 +13,7 @@
<g:VerticalPanel>
<g:CheckBox ui:field="caseSensitiveChk"><ui:msg>Case sensitive</ui:msg></g:CheckBox>
<g:ListBox ui:field="searchFieldsSelect" selectedIndex="0">
<!-- TODO use values from SearchResultsPresenter.Display -->
<g:item value="target"><ui:msg>search target</ui:msg></g:item>
<g:item value="source"><ui:msg>search source</ui:msg></g:item>
<g:item value="both"><ui:msg>search both</ui:msg></g:item>
Expand Down

0 comments on commit be08335

Please sign in to comment.