コード例 #1
0
ファイル: Models.java プロジェクト: langerhans/multibit-hd
  /**
   * @param transactionSeenEvent The transaction seen event
   * @return An alert model suitable for use for displaying the information, absent if the Bitcoin
   *     URI does not contain sufficient information
   */
  public static AlertModel newPaymentReceivedAlertModel(TransactionSeenEvent transactionSeenEvent) {

    // Attempt to decode the "transaction seen" event
    String alertMessage = Formats.formatAlertMessage(transactionSeenEvent);

    return Models.newAlertModel(alertMessage, RAGStatus.GREEN);
  }
コード例 #2
0
ファイル: Models.java プロジェクト: langerhans/multibit-hd
  /**
   * @param bitcoinURI A Bitcoin URI
   * @return An alert model suitable for use for displaying the information, absent if the Bitcoin
   *     URI does not contain sufficient information
   */
  public static Optional<AlertModel> newBitcoinURIAlertModel(final BitcoinURI bitcoinURI) {

    // Action to show the "send Bitcoin" wizard
    AbstractAction action =
        new AbstractAction() {
          @Override
          public void actionPerformed(ActionEvent e) {

            ControllerEvents.fireRemoveAlertEvent();

            SendBitcoinParameter parameter = new SendBitcoinParameter(bitcoinURI, null);

            Panels.showLightBox(Wizards.newSendBitcoinWizard(parameter).getWizardScreenHolder());
          }
        };
    JButton button =
        Buttons.newAlertPanelButton(
            action, MessageKey.YES, MessageKey.YES_TOOLTIP, AwesomeIcon.CHECK);

    // Attempt to decode the Bitcoin URI
    Optional<String> alertMessage = Formats.formatAlertMessage(bitcoinURI);

    // If there is sufficient information in the Bitcoin URI display it to the user as an alert
    if (alertMessage.isPresent()) {

      return Optional.of(Models.newAlertModel(alertMessage.get(), RAGStatus.PINK, button));
    }

    return Optional.absent();
  }
コード例 #3
0
ファイル: Models.java プロジェクト: langerhans/multibit-hd
  /**
   * @param paymentSessionSummary The payment session summary providing meta data
   * @return An alert model suitable for use for displaying the payment request information, absent
   *     if the payment session summary does not contain sufficient information
   */
  public static Optional<AlertModel> newPaymentRequestAlertModel(
      final PaymentSessionSummary paymentSessionSummary) {

    // Action to show the "payment request details" wizard
    AbstractAction action =
        new AbstractAction() {
          @Override
          public void actionPerformed(ActionEvent e) {

            ControllerEvents.fireRemoveAlertEvent();

            // The user has indicated that the payment request is of interest so persist it
            Preconditions.checkState(WalletManager.INSTANCE.getCurrentWalletSummary().isPresent());
            Preconditions.checkNotNull(paymentSessionSummary);

            WalletService walletService =
                CoreServices.getOrCreateWalletService(
                    WalletManager.INSTANCE.getCurrentWalletSummary().get().getWalletId());
            if (paymentSessionSummary.hasPaymentSession()) {

              // Build a PaymentRequestData for persistence
              PaymentRequestData paymentRequestData = new PaymentRequestData(paymentSessionSummary);

              // Add the localised trust status
              paymentRequestData.setTrustStatus(paymentSessionSummary.getStatus());
              paymentRequestData.setTrustErrorMessage(
                  Languages.safeText(
                      paymentSessionSummary.getMessageKey(),
                      paymentSessionSummary.getMessageData()));

              // Store it (in memory) in the wallet service
              walletService.addPaymentRequestData(paymentRequestData);

              // The wallet has changed so UI will need updating
              ViewEvents.fireWalletDetailChangedEvent(new WalletDetail());

              // Show the wizard and provide the PaymentRequestData to the model
              Panels.showLightBox(
                  Wizards.newPaymentsWizard(paymentRequestData).getWizardScreenHolder());
            }
          }
        };
    JButton button =
        Buttons.newAlertPanelButton(
            action, MessageKey.YES, MessageKey.YES_TOOLTIP, AwesomeIcon.CHECK);

    // Attempt to decode the Bitcoin URI
    Optional<String> alertMessage = Formats.formatAlertMessage(paymentSessionSummary);

    // If there is sufficient information in the payment request display it to the user as an alert
    if (alertMessage.isPresent()) {

      return Optional.of(Models.newAlertModel(alertMessage.get(), RAGStatus.PINK, button));
    }

    return Optional.absent();
  }