@Test public void shouldGetLibraryName() throws Exception { Root root = mock(Root.class); when(viewEngine.get(Model.USER_ROOT)).thenReturn(root); when(root.getType()).thenReturn(ContainerType.LOCAL); when(messages.getMessage(anyString(), anyString())).thenReturn(""); header.initialize(viewEngine); header.initialize(); header.setMessages(messages); User user = new User(); String nickName = "Alice"; user.setNickName(nickName); when(viewEngine.get(Model.CURRENT_USER)).thenReturn(user); header.onUserSessionStarted(); verify(messages).getMessage("headerPanel.mylibrary.label", nickName); User user2 = new User(); String email = "*****@*****.**"; user2.setEmail(email); when(viewEngine.get(Model.CURRENT_USER)).thenReturn(user2); header.onUserSessionStarted(); verify(messages).getMessage("headerPanel.mylibrary.label", email); }
public void deleteDownloads(final List<Download> downloads) { final DeleteDownloadsAction action = dialogFactory.showDeleteDownloadsDialog(); if (action == DeleteDownloadsAction.CANCEL) { return; } List<String> hashcodes = new ArrayList<String>(); for (Download download : downloads) { hashcodes.add(download.getDownloadId()); } viewEngine.request( Actions.Library.MODEL_FIND_TRACKS, hashcodes, new ResponseCallback<List<Track>>() { @Override public void onResponse(List<Track> tracks) { ModelCollection model = new ModelCollection(tracks); if (action == DeleteDownloadsAction.DELETE_ALL) { if (dialogFactory.showConfirmationDeleteDialog(model)) { viewEngine.send(Actions.Library.DELETE_FILES, new ValueAction<List<Track>>(tracks)); } else { return; // user canceled operation } } viewEngine.sendValueAction(Actions.Downloads.DELETE_DOWNLOAD_COLLECTION, downloads); } }); }
public void deleteSelected() { List<?> list = viewEngine.get(Model.CLIPBOARD_SELECTION); ModelCollection model = new ModelCollection(); List<Download> downloads = new ArrayList<Download>(); for (Object object : list) { if (object instanceof Download) { downloads.add((Download) object); } else { model.add(object); } } if (!downloads.isEmpty()) { deleteDownloads(downloads); } else { TrackContainer trackContainer = viewEngine.get(Model.SELECTED_CONTAINER); delete(trackContainer, model); } }
private void doDelete(TrackContainer container, ModelCollection model, DeleteMode mode) { ModelDeleteAction action = new ModelDeleteAction(container, model, mode); viewEngine.send(Actions.Library.MODEL_DELETE, action); }
public void delete(ModelCollection model) { delete(viewEngine.get(Model.SELECTED_CONTAINER), model); }