Package org.zanata.webtrans.client.events

Examples of org.zanata.webtrans.client.events.NotificationEvent


        GetLocaleList action = new GetLocaleList();

        dispatcher.execute(action, new AsyncCallback<GetLocaleListResult>() {
            @Override
            public void onFailure(Throwable caught) {
                eventBus.fireEvent(new NotificationEvent(NotificationEvent
                        .Severity.Error, "Failed to fetch locales"));
            }

            @Override
            public void onSuccess(GetLocaleListResult result) {
View Full Code Here


        dispatcher.execute(new GetTranslationHistoryAction(transUnitId),
                new AsyncCallback<GetTranslationHistoryResult>() {
                    @Override
                    public void onFailure(Throwable caught) {
                        Log.error("failure getting translation history", caught);
                        eventBus.fireEvent(new NotificationEvent(
                                NotificationEvent.Severity.Error, caught
                                        .getMessage()));
                        display.hide();
                    }
View Full Code Here

            @Override
            public void onFailure(Throwable caught) {
                Log.error("[SearchResultsPresenter] failed project-wide search request: "
                        + caught.getMessage());
                eventBus.fireEvent(new NotificationEvent(Severity.Error,
                        messages.searchFailed()));
                display.clearAll();
                display.getSearchResponseLabel().setText(
                        messages.searchFailed());
            }
View Full Code Here

     *
     * @param toPreview
     */
    private void firePreviewEvent(List<TransUnitReplaceInfo> toPreview) {
        if (toPreview.isEmpty()) {
            eventBus.fireEvent(new NotificationEvent(Severity.Warning, messages
                    .noTextFlowsSelected()));
            return;
        }
        final String replacement = display.getReplacementTextBox().getValue();
        // prevent failed requests for empty replacement
        if (replacement.isEmpty()) {
            eventBus.fireEvent(new NotificationEvent(Severity.Warning, messages
                    .noReplacementPhraseEntered()));
            return;
        }

        List<TransUnit> transUnits = new ArrayList<TransUnit>();
        for (TransUnitReplaceInfo replaceInfo : toPreview) {
            switch (replaceInfo.getPreviewState()) {
            case NotFetched:
                transUnits.add(replaceInfo.getTransUnit());
                replaceInfo.setPreviewState(PreviewState.Fetching);
                refreshInfoDisplay(replaceInfo);
                break;
            case Hide:
                replaceInfo.setPreviewState(PreviewState.Show);
                refreshInfoDisplay(replaceInfo);
                break;
            }
        }

        if (transUnits.isEmpty()) {
            // could notify user, doesn't seem worthwhile
            return;
        }

        final String searchText = display.getFilterTextBox().getValue();
        boolean caseSensitive = display.getCaseSensitiveChk().getValue();
        ReplaceText action =
                new ReplaceText(transUnits, searchText, replacement,
                        caseSensitive);
        PreviewReplaceText previewAction = new PreviewReplaceText(action);
        dispatcher.execute(previewAction,
                new AsyncCallback<PreviewReplaceTextResult>() {

                    @Override
                    public void onFailure(Throwable e) {
                        Log.error(
                                "[SearchResultsPresenter] Preview replace text failure "
                                        + e, e);
                        eventBus.fireEvent(new NotificationEvent(
                                Severity.Error, messages.previewFailed()));
                        // may want to change TU state from 'previewing'
                        // (possibly error
                        // state)
                    }

                    @Override
                    public void
                            onSuccess(final PreviewReplaceTextResult result) {
                        for (TransUnitUpdatePreview preview : result
                                .getPreviews()) {
                            TransUnitReplaceInfo replaceInfo =
                                    allReplaceInfos.get(preview.getId());
                            if (replaceInfo == null) {
                                Log.error("no replace info found for previewed text flow");
                            } else {
                                Log.debug("setting preview state for preview id: "
                                        + preview.getId());
                                replaceInfo.setPreview(preview);
                                replaceInfo.setPreviewState(PreviewState.Show);
                                refreshInfoDisplay(replaceInfo);
                            }
                        }
                        refreshReplaceAllButton();
                        eventBus.fireEvent(new NotificationEvent(Severity.Info,
                                messages.fetchedPreview()));
                    }

                });
    }
View Full Code Here

    private void replaceSelected() {
        if (replaceSelectedAllowed()) {
            fireReplaceTextEvent(getAllSelected());
        } else {
            eventBus.fireEvent(new NotificationEvent(Severity.Warning, messages
                    .previewRequiredBeforeReplace()));
        }
    }
View Full Code Here

     * @param toReplace
     *            list of TransUnits to replace
     */
    private void fireReplaceTextEvent(List<TransUnitReplaceInfo> toReplace) {
        if (!userWorkspaceContext.hasEditTranslationAccess()) {
            eventBus.fireEvent(new NotificationEvent(Severity.Warning, messages
                    .youAreNotAllowedToModifyTranslations()));
            return;
        }

        if (toReplace.isEmpty()) {
            eventBus.fireEvent(new NotificationEvent(Severity.Warning, messages
                    .noTextFlowsSelected()));
            return;
        }
        List<TransUnit> transUnits = new ArrayList<TransUnit>();
        for (TransUnitReplaceInfo info : toReplace) {
            switch (info.getReplaceState()) {
            case NotReplaced:
                transUnits.add(info.getTransUnit());
                setReplaceState(info, ReplacementState.Replacing);
                info.setPreviewState(PreviewState.Hide);
                refreshInfoDisplay(info);
                break;
            }
        }

        if (transUnits.isEmpty()) {
            eventBus.fireEvent(new NotificationEvent(Severity.Warning, messages
                    .noReplacementsToMake()));
            return;
        }

        final String searchText = display.getFilterTextBox().getValue();
        final String replacement = display.getReplacementTextBox().getValue();
        boolean caseSensitive = display.getCaseSensitiveChk().getValue();
        ReplaceText action =
                new ReplaceText(transUnits, searchText, replacement,
                        caseSensitive);
        dispatcher.execute(action, new AsyncCallback<UpdateTransUnitResult>() {

            @Override
            public void onFailure(Throwable e) {
                Log.error("[SearchResultsPresenter] Replace text failure " + e,
                        e);
                eventBus.fireEvent(new NotificationEvent(Severity.Error,
                        messages.replaceTextFailure()));
                // may want to change state from 'replacing' (possibly add error
                // state)
            }

            @Override
            public void onSuccess(final UpdateTransUnitResult result) {
                final List<TransUnitUpdateInfo> updateInfoList =
                        processSuccessfulReplacements(result
                                .getUpdateInfoList());

                if (updateInfoList.isEmpty()) {
                    eventBus.fireEvent(new NotificationEvent(Info, messages
                            .noReplacementsToMake()));
                    return;
                }

                String message;
                if (updateInfoList.size() == 1) {
                    TransUnitUpdateInfo info = updateInfoList.get(0);
                    String text = info.getTransUnit().getTargets().get(0);
                    String truncatedText =
                            text.substring(
                                    0,
                                    (text.length() <= TRUNCATED_TARGET_LENGTH ? text
                                            .length() : TRUNCATED_TARGET_LENGTH));
                    int oneBasedRowIndex =
                            info.getTransUnit().getRowIndex() + 1;
                    String docName = docPaths.get(info.getDocumentId().getId());
                    message =
                            messages.replacedTextInOneTextFlow(searchText,
                                    replacement, docName, oneBasedRowIndex,
                                    truncatedText);
                } else {
                    message =
                            messages.replacedTextInMultipleTextFlows(
                                    searchText, replacement,
                                    updateInfoList.size());
                }

                final UndoLink undoLink = undoLinkProvider.get();
                undoLink.prepareUndoFor(result);
                undoLink.setUndoCallback(new UndoLink.UndoCallback() {
                    @Override
                    public void preUndo() {
                        executePreUndo(updateInfoList);
                    }

                    @Override
                    public void postUndoSuccess() {
                        executePostSucess(result);
                    }
                });

                NotificationEvent event =
                        new NotificationEvent(Info, message, undoLink);
                eventBus.fireEvent(event);
            }
        });
    }
View Full Code Here

     */
    private void fireUndoEvent(List<TransUnitUpdateInfo> updateInfoList) {
        // TODO only fire undo for flows that are undoable?
        // rpc method should cope with this anyway, so no big deal

        eventBus.fireEvent(new NotificationEvent(Severity.Info, messages
                .undoInProgress()));
        RevertTransUnitUpdates action = new RevertTransUnitUpdates();
        executePreUndo(updateInfoList);
        dispatcher.execute(action, new AsyncCallback<UpdateTransUnitResult>() {
            @Override
            public void onFailure(Throwable caught) {
                eventBus.fireEvent(new NotificationEvent(Severity.Error,
                        messages.undoReplacementFailure()));
            }

            @Override
            public void onSuccess(UpdateTransUnitResult result) {
View Full Code Here

                    // anyway may want to remove this
                    replaceInfo.setTransUnit(updateInfo.getTransUnit());
                    refreshInfoDisplay(replaceInfo);
                }
            } else {
                eventBus.fireEvent(new NotificationEvent(Severity.Error,
                        messages.replaceTextFailureWithMessage(updateInfo
                                .getTransUnit().getId().toString(),
                                updateInfo.getErrorMessage())));
            }
        }
View Full Code Here

        dispatcher.execute(new LoadOptionsAction(prefixes),
                new AsyncCallback<LoadOptionsResult>() {
                    @Override
                    public void onFailure(Throwable caught) {
                        eventBus.fireEvent(new NotificationEvent(
                                NotificationEvent.Severity.Warning,
                                "Unable to load user options"));
                    }

                    @Override
                    public void onSuccess(LoadOptionsResult result) {
                        userOptionsService.getConfigHolder().setState(
                                result.getConfiguration());
                        display.setOptionsState(userOptionsService
                                .getConfigHolder().getState());
                        eventBus.fireEvent(UserConfigChangeEvent.DOCUMENT_CONFIG_CHANGE_EVENT);
                        eventBus.fireEvent(new NotificationEvent(
                                NotificationEvent.Severity.Warning,
                                "Loaded user options"));
                    }
                });
    }
View Full Code Here

    public void loadDefaultOptions() {
        userOptionsService.loadDocumentListDefaultOptions();
        display.setOptionsState(userOptionsService.getConfigHolder().getState());

        eventBus.fireEvent(UserConfigChangeEvent.DOCUMENT_CONFIG_CHANGE_EVENT);
        eventBus.fireEvent(new NotificationEvent(
                NotificationEvent.Severity.Warning,
                "Loaded default user options."));
    }
View Full Code Here

TOP

Related Classes of org.zanata.webtrans.client.events.NotificationEvent

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.