+
\ No newline at end of file
diff --git a/res/images/deckeditor/filter_artifact_n.png b/res/images/deckeditor/filter_artifact_n.png
deleted file mode 100644
index 2523d044c0a..00000000000
Binary files a/res/images/deckeditor/filter_artifact_n.png and /dev/null differ
diff --git a/res/images/deckeditor/filter_artifact_y.png b/res/images/deckeditor/filter_artifact_y.png
deleted file mode 100644
index 0b551e67d93..00000000000
Binary files a/res/images/deckeditor/filter_artifact_y.png and /dev/null differ
diff --git a/res/images/deckeditor/filter_black_n.png b/res/images/deckeditor/filter_black_n.png
deleted file mode 100644
index 60b23423217..00000000000
Binary files a/res/images/deckeditor/filter_black_n.png and /dev/null differ
diff --git a/res/images/deckeditor/filter_black_y.png b/res/images/deckeditor/filter_black_y.png
deleted file mode 100644
index 6e4246a2beb..00000000000
Binary files a/res/images/deckeditor/filter_black_y.png and /dev/null differ
diff --git a/res/images/deckeditor/filter_blue_n.png b/res/images/deckeditor/filter_blue_n.png
deleted file mode 100644
index c2183dc0c50..00000000000
Binary files a/res/images/deckeditor/filter_blue_n.png and /dev/null differ
diff --git a/res/images/deckeditor/filter_blue_y.png b/res/images/deckeditor/filter_blue_y.png
deleted file mode 100644
index ff5b7e7d35b..00000000000
Binary files a/res/images/deckeditor/filter_blue_y.png and /dev/null differ
diff --git a/res/images/deckeditor/filter_colorless_n.png b/res/images/deckeditor/filter_colorless_n.png
deleted file mode 100644
index cf231becc4c..00000000000
Binary files a/res/images/deckeditor/filter_colorless_n.png and /dev/null differ
diff --git a/res/images/deckeditor/filter_colorless_y.png b/res/images/deckeditor/filter_colorless_y.png
deleted file mode 100644
index bce292d3086..00000000000
Binary files a/res/images/deckeditor/filter_colorless_y.png and /dev/null differ
diff --git a/res/images/deckeditor/filter_creature_n.png b/res/images/deckeditor/filter_creature_n.png
deleted file mode 100644
index d577f01ef08..00000000000
Binary files a/res/images/deckeditor/filter_creature_n.png and /dev/null differ
diff --git a/res/images/deckeditor/filter_creature_y.png b/res/images/deckeditor/filter_creature_y.png
deleted file mode 100644
index aee035d6445..00000000000
Binary files a/res/images/deckeditor/filter_creature_y.png and /dev/null differ
diff --git a/res/images/deckeditor/filter_enchant_n.png b/res/images/deckeditor/filter_enchant_n.png
deleted file mode 100644
index b23e3122a68..00000000000
Binary files a/res/images/deckeditor/filter_enchant_n.png and /dev/null differ
diff --git a/res/images/deckeditor/filter_enchant_y.png b/res/images/deckeditor/filter_enchant_y.png
deleted file mode 100644
index 054bfbdbb47..00000000000
Binary files a/res/images/deckeditor/filter_enchant_y.png and /dev/null differ
diff --git a/res/images/deckeditor/filter_green_n.png b/res/images/deckeditor/filter_green_n.png
deleted file mode 100644
index 95d9527074f..00000000000
Binary files a/res/images/deckeditor/filter_green_n.png and /dev/null differ
diff --git a/res/images/deckeditor/filter_green_y.png b/res/images/deckeditor/filter_green_y.png
deleted file mode 100644
index eb4a5112544..00000000000
Binary files a/res/images/deckeditor/filter_green_y.png and /dev/null differ
diff --git a/res/images/deckeditor/filter_instant_n.png b/res/images/deckeditor/filter_instant_n.png
deleted file mode 100644
index 7c25dd437a5..00000000000
Binary files a/res/images/deckeditor/filter_instant_n.png and /dev/null differ
diff --git a/res/images/deckeditor/filter_instant_y.png b/res/images/deckeditor/filter_instant_y.png
deleted file mode 100644
index 83cd0d9a9d3..00000000000
Binary files a/res/images/deckeditor/filter_instant_y.png and /dev/null differ
diff --git a/res/images/deckeditor/filter_land_n.png b/res/images/deckeditor/filter_land_n.png
deleted file mode 100644
index f54f4f2864d..00000000000
Binary files a/res/images/deckeditor/filter_land_n.png and /dev/null differ
diff --git a/res/images/deckeditor/filter_land_y.png b/res/images/deckeditor/filter_land_y.png
deleted file mode 100644
index 8cc194c5327..00000000000
Binary files a/res/images/deckeditor/filter_land_y.png and /dev/null differ
diff --git a/res/images/deckeditor/filter_planeswalker_n.png b/res/images/deckeditor/filter_planeswalker_n.png
deleted file mode 100644
index f7b4c8bd85b..00000000000
Binary files a/res/images/deckeditor/filter_planeswalker_n.png and /dev/null differ
diff --git a/res/images/deckeditor/filter_planeswalker_y.png b/res/images/deckeditor/filter_planeswalker_y.png
deleted file mode 100644
index 81d204b7756..00000000000
Binary files a/res/images/deckeditor/filter_planeswalker_y.png and /dev/null differ
diff --git a/res/images/deckeditor/filter_red_n.png b/res/images/deckeditor/filter_red_n.png
deleted file mode 100644
index 4c059bc8392..00000000000
Binary files a/res/images/deckeditor/filter_red_n.png and /dev/null differ
diff --git a/res/images/deckeditor/filter_red_y.png b/res/images/deckeditor/filter_red_y.png
deleted file mode 100644
index 6c3f7b1c34f..00000000000
Binary files a/res/images/deckeditor/filter_red_y.png and /dev/null differ
diff --git a/res/images/deckeditor/filter_sorcery_n.png b/res/images/deckeditor/filter_sorcery_n.png
deleted file mode 100644
index cbfb904f55a..00000000000
Binary files a/res/images/deckeditor/filter_sorcery_n.png and /dev/null differ
diff --git a/res/images/deckeditor/filter_sorcery_y.png b/res/images/deckeditor/filter_sorcery_y.png
deleted file mode 100644
index e7b1cf10f76..00000000000
Binary files a/res/images/deckeditor/filter_sorcery_y.png and /dev/null differ
diff --git a/res/images/deckeditor/filter_white_n.png b/res/images/deckeditor/filter_white_n.png
deleted file mode 100644
index 77a37ec4337..00000000000
Binary files a/res/images/deckeditor/filter_white_n.png and /dev/null differ
diff --git a/res/images/deckeditor/filter_white_y.png b/res/images/deckeditor/filter_white_y.png
deleted file mode 100644
index d6ed26b89b5..00000000000
Binary files a/res/images/deckeditor/filter_white_y.png and /dev/null differ
diff --git a/res/skins/default/grid_icons.png b/res/skins/default/grid_icons.png
index 7b3285fb277..482bfd5685e 100644
Binary files a/res/skins/default/grid_icons.png and b/res/skins/default/grid_icons.png differ
diff --git a/res/skins/default/sprite_icons.png b/res/skins/default/sprite_icons.png
index 4c891fd1086..0a2e4704aa4 100644
Binary files a/res/skins/default/sprite_icons.png and b/res/skins/default/sprite_icons.png differ
diff --git a/res/sound/tap.mp3 b/res/sound/tap.mp3
deleted file mode 100644
index 806612a6aa3..00000000000
Binary files a/res/sound/tap.mp3 and /dev/null differ
diff --git a/src/main/java/forge/card/CardRules.java b/src/main/java/forge/card/CardRules.java
index 671522b1a4a..fbeea4fa9e2 100644
--- a/src/main/java/forge/card/CardRules.java
+++ b/src/main/java/forge/card/CardRules.java
@@ -27,18 +27,17 @@ import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import forge.util.closures.Predicate;
-import forge.util.closures.PredicateString;
import forge.util.closures.Predicate.ComparableOp;
import forge.util.closures.Predicate.PredicatesOp;
+import forge.util.closures.PredicateString;
/**
- *
- * CardOracle class.
- *
+ * A collection of methods containing full
+ * meta and gameplay properties of a card.
*
* @author Forge
- * @version $Id: CardOracle.java 9708 2011-08-09 19:34:12Z jendave $
+ * @version $Id: CardRules.java 9708 2011-08-09 19:34:12Z jendave $
*/
public final class CardRules {
@@ -389,8 +388,31 @@ public final class CardRules {
return new LeafNumber(LeafNumber.CardField.CMC, op, what);
}
- // Power
- // Toughness
+ /**
+ *
+ * @param op
+ * the op
+ * @param what
+ * the what
+ * @return the predicate
+ */
+ public static Predicate power(final ComparableOp op, final int what) {
+ return new LeafNumber(LeafNumber.CardField.POWER, op, what);
+ }
+
+ /**
+ *
+ * @param op
+ * the op
+ * @param what
+ * the what
+ * @return the predicate
+ */
+ public static Predicate toughness(final ComparableOp op, final int what) {
+ return new LeafNumber(LeafNumber.CardField.TOUGHNESS, op, what);
+ }
+
+ // P/T
/**
* Rules.
*
@@ -462,7 +484,7 @@ public final class CardRules {
* @return the predicate
*/
public static Predicate wasPrintedInSets(final List setCodes) {
- return new PredicateExitsInSets(setCodes);
+ return new PredicateExistsInSets(setCodes);
}
/**
@@ -568,7 +590,7 @@ public final class CardRules {
* @return the predicate
*/
public static Predicate hasCntColors(final byte cntColors) {
- return new LeafColor(LeafColor.ColorOperator.Equals, cntColors);
+ return new LeafColor(LeafColor.ColorOperator.CountColors, cntColors);
}
/**
@@ -634,18 +656,18 @@ public final class CardRules {
@Override
public boolean isTrue(final CardRules subject) {
switch (this.op) {
- case CountColors:
- return subject.getColor().countColors() == this.color;
- case CountColorsGreaterOrEqual:
- return subject.getColor().countColors() >= this.color;
- case Equals:
- return subject.getColor().isEqual(this.color);
- case HasAllOf:
- return subject.getColor().hasAllColors(this.color);
- case HasAnyOf:
- return subject.getColor().hasAnyColor(this.color);
- default:
- return false;
+ case CountColors:
+ return subject.getColor().countColors() == this.color;
+ case CountColorsGreaterOrEqual:
+ return subject.getColor().countColors() >= this.color;
+ case Equals:
+ return subject.getColor().isEqual(this.color);
+ case HasAllOf:
+ return subject.getColor().hasAllColors(this.color);
+ case HasAnyOf:
+ return subject.getColor().hasAnyColor(this.color);
+ default:
+ return false;
}
}
}
@@ -747,10 +769,10 @@ public final class CardRules {
}
}
- private static class PredicateExitsInSets extends Predicate {
+ private static class PredicateExistsInSets extends Predicate {
private final List sets;
- public PredicateExitsInSets(final List wantSets) {
+ public PredicateExistsInSets(final List wantSets) {
this.sets = wantSets; // maybe should make a copy here?
}
@@ -808,6 +830,9 @@ public final class CardRules {
public static final Predicate IS_NON_CREATURE_SPELL = Predicate.compose(Presets.IS_CREATURE,
PredicatesOp.NOR, Presets.IS_LAND);
+ /**
+ *
+ */
@SuppressWarnings("unchecked")
public static final Predicate IS_NONCREATURE_SPELL_FOR_GENERATOR = Predicate.or(Arrays.asList(
Presets.IS_SORCERY, Presets.IS_INSTANT, Presets.IS_PLANESWALKER, Presets.IS_ENCHANTMENT,
diff --git a/src/main/java/forge/control/FControl.java b/src/main/java/forge/control/FControl.java
index 7a7bad40025..33f37631c53 100644
--- a/src/main/java/forge/control/FControl.java
+++ b/src/main/java/forge/control/FControl.java
@@ -31,8 +31,12 @@ import javax.swing.WindowConstants;
import forge.AllZone;
import forge.Singletons;
import forge.control.KeyboardShortcuts.Shortcut;
+import forge.gui.deckeditor.CDeckEditorUI;
+import forge.gui.deckeditor.VDeckEditorUI;
+import forge.gui.framework.SOverflowUtil;
+import forge.gui.framework.SResizingUtil;
import forge.gui.home.VHomeUI;
-import forge.gui.home.quest.SubmenuQuestUtil;
+import forge.gui.home.quest.SSubmenuQuestUtil;
import forge.gui.match.VMatchUI;
import forge.gui.match.controllers.CDock;
import forge.gui.toolbox.CardFaceSymbols;
@@ -55,16 +59,24 @@ public enum FControl {
private JLayeredPane display;
private int state = -1;
- private WindowListener waDefault, waConcede, waLeaveBazaar;
+ private WindowListener waDefault, waConcede, waLeaveBazaar, waLeaveEditor;
/** */
public static final int HOME_SCREEN = 0;
/** */
public static final int MATCH_SCREEN = 1;
/** */
- public static final int DEFAULT_EDITOR = 2;
+ public static final int DECK_EDITOR_CONSTRUCTED = 2;
/** */
public static final int QUEST_BAZAAR = 3;
+ /** */
+ public static final int DECK_EDITOR_LIMITED = 4;
+ /** */
+ public static final int DECK_EDITOR_QUEST = 5;
+ /** */
+ public static final int QUEST_CARD_SHOP = 6;
+ /** */
+ public static final int DRAFTING_PROCESS = 7;
/**
*
@@ -75,11 +87,21 @@ public enum FControl {
* instantiated separately by each state's top level view class.
*/
private FControl() {
+ this.waDefault = new WindowAdapter() {
+ @Override
+ public void windowClosing(final WindowEvent e) {
+ Singletons.getView().getFrame().setDefaultCloseOperation(
+ WindowConstants.EXIT_ON_CLOSE);
+ }
+ };
+
// "Close" button override during match
this.waConcede = new WindowAdapter() {
@Override
public void windowClosing(final WindowEvent e) {
- Singletons.getView().getFrame().setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
+ Singletons.getView().getFrame().setDefaultCloseOperation(
+ WindowConstants.DO_NOTHING_ON_CLOSE);
+
CDock.SINGLETON_INSTANCE.concede();
}
};
@@ -88,19 +110,28 @@ public enum FControl {
this.waLeaveBazaar = new WindowAdapter() {
@Override
public void windowClosing(final WindowEvent e) {
- Singletons.getView().getFrame().setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
- changeState(0);
- SubmenuQuestUtil.updateStatsAndPet();
+ Singletons.getView().getFrame().setDefaultCloseOperation(
+ WindowConstants.DO_NOTHING_ON_CLOSE);
+
+ changeState(FControl.HOME_SCREEN);
+ SSubmenuQuestUtil.updateStatsAndPet();
}
};
- // Default action on window close
- this.waDefault = new WindowAdapter() {
- @Override
- public void windowClosing(final WindowEvent e) {
- Singletons.getView().getFrame().setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
- }
+ this.waLeaveEditor = new WindowAdapter() {
+ @Override
+ public void windowClosing(final WindowEvent ev) {
+ Singletons.getView().getFrame().setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
+
+ if (CDeckEditorUI.SINGLETON_INSTANCE.getCurrentEditorController().exit()) {
+ changeState(FControl.HOME_SCREEN);
+ }
+ }
};
+
+ FView.SINGLETON_INSTANCE.getLpnDocument().addMouseListener(SOverflowUtil.getHideOverflowListener());
+ FView.SINGLETON_INSTANCE.getLpnDocument().addComponentListener(SResizingUtil.getWindowResizeListener());
+ Singletons.getView().getFrame().setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
}
/** After view and model have been initialized, control can start. */
@@ -117,8 +148,6 @@ public enum FControl {
this.shortcuts = KeyboardShortcuts.attachKeyboardShortcuts();
this.display = FView.SINGLETON_INSTANCE.getLpnDocument();
- //Singletons.getView().initialize();
-
// Handles resizing in null layouts of layers in JLayeredPane.
Singletons.getView().getFrame().addComponentListener(new ComponentAdapter() {
@Override
@@ -141,17 +170,19 @@ public enum FControl {
clearChildren(JLayeredPane.DEFAULT_LAYER);
this.state = i0;
- /// TODO should these be here?
+ Singletons.getView().getFrame().removeWindowListener(waDefault);
Singletons.getView().getFrame().removeWindowListener(waConcede);
Singletons.getView().getFrame().removeWindowListener(waLeaveBazaar);
- Singletons.getView().getFrame().addWindowListener(waDefault);
+ Singletons.getView().getFrame().removeWindowListener(waLeaveEditor);
// Fire up new state
switch (i0) {
case HOME_SCREEN:
+ Singletons.getView().getFrame().addWindowListener(waDefault);
VHomeUI.SINGLETON_INSTANCE.populate();
FView.SINGLETON_INSTANCE.getPnlInsets().setVisible(false);
- //sizeChildren();
+ VHomeUI.SINGLETON_INSTANCE.updateLayout();
+ sizeChildren();
break;
case MATCH_SCREEN:
@@ -160,8 +191,14 @@ public enum FControl {
Singletons.getView().getFrame().addWindowListener(waConcede);
break;
- case DEFAULT_EDITOR:
- display.add(Singletons.getView().getViewEditor(), JLayeredPane.DEFAULT_LAYER);
+ case DECK_EDITOR_CONSTRUCTED:
+ case DECK_EDITOR_LIMITED:
+ case DECK_EDITOR_QUEST:
+ case QUEST_CARD_SHOP:
+ case DRAFTING_PROCESS:
+ VDeckEditorUI.SINGLETON_INSTANCE.populate();
+ FView.SINGLETON_INSTANCE.getPnlInsets().setVisible(true);
+ Singletons.getView().getFrame().addWindowListener(waLeaveEditor);
break;
case QUEST_BAZAAR:
diff --git a/src/main/java/forge/deck/Deck.java b/src/main/java/forge/deck/Deck.java
index ee4cf8a67aa..5413a3823e9 100644
--- a/src/main/java/forge/deck/Deck.java
+++ b/src/main/java/forge/deck/Deck.java
@@ -33,7 +33,7 @@ import org.apache.commons.lang3.StringUtils;
import forge.deck.io.DeckFileHeader;
import forge.deck.io.DeckSerializer;
-import forge.gui.deckeditor.elements.TableSorter;
+import forge.gui.deckeditor.tables.TableSorter;
import forge.item.CardPrinted;
import forge.item.ItemPoolView;
import forge.util.FileSection;
diff --git a/src/main/java/forge/game/limited/BoosterDraft.java b/src/main/java/forge/game/limited/BoosterDraft.java
index 6daa597e514..ab08aae76c0 100644
--- a/src/main/java/forge/game/limited/BoosterDraft.java
+++ b/src/main/java/forge/game/limited/BoosterDraft.java
@@ -290,7 +290,12 @@ public final class BoosterDraft implements IBoosterDraft {
}
} // computerChoose()
- private int getCurrentBoosterIndex() {
+ /**
+ *
+ * TODO: Write javadoc for this method.
+ * @return int
+ */
+ public int getCurrentBoosterIndex() {
return this.currentBoosterPick % BoosterDraft.N_PLAYERS;
}
diff --git a/src/main/java/forge/game/player/Player.java b/src/main/java/forge/game/player/Player.java
index 99f4e7961bd..439b9dfcb66 100644
--- a/src/main/java/forge/game/player/Player.java
+++ b/src/main/java/forge/game/player/Player.java
@@ -49,7 +49,7 @@ import forge.game.zone.PlayerZone;
import forge.game.zone.PlayerZoneComesIntoPlay;
import forge.game.zone.ZoneType;
import forge.gui.GuiUtils;
-import forge.gui.match.VMatchUI;
+import forge.gui.match.views.VDev;
import forge.util.MyRandom;
/**
@@ -1838,7 +1838,7 @@ public abstract class Player extends GameEntity {
* @return a boolean.
*/
public final boolean canPlayLand() {
- if (VMatchUI.SINGLETON_INSTANCE.getViewDevMode().getLblUnlimitedLands().getEnabled() && this.isHuman()
+ if (VDev.SINGLETON_INSTANCE.getLblUnlimitedLands().getEnabled() && this.isHuman()
&& Constant.Runtime.DEV_MODE[0]) {
return PhaseHandler.canCastSorcery(this);
}
diff --git a/src/main/java/forge/gui/deckeditor/CDeckEditorUI.java b/src/main/java/forge/gui/deckeditor/CDeckEditorUI.java
new file mode 100644
index 00000000000..5fe830b5f6a
--- /dev/null
+++ b/src/main/java/forge/gui/deckeditor/CDeckEditorUI.java
@@ -0,0 +1,113 @@
+/*
+ * Forge: Play Magic: the Gathering.
+ * Copyright (C) 2011 Forge Team
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package forge.gui.deckeditor;
+
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+
+import forge.Card;
+import forge.gui.CardContainer;
+import forge.gui.deckeditor.controllers.ACEditorBase;
+import forge.gui.match.controllers.CDetail;
+import forge.gui.match.controllers.CPicture;
+
+/**
+ * Constructs instance of deck editor UI controller, used as a single point of
+ * top-level control for child UIs. Tasks targeting the view of individual
+ * components are found in a separate controller for that component and
+ * should not be included here.
+ *
+ *
(C at beginning of class name denotes a control class.)
+ */
+public enum CDeckEditorUI implements CardContainer {
+ /** */
+ SINGLETON_INSTANCE;
+
+ private ACEditorBase, ?> childController;
+
+ private CDeckEditorUI() {
+ }
+
+ //========== Overridden from CardContainer
+
+ @Override
+ public void setCard(final Card c) {
+ CDetail.SINGLETON_INSTANCE.showCard(c);
+ CPicture.SINGLETON_INSTANCE.showCard(c);
+ }
+
+ @Override
+ public Card getCard() {
+ return CDetail.SINGLETON_INSTANCE.getCurrentCard();
+ }
+
+ //========= Accessor/mutator methods
+ /**
+ * @return ACEditorBase, ?>
+ */
+ public ACEditorBase, ?> getCurrentEditorController() {
+ return childController;
+ }
+
+ /**
+ * Set controller for current configuration of editor.
+ * @param editor0 {@link forge.gui.deckeditor.controllers.ACEditorBase}, ?>
+ */
+ public void setCurrentEditorController(ACEditorBase, ?> editor0) {
+ this.childController = editor0;
+ updateController();
+ }
+
+ //========== Other methods
+ /**
+ * Updates listeners for current controller.
+ */
+ private void updateController() {
+ childController.getTableCatalog().getTable().addKeyListener(new KeyAdapter() {
+ @Override
+ public void keyPressed(final KeyEvent e) {
+ if (e.getKeyChar() == ' ') { childController.addCard(); }
+ }
+ });
+
+ childController.getTableDeck().getTable().addKeyListener(new KeyAdapter() {
+ @Override
+ public void keyPressed(final KeyEvent e) {
+ if (e.getKeyChar() == ' ') { childController.removeCard(); }
+ }
+ });
+
+ childController.getTableCatalog().getTable().addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseClicked(final MouseEvent e) {
+ if (e.getClickCount() == 2) { childController.addCard(); }
+ }
+ });
+
+ childController.getTableDeck().getTable().addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseClicked(final MouseEvent e) {
+ if (e.getClickCount() == 2) { childController.removeCard(); }
+ }
+ });
+
+ childController.init();
+ }
+}
diff --git a/src/main/java/forge/gui/deckeditor/DeckEditorBase.java b/src/main/java/forge/gui/deckeditor/DeckEditorBase.java
deleted file mode 100644
index e2e586975e3..00000000000
--- a/src/main/java/forge/gui/deckeditor/DeckEditorBase.java
+++ /dev/null
@@ -1,358 +0,0 @@
-/*
- * Forge: Play Magic: the Gathering.
- * Copyright (C) 2011 Forge Team
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package forge.gui.deckeditor;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
-import javax.swing.JDialog;
-import javax.swing.JFrame;
-import javax.swing.JOptionPane;
-import javax.swing.event.DocumentEvent;
-import javax.swing.event.DocumentListener;
-
-import forge.Command;
-import forge.deck.DeckBase;
-import forge.gui.deckeditor.elements.CardPanelBase;
-import forge.gui.deckeditor.elements.DeckAnalysis;
-import forge.gui.deckeditor.elements.FilterCheckBoxes;
-import forge.gui.deckeditor.elements.TableView;
-import forge.item.CardPrinted;
-import forge.item.InventoryItem;
-import forge.item.ItemPool;
-import forge.item.ItemPoolView;
-import forge.util.closures.Predicate;
-
-/**
- * The Class DeckEditorBase.
- *
- * @param the generic type
- * @param the generic type
- */
-public abstract class DeckEditorBase extends JDialog {
- private static final long serialVersionUID = -401223933343539977L;
-
- /** The filter boxes. */
- private FilterCheckBoxes filterBoxes;
- // set this to false when resetting filter from code (like
- // "clearFiltersPressed"), reset when done.
- /** The is filters change firing update. */
- private boolean isFiltersChangeFiringUpdate = true;
-
- /** The card view. */
- private CardPanelBase cardView;
-
- // CardPools and Table data for top and bottom lists
- /** The top. */
- private TableView topTableWithCards;
-
- /** The bottom. */
- private TableView bottomTableWithCards;
- /**
- * Instantiates a new deck editor base.
- *
- * @param parent the parent frame for this deck editor
- */
- public DeckEditorBase(JFrame parent) {
- super(parent, ModalityType.APPLICATION_MODAL);
- }
-
- // top shows available card pool
- // if constructed, top shows all cards
- // if sealed, top shows N booster packs
- // if draft, top shows cards that were chosen
- /**
- * Gets the top table model.
- *
- * @return the top table model
- */
- public final TableView getTopTableModel() {
- return this.getTopTableWithCards();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see forge.gui.deckeditor.DeckDisplay#getTop()
- */
- /**
- * Gets the top.
- *
- * @return the top
- */
- public final ItemPoolView getTop() {
- return this.getTopTableWithCards().getCards();
- }
-
- // bottom shows player's choice - be it deck or draft
- /*
- * (non-Javadoc)
- *
- * @see forge.gui.deckeditor.DeckDisplay#getBottom()
- */
- /**
- * Gets the bottom.
- *
- * @return the bottom
- */
- public final ItemPoolView getBottom() {
- return this.getBottomTableWithCards().getCards();
- }
-
- /**
- * Gets the controller.
- *
- * @return the controller
- */
- public abstract DeckController getController();
-
- // THIS IS HERE FOR OVERLOADING!!!1
- // or may be return abstract getFilter from derived class + this filter ...
- // virtual protected member, but later
- /**
- * Builds the filter.
- *
- * @return the predicate
- */
- protected abstract Predicate buildFilter();
-
- /**
- * Show.
- *
- * @param exitCommand the exit command
- */
- public abstract void show(final Command exitCommand);
-
- /**
- * Analysis button_action performed.
- *
- * @param e
- * the e
- */
- final void analysisButtonActionPerformed(final ActionEvent e) {
- final ItemPoolView deck = ItemPool.createFrom(this.getBottomTableWithCards().getCards(),
- CardPrinted.class);
- if (deck.isEmpty()) {
- JOptionPane.showMessageDialog(null, "Cards in deck not found.", "Analysis Deck",
- JOptionPane.INFORMATION_MESSAGE);
- } else {
- final DeckEditorBase g = DeckEditorBase.this;
- final DeckAnalysis dAnalysis = new DeckAnalysis(g, deck);
- dAnalysis.setVisible(true);
- g.setEnabled(false);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see forge.gui.deckeditor.DeckDisplay#setItems(forge.item.ItemPoolView,
- * forge.item.ItemPoolView, forge.game.GameType)
- */
- /**
- * Update view.
- */
- public abstract void updateView();
-
- /**
- * Update display.
- */
- public final void updateDisplay() {
- this.getTopTableWithCards().setFilter(this.buildFilter());
- }
-
- /** The item listener updates display. */
- private ItemListener itemListenerUpdatesDisplay = new ItemListener() {
- @Override
- public void itemStateChanged(final ItemEvent e) {
- if (DeckEditorBase.this.isFiltersChangeFiringUpdate()) {
- DeckEditorBase.this.updateDisplay();
- }
- }
- };
-
- /**
- * This class is used for a feature: when you start typing card name, the
- * list gets auto-filtered.
- */
- protected class OnChangeTextUpdateDisplay implements DocumentListener {
- private void onChange() {
- if (DeckEditorBase.this.isFiltersChangeFiringUpdate()) {
- DeckEditorBase.this.updateDisplay();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * javax.swing.event.DocumentListener#insertUpdate(javax.swing.event
- * .DocumentEvent)
- */
- @Override
- public final void insertUpdate(final DocumentEvent e) {
- this.onChange();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * javax.swing.event.DocumentListener#removeUpdate(javax.swing.event
- * .DocumentEvent)
- */
- @Override
- public final void removeUpdate(final DocumentEvent e) {
- this.onChange();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * javax.swing.event.DocumentListener#changedUpdate(javax.swing.event
- * .DocumentEvent)
- */
- @Override
- public void changedUpdate(final DocumentEvent e) {
- } // Happend only on ENTER pressed
- }
-
- /**
- * Gets the item listener updates display.
- *
- * @return the itemListenerUpdatesDisplay
- */
- public ItemListener getItemListenerUpdatesDisplay() {
- return this.itemListenerUpdatesDisplay;
- }
-
- /**
- * Sets the item listener updates display.
- *
- * @param itemListenerUpdatesDisplay
- * the itemListenerUpdatesDisplay to set
- */
- public void setItemListenerUpdatesDisplay(final ItemListener itemListenerUpdatesDisplay) {
- this.itemListenerUpdatesDisplay = itemListenerUpdatesDisplay; // TODO:
- // Add 0
- // to
- // parameter's
- // name.
- }
-
- /**
- * Checks if is filters change firing update.
- *
- * @return the isFiltersChangeFiringUpdate
- */
- public boolean isFiltersChangeFiringUpdate() {
- return this.isFiltersChangeFiringUpdate;
- }
-
- /**
- * Sets the filters change firing update.
- *
- * @param isFiltersChangeFiringUpdate
- * the isFiltersChangeFiringUpdate to set
- */
- public void setFiltersChangeFiringUpdate(final boolean isFiltersChangeFiringUpdate) {
- this.isFiltersChangeFiringUpdate = isFiltersChangeFiringUpdate; // TODO:
- // Add 0
- // to
- // parameter's
- // name.
- }
-
- /**
- * Gets the card view.
- *
- * @return the cardView
- */
- public CardPanelBase getCardView() {
- return this.cardView;
- }
-
- /**
- * Sets the card view.
- *
- * @param cardView0
- * the cardView to set
- */
- protected void setCardView(final CardPanelBase cardView0) {
- this.cardView = cardView0;
- }
-
- /**
- * Gets the filter boxes.
- *
- * @return the filterBoxes
- */
- public FilterCheckBoxes getFilterBoxes() {
- return this.filterBoxes;
- }
-
- /**
- * Sets the filter boxes.
- *
- * @param filterBoxes0
- * the filterBoxes to set
- */
- public void setFilterBoxes(final FilterCheckBoxes filterBoxes0) {
- this.filterBoxes = filterBoxes0;
- }
-
- /**
- * Gets the bottom table with cards.
- *
- * @return the bottomTableWithCards
- */
- public TableView getBottomTableWithCards() {
- return this.bottomTableWithCards;
- }
-
- /**
- * Sets the bottom table with cards.
- *
- * @param bottomTableWithCards0
- * the bottomTableWithCards to set
- */
- public void setBottomTableWithCards(final TableView bottomTableWithCards0) {
- this.bottomTableWithCards = bottomTableWithCards0;
- }
-
- /**
- * Gets the top table with cards.
- *
- * @return the topTableWithCards
- */
- public TableView getTopTableWithCards() {
- return this.topTableWithCards;
- }
-
- /**
- * Sets the top table with cards.
- *
- * @param topTableWithCards0
- * the topTableWithCards to set
- */
- public void setTopTableWithCards(final TableView topTableWithCards0) {
- this.topTableWithCards = topTableWithCards0;
- }
-
-}
diff --git a/src/main/java/forge/gui/deckeditor/DeckEditorConstructed.java b/src/main/java/forge/gui/deckeditor/DeckEditorConstructed.java
deleted file mode 100644
index fa4058b03ce..00000000000
--- a/src/main/java/forge/gui/deckeditor/DeckEditorConstructed.java
+++ /dev/null
@@ -1,414 +0,0 @@
-/*
- * Forge: Play Magic: the Gathering.
- * Copyright (C) 2011 Forge Team
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package forge.gui.deckeditor;
-
-import java.awt.Container;
-import java.awt.Font;
-import java.awt.event.ActionEvent;
-import java.awt.event.KeyAdapter;
-import java.awt.event.KeyEvent;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.util.ArrayList;
-import java.util.List;
-import javax.swing.JButton;
-import javax.swing.JCheckBox;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-
-import forge.Command;
-import forge.Singletons;
-import forge.deck.Deck;
-import forge.error.ErrorViewer;
-import forge.gui.deckeditor.elements.CardPanelHeavy;
-import forge.gui.deckeditor.elements.FilterCheckBoxes;
-import forge.gui.deckeditor.elements.FilterNameTypeSetPanel;
-import forge.gui.deckeditor.elements.ManaCostRenderer;
-import forge.gui.deckeditor.elements.TableColumnInfo;
-import forge.gui.deckeditor.elements.TableView;
-import forge.item.CardDb;
-import forge.item.CardPrinted;
-import forge.item.InventoryItem;
-import forge.item.ItemPool;
-import forge.util.closures.Lambda0;
-import forge.util.closures.Predicate;
-import net.miginfocom.swing.MigLayout;
-
-/**
- *
- * Gui_DeckEditor class.
- *
- *
- * @author Forge
- * @version $Id$
- */
-public final class DeckEditorConstructed extends DeckEditorBase {
- /** Constant serialVersionUID=130339644136746796L. */
- private static final long serialVersionUID = 130339644136746796L;
-
- private final JButton removeButton = new JButton();
- private final JButton addButton = new JButton();
- private final JButton importButton = new JButton();
-
- private final JButton analysisButton = new JButton();
- private final JButton clearFilterButton = new JButton();
-
- private final JLabel jLabelAnalysisGap = new JLabel("");
- private FilterNameTypeSetPanel filterNameTypeSet;
-
- private final DeckController controller;
-
- /**
- * Show.
- *
- * @param exitCommand
- * the exit command
- */
- @Override
- public void show(final Command exitCommand) {
- final Command exit = new Command() {
- private static final long serialVersionUID = 5210924838133689758L;
-
- @Override
- public void execute() {
- DeckEditorConstructed.this.dispose();
- if (exitCommand != null) {
- exitCommand.execute();
- }
- }
- };
-
- final MenuCommon menu = new MenuCommon(this.getController(), exit);
- this.setJMenuBar(menu);
-
- // do not change this!!!!
- this.addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosing(final WindowEvent ev) {
- menu.close();
- }
- });
-
- this.setup();
-
- this.controller.newModel();
-
- this.getTopTableWithCards().sort(1, true);
- this.getBottomTableWithCards().sort(1, true);
-
- } // show(Command)
-
- private void setup() {
- final List> columns = new ArrayList>();
- columns.add(new TableColumnInfo("Qty", 30, PresetColumns.FN_QTY_COMPARE,
- PresetColumns.FN_QTY_GET));
- columns.add(new TableColumnInfo("Name", 175, PresetColumns.FN_NAME_COMPARE,
- PresetColumns.FN_NAME_GET));
- columns.add(new TableColumnInfo("Cost", 75, PresetColumns.FN_COST_COMPARE,
- PresetColumns.FN_COST_GET));
- columns.add(new TableColumnInfo("Color", 60, PresetColumns.FN_COLOR_COMPARE,
- PresetColumns.FN_COLOR_GET));
- columns.add(new TableColumnInfo("Type", 100, PresetColumns.FN_TYPE_COMPARE,
- PresetColumns.FN_TYPE_GET));
- columns.add(new TableColumnInfo("Stats", 60, PresetColumns.FN_STATS_COMPARE,
- PresetColumns.FN_STATS_GET));
- columns.add(new TableColumnInfo("R", 25, PresetColumns.FN_RARITY_COMPARE,
- PresetColumns.FN_RARITY_GET));
- columns.add(new TableColumnInfo("Set", 40, PresetColumns.FN_SET_COMPARE,
- PresetColumns.FN_SET_GET));
- columns.add(new TableColumnInfo("AI", 30, PresetColumns.FN_AI_STATUS_COMPARE,
- PresetColumns.FN_AI_STATUS_GET));
- columns.get(2).setCellRenderer(new ManaCostRenderer());
-
- this.getTopTableWithCards().setup(columns, this.getCardView());
- this.getBottomTableWithCards().setup(columns, this.getCardView());
-
- this.filterNameTypeSet.setListeners(new OnChangeTextUpdateDisplay(), this.getItemListenerUpdatesDisplay());
-
- this.setSize(1024, 740);
- }
-
- /**
- * Instantiates a new deck editor common.
- *
- * @param parent the parent frame for this deck editor instance
- */
- public DeckEditorConstructed(JFrame parent) {
- super(parent);
- try {
- this.setFilterBoxes(new FilterCheckBoxes(true));
- this.setTopTableWithCards(new TableView("Available Cards", true, true, CardPrinted.class));
- this.setBottomTableWithCards(new TableView("Deck", true, CardPrinted.class));
- this.setCardView(new CardPanelHeavy());
- this.filterNameTypeSet = new FilterNameTypeSetPanel();
-
- this.jbInit();
- } catch (final Exception ex) {
- ErrorViewer.showError(ex);
- }
-
- final Lambda0 newCreator = new Lambda0() {
- @Override
- public Deck apply() {
- return new Deck();
- }
- };
- this.controller = new DeckController(Singletons.getModel().getDecks().getConstructed(), this, newCreator);
- }
-
- private void jbInit() {
-
- final Font fButtons = new java.awt.Font("Dialog", 0, 13);
- this.removeButton.setFont(fButtons);
- this.addButton.setFont(fButtons);
- this.importButton.setFont(fButtons);
- this.clearFilterButton.setFont(fButtons);
- this.analysisButton.setFont(fButtons);
-
- this.addButton.setText("Add to Deck");
- this.removeButton.setText("Remove from Deck");
- this.importButton.setText("Import a Deck");
- this.clearFilterButton.setText("Clear Filter");
- this.analysisButton.setText("Deck Analysis");
-
- this.removeButton.addActionListener(new java.awt.event.ActionListener() {
- @Override
- public void actionPerformed(final ActionEvent e) {
- DeckEditorConstructed.this.removeButtonClicked(e);
- }
- });
- this.addButton.addActionListener(new java.awt.event.ActionListener() {
- @Override
- public void actionPerformed(final ActionEvent e) {
- DeckEditorConstructed.this.addButtonActionPerformed(e);
- }
- });
- this.importButton.addActionListener(new java.awt.event.ActionListener() {
- @Override
- public void actionPerformed(final ActionEvent e) {
- DeckEditorConstructed.this.importButtonActionPerformed(e);
- }
- });
- this.clearFilterButton.addActionListener(new java.awt.event.ActionListener() {
- @Override
- public void actionPerformed(final ActionEvent e) {
- DeckEditorConstructed.this.clearFilterButtonActionPerformed(e);
- }
- });
- this.analysisButton.addActionListener(new java.awt.event.ActionListener() {
- @Override
- public void actionPerformed(final ActionEvent e) {
- DeckEditorConstructed.this.analysisButtonActionPerformed(e);
- }
- });
-
- // Type filtering
- final Font f = new Font("Tahoma", Font.PLAIN, 10);
- for (final JCheckBox box : this.getFilterBoxes().getAllTypes()) {
- box.setFont(f);
- box.setOpaque(false);
- }
-
- // Color filtering
- for (final JCheckBox box : this.getFilterBoxes().getAllColors()) {
- box.setOpaque(false);
- }
-
- // Do not lower statsLabel any lower, we want this to be visible at 1024
- // x 768 screen size
- this.setTitle("Deck Editor");
-
- final Container content = this.getContentPane();
- final MigLayout layout = new MigLayout("fill");
- content.setLayout(layout);
-
- boolean isFirst = true;
- for (final JCheckBox box : this.getFilterBoxes().getAllTypes()) {
- String growParameter = "grow";
- if (isFirst) {
- growParameter = "cell 0 0, egx checkbox, grow, split 14";
- isFirst = false;
- }
- content.add(box, growParameter);
- box.addItemListener(this.getItemListenerUpdatesDisplay());
- }
-
- for (final JCheckBox box : this.getFilterBoxes().getAllColors()) {
- content.add(box, "grow");
- box.addItemListener(this.getItemListenerUpdatesDisplay());
- }
-
- content.add(this.clearFilterButton, "wmin 100, hmin 25, wmax 140, hmax 25, grow");
-
- content.add(this.filterNameTypeSet, "cell 0 1, grow");
- content.add(this.getTopTableWithCards().getTableDecorated(), "cell 0 2 1 2, push, grow");
- content.add(this.getTopTableWithCards().getLabel(), "cell 0 4");
-
- content.add(this.addButton, "w 100, h 49, sg button, cell 0 5, split 5");
- content.add(this.removeButton, "w 100, h 49, sg button");
- content.add(this.importButton, "w 100, h 49, sg button, gapleft 40px");
- // Label is used to push the analysis button to the right to separate
- // analysis button from add/remove card ones
- content.add(this.jLabelAnalysisGap, "wmin 75, growx");
- content.add(this.analysisButton, "w 100, h 49, wrap");
-
- content.add(this.getBottomTableWithCards().getTableDecorated(), "cell 0 6, grow");
- content.add(this.getBottomTableWithCards().getLabel(), "cell 0 7");
-
- content.add(this.getCardView(), "cell 1 0 1 8, flowy, grow");
-
- this.getTopTableWithCards().getTable().addMouseListener(new MouseAdapter() {
- @Override
- public void mouseClicked(final MouseEvent e) {
- if (e.getClickCount() == 2) {
- DeckEditorConstructed.this.addCardToDeck();
- }
- }
- });
- this.getTopTableWithCards().getTable().addKeyListener(new KeyAdapter() {
- @Override
- public void keyPressed(final KeyEvent e) {
- if (e.getKeyChar() == ' ') {
- DeckEditorConstructed.this.addCardToDeck();
- }
- }
- });
-
- // javax.swing.JRootPane rootPane = this.getRootPane();
- // rootPane.setDefaultButton(filterButton);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see forge.gui.deckeditor.DeckEditorBase#buildFilter()
- */
- @Override
- protected Predicate buildFilter() {
- final Predicate cardFilter = Predicate.and(this.getFilterBoxes().buildFilter(),
- this.filterNameTypeSet.buildFilter());
- return Predicate.instanceOf(cardFilter, CardPrinted.class);
- }
-
- /**
- * Clear filter button_action performed.
- *
- * @param e
- * the e
- */
- void clearFilterButtonActionPerformed(final ActionEvent e) {
- // disable automatic update triggered by listeners
- this.setFiltersChangeFiringUpdate(false);
-
- for (final JCheckBox box : this.getFilterBoxes().getAllTypes()) {
- if (!box.isSelected()) {
- box.doClick();
- }
- }
- for (final JCheckBox box : this.getFilterBoxes().getAllColors()) {
- if (!box.isSelected()) {
- box.doClick();
- }
- }
-
- this.filterNameTypeSet.clearFilters();
-
- this.setFiltersChangeFiringUpdate(true);
-
- this.getTopTableWithCards().setFilter(null);
- }
-
- /**
- * Adds the button_action performed.
- *
- * @param e
- * the e
- */
- void addButtonActionPerformed(final ActionEvent e) {
- this.addCardToDeck();
- }
-
- /**
- * Adds the card to deck.
- */
- void addCardToDeck() {
- final InventoryItem item = this.getTopTableWithCards().getSelectedCard();
- if ((item == null) || !(item instanceof CardPrinted)) {
- return;
- }
-
- final CardPrinted card = (CardPrinted) item;
- this.getBottomTableWithCards().addCard(card);
- this.controller.notifyModelChanged();
- }
-
- /**
- * Removes the button clicked.
- *
- * @param e
- * the e
- */
- void removeButtonClicked(final ActionEvent e) {
- final InventoryItem item = this.getBottomTableWithCards().getSelectedCard();
- if ((item == null) || !(item instanceof CardPrinted)) {
- return;
- }
-
- final CardPrinted card = (CardPrinted) item;
- this.getBottomTableWithCards().removeCard(card);
- this.controller.notifyModelChanged();
- }
-
- /**
- * Import button_action performed.
- *
- * @param e
- * the e
- */
- void importButtonActionPerformed(final ActionEvent e) {
- final DeckEditorConstructed g = this;
- final DeckImport dImport = new DeckImport(g);
- dImport.setModalityType(ModalityType.APPLICATION_MODAL);
- dImport.setVisible(true);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see forge.gui.deckeditor.DeckEditorBase#updateView()
- */
- @Override
- public void updateView() {
- // if constructed, can add the all cards above
- this.getTopTableWithCards().setDeck(ItemPool.createFrom(CardDb.instance().getAllCards(), CardPrinted.class));
- this.getBottomTableWithCards().setDeck(this.controller.getModel().getMain());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see forge.gui.deckeditor.DeckEditorBase#getController()
- */
- @Override
- public DeckController getController() {
- return this.controller;
- }
-
-}
diff --git a/src/main/java/forge/gui/deckeditor/DeckEditorLimited.java b/src/main/java/forge/gui/deckeditor/DeckEditorLimited.java
deleted file mode 100644
index c96551c0b56..00000000000
--- a/src/main/java/forge/gui/deckeditor/DeckEditorLimited.java
+++ /dev/null
@@ -1,415 +0,0 @@
-/*
- * Forge: Play Magic: the Gathering.
- * Copyright (C) 2011 Forge Team
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package forge.gui.deckeditor;
-
-import java.awt.Container;
-import java.awt.Font;
-import java.awt.event.ActionEvent;
-import java.awt.event.KeyAdapter;
-import java.awt.event.KeyEvent;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.util.ArrayList;
-import java.util.List;
-import javax.swing.JButton;
-import javax.swing.JCheckBox;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-
-import forge.Command;
-import forge.deck.Deck;
-import forge.deck.DeckGroup;
-import forge.error.ErrorViewer;
-import forge.gui.deckeditor.elements.CardPanelHeavy;
-import forge.gui.deckeditor.elements.FilterCheckBoxes;
-import forge.gui.deckeditor.elements.FilterNameTypeSetPanel;
-import forge.gui.deckeditor.elements.ManaCostRenderer;
-import forge.gui.deckeditor.elements.TableColumnInfo;
-import forge.gui.deckeditor.elements.TableView;
-import forge.item.CardPrinted;
-import forge.item.InventoryItem;
-import forge.util.IStorage;
-import forge.util.closures.Lambda0;
-import forge.util.closures.Predicate;
-import net.miginfocom.swing.MigLayout;
-
-/**
- *
- * Gui_DeckEditor class.
- *
- *
- * @author Forge
- * @version $Id: DeckEditorCommon.java 12850 2011-12-26 14:55:09Z slapshot5 $
- */
-public final class DeckEditorLimited extends DeckEditorBase {
- /** Constant serialVersionUID=130339644136746796L. */
- private static final long serialVersionUID = 130339644136746796L;
-
- private final JButton removeButton = new JButton();
- private final JButton addButton = new JButton();
-
- private final JButton analysisButton = new JButton();
- private final JButton clearFilterButton = new JButton();
-
- private final JLabel jLabelAnalysisGap = new JLabel("");
- private FilterNameTypeSetPanel filterNameTypeSet;
-
- private final DeckController controller;
-
- /**
- * Show.
- *
- * @param exitCommand
- * the exit command
- */
- @Override
- public void show(final Command exitCommand) {
- final Command exit = new Command() {
- private static final long serialVersionUID = 5210924838133689758L;
-
- @Override
- public void execute() {
- DeckEditorLimited.this.dispose();
- if (exitCommand != null) {
- exitCommand.execute();
- }
- }
- };
-
- final MenuLimited menu = new MenuLimited(this.getController(), exit);
-
- this.setJMenuBar(menu);
-
- // do not change this!!!!
- this.addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosing(final WindowEvent ev) {
- menu.close();
- }
- });
-
- this.setup();
-
- this.getTopTableWithCards().sort(1, true);
- this.getBottomTableWithCards().sort(1, true);
-
- } // show(Command)
-
- private void setup() {
- final List> columns = new ArrayList>();
- columns.add(new TableColumnInfo("Qty", 30, PresetColumns.FN_QTY_COMPARE,
- PresetColumns.FN_QTY_GET));
- columns.add(new TableColumnInfo("Name", 175, PresetColumns.FN_NAME_COMPARE,
- PresetColumns.FN_NAME_GET));
- columns.add(new TableColumnInfo("Cost", 75, PresetColumns.FN_COST_COMPARE,
- PresetColumns.FN_COST_GET));
- columns.add(new TableColumnInfo("Color", 60, PresetColumns.FN_COLOR_COMPARE,
- PresetColumns.FN_COLOR_GET));
- columns.add(new TableColumnInfo("Type", 100, PresetColumns.FN_TYPE_COMPARE,
- PresetColumns.FN_TYPE_GET));
- columns.add(new TableColumnInfo("Stats", 60, PresetColumns.FN_STATS_COMPARE,
- PresetColumns.FN_STATS_GET));
- columns.add(new TableColumnInfo("R", 25, PresetColumns.FN_RARITY_COMPARE,
- PresetColumns.FN_RARITY_GET));
- columns.add(new TableColumnInfo("Set", 40, PresetColumns.FN_SET_COMPARE,
- PresetColumns.FN_SET_GET));
- columns.add(new TableColumnInfo("AI", 30, PresetColumns.FN_AI_STATUS_COMPARE,
- PresetColumns.FN_AI_STATUS_GET));
- columns.get(2).setCellRenderer(new ManaCostRenderer());
-
- this.getTopTableWithCards().setup(columns, this.getCardView());
- this.getBottomTableWithCards().setup(columns, this.getCardView());
-
- this.filterNameTypeSet.setListeners(new OnChangeTextUpdateDisplay(), this.getItemListenerUpdatesDisplay());
-
- this.setSize(1024, 740);
- }
-
- /**
- * Instantiates a new deck editor common.
- *
- * @param mainFrame the parent frame for this deck editor instance
- * @param deckMap the deck map
- */
- public DeckEditorLimited(JFrame mainFrame, final IStorage deckMap) {
- super(mainFrame);
- try {
- this.setFilterBoxes(new FilterCheckBoxes(true));
- this.setTopTableWithCards(new TableView("Avaliable Cards", true, true, CardPrinted.class));
- this.setBottomTableWithCards(new TableView("Deck", true, CardPrinted.class));
- this.setCardView(new CardPanelHeavy());
- this.filterNameTypeSet = new FilterNameTypeSetPanel();
-
- this.jbInit();
- } catch (final Exception ex) {
- ErrorViewer.showError(ex);
- }
-
- final Lambda0 newCreator = new Lambda0() {
- @Override
- public DeckGroup apply() {
- return new DeckGroup("");
- }
- };
- this.controller = new DeckController(deckMap, this, newCreator);
- }
-
- private void jbInit() {
-
- final Font fButtons = new java.awt.Font("Dialog", 0, 13);
- this.removeButton.setFont(fButtons);
- this.addButton.setFont(fButtons);
- this.clearFilterButton.setFont(fButtons);
- this.analysisButton.setFont(fButtons);
-
- this.addButton.setText("Add to Deck");
- this.removeButton.setText("Remove from Deck");
- this.clearFilterButton.setText("Clear Filter");
- this.analysisButton.setText("Deck Analysis");
-
- this.removeButton.addActionListener(new java.awt.event.ActionListener() {
- @Override
- public void actionPerformed(final ActionEvent e) {
- DeckEditorLimited.this.removeButtonClicked(e);
- }
- });
- this.addButton.addActionListener(new java.awt.event.ActionListener() {
- @Override
- public void actionPerformed(final ActionEvent e) {
- DeckEditorLimited.this.addButtonActionPerformed(e);
- }
- });
- this.clearFilterButton.addActionListener(new java.awt.event.ActionListener() {
- @Override
- public void actionPerformed(final ActionEvent e) {
- DeckEditorLimited.this.clearFilterButtonActionPerformed(e);
- }
- });
- this.analysisButton.addActionListener(new java.awt.event.ActionListener() {
- @Override
- public void actionPerformed(final ActionEvent e) {
- DeckEditorLimited.this.analysisButtonActionPerformed(e);
- }
- });
-
- // Type filtering
- final Font f = new Font("Tahoma", Font.PLAIN, 10);
- for (final JCheckBox box : this.getFilterBoxes().getAllTypes()) {
- box.setFont(f);
- box.setOpaque(false);
- }
-
- // Color filtering
- for (final JCheckBox box : this.getFilterBoxes().getAllColors()) {
- box.setOpaque(false);
- }
-
- // Do not lower statsLabel any lower, we want this to be visible at 1024
- // x 768 screen size
- this.setTitle("Deck Editor");
-
- final Container content = this.getContentPane();
- final MigLayout layout = new MigLayout("fill");
- content.setLayout(layout);
-
- boolean isFirst = true;
- for (final JCheckBox box : this.getFilterBoxes().getAllTypes()) {
- String growParameter = "grow";
- if (isFirst) {
- growParameter = "cell 0 0, egx checkbox, grow, split 14";
- isFirst = false;
- }
- content.add(box, growParameter);
- box.addItemListener(this.getItemListenerUpdatesDisplay());
- }
-
- for (final JCheckBox box : this.getFilterBoxes().getAllColors()) {
- content.add(box, "grow");
- box.addItemListener(this.getItemListenerUpdatesDisplay());
- }
-
- content.add(this.clearFilterButton, "wmin 100, hmin 25, wmax 140, hmax 25, grow");
-
- content.add(this.filterNameTypeSet, "cell 0 1, grow");
- content.add(this.getTopTableWithCards().getTableDecorated(), "cell 0 2 1 2, push, grow");
- content.add(this.getTopTableWithCards().getLabel(), "cell 0 4");
-
- content.add(this.addButton, "w 100, h 49, sg button, cell 0 5, split 5");
- content.add(this.removeButton, "w 100, h 49, sg button");
- // Label is used to push the analysis button to the right to separate
- // analysis button from add/remove card ones
- content.add(this.jLabelAnalysisGap, "wmin 75, growx");
- content.add(this.analysisButton, "w 100, h 49, wrap");
-
- content.add(this.getBottomTableWithCards().getTableDecorated(), "cell 0 6, grow");
- content.add(this.getBottomTableWithCards().getLabel(), "cell 0 7");
-
- content.add(this.getCardView(), "cell 1 0 1 8, flowy, grow");
-
- this.getTopTableWithCards().getTable().addMouseListener(new MouseAdapter() {
- @Override
- public void mouseClicked(final MouseEvent e) {
- if (e.getClickCount() == 2) {
- DeckEditorLimited.this.addCardToDeck();
- }
- }
- });
- this.getTopTableWithCards().getTable().addKeyListener(new KeyAdapter() {
- @Override
- public void keyPressed(final KeyEvent e) {
- if (e.getKeyChar() == ' ') {
- DeckEditorLimited.this.addCardToDeck();
- }
- }
- });
- }
-
- /*
- * (non-Javadoc)
- *
- * @see forge.gui.deckeditor.DeckEditorBase#buildFilter()
- */
- @Override
- protected Predicate buildFilter() {
- final Predicate cardFilter = Predicate.and(this.getFilterBoxes().buildFilter(),
- this.filterNameTypeSet.buildFilter());
- return Predicate.instanceOf(cardFilter, CardPrinted.class);
- }
-
- /**
- * Clear filter button_action performed.
- *
- * @param e
- * the e
- */
- void clearFilterButtonActionPerformed(final ActionEvent e) {
- // disable automatic update triggered by listeners
- this.setFiltersChangeFiringUpdate(false);
-
- for (final JCheckBox box : this.getFilterBoxes().getAllTypes()) {
- if (!box.isSelected()) {
- box.doClick();
- }
- }
- for (final JCheckBox box : this.getFilterBoxes().getAllColors()) {
- if (!box.isSelected()) {
- box.doClick();
- }
- }
-
- this.filterNameTypeSet.clearFilters();
-
- this.setFiltersChangeFiringUpdate(true);
-
- this.getTopTableWithCards().setFilter(null);
- }
-
- /**
- * Adds the button_action performed.
- *
- * @param e
- * the e
- */
- void addButtonActionPerformed(final ActionEvent e) {
- this.addCardToDeck();
- }
-
- /**
- * Adds the card to deck.
- */
- void addCardToDeck() {
- final InventoryItem item = this.getTopTableWithCards().getSelectedCard();
- if ((item == null) || !(item instanceof CardPrinted)) {
- return;
- }
-
- // update view
- final CardPrinted card = (CardPrinted) item;
- this.getBottomTableWithCards().addCard(card);
- this.getTopTableWithCards().removeCard(card);
-
- /*
- * update model Deck model =
- * getSelectedDeck(getController().getModel());
- * model.getMain().add(card); model.getSideboard().remove(card);
- */
-
- this.getController().notifyModelChanged();
- }
-
- /**
- * TODO: Write javadoc for this method.
- *
- * @param model
- * @return
- */
- private Deck getSelectedDeck(final DeckGroup model) {
- return model.getHumanDeck();
- }
-
- /**
- * Removes the button clicked.
- *
- * @param e
- * the e
- */
- void removeButtonClicked(final ActionEvent e) {
- final InventoryItem item = this.getBottomTableWithCards().getSelectedCard();
- if ((item == null) || !(item instanceof CardPrinted)) {
- return;
- }
-
- // update view
- final CardPrinted card = (CardPrinted) item;
- this.getBottomTableWithCards().removeCard(card);
- this.getTopTableWithCards().addCard(card);
-
- /*
- * update model Deck model =
- * getSelectedDeck(getController().getModel());
- * model.getMain().remove(card); model.getSideboard().add(card);
- */
-
- this.getController().notifyModelChanged();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see forge.gui.deckeditor.DeckEditorBase#getController()
- */
- @Override
- public DeckController getController() {
- return this.controller;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see forge.gui.deckeditor.DeckEditorBase#updateView()
- */
- @Override
- public void updateView() {
- Deck toEdit = this.getSelectedDeck(this.controller.getModel());
- this.getTopTableWithCards().setDeck(toEdit.getSideboard());
- this.getBottomTableWithCards().setDeck(toEdit.getMain());
- }
-
-}
diff --git a/src/main/java/forge/gui/deckeditor/DeckEditorQuest.java b/src/main/java/forge/gui/deckeditor/DeckEditorQuest.java
deleted file mode 100644
index dac5ef7edd6..00000000000
--- a/src/main/java/forge/gui/deckeditor/DeckEditorQuest.java
+++ /dev/null
@@ -1,414 +0,0 @@
-/*
- * Forge: Play Magic: the Gathering.
- * Copyright (C) 2011 Forge Team
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package forge.gui.deckeditor;
-
-// import java.awt.Font;
-import java.awt.Container;
-import java.awt.Font;
-import java.awt.event.ActionEvent;
-import java.awt.event.KeyAdapter;
-import java.awt.event.KeyEvent;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.util.ArrayList;
-import java.util.List;
-import javax.swing.JButton;
-import javax.swing.JCheckBox;
-import javax.swing.JLabel;
-import javax.swing.JFrame;
-import javax.swing.WindowConstants;
-
-import forge.Command;
-import forge.Constant;
-import forge.deck.Deck;
-import forge.error.ErrorViewer;
-import forge.gui.deckeditor.elements.CardPanelHeavy;
-import forge.gui.deckeditor.elements.FilterCheckBoxes;
-import forge.gui.deckeditor.elements.FilterNameTypeSetPanel;
-import forge.gui.deckeditor.elements.ManaCostRenderer;
-import forge.gui.deckeditor.elements.TableColumnInfo;
-import forge.gui.deckeditor.elements.TableView;
-import forge.item.CardPrinted;
-import forge.item.InventoryItem;
-import forge.item.ItemPool;
-import forge.quest.QuestController;
-import forge.util.closures.Lambda0;
-import forge.util.closures.Predicate;
-import net.miginfocom.swing.MigLayout;
-
-//import forge.quest.data.QuestBoosterPack;
-
-/**
- *
- * Gui_Quest_DeckEditor class.
- *
- *
- * @author Forge
- * @version $Id$
- */
-public final class DeckEditorQuest extends DeckEditorBase {
- /** Constant serialVersionUID=152061168634545L. */
- private static final long serialVersionUID = 152061168634545L;
-
- /** The custom menu. */
- private final JButton clearFilterButton = new JButton();
- private final JButton addButton = new JButton();
- private final JButton removeButton = new JButton();
- private final JLabel jLabelAnalysisGap = new JLabel("");
- private final JButton analysisButton = new JButton();
-
- private FilterNameTypeSetPanel filterNameTypeSet;
-
- private final QuestController questData;
- private final DeckController controller;
-
- /**
- * Show.
- *
- * @param exitCommand
- * the exit command
- */
- @Override
- public void show(final Command exitCommand) {
- final Command exit = new Command() {
- private static final long serialVersionUID = -7428793574300520612L;
-
- @Override
- public void execute() {
- DeckEditorQuest.this.dispose();
- exitCommand.execute();
- }
- };
-
- this.setup();
-
- final MenuQuest menu = new MenuQuest(this.getController(), exit);
- this.setJMenuBar(menu);
-
- // do not change this!!!!
- this.addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosing(final WindowEvent ev) {
- menu.close();
- }
- });
-
- Deck deck = Constant.Runtime.HUMAN_DECK[0] == null ? null : this.questData.getMyDecks().get(
- Constant.Runtime.HUMAN_DECK[0].getName());
-
- if (deck == null) {
- deck = new Deck();
- }
-
- // tell Gui_Quest_DeckEditor the name of the deck
-
- this.getController().setModel(deck);
-
- // this affects the card pool
- this.getTopTableWithCards().sort(4, true); // sort by type
- this.getTopTableWithCards().sort(3, true); // then sort by color
- this.getBottomTableWithCards().sort(1, true);
- } // show(Command)
-
- /**
- *
- * setup.
- *
- */
- public void setup() {
- final List> columns = new ArrayList>();
- columns.add(new TableColumnInfo("Qty", 30, PresetColumns.FN_QTY_COMPARE,
- PresetColumns.FN_QTY_GET));
- columns.add(new TableColumnInfo("Name", 180, PresetColumns.FN_NAME_COMPARE,
- PresetColumns.FN_NAME_GET));
- columns.add(new TableColumnInfo("Cost", 70, PresetColumns.FN_COST_COMPARE,
- PresetColumns.FN_COST_GET));
- columns.add(new TableColumnInfo("Color", 50, PresetColumns.FN_COLOR_COMPARE,
- PresetColumns.FN_COLOR_GET));
- columns.add(new TableColumnInfo("Type", 100, PresetColumns.FN_TYPE_COMPARE,
- PresetColumns.FN_TYPE_GET));
- columns.add(new TableColumnInfo("Stats", 40, PresetColumns.FN_STATS_COMPARE,
- PresetColumns.FN_STATS_GET));
- columns.add(new TableColumnInfo("R", 35, PresetColumns.FN_RARITY_COMPARE,
- PresetColumns.FN_RARITY_GET));
- columns.add(new TableColumnInfo("Set", 40, PresetColumns.FN_SET_COMPARE,
- PresetColumns.FN_SET_GET));
- columns.add(new TableColumnInfo("New", 30, this.questData.getCards().getFnNewCompare(),
- this.questData.getCards().getFnNewGet()));
-
- columns.get(2).setCellRenderer(new ManaCostRenderer());
-
- this.getTopTableWithCards().setup(columns, this.getCardView());
- this.getBottomTableWithCards().setup(columns, this.getCardView());
-
- this.filterNameTypeSet.setListeners(new OnChangeTextUpdateDisplay(), this.getItemListenerUpdatesDisplay());
-
- setSize(1024, 740);
- }
-
- /**
- * Instantiates a new deck editor quest.
- *
- * @param parent
- * the parent frame for this deck editor instance
- * @param questData2
- * the quest data2
- */
- public DeckEditorQuest(JFrame parent, final QuestController questData2) {
- super(parent);
- this.questData = questData2;
- try {
- this.setFilterBoxes(new FilterCheckBoxes(true));
- this.setTopTableWithCards(new TableView("All Cards", true, true, CardPrinted.class));
- this.setBottomTableWithCards(new TableView("Your deck", true, CardPrinted.class));
- this.setCardView(new CardPanelHeavy());
- this.filterNameTypeSet = new FilterNameTypeSetPanel();
- this.jbInit();
- } catch (final Exception ex) {
- ErrorViewer.showError(ex);
- }
-
- final Lambda0 newCreator = new Lambda0() {
- @Override
- public Deck apply() {
- return new Deck();
- }
- };
- this.controller = new DeckController(questData2.getMyDecks(), this, newCreator);
- }
-
- private void jbInit() throws Exception {
-
- this.setTitle("Deck Editor");
- this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
-
- final Font fButtons = new java.awt.Font("Dialog", 0, 13);
- this.removeButton.setFont(fButtons);
- this.addButton.setFont(fButtons);
- this.clearFilterButton.setFont(fButtons);
- this.analysisButton.setFont(fButtons);
-
- this.addButton.setText("Add to Deck");
- this.removeButton.setText("Remove from Deck");
- this.clearFilterButton.setText("Clear Filter");
- this.analysisButton.setText("Deck Analysis");
-
- this.removeButton.addActionListener(new java.awt.event.ActionListener() {
- @Override
- public void actionPerformed(final ActionEvent e) {
- DeckEditorQuest.this.removeButtonActionPerformed(e);
- }
- });
- this.addButton.addActionListener(new java.awt.event.ActionListener() {
- @Override
- public void actionPerformed(final ActionEvent e) {
- DeckEditorQuest.this.addButtonActionPerformed(e);
- }
- });
- this.clearFilterButton.addActionListener(new java.awt.event.ActionListener() {
- @Override
- public void actionPerformed(final ActionEvent e) {
- DeckEditorQuest.this.clearFilterButtonActionPerformed(e);
- }
- });
- this.analysisButton.addActionListener(new java.awt.event.ActionListener() {
- @Override
- public void actionPerformed(final ActionEvent e) {
- DeckEditorQuest.this.analysisButtonActionPerformed(e);
- }
- });
-
- // Type filtering
- final Font f = new Font("Tahoma", Font.PLAIN, 10);
- for (final JCheckBox box : this.getFilterBoxes().getAllTypes()) {
- box.setFont(f);
- box.setOpaque(false);
- }
-
- // Color filtering
- for (final JCheckBox box : this.getFilterBoxes().getAllColors()) {
- box.setOpaque(false);
- }
-
- final Container content = this.getContentPane();
- final MigLayout layout = new MigLayout("fill");
- content.setLayout(layout);
-
- boolean isFirst = true;
- for (final JCheckBox box : this.getFilterBoxes().getAllTypes()) {
- String growParameter = "grow";
- if (isFirst) {
- growParameter = "cell 0 0, egx checkbox, grow, split 14";
- isFirst = false;
- }
- content.add(box, growParameter);
- box.addItemListener(this.getItemListenerUpdatesDisplay());
- }
-
- for (final JCheckBox box : this.getFilterBoxes().getAllColors()) {
- content.add(box, "grow");
- box.addItemListener(this.getItemListenerUpdatesDisplay());
- }
-
- content.add(this.clearFilterButton, "wmin 100, hmin 25, wmax 140, hmax 25, grow");
-
- content.add(this.filterNameTypeSet, "cell 0 1, grow");
- content.add(this.getTopTableWithCards().getTableDecorated(), "cell 0 2 1 2, push, grow");
- content.add(this.getTopTableWithCards().getLabel(), "cell 0 4");
-
- content.add(this.addButton, "w 100, h 49, sg button, cell 0 5, split 5");
- content.add(this.removeButton, "w 100, h 49, sg button");
-
- content.add(this.jLabelAnalysisGap, "wmin 75, growx");
- content.add(this.analysisButton, "w 100, h 49, wrap");
-
- content.add(this.getBottomTableWithCards().getTableDecorated(), "cell 0 6, grow");
- content.add(this.getBottomTableWithCards().getLabel(), "cell 0 7");
-
- content.add(this.getCardView(), "cell 1 0 1 8, flowy, growy");
-
- this.getTopTableWithCards().getTable().addMouseListener(new MouseAdapter() {
- @Override
- public void mouseClicked(final MouseEvent e) {
- if (e.getClickCount() == 2) {
- DeckEditorQuest.this.addCardToDeck();
- }
- }
- });
- this.getTopTableWithCards().getTable().addKeyListener(new KeyAdapter() {
- @Override
- public void keyPressed(final KeyEvent e) {
- if (e.getKeyChar() == ' ') {
- DeckEditorQuest.this.addCardToDeck();
- }
- }
- });
- }
-
- /*
- * (non-Javadoc)
- *
- * @see forge.gui.deckeditor.DeckEditorBase#buildFilter()
- */
- @Override
- protected Predicate buildFilter() {
- final Predicate cardFilter = Predicate.and(this.getFilterBoxes().buildFilter(),
- this.filterNameTypeSet.buildFilter());
- return Predicate.instanceOf(cardFilter, CardPrinted.class);
- }
-
- private void addButtonActionPerformed(final ActionEvent e) {
- addCardToDeck();
- }
-
- /**
- * Clear filter button_action performed.
- *
- * @param e
- * the e
- */
- void clearFilterButtonActionPerformed(final ActionEvent e) {
- // disable automatic update triggered by listeners
- this.setFiltersChangeFiringUpdate(false);
-
- for (final JCheckBox box : this.getFilterBoxes().getAllTypes()) {
- if (!box.isSelected()) {
- box.doClick();
- }
- }
- for (final JCheckBox box : this.getFilterBoxes().getAllColors()) {
- if (!box.isSelected()) {
- box.doClick();
- }
- }
-
- this.filterNameTypeSet.clearFilters();
-
- this.setFiltersChangeFiringUpdate(true);
-
- this.getTopTableWithCards().setFilter(null);
- }
-
- /**
- * Adds the card to deck.
- */
- void addCardToDeck() {
- final InventoryItem item = this.getTopTableWithCards().getSelectedCard();
- if ((item == null) || !(item instanceof CardPrinted)) {
- return;
- }
-
- final CardPrinted card = (CardPrinted) item;
- this.getTopTableWithCards().removeCard(card);
- this.getBottomTableWithCards().addCard(card);
- this.controller.notifyModelChanged();
- }
-
- private void removeButtonActionPerformed(final ActionEvent e) {
- final InventoryItem item = this.getBottomTableWithCards().getSelectedCard();
- if ((item == null) || !(item instanceof CardPrinted)) {
- return;
- }
-
- final CardPrinted card = (CardPrinted) item;
- this.getTopTableWithCards().addCard(card);
- this.getBottomTableWithCards().removeCard(card);
- }
-
- /**
- * Adds the cheat card.
- *
- * @param card
- * the card
- */
- public void addCheatCard(final CardPrinted card) {
- this.getTopTableWithCards().addCard(card);
- this.questData.getCards().getCardpool().add(card);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see forge.gui.deckeditor.DeckEditorBase#getController()
- */
- @Override
- public DeckController getController() {
- return this.controller;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see forge.gui.deckeditor.DeckEditorBase#updateView()
- */
- @Override
- public void updateView() {
- final Deck deck = this.controller.getModel();
-
- final ItemPool cardpool = new ItemPool(CardPrinted.class);
- cardpool.addAll(this.questData.getCards().getCardpool());
- // remove bottom cards that are in the deck from the card pool
- cardpool.removeAll(deck.getMain());
- // show cards, makes this user friendly
- this.getTopTableWithCards().setDeck(cardpool);
- this.getBottomTableWithCards().setDeck(deck.getMain());
- }
-
-}
diff --git a/src/main/java/forge/gui/deckeditor/DeckImport.java b/src/main/java/forge/gui/deckeditor/DeckImport.java
index 2e5ff3060a2..a5d9880caf5 100644
--- a/src/main/java/forge/gui/deckeditor/DeckImport.java
+++ b/src/main/java/forge/gui/deckeditor/DeckImport.java
@@ -41,15 +41,22 @@ import javax.swing.text.ElementIterator;
import net.miginfocom.swing.MigLayout;
import forge.deck.Deck;
+import forge.deck.DeckBase;
import forge.deck.DeckRecognizer;
import forge.deck.DeckRecognizer.TokenType;
import forge.gui.GuiUtils;
+import forge.gui.deckeditor.controllers.ACEditorBase;
import forge.item.CardPrinted;
+import forge.item.InventoryItem;
/**
+ *
* Dialog for quick import of decks.
+ *
+ * @param
+ * @param
*/
-public class DeckImport extends JDialog {
+public class DeckImport extends JDialog {
private static final long serialVersionUID = -5837776824284093004L;
private final JTextArea txtInput = new JTextArea();
@@ -83,7 +90,7 @@ public class DeckImport extends JDialog {
/** The tokens. */
private final List tokens = new ArrayList();
- private final DeckEditorConstructed host;
+ private final ACEditorBase host;
/**
* Instantiates a new deck import.
@@ -91,7 +98,7 @@ public class DeckImport extends JDialog {
* @param g
* the g
*/
- public DeckImport(final DeckEditorConstructed g) {
+ public DeckImport(final ACEditorBase g) {
this.host = g;
final int wWidth = 600;
@@ -136,6 +143,7 @@ public class DeckImport extends JDialog {
});
this.cmdAccept.addActionListener(new ActionListener() {
+ @SuppressWarnings("unchecked")
@Override
public void actionPerformed(final ActionEvent e) {
final String warning = "This will replace contents of your currently open deck with whatever you are importing. Proceed?";
@@ -145,7 +153,7 @@ public class DeckImport extends JDialog {
return;
}
final Deck toSet = DeckImport.this.buildDeck();
- DeckImport.this.host.getController().setModel(toSet);
+ DeckImport.this.host.getDeckController().setModel((TModel) toSet);
DeckImport.this.processWindowEvent(new WindowEvent(DeckImport.this, WindowEvent.WINDOW_CLOSING));
}
});
diff --git a/src/main/java/forge/gui/deckeditor/DraftingProcess.java b/src/main/java/forge/gui/deckeditor/DraftingProcess.java
deleted file mode 100644
index 28ce286948a..00000000000
--- a/src/main/java/forge/gui/deckeditor/DraftingProcess.java
+++ /dev/null
@@ -1,392 +0,0 @@
-/*
- * Forge: Play Magic: the Gathering.
- * Copyright (C) 2011 Forge Team
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package forge.gui.deckeditor;
-
-import java.awt.Rectangle;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.InputEvent;
-import java.awt.event.KeyAdapter;
-import java.awt.event.KeyEvent;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.util.ArrayList;
-import java.util.List;
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JOptionPane;
-import javax.swing.JTable;
-import javax.swing.WindowConstants;
-
-import forge.Command;
-import forge.Constant;
-import forge.Singletons;
-import forge.deck.Deck;
-import forge.deck.DeckGroup;
-import forge.error.ErrorViewer;
-import forge.game.limited.IBoosterDraft;
-import forge.gui.GuiUtils;
-import forge.gui.SOverlayUtils;
-import forge.gui.deckeditor.elements.CardPanelLite;
-import forge.gui.deckeditor.elements.ManaCostRenderer;
-import forge.gui.deckeditor.elements.TableColumnInfo;
-import forge.gui.deckeditor.elements.TableView;
-import forge.gui.home.sanctioned.CSubmenuDraft;
-import forge.item.CardDb;
-import forge.item.CardPrinted;
-import forge.item.InventoryItem;
-import forge.item.ItemPoolView;
-import forge.properties.ForgeProps;
-import forge.properties.NewConstants.Lang.GuiBoosterDraft;
-import forge.util.closures.Predicate;
-
-/**
- *
- * DeckEditorDraft class.
- *
- *
- * @author Forge
- * @version $Id$
- */
-public class DraftingProcess extends DeckEditorBase {
- /**
- * Constant serialVersionUID=-6055633915602448260L.
- */
- private static final long serialVersionUID = -6055633915602448260L;
-
- private IBoosterDraft boosterDraft;
-
- private final JButton jButtonPick = new JButton();
-
- private CardPanelLite cardView = new CardPanelLite();
-
- private final MouseListener pickWithMouse = new MouseAdapter() {
- @Override
- public void mouseClicked(final MouseEvent e) {
- // Pick on left-button double click
- if (((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0) && (e.getClickCount() == 2)) {
- DraftingProcess.this.jButtonPickClicked(null);
- } else if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0) {
- // pick on right click
- final JTable table = DraftingProcess.this.getTopTableWithCards().getTable();
- final int rowNumber = table.rowAtPoint(e.getPoint());
- // after hittest - if it was outside of rows - discard this
- // click
- if (rowNumber == -1) {
- return;
- }
-
- // if row was not selected, select it. If it was, pick a card
- if (rowNumber != table.getSelectedRow()) {
- table.getSelectionModel().setSelectionInterval(rowNumber, rowNumber);
- } else {
- DraftingProcess.this.jButtonPickClicked(null);
- }
- }
- }
- };
-
- /**
- * Show gui.
- *
- * @param inBoosterDraft
- * the in_booster draft
- */
- public final void showGui(final IBoosterDraft inBoosterDraft) {
- this.boosterDraft = inBoosterDraft;
- this.show(null);
- }
-
- /**
- *
- */
- private void saveDraft() {
- String s = "";
- while ((s == null) || (s.length() == 0)) {
- s = JOptionPane.showInputDialog(null, ForgeProps.getLocalized(GuiBoosterDraft.SAVE_DRAFT_MESSAGE),
- ForgeProps.getLocalized(GuiBoosterDraft.SAVE_DRAFT_TITLE), JOptionPane.QUESTION_MESSAGE);
- }
- // TODO: check if overwriting the same name, and let the user delete old
- // drafts
-
- // construct computer's decks
- // save draft
- final Deck[] computer = this.boosterDraft.getDecks();
-
- final DeckGroup finishedDraft = new DeckGroup(s);
- finishedDraft.setHumanDeck((Deck) this.getPlayersDeck().copyTo(s));
- finishedDraft.addAiDecks(computer);
-
- // DeckManager deckManager = new
- // DeckManager(ForgeProps.getFile(NEW_DECKS));
- Singletons.getModel().getDecks().getDraft().add(finishedDraft); // write
- // file
- // right
- // here
-
- // close and open next screen
- DraftingProcess.this.dispose();
-
- // This should be handled in the exit command of the editor, not here.
- CSubmenuDraft.SINGLETON_INSTANCE.update();
- SOverlayUtils.hideOverlay();
- } /* saveDraft() */
-
- /*
- * (non-Javadoc)
- *
- * @see forge.gui.deckeditor.DeckEditorBase#buildFilter()
- */
- @Override
- protected final Predicate buildFilter() {
- return Predicate.getTrue(CardPrinted.class);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see forge.gui.deckeditor.DeckEditorBase#getController()
- */
- @Override
- public DeckController getController() {
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see forge.gui.deckeditor.DeckEditorBase#updateView()
- */
- @Override
- public void updateView() {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see forge.gui.deckeditor.DeckEditorBase#show(forge.Command)
- */
- @Override
- public void show(final Command exitCommand) {
- this.setup();
- this.showChoices(this.boosterDraft.nextChoice());
- this.getBottomTableWithCards().setDeck((Iterable) null);
-
- this.getTopTableWithCards().sort(1, true);
- this.getBottomTableWithCards().sort(1, true);
-
- this.setVisible(true);
- }
-}
diff --git a/src/main/java/forge/gui/deckeditor/MenuBase.java b/src/main/java/forge/gui/deckeditor/MenuBase.java
deleted file mode 100644
index bc04ef9e7bc..00000000000
--- a/src/main/java/forge/gui/deckeditor/MenuBase.java
+++ /dev/null
@@ -1,454 +0,0 @@
-/*
- * Forge: Play Magic: the Gathering.
- * Copyright (C) 2011 Forge Team
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package forge.gui.deckeditor;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.util.List;
-
-import javax.swing.JMenu;
-import javax.swing.JMenuBar;
-import javax.swing.JMenuItem;
-import javax.swing.JOptionPane;
-import javax.swing.SwingUtilities;
-
-import org.apache.commons.lang3.StringUtils;
-
-import forge.Command;
-import forge.deck.DeckBase;
-import forge.error.ErrorViewer;
-import forge.gui.GuiUtils;
-
-/**
- *
- * Gui_DeckEditor_Menu class.
- *
- *
- * @param the generic type
- * @author Forge
- * @version $Id: DeckEditorCommonMenu.java 13590 2012-01-27 20:46:27Z Max mtg $
- */
-public class MenuBase extends JMenuBar {
-
- private static final long serialVersionUID = -4037993759604768755L;
- private final Command exitCommand;
- private final DeckController controller;
-
- /**
- * Menu for Deck Editor.
- *
- * @param ctrl the ctrl
- * @param exit a Command
- */
- public MenuBase(final DeckController ctrl, final Command exit) {
- this.controller = ctrl;
- this.exitCommand = exit;
-
- this.setupMenu();
- }
-
- /**
- * Gets the controller.
- *
- * @return the controller
- */
- protected final DeckController getController() {
- return this.controller;
- }
-
- /**
- * Setup menu.
- */
- protected void setupMenu() {
- this.add(this.getDefaultFileMenu());
- this.add(this.getSortMenu());
- }
-
- /**
- * New constructed.
- *
- * @param careAboutOldDeck
- * a boolean
- */
- protected final void newDocument(final boolean careAboutOldDeck) {
- if (careAboutOldDeck && !this.canLeaveCurrentDeck()) {
- return;
- }
-
- this.controller.newModel();
- }
-
- /**
- * Gets the user input open deck.
- *
- * @return the user input open deck
- */
- protected final String getUserInputOpenDeck() {
- final List choices = this.controller.getSavedNames();
- if (choices.isEmpty()) {
- JOptionPane.showMessageDialog(null, "No decks found", "Open Deck", JOptionPane.PLAIN_MESSAGE);
- return null;
- }
-
- final Object o = GuiUtils.chooseOneOrNone("Open Deck", choices.toArray());
- return o == null ? null : o.toString();
- }
-
- // deck.setName(currentDeckName);
-
- /**
- * Open.
- */
- protected final void open() {
- if (!this.canLeaveCurrentDeck()) {
- return;
- }
- final String name = this.getUserInputOpenDeck();
- if (StringUtils.isBlank(name)) {
- return;
- }
- this.controller.load(name);
- }
-
- /**
- * Save.
- */
- protected final void save() {
- if (StringUtils.isBlank(this.controller.getModel().getName())) {
- this.saveAs();
- return;
- }
-
- this.controller.save();
- }
-
- /**
- * Save as.
- */
- protected final void saveAs() {
- final String name = this.getDeckNameFromDialog();
-
- if (StringUtils.isBlank(name)) {
- final int n = JOptionPane.showConfirmDialog(null, "This name is incorrect. Enter another one?",
- "Cannot save", JOptionPane.YES_NO_OPTION);
-
- if (n == JOptionPane.NO_OPTION) {
- return;
- }
- }
-
- if (this.controller.fileExists(name)) {
- final int m = JOptionPane.showConfirmDialog(null, "There is already saved an item named '" + name
- + "'. Would you like to overwrite it?", "Confirm overwrite", JOptionPane.YES_NO_OPTION);
-
- if (m == JOptionPane.NO_OPTION) {
- return;
- }
- }
-
- this.controller.saveAs(name);
- }
-
- /**
- * Delete.
- */
- protected final void delete() {
- if (!this.controller.isModelInStore()) {
- return;
- }
-
- final int n = JOptionPane.showConfirmDialog(null, "Do you want to delete this deck "
- + this.controller.getModel().getName() + " ?", "Delete", JOptionPane.YES_NO_OPTION);
-
- if (n == JOptionPane.NO_OPTION) {
- return;
- }
-
- this.controller.delete();
- }
-
- /**
- *
- * close window.
- */
- public final void close() {
- if (!this.canLeaveCurrentDeck()) {
- return;
- }
- this.exitCommand.execute();
- }
-
- /**
- * Can leave current deck.
- *
- * @return true, if successful
- */
- protected final boolean canLeaveCurrentDeck() {
- if (this.controller.isSaved()) {
- return true;
- }
- final String message = String.format("Do you wish to save changes you made to your current deck '%s'?",
- this.controller.getModel().getName());
- final int choice = JOptionPane
- .showConfirmDialog(this.controller.getOwnerWindow(), message, "You have unsaved changes in your deck",
- JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
- if (JOptionPane.CANCEL_OPTION == choice) {
- return false;
- }
- if (JOptionPane.NO_OPTION == choice) {
- return true;
- }
-
- this.save();
- return true;
- }
-
- /**
- *
@@ -44,11 +26,11 @@ import forge.util.closures.Predicate;
* @author Forge
* @version $Id$
*/
-public final class MenuCommon extends MenuBase {
+public final class MenuCommon {
- /** Constant serialVersionUID=-4037993759604768755L. */
+ /** Constant serialVersionUID=-4037993759604768755L. *
private static final long serialVersionUID = -4037993759604768755L;
- /** Constant previousDirectory. */
+ /** Constant previousDirectory. *
private static File previousDirectory = null;
/**
@@ -58,7 +40,7 @@ public final class MenuCommon extends MenuBase {
* the ctrl
* @param exit
* a Command
- */
+ *
public MenuCommon(final DeckController ctrl, final Command exit) {
super(ctrl, exit);
@@ -132,7 +114,7 @@ public final class MenuCommon extends MenuBase {
*
* exportDeck.
*
- */
+ *
private void exportDeck() {
final File filename = this.getExportFilename();
if (filename == null) {
@@ -168,7 +150,7 @@ public final class MenuCommon extends MenuBase {
*
* Generate Proxy for a Deck.
*
- */
+ *
private void generateProxies() {
final File filename = this.getProxiesFilename();
if (filename == null) {
@@ -206,7 +188,7 @@ public final class MenuCommon extends MenuBase {
* (non-Javadoc)
*
* @see forge.gui.deckeditor.MenuBase#getDefaultFileMenu()
- */
+ *
@Override
protected JMenu getDefaultFileMenu() {
final JMenu fileMenu = super.getDefaultFileMenu();
@@ -327,4 +309,5 @@ public final class MenuCommon extends MenuBase {
return fileMenu;
} // setupMenu()
+ */
}
diff --git a/src/main/java/forge/gui/deckeditor/MenuLimited.java b/src/main/java/forge/gui/deckeditor/MenuLimited.java
deleted file mode 100644
index b13a388e92d..00000000000
--- a/src/main/java/forge/gui/deckeditor/MenuLimited.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Forge: Play Magic: the Gathering.
- * Copyright (C) 2011 Forge Team
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package forge.gui.deckeditor;
-
-import forge.Command;
-import forge.deck.DeckGroup;
-
-/**
- *
- * Gui_DeckEditor_Menu class.
- *
- *
- * @author Forge
- * @version $Id: DeckEditorCommonMenu.java 13590 2012-01-27 20:46:27Z Max mtg $
- */
-public final class MenuLimited extends MenuBase {
-
- /** Constant serialVersionUID=-4037993759604768755L. */
- private static final long serialVersionUID = -4037993759604768755L;
-
- /**
- * Menu for Deck Editor.
- *
- * @param ctrl the ctrl
- * @param exit a Command
- */
- public MenuLimited(final DeckController ctrl, final Command exit) {
- super(ctrl, exit);
- }
-
- // deck.setName(currentDeckName);
-
-}
diff --git a/src/main/java/forge/gui/deckeditor/MenuQuest.java b/src/main/java/forge/gui/deckeditor/MenuQuest.java
deleted file mode 100644
index a4c9d89b0a5..00000000000
--- a/src/main/java/forge/gui/deckeditor/MenuQuest.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * Forge: Play Magic: the Gathering.
- * Copyright (C) 2011 Forge Team
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package forge.gui.deckeditor;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import javax.swing.JFileChooser;
-import javax.swing.JMenu;
-import javax.swing.JMenuItem;
-
-import forge.Command;
-import forge.Constant;
-import forge.deck.Deck;
-import forge.deck.io.DeckSerializer;
-import forge.error.ErrorViewer;
-import forge.gui.ListChooser;
-import forge.item.CardDb;
-import forge.item.CardPrinted;
-
-//presumes AllZone.getQuestData() is not null
-/**
- *
- * Gui_Quest_DeckEditor_Menu class.
- *
- *
- * @author Forge
- * @version $Id$
- */
-public class MenuQuest extends MenuBase {
- /** Constant serialVersionUID=-4052319220021158574L. */
- private static final long serialVersionUID = -4052319220021158574L;
-
- // used for import and export, try to made the gui user friendly
- /** Constant previousDirectory. */
- private static File previousDirectory = null;
-
- /**
- *
- * Constructor for Gui_Quest_DeckEditor_Menu.
- *
- *
- * @param d
- * a {@link forge.gui.deckeditor.IDeckDisplay} object.
- * @param exit
- * a {@link forge.Command} object.
- */
- public MenuQuest(final DeckController d, final Command exit) {
- super(d, exit);
- }
-
- /**
- *