mirror of
https://github.com/correl/mage.git
synced 2025-04-03 01:08:59 -09:00
DeckEditorPanel - Fixed some existing exceptions.
This commit is contained in:
parent
681cb4b66a
commit
189984d3d6
7 changed files with 127 additions and 114 deletions
Mage.Client/src/main/java/mage/client
cards
deckeditor
util/sets
Mage/src/main/java/mage/cards/repository
|
@ -1,5 +1,15 @@
|
|||
package mage.client.cards;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.swing.*;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.MageCard;
|
||||
import mage.cards.decks.DeckCardInfo;
|
||||
|
@ -20,17 +30,6 @@ import mage.view.CardsView;
|
|||
import org.apache.log4j.Logger;
|
||||
import org.mage.card.arcane.CardRenderer;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Created by StravantUser on 2016-09-20.
|
||||
*/
|
||||
|
@ -1408,13 +1407,13 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
while (regexMatcher.find()) {
|
||||
String val = regexMatcher.group(1);
|
||||
int colorless_val = Integer.parseInt(val);
|
||||
|
||||
|
||||
int total_c_pip = 0;
|
||||
if (pips.get("#c}") != null) {
|
||||
if (pips.get("#c}") != null) {
|
||||
total_c_pip = pips.get("#c}");
|
||||
}
|
||||
pips.put("#c}", colorless_val + total_c_pip);
|
||||
|
||||
|
||||
int cmc_pip_value = 0;
|
||||
if (pips_at_cmcs.get(cmc + "##c}") != null) {
|
||||
cmc_pip_value = pips_at_cmcs.get(cmc + "##c}");
|
||||
|
@ -2032,6 +2031,9 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
}
|
||||
|
||||
private int getCardWidth() {
|
||||
if (GUISizeHelper.editorCardDimension == null) {
|
||||
return 200;
|
||||
}
|
||||
return (int) (GUISizeHelper.editorCardDimension.width * cardSizeMod);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
|
||||
|
||||
/*
|
||||
/*
|
||||
* CardSelector.java
|
||||
*
|
||||
* Created on Feb 18, 2010, 2:49:03 PM
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
|
||||
|
||||
/*
|
||||
/*
|
||||
* DeckEditorPane.java
|
||||
*
|
||||
* Created on Dec 17, 2009, 9:21:42 AM
|
||||
|
@ -98,14 +96,13 @@ public class DeckEditorPane extends MagePane {
|
|||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(container, javax.swing.GroupLayout.DEFAULT_SIZE, 885, Short.MAX_VALUE)
|
||||
.addComponent(container, javax.swing.GroupLayout.DEFAULT_SIZE, 885, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(container, javax.swing.GroupLayout.DEFAULT_SIZE, 626, Short.MAX_VALUE)
|
||||
.addComponent(container, javax.swing.GroupLayout.DEFAULT_SIZE, 626, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public DeckEditorPanel getPanel() {
|
||||
|
|
|
@ -192,6 +192,15 @@
|
|||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnAddLandActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="btnGenDeck">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Generate"/>
|
||||
<Property name="name" type="java.lang.String" value="btnGenDeck" noResource="true"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnGenDeckActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="btnSubmit">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Submit"/>
|
||||
|
@ -210,7 +219,7 @@
|
|||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSubmitTimerActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="JComponent" name="cardInfoPane">
|
||||
<Component class="org.mage.plugins.card.info.CardInfoPaneImpl" name="cardInfoPane">
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="txtTimeRemaining">
|
||||
</Component>
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
|
||||
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;
|
||||
|
@ -29,18 +37,6 @@ import mage.view.CardView;
|
|||
import mage.view.SimpleCardView;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.Timer;
|
||||
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.List;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
|
@ -55,7 +51,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
private UUID tableId;
|
||||
private DeckEditorMode mode;
|
||||
private int timeout;
|
||||
private Timer countdown;
|
||||
private javax.swing.Timer countdown;
|
||||
private UpdateDeckTask updateDeckTask;
|
||||
private int timeToSubmit = -1;
|
||||
|
||||
|
@ -75,7 +71,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
jPanel1.setOpaque(false);
|
||||
jSplitPane1.setOpaque(false);
|
||||
restoreDividerLocationsAndDeckAreaSettings();
|
||||
countdown = new Timer(1000,
|
||||
countdown = new javax.swing.Timer(1000,
|
||||
e -> {
|
||||
if (--timeout > 0) {
|
||||
setTimeout(timeout);
|
||||
|
@ -209,7 +205,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
this.btnGenDeck.setVisible(false);
|
||||
this.btnImport.setVisible(false);
|
||||
this.btnLoad.setVisible(false);
|
||||
this.btnNew.setVisible(false);
|
||||
this.btnNew.setVisible(false);
|
||||
this.btnSubmit.setVisible(false);
|
||||
this.btnSubmitTimer.setVisible(false);
|
||||
this.cardSelector.loadCards(this.bigCard);
|
||||
|
@ -456,7 +452,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
CardView cardView = (CardView) event.getSource();
|
||||
int numberToSet = event.getNumber();
|
||||
int cardsFound = 0;
|
||||
List<Card> toDelete = new ArrayList<>();
|
||||
java.util.List<Card> toDelete = new ArrayList<>();
|
||||
for (Card card : cards) {
|
||||
if (card.getName().equals(cardView.getName())
|
||||
&& Objects.equals(card.getCardNumber(), cardView.getCardNumber())
|
||||
|
@ -689,7 +685,6 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
btnGenDeck.setText("Generate");
|
||||
btnGenDeck.setName("btnGenDeck");
|
||||
btnGenDeck.addActionListener(evt -> btnGenDeckActionPerformed(evt));
|
||||
|
||||
txtTimeRemaining.setEditable(false);
|
||||
txtTimeRemaining.setForeground(java.awt.Color.red);
|
||||
txtTimeRemaining.setHorizontalAlignment(javax.swing.JTextField.CENTER);
|
||||
|
@ -699,89 +694,89 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
jPanel1.setLayout(jPanel1Layout);
|
||||
jPanel1Layout.setHorizontalGroup(
|
||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
/*.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
/*.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jLayeredPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE))*/
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addGap(6, 6, 6)
|
||||
.addComponent(lblDeckName)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(txtDeckName, javax.swing.GroupLayout.DEFAULT_SIZE, 189, Short.MAX_VALUE))
|
||||
.addComponent(cardInfoPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(btnSave)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnLoad)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnNew)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnExit))
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(btnImport)
|
||||
.addContainerGap()
|
||||
.addComponent(btnGenDeck)
|
||||
.addContainerGap()
|
||||
.addComponent(btnAddLand)
|
||||
.addContainerGap()
|
||||
.addComponent(btnSubmit)
|
||||
.addContainerGap()
|
||||
.addComponent(btnSubmitTimer))
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(txtTimeRemaining))
|
||||
)
|
||||
.addContainerGap()));
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addGap(6, 6, 6)
|
||||
.addComponent(lblDeckName)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(txtDeckName, javax.swing.GroupLayout.DEFAULT_SIZE, 189, Short.MAX_VALUE))
|
||||
.addComponent(cardInfoPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(btnSave)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnLoad)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnNew)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnExit))
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(btnImport)
|
||||
.addContainerGap()
|
||||
.addComponent(btnGenDeck)
|
||||
.addContainerGap()
|
||||
.addComponent(btnAddLand)
|
||||
.addContainerGap()
|
||||
.addComponent(btnSubmit)
|
||||
.addContainerGap()
|
||||
.addComponent(btnSubmitTimer))
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(txtTimeRemaining))
|
||||
)
|
||||
.addContainerGap()));
|
||||
jPanel1Layout.setVerticalGroup(
|
||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(txtDeckName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(lblDeckName))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(btnSave)
|
||||
.addComponent(btnLoad)
|
||||
.addComponent(btnNew)
|
||||
.addComponent(btnExit))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(btnImport)
|
||||
.addComponent(btnGenDeck)
|
||||
.addComponent(btnAddLand)
|
||||
.addComponent(btnSubmit)
|
||||
.addComponent(btnSubmitTimer))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(txtTimeRemaining))
|
||||
//.addComponent(jLayeredPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, isShowCardInfo ? 30 : 159, Short.MAX_VALUE)
|
||||
.addComponent(cardInfoPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 104, Short.MAX_VALUE)
|
||||
.addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)));
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(txtDeckName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(lblDeckName))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(btnSave)
|
||||
.addComponent(btnLoad)
|
||||
.addComponent(btnNew)
|
||||
.addComponent(btnExit))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(btnImport)
|
||||
.addComponent(btnGenDeck)
|
||||
.addComponent(btnAddLand)
|
||||
.addComponent(btnSubmit)
|
||||
.addComponent(btnSubmitTimer))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(txtTimeRemaining))
|
||||
//.addComponent(jLayeredPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, isShowCardInfo ? 30 : 159, Short.MAX_VALUE)
|
||||
.addComponent(cardInfoPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 104, Short.MAX_VALUE)
|
||||
.addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)));
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 261, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(0, 0, 0)
|
||||
.addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 604, Short.MAX_VALUE)));
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 261, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(0, 0, 0)
|
||||
.addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 604, Short.MAX_VALUE)));
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jSplitPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 615, Short.MAX_VALUE));
|
||||
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jSplitPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 615, Short.MAX_VALUE));
|
||||
}
|
||||
|
||||
private void processAndShowImportErrors(StringBuilder errorMessages){
|
||||
private void processAndShowImportErrors(StringBuilder errorMessages) {
|
||||
// show up errors list
|
||||
if (errorMessages.length() > 0){
|
||||
if (errorMessages.length() > 0) {
|
||||
String mes = "Founded problems with deck: \n\n" + errorMessages.toString();
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), mes.substring(0, Math.min(1000, mes.length())), "Errors while loading deck", JOptionPane.WARNING_MESSAGE);
|
||||
}
|
||||
|
@ -813,7 +808,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
|
||||
} catch (GameException e1) {
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), e1.getMessage(), "Error loading deck", JOptionPane.ERROR_MESSAGE);
|
||||
}finally {
|
||||
} finally {
|
||||
MageFrame.getDesktop().setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
}
|
||||
|
@ -845,7 +840,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
}
|
||||
} catch (GameException e1) {
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), e1.getMessage(), "Error loading deck", JOptionPane.ERROR_MESSAGE);
|
||||
}finally {
|
||||
} finally {
|
||||
MageFrame.getDesktop().setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
}
|
||||
|
@ -1063,7 +1058,6 @@ 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;
|
||||
|
|
|
@ -9,6 +9,8 @@ import java.util.Map;
|
|||
import mage.cards.repository.ExpansionInfo;
|
||||
import mage.cards.repository.ExpansionRepository;
|
||||
import mage.constants.SetType;
|
||||
import static mage.constants.SetType.EXPANSION;
|
||||
import static mage.constants.SetType.SUPPLEMENTAL;
|
||||
import mage.deck.Standard;
|
||||
|
||||
/**
|
||||
|
@ -64,6 +66,13 @@ public final class ConstructedFormats {
|
|||
underlyingSetCodesPerFormat.put(CUSTOM, new ArrayList<>());
|
||||
final Map<String, ExpansionInfo> expansionInfo = new HashMap<>();
|
||||
formats.clear(); // prevent NPE on sorting if this is not the first try
|
||||
|
||||
// Because this is also called in Netbeans Design view, but the object does not exist in that case,
|
||||
// we have to return here to prevent exception in design view. (Does not hurt at design time)
|
||||
if (!ExpansionRepository.instance.instanceInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (ExpansionInfo set : ExpansionRepository.instance.getAll()) {
|
||||
expansionInfo.put(set.getName(), set);
|
||||
formats.add(set.getName());
|
||||
|
|
|
@ -33,6 +33,8 @@ public enum ExpansionRepository {
|
|||
|
||||
private Dao<ExpansionInfo, Object> expansionDao;
|
||||
|
||||
public boolean instanceInitialized = false;
|
||||
|
||||
ExpansionRepository() {
|
||||
File file = new File("db");
|
||||
if (!file.exists()) {
|
||||
|
@ -48,9 +50,11 @@ public enum ExpansionRepository {
|
|||
|
||||
TableUtils.createTableIfNotExists(connectionSource, ExpansionInfo.class);
|
||||
expansionDao = DaoManager.createDao(connectionSource, ExpansionInfo.class);
|
||||
instanceInitialized = true;
|
||||
} catch (SQLException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void add(ExpansionInfo expansion) {
|
||||
|
|
Loading…
Add table
Reference in a new issue