Examples of HistoryToken


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

        this.configHolder = configHolder;
    }

    @Override
    public void onValueChange(ValueChangeEvent<String> event) {
        HistoryToken newHistoryToken =
                HistoryToken.fromTokenString(event.getValue());
        Log.info("[gwt-history] Responding to history token: "
                + event.getValue());

        processForDocumentListPresenter(newHistoryToken);
        processForProjectWideSearch(newHistoryToken);

        configHolder.setFilterByUntranslated(newHistoryToken
                .isFilterUntranslated());
        configHolder.setFilterByFuzzy(newHistoryToken.isFilterFuzzy());
        configHolder
                .setFilterByTranslated(newHistoryToken.isFilterTranslated());
        configHolder.setFilterByApproved(newHistoryToken.isFilterApproved());
        configHolder.setFilterByRejected(newHistoryToken.isFilterRejected());
        configHolder.setFilterByHasError(newHistoryToken.isFilterHasError());

        DocumentId documentId =
                documentListPresenter.getDocumentId(newHistoryToken
                        .getDocumentPath());
        EditorFilter editorFilter = getEditorFilterFromToken(newHistoryToken);
        if (!getTransUnitActionContextHolder.isContextInitialized()
                && documentId != null) {
            DocumentInfo documentInfo =
                    documentListPresenter.getDocumentInfo(documentId);
            // if editor is not yet initialized, we want to load document with
            // search and target trans unit all at once
            Long textFlowId = newHistoryToken.getTextFlowId();
            TransUnitId transUnitId =
                    textFlowId == null ? null : new TransUnitId(textFlowId);
            getTransUnitActionContextHolder.initContext(documentInfo,
                    transUnitId, editorFilter);
            eventBus.fireEvent(new InitEditorEvent());
        }

        processForAppPresenter(documentId);
        processForBookmarkedTextFlow(newHistoryToken);
        processMessageFilterOptions(newHistoryToken);

        currentHistoryState = newHistoryToken;
        appPresenter.showView(newHistoryToken.getView());
    }
View Full Code Here

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

        registerHandler(display.getReplacementTextBox().addValueChangeHandler(
                new ValueChangeHandler<String>() {

                    @Override
                    public void onValueChange(ValueChangeEvent<String> event) {
                        HistoryToken token = history.getHistoryToken();
                        if (!event.getValue().equals(
                                token.getProjectSearchReplacement())) {
                            token.setProjectSearchReplacement(event.getValue());
                            history.newItem(token);
                        }
                    }
                }));
View Full Code Here

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

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

                    // 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

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

        }
    }

    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

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

                .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

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

        }
    }

    @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

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

    }

    @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

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

        }
    }

    @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

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

    }

    @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
TOP
Copyright © 2018 www.massapi.com. 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.