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

Commit

Permalink
use default value for history token filter type
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmason committed Dec 9, 2011
1 parent eaf97fc commit 4bf027e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 40 deletions.
Expand Up @@ -18,18 +18,18 @@ public class HistoryToken
public static final String KEY_DOCUMENT = "doc";

public static final String KEY_VIEW = "view";
public static final String VALUE_DOCLIST_VIEW = "list";
// public static final String VALUE_DOCLIST_VIEW = "list";
public static final String VALUE_EDITOR_VIEW = "doc";

public static final String KEY_DOC_FILTER_TEXT = "filter";

public static final String KEY_DOC_FILTER_OPTION = "filtertype";
public static final String VALUE_DOC_FILTER_EXACT = "exact";
public static final String VALUE_DOC_FILTER_INEXACT = "substr";
// public static final String VALUE_DOC_FILTER_INEXACT = "substr";

private AppPresenter.Display.MainView view;
private String fullDocPath;
private Boolean docFilterExact;
private boolean docFilterExact;
private String docFilterText;

// defaults
Expand Down Expand Up @@ -91,8 +91,7 @@ else if (key == HistoryToken.KEY_DOC_FILTER_OPTION)
{
if (value == VALUE_DOC_FILTER_EXACT)
historyToken.setDocFilterExact(true);
else if (value == VALUE_DOC_FILTER_INEXACT)
historyToken.setDocFilterExact(false);
// else default used
}
else if (key == HistoryToken.KEY_DOC_FILTER_TEXT)
{
Expand Down Expand Up @@ -133,17 +132,12 @@ public void setView(AppPresenter.Display.MainView view)
this.view = view;
}

public boolean hasDocFilterExact()
{
return docFilterExact != null;
}

public Boolean getDocFilterExact()
{
return docFilterExact;
}

public void setDocFilterExact(Boolean exactMatch)
public void setDocFilterExact(boolean exactMatch)
{
docFilterExact = exactMatch;
}
Expand Down Expand Up @@ -189,14 +183,14 @@ public String toTokenString()
token += KEY_DOCUMENT + DELIMITER_K_V + fullDocPath;
}

if (hasDocFilterExact())
if (docFilterExact != DEFAULT_DOC_FILTER_EXACT)
{
if (first)
first = false;
else
token += PAIR_SEPARATOR;
token += KEY_DOC_FILTER_OPTION + DELIMITER_K_V;
token += docFilterExact ? VALUE_DOC_FILTER_EXACT : VALUE_DOC_FILTER_INEXACT;
// exact is the only non-default filter value
token += KEY_DOC_FILTER_OPTION + DELIMITER_K_V + VALUE_DOC_FILTER_EXACT;
}

if (!docFilterText.equals(DEFAULT_DOC_FILTER_TEXT))
Expand Down
Expand Up @@ -224,35 +224,16 @@ public void onValueChange(ValueChangeEvent<String> event)
filterChanged = true;
}

if (token.hasDocFilterExact())
// update checkbox to match new history state
if (token.getDocFilterExact() != display.getExactSearchCheckbox().getValue())
{
// update checkbox to match new history state
if (token.getDocFilterExact() != display.getExactSearchCheckbox().getValue())
{
display.getExactSearchCheckbox().setValue(token.getDocFilterExact());
}

boolean flagChanged;
if (currentHistoryState == null)
flagChanged = true;
else
flagChanged = !token.getDocFilterExact().equals(currentHistoryState.getDocFilterExact());

if (flagChanged)
{
filter.setFullText(token.getDocFilterExact());
filterChanged = true;
}
display.getExactSearchCheckbox().setValue(token.getDocFilterExact());
}
else

if (token.getDocFilterExact() != currentHistoryState.getDocFilterExact())
{
if (currentHistoryState != null && currentHistoryState.hasDocFilterExact() && currentHistoryState.getDocFilterExact() == true)
{
// not using default
filter.setFullText(false);
filterChanged = true;
}
// else was already using substring match
filter.setFullText(token.getDocFilterExact());
filterChanged = true;
}

currentHistoryState = token;
Expand Down

0 comments on commit 4bf027e

Please sign in to comment.