sonar fixed 25022019

This commit is contained in:
Ingmar Goudt 2019-02-26 09:19:46 +01:00
parent 4e3ecc262c
commit a64e31e697
12 changed files with 145 additions and 137 deletions

View file

@ -1,14 +1,5 @@
package mage.client.deckeditor;
import java.awt.*;
import java.awt.event.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.*;
import javax.swing.*;
import javax.swing.filechooser.FileFilter;
import mage.cards.Card;
import mage.cards.Sets;
import mage.cards.decks.Deck;
@ -36,6 +27,16 @@ import mage.view.CardView;
import mage.view.SimpleCardView;
import org.apache.log4j.Logger;
import javax.swing.*;
import javax.swing.filechooser.FileFilter;
import java.awt.*;
import java.awt.event.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.*;
/**
* @author BetaSteward_at_googlemail.com
*/
@ -53,6 +54,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
private javax.swing.Timer countdown;
private UpdateDeckTask updateDeckTask;
private int timeToSubmit = -1;
private final String LAST_DECK_FOLDER = "lastDeckFolder";
/**
* Creates new form DeckEditorPanel
@ -664,6 +666,8 @@ public class DeckEditorPanel extends javax.swing.JPanel {
case 2:
btnImportFromClipboardActionWAppendPerformed(evt);
break;
default:
break;
}
});
@ -848,7 +852,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
private void btnLoadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLoadActionPerformed
//fcSelectDeck.setCurrentDirectory(new File());
String lastFolder = MageFrame.getPreferences().get("lastDeckFolder", "");
String lastFolder = MageFrame.getPreferences().get(LAST_DECK_FOLDER, "");
if (!lastFolder.isEmpty()) {
fcSelectDeck.setCurrentDirectory(new File(lastFolder));
}
@ -887,7 +891,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
// save last deck history
try {
MageFrame.getPreferences().put("lastDeckFolder", file.getCanonicalPath());
MageFrame.getPreferences().put(LAST_DECK_FOLDER, file.getCanonicalPath());
} catch (IOException ex) {
logger.error("Error on save last load deck folder: " + ex.getMessage());
}
@ -902,7 +906,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
}//GEN-LAST:event_btnLoadActionPerformed
private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveActionPerformed
String lastFolder = MageFrame.getPreferences().get("lastDeckFolder", "");
String lastFolder = MageFrame.getPreferences().get(LAST_DECK_FOLDER, "");
if (!lastFolder.isEmpty()) {
fcSelectDeck.setCurrentDirectory(new File(lastFolder));
}
@ -942,7 +946,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
MageFrame.getDesktop().setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}
try {
MageFrame.getPreferences().put("lastDeckFolder", file.getCanonicalPath());
MageFrame.getPreferences().put(LAST_DECK_FOLDER, file.getCanonicalPath());
} catch (IOException ex) {
ex.printStackTrace();
}
@ -1057,6 +1061,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
}
refreshDeck();
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private mage.client.cards.BigCard bigCard;
private javax.swing.JButton btnExit;

View file

@ -52,15 +52,15 @@ public class MageBook extends JComponent {
private static final long serialVersionUID = 1L;
public static final String LAYOUT_3x3 = "small";
public static final String LAYOUT_3X3 = "small";
public static final String LAYOUT_4x4 = "big";
public static final String LAYOUT_4X4 = "big";
public MageBook(BigCard bigCard) {
super();
this.bigCard = bigCard;
this.setsToDisplay = ConstructedFormats.getSetsByFormat(ConstructedFormats.getDefault());
boolean selected3x3 = MageFrame.getPreferences().get(CollectionViewerPanel.LAYOYT_CONFIG_KEY, MageBook.LAYOUT_3x3).equals(MageBook.LAYOUT_3x3);
boolean selected3x3 = MageFrame.getPreferences().get(CollectionViewerPanel.LAYOYT_CONFIG_KEY, MageBook.LAYOUT_3X3).equals(MageBook.LAYOUT_3X3);
this.conf = selected3x3 ? new _3x3Configuration() : new _4x4Configuration();
initComponents();
}
@ -827,10 +827,10 @@ public class MageBook extends JComponent {
public void updateSize(String size) {
switch (size) {
case LAYOUT_3x3:
case LAYOUT_3X3:
this.conf = new _3x3Configuration();
break;
case LAYOUT_4x4:
case LAYOUT_4X4:
this.conf = new _4x4Configuration();
break;
default:

View file

@ -829,7 +829,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
.add(cbAskMoveToGraveOrder))
);
nonLandPermanentsInOnePile.getAccessibleContext().setAccessibleName("nonLandPermanentsInOnePile");
nonLandPermanentsInOnePile.getAccessibleContext().setAccessibleName(KEY_PERMANENTS_IN_ONE_PILE);
main_battlefield.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Battlefield"));

View file

@ -921,6 +921,8 @@ public final class GamePanel extends javax.swing.JPanel {
case END_TURN:
updateButton("Cleanup");
break;
default:
break;
}
}
@ -1027,6 +1029,8 @@ public final class GamePanel extends javax.swing.JPanel {
case LOOKED_AT:
cardInfoWindowDialog.loadCards((SimpleCardsView) cardsView, bigCard, gameId);
break;
default:
break;
}
}
}
@ -2214,6 +2218,8 @@ public final class GamePanel extends javax.swing.JPanel {
case CMD_AUTO_ORDER_RESET_ALL:
SessionHandler.sendPlayerAction(TRIGGER_AUTO_ORDER_RESET_ALL, gameId, null);
break;
default:
break;
}
for (ShowCardsDialog dialog : pickTarget) {
dialog.removeDialog();

View file

@ -1,40 +1,23 @@
package mage.client.game;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import java.util.UUID;
import javax.swing.JButton;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.ScrollPaneConstants;
import javax.swing.SwingUtilities;
import javax.swing.ToolTipManager;
import javax.swing.UIManager;
import javax.swing.border.EmptyBorder;
import mage.client.SessionHandler;
import mage.client.components.MageTextArea;
import mage.client.constants.Constants;
import mage.client.dialog.PreferencesDialog;
import mage.client.game.FeedbackPanel.FeedbackMode;
import static mage.client.game.FeedbackPanel.FeedbackMode.QUESTION;
import mage.client.util.GUISizeHelper;
import mage.constants.TurnPhase;
import static mage.constants.PlayerAction.REQUEST_AUTO_ANSWER_ID_NO;
import static mage.constants.PlayerAction.REQUEST_AUTO_ANSWER_ID_YES;
import static mage.constants.PlayerAction.REQUEST_AUTO_ANSWER_RESET_ALL;
import static mage.constants.PlayerAction.REQUEST_AUTO_ANSWER_TEXT_NO;
import static mage.constants.PlayerAction.REQUEST_AUTO_ANSWER_TEXT_YES;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;
import java.util.UUID;
import static mage.client.game.FeedbackPanel.FeedbackMode.QUESTION;
import static mage.constants.PlayerAction.*;
/**
* Panel with buttons that copy the state of feedback panel.
@ -326,10 +309,18 @@ public class HelperPanel extends JPanel {
this.buttonGrid.setPreferredSize(null);
ArrayList<JButton> buttons = new ArrayList<>();
if (this.btnSpecial.isVisible()) { buttons.add(this.btnSpecial); }
if (this.btnLeft.isVisible()) { buttons.add(this.btnLeft); }
if (this.btnRight.isVisible()) { buttons.add(this.btnRight); }
if (this.btnUndo.isVisible()) { buttons.add(this.btnUndo); }
if (this.btnSpecial.isVisible()) {
buttons.add(this.btnSpecial);
}
if (this.btnLeft.isVisible()) {
buttons.add(this.btnLeft);
}
if (this.btnRight.isVisible()) {
buttons.add(this.btnRight);
}
if (this.btnUndo.isVisible()) {
buttons.add(this.btnUndo);
}
// color panel on player's feedback waiting
if (this.gameNeedFeedback) {
@ -360,10 +351,14 @@ public class HelperPanel extends JPanel {
case COMBAT:
backColor = ACTIVE_FEEDBACK_BACKGROUND_COLOR_BATTLE;
break;
default:
break;
}
}
this.mainPanel.setBackground(backColor);
break;
default:
break;
}
} else {
// inform about other players
@ -500,6 +495,8 @@ public class HelperPanel extends JPanel {
case CMD_AUTO_ANSWER_RESET_ALL:
SessionHandler.sendPlayerAction(REQUEST_AUTO_ANSWER_RESET_ALL, gameId, null);
break;
default:
break;
}
}

View file

@ -168,6 +168,8 @@ public class PlayAreaPanel extends javax.swing.JPanel {
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_END_STEP_BEFORE_MY_NEXT_TURN, gameId, null);
break;
}
default:
break;
}
};
@ -409,6 +411,8 @@ public class PlayAreaPanel extends javax.swing.JPanel {
MageFrame.getInstance().showUserRequestDialog(message);
break;
}
default:
break;
}
};

View file

@ -1,22 +1,5 @@
package mage.client.plugins.adapters;
import java.awt.Component;
import java.awt.Image;
import java.awt.Point;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
import java.awt.image.BufferedImage;
import java.util.*;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.Popup;
import javax.swing.PopupFactory;
import javax.swing.SwingUtilities;
import mage.cards.MageCard;
import mage.cards.action.ActionCallback;
import mage.cards.action.TransferData;
@ -42,6 +25,18 @@ import org.jdesktop.swingx.JXPanel;
import org.mage.card.arcane.CardPanel;
import org.mage.plugins.card.images.ImageCache;
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
import java.awt.image.BufferedImage;
import java.util.*;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
/**
* Class that handles the callbacks from the card panels to mage to display big
* card images from the cards the mouse hovers on. Also handles tooltip text
@ -598,6 +593,8 @@ public class MageActionCallback implements ActionCallback {
}
}
break;
default:
break;
}
if (image == null) {
image = mageCard.getImage();

View file

@ -69,15 +69,11 @@ public enum Plugins implements MagePlugins {
@Override
public void changeGUISize() {
setGUISize();
if (this.cardPlugin != null) {
cardPlugin.changeGUISize();
}
}
private void setGUISize() {
}
@Override
public void updateGamePanel(Map<String, JComponent> ui) {

View file

@ -1,10 +1,6 @@
package mage.client.remote;
import java.awt.event.KeyEvent;
import java.util.List;
import java.util.UUID;
import javax.swing.*;
import mage.cards.decks.Deck;
import mage.client.MageFrame;
import mage.client.SessionHandler;
@ -28,8 +24,12 @@ import mage.view.*;
import mage.view.ChatMessage.MessageType;
import org.apache.log4j.Logger;
import javax.swing.*;
import java.awt.event.KeyEvent;
import java.util.List;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class CallbackClientImpl implements CallbackClient {
@ -372,6 +372,8 @@ public class CallbackClientImpl implements CallbackClient {
case USER_REQUEST_DIALOG:
frame.showUserRequestDialog((UserRequestMessage) callback.getData());
break;
default:
break;
}
messageId = callback.getMessageId();
} catch (Exception ex) {
@ -444,6 +446,8 @@ public class CallbackClientImpl implements CallbackClient {
.append("<br/>Type <font color=green>\\w yourUserName profanity 0 (or 1 or 2)</font> to turn off/on the profanity filter").toString(),
null, MessageType.USER_INFO, ChatMessage.MessageColor.BLUE);
break;
default:
break;
}
}

View file

@ -92,9 +92,10 @@ public class MatchesTableModel extends AbstractTableModel {
}
case 9:
return matches[arg0].getGames();
}
default:
return "";
}
}
public java.util.List<UUID> getListofGames(int row) {
return matches[row].getGames();

View file

@ -185,9 +185,10 @@ public class PlayersChatPanel extends javax.swing.JPanel {
return players[rowIndex].getInfoGames();
case 9:
return players[rowIndex].getInfoPing();
}
default:
return "";
}
}
@Override
public String getColumnName(int columnIndex) {

View file

@ -10,9 +10,6 @@ public class TableInfo {
private List<ColumnInfo> columns = new ArrayList<>();
public TableInfo() {
}
public TableInfo addColumn(Integer index, Integer width, Class colClass, String headerName, String headerHint) {
this.columns.add(new ColumnInfo(index, width, colClass, headerName, headerHint));