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());
}
}
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);
}
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);
}
}
Aggregations