public void onUpdatedLockStatusEvent(final @Observes UpdatedLockStatusEvent event) { if (!hasActiveDecisionTable()) { return; } getActiveDecisionTable().ifPresent(dt -> { final ObservablePath currentPath = dt.getCurrentPath(); if (currentPath.equals(event.getFile())) { refresh(); } }); }
public void onUpdatedLockStatusEvent(final @Observes UpdatedLockStatusEvent event) { if (!hasActiveDecisionTable()) { return; } getActiveDecisionTable().ifPresent(dt -> { final ObservablePath currentPath = dt.getCurrentPath(); if (currentPath.equals(event.getFile())) { refresh(); } }); }
void onUpdatedLockStatusEvent(final @Observes UpdatedLockStatusEvent event) { super.onUpdatedLockStatusEvent(event); if (editorPath == null) { return; } if (editorPath.equals(event.getFile())) { if (event.isLocked()) { access.setLock(event.isLockedByCurrentUser() ? CURRENT_USER : OTHER_USER); } else { access.setLock(NOBODY); } } }
void onUpdatedLockStatusEvent(final @Observes UpdatedLockStatusEvent event) { super.onUpdatedLockStatusEvent(event); if (editorPath == null) { return; } if (editorPath.equals(event.getFile())) { if (event.isLocked()) { access.setLock(event.isLockedByCurrentUser() ? CURRENT_USER : OTHER_USER); } else { access.setLock(NOBODY); } } }
void onEditorLockInfo(@Observes UpdatedLockStatusEvent lockInfo) { final Operation op = lockSyncMenuStateHelper.enable(lockInfo.getFile(), lockInfo.isLocked(), lockInfo.isLockedByCurrentUser()); switch (op) { case ENABLE: case DISABLE: for (MenuItem menuItem : menuItemsSyncedWithLockState) { menuItem.setEnabled(op == Operation.ENABLE); } break; case VETO: //Do nothing } } }
void onEditorLockInfo(@Observes UpdatedLockStatusEvent lockInfo) { final Operation op = lockSyncMenuStateHelper.enable(lockInfo.getFile(), lockInfo.isLocked(), lockInfo.isLockedByCurrentUser()); switch (op) { case ENABLE: case DISABLE: for (MenuItem menuItem : menuItemsSyncedWithLockState) { menuItem.setEnabled(op == Operation.ENABLE); } break; case VETO: //Do nothing } } }
void onUpdatedLockStatusEvent(final @Observes UpdatedLockStatusEvent event) { if (currentPath == null) { return; } if (currentPath.equals(event.getFile())) { if (event.isLocked()) { access.setLock(event.isLockedByCurrentUser() ? CURRENT_USER : OTHER_USER); } else { access.setLock(NOBODY); } refreshColumnsPage(); refreshMenus(); } }
void onUpdatedLockStatusEvent(final @Observes UpdatedLockStatusEvent event) { if (currentPath == null) { return; } if (currentPath.equals(event.getFile())) { if (event.isLocked()) { access.setLock(event.isLockedByCurrentUser() ? CURRENT_USER : OTHER_USER); } else { access.setLock(NOBODY); } refreshColumnsPage(); refreshMenus(); } }
@Test public void testOnUpdatedLockStatusEventWhenActiveDecisionTableHasAnInvalidPath() { final UpdatedLockStatusEvent event = mock(UpdatedLockStatusEvent.class); final GuidedDecisionTableView.Presenter activeDecisionTable = mock(GuidedDecisionTableView.Presenter.class); final ObservablePath path = mock(ObservablePath.class); doReturn(true).when(presenter).hasActiveDecisionTable(); doReturn(Optional.of(activeDecisionTable)).when(modeller).getActiveDecisionTable(); doReturn(path).when(activeDecisionTable).getCurrentPath(); doReturn(null).when(event).getFile(); presenter.onUpdatedLockStatusEvent(event); verify(presenter, never()).refresh(); }
@Test public void testOnUpdatedLockStatusEventWhenActiveDecisionTableHasAValidPath() { final UpdatedLockStatusEvent event = mock(UpdatedLockStatusEvent.class); final GuidedDecisionTableView.Presenter activeDecisionTable = mock(GuidedDecisionTableView.Presenter.class); final ObservablePath path = mock(ObservablePath.class); doReturn(true).when(presenter).hasActiveDecisionTable(); doReturn(Optional.of(activeDecisionTable)).when(modeller).getActiveDecisionTable(); doReturn(path).when(activeDecisionTable).getCurrentPath(); doReturn(path).when(event).getFile(); doNothing().when(presenter).refresh(); presenter.onUpdatedLockStatusEvent(event); verify(presenter).refresh(); }
@Test public void testOnUpdatedLockStatusEvent_NotLocked() { final UpdatedLockStatusEvent event = mock(UpdatedLockStatusEvent.class); when(event.getFile()).thenReturn(dtPath); dtPresenter.onUpdatedLockStatusEvent(event); verify(dtPresenter).refreshColumnsPage(); verify(dtPresenter).refreshMenus(); assertEquals(NOBODY, dtPresenter.getAccess().getLock()); }
@Test public void testOnUpdatedLockStatusEvent_LockedByCurrentUser() { final UpdatedLockStatusEvent event = mock(UpdatedLockStatusEvent.class); when(event.getFile()).thenReturn(dtPath); when(event.isLockedByCurrentUser()).thenReturn(true); when(event.isLocked()).thenReturn(true); dtPresenter.onUpdatedLockStatusEvent(event); verify(dtPresenter).refreshColumnsPage(); verify(dtPresenter).refreshMenus(); assertEquals(CURRENT_USER, dtPresenter.getAccess().getLock()); }
@Test public void testOnUpdatedLockStatusEvent_LockedByOtherUser() { final UpdatedLockStatusEvent event = mock(UpdatedLockStatusEvent.class); when(event.getFile()).thenReturn(dtPath); when(event.isLockedByCurrentUser()).thenReturn(false); when(event.isLocked()).thenReturn(true); dtPresenter.onUpdatedLockStatusEvent(event); verify(dtPresenter).refreshColumnsPage(); verify(dtPresenter).refreshMenus(); assertEquals(OTHER_USER, dtPresenter.getAccess().getLock()); }