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()); }
@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())); }
@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); }
/** * 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); } }
@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; }
@Override public List<String> getCachedTargets() { return cachedValue.getTargets(); }