Package org.zanata.webtrans.shared.model

Examples of org.zanata.webtrans.shared.model.TransUnit


                    matchingTUs.get(textFlow.getDocument().getId());
            if (listForDoc == null) {
                listForDoc = new ArrayList<TransUnit>();
            }

            TransUnit transUnit =
                    transUnitTransformer.transform(textFlow, hLocale);
            listForDoc.add(transUnit);
            matchingTUs.put(textFlow.getDocument().getId(), listForDoc);
            docPaths.put(textFlow.getDocument().getId(), textFlow.getDocument()
                    .getDocId());
View Full Code Here


            return;
        }

        TransUnitTransformer transUnitTransformer =
                serviceLocator.getInstance(TransUnitTransformer.class);
        TransUnit transUnit =
                transUnitTransformer.transform(textFlow, target,
                        target.getLocale());

        DocumentId documentId =
                new DocumentId(document.getId(), document.getDocId());
        int wordCount = textFlow.getWordCount().intValue();

        TransUnitUpdateInfo updateInfo =
                createTransUnitUpdateInfo(transUnit, documentId, wordCount,
                        previousVersionNum, previousState);

        CacheValue context =
                updateContext.getIfPresent(new CacheKey(transUnit.getId(),
                        transUnit.getLocaleId()));
        TransUnitUpdated updated;
        if (context != null) {
            updated =
                    new TransUnitUpdated(updateInfo, context.editorClientId,
                            context.updateType);
View Full Code Here

    /**
     * Check if the editor is ready and selected. See gotoRow in
     * TargetContentsPresenter
     */
    private void copyTranslationToEditor() {
        TransUnit selectedTransUnit = navigationService.getSelectedOrNull();

        if (selectedTransUnit != null
                && selectedTransUnit.getId().equals(transUnitId)) {
            timer.cancel();
            eventBus.fireEvent(new CopyDataToEditorEvent(targets));
            if(saveAsFuzzyOpt) {
                listener.saveAsFuzzy(transUnitId);
            }
View Full Code Here

    @Override
    public void onTransUnitUpdated(TransUnitUpdatedEvent event) {
        if (contextHolder.isContextInitialized()) {
            if (Objects.equal(event.getUpdateInfo().getDocumentId(),
                    contextHolder.getContext().getDocument().getId())) {
                TransUnit updatedTU = event.getUpdateInfo().getTransUnit();
                boolean updated = updateDataModel(updatedTU);
                if (updated) {
                    pageDataChangeListener.refreshRow(updatedTU,
                            event.getEditorClientId(), event.getUpdateType());
                }
View Full Code Here

     * Display confirmation dialog box if new status of TU has been changed to
     * approved without any content changes.
     */
    @Override
    public void onCheckStateHasChanged(CheckStateHasChangedEvent event) {
        TransUnit transUnit =
                navigationService.getByIdOrNull(event.getTransUnitId());
        if (transUnit == null) {
            return;
        }

        boolean targetChanged =
                !Objects.equal(transUnit.getTargets(), event.getTargets());
        boolean targetUnchangedButCanSaveAsApproved =
                (event.getAdjustedState() == ContentState.Translated)
                        && !Objects.equal(transUnit.getStatus(),
                                event.getAdjustedState());

        if (targetChanged) {
            targetContentsPresenter.saveAsApprovedAndMoveNext(event
                    .getTransUnitId());
View Full Code Here

            eventBus.fireEvent(NavTransUnitEvent.NEXT_ENTRY_EVENT);
        }
    }

    private boolean stateHasNotChanged(TransUnitSaveEvent event) {
        TransUnit transUnit =
                navigationService.getByIdOrNull(event.getTransUnitId());
        if (transUnit == null) {
            return false;
        }
        Log.info("id:" + transUnit.getId() + " old contents: "
                + transUnit.getTargets() + " state: " + transUnit.getStatus());
        return Objects.equal(transUnit.getStatus(), event.getAdjustedStatus())
                && Objects.equal(transUnit.getTargets(), event.getTargets());
    }
View Full Code Here

            saveFailure(e.getMessage());
        }

        @Override
        public void onSuccess(UpdateTransUnitResult result) {
            TransUnit updatedTU =
                    result.getUpdateInfoList().get(0).getTransUnit();
            Log.debug("save resulted TU: " + updatedTU.debugString());
            if (result.isSingleSuccess()) {
                eventBus.fireEvent(new NotificationEvent(
                        NotificationEvent.Severity.Info, messages
                                .notifyUpdateSaved(updatedTU.getRowIndex(),
                                        updatedTU.getId().toString()),
                        goToRowLink));
                int rowIndexOnPage =
                        navigationService.findRowIndexById(updatedTU.getId());
                if (rowIndexOnPage != NavigationService.UNDEFINED) {
                    UndoLink undoLink = undoLinkProvider.get();
                    undoLink.prepareUndoFor(result);
                    targetContentsPresenter.addUndoLink(rowIndexOnPage,
                            undoLink);
                    navigationService.updateDataModel(updatedTU);
                    targetContentsPresenter.confirmSaved(updatedTU);
                    targetContentsPresenter.setFocus();
                }
                queue.removeSaved(event, updatedTU.getVerNum());
            } else {
                saveFailure(result.getUpdateInfoList().get(0).getErrorMessage());
            }
            if (queue.hasPending()) {
                performSave(id);
View Full Code Here

    protected void onRevealDisplay() {
    }

    @Override
    public void onTransUnitSelected(TransUnitSelectionEvent event) {
        TransUnit selection = event.getSelection();
        selectedId = selection.getId();
        Log.debug("selected id: " + selectedId);
        sourceContentsPresenter.setSelectedSource(selectedId);
        targetContentsPresenter.setSelected(selectedId);
        display.ensureVisible(targetContentsPresenter.getCurrentDisplay());
        translatorService.transUnitSelected(selection);
View Full Code Here

        checkPanelDisplayOption();
        display.setSouthPanelExpanded(expanded);
        if (expanded && !userWorkspaceContext.hasReadOnlyAccess()) {
            bindSouthPanelPresenters();

            TransUnit tu = navigationService.getSelectedOrNull();
            if (tu != null) {
                if (configHolder.getState().isShowTMPanel()) {
                    transMemoryPresenter.createTMRequestForTransUnit(tu);
                }
                if (configHolder.getState().isShowGlossaryPanel()) {
View Full Code Here

      // @formatter:on
    }

    @Test
    public void testExecute() throws Exception {
        TransUnit transUnit =
                TestFixture.makeTransUnit(1, ContentState.NeedReview, "target");
        PreviewReplaceText action =
                new PreviewReplaceText(new ReplaceText(transUnit, "target",
                        "replace", true));

        PreviewReplaceTextResult result = handler.execute(action, null);

        verify(identity).checkLoggedIn();
        assertThat(result.getPreviews(), Matchers.hasSize(1));
        TransUnitUpdatePreview preview = result.getPreviews().get(0);
        assertThat(preview.getId(), Matchers.equalTo(transUnit.getId()));
        assertThat(preview.getState(),
                Matchers.equalTo(ContentState.NeedReview));
        assertThat(preview.getContents(), Matchers.contains("replace"));
    }
View Full Code Here

TOP

Related Classes of org.zanata.webtrans.shared.model.TransUnit

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.