Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
rhbz953734 - refactor to move TransUnitSaveService out of TransUnitsT…
Browse files Browse the repository at this point in the history
…ablePresenter
  • Loading branch information
Patrick Huang committed May 17, 2013
1 parent e1aeeb8 commit 5ae7f3f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
Expand Up @@ -200,6 +200,7 @@ public void onSuccess(GetDocumentListResult result)

documentListPresenter.queryStats();
documentListPresenter.showLoading(false);
injector.getTransUnitSaveService().init();

stopwatch.stop();
}
Expand Down
Expand Up @@ -11,6 +11,7 @@
import org.zanata.webtrans.client.presenter.UserConfigHolder;
import org.zanata.webtrans.client.rpc.CachingDispatchAsync;
import org.zanata.webtrans.client.service.HistoryEventHandlerService;
import org.zanata.webtrans.client.service.TransUnitSaveService;
import org.zanata.webtrans.client.service.ValidationService;
import org.zanata.webtrans.shared.model.UserWorkspaceContext;

Expand Down Expand Up @@ -45,4 +46,6 @@ public interface WebTransGinjector extends Ginjector
TargetContentsPresenter getTargetContentsPresenter();

ValidationService getValidationService();

TransUnitSaveService getTransUnitSaveService();
}
Expand Up @@ -123,10 +123,9 @@ public TransUnitsTablePresenter(TransUnitsTableDisplay display, EventBus eventBu
SourceContentsPresenter sourceContentsPresenter,
TargetContentsPresenter targetContentsPresenter,
TranslatorInteractionService translatorService,
TransUnitSaveService transUnitSaveService,
TranslationHistoryPresenter translationHistoryPresenter,
Provider<GoToRowLink> goToRowLinkProvider,
WebTransMessages messages,UserOptionsService userOptionsService)
WebTransMessages messages, UserOptionsService userOptionsService)
// @formatter:on
{
super(display, eventBus);
Expand All @@ -144,12 +143,6 @@ public TransUnitsTablePresenter(TransUnitsTableDisplay display, EventBus eventBu
this.targetContentsPresenter = targetContentsPresenter;
this.translatorService = translatorService;
this.userOptionsService = userOptionsService;

// we register it here because we can't use eager singleton on it (it
// references TargetContentsPresenter). And if it's not eagerly created,
// it won't get created at all!!
eventBus.addHandler(TransUnitSaveEvent.TYPE, transUnitSaveService);
eventBus.addHandler(CheckStateHasChangedEvent.TYPE, transUnitSaveService);
}

@Override
Expand Down
Expand Up @@ -82,6 +82,12 @@ public TransUnitSaveService(EventBus eventBus, CachingDispatchAsync dispatcher,
this.queue = queue;
}

public void init()
{
eventBus.addHandler(TransUnitSaveEvent.TYPE, this);
eventBus.addHandler(CheckStateHasChangedEvent.TYPE, this);
}

@Override
public void onTransUnitSave(TransUnitSaveEvent event)
{
Expand Down
Expand Up @@ -74,8 +74,6 @@ public class TransUnitsTablePresenterTest
@Mock
private TranslatorInteractionService translatorService;
@Mock
private TransUnitSaveService saveService;
@Mock
private WebTransMessages messages;
@Mock
private TranslationHistoryPresenter translationHistoryPresenter;
Expand All @@ -91,13 +89,11 @@ public class TransUnitsTablePresenterTest
public void setUp() throws Exception
{
MockitoAnnotations.initMocks(this);
presenter = new TransUnitsTablePresenter(display, eventBus, navigationService, sourceContentsPresenter, targetContentsPresenter, translatorService, saveService, translationHistoryPresenter, goToRowProvider, messages, userOptionsService);
presenter = new TransUnitsTablePresenter(display, eventBus, navigationService, sourceContentsPresenter, targetContentsPresenter, translatorService, translationHistoryPresenter, goToRowProvider, messages, userOptionsService);

verify(display).setRowSelectionListener(presenter);
verify(display).addFilterConfirmationHandler(presenter);
verify(navigationService).addPageDataChangeListener(presenter);
verify(eventBus).addHandler(TransUnitSaveEvent.TYPE, saveService);
verify(eventBus).addHandler(CheckStateHasChangedEvent.TYPE, saveService);
}

@Test
Expand Down

0 comments on commit 5ae7f3f

Please sign in to comment.