@Override public void displayView(DisplayHint displayHint) { super.displayView(displayHint); if (DisplayHint.WALLET_TRANSACTIONS_HAVE_CHANGED == displayHint) { return; } JTextField aTextField = new JTextField(); labelTextArea.setBorder(aTextField.getBorder()); String bringToFront = controller.getModel().getUserPreference(BitcoinModel.BRING_TO_FRONT); if (Boolean.TRUE.toString().equals(bringToFront)) { controller.getModel().setUserPreference(BitcoinModel.BRING_TO_FRONT, "false"); mainFrame.bringToFront(); } // disable any new changes if another process has changed the wallet if (this.bitcoinController.getModel().getActivePerWalletModelData() != null && this.bitcoinController .getModel() .getActivePerWalletModelData() .isFilesHaveBeenChangedByAnotherProcess()) { // files have been changed by another process - disallow edits mainFrame.setUpdatesStoppedTooltip(addressTextField); addressTextField.setEditable(false); addressTextField.setEnabled(false); if (sendButton != null) { sendButton.setEnabled(false); mainFrame.setUpdatesStoppedTooltip(sendButton); } if (pasteAddressButton != null) { pasteAddressButton.setEnabled(false); mainFrame.setUpdatesStoppedTooltip(pasteAddressButton); } titleLabel.setText( controller .getLocaliser() .getString("sendBitcoinPanel.sendingAddressesTitle.mayBeOutOfDate")); mainFrame.setUpdatesStoppedTooltip(titleLabel); } else { addressTextField.setToolTipText(null); addressTextField.setEditable(true); addressTextField.setEnabled(true); if (sendButton != null) { if (SendBitcoinPanel.enableSendButton) { sendButton.setEnabled(true); sendButton.setToolTipText( HelpContentsPanel.createTooltipText( controller.getLocaliser().getString("sendBitcoinAction.tooltip"))); } else { sendButton.setEnabled(false); sendButton.setToolTipText( HelpContentsPanel.createTooltipText( controller.getLocaliser().getString("sendBitcoinAction.pleaseWait.tooltip"))); } } if (pasteAddressButton != null) { pasteAddressButton.setEnabled(true); pasteAddressButton.setToolTipText( HelpContentsPanel.createTooltipText( controller.getLocaliser().getString("pasteAddressAction.tooltip"))); } titleLabel.setText( controller.getLocaliser().getString("sendBitcoinPanel.sendingAddressesTitle")); titleLabel.setToolTipText(null); } checkDeleteSendingEnabled(); updateAmountPanel(); }
@Override public void loadForm() { // get the current address, label and amount from the model String address = this.bitcoinController.getModel().getActiveWalletPreference(BitcoinModel.SEND_ADDRESS); String label = this.bitcoinController.getModel().getActiveWalletPreference(BitcoinModel.SEND_LABEL); String amountNotLocalised = this.bitcoinController.getModel().getActiveWalletPreference(BitcoinModel.SEND_AMOUNT); if (amountBTCTextField != null) { CurrencyConverterResult converterResult = CurrencyConverter.INSTANCE.parseToBTCNotLocalised(amountNotLocalised); if (converterResult.isBtcMoneyValid()) { parsedAmountBTC = converterResult.getBtcMoney(); String amountLocalised = CurrencyConverter.INSTANCE.getBTCAsLocalisedString(converterResult.getBtcMoney()); amountBTCTextField.setText(amountLocalised); if (notificationLabel != null) { notificationLabel.setText(""); } } else { parsedAmountBTC = null; amountBTCTextField.setText(""); if (notificationLabel != null) { notificationLabel.setText(converterResult.getBtcMessage()); } } } if (address != null) { addressTextField.setText(address); } else { addressTextField.setText(""); } if (label != null) { labelTextArea.setText(label); } else { labelTextArea.setText(""); } // if there is a pending 'handleopenURI' that needs pasting into the // send form, do it String performPasteNow = this.bitcoinController .getModel() .getActiveWalletPreference(BitcoinModel.SEND_PERFORM_PASTE_NOW); if (Boolean.TRUE.toString().equalsIgnoreCase(performPasteNow)) { try { Address decodeAddress = new Address(this.bitcoinController.getModel().getNetworkParameters(), address); processDecodedString( com.google.bitcoin.uri.BitcoinURI.convertToBitcoinURI( decodeAddress, Utils.toNanoCoins(amountNotLocalised), label, null), null); this.bitcoinController .getModel() .setActiveWalletPreference(BitcoinModel.SEND_PERFORM_PASTE_NOW, "false"); sendButton.requestFocusInWindow(); mainFrame.bringToFront(); } catch (AddressFormatException e) { throw new RuntimeException(e); } } }