Package org.zanata.webtrans.client.history

Examples of org.zanata.webtrans.client.history.HistoryToken


    private void showDocInEditor(String doc, boolean runSearch) {
        contextHolder.updateContext(null); // this will ensure editor reload
                                           // (prevent multiple cursors in code
                                           // mirror)
        HistoryToken token = HistoryToken.fromTokenString(history.getToken());
        token.setDocumentPath(doc);
        token.clearEditorFilterAndSearch();
        token.setView(MainView.Editor);
        if (runSearch) {
            token.setEditorTextSearch(token.getProjectSearchText());
        } else {
            token.setEditorTextSearch("");
        }
        history.newItem(token);
    }
View Full Code Here


                    // result,
                    // requested text flow may not appear in result. We want to
                    // make
                    // sure it reloads everything for this document.

                    HistoryToken token = history.getHistoryToken();
                    contextHolder.updateContext(null); // this will ensure
                                                       // HistoryEventHandlerService
                                                       // fire InitEditorEvent
                    token.clearEditorFilterAndSearch();
                    token.setView(MainView.Editor);
                    token.setDocumentPath(docPaths.get(info.getDocId()));
                    token.setTextFlowId(info.getTransUnit().getId().toString());
                    history.newItem(token);
                }
            };
        }
        return goToEditorDelegate;
View Full Code Here

        }
    }

    private void updateSearch() {
        boolean changed = false;
        HistoryToken token = history.getHistoryToken();

        Boolean caseSensitive = display.getCaseSensitiveChk().getValue();
        if (caseSensitive != token.getProjectSearchCaseSensitive()) {
            token.setProjectSearchCaseSensitive(caseSensitive);
            changed = true;
        }

        String searchPhrase = display.getFilterTextBox().getValue();
        if (!searchPhrase.equals(token.getProjectSearchText())) {
            token.setProjectSearchText(searchPhrase);
            changed = true;
        }

        String selected = display.getSelectedSearchField();
        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);
            changed = true;
        }
        if (searchTarget != token.isProjectSearchInTarget()) {
            token.setProjectSearchInTarget(searchTarget);
            changed = true;
        }

        if (changed) {
            history.newItem(token);
View Full Code Here

                .setContext(ShortcutContext.Application)
                .setDescription(messages.showDocumentListKeyShortcut())
                .setHandler(new KeyShortcutEventHandler() {
                    @Override
                    public void onKeyShortcut(KeyShortcutEvent event) {
                        HistoryToken token = history.getHistoryToken();
                        token.setView(MainView.Documents);
                        history.newItem(token.toTokenString());
                    }
                }).build());

        keyShortcutPresenter.register(KeyShortcut.Builder.builder()
                .addKey(new Keys(Keys.ALT_KEY, 'O'))
                .setContext(ShortcutContext.Application)
                .setDescription(messages.showEditorKeyShortcut())
                .setHandler(new KeyShortcutEventHandler() {
                    @Override
                    public void onKeyShortcut(KeyShortcutEvent event) {
                        if (selectedDocument == null) {
                            eventBus.fireEvent(new NotificationEvent(
                                    Severity.Warning, messages
                                            .noDocumentSelected()));
                        } else {
                            HistoryToken token = history.getHistoryToken();
                            token.setView(MainView.Editor);
                            history.newItem(token.toTokenString());
                        }
                    }
                }).build());

        keyShortcutPresenter.register(KeyShortcut.Builder.builder()
                .addKey(new Keys(Keys.ALT_KEY, 'P'))
                .setContext(ShortcutContext.Application)
                .setDescription(messages.showProjectWideSearch())
                .setHandler(new KeyShortcutEventHandler() {
                    @Override
                    public void onKeyShortcut(KeyShortcutEvent event) {
                        HistoryToken token = history.getHistoryToken();
                        token.setView(MainView.Search);
                        history.newItem(token.toTokenString());
                    }
                }).build());
    }
View Full Code Here

        }
    }

    @Override
    public void onSearchAndReplaceClicked() {
        HistoryToken token = HistoryToken.fromTokenString(history.getToken());
        if (!token.getView().equals(MainView.Search)) {
            token.setView(MainView.Search);
            history.newItem(token.toTokenString());
        }
    }
View Full Code Here

    }

    @Override
    public void onEditorClicked() {
        if (selectedDocument != null) {
            HistoryToken token =
                    HistoryToken.fromTokenString(history.getToken());
            if (!token.getView().equals(MainView.Editor)) {
                token.setView(MainView.Editor);
                history.newItem(token.toTokenString());
            }
        }
    }
View Full Code Here

        }
    }

    @Override
    public void onDocumentListClicked() {
        HistoryToken token = HistoryToken.fromTokenString(history.getToken());
        if (!token.getView().equals(MainView.Documents)) {
            token.setView(MainView.Documents);
            history.newItem(token.toTokenString());
        }
    }
View Full Code Here

    }

    @Test
    public void processHistoryTokenWithInitializedContext() {
        // Given: history token contains everything and editor context is loaded
        HistoryToken token = new HistoryToken();
        token.setDocFilterText("doc filter test");
        token.setEditorTextSearch("search text");
        token.setProjectSearchText("project search text");
        token.setDocumentPath("doc/path");
        token.setProjectSearchReplacement("replacement");
        when(historyChangeEvent.getValue()).thenReturn(token.toTokenString());
        DocumentInfo documentInfo = TestFixture.documentInfo(1, "doc/path");
        DocumentId documentId = documentInfo.getId();
        when(documentListPresenter.getDocumentId("doc/path")).thenReturn(
                documentId);
        when(documentListPresenter.getDocumentInfo(documentId)).thenReturn(
                documentInfo);
        when(appPresenter.getSelectedDocIdOrNull()).thenReturn(
                new DocumentId(new Long(99), ""));
        contextHolder.updateContext(new GetTransUnitActionContext(documentInfo(
                99, "")));

        // When:
        service.onValueChange(historyChangeEvent);

        // Then:
        InOrder inOrder =
                Mockito.inOrder(documentListPresenter, appPresenter, eventBus,
                        searchResultsPresenter);
        inOrder.verify(documentListPresenter).updateFilterAndRun(
                token.getDocFilterText(), token.getDocFilterExact(),
                token.isDocFilterCaseSensitive());
        inOrder.verify(searchResultsPresenter).updateViewAndRun(
                token.getProjectSearchText(),
                token.getProjectSearchCaseSensitive(),
                token.isProjectSearchInSource(),
                token.isProjectSearchInTarget());
        inOrder.verify(searchResultsPresenter).updateReplacementText(
                token.getProjectSearchReplacement());
        inOrder.verify(documentListPresenter).getDocumentId(
                token.getDocumentPath());
        inOrder.verify(appPresenter).getSelectedDocIdOrNull();
        inOrder.verify(appPresenter).selectDocument(documentId);
        inOrder.verify(documentListPresenter).getDocumentInfo(documentId);
        inOrder.verify(eventBus).fireEvent(
                Mockito.isA(DocumentSelectionEvent.class));
        inOrder.verify(eventBus).fireEvent(UserConfigChangeEvent.EDITOR_CONFIG_CHANGE_EVENT);
        inOrder.verify(eventBus).fireEvent(Mockito.isA(FilterViewEvent.class));
        inOrder.verify(appPresenter).showView(token.getView());

        verifyNoMoreInteractions(documentListPresenter, appPresenter, eventBus,
                searchResultsPresenter);
    }
View Full Code Here

    @Test
    public void processHistoryTokenForUninitializedContext() {
        // Given: history token contains everything but editor context is not
        // initialized
        HistoryToken token = new HistoryToken();
        token.setDocFilterText("doc filter test");
        token.setProjectSearchText("project search text");
        token.setDocumentPath("doc/path");
        token.setProjectSearchReplacement("replacement");
        token.setTextFlowId("1");
        when(historyChangeEvent.getValue()).thenReturn(token.toTokenString());
        DocumentInfo documentInfo = TestFixture.documentInfo(1, "doc/path");
        DocumentId documentId = documentInfo.getId();
        when(documentListPresenter.getDocumentId("doc/path")).thenReturn(
                documentId);
        when(documentListPresenter.getDocumentInfo(documentId)).thenReturn(
                documentInfo);
        when(appPresenter.getSelectedDocIdOrNull()).thenReturn(
                new DocumentId(new Long(99), ""));
        contextHolder.updateContext(null);

        // When:
        service.onValueChange(historyChangeEvent);

        // Then:
        InOrder inOrder =
                Mockito.inOrder(documentListPresenter, appPresenter, eventBus,
                        searchResultsPresenter);
        inOrder.verify(documentListPresenter).updateFilterAndRun(
                token.getDocFilterText(), token.getDocFilterExact(),
                token.isDocFilterCaseSensitive());
        inOrder.verify(searchResultsPresenter).updateViewAndRun(
                token.getProjectSearchText(),
                token.getProjectSearchCaseSensitive(),
                token.isProjectSearchInSource(),
                token.isProjectSearchInTarget());
        inOrder.verify(searchResultsPresenter).updateReplacementText(
                token.getProjectSearchReplacement());

        inOrder.verify(documentListPresenter).getDocumentId(
                token.getDocumentPath());
        inOrder.verify(documentListPresenter).getDocumentInfo(documentId);
        inOrder.verify(eventBus).fireEvent(Mockito.isA(InitEditorEvent.class));
        inOrder.verify(appPresenter).getSelectedDocIdOrNull();
        inOrder.verify(appPresenter).selectDocument(documentId);
        inOrder.verify(documentListPresenter).getDocumentInfo(documentId);
        inOrder.verify(eventBus).fireEvent(
                Mockito.isA(DocumentSelectionEvent.class));
        inOrder.verify(appPresenter).showView(token.getView());

        verifyNoMoreInteractions(documentListPresenter, appPresenter, eventBus,
                searchResultsPresenter);
    }
View Full Code Here

    }

    @Test
    public void processBookmarkedTextFlowWhenEditorIsNotInitialized() {
        // Given: editor is not initialized yet
        HistoryToken token = new HistoryToken();
        token.setTextFlowId("1");

        // When:
        service.processForBookmarkedTextFlow(token);

        // Then:
View Full Code Here

TOP

Related Classes of org.zanata.webtrans.client.history.HistoryToken

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.