CreateNewSendingAddressAction extends MultiBitSubmitAction { @Override public void actionPerformed(ActionEvent e) { if (abort()) { return; } WalletData perWalletModelData = super.bitcoinController.getModel().getActivePerWalletModelData(); WalletInfoData walletInfo = perWalletModelData.getWalletInfo(); if (walletInfo == null) { walletInfo = new WalletInfoData(perWalletModelData.getWalletFilename(), perWalletModelData.getWallet(), MultiBitWalletVersion.PROTOBUF_ENCRYPTED); perWalletModelData.setWalletInfo(walletInfo); } if (walletInfo.getSendingAddresses().isEmpty()) { String address = super.bitcoinController.getModel().getActiveWalletPreference(BitcoinModel.SEND_ADDRESS); String label = super.bitcoinController.getModel().getActiveWalletPreference(BitcoinModel.SEND_LABEL); perWalletModelData.getWalletInfo().addSendingAddress(new WalletAddressBookData(label, address)); sendBitcoinPanel.getAddressesTableModel().fireTableDataChanged(); super.bitcoinController.getModel().getActivePerWalletModelData().setDirty(true); } else { perWalletModelData.getWalletInfo().addSendingAddress(new WalletAddressBookData("", "")); sendBitcoinPanel.getAddressesTableModel().fireTableDataChanged(); sendBitcoinPanel.selectRows(); super.bitcoinController.getModel().setActiveWalletPreference(BitcoinModel.SEND_ADDRESS, ""); super.bitcoinController.getModel().setActiveWalletPreference(BitcoinModel.SEND_LABEL, ""); } sendBitcoinPanel.checkDeleteSendingEnabled(); controller.displayView(controller.getCurrentView()); if (sendBitcoinPanel.getLabelTextArea() != null) { sendBitcoinPanel.getLabelTextArea().requestFocusInWindow(); } } CreateNewSendingAddressAction(BitcoinController bitcoinController, SendBitcoinPanel sendBitcoinPanel); @Override void actionPerformed(ActionEvent e);  }
@Test public void testNoWalletSelected() throws Exception { final CreateControllers.Controllers controllers = CreateControllers.createControllers(); BitcoinController controller = controllers.bitcoinController; assertTrue("There was an active wallet when there should not be", controller.getModel().thereIsNoActiveWallet()); ColorAndFontConstants.init(); FontSizer.INSTANCE.initialise(controller); SendBitcoinPanel sendBitcoinPanel = new SendBitcoinPanel(controller, null); CreateNewSendingAddressAction createNewSendingAddressAction = (CreateNewSendingAddressAction)sendBitcoinPanel.getCreateNewAddressAction(); assertNotNull("createNewSendingAddressAction was not created successfully", createNewSendingAddressAction); createNewSendingAddressAction.actionPerformed(null); Object[] messages = MessageManager.INSTANCE.getMessages().toArray(); assertTrue("There were no messages but there should have been", messages != null && messages.length > 0); assertEquals("Wrong message after send bitcoin confirm with no active wallet", ResetTransactionsSubmitActionTest.EXPECTED_NO_WALLET_IS_SELECTED, ((Message)messages[messages.length - 1]).getText()); }