Search in sources :

Example 6 with MagicCardAlert

use of org.magic.api.beans.MagicCardAlert in project MtgDesktopCompanion by nicho92.

the class DAOProviderTests method testProviders.

public void testProviders(MTGDao p) {
    try {
        p.init();
        System.out.println("******************TESTING " + p);
        System.out.println("STATUT " + p.getStatut());
        System.out.println("LOCATION " + p.getDBLocation());
        System.out.println("SIZE " + p.getDBSize() / 1024 / 1024);
        System.out.println("TYPE " + p.getType());
        System.out.println("VERS " + p.getVersion());
        System.out.println("******************SAVING");
        p.saveCollection(col);
        p.saveCard(mc, col);
        System.out.println("******************LISTING");
        System.out.println("list  " + p.listCards());
        System.out.println("count " + p.getCardsCount(col, ed));
        System.out.println(p.listCardsFromCollection(col));
        System.out.println(p.listCardsFromCollection(col, ed));
        System.out.println(p.listCardsFromCollection(col, null));
        System.out.println(p.getEditionsIDFromCollection(col));
        System.out.println("global" + p.getCardsCountGlobal(col));
        System.out.println("cols: " + p.getCollections());
        System.out.println("test: " + p.getCollection("TEST"));
        System.out.println("cols: " + p.listCollectionFromCards(mc));
        System.out.println("******************ALERTS");
        MagicCardAlert alert = new MagicCardAlert();
        alert.setCard(mc);
        alert.setPrice(10.0);
        p.saveAlert(alert);
        alert.setPrice(15.0);
        p.updateAlert(alert);
        System.out.println(p.listAlerts());
        System.out.println(p.hasAlert(mc));
        System.out.println("******************STOCKS");
        MagicCardStock stock = new MagicCardStock();
        stock.setMagicCard(mc);
        stock.setComment("TEST");
        stock.setQte(1);
        stock.setCondition(EnumCondition.MINT);
        stock.setLanguage("French");
        stock.setMagicCollection(col);
        p.saveOrUpdateStock(stock);
        stock.setFoil(true);
        p.saveOrUpdateStock(stock);
        for (MagicCardStock st : p.listStocks()) {
            System.out.println(st.getIdstock() + " " + st.getMagicCard() + " " + st.getMagicCollection() + " " + st.isFoil());
        }
        System.out.println("Get stocks " + p.listStocks(mc, col));
        List<MagicCardStock> stocks = new ArrayList<>();
        stocks.add(stock);
        System.out.println("******************BACKUP");
        try {
            p.backup(new File("d:/"));
        } catch (Exception e) {
            System.err.println(e);
        }
        System.out.println("******************DELETE");
        p.deleteStock(stocks);
        // p.removeEdition(ed, col);
        p.removeCard(mc, col);
        p.removeCollection(col);
        p.deleteAlert(alert);
    } catch (Exception e) {
        System.out.println(e.getMessage());
    }
}
Also used : ArrayList(java.util.ArrayList) MagicCardAlert(org.magic.api.beans.MagicCardAlert) File(java.io.File) MagicCardStock(org.magic.api.beans.MagicCardStock)

Example 7 with MagicCardAlert

use of org.magic.api.beans.MagicCardAlert in project MtgDesktopCompanion by nicho92.

the class AlertedCardsTrendingDashlet method initGUI.

@Override
public void initGUI() {
    JScrollPane scrollPane = new JScrollPane();
    getContentPane().add(scrollPane, BorderLayout.CENTER);
    model = new CardAlertTableModel();
    JTable table = new JTable(model);
    scrollPane.setViewportView(table);
    HistoryPricesPanel historyPricesPanel = new HistoryPricesPanel();
    historyPricesPanel.setMaximumSize(new Dimension(2147483647, 200));
    historyPricesPanel.setPreferredSize(new Dimension(119, 200));
    getContentPane().add(historyPricesPanel, BorderLayout.SOUTH);
    table.getSelectionModel().addListSelectionListener(event -> {
        if (!event.getValueIsAdjusting()) {
            ThreadManager.getInstance().execute(() -> {
                int row = table.getSelectedRow();
                MagicCardAlert alt = (MagicCardAlert) table.getValueAt(row, 0);
                historyPricesPanel.init(alt.getCard(), alt.getCard().getEditions().get(0), alt.getCard().toString());
                historyPricesPanel.revalidate();
            });
        }
    });
    if (getProperties().size() > 0) {
        Rectangle r = new Rectangle((int) Double.parseDouble(getProperty("x")), (int) Double.parseDouble(getProperty("y")), (int) Double.parseDouble(getProperty("w")), (int) Double.parseDouble(getProperty("h")));
        setBounds(r);
    }
    setVisible(true);
}
Also used : JScrollPane(javax.swing.JScrollPane) JTable(javax.swing.JTable) Rectangle(java.awt.Rectangle) MagicCardAlert(org.magic.api.beans.MagicCardAlert) Dimension(java.awt.Dimension) HistoryPricesPanel(org.magic.gui.components.charts.HistoryPricesPanel) CardAlertTableModel(org.magic.gui.models.CardAlertTableModel)

Example 8 with MagicCardAlert

use of org.magic.api.beans.MagicCardAlert in project MtgDesktopCompanion by nicho92.

the class CardAlertTableModel method setValueAt.

@Override
public void setValueAt(Object aValue, int row, int column) {
    MagicCardAlert alert = MTGControler.getInstance().getEnabledDAO().listAlerts().get(row);
    alert.setPrice(Double.parseDouble(aValue.toString()));
    try {
        MTGControler.getInstance().getEnabledDAO().updateAlert(alert);
        fireTableDataChanged();
    } catch (Exception e) {
        MTGLogger.printStackTrace(e);
    }
}
Also used : MagicCardAlert(org.magic.api.beans.MagicCardAlert)

Aggregations

MagicCardAlert (org.magic.api.beans.MagicCardAlert)8 SQLException (java.sql.SQLException)4 IOException (java.io.IOException)3 PreparedStatement (java.sql.PreparedStatement)3 ResultSet (java.sql.ResultSet)3 ArrayList (java.util.ArrayList)2 Dimension (java.awt.Dimension)1 Rectangle (java.awt.Rectangle)1 File (java.io.File)1 TimerTask (java.util.TimerTask)1 JScrollPane (javax.swing.JScrollPane)1 JTable (javax.swing.JTable)1 MagicCard (org.magic.api.beans.MagicCard)1 MagicCardStock (org.magic.api.beans.MagicCardStock)1 MagicPrice (org.magic.api.beans.MagicPrice)1 MTGPricesProvider (org.magic.api.interfaces.MTGPricesProvider)1 HistoryPricesPanel (org.magic.gui.components.charts.HistoryPricesPanel)1 CardAlertTableModel (org.magic.gui.models.CardAlertTableModel)1