Skip to content

Commit

Permalink
update deck sniffer dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
nicol authored and nicol committed Dec 1, 2024
1 parent 338694c commit 78e870e
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ public AetherhubDeckSniffer() {

}

@Override
public boolean hasCardFilter() {
return true;
}

@Override
public boolean equals(Object obj) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,6 @@ public STATUT getStatut() {
}


@Override
public boolean hasCardFilter() {
// TODO Auto-generated method stub
return super.hasCardFilter();
}


@Override
public MTGDeck getDeck(RetrievableDeck info) throws IOException {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@ private void initcache() {
}


@Override
public boolean hasCardFilter() {
return true;
}

@Override
public String[] listFilter() {
return new String[] { "casual", "standard", "modern", "legacy", "edh-commander", "highlander", "frontier","pauper", "vintage", "extended", "cube", "tiny-leaders", "peasant", "other" };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,6 @@ public MagicVilleDeckSniffer()
mapCodes.put("EDH Peasant", "resultats?data=1&alt=EDHPeasant");
}

@Override
public boolean hasCardFilter() {
return true;
}




@Override
public String[] listFilter() {
return mapCodes.keySet().stream().toArray(String[]::new);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,6 @@ public Map<String, MTGProperty> getDefaultAttributes() {
}


@Override
public boolean hasCardFilter() {
return true;
}


@Override
public List<RetrievableDeck> getDeckList(String filter, MTGCard mc) throws IOException {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/magic/gui/AlarmGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
import org.magic.gui.abstracts.MTGUIComponent;
import org.magic.gui.components.card.MagicCardDetailPanel;
import org.magic.gui.components.charts.HistoryPricesPanel;
import org.magic.gui.components.dialog.importer.CardChooseDialog;
import org.magic.gui.components.dialog.importer.CardImporterDialog;
import org.magic.gui.components.prices.DeckPricePanel;
import org.magic.gui.components.prices.GroupedShoppingPanel;
import org.magic.gui.components.prices.PriceSuggesterComponent;
Expand Down Expand Up @@ -393,7 +393,7 @@ protected void process(List<MTGAlert> chunks) {
mnuImportSearch.setIcon(MTGConstants.ICON_SEARCH);

mnuImportSearch.addActionListener(importAE -> {
var cdSearch = new CardChooseDialog();
var cdSearch = new CardImporterDialog();
cdSearch.setVisible(true);
if (cdSearch.hasSelected()) {
for (MTGCard mc : cdSearch.getSelectedItems())
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/magic/gui/CardBuilder2GUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
import org.magic.gui.abstracts.AbstractBuzyIndicatorComponent;
import org.magic.gui.abstracts.MTGUIComponent;
import org.magic.gui.components.card.MagicEditionDetailPanel;
import org.magic.gui.components.dialog.importer.CardChooseDialog;
import org.magic.gui.components.dialog.importer.CardImporterDialog;
import org.magic.gui.components.editor.MagicCardEditorPanel;
import org.magic.gui.components.tech.ObjectViewerPanel;
import org.magic.gui.models.MagicCardTableModel;
Expand Down Expand Up @@ -308,7 +308,7 @@ protected Void doInBackground() throws Exception {
});

btnImport.addActionListener(e -> {
var l = new CardChooseDialog();
var l = new CardImporterDialog();
l.setVisible(true);
if (l.hasSelected())
initCard(l.getSelectedItem());
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/magic/gui/StockPanelGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
import org.magic.gui.components.card.MagicCardDetailPanel;
import org.magic.gui.components.charts.HistoryPricesPanel;
import org.magic.gui.components.deck.CardsDeckCheckerPanel;
import org.magic.gui.components.dialog.importer.CardChooseDialog;
import org.magic.gui.components.dialog.importer.CardImporterDialog;
import org.magic.gui.components.editor.LanguageComboBoxCellEditor;
import org.magic.gui.components.prices.PriceSuggesterComponent;
import org.magic.gui.components.prices.PricesTablePanel;
Expand Down Expand Up @@ -246,7 +246,7 @@ protected void done() {
mnuImportSearch.setIcon(MTGConstants.ICON_SEARCH);

mnuImportSearch.addActionListener(importAE -> {
var cdSearch = new CardChooseDialog();
var cdSearch = new CardImporterDialog();
cdSearch.setVisible(true);
if (cdSearch.hasSelected()) {
for (MTGCard mc : cdSearch.getSelectedItems())
Expand Down
61 changes: 53 additions & 8 deletions src/main/java/org/magic/gui/components/deck/DeckSnifferDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.KeyEvent;
import java.util.List;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ListSelectionModel;
Expand All @@ -21,6 +23,7 @@
import org.magic.api.beans.technical.RetrievableDeck;
import org.magic.api.interfaces.MTGDeckSniffer;
import org.magic.gui.abstracts.AbstractBuzyIndicatorComponent;
import org.magic.gui.components.dialog.importer.CardImporterDialog;
import org.magic.gui.models.DeckSnifferTableModel;
import org.magic.gui.renderer.ManaCellRenderer;
import org.magic.services.MTGConstants;
Expand All @@ -46,6 +49,10 @@ public class DeckSnifferDialog extends JDialog {
private transient MTGDeckSniffer selectedSniffer;
private JButton btnConnect;
private transient Logger logger = MTGLogger.getLogger(this.getClass());
private JPanel cardFilterPanel;

private MTGCard filteredCard=null;


public DeckSnifferDialog() {

Expand All @@ -60,26 +67,61 @@ public DeckSnifferDialog() {
getContentPane().add(new JScrollPane(table), BorderLayout.CENTER);


var panel = new JPanel();
getContentPane().add(panel, BorderLayout.NORTH);
var panelNorth = new JPanel();
getContentPane().add(panelNorth, BorderLayout.NORTH);

selectedSniffer = listEnabledPlugins(MTGDeckSniffer.class).get(0);
panel.setLayout(new BorderLayout(0, 0));
panelNorth.setLayout(new BorderLayout(0, 0));


panel.add(lblLoad, BorderLayout.CENTER);
panelNorth.add(lblLoad, BorderLayout.CENTER);

cboSniffers =UITools.createComboboxPlugins(MTGDeckSniffer.class,false);
btnConnect = new JButton(capitalize("CONNECT"));
cboFormats = new JComboBox<>();
panel.add(UITools.createFlowPanel(cboSniffers,btnConnect,cboFormats), BorderLayout.WEST);



var labCardFilter = new JLabel("With this card : ");
var btnCardImport = UITools.createBindableJButton("", MTGConstants.ICON_TAB_IMPORT, KeyEvent.VK_I, "WithCard");
var lblCard = new JLabel();
var btnRemoveCard = new JButton(MTGConstants.ICON_SMALL_DELETE);

btnCardImport.addActionListener(al->{
var importer = new CardImporterDialog();
importer.setVisible(true);

if(importer.hasSelected())
{
filteredCard = importer.getSelectedItem();
lblCard.setText(filteredCard.getName());
}
});

btnRemoveCard.addActionListener(al->{
filteredCard = null;
lblCard.setText("");

});



cardFilterPanel = UITools.createFlowPanel(labCardFilter,btnCardImport,lblCard,btnRemoveCard);

cardFilterPanel.setVisible(selectedSniffer.hasCardFilter());


panelNorth.add(UITools.createFlowPanel(cboSniffers,btnConnect,cboFormats,cardFilterPanel), BorderLayout.WEST);


cboFormats.addActionListener(e -> {
try {
lblLoad.start();
model.init(selectedSniffer.getDeckList(cboFormats.getSelectedItem().toString(),null));

if(selectedSniffer.hasCardFilter())
model.init(selectedSniffer.getDeckList(cboFormats.getSelectedItem().toString(),filteredCard));
else
model.init(selectedSniffer.getDeckList(cboFormats.getSelectedItem().toString(),null));

model.fireTableDataChanged();
lblLoad.end();
}catch (NullPointerException e1) {
Expand Down Expand Up @@ -115,7 +157,10 @@ protected void auditedRun() {
}
}, "Connection to " + selectedSniffer));

cboSniffers.addActionListener(e -> selectedSniffer = (MTGDeckSniffer) cboSniffers.getSelectedItem());
cboSniffers.addActionListener(e -> {
selectedSniffer = (MTGDeckSniffer) cboSniffers.getSelectedItem();
cardFilterPanel.setVisible(selectedSniffer.hasCardFilter());
});

var panelButton = new JPanel();
getContentPane().add(panelButton, BorderLayout.SOUTH);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.magic.gui.abstracts.AbstractDelegatedImporterDialog;
import org.magic.gui.components.card.CardSearchPanel;

public class CardChooseDialog extends AbstractDelegatedImporterDialog<MTGCard> {
public class CardImporterDialog extends AbstractDelegatedImporterDialog<MTGCard> {

private static final long serialVersionUID = 1L;
JButton selectCard;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
import org.magic.gui.abstracts.MTGUIComponent;
import org.magic.gui.components.deck.ConstructPanel;
import org.magic.gui.components.deck.JDeckChooserDialog;
import org.magic.gui.components.dialog.importer.CardChooseDialog;
import org.magic.gui.components.dialog.importer.CardImporterDialog;
import org.magic.gui.components.widgets.JLangLabel;
import org.magic.gui.models.CardStockTableModel;
import org.magic.gui.renderer.MessageRenderer;
Expand Down Expand Up @@ -339,7 +339,7 @@ public void keyReleased(java.awt.event.KeyEvent e) {
btnSearch.addActionListener(al->{
try
{
var diag = new CardChooseDialog();
var diag = new CardImporterDialog();
diag.setVisible(true);

if(diag.hasSelected())
Expand Down

0 comments on commit 78e870e

Please sign in to comment.