From 0528555075e61ee1ee989331f4b9ba183edfddaa Mon Sep 17 00:00:00 2001 From: igoudt Date: Wed, 26 Apr 2017 10:23:49 +0200 Subject: [PATCH] make DefaulActionCallback an enum and remove unused parameter --- .../src/main/java/mage/client/cards/Card.java | 3 +-- .../client/plugins/adapters/MageActionCallback.java | 5 ++--- .../java/mage/client/util/DefaultActionCallback.java | 12 +++--------- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/Mage.Client/src/main/java/mage/client/cards/Card.java b/Mage.Client/src/main/java/mage/client/cards/Card.java index 1869334557..09806d887e 100644 --- a/Mage.Client/src/main/java/mage/client/cards/Card.java +++ b/Mage.Client/src/main/java/mage/client/cards/Card.java @@ -68,7 +68,6 @@ import static mage.client.constants.Constants.*; @SuppressWarnings("serial") public class Card extends MagePermanent implements MouseMotionListener, MouseListener, FocusListener, ComponentListener { - protected static final DefaultActionCallback callback = DefaultActionCallback.getInstance(); protected Point p; protected final CardDimensions dimension; @@ -367,7 +366,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis @Override public void mousePressed(MouseEvent e) { requestFocusInWindow(); - callback.mouseClicked(e, gameId, card); + DefaultActionCallback.instance.mouseClicked(gameId, card); } @Override diff --git a/Mage.Client/src/main/java/mage/client/plugins/adapters/MageActionCallback.java b/Mage.Client/src/main/java/mage/client/plugins/adapters/MageActionCallback.java index baddaf08b1..6bbf237cce 100644 --- a/Mage.Client/src/main/java/mage/client/plugins/adapters/MageActionCallback.java +++ b/Mage.Client/src/main/java/mage/client/plugins/adapters/MageActionCallback.java @@ -67,7 +67,6 @@ public class MageActionCallback implements ActionCallback { private Popup tooltipPopup; private JPopupMenu jPopupMenu; private BigCard bigCard; - protected static final DefaultActionCallback defaultCallback = DefaultActionCallback.getInstance(); private CardView tooltipCard; private TransferData popupData; @@ -236,14 +235,14 @@ public class MageActionCallback implements ActionCallback { this.startedDragging = false; if (maxXOffset < MIN_X_OFFSET_REQUIRED) { // we need this for protection from small card movements transferData.component.requestFocusInWindow(); - defaultCallback.mouseClicked(e, transferData.gameId, transferData.card); + DefaultActionCallback.instance.mouseClicked(transferData.gameId, transferData.card); // Closes popup & enlarged view if a card/Permanent is selected hideTooltipPopup(); } e.consume(); } else { transferData.component.requestFocusInWindow(); - defaultCallback.mouseClicked(e, transferData.gameId, transferData.card); + DefaultActionCallback.instance.mouseClicked(transferData.gameId, transferData.card); // Closes popup & enlarged view if a card/Permanent is selected hideTooltipPopup(); e.consume(); diff --git a/Mage.Client/src/main/java/mage/client/util/DefaultActionCallback.java b/Mage.Client/src/main/java/mage/client/util/DefaultActionCallback.java index 7a678e49be..33fc7f803c 100644 --- a/Mage.Client/src/main/java/mage/client/util/DefaultActionCallback.java +++ b/Mage.Client/src/main/java/mage/client/util/DefaultActionCallback.java @@ -7,17 +7,11 @@ import mage.client.SessionHandler; import mage.view.CardView; -public class DefaultActionCallback { +public enum DefaultActionCallback { - private static final DefaultActionCallback INSTANCE = new DefaultActionCallback(); + instance; - private DefaultActionCallback() {} - - public static DefaultActionCallback getInstance() { - return INSTANCE; - } - - public void mouseClicked(MouseEvent e, UUID gameId, CardView card) { + public void mouseClicked(UUID gameId, CardView card) { if (gameId != null) { if (card.isAbility() && card.getAbility() != null) { SessionHandler.sendPlayerUUID(gameId, card.getAbility().getId());