mirror of
https://github.com/correl/mage.git
synced 2025-04-06 09:13:45 -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;
|
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.Card;
|
||||||
import mage.cards.MageCard;
|
import mage.cards.MageCard;
|
||||||
import mage.cards.decks.DeckCardInfo;
|
import mage.cards.decks.DeckCardInfo;
|
||||||
|
@ -20,17 +30,6 @@ import mage.view.CardsView;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.mage.card.arcane.CardRenderer;
|
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.
|
* Created by StravantUser on 2016-09-20.
|
||||||
*/
|
*/
|
||||||
|
@ -1408,13 +1407,13 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
||||||
while (regexMatcher.find()) {
|
while (regexMatcher.find()) {
|
||||||
String val = regexMatcher.group(1);
|
String val = regexMatcher.group(1);
|
||||||
int colorless_val = Integer.parseInt(val);
|
int colorless_val = Integer.parseInt(val);
|
||||||
|
|
||||||
int total_c_pip = 0;
|
int total_c_pip = 0;
|
||||||
if (pips.get("#c}") != null) {
|
if (pips.get("#c}") != null) {
|
||||||
total_c_pip = pips.get("#c}");
|
total_c_pip = pips.get("#c}");
|
||||||
}
|
}
|
||||||
pips.put("#c}", colorless_val + total_c_pip);
|
pips.put("#c}", colorless_val + total_c_pip);
|
||||||
|
|
||||||
int cmc_pip_value = 0;
|
int cmc_pip_value = 0;
|
||||||
if (pips_at_cmcs.get(cmc + "##c}") != null) {
|
if (pips_at_cmcs.get(cmc + "##c}") != null) {
|
||||||
cmc_pip_value = pips_at_cmcs.get(cmc + "##c}");
|
cmc_pip_value = pips_at_cmcs.get(cmc + "##c}");
|
||||||
|
@ -2032,6 +2031,9 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getCardWidth() {
|
private int getCardWidth() {
|
||||||
|
if (GUISizeHelper.editorCardDimension == null) {
|
||||||
|
return 200;
|
||||||
|
}
|
||||||
return (int) (GUISizeHelper.editorCardDimension.width * cardSizeMod);
|
return (int) (GUISizeHelper.editorCardDimension.width * cardSizeMod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
|
/*
|
||||||
|
|
||||||
/*
|
|
||||||
* CardSelector.java
|
* CardSelector.java
|
||||||
*
|
*
|
||||||
* Created on Feb 18, 2010, 2:49:03 PM
|
* Created on Feb 18, 2010, 2:49:03 PM
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
|
/*
|
||||||
|
|
||||||
/*
|
|
||||||
* DeckEditorPane.java
|
* DeckEditorPane.java
|
||||||
*
|
*
|
||||||
* Created on Dec 17, 2009, 9:21:42 AM
|
* Created on Dec 17, 2009, 9:21:42 AM
|
||||||
|
@ -98,14 +96,13 @@ public class DeckEditorPane extends MagePane {
|
||||||
this.setLayout(layout);
|
this.setLayout(layout);
|
||||||
layout.setHorizontalGroup(
|
layout.setHorizontalGroup(
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
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.setVerticalGroup(
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
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() {
|
public DeckEditorPanel getPanel() {
|
||||||
|
|
|
@ -192,6 +192,15 @@
|
||||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnAddLandActionPerformed"/>
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnAddLandActionPerformed"/>
|
||||||
</Events>
|
</Events>
|
||||||
</Component>
|
</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">
|
<Component class="javax.swing.JButton" name="btnSubmit">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="text" type="java.lang.String" value="Submit"/>
|
<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"/>
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSubmitTimerActionPerformed"/>
|
||||||
</Events>
|
</Events>
|
||||||
</Component>
|
</Component>
|
||||||
<Component class="JComponent" name="cardInfoPane">
|
<Component class="org.mage.plugins.card.info.CardInfoPaneImpl" name="cardInfoPane">
|
||||||
</Component>
|
</Component>
|
||||||
<Component class="javax.swing.JTextField" name="txtTimeRemaining">
|
<Component class="javax.swing.JTextField" name="txtTimeRemaining">
|
||||||
</Component>
|
</Component>
|
||||||
|
|
|
@ -1,6 +1,14 @@
|
||||||
|
|
||||||
package mage.client.deckeditor;
|
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.Card;
|
||||||
import mage.cards.Sets;
|
import mage.cards.Sets;
|
||||||
import mage.cards.decks.Deck;
|
import mage.cards.decks.Deck;
|
||||||
|
@ -29,18 +37,6 @@ import mage.view.CardView;
|
||||||
import mage.view.SimpleCardView;
|
import mage.view.SimpleCardView;
|
||||||
import org.apache.log4j.Logger;
|
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
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
|
@ -55,7 +51,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
private UUID tableId;
|
private UUID tableId;
|
||||||
private DeckEditorMode mode;
|
private DeckEditorMode mode;
|
||||||
private int timeout;
|
private int timeout;
|
||||||
private Timer countdown;
|
private javax.swing.Timer countdown;
|
||||||
private UpdateDeckTask updateDeckTask;
|
private UpdateDeckTask updateDeckTask;
|
||||||
private int timeToSubmit = -1;
|
private int timeToSubmit = -1;
|
||||||
|
|
||||||
|
@ -75,7 +71,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
jPanel1.setOpaque(false);
|
jPanel1.setOpaque(false);
|
||||||
jSplitPane1.setOpaque(false);
|
jSplitPane1.setOpaque(false);
|
||||||
restoreDividerLocationsAndDeckAreaSettings();
|
restoreDividerLocationsAndDeckAreaSettings();
|
||||||
countdown = new Timer(1000,
|
countdown = new javax.swing.Timer(1000,
|
||||||
e -> {
|
e -> {
|
||||||
if (--timeout > 0) {
|
if (--timeout > 0) {
|
||||||
setTimeout(timeout);
|
setTimeout(timeout);
|
||||||
|
@ -209,7 +205,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
this.btnGenDeck.setVisible(false);
|
this.btnGenDeck.setVisible(false);
|
||||||
this.btnImport.setVisible(false);
|
this.btnImport.setVisible(false);
|
||||||
this.btnLoad.setVisible(false);
|
this.btnLoad.setVisible(false);
|
||||||
this.btnNew.setVisible(false);
|
this.btnNew.setVisible(false);
|
||||||
this.btnSubmit.setVisible(false);
|
this.btnSubmit.setVisible(false);
|
||||||
this.btnSubmitTimer.setVisible(false);
|
this.btnSubmitTimer.setVisible(false);
|
||||||
this.cardSelector.loadCards(this.bigCard);
|
this.cardSelector.loadCards(this.bigCard);
|
||||||
|
@ -456,7 +452,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
CardView cardView = (CardView) event.getSource();
|
CardView cardView = (CardView) event.getSource();
|
||||||
int numberToSet = event.getNumber();
|
int numberToSet = event.getNumber();
|
||||||
int cardsFound = 0;
|
int cardsFound = 0;
|
||||||
List<Card> toDelete = new ArrayList<>();
|
java.util.List<Card> toDelete = new ArrayList<>();
|
||||||
for (Card card : cards) {
|
for (Card card : cards) {
|
||||||
if (card.getName().equals(cardView.getName())
|
if (card.getName().equals(cardView.getName())
|
||||||
&& Objects.equals(card.getCardNumber(), cardView.getCardNumber())
|
&& Objects.equals(card.getCardNumber(), cardView.getCardNumber())
|
||||||
|
@ -689,7 +685,6 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
btnGenDeck.setText("Generate");
|
btnGenDeck.setText("Generate");
|
||||||
btnGenDeck.setName("btnGenDeck");
|
btnGenDeck.setName("btnGenDeck");
|
||||||
btnGenDeck.addActionListener(evt -> btnGenDeckActionPerformed(evt));
|
btnGenDeck.addActionListener(evt -> btnGenDeckActionPerformed(evt));
|
||||||
|
|
||||||
txtTimeRemaining.setEditable(false);
|
txtTimeRemaining.setEditable(false);
|
||||||
txtTimeRemaining.setForeground(java.awt.Color.red);
|
txtTimeRemaining.setForeground(java.awt.Color.red);
|
||||||
txtTimeRemaining.setHorizontalAlignment(javax.swing.JTextField.CENTER);
|
txtTimeRemaining.setHorizontalAlignment(javax.swing.JTextField.CENTER);
|
||||||
|
@ -699,89 +694,89 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
jPanel1.setLayout(jPanel1Layout);
|
jPanel1.setLayout(jPanel1Layout);
|
||||||
jPanel1Layout.setHorizontalGroup(
|
jPanel1Layout.setHorizontalGroup(
|
||||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
/*.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
|
/*.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addComponent(jLayeredPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE))*/
|
.addComponent(jLayeredPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE))*/
|
||||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||||
.addGap(6, 6, 6)
|
.addGap(6, 6, 6)
|
||||||
.addComponent(lblDeckName)
|
.addComponent(lblDeckName)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(txtDeckName, javax.swing.GroupLayout.DEFAULT_SIZE, 189, Short.MAX_VALUE))
|
.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(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)
|
.addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addComponent(btnSave)
|
.addComponent(btnSave)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(btnLoad)
|
.addComponent(btnLoad)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(btnNew)
|
.addComponent(btnNew)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(btnExit))
|
.addComponent(btnExit))
|
||||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addComponent(btnImport)
|
.addComponent(btnImport)
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addComponent(btnGenDeck)
|
.addComponent(btnGenDeck)
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addComponent(btnAddLand)
|
.addComponent(btnAddLand)
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addComponent(btnSubmit)
|
.addComponent(btnSubmit)
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addComponent(btnSubmitTimer))
|
.addComponent(btnSubmitTimer))
|
||||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addComponent(txtTimeRemaining))
|
.addComponent(txtTimeRemaining))
|
||||||
)
|
)
|
||||||
.addContainerGap()));
|
.addContainerGap()));
|
||||||
jPanel1Layout.setVerticalGroup(
|
jPanel1Layout.setVerticalGroup(
|
||||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.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(txtDeckName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addComponent(lblDeckName))
|
.addComponent(lblDeckName))
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(btnSave)
|
.addComponent(btnSave)
|
||||||
.addComponent(btnLoad)
|
.addComponent(btnLoad)
|
||||||
.addComponent(btnNew)
|
.addComponent(btnNew)
|
||||||
.addComponent(btnExit))
|
.addComponent(btnExit))
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(btnImport)
|
.addComponent(btnImport)
|
||||||
.addComponent(btnGenDeck)
|
.addComponent(btnGenDeck)
|
||||||
.addComponent(btnAddLand)
|
.addComponent(btnAddLand)
|
||||||
.addComponent(btnSubmit)
|
.addComponent(btnSubmit)
|
||||||
.addComponent(btnSubmitTimer))
|
.addComponent(btnSubmitTimer))
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(txtTimeRemaining))
|
.addComponent(txtTimeRemaining))
|
||||||
//.addComponent(jLayeredPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
|
//.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)
|
.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)
|
.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)
|
.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)));
|
.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);
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||||
this.setLayout(layout);
|
this.setLayout(layout);
|
||||||
layout.setHorizontalGroup(
|
layout.setHorizontalGroup(
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 261, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 261, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addGap(0, 0, 0)
|
.addGap(0, 0, 0)
|
||||||
.addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 604, Short.MAX_VALUE)));
|
.addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 604, Short.MAX_VALUE)));
|
||||||
layout.setVerticalGroup(
|
layout.setVerticalGroup(
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, 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));
|
.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
|
// show up errors list
|
||||||
if (errorMessages.length() > 0){
|
if (errorMessages.length() > 0) {
|
||||||
String mes = "Founded problems with deck: \n\n" + errorMessages.toString();
|
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);
|
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) {
|
} catch (GameException e1) {
|
||||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), e1.getMessage(), "Error loading deck", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(MageFrame.getDesktop(), e1.getMessage(), "Error loading deck", JOptionPane.ERROR_MESSAGE);
|
||||||
}finally {
|
} finally {
|
||||||
MageFrame.getDesktop().setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
MageFrame.getDesktop().setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -845,7 +840,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
} catch (GameException e1) {
|
} catch (GameException e1) {
|
||||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), e1.getMessage(), "Error loading deck", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(MageFrame.getDesktop(), e1.getMessage(), "Error loading deck", JOptionPane.ERROR_MESSAGE);
|
||||||
}finally {
|
} finally {
|
||||||
MageFrame.getDesktop().setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
MageFrame.getDesktop().setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1063,7 +1058,6 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
refreshDeck();
|
refreshDeck();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
private mage.client.cards.BigCard bigCard;
|
private mage.client.cards.BigCard bigCard;
|
||||||
private javax.swing.JButton btnExit;
|
private javax.swing.JButton btnExit;
|
||||||
|
|
|
@ -9,6 +9,8 @@ import java.util.Map;
|
||||||
import mage.cards.repository.ExpansionInfo;
|
import mage.cards.repository.ExpansionInfo;
|
||||||
import mage.cards.repository.ExpansionRepository;
|
import mage.cards.repository.ExpansionRepository;
|
||||||
import mage.constants.SetType;
|
import mage.constants.SetType;
|
||||||
|
import static mage.constants.SetType.EXPANSION;
|
||||||
|
import static mage.constants.SetType.SUPPLEMENTAL;
|
||||||
import mage.deck.Standard;
|
import mage.deck.Standard;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -64,6 +66,13 @@ public final class ConstructedFormats {
|
||||||
underlyingSetCodesPerFormat.put(CUSTOM, new ArrayList<>());
|
underlyingSetCodesPerFormat.put(CUSTOM, new ArrayList<>());
|
||||||
final Map<String, ExpansionInfo> expansionInfo = new HashMap<>();
|
final Map<String, ExpansionInfo> expansionInfo = new HashMap<>();
|
||||||
formats.clear(); // prevent NPE on sorting if this is not the first try
|
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()) {
|
for (ExpansionInfo set : ExpansionRepository.instance.getAll()) {
|
||||||
expansionInfo.put(set.getName(), set);
|
expansionInfo.put(set.getName(), set);
|
||||||
formats.add(set.getName());
|
formats.add(set.getName());
|
||||||
|
|
|
@ -33,6 +33,8 @@ public enum ExpansionRepository {
|
||||||
|
|
||||||
private Dao<ExpansionInfo, Object> expansionDao;
|
private Dao<ExpansionInfo, Object> expansionDao;
|
||||||
|
|
||||||
|
public boolean instanceInitialized = false;
|
||||||
|
|
||||||
ExpansionRepository() {
|
ExpansionRepository() {
|
||||||
File file = new File("db");
|
File file = new File("db");
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
|
@ -48,9 +50,11 @@ public enum ExpansionRepository {
|
||||||
|
|
||||||
TableUtils.createTableIfNotExists(connectionSource, ExpansionInfo.class);
|
TableUtils.createTableIfNotExists(connectionSource, ExpansionInfo.class);
|
||||||
expansionDao = DaoManager.createDao(connectionSource, ExpansionInfo.class);
|
expansionDao = DaoManager.createDao(connectionSource, ExpansionInfo.class);
|
||||||
|
instanceInitialized = true;
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(ExpansionInfo expansion) {
|
public void add(ExpansionInfo expansion) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue