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());
 }
Esempio n. 2
0
 @Override
 public void revertEditorContents() {
   List<String> cachedTargets = cachedValue.getTargets();
   for (int i = 0; i < cachedTargets.size(); i++) {
     String target = cachedTargets.get(i);
     editors.get(i).setTextAndValidate(target);
   }
   editorGrid.setStyleName(resolveStyleName(cachedValue.getStatus()));
 }
Esempio n. 3
0
 @Override
 public void updateCachedTargetsAndVersion(
     List<String> targets, Integer verNum, ContentState status) {
   cachedValue =
       TransUnit.Builder.from(cachedValue)
           .setTargets(targets)
           .setVerNum(verNum)
           .setStatus(status)
           .build();
   editorGrid.setStyleName(resolveStyleName(cachedValue.getStatus()));
 }
  @Test
  public void canConfirmSavedOnSavingState() {
    selectedTU = currentPageRows.get(1);
    when(display.getId()).thenReturn(selectedTU.getId());
    when(display.getEditingState()).thenReturn(TargetContentsDisplay.EditingState.SAVING);
    presenter.setStatesForTesting(selectedTU.getId(), 0, display);

    presenter.confirmSaved(selectedTU);

    verify(display)
        .updateCachedTargetsAndVersion(
            selectedTU.getTargets(), selectedTU.getVerNum(), selectedTU.getStatus());
    verify(display).setState(TargetContentsDisplay.EditingState.SAVED);
  }
Esempio n. 5
0
  @Override
  public void setState(EditingState editingState) {
    if (this.editingState == editingState) {
      return;
    }
    this.editingState = editingState;
    if (editingState == EditingState.UNSAVED) {
      editorGrid.setStyleName(style.unsaved());
      savingIndicator.setVisible(false);

    } else if (editingState == EditingState.SAVING) {
      savingIndicator.setVisible(true);
    } else {
      editorGrid.setStyleName(resolveStyleName(cachedValue.getStatus()));
      savingIndicator.setVisible(false);
    }
  }
 private void initData() {
   // @formatter:off
   data =
       Lists.newArrayList(
           TestFixture.makeTransUnit(1, ContentState.Approved),
           TestFixture.makeTransUnit(2, ContentState.Approved),
           TestFixture.makeTransUnit(3, ContentState.NeedReview),
           TestFixture.makeTransUnit(4, ContentState.New),
           TestFixture.makeTransUnit(5, ContentState.Approved));
   // @formatter:on
   idStateMap = Maps.newHashMap();
   idIndexList = Lists.newArrayList();
   for (TransUnit transUnit : data) {
     idStateMap.put(transUnit.getId(), transUnit.getStatus());
     idIndexList.add(transUnit.getId());
   }
 }
  /**
   * 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());
    } else if (targetUnchangedButCanSaveAsApproved) {
      targetContentsPresenter.showSaveAsApprovedConfirmation(event.getTransUnitId());
    } else {
      eventBus.fireEvent(NavTransUnitEvent.NEXT_ENTRY_EVENT);
    }
  }
Esempio n. 8
0
  @Override
  public void setValueAndCreateNewEditors(TransUnit transUnit) {
    cachedValue = transUnit;

    editors.clear();
    List<String> cachedTargets = cachedValue.getTargets();
    if (cachedTargets == null) {
      cachedTargets = Lists.newArrayList("");
    }
    editorGrid.resize(cachedTargets.size(), COLUMNS);
    int rowIndex = 0;
    for (String target : cachedTargets) {
      Editor editor = new Editor(target, rowIndex, listener, transUnit.getId());
      editor.setEnableSpellCheck(listener.getConfigState().isSpellCheckEnabled());
      editorGrid.setWidget(rowIndex, 0, editor);
      editors.add(editor);
      rowIndex++;
    }
    editorGrid.setStyleName(resolveStyleName(cachedValue.getStatus()));
    editingState = EditingState.SAVED;
  }