Package org.zanata.webtrans.client.keys

Examples of org.zanata.webtrans.client.keys.Keys


    }

    private void registerKeyShortcut() {
        KeyShortcut confirmShortcut =
                KeyShortcut.Builder.builder()
                        .addKey(new Keys(Keys.CTRL_KEY, KeyCodes.KEY_ENTER))
                        .setContext(ShortcutContext.RejectConfirmationPopup)
                        .setHandler(new KeyShortcutEventHandler() {
                            @Override
                            public void onKeyShortcut(KeyShortcutEvent event) {
                                addComment(display.getComment());
View Full Code Here


    public void testKeyShortcutForAddComment() {
        when(display.getComment()).thenReturn("blah");
        KeyShortcut keyShortcut = keyShortcutCapture.getValue();

        assertThat(keyShortcut.getAllKeys().iterator().next(),
                Matchers.equalTo(new Keys(Keys.CTRL_KEY, KeyCodes.KEY_ENTER)));
        keyShortcut.getHandler().onKeyShortcut(mock(KeyShortcutEvent.class));

        verify(display).getComment();
        verify(dispatcher).execute(Mockito.isA(AddReviewCommentAction.class),
                Mockito.isA(AsyncCallback.class));
View Full Code Here

        // esc should be first as it has no modifiers
        Set<Keys> firstShortcutKeys = shortcutList.get(0).getAllKeys();
        String firstShortcut = "first shortcut should be Esc with no modifiers";
        assertThat(firstShortcut, firstShortcutKeys.size(), is(1));
        Keys firstShortcutFirstKeys = firstShortcutKeys.iterator().next();
        assertThat(firstShortcut, firstShortcutFirstKeys.getModifiers(), is(0));
        assertThat(firstShortcut, firstShortcutFirstKeys.getKeyCode(),
                is(KeyCodes.KEY_ESCAPE));

        // Alt+X should be next
        Set<Keys> secondShortcutKeys = shortcutList.get(1).getAllKeys();
        String secondShortcut = "second shortcut should be Alt+X";
        assertThat(secondShortcut, secondShortcutKeys.size(), is(1));
        Keys secondShortcutFirstKeys = secondShortcutKeys.iterator().next();
        assertThat(secondShortcut, secondShortcutFirstKeys.getModifiers(),
                is(Keys.ALT_KEY));
        assertThat(secondShortcut, secondShortcutFirstKeys.getKeyCode(),
                is((int) 'X'));

        // Alt+Y should be last
        Set<Keys> thirdShortcutKeys = shortcutList.get(2).getAllKeys();
        String thirdShortcut = "third shortcut should be Alt+Y";
        assertThat(thirdShortcut, thirdShortcutKeys.size(), is(1));
        Keys thirdShortcutFirstKeys = thirdShortcutKeys.iterator().next();
        assertThat(thirdShortcut, thirdShortcutFirstKeys.getModifiers(),
                is(Keys.ALT_KEY));
        assertThat(thirdShortcut, thirdShortcutFirstKeys.getKeyCode(),
                is((int) 'Y'));
    }
View Full Code Here

    }

    @Test
    public void testRespondsToAltY() {
        NativePreviewEvent altYPressed =
                buildNativeKeyDownEvent(new Keys(Keys.ALT_KEY, KEY_CODE_Y));
        mockShortcutDisplayListInteractions();
        keyShortcutPresenter.bind();
        capturedNativePreviewHandler.getValue().onPreviewNativeEvent(
                altYPressed);
        verify(mockDisplay).showPanel();
View Full Code Here

    }

    @Test
    public void testAttentionModeTimesOut() {
        NativePreviewEvent altXPressed =
                buildNativeKeyDownEvent(new Keys(Keys.ALT_KEY, KEY_CODE_X));
        mockShortcutDisplayListInteractions();
        ArgumentCaptor<AttentionModeActivationEvent> eventBusCapture =
                ArgumentCaptor.forClass(AttentionModeActivationEvent.class);

        Timer mockTimer = mock(Timer.class);
View Full Code Here

        keyShortcuts.registerCopyTMKeys();

        verify(keyShortcutPresenter, times(4)).register(
                keyShortcutCaptor.capture());
        List<KeyShortcut> keys = keyShortcutCaptor.getAllValues();
        assertKeys(keys.get(0), "copy from tm 1", false, false, new Keys(
                Keys.CTRL_ALT_KEYS, Keys.KEY_1), new Keys(Keys.CTRL_ALT_KEYS,
                Keys.KEY_NUM_1));
        assertKeys(keys.get(1), "copy from tm 2", false, false, new Keys(
                Keys.CTRL_ALT_KEYS, Keys.KEY_2), new Keys(Keys.CTRL_ALT_KEYS,
                Keys.KEY_NUM_2));
        assertKeys(keys.get(2), "copy from tm 3", false, false, new Keys(
                Keys.CTRL_ALT_KEYS, Keys.KEY_3), new Keys(Keys.CTRL_ALT_KEYS,
                Keys.KEY_NUM_3));
        assertKeys(keys.get(3), "copy from tm 4", false, false, new Keys(
                Keys.CTRL_ALT_KEYS, Keys.KEY_4), new Keys(Keys.CTRL_ALT_KEYS,
                Keys.KEY_NUM_4));
    }
View Full Code Here

        keyShortcuts.registerNavigationKeys(targetContentsPresenter);

        verify(keyShortcutPresenter, times(4)).register(
                keyShortcutCaptor.capture());
        List<KeyShortcut> keys = keyShortcutCaptor.getAllValues();
        assertKeys(keys.get(0), "next entry", true, true, new Keys(
                Keys.ALT_KEY, KeyCodes.KEY_DOWN), new Keys(Keys.ALT_KEY, 'K'));
        assertKeys(keys.get(1), "previous entry", true, true, new Keys(
                Keys.ALT_KEY, KeyCodes.KEY_UP), new Keys(Keys.ALT_KEY, 'J'));
        assertKeys(keys.get(2), "next fuzzy or untranslated", true, true,
                new Keys(Keys.ALT_KEY, KeyCodes.KEY_PAGEDOWN));
        assertKeys(keys.get(3), "previous fuzzy or untranslated", true, true,
                new Keys(Keys.ALT_KEY, KeyCodes.KEY_PAGEUP));
    }
View Full Code Here

        keyShortcuts.registerEditorActionKeys(targetContentsPresenter);

        verify(keyShortcutPresenter, times(4)).register(
                keyShortcutCaptor.capture());
        List<KeyShortcut> keys = keyShortcutCaptor.getAllValues();
        assertKeys(keys.get(0), "save fuzzy", true, true, new Keys(
                Keys.CTRL_KEY, 'S'));
        assertKeys(keys.get(1), "save approved", true, true, new Keys(
                Keys.CTRL_KEY, KeyCodes.KEY_ENTER));
        assertKeys(keys.get(2), "copy from source", true, true, new Keys(
                Keys.ALT_KEY, 'G'));
        assertAttentionKeys(keys.get(2), new Keys('G'));
        assertKeys(keys.get(3), "switch editor", true, true, new Keys(
                Keys.CTRL_ALT_KEYS, 'H'));
    }
View Full Code Here

        keyShortcuts.registerEditorActionKeys(targetContentsPresenter);

        verify(keyShortcutPresenter, times(5)).register(
                keyShortcutCaptor.capture());
        List<KeyShortcut> keys = keyShortcutCaptor.getAllValues();
        assertKeys(keys.get(0), "save fuzzy", true, true, new Keys(
                Keys.CTRL_KEY, 'S'));
        assertKeys(keys.get(1), "save approved", true, true, new Keys(
                Keys.CTRL_KEY, KeyCodes.KEY_ENTER));
        assertKeys(keys.get(2), "save approved", true, true, new Keys(
                Keys.NO_MODIFIER, KeyCodes.KEY_ENTER));
        assertKeys(keys.get(3), "copy from source", true, true, new Keys(
                Keys.ALT_KEY, 'G'));
        assertAttentionKeys(keys.get(3), new Keys('G'));
        assertKeys(keys.get(4), "switch editor", true, true, new Keys(
                Keys.CTRL_ALT_KEYS, 'H'));
    }
View Full Code Here

        verify(keyShortcutPresenter, atLeastOnce()).register(
                keyShortcutCaptor.capture());
        List<KeyShortcut> allKeys = keyShortcutCaptor.getAllValues();
        KeyShortcut shortcut = allKeys.get(allKeys.size() - 1); // last key

        assertKeys(shortcut, "enter save as approved", true, true, new Keys(
                Keys.NO_MODIFIER, KeyCodes.KEY_ENTER));
    }
View Full Code Here

TOP

Related Classes of org.zanata.webtrans.client.keys.Keys

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.