Exemplo n.º 1
0
  public void show(final GlossaryResultItem item) {
    // request glossary details from the server
    dispatcher.execute(
        new GetGlossaryDetailsAction(item.getSourceIdList()),
        new AsyncCallback<GetGlossaryDetailsResult>() {
          @Override
          public void onFailure(Throwable caught) {
            Log.error(caught.getMessage(), caught);
          }

          @Override
          public void onSuccess(GetGlossaryDetailsResult result) {
            glossaryDetails = result;
            display.getSourceText().setText(item.getSource());
            display.getTargetText().setText(item.getTarget());
            display.clearEntries();

            int i = 1;
            for (GlossaryDetails detailsItem : result.getGlossaryDetails()) {
              display
                  .getSourceLabel()
                  .setText(messages.glossarySourceTermLabel(detailsItem.getSrcLocale().toString()));
              display
                  .getTargetLabel()
                  .setText(
                      messages.glossaryTargetTermLabel(detailsItem.getTargetLocale().toString()));
              display.addEntry(messages.entriesLabel(i));
              i++;
            }
            selectEntry(0);
            display.show();
          }
        });
  }
Exemplo n.º 2
0
  @Override
  public void onSaveClick() {
    if (selectedDetailEntry != null && userWorkspaceContext.hasGlossaryUpdateAccess()) {
      // check if there's any changes on the target term or the target
      // comments and save
      if (!display.getTargetText().getText().equals(selectedDetailEntry.getTarget())) {
        display.showLoading(true);
        UpdateGlossaryTermAction action =
            new UpdateGlossaryTermAction(
                selectedDetailEntry,
                display.getTargetText().getText(),
                display.getCurrentTargetComments());

        dispatcher.execute(
            action,
            new AsyncCallback<UpdateGlossaryTermResult>() {
              @Override
              public void onFailure(Throwable caught) {
                Log.error(caught.getMessage(), caught);
                eventBus.fireEvent(
                    new NotificationEvent(Severity.Error, messages.saveGlossaryFailed()));
                display.showLoading(false);
              }

              @Override
              public void onSuccess(UpdateGlossaryTermResult result) {
                Log.info("Glossary term updated:" + result.getDetail().getTarget());
                glossaryListener.fireSearchEvent();
                selectedDetailEntry = result.getDetail();
                populateDisplayData();
                display.showLoading(false);
              }
            });
      }
    }
  }
  private void performSave(TransUnitId idToSave) {
    TransUnitSaveEvent forSaving = queue.getNextPendingForSaving(idToSave);
    if (forSaving == null) {
      Log.info("no pending save for " + idToSave);
      return;
    }

    targetContentsPresenter.setEditingState(idToSave, TargetContentsDisplay.EditingState.SAVING);

    UpdateTransUnit updateTransUnit =
        new UpdateTransUnit(
            new TransUnitUpdateRequest(
                idToSave,
                forSaving.getTargets(),
                forSaving.getAdjustedStatus(),
                forSaving.getVerNum(),
                sourceType),
            TransUnitUpdated.UpdateType.WebEditorSave);
    Log.info("about to save translation: " + updateTransUnit);
    dispatcher.execute(
        updateTransUnit,
        new UpdateTransUnitCallback(
            forSaving, documentListPresenter.getCurrentDocument(), idToSave));
  }