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

Commit

Permalink
ensure appropriate context activation when searching
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmason committed Apr 28, 2014
1 parent 1808dce commit 63899b8
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 24 deletions.
Expand Up @@ -31,6 +31,7 @@
import org.zanata.webtrans.client.events.UserConfigChangeHandler;
import org.zanata.webtrans.client.history.History;
import org.zanata.webtrans.client.history.HistoryToken;
import org.zanata.webtrans.client.keys.ShortcutContext;
import org.zanata.webtrans.client.service.UserOptionsService;
import org.zanata.webtrans.client.view.TransFilterDisplay;

Expand All @@ -42,15 +43,18 @@ public class TransFilterPresenter extends WidgetPresenter<TransFilterDisplay>
private final History history;

private final UserOptionsService userOptionsService;
private final KeyShortcutPresenter keyShortcutPresenter;

@Inject
public TransFilterPresenter(final TransFilterDisplay display,
final EventBus eventBus, final History history,
UserOptionsService userOptionsService) {
UserOptionsService userOptionsService,
KeyShortcutPresenter keyShortcutPresenter) {
super(display, eventBus);
display.setListener(this);
this.history = history;
this.userOptionsService = userOptionsService;
this.keyShortcutPresenter = keyShortcutPresenter;
}

@Override
Expand Down Expand Up @@ -91,6 +95,12 @@ public void messageFilterOptionChanged(Boolean translatedChkValue,
hasErrorChkValue);
}

@Override
public void onSearchFieldFocused(boolean focused) {
keyShortcutPresenter.setContextActive(ShortcutContext.Edit, !focused);
keyShortcutPresenter.setContextActive(ShortcutContext.Navigation, !focused);
}

@Override
public void onFindMessage(FindMessageEvent event) {
// this is fired from HistoryEventHandlerService
Expand Down
Expand Up @@ -84,16 +84,16 @@ private native void initTextBox(Element wrapper, EditorSearchFieldListener liste
// public void onFilterTextBoxClick(ClickEvent event) {
// listener.onSearchFieldClick();
// }
//
// @UiHandler("filterTextBox")
// public void onFilterTextBoxBlur(BlurEvent event) {
// listener.onSearchFieldBlur();
// }
//
// @UiHandler("filterTextBox")
// public void onFilterTextBoxFocus(FocusEvent event) {
// listener.onSearchFieldFocus();
// }

@UiHandler("filterTextBox")
public void onFilterTextBoxBlur(BlurEvent event) {
listener.onSearchFieldBlur();
}

@UiHandler("filterTextBox")
public void onFilterTextBoxFocus(FocusEvent event) {
listener.onSearchFieldFocus();
}

@UiHandler("cancelBtn")
public void onCancel(ClickEvent event) {
Expand Down
Expand Up @@ -3,9 +3,9 @@
public interface EditorSearchFieldListener {
void onSearchFieldValueChange(String value);

// void onSearchFieldBlur();
void onSearchFieldBlur();

// void onSearchFieldFocus();
void onSearchFieldFocus();

// void onSearchFieldClick();

Expand Down
Expand Up @@ -35,6 +35,8 @@ void messageFilterOptionChanged(Boolean translatedChkValue,
Boolean fuzzyChkValue, Boolean untranslatedChkValue,
Boolean approvedChkValue, Boolean rejectedChkValue,
Boolean hasErrorChkValue);

void onSearchFieldFocused(boolean focused);
}

void setOptionsState(ConfigurationState state);
Expand Down
Expand Up @@ -158,17 +158,15 @@ public void onSearchFieldValueChange(String value) {
listener.searchTerm(value);
}

// @Override
// public void onSearchFieldBlur() {
// Log.info("search field blur event received");
// focused = false;
// }
@Override
public void onSearchFieldBlur() {
listener.onSearchFieldFocused(false);
}

// @Override
// public void onSearchFieldFocus() {
// Log.info("search field focus event received");
// focused = true;
// }
@Override
public void onSearchFieldFocus() {
listener.onSearchFieldFocused(true);
}

// @Override
// public void onSearchFieldClick() {
Expand Down
Expand Up @@ -34,6 +34,8 @@ public class TransFilterPresenterTest {
private History history;
@Mock
private UserOptionsService userOptionsService;
@Mock
private KeyShortcutPresenter keyShortcutPresenter;

private UserConfigHolder configHolder = new UserConfigHolder();

Expand All @@ -45,7 +47,7 @@ public void setUp() throws Exception {

presenter =
new TransFilterPresenter(display, eventBus, history,
userOptionsService);
userOptionsService, keyShortcutPresenter);

verify(display).setListener(presenter);
}
Expand Down

0 comments on commit 63899b8

Please sign in to comment.