Search in sources :

Example 1 with CashPurseAccount

use of com.moneychanger.core.CashPurseAccount in project otapij by FellowTraveler.

the class CashPurseDepositDialog method jButton1ActionPerformed.

//GEN-LAST:event_jComboBox1ActionPerformed
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    //GEN-FIRST:event_jButton1ActionPerformed
    try {
        CashPurseAccount cashPurseAccount = new CashPurseAccount();
        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        boolean isSuccess = cashPurseAccount.depositCashPurse(details.getServerID(), details.getAssetID(), details.getNymID(), details.getPurse(), selectedIndices, jTextField1.getText());
        if (isSuccess) {
            JOptionPane.showMessageDialog(this, "Cash Purse deposited successfully", "Cash Purse Deposit Success", JOptionPane.INFORMATION_MESSAGE);
            CashPurseDetails cashDetails = new CashPurseAccount().getCashPurseDetails(details.getServerID() + ":" + details.getAssetID() + ":" + details.getNymID());
            CashPurseAccountBottomPanel.populateCashPurseDetails(cashDetails);
            CashPurseAccountTopPanel.populateCashPurseDetails(cashDetails, cashDetails.getBalance());
            MainPage.reLoadAccount();
        //CashPurseAccountBottomPanel.refreshGrid(cashPurseAccount.refreshGridData(details.getServerID(), details.getAssetID(), details.getNymID()));
        } else {
            if (Helpers.getObj() != null) {
                new CashPurseExportDetails(null, true, (String) Helpers.getObj(), false).setVisible(true);
            } else
                JOptionPane.showMessageDialog(this, "Error in cash purse deposit", "Server Error", JOptionPane.ERROR_MESSAGE);
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        setCursor(Cursor.getDefaultCursor());
    }
    this.dispose();
}
Also used : CashPurseDetails(com.moneychanger.core.dataobjects.CashPurseDetails) CashPurseAccount(com.moneychanger.core.CashPurseAccount)

Example 2 with CashPurseAccount

use of com.moneychanger.core.CashPurseAccount in project otapij by FellowTraveler.

the class ExportCashToDialog method jButton1ActionPerformed.

//GEN-LAST:event_jComboBox2ActionPerformed
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    //GEN-FIRST:event_jButton1ActionPerformed
    CashPurseAccount cashPurseAccount = new CashPurseAccount();
    boolean isPasted = true;
    if (jComboBox2.getSelectedIndex() > 0)
        isPasted = false;
    try {
        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        String purse = cashPurseAccount.exportCashPurse(details.getServerID(), details.getAssetID(), details.getNymID(), details.getPurse(), selectedIndices, jTextField1.getText(), isPasted);
        if (purse != null) {
            CashPurseDetails cashDetails = new CashPurseAccount().getCashPurseDetails(details.getServerID() + ":" + details.getAssetID() + ":" + details.getNymID());
            CashPurseAccountBottomPanel.populateCashPurseDetails(cashDetails);
            CashPurseAccountTopPanel.populateCashPurseDetails(cashDetails, cashDetails.getBalance());
            MainPage.reLoadAccount();
        //((CashPurseTableModel) jTable5.getModel()).setValue(cashPurseAccount.refreshGridData(details.getServerID(), details.getAssetID(), details.getNymID()), jTable5);
        }
        if (Helpers.getObj() != null) {
            new CashPurseExportDetails(null, true, purse, false).setVisible(true);
            dispose();
        } else {
            new CashPurseExportDetails(null, true, purse, true).setVisible(true);
            dispose();
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        setCursor(Cursor.getDefaultCursor());
    }
    dispose();
}
Also used : CashPurseDetails(com.moneychanger.core.dataobjects.CashPurseDetails) CashPurseAccount(com.moneychanger.core.CashPurseAccount)

Example 3 with CashPurseAccount

use of com.moneychanger.core.CashPurseAccount in project otapij by FellowTraveler.

the class ImportCashPurse method jButton1ActionPerformed.

// </editor-fold>//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    //GEN-FIRST:event_jButton1ActionPerformed
    try {
        boolean isPurse = true;
        if (jTextArea1.getText().length() < 1) {
            JOptionPane.showMessageDialog(this, "Error in cash purse import. Empty purse", "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
        if (!jTextArea1.getText().trim().startsWith("-----BEGIN SIGNED CASH-----") && !jTextArea1.getText().trim().startsWith("-----BEGIN SIGNED PURSE-----")) {
            JOptionPane.showMessageDialog(this, "Please enter valid purse/token", "Purse Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
        if (jTextArea1.getText().trim().startsWith("-----BEGIN SIGNED CASH-----")) {
            isPurse = false;
        }
        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        boolean success = new CashPurseAccount().importCashPurse(serverID, nymID, assetID, jTextArea1.getText(), isPurse);
        if (success) {
            JOptionPane.showMessageDialog(this, "Cash imported successfully", "Success", JOptionPane.INFORMATION_MESSAGE);
            CashPurseDetails details = new CashPurseAccount().getCashPurseDetails(serverID + ":" + assetID + ":" + nymID);
            CashPurseAccountBottomPanel.populateCashPurseDetails(details);
            CashPurseAccountTopPanel.populateCashPurseDetails(details, details.getBalance());
            MainPage.reLoadAccount();
        } else
            JOptionPane.showMessageDialog(this, "Error in cash purse import", "Server Error", JOptionPane.ERROR_MESSAGE);
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        setCursor(Cursor.getDefaultCursor());
        this.dispose();
    }
}
Also used : CashPurseDetails(com.moneychanger.core.dataobjects.CashPurseDetails) CashPurseAccount(com.moneychanger.core.CashPurseAccount)

Example 4 with CashPurseAccount

use of com.moneychanger.core.CashPurseAccount in project otapij by FellowTraveler.

the class CashPurseAccountBottomPanel method jButton_ExchangeActionPerformed1.

//GEN-LAST:event_jButton_ExportActionPerformed
private void jButton_ExchangeActionPerformed1(java.awt.event.ActionEvent evt) {
    try {
        if (true) {
            JOptionPane.showMessageDialog(null, "Exchange is currently not supported", "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
        CashPurseAccount cashPurseAccount = new CashPurseAccount();
        ArrayList selectedIndices = new ArrayList();
        for (int i = 0; i < jTable5.getRowCount(); i++) {
            String id = (String) jTable5.getModel().getValueAt(i, 3);
            if ((Boolean) jTable5.getModel().getValueAt(i, 5)) {
                selectedIndices.add(id);
            }
        }
        System.out.println("selectedIndices:" + selectedIndices);
        if (selectedIndices.isEmpty()) {
            int selected = JOptionPane.showConfirmDialog(this, "This will exchange all of the tokens in the purse", "Warning", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
            if (selected == 2)
                return;
        }
        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        boolean isSuccess = cashPurseAccount.exchangeCashPurse(details.getServerID(), details.getAssetID(), details.getNymID(), details.getPurse(), selectedIndices);
        if (isSuccess) {
            JOptionPane.showMessageDialog(this, "Cash exchanged successfully", "Exchange Success", JOptionPane.INFORMATION_MESSAGE);
            CashPurseDetails cashDetails = new CashPurseAccount().getCashPurseDetails(details.getServerID() + ":" + details.getAssetID() + ":" + details.getNymID());
            CashPurseAccountBottomPanel.populateCashPurseDetails(cashDetails);
            CashPurseAccountTopPanel.populateCashPurseDetails(cashDetails, cashDetails.getBalance());
            MainPage.reLoadAccount();
        //((CashPurseTableModel) jTable5.getModel()).setValue(cashPurseAccount.refreshGridData(details.getServerID(), details.getAssetID(), details.getNymID()), jTable5);
        } else {
            if (Helpers.getObj() != null) {
                new CashPurseExportDetails(null, true, (String) Helpers.getObj(), false).setVisible(true);
            } else
                JOptionPane.showMessageDialog(this, "Error in cash purse exchange", "Server Error", JOptionPane.ERROR_MESSAGE);
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        setCursor(Cursor.getDefaultCursor());
    }
}
Also used : CashPurseDetails(com.moneychanger.core.dataobjects.CashPurseDetails) ArrayList(java.util.ArrayList) CashPurseAccount(com.moneychanger.core.CashPurseAccount) CashPurseExportDetails(com.moneychanger.ui.dialogs.CashPurseExportDetails)

Aggregations

CashPurseAccount (com.moneychanger.core.CashPurseAccount)4 CashPurseDetails (com.moneychanger.core.dataobjects.CashPurseDetails)4 CashPurseExportDetails (com.moneychanger.ui.dialogs.CashPurseExportDetails)1 ArrayList (java.util.ArrayList)1