diff --git a/Mage.Client/src/main/java/mage/client/dialog/NewTournamentDialog.java b/Mage.Client/src/main/java/mage/client/dialog/NewTournamentDialog.java index bff5fe844d..6a340e082a 100644 --- a/Mage.Client/src/main/java/mage/client/dialog/NewTournamentDialog.java +++ b/Mage.Client/src/main/java/mage/client/dialog/NewTournamentDialog.java @@ -1,5 +1,10 @@ package mage.client.dialog; +import java.awt.*; +import java.io.File; +import java.util.*; +import java.util.stream.Collectors; +import javax.swing.*; import mage.cards.decks.Deck; import mage.cards.decks.DeckFileFilter; import mage.cards.decks.importer.DeckImporter; @@ -26,13 +31,6 @@ import mage.view.TableView; import mage.view.TournamentTypeView; import org.apache.log4j.Logger; -import javax.swing.*; -import java.awt.*; -import java.io.File; -import java.util.List; -import java.util.*; -import java.util.stream.Collectors; - /** * @author BetaSteward_at_googlemail.com, JayDi85 */ @@ -41,13 +39,13 @@ public class NewTournamentDialog extends MageDialog { private static final Logger logger = Logger.getLogger(NewTournamentDialog.class); private TableView table; - private UUID playerId; + // private UUID playerId; private UUID roomId; private String lastSessionId; private RandomPacksSelectorDialog randomPackSelector; private JTextArea txtRandomPacks; - private final List players = new ArrayList<>(); - private final List packPanels = new ArrayList<>(); + private final java.util.List players = new ArrayList<>(); + private final java.util.List packPanels = new ArrayList<>(); private static final int CONSTRUCTION_TIME_MIN = 6; private static final int CONSTRUCTION_TIME_MAX = 30; private boolean isRandom = false; @@ -709,12 +707,12 @@ public class NewTournamentDialog extends MageDialog { private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed this.table = null; - this.playerId = null; + // this.playerId = null; this.hideDialog(); }//GEN-LAST:event_btnCancelActionPerformed private void updateNumSeats() { - int numPlayers = (Integer) this.spnNumPlayers.getValue(); + // int numPlayers = (Integer) this.spnNumPlayers.getValue(); int numSeats = (Integer) this.spnNumSeats.getValue(); if (numSeats > 2) { @@ -966,11 +964,6 @@ public class NewTournamentDialog extends MageDialog { } randomPackSelector.setSelectedPacks(packList); txtRandomPacks.setText(packNames); - - // workaround to apply field's auto-size - this.pack(); - this.revalidate(); - this.repaint(); } private void createRandomPacks() { @@ -993,6 +986,7 @@ public class NewTournamentDialog extends MageDialog { btnSelectRandomPacks.setToolTipText(RandomPacksSelectorDialog.randomDraftDescription); btnSelectRandomPacks.addActionListener(evt -> showRandomPackSelectorDialog()); pnlRandomPacks.add(btnSelectRandomPacks); + this.pnlRandomPacks.setMinimumSize(new Dimension(784, 150)); } txtRandomPacks.setText(txtRandomPacks.getText()); // workaround to apply field's auto-size this.pack(); @@ -1154,7 +1148,7 @@ public class NewTournamentDialog extends MageDialog { int packNumber = 0; for (String pack : packsArray) { packNumber++; - if (this.packPanels.size() >= packNumber - 1) { + if (!packPanels.isEmpty() && this.packPanels.size() >= packNumber - 1) { JPanel panel = packPanels.get(packNumber - 1); JComboBox comboBox = findComboInComponent(panel); @@ -1466,4 +1460,4 @@ public class NewTournamentDialog extends MageDialog { private org.jdesktop.beansbinding.BindingGroup bindingGroup; // End of variables declaration//GEN-END:variables -} \ No newline at end of file +} diff --git a/Mage.Client/src/main/java/mage/client/dialog/RandomPacksSelectorDialog.form b/Mage.Client/src/main/java/mage/client/dialog/RandomPacksSelectorDialog.form index 7644055a2a..7c59eafa7c 100644 --- a/Mage.Client/src/main/java/mage/client/dialog/RandomPacksSelectorDialog.form +++ b/Mage.Client/src/main/java/mage/client/dialog/RandomPacksSelectorDialog.form @@ -36,12 +36,17 @@ - - - - - - + + + + + + + + + + + @@ -49,11 +54,13 @@ - + + + @@ -64,8 +71,8 @@ - - + + @@ -94,17 +101,15 @@ - - - - - - - - - - - + + + + + + + + + diff --git a/Mage.Client/src/main/java/mage/client/dialog/RandomPacksSelectorDialog.java b/Mage.Client/src/main/java/mage/client/dialog/RandomPacksSelectorDialog.java index e8620840c8..18b5083866 100644 --- a/Mage.Client/src/main/java/mage/client/dialog/RandomPacksSelectorDialog.java +++ b/Mage.Client/src/main/java/mage/client/dialog/RandomPacksSelectorDialog.java @@ -58,25 +58,25 @@ public class RandomPacksSelectorDialog extends javax.swing.JDialog { this.setModal(true); } - public void setSelectedPacks(ArrayList packs){ - if (!boxesCreated){ - createCheckboxes(); - } - for (Component pack : pnlPacks.getComponents()) { - JCheckBox thePack = (JCheckBox) pack; - if (packs.contains(thePack.getText())) { - thePack.setSelected(true); - } else{ - thePack.setSelected(false); - } - } - } + public void setSelectedPacks(ArrayList packs) { + if (!boxesCreated) { + createCheckboxes(); + } + for (Component pack : pnlPacks.getComponents()) { + JCheckBox thePack = (JCheckBox) pack; + if (packs.contains(thePack.getText())) { + thePack.setSelected(true); + } else { + thePack.setSelected(false); + } + } + } public ArrayList getSelectedPacks() { ArrayList returnVal = new ArrayList<>(); - for (Component pack: pnlPacks.getComponents()){ + for (Component pack : pnlPacks.getComponents()) { JCheckBox thePack = (JCheckBox) pack; - if (thePack.isSelected()){ + if (thePack.isSelected()) { returnVal.add(thePack.getText()); } } @@ -100,7 +100,6 @@ public class RandomPacksSelectorDialog extends javax.swing.JDialog { } } - /** * 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 @@ -118,7 +117,7 @@ public class RandomPacksSelectorDialog extends javax.swing.JDialog { btnApply = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); - setTitle(title); + setTitle("Random Booster Draft Packs Selector"); setModal(true); setModalExclusionType(java.awt.Dialog.ModalExclusionType.APPLICATION_EXCLUDE); setPreferredSize(new java.awt.Dimension(600, 450)); @@ -129,50 +128,63 @@ public class RandomPacksSelectorDialog extends javax.swing.JDialog { } }); - pnlPacks.setLayout(new java.awt.GridLayout(11, 12)); + pnlPacks.setLayout(new java.awt.GridLayout(12, 13)); pnlSelect.setLayout(new javax.swing.BoxLayout(pnlSelect, javax.swing.BoxLayout.LINE_AXIS)); btnNone.setText("Select none"); btnNone.setActionCommand("none"); - btnNone.addActionListener(evt -> btnNoneActionPerformed(evt)); + btnNone.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnNoneActionPerformed(evt); + } + }); pnlSelect.add(btnNone); btnAll.setText("Select all"); - btnAll.addActionListener(evt -> btnAllActionPerformed(evt)); + btnAll.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnAllActionPerformed(evt); + } + }); pnlSelect.add(btnAll); pnlApply.setLayout(new javax.swing.BoxLayout(pnlApply, javax.swing.BoxLayout.LINE_AXIS)); btnApply.setText("Apply"); - if (isRandomDraft) { - btnApply.setToolTipText("At least 2 packs must be selected"); - } else if (isRichManDraft) { - btnApply.setToolTipText("At least 1 pack must be selected"); - } - btnApply.addActionListener(evt -> btnApplyActionPerformed(evt)); - pnlApply.add(btnApply); + btnApply.setToolTipText("At least two packs must be selected"); + btnApply.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnApplyActionPerformed(evt); + } + }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() - .addComponent(pnlSelect, javax.swing.GroupLayout.PREFERRED_SIZE, 241, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 300, Short.MAX_VALUE) - .addComponent(pnlApply, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGroup(layout.createSequentialGroup() - .addComponent(pnlPacks, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(pnlSelect, javax.swing.GroupLayout.PREFERRED_SIZE, 196, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 402, Short.MAX_VALUE) + .addComponent(pnlApply, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(btnApply)) + .addComponent(pnlPacks, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() - .addComponent(pnlPacks, javax.swing.GroupLayout.PREFERRED_SIZE, 372, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap() + .addComponent(pnlPacks, javax.swing.GroupLayout.PREFERRED_SIZE, 362, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(pnlApply, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(pnlSelect, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(pnlSelect, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(btnApply)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); @@ -220,4 +232,4 @@ public class RandomPacksSelectorDialog extends javax.swing.JDialog { private java.awt.Panel pnlPacks; private javax.swing.JPanel pnlSelect; // End of variables declaration//GEN-END:variables -} +}