Search in sources :

Example 1 with CardAlertTableModel

use of org.magic.gui.models.CardAlertTableModel 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)

Aggregations

Dimension (java.awt.Dimension)1 Rectangle (java.awt.Rectangle)1 JScrollPane (javax.swing.JScrollPane)1 JTable (javax.swing.JTable)1 MagicCardAlert (org.magic.api.beans.MagicCardAlert)1 HistoryPricesPanel (org.magic.gui.components.charts.HistoryPricesPanel)1 CardAlertTableModel (org.magic.gui.models.CardAlertTableModel)1