mirror of
https://github.com/magefree/mage.git
synced 2025-12-27 22:12:03 -08:00
Few lambda's and removed explicit type from creating lists and hashmaps
This commit is contained in:
parent
0a3c95dde5
commit
11dc1e10f1
130 changed files with 725 additions and 1105 deletions
|
|
@ -27,84 +27,19 @@
|
|||
*/
|
||||
package mage.client;
|
||||
|
||||
import java.awt.AWTEvent;
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.SplashScreen;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.ComponentAdapter;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.beans.PropertyVetoException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.prefs.Preferences;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.AbstractButton;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.InputMap;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JDesktopPane;
|
||||
import javax.swing.JEditorPane;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JInternalFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JLayeredPane;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JPopupMenu;
|
||||
import javax.swing.JToggleButton;
|
||||
import javax.swing.KeyStroke;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.event.PopupMenuEvent;
|
||||
import javax.swing.event.PopupMenuListener;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.cards.repository.CardCriteria;
|
||||
import mage.cards.repository.CardInfo;
|
||||
import mage.cards.repository.CardRepository;
|
||||
import mage.client.cards.BigCard;
|
||||
import mage.client.chat.ChatPanelBasic;
|
||||
import mage.client.components.MageComponents;
|
||||
import mage.client.components.MageDesktopManager;
|
||||
import mage.client.components.MageJDesktop;
|
||||
import mage.client.components.MageRoundPane;
|
||||
import mage.client.components.MageUI;
|
||||
import mage.client.components.*;
|
||||
import mage.client.components.ext.dlg.DialogManager;
|
||||
import mage.client.components.tray.MageTray;
|
||||
import mage.client.constants.Constants.DeckEditorMode;
|
||||
import mage.client.deckeditor.DeckEditorPane;
|
||||
import mage.client.deckeditor.collection.viewer.CollectionViewerPane;
|
||||
import mage.client.dialog.AboutDialog;
|
||||
import mage.client.dialog.ConnectDialog;
|
||||
import mage.client.dialog.ErrorDialog;
|
||||
import mage.client.dialog.FeedbackDialog;
|
||||
import mage.client.dialog.GameEndDialog;
|
||||
import mage.client.dialog.MageDialog;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
import mage.client.dialog.TableWaitingDialog;
|
||||
import mage.client.dialog.UserRequestDialog;
|
||||
import mage.client.dialog.*;
|
||||
import mage.client.draft.DraftPane;
|
||||
import mage.client.draft.DraftPanel;
|
||||
import mage.client.game.GamePane;
|
||||
|
|
@ -114,11 +49,7 @@ import mage.client.preference.MagePreferences;
|
|||
import mage.client.remote.CallbackClientImpl;
|
||||
import mage.client.table.TablesPane;
|
||||
import mage.client.tournament.TournamentPane;
|
||||
import mage.client.util.EDTExceptionHandler;
|
||||
import mage.client.util.GUISizeHelper;
|
||||
import mage.client.util.ImageCaches;
|
||||
import mage.client.util.SettingsManager;
|
||||
import mage.client.util.SystemUtil;
|
||||
import mage.client.util.*;
|
||||
import mage.client.util.audio.MusicPlayer;
|
||||
import mage.client.util.gui.ArrowBuilder;
|
||||
import mage.client.util.gui.countryBox.CountryUtil;
|
||||
|
|
@ -145,6 +76,25 @@ import org.mage.plugins.card.images.DownloadPictures;
|
|||
import org.mage.plugins.card.info.CardInfoPaneImpl;
|
||||
import org.mage.plugins.card.utils.impl.ImageManagerImpl;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.PopupMenuEvent;
|
||||
import javax.swing.event.PopupMenuListener;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.beans.PropertyVetoException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.prefs.Preferences;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
|
|
@ -472,7 +422,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
String filename = "/background.jpg";
|
||||
try {
|
||||
if (Plugins.getInstance().isThemePluginLoaded()) {
|
||||
backgroundPane = (ImagePanel) Plugins.getInstance().updateTablePanel(new HashMap<String, JComponent>());
|
||||
backgroundPane = (ImagePanel) Plugins.getInstance().updateTablePanel(new HashMap<>());
|
||||
} else {
|
||||
InputStream is = this.getClass().getResourceAsStream(filename);
|
||||
BufferedImage background = ImageIO.read(is);
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
|
|||
}
|
||||
|
||||
public void show(AbilityPickerView choices, Point p) {
|
||||
this.choices = new ArrayList<Object>();
|
||||
this.choices = new ArrayList<>();
|
||||
this.selected = true; // to stop previous modal
|
||||
|
||||
for (Map.Entry<UUID, String> choice : choices.getChoices().entrySet()) {
|
||||
|
|
@ -236,7 +236,7 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
|
|||
|
||||
public static class ImageRenderer2 extends JEditorPane implements ListCellRenderer {
|
||||
|
||||
public final Map<String, String> cache = new HashMap<String, String>();
|
||||
public final Map<String, String> cache = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(
|
||||
|
|
@ -398,7 +398,7 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
|
|||
|
||||
JFrame jframe = new JFrame("Test");
|
||||
|
||||
List<Object> objectList = new ArrayList<Object>();
|
||||
List<Object> objectList = new ArrayList<>();
|
||||
objectList.add("T: add {R} to your mana pool. 111111111111111111111111111");
|
||||
objectList.add("T: add {B} to your mana pool. {source} deals 1 damage to you.");
|
||||
objectList.add("{T}: add {B} to your mana pool");
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ public class DlgParams {
|
|||
|
||||
boolean isAI = false;
|
||||
|
||||
public HashSet<String> manaChoices = new HashSet<String>();
|
||||
public HashSet<String> manaChoices = new HashSet<>();
|
||||
|
||||
public int getPlayerID() {
|
||||
return playerID;
|
||||
|
|
|
|||
|
|
@ -9,18 +9,18 @@ import mage.client.components.ext.dlg.DialogManager;
|
|||
import mage.client.components.ext.dlg.DlgParams;
|
||||
import mage.client.components.ext.dlg.IDialogPanel;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
import mage.client.util.audio.AudioManager;
|
||||
import mage.client.util.Command;
|
||||
import mage.client.util.SettingsManager;
|
||||
import mage.client.util.audio.AudioManager;
|
||||
import mage.view.CardView;
|
||||
import mage.view.CardsView;
|
||||
import org.mage.card.arcane.CardPanel;
|
||||
import org.mage.plugins.card.utils.impl.ImageManagerImpl;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
import org.mage.card.arcane.CardPanel;
|
||||
|
||||
/**
|
||||
* @author mw, noxx
|
||||
|
|
@ -130,7 +130,7 @@ public class ChoiceDialog extends IDialogPanel {
|
|||
return;
|
||||
}
|
||||
|
||||
java.util.List<Component> toRemove = new ArrayList<Component>();
|
||||
java.util.List<Component> toRemove = new ArrayList<>();
|
||||
for (int i = getComponentCount() - 1; i > 0; i--) {
|
||||
Component o = getComponent(i);
|
||||
if (o instanceof MageCard) {
|
||||
|
|
@ -141,7 +141,7 @@ public class ChoiceDialog extends IDialogPanel {
|
|||
remove(toRemove.get(i));
|
||||
}
|
||||
|
||||
java.util.List<CardView> cardList = new ArrayList<CardView>(cards.values());
|
||||
java.util.List<CardView> cardList = new ArrayList<>(cards.values());
|
||||
|
||||
int width = SettingsManager.getInstance().getCardSize().width;
|
||||
int height = SettingsManager.getInstance().getCardSize().height;
|
||||
|
|
|
|||
|
|
@ -33,19 +33,6 @@
|
|||
*/
|
||||
package mage.client.deckeditor;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.ComponentListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.*;
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
import mage.MageObject;
|
||||
import mage.ObjectColor;
|
||||
import mage.cards.Card;
|
||||
|
|
@ -72,6 +59,13 @@ import mage.filter.predicate.other.ExpansionSetPredicate;
|
|||
import mage.view.CardView;
|
||||
import mage.view.CardsView;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com, nantuko
|
||||
|
|
@ -442,7 +436,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
|||
tbWhite = new javax.swing.JToggleButton();
|
||||
tbColorless = new javax.swing.JToggleButton();
|
||||
jSeparator1 = new javax.swing.JToolBar.Separator();
|
||||
cbExpansionSet = new javax.swing.JComboBox<String>();
|
||||
cbExpansionSet = new javax.swing.JComboBox<>();
|
||||
jSeparator2 = new javax.swing.JToolBar.Separator();
|
||||
btnBooster = new javax.swing.JButton();
|
||||
btnClear = new javax.swing.JButton();
|
||||
|
|
@ -457,7 +451,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
|||
jSeparator6 = new javax.swing.JToolBar.Separator();
|
||||
chkPiles = new javax.swing.JCheckBox();
|
||||
jSeparator3 = new javax.swing.JToolBar.Separator();
|
||||
cbSortBy = new javax.swing.JComboBox<SortBy>();
|
||||
cbSortBy = new javax.swing.JComboBox<>();
|
||||
jSeparator4 = new javax.swing.JToolBar.Separator();
|
||||
jToggleListView = new javax.swing.JToggleButton();
|
||||
jToggleCardView = new javax.swing.JToggleButton();
|
||||
|
|
|
|||
|
|
@ -27,13 +27,14 @@
|
|||
*/
|
||||
package mage.client.deckeditor.collection.viewer;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.swing.JComponent;
|
||||
import mage.client.MagePane;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Collection viewer pane.
|
||||
* Contains background and components container.
|
||||
|
|
@ -46,7 +47,7 @@ public class CollectionViewerPane extends MagePane {
|
|||
boolean initialized = false;
|
||||
this.setTitle("Collection Viewer");
|
||||
if (Plugins.getInstance().isThemePluginLoaded()) {
|
||||
Map<String, JComponent> uiComponents = new HashMap<String, JComponent>();
|
||||
Map<String, JComponent> uiComponents = new HashMap<>();
|
||||
JComponent container = Plugins.getInstance().updateTablePanel(uiComponents);
|
||||
if (container != null) {
|
||||
collectionViewerPanel = new CollectionViewerPanel();
|
||||
|
|
|
|||
|
|
@ -34,14 +34,15 @@
|
|||
|
||||
package mage.client.table;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.deck.generator.DeckGenerator;
|
||||
import mage.client.util.Config;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
|
@ -150,18 +151,10 @@ public class NewPlayerPanel extends javax.swing.JPanel {
|
|||
lblPlayerDeck.setText("Deck:");
|
||||
|
||||
btnPlayerDeck.setText("...");
|
||||
btnPlayerDeck.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
btnPlayerDeckActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
btnPlayerDeck.addActionListener(evt -> btnPlayerDeckActionPerformed(evt));
|
||||
|
||||
btnGenerate.setText("Generate");
|
||||
btnGenerate.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
btnGenerateActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
btnGenerate.addActionListener(evt -> btnGenerateActionPerformed(evt));
|
||||
|
||||
lblLevel.setText("Skill:");
|
||||
|
||||
|
|
|
|||
|
|
@ -34,12 +34,12 @@
|
|||
|
||||
package mage.client.table;
|
||||
|
||||
import java.util.UUID;
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.JComboBox;
|
||||
import mage.cards.decks.DeckCardLists;
|
||||
import mage.client.SessionHandler;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
|
@ -99,11 +99,7 @@ public class TournamentPlayerPanel extends javax.swing.JPanel {
|
|||
jLabel1.setText("Type:");
|
||||
|
||||
cbPlayerType.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
|
||||
cbPlayerType.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
cbPlayerTypeActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
cbPlayerType.addActionListener(evt -> cbPlayerTypeActionPerformed(evt));
|
||||
|
||||
lblPlayerNum.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
|
||||
lblPlayerNum.setText("Player Num:");
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
package mage.client.unusedFiles;
|
||||
//package mage.client.thread;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
|
@ -18,7 +18,7 @@ public class DelayedViewerThread extends Thread {
|
|||
private final Map<Component, Long> delayedViewers;
|
||||
|
||||
protected DelayedViewerThread() {
|
||||
delayedViewers = new HashMap<Component, Long>();
|
||||
delayedViewers = new HashMap<>();
|
||||
start();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,9 +30,9 @@ public class ArrowBuilder {
|
|||
/**
|
||||
* Stores arrow panels per game
|
||||
*/
|
||||
private final Map<UUID, JPanel> arrowPanels = new HashMap<UUID, JPanel>();
|
||||
private final Map<UUID, JPanel> arrowPanels = new HashMap<>();
|
||||
|
||||
private final Map<UUID, Map<Type, List<Arrow>>> map = new HashMap<UUID, Map<Type, java.util.List<Arrow>>>();
|
||||
private final Map<UUID, Map<Type, List<Arrow>>> map = new HashMap<>();
|
||||
|
||||
private int currentWidth;
|
||||
private int currentHeight;
|
||||
|
|
@ -103,16 +103,8 @@ public class ArrowBuilder {
|
|||
|
||||
synchronized (map) {
|
||||
p.add(arrow);
|
||||
Map<Type, java.util.List<Arrow>> innerMap = map.get(gameId);
|
||||
if (innerMap == null) {
|
||||
innerMap = new HashMap<Type, List<Arrow>>();
|
||||
map.put(gameId, innerMap);
|
||||
}
|
||||
java.util.List<Arrow> arrows = innerMap.get(type);
|
||||
if (arrows == null) {
|
||||
arrows = new ArrayList<Arrow>();
|
||||
innerMap.put(type, arrows);
|
||||
}
|
||||
Map<Type, java.util.List<Arrow>> innerMap = map.computeIfAbsent(gameId, k -> new HashMap<>());
|
||||
java.util.List<Arrow> arrows = innerMap.computeIfAbsent(type, k -> new ArrayList<>());
|
||||
arrows.add(arrow);
|
||||
}
|
||||
|
||||
|
|
@ -149,7 +141,7 @@ public class ArrowBuilder {
|
|||
for (Arrow arrow : arrows) {
|
||||
p.remove(arrow);
|
||||
}
|
||||
innerMap.put(type, new ArrayList<Arrow>());
|
||||
innerMap.put(type, new ArrayList<>());
|
||||
}
|
||||
p.revalidate();
|
||||
p.repaint();
|
||||
|
|
|
|||
|
|
@ -767,7 +767,7 @@ public class ModernCardRenderer extends CardRenderer {
|
|||
// Add the keyword rule if there are any keywords
|
||||
if (!textboxKeywords.isEmpty()) {
|
||||
String keywordRulesString = getKeywordRulesString();
|
||||
TextboxRule keywordsRule = new TextboxRule(keywordRulesString, new ArrayList<TextboxRule.AttributeRegion>());
|
||||
TextboxRule keywordsRule = new TextboxRule(keywordRulesString, new ArrayList<>());
|
||||
allRules.add(0, keywordsRule);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,12 +9,10 @@ import com.google.common.base.Function;
|
|||
import com.google.common.collect.AbstractIterator;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import java.util.ArrayList;
|
||||
import static java.util.Arrays.*;
|
||||
import java.util.EventListener;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
/**
|
||||
* The class EventListenerList.
|
||||
|
|
@ -35,13 +33,13 @@ public class EventListenerList extends javax.swing.event.EventListenerList {
|
|||
*/
|
||||
public <T extends EventListener> Iterable<T> getIterable(final Class<? extends T>... listenerClass) {
|
||||
//transform class -> iterable
|
||||
List<Iterable<T>> l = Lists.transform(asList(listenerClass), new ClassToIterableFunction<T>());
|
||||
List<Iterable<T>> l = Lists.transform(asList(listenerClass), new ClassToIterableFunction<>());
|
||||
|
||||
//compose iterable (use an arraylist to memoize the function's results)
|
||||
final Iterable<T> it = Iterables.concat(new ArrayList<Iterable<T>>(l));
|
||||
final Iterable<T> it = Iterables.concat(new ArrayList<>(l));
|
||||
|
||||
//transform to singleton iterators
|
||||
return () -> new SingletonIterator<T>(it.iterator());
|
||||
return () -> new SingletonIterator<>(it.iterator());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -92,7 +90,7 @@ public class EventListenerList extends javax.swing.event.EventListenerList {
|
|||
private class ClassToIterableFunction<T> implements Function<Class<? extends T>, Iterable<T>> {
|
||||
|
||||
public Iterable<T> apply(final Class<? extends T> from) {
|
||||
return () -> new ListenerIterator<T>(from);
|
||||
return () -> new ListenerIterator<>(from);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -103,7 +101,7 @@ public class EventListenerList extends javax.swing.event.EventListenerList {
|
|||
private static class SingletonIterator<T> extends AbstractIterator<T> {
|
||||
|
||||
private final Iterator<T> it;
|
||||
private final HashSet<T> previous = new HashSet<T>();
|
||||
private final HashSet<T> previous = new HashSet<>();
|
||||
|
||||
public SingletonIterator(Iterator<T> it) {
|
||||
this.it = it;
|
||||
|
|
|
|||
|
|
@ -8,16 +8,7 @@ package org.mage.plugins.card.dl.beans.collections;
|
|||
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.AbstractList;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.AbstractSequentialList;
|
||||
import java.util.AbstractSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
import java.util.RandomAccess;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -34,18 +25,18 @@ public final class ListenableCollections {
|
|||
|
||||
public static <E> List<E> listenableList(List<E> list, ListListener<E> listener) {
|
||||
if (list instanceof RandomAccess) {
|
||||
return new ListenableList<E>(list, listener);
|
||||
return new ListenableList<>(list, listener);
|
||||
} else {
|
||||
return new ListenableSequentialList<E>(list, listener);
|
||||
return new ListenableSequentialList<>(list, listener);
|
||||
}
|
||||
}
|
||||
|
||||
public static <E> Set<E> listenableSet(Set<E> set, SetListener<E> listener) {
|
||||
return new ListenableSet<E>(set, listener);
|
||||
return new ListenableSet<>(set, listener);
|
||||
}
|
||||
|
||||
public static <K, V> Map<K, V> listenableMap(Map<K, V> map, MapListener<K, V> listener) {
|
||||
return new ListenableMap<K, V>(map, listener);
|
||||
return new ListenableMap<>(map, listener);
|
||||
}
|
||||
|
||||
public interface ListListener<E> extends Serializable {
|
||||
|
|
|
|||
|
|
@ -7,13 +7,9 @@
|
|||
package org.mage.plugins.card.dl.beans.properties;
|
||||
|
||||
|
||||
import static java.util.Arrays.*;
|
||||
import java.util.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -31,7 +27,7 @@ public class CompoundProperties extends AbstractProperties {
|
|||
}
|
||||
|
||||
public CompoundProperties(List<Properties> delegates) {
|
||||
this.delegates = new ArrayList<Properties>(delegates);
|
||||
this.delegates = new ArrayList<>(delegates);
|
||||
Collections.reverse(this.delegates);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,17 +7,15 @@
|
|||
package org.mage.plugins.card.dl.beans.properties.bound;
|
||||
|
||||
|
||||
import static org.mage.plugins.card.dl.beans.collections.ListenableCollections.listenableList;
|
||||
import static org.mage.plugins.card.dl.beans.collections.ListenableCollections.listenableMap;
|
||||
import static org.mage.plugins.card.dl.beans.collections.ListenableCollections.listenableSet;
|
||||
import org.mage.plugins.card.dl.beans.PropertyChangeSupport;
|
||||
import org.mage.plugins.card.dl.beans.properties.AbstractProperties;
|
||||
import org.mage.plugins.card.dl.beans.properties.Property;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.mage.plugins.card.dl.beans.PropertyChangeSupport;
|
||||
import org.mage.plugins.card.dl.beans.properties.AbstractProperties;
|
||||
import org.mage.plugins.card.dl.beans.properties.Property;
|
||||
import static org.mage.plugins.card.dl.beans.collections.ListenableCollections.*;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -39,18 +37,18 @@ public class BoundProperties extends AbstractProperties {
|
|||
}
|
||||
|
||||
public <T> Property<T> property(String name, Property<T> property) {
|
||||
return new BoundProperty<T>(s, name, property);
|
||||
return new BoundProperty<>(s, name, property);
|
||||
}
|
||||
|
||||
public <E> List<E> list(String name, List<E> list) {
|
||||
return listenableList(list, new PropertyChangeListListener<E>(s, name));
|
||||
return listenableList(list, new PropertyChangeListListener<>(s, name));
|
||||
}
|
||||
|
||||
public <E> Set<E> set(String name, Set<E> set) {
|
||||
return listenableSet(set, new PropertyChangeSetListener<E>(s, set, name));
|
||||
return listenableSet(set, new PropertyChangeSetListener<>(s, set, name));
|
||||
}
|
||||
|
||||
public <K, V> Map<K, V> map(String name, Map<K, V> map) {
|
||||
return listenableMap(map, new PropertyChangeMapListener<K, V>(s, map, name));
|
||||
return listenableMap(map, new PropertyChangeMapListener<>(s, map, name));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@
|
|||
package org.mage.plugins.card.dl.beans.properties.bound;
|
||||
|
||||
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.util.Map;
|
||||
|
||||
import org.mage.plugins.card.dl.beans.PropertyChangeSupport;
|
||||
import org.mage.plugins.card.dl.beans.collections.ListenableCollections.MapListener;
|
||||
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* The class PropertyChangeMapListener. This listener alway fires events with {@link Map} -> {@link Map} as the
|
||||
|
|
@ -35,15 +35,15 @@ public class PropertyChangeMapListener<K, V> implements MapListener<K, V> {
|
|||
}
|
||||
|
||||
public void put(K key, V newValue) {
|
||||
s.firePropertyChange(new MapPutEvent<K, V>(s.getSourceBean(), propertyName, map, key, newValue));
|
||||
s.firePropertyChange(new MapPutEvent<>(s.getSourceBean(), propertyName, map, key, newValue));
|
||||
}
|
||||
|
||||
public void set(K key, V oldValue, V newValue) {
|
||||
s.firePropertyChange(new MapSetEvent<K, V>(s.getSourceBean(), propertyName, map, key, oldValue, newValue));
|
||||
s.firePropertyChange(new MapSetEvent<>(s.getSourceBean(), propertyName, map, key, oldValue, newValue));
|
||||
}
|
||||
|
||||
public void remove(K key, V oldValue) {
|
||||
s.firePropertyChange(new MapRemoveEvent<K, V>(s.getSourceBean(), propertyName, map, key, oldValue));
|
||||
s.firePropertyChange(new MapRemoveEvent<>(s.getSourceBean(), propertyName, map, key, oldValue));
|
||||
}
|
||||
|
||||
public static abstract class MapEvent<K, V> extends PropertyChangeEvent {
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@
|
|||
package org.mage.plugins.card.dl.beans.properties.bound;
|
||||
|
||||
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.util.Set;
|
||||
|
||||
import org.mage.plugins.card.dl.beans.PropertyChangeSupport;
|
||||
import org.mage.plugins.card.dl.beans.collections.ListenableCollections.SetListener;
|
||||
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
* The class PropertyChangeSetListener. This listener always fires events with {@link Set} -> {@link Set} as the
|
||||
|
|
@ -35,11 +35,11 @@ public class PropertyChangeSetListener<E> implements SetListener<E> {
|
|||
}
|
||||
|
||||
public void add(E newValue) {
|
||||
s.firePropertyChange(new SetAddEvent<E>(s.getSourceBean(), propertyName, set, newValue));
|
||||
s.firePropertyChange(new SetAddEvent<>(s.getSourceBean(), propertyName, set, newValue));
|
||||
}
|
||||
|
||||
public void remove(E oldValue) {
|
||||
s.firePropertyChange(new SetRemoveEvent<E>(s.getSourceBean(), propertyName, set, oldValue));
|
||||
s.firePropertyChange(new SetRemoveEvent<>(s.getSourceBean(), propertyName, set, oldValue));
|
||||
}
|
||||
|
||||
public static abstract class SetEvent<E> extends PropertyChangeEvent {
|
||||
|
|
|
|||
|
|
@ -27,11 +27,12 @@
|
|||
*/
|
||||
package org.mage.plugins.card.dl.sources;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.mage.plugins.card.images.CardDownloadData;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author spjspj
|
||||
|
|
@ -104,9 +105,9 @@ public class AltMtgOnlTokensImageSource implements CardImageSource {
|
|||
if (copyUrlToImage != null) {
|
||||
return;
|
||||
}
|
||||
copyUrlToImage = new HashMap<String, String>();
|
||||
copyImageToUrl = new HashMap<String, String>();
|
||||
copyUrlToImageDone = new HashMap<String, Integer>();
|
||||
copyUrlToImage = new HashMap<>();
|
||||
copyImageToUrl = new HashMap<>();
|
||||
copyUrlToImageDone = new HashMap<>();
|
||||
|
||||
copyUrlToImage.put("SCG_CC_002-Penguin.jpg", "BIRD.WU.BIRD.CREATURE.1.1.full.jpg");
|
||||
copyUrlToImage.put("SCG_CC_005-Vampire.jpg", "VAMPIRE.B.VAMPIRE.CREATURE.1.1.full.jpg");
|
||||
|
|
|
|||
|
|
@ -27,11 +27,12 @@
|
|||
*/
|
||||
package org.mage.plugins.card.dl.sources;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.mage.plugins.card.images.CardDownloadData;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author spjspj
|
||||
|
|
@ -104,9 +105,9 @@ public class MtgOnlTokensImageSource implements CardImageSource {
|
|||
if (copyUrlToImage != null) {
|
||||
return;
|
||||
}
|
||||
copyUrlToImage = new HashMap<String, String>();
|
||||
copyImageToUrl = new HashMap<String, String>();
|
||||
copyUrlToImageDone = new HashMap<String, Integer>();
|
||||
copyUrlToImage = new HashMap<>();
|
||||
copyImageToUrl = new HashMap<>();
|
||||
copyUrlToImageDone = new HashMap<>();
|
||||
copyUrlToImage.put("Angel_B_3_3.jpg", "ANGEL.B.ANGEL.CREATURE.3.3.full.jpg");
|
||||
copyUrlToImage.put("Angel_W_3_3.jpg", "ANGEL.W.ANGEL.CREATURE.3.3.full.jpg");
|
||||
copyUrlToImage.put("Angel_W_4_4.jpg", "ANGEL.W.ANGEL.CREATURE.4.4.full.jpg");
|
||||
|
|
|
|||
|
|
@ -105,20 +105,12 @@ public class MultiConnectTest {
|
|||
}
|
||||
|
||||
private void connect(final int index) throws Exception {
|
||||
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
|
||||
@Override
|
||||
public void uncaughtException(Thread t, Throwable e) {
|
||||
logger.fatal(null, e);
|
||||
}
|
||||
});
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String username = "player" + index;
|
||||
ClientMock client = new ClientMock(username);
|
||||
client.connect();
|
||||
latch.countDown();
|
||||
}
|
||||
Thread.setDefaultUncaughtExceptionHandler((t, e) -> logger.fatal(null, e));
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
String username = "player" + index;
|
||||
ClientMock client = new ClientMock(username);
|
||||
client.connect();
|
||||
latch.countDown();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
package mage.client.game;
|
||||
|
||||
import javax.swing.SwingUtilities;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.components.MageComponents;
|
||||
import mage.client.components.MageUI;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.Ignore;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author ayratn
|
||||
*/
|
||||
|
|
@ -42,18 +43,12 @@ public class StartMultiGamesTest {
|
|||
|
||||
private void startGame() throws Exception {
|
||||
frame = null;
|
||||
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
|
||||
public void uncaughtException(Thread t, Throwable e) {
|
||||
logger.fatal(null, e);
|
||||
}
|
||||
});
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
synchronized (sync) {
|
||||
frame = new MageFrame();
|
||||
frame.setVisible(true);
|
||||
sync.notify();
|
||||
}
|
||||
Thread.setDefaultUncaughtExceptionHandler((t, e) -> logger.fatal(null, e));
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
synchronized (sync) {
|
||||
frame = new MageFrame();
|
||||
frame.setVisible(true);
|
||||
sync.notify();
|
||||
}
|
||||
});
|
||||
synchronized (sync) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue