Search in sources :

Example 1 with NYM

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

the class MainPage method jButton_RemoveAccount1ActionPerformed.

//GEN-LAST:event_jButton_EditAccount1ActionPerformed
private void jButton_RemoveAccount1ActionPerformed(java.awt.event.ActionEvent evt) {
    //GEN-FIRST:event_jButton_RemoveAccount1ActionPerformed
    if (jTable_NymsList.getSelectedRow() < 0) {
        JOptionPane.showMessageDialog(this, "Please select NYM to delete", "Error", JOptionPane.ERROR_MESSAGE);
        return;
    }
    String nymID = (String) jTable_NymsList.getModel().getValueAt(jTable_NymsList.getSelectedRow(), 1);
    int userSelection = JOptionPane.showConfirmDialog(this, "Are you sure you want to delete NYM", "NYM Deletion", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
    System.out.println("userSelection:" + userSelection);
    NYM nym = new NYM();
    if (userSelection == 0) {
        try {
            setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            Map registeredServers = new NYM().registeredServers(nymID);
            if (registeredServers == null || registeredServers.size() < 1) {
                boolean status = new NYM().deleteWalletNym(nymID);
                if (status) {
                    JOptionPane.showMessageDialog(this, "Nym deleted sucessfully from the wallet", "NYM deletion success", JOptionPane.INFORMATION_MESSAGE);
                    refreshNYMSList();
                    return;
                } else {
                    JOptionPane.showMessageDialog(this, "Cannot delete nym from the wallet", "Error", JOptionPane.ERROR_MESSAGE);
                    return;
                }
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        } finally {
            setCursor(Cursor.getDefaultCursor());
            dispose();
        }
        new DeleteNYMDialog(this, true, nymID).setVisible(true);
    }
}
Also used : NYM(com.moneychanger.core.NYM) Map(java.util.Map) Point(java.awt.Point) AWTException(java.awt.AWTException) DeleteNYMDialog(com.moneychanger.ui.dialogs.DeleteNYMDialog)

Example 2 with NYM

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

the class MainPage method initNYMSTab.

private void initNYMSTab() {
    jTable_NymsList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting()) {
                return;
            }
            System.out.println("selectedRow:" + jTable_NymsList.getSelectedRow());
            if (jTable_NymsList.getSelectedRow() >= 0) {
                String nymID = (String) jTable_NymsList.getModel().getValueAt(jTable_NymsList.getSelectedRow(), 1);
                System.out.println("selected nymID:" + nymID);
                NYM nym = new NYM();
                nymBox = nym.loadNymBox(nymID);
                nymOutBox = nym.loadNymOutBox(nymID);
                System.out.println("loadNymBox loadNymOutBox data loaded");
                populateNYMDetails(nymID, nym.getRawFileData(nymID), nymBox, nymOutBox);
            }
        }
    });
    ((NYMTableModel) jTable_NymsList.getModel()).setValue(new NYM().loadNYM(), jTable_NymsList);
}
Also used : NYM(com.moneychanger.core.NYM) NYMTableModel(com.moneychanger.ui.model.NYMTableModel) ListSelectionEvent(javax.swing.event.ListSelectionEvent) ListSelectionListener(javax.swing.event.ListSelectionListener)

Example 3 with NYM

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

the class MainPage method jComboBox5ActionPerformed.

//GEN-LAST:event_jComboBox4ActionPerformed
private void jComboBox5ActionPerformed(java.awt.event.ActionEvent evt) {
    //GEN-FIRST:event_jComboBox5ActionPerformed
    // Load the markets for this server
    String serverID = "ALL";
    String nymID = "ALL";
    if (serverMap != null && serverMap.size() > 0 && jComboBox5.getSelectedIndex() > -1) {
        serverID = ((String[]) serverMap.get((Integer) jComboBox5.getSelectedIndex()))[1];
    }
    System.out.println("Mrkets tab - nym selected index - " + jComboBox6.getSelectedIndex());
    nymRegisteredMap = new NYM().loadRegisteredNYM(serverID);
    Helpers.populateComboWithoutAll(nymRegisteredMap, jComboBox6);
    if (nymRegisteredMap != null && nymRegisteredMap.size() > 0 && jComboBox6.getSelectedIndex() > -1) {
        nymID = ((String[]) nymRegisteredMap.get((Integer) jComboBox6.getSelectedIndex()))[1];
    }
    System.out.println("Mrkets tab, serverID:" + serverID + " nymID:" + nymID);
    if (jComboBox6.getSelectedIndex() > -1 && jComboBox5.getSelectedIndex() > -1) {
        Map marketList = null;
        try {
            marketList = Market.loadMarketList(serverID, nymID);
        } catch (InterruptedException ex) {
            Logger.getLogger(MainPage.class.getName()).log(Level.SEVERE, null, ex);
        }
        if (marketList != null) {
            ((MarketTableModel) jTable13.getModel()).setValue(marketList, jTable13);
        }
        if (marketList != null && marketList.size() > 0) {
            String marketID = (String) jTable13.getModel().getValueAt(jTable13.getSelectedRow(), 1);
            System.out.println("-----marketID----:" + marketID);
            boolean marketExists = false;
            for (int i = 0; i < jTable13.getRowCount(); i++) {
                if (marketID != null && jTable13.getModel().getValueAt(jTable13.getSelectedRow(), 1) != null && marketID.equals(jTable13.getModel().getValueAt(jTable13.getSelectedRow(), 1))) {
                    jTable13.setRowSelectionInterval(i, i);
                    marketListClick();
                    marketExists = true;
                    break;
                }
            }
            if (jTable13.getRowCount() > 0 && !marketExists) {
                jTable13.setRowSelectionInterval(0, 0);
                marketListClick();
            }
        }
    }
}
Also used : MarketTableModel(com.moneychanger.ui.model.MarketTableModel) NYM(com.moneychanger.core.NYM) Map(java.util.Map) Point(java.awt.Point)

Example 4 with NYM

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

the class MainPage method initMarketsTab.

private void initMarketsTab() {
    jLabel25.setText("");
    jLabel46.setText("");
    jLabel30.setText("");
    jLabel27.setText("");
    jLabel39.setText("");
    jLabel32.setText("");
    jLabel40.setText("");
    jLabel41.setText("");
    jLabel59.setText("");
    jLabel60.setText("");
    jLabel61.setText("");
    MarketTableModel.removeCols(jTable13);
    MarketOffersTableModel.removeCols(jTable14);
    Helpers.populateComboWithoutAll(serverMap, jComboBox5);
    String serverID = "ALL";
    String nymID = "ALL";
    if (serverMap != null && serverMap.size() > 0 && jComboBox5.getSelectedIndex() > -1) {
        serverID = ((String[]) serverMap.get((Integer) jComboBox5.getSelectedIndex()))[1];
    }
    nymRegisteredMap = new NYM().loadRegisteredNYM(serverID);
    Helpers.populateComboWithoutAll(nymRegisteredMap, jComboBox6);
    jTable14.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting()) {
                return;
            }
            System.out.println("valueChanged Market List Action Listener :" + jTable14.getSelectedRow() + "e:" + e.getSource());
            // Get nym offer details
            nymOfferClick();
        }
    });
    jTable13.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting()) {
                return;
            }
            System.out.println("jTable13 valueChanged Market List Action Listener :" + jTable13.getSelectedRow() + "e:" + e.getSource());
            // Get market details
            marketListClick();
        }
    });
    if (nymRegisteredMap != null && nymRegisteredMap.size() > 0 && jComboBox6.getSelectedIndex() > -1) {
        nymID = ((String[]) nymRegisteredMap.get((Integer) jComboBox6.getSelectedIndex()))[1];
    }
    if (!"ALL".equalsIgnoreCase(nymID)) {
        Map nymTrades = Market.getNymTrades(serverID, nymID);
        if (nymTrades != null) {
            ((MarketTradesTableModel) jTable16.getModel()).setValue(nymTrades, jTable16);
        }
    }
}
Also used : NYM(com.moneychanger.core.NYM) ListSelectionEvent(javax.swing.event.ListSelectionEvent) MarketTradesTableModel(com.moneychanger.ui.model.MarketTradesTableModel) Map(java.util.Map) ListSelectionListener(javax.swing.event.ListSelectionListener)

Example 5 with NYM

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

the class MainPage method jButton_DeleteActionPerformed.

//GEN-LAST:event_jButton_DownloadMailActionPerformed
private void jButton_DeleteActionPerformed(java.awt.event.ActionEvent evt) {
    //GEN-FIRST:event_jButton_DeleteActionPerformed
    if (jTable8.getSelectedRow() < 0 && jTable10.getSelectedRow() < 0) {
        JOptionPane.showMessageDialog(this, "Please select mail to delete", "Error", JOptionPane.ERROR_MESSAGE);
        return;
    }
    try {
        NYM nym = new NYM();
        if (jTabbedPane_Nymbox.getSelectedIndex() == 0) {
            boolean success = nym.deleteMail(jTextField_NymID.getText(), Integer.parseInt((String) jTable8.getModel().getValueAt(jTable8.getSelectedRow(), 3)));
            int previousSelection = jTable8.getSelectedRow();
            if (success) {
                //JOptionPane.showMessageDialog(this, "Mail deleted successfully", "Mail Deletion Success", JOptionPane.INFORMATION_MESSAGE);
                ((NYMBoxTableModel) jTable8.getModel()).setValue(nym.loadNymBox(jTextField_NymID.getText()), jTable8);
                int newCount = jTable8.getModel().getRowCount();
                if (newCount > 0) {
                    if (newCount > previousSelection) {
                        jTable8.setRowSelectionInterval(previousSelection, previousSelection);
                    } else {
                        jTable8.setRowSelectionInterval(previousSelection - 1, previousSelection - 1);
                    }
                }
            } else {
                JOptionPane.showMessageDialog(this, "Mail deletion failed", "Error", JOptionPane.ERROR_MESSAGE);
            }
        } else {
            boolean success = nym.deleteOutboxMail(jTextField_NymID.getText(), Integer.parseInt((String) jTable10.getModel().getValueAt(jTable10.getSelectedRow(), 3)));
            int previousSelection = jTable10.getSelectedRow();
            if (success) {
                //JOptionPane.showMessageDialog(this, "Mail deleted successfully", "Mail Deletion Success", JOptionPane.INFORMATION_MESSAGE);
                ((NYMOutboxTableModel) jTable10.getModel()).setValue(nym.loadNymOutBox(jTextField_NymID.getText()), jTable10);
                int newCount = jTable10.getModel().getRowCount();
                if (newCount > 0) {
                    if (newCount > previousSelection) {
                        jTable10.setRowSelectionInterval(previousSelection, previousSelection);
                    } else {
                        jTable10.setRowSelectionInterval(previousSelection - 1, previousSelection - 1);
                    }
                }
            } else {
                JOptionPane.showMessageDialog(this, "Mail deletion failed", "Error", JOptionPane.ERROR_MESSAGE);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : NYM(com.moneychanger.core.NYM) NYMBoxTableModel(com.moneychanger.ui.model.NYMBoxTableModel) NYMOutboxTableModel(com.moneychanger.ui.model.NYMOutboxTableModel) Point(java.awt.Point) AWTException(java.awt.AWTException)

Aggregations

NYM (com.moneychanger.core.NYM)19 Point (java.awt.Point)5 Map (java.util.Map)4 ListSelectionEvent (javax.swing.event.ListSelectionEvent)4 ListSelectionListener (javax.swing.event.ListSelectionListener)4 Contract (com.moneychanger.core.Contract)3 AWTException (java.awt.AWTException)3 NYMBoxTableModel (com.moneychanger.ui.model.NYMBoxTableModel)2 NYMOutboxTableModel (com.moneychanger.ui.model.NYMOutboxTableModel)2 NYMTableModel (com.moneychanger.ui.model.NYMTableModel)2 Account (com.moneychanger.core.Account)1 OpenTransactionAccount (com.moneychanger.core.OpenTransactionAccount)1 RippleAccount (com.moneychanger.core.RippleAccount)1 CashPurseDetails (com.moneychanger.core.dataobjects.CashPurseDetails)1 OTDetails (com.moneychanger.core.dataobjects.OTDetails)1 ComboObject (com.moneychanger.core.util.ComboObject)1 DateField (com.moneychanger.ui.custom.DateField)1 DeleteNYMDialog (com.moneychanger.ui.dialogs.DeleteNYMDialog)1 MarketTableModel (com.moneychanger.ui.model.MarketTableModel)1 MarketTradesTableModel (com.moneychanger.ui.model.MarketTradesTableModel)1