mirror of
https://github.com/correl/mage.git
synced 2024-12-25 19:25:41 +00:00
UI: added deck editor sets update on server connection (on new release);
This commit is contained in:
parent
264d81305e
commit
ff00d3c482
1 changed files with 120 additions and 107 deletions
|
@ -5,29 +5,17 @@
|
||||||
*/
|
*/
|
||||||
package mage.client.deckeditor;
|
package mage.client.deckeditor;
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.event.*;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import javax.swing.*;
|
|
||||||
import javax.swing.table.DefaultTableCellRenderer;
|
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.ObjectColor;
|
import mage.ObjectColor;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.ExpansionSet;
|
import mage.cards.ExpansionSet;
|
||||||
import mage.cards.Sets;
|
import mage.cards.Sets;
|
||||||
import mage.cards.repository.CardCriteria;
|
import mage.cards.repository.*;
|
||||||
import mage.cards.repository.CardInfo;
|
|
||||||
import mage.cards.repository.CardRepository;
|
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.client.cards.*;
|
import mage.client.cards.*;
|
||||||
import mage.client.constants.Constants.SortBy;
|
import mage.client.constants.Constants.SortBy;
|
||||||
import mage.client.deckeditor.table.TableModel;
|
import mage.client.deckeditor.table.TableModel;
|
||||||
import mage.client.dialog.CheckBoxList;
|
import mage.client.dialog.CheckBoxList;
|
||||||
import static mage.client.dialog.PreferencesDialog.KEY_DECK_EDITOR_SEARCH_NAMES;
|
|
||||||
import static mage.client.dialog.PreferencesDialog.KEY_DECK_EDITOR_SEARCH_RULES;
|
|
||||||
import static mage.client.dialog.PreferencesDialog.KEY_DECK_EDITOR_SEARCH_TYPES;
|
|
||||||
import static mage.client.dialog.PreferencesDialog.KEY_DECK_EDITOR_SEARCH_UNIQUE;
|
|
||||||
import mage.client.util.GUISizeHelper;
|
import mage.client.util.GUISizeHelper;
|
||||||
import mage.client.util.gui.FastSearchUtil;
|
import mage.client.util.gui.FastSearchUtil;
|
||||||
import mage.client.util.sets.ConstructedFormats;
|
import mage.client.util.sets.ConstructedFormats;
|
||||||
|
@ -41,12 +29,21 @@ import mage.filter.predicate.mageobject.ColorPredicate;
|
||||||
import mage.filter.predicate.mageobject.ColorlessPredicate;
|
import mage.filter.predicate.mageobject.ColorlessPredicate;
|
||||||
import mage.filter.predicate.other.CardTextPredicate;
|
import mage.filter.predicate.other.CardTextPredicate;
|
||||||
import mage.filter.predicate.other.ExpansionSetPredicate;
|
import mage.filter.predicate.other.ExpansionSetPredicate;
|
||||||
|
import mage.game.events.Listener;
|
||||||
import mage.view.CardView;
|
import mage.view.CardView;
|
||||||
import mage.view.CardsView;
|
import mage.view.CardsView;
|
||||||
import org.mage.card.arcane.ManaSymbolsCellRenderer;
|
import org.mage.card.arcane.ManaSymbolsCellRenderer;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import javax.swing.table.DefaultTableCellRenderer;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import static mage.client.dialog.PreferencesDialog.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author BetaSteward_at_googlemail.com, nantuko
|
* @author BetaSteward_at_googlemail.com, nantuko
|
||||||
*/
|
*/
|
||||||
public class CardSelector extends javax.swing.JPanel implements ComponentListener, DragCardTarget {
|
public class CardSelector extends javax.swing.JPanel implements ComponentListener, DragCardTarget {
|
||||||
|
@ -56,6 +53,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
||||||
private boolean limited = false;
|
private boolean limited = false;
|
||||||
private final SortSetting sortSetting;
|
private final SortSetting sortSetting;
|
||||||
private static final Map<String, Integer> pdAllowed = new HashMap<>();
|
private static final Map<String, Integer> pdAllowed = new HashMap<>();
|
||||||
|
private static Listener<RepositoryEvent> setsDbListener = null;
|
||||||
|
|
||||||
private final String TEST_MULTI_SET = "Multiple Sets selected";
|
private final String TEST_MULTI_SET = "Multiple Sets selected";
|
||||||
|
|
||||||
|
@ -163,7 +161,6 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Free all references
|
* Free all references
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public void cleanUp() {
|
public void cleanUp() {
|
||||||
this.cardGrid.clear();
|
this.cardGrid.clear();
|
||||||
|
@ -503,6 +500,11 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void reloadSetsCombobox() {
|
||||||
|
DefaultComboBoxModel model = new DefaultComboBoxModel<>(ConstructedFormats.getTypes());
|
||||||
|
cbExpansionSet.setModel(model);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is called from within the constructor to initialize the form.
|
* This method is called from within the constructor to initialize the form.
|
||||||
* WARNING: Do NOT modify this code. The content of this method is always
|
* WARNING: Do NOT modify this code. The content of this method is always
|
||||||
|
@ -664,7 +666,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
||||||
tbColor.add(tbColorless);
|
tbColor.add(tbColorless);
|
||||||
tbColor.add(jSeparator1);
|
tbColor.add(jSeparator1);
|
||||||
|
|
||||||
cbExpansionSet.setModel(new DefaultComboBoxModel<>(ConstructedFormats.getTypes()));
|
reloadSetsCombobox();
|
||||||
cbExpansionSet.setMaximumSize(new java.awt.Dimension(250, 25));
|
cbExpansionSet.setMaximumSize(new java.awt.Dimension(250, 25));
|
||||||
cbExpansionSet.setMinimumSize(new java.awt.Dimension(250, 25));
|
cbExpansionSet.setMinimumSize(new java.awt.Dimension(250, 25));
|
||||||
cbExpansionSet.setName("cbExpansionSet"); // NOI18N
|
cbExpansionSet.setName("cbExpansionSet"); // NOI18N
|
||||||
|
@ -674,6 +676,17 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
||||||
cbExpansionSetActionPerformed(evt);
|
cbExpansionSetActionPerformed(evt);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// auto-update sets list on changes
|
||||||
|
setsDbListener = new Listener<RepositoryEvent>() {
|
||||||
|
@Override
|
||||||
|
public void event(RepositoryEvent event) {
|
||||||
|
if (event.getEventType().equals(RepositoryEvent.RepositoryEventType.DB_UPDATED)) {
|
||||||
|
reloadSetsCombobox();
|
||||||
|
// TODO: auto-refresh cards list
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
ExpansionRepository.instance.subscribe(setsDbListener);
|
||||||
tbColor.add(cbExpansionSet);
|
tbColor.add(cbExpansionSet);
|
||||||
|
|
||||||
btnExpansionSearch.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/search_32.png"))); // NOI18N
|
btnExpansionSearch.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/search_32.png"))); // NOI18N
|
||||||
|
|
Loading…
Reference in a new issue