mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +00:00
Added generic types to Swing components that needed them (with transition to Java 7)
This commit is contained in:
@@ -57,19 +57,19 @@ public class DeckgenUtil {
|
|||||||
* @param selection {@link java.lang.String} array
|
* @param selection {@link java.lang.String} array
|
||||||
* @return {@link forge.deck.Deck}
|
* @return {@link forge.deck.Deck}
|
||||||
*/
|
*/
|
||||||
public static Deck buildColorDeck(final String[] selection, boolean forAi) {
|
public static Deck buildColorDeck(List<String> selection, boolean forAi) {
|
||||||
|
|
||||||
final Deck deck;
|
final Deck deck;
|
||||||
String deckName = null;
|
String deckName = null;
|
||||||
|
|
||||||
GenerateColoredDeckBase gen = null;
|
GenerateColoredDeckBase gen = null;
|
||||||
|
|
||||||
if (selection.length == 1) {
|
if (selection.size() == 1) {
|
||||||
gen = new GenerateMonoColorDeck(selection[0]);
|
gen = new GenerateMonoColorDeck(selection.get(0));
|
||||||
} else if (selection.length == 2) {
|
} else if (selection.size() == 2) {
|
||||||
gen = new Generate2ColorDeck(selection[0], selection[1]);
|
gen = new Generate2ColorDeck(selection.get(0), selection.get(1));
|
||||||
} else if (selection.length == 3) {
|
} else if (selection.size() == 3) {
|
||||||
gen = new Generate3ColorDeck(selection[0], selection[1], selection[2]);
|
gen = new Generate3ColorDeck(selection.get(0), selection.get(1), selection.get(2));
|
||||||
} else {
|
} else {
|
||||||
gen = new Generate5ColorDeck();
|
gen = new Generate5ColorDeck();
|
||||||
deckName = "5 colors";
|
deckName = "5 colors";
|
||||||
@@ -91,10 +91,10 @@ public class DeckgenUtil {
|
|||||||
* @param selection {@link java.lang.String}
|
* @param selection {@link java.lang.String}
|
||||||
* @return {@link forge.deck.Deck}
|
* @return {@link forge.deck.Deck}
|
||||||
*/
|
*/
|
||||||
public static Deck buildThemeDeck(final String[] selection) {
|
public static Deck buildThemeDeck(final String selection) {
|
||||||
final GenerateThemeDeck gen = new GenerateThemeDeck();
|
final GenerateThemeDeck gen = new GenerateThemeDeck();
|
||||||
final Deck deck = new Deck();
|
final Deck deck = new Deck();
|
||||||
deck.getMain().addAll(gen.getThemeDeck(selection[0], 60));
|
deck.getMain().addAll(gen.getThemeDeck(selection, 60));
|
||||||
|
|
||||||
return deck;
|
return deck;
|
||||||
}
|
}
|
||||||
@@ -105,12 +105,12 @@ public class DeckgenUtil {
|
|||||||
* @param selection {java.lang.String}
|
* @param selection {java.lang.String}
|
||||||
* @return {@link forge.deck.Deck}
|
* @return {@link forge.deck.Deck}
|
||||||
*/
|
*/
|
||||||
public static Deck getConstructedDeck(final String[] selection) {
|
public static Deck getConstructedDeck(final String selection) {
|
||||||
return Singletons.getModel().getDecks().getConstructed().get(selection[0]);
|
return Singletons.getModel().getDecks().getConstructed().get(selection);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Deck getPreconDeck(String[] selection) {
|
public static Deck getPreconDeck(String selection) {
|
||||||
return QuestController.getPrecons().get(selection[0]).getDeck();
|
return QuestController.getPrecons().get(selection).getDeck();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static QuestEvent getQuestEvent(final String name) {
|
public static QuestEvent getQuestEvent(final String name) {
|
||||||
@@ -130,10 +130,10 @@ public class DeckgenUtil {
|
|||||||
public static Deck getRandomColorDeck(boolean forAi) {
|
public static Deck getRandomColorDeck(boolean forAi) {
|
||||||
final int[] colorCount = new int[] {1, 2, 3, 5};
|
final int[] colorCount = new int[] {1, 2, 3, 5};
|
||||||
final int count = colorCount[MyRandom.getRandom().nextInt(colorCount.length)];
|
final int count = colorCount[MyRandom.getRandom().nextInt(colorCount.length)];
|
||||||
final String[] selection = new String[count];
|
final List<String> selection = new ArrayList<String>();
|
||||||
|
|
||||||
// A simulated selection of "random 1" will trigger the AI selection process.
|
// A simulated selection of "random 1" will trigger the AI selection process.
|
||||||
for (int i = 0; i < count; i++) { selection[i] = "Random 1"; }
|
for (int i = 0; i < count; i++) { selection.add("Random"); }
|
||||||
|
|
||||||
return DeckgenUtil.buildColorDeck(selection, forAi);
|
return DeckgenUtil.buildColorDeck(selection, forAi);
|
||||||
}
|
}
|
||||||
@@ -143,7 +143,7 @@ public class DeckgenUtil {
|
|||||||
final List<String> themeNames = new ArrayList<String>();
|
final List<String> themeNames = new ArrayList<String>();
|
||||||
for (final String s : GenerateThemeDeck.getThemeNames()) { themeNames.add(s); }
|
for (final String s : GenerateThemeDeck.getThemeNames()) { themeNames.add(s); }
|
||||||
final int rand = (int) (Math.floor(Math.random() * themeNames.size()));
|
final int rand = (int) (Math.floor(Math.random() * themeNames.size()));
|
||||||
return DeckgenUtil.buildThemeDeck(new String[] {themeNames.get(rand)});
|
return DeckgenUtil.buildThemeDeck(themeNames.get(rand));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return {@link forge.deck.Deck} */
|
/** @return {@link forge.deck.Deck} */
|
||||||
@@ -201,7 +201,7 @@ public class DeckgenUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @param lst0 {@link javax.swing.JList} */
|
/** @param lst0 {@link javax.swing.JList} */
|
||||||
public static void randomSelect(final JList lst0) {
|
public static void randomSelect(final JList<String> lst0) {
|
||||||
final int size = lst0.getModel().getSize();
|
final int size = lst0.getModel().getSize();
|
||||||
|
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
@@ -216,7 +216,7 @@ public class DeckgenUtil {
|
|||||||
/** Shows decklist dialog for a given deck.
|
/** Shows decklist dialog for a given deck.
|
||||||
* @param lst0 {@link javax.swing.JList}
|
* @param lst0 {@link javax.swing.JList}
|
||||||
*/
|
*/
|
||||||
public static void showDecklist(final JList lst0) {
|
public static void showDecklist(final JList<String> lst0) {
|
||||||
final String deckName = lst0.getSelectedValue().toString();
|
final String deckName = lst0.getSelectedValue().toString();
|
||||||
final Deck deck;
|
final Deck deck;
|
||||||
|
|
||||||
@@ -281,17 +281,17 @@ public class DeckgenUtil {
|
|||||||
* @param colors0 String[]
|
* @param colors0 String[]
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static boolean colorCheck(final String[] colors0) {
|
public static boolean colorCheck(final List<String> colors0) {
|
||||||
boolean result = true;
|
boolean result = true;
|
||||||
|
|
||||||
if (colors0.length == 4) {
|
if (colors0.size() == 4) {
|
||||||
JOptionPane.showMessageDialog(null,
|
JOptionPane.showMessageDialog(null,
|
||||||
"Sorry, four color generated decks aren't supported yet."
|
"Sorry, four color generated decks aren't supported yet."
|
||||||
+ "\n\rPlease use 2, 3, or 5 colors for this deck.",
|
+ "\n\rPlease use 2, 3, or 5 colors for this deck.",
|
||||||
"Generate deck: 4 colors", JOptionPane.ERROR_MESSAGE);
|
"Generate deck: 4 colors", JOptionPane.ERROR_MESSAGE);
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
else if (colors0.length > 5) {
|
else if (colors0.size() > 5) {
|
||||||
JOptionPane.showMessageDialog(null,
|
JOptionPane.showMessageDialog(null,
|
||||||
"Generate deck: maximum five colors!",
|
"Generate deck: maximum five colors!",
|
||||||
"Generate deck: too many colors", JOptionPane.ERROR_MESSAGE);
|
"Generate deck: too many colors", JOptionPane.ERROR_MESSAGE);
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class CardListViewer {
|
|||||||
// Flag: was the dialog already shown?
|
// Flag: was the dialog already shown?
|
||||||
private boolean called;
|
private boolean called;
|
||||||
// initialized before; listeners may be added to it
|
// initialized before; listeners may be added to it
|
||||||
private final JList jList;
|
private final JList<PaperCard> jList;
|
||||||
private final CardDetailPanel detail;
|
private final CardDetailPanel detail;
|
||||||
private final CardPicturePanel picture;
|
private final CardPicturePanel picture;
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ public class CardListViewer {
|
|||||||
public CardListViewer(final String title, final String message, final List<PaperCard> list, final Icon dialogIcon) {
|
public CardListViewer(final String title, final String message, final List<PaperCard> list, final Icon dialogIcon) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.list = Collections.unmodifiableList(list);
|
this.list = Collections.unmodifiableList(list);
|
||||||
this.jList = new JList(new ChooserListModel());
|
this.jList = new JList<PaperCard>(new ChooserListModel());
|
||||||
this.detail = new CardDetailPanel(null);
|
this.detail = new CardDetailPanel(null);
|
||||||
this.picture = new CardPicturePanel();
|
this.picture = new CardPicturePanel();
|
||||||
this.ok = new CloseAction(JOptionPane.OK_OPTION, "OK");
|
this.ok = new CloseAction(JOptionPane.OK_OPTION, "OK");
|
||||||
@@ -150,7 +150,7 @@ public class CardListViewer {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ChooserListModel extends AbstractListModel {
|
private class ChooserListModel extends AbstractListModel<PaperCard> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 3871965346333840556L;
|
private static final long serialVersionUID = 3871965346333840556L;
|
||||||
|
|
||||||
@@ -160,7 +160,7 @@ public class CardListViewer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getElementAt(final int index) {
|
public PaperCard getElementAt(final int index) {
|
||||||
return CardListViewer.this.list.get(index);
|
return CardListViewer.this.list.get(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,10 +47,10 @@ import forge.item.IPaperCard;
|
|||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class DualListBox<T> extends FPanel {
|
public class DualListBox<T> extends FPanel {
|
||||||
private final FList sourceList;
|
private final FList<T> sourceList;
|
||||||
private final UnsortedListModel<T> sourceListModel;
|
private final UnsortedListModel<T> sourceListModel;
|
||||||
|
|
||||||
private final FList destList;
|
private final FList<T> destList;
|
||||||
private final UnsortedListModel<T> destListModel;
|
private final UnsortedListModel<T> destListModel;
|
||||||
|
|
||||||
private final FButton addButton;
|
private final FButton addButton;
|
||||||
@@ -71,9 +71,9 @@ public class DualListBox<T> extends FPanel {
|
|||||||
public DualListBox(int remainingSources, List<T> sourceElements, List<T> destElements ) {
|
public DualListBox(int remainingSources, List<T> sourceElements, List<T> destElements ) {
|
||||||
targetRemainingSources = remainingSources;
|
targetRemainingSources = remainingSources;
|
||||||
sourceListModel = new UnsortedListModel<T>();
|
sourceListModel = new UnsortedListModel<T>();
|
||||||
sourceList = new FList(sourceListModel);
|
sourceList = new FList<T>(sourceListModel);
|
||||||
destListModel = new UnsortedListModel<T>();
|
destListModel = new UnsortedListModel<T>();
|
||||||
destList = new FList(destListModel);
|
destList = new FList<T>(destListModel);
|
||||||
|
|
||||||
setPreferredSize(new Dimension(650, 300));
|
setPreferredSize(new Dimension(650, 300));
|
||||||
setLayout(new GridLayout(0, 3));
|
setLayout(new GridLayout(0, 3));
|
||||||
@@ -85,7 +85,7 @@ public class DualListBox<T> extends FPanel {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
List<T> selected = new ArrayList<T>();
|
List<T> selected = new ArrayList<T>();
|
||||||
for (Object item : sourceList.getSelectedValues()) {
|
for (Object item : sourceList.getSelectedValuesList()) {
|
||||||
selected.add((T)item);
|
selected.add((T)item);
|
||||||
}
|
}
|
||||||
addDestinationElements(selected);
|
addDestinationElements(selected);
|
||||||
@@ -100,7 +100,7 @@ public class DualListBox<T> extends FPanel {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
List<T> selected = new ArrayList<T>();
|
List<T> selected = new ArrayList<T>();
|
||||||
for (Object item : destList.getSelectedValues()) {
|
for (Object item : destList.getSelectedValuesList()) {
|
||||||
selected.add((T)item);
|
selected.add((T)item);
|
||||||
}
|
}
|
||||||
clearDestinationSelected();
|
clearDestinationSelected();
|
||||||
@@ -217,7 +217,7 @@ public class DualListBox<T> extends FPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void _handleListKey (KeyEvent e, Runnable onSpace, FList arrowFocusTarget) {
|
private void _handleListKey (KeyEvent e, Runnable onSpace, FList<T> arrowFocusTarget) {
|
||||||
switch (e.getKeyCode()) {
|
switch (e.getKeyCode()) {
|
||||||
case KeyEvent.VK_SPACE:
|
case KeyEvent.VK_SPACE:
|
||||||
onSpace.run();
|
onSpace.run();
|
||||||
@@ -249,11 +249,11 @@ public class DualListBox<T> extends FPanel {
|
|||||||
destListModel.clear();
|
destListModel.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSourceElements(ListModel newValue) {
|
public void addSourceElements(ListModel<T> newValue) {
|
||||||
fillListModel(sourceListModel, newValue);
|
fillListModel(sourceListModel, newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSourceElements(ListModel newValue) {
|
public void setSourceElements(ListModel<T> newValue) {
|
||||||
clearSourceListModel();
|
clearSourceListModel();
|
||||||
addSourceElements(newValue);
|
addSourceElements(newValue);
|
||||||
}
|
}
|
||||||
@@ -262,11 +262,11 @@ public class DualListBox<T> extends FPanel {
|
|||||||
fillListModel(destListModel, newValue);
|
fillListModel(destListModel, newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addDestinationElements(ListModel newValue) {
|
public void addDestinationElements(ListModel<T> newValue) {
|
||||||
fillListModel(destListModel, newValue);
|
fillListModel(destListModel, newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillListModel(UnsortedListModel<T> model, ListModel newValues) {
|
private void fillListModel(UnsortedListModel<T> model, ListModel<T> newValues) {
|
||||||
model.addAll(newValues);
|
model.addAll(newValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -326,7 +326,7 @@ public class DualListBox<T> extends FPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void _addListListeners(final FList list) {
|
private void _addListListeners(final FList<T> list) {
|
||||||
list.getModel().addListDataListener(new ListDataListener() {
|
list.getModel().addListDataListener(new ListDataListener() {
|
||||||
int callCount = 0;
|
int callCount = 0;
|
||||||
@Override
|
@Override
|
||||||
@@ -342,7 +342,7 @@ public class DualListBox<T> extends FPanel {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ListModel model = list.getModel();
|
ListModel<T> model = list.getModel();
|
||||||
if (0 == model.getSize()) {
|
if (0 == model.getSize()) {
|
||||||
// nothing left to show
|
// nothing left to show
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ public class GuiChoose {
|
|||||||
@Override
|
@Override
|
||||||
public List<T> call() {
|
public List<T> call() {
|
||||||
ListChooser<T> c = new ListChooser<T>(message, min, max, choices);
|
ListChooser<T> c = new ListChooser<T>(message, min, max, choices);
|
||||||
final JList list = c.getJList();
|
final JList<T> list = c.getJList();
|
||||||
list.addListSelectionListener(new ListSelectionListener() {
|
list.addListSelectionListener(new ListSelectionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void valueChanged(final ListSelectionEvent ev) {
|
public void valueChanged(final ListSelectionEvent ev) {
|
||||||
|
|||||||
@@ -307,7 +307,7 @@ public class ImportDialog {
|
|||||||
private final Runnable _onAnalyzerDone;
|
private final Runnable _onAnalyzerDone;
|
||||||
private final boolean _isMigration;
|
private final boolean _isMigration;
|
||||||
private final FLabel _unknownDeckLabel;
|
private final FLabel _unknownDeckLabel;
|
||||||
private final JComboBox _unknownDeckCombo;
|
private final JComboBox<_UnknownDeckChoice> _unknownDeckCombo;
|
||||||
private final FCheckBox _moveCheckbox;
|
private final FCheckBox _moveCheckbox;
|
||||||
private final FCheckBox _overwriteCheckbox;
|
private final FCheckBox _overwriteCheckbox;
|
||||||
private final JTextArea _operationLog;
|
private final JTextArea _operationLog;
|
||||||
@@ -340,7 +340,7 @@ public class ImportDialog {
|
|||||||
_addSelectionWidget(knownDeckPanel, OpType.UNKNOWN_DECK, "Unknown decks");
|
_addSelectionWidget(knownDeckPanel, OpType.UNKNOWN_DECK, "Unknown decks");
|
||||||
JPanel unknownDeckPanel = new JPanel(new MigLayout("insets 0, gap 5"));
|
JPanel unknownDeckPanel = new JPanel(new MigLayout("insets 0, gap 5"));
|
||||||
unknownDeckPanel.setOpaque(false);
|
unknownDeckPanel.setOpaque(false);
|
||||||
_unknownDeckCombo = new JComboBox();
|
_unknownDeckCombo = new JComboBox<_UnknownDeckChoice>();
|
||||||
_unknownDeckCombo.addItem(new _UnknownDeckChoice("Constructed", NewConstants.DECK_CONSTRUCTED_DIR));
|
_unknownDeckCombo.addItem(new _UnknownDeckChoice("Constructed", NewConstants.DECK_CONSTRUCTED_DIR));
|
||||||
_unknownDeckCombo.addItem(new _UnknownDeckChoice("Draft", NewConstants.DECK_DRAFT_DIR));
|
_unknownDeckCombo.addItem(new _UnknownDeckChoice("Draft", NewConstants.DECK_DRAFT_DIR));
|
||||||
_unknownDeckCombo.addItem(new _UnknownDeckChoice("Planar", NewConstants.DECK_PLANE_DIR));
|
_unknownDeckCombo.addItem(new _UnknownDeckChoice("Planar", NewConstants.DECK_PLANE_DIR));
|
||||||
@@ -816,7 +816,7 @@ public class ImportDialog {
|
|||||||
private final boolean _move;
|
private final boolean _move;
|
||||||
private final boolean _overwrite;
|
private final boolean _overwrite;
|
||||||
|
|
||||||
public _Importer(String srcDir, Map<OpType, Pair<FCheckBox, ? extends Map<File, File>>> selections, JComboBox unknownDeckCombo,
|
public _Importer(String srcDir, Map<OpType, Pair<FCheckBox, ? extends Map<File, File>>> selections, JComboBox<_UnknownDeckChoice> unknownDeckCombo,
|
||||||
JTextArea operationLog, JProgressBar progressBar, boolean move, boolean overwrite) {
|
JTextArea operationLog, JProgressBar progressBar, boolean move, boolean overwrite) {
|
||||||
_srcDir = srcDir;
|
_srcDir = srcDir;
|
||||||
_operationLog = operationLog;
|
_operationLog = operationLog;
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import java.awt.event.MouseAdapter;
|
|||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.WindowEvent;
|
import java.awt.event.WindowEvent;
|
||||||
import java.awt.event.WindowFocusListener;
|
import java.awt.event.WindowFocusListener;
|
||||||
import java.util.AbstractList;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -79,7 +78,7 @@ public class ListChooser<T> {
|
|||||||
// Flag: was the dialog already shown?
|
// Flag: was the dialog already shown?
|
||||||
private boolean called;
|
private boolean called;
|
||||||
// initialized before; listeners may be added to it
|
// initialized before; listeners may be added to it
|
||||||
private JList jList;
|
private JList<T> jList;
|
||||||
// Temporarily stored for event handlers during show
|
// Temporarily stored for event handlers during show
|
||||||
private JDialog dialog;
|
private JDialog dialog;
|
||||||
private JOptionPane optionPane;
|
private JOptionPane optionPane;
|
||||||
@@ -91,7 +90,7 @@ public class ListChooser<T> {
|
|||||||
this.minChoices = minChoices;
|
this.minChoices = minChoices;
|
||||||
this.maxChoices = maxChoices;
|
this.maxChoices = maxChoices;
|
||||||
this.list = list.getClass().isInstance(List.class) ? (List<T>)list : Lists.newArrayList(list);
|
this.list = list.getClass().isInstance(List.class) ? (List<T>)list : Lists.newArrayList(list);
|
||||||
this.jList = new JList(new ChooserListModel());
|
this.jList = new JList<T>(new ChooserListModel());
|
||||||
this.ok = new CloseAction(JOptionPane.OK_OPTION, "OK");
|
this.ok = new CloseAction(JOptionPane.OK_OPTION, "OK");
|
||||||
this.ok.setEnabled(minChoices == 0);
|
this.ok.setEnabled(minChoices == 0);
|
||||||
this.cancel = new CloseAction(JOptionPane.CANCEL_OPTION, "Cancel");
|
this.cancel = new CloseAction(JOptionPane.CANCEL_OPTION, "Cancel");
|
||||||
@@ -118,7 +117,7 @@ public class ListChooser<T> {
|
|||||||
*
|
*
|
||||||
* @return a {@link javax.swing.JList} object.
|
* @return a {@link javax.swing.JList} object.
|
||||||
*/
|
*/
|
||||||
public JList getJList() {
|
public JList<T> getJList() {
|
||||||
return this.jList;
|
return this.jList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,19 +209,7 @@ public class ListChooser<T> {
|
|||||||
if (!this.called) {
|
if (!this.called) {
|
||||||
throw new IllegalStateException("not yet shown");
|
throw new IllegalStateException("not yet shown");
|
||||||
}
|
}
|
||||||
final Object[] selected = this.jList.getSelectedValues();
|
return this.jList.getSelectedValuesList();
|
||||||
return new AbstractList<T>() {
|
|
||||||
@Override
|
|
||||||
public int size() {
|
|
||||||
return selected.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
public T get(final int index) {
|
|
||||||
return (T) selected[index];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -242,7 +229,6 @@ public class ListChooser<T> {
|
|||||||
*
|
*
|
||||||
* @return a T object.
|
* @return a T object.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public T getSelectedValue() {
|
public T getSelectedValue() {
|
||||||
if (!this.called) {
|
if (!this.called) {
|
||||||
throw new IllegalStateException("not yet shown");
|
throw new IllegalStateException("not yet shown");
|
||||||
@@ -261,7 +247,7 @@ public class ListChooser<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ChooserListModel extends AbstractListModel {
|
private class ChooserListModel extends AbstractListModel<T> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 3871965346333840556L;
|
private static final long serialVersionUID = 3871965346333840556L;
|
||||||
|
|
||||||
@@ -271,7 +257,7 @@ public class ListChooser<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getElementAt(final int index) {
|
public T getElementAt(final int index) {
|
||||||
return ListChooser.this.list.get(index);
|
return ListChooser.this.list.get(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import javax.swing.ListModel;
|
|||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class UnsortedListModel<T> extends AbstractListModel { // Java 7 has a generic version. In 6 we have to cast types
|
public class UnsortedListModel<T> extends AbstractListModel<T> {
|
||||||
List<T> model;
|
List<T> model;
|
||||||
|
|
||||||
public UnsortedListModel() {
|
public UnsortedListModel() {
|
||||||
@@ -23,7 +23,7 @@ public class UnsortedListModel<T> extends AbstractListModel { // Java 7 has a ge
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getElementAt(int index) {
|
public T getElementAt(int index) {
|
||||||
return model.get(index);
|
return model.get(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,8 +50,7 @@ public class UnsortedListModel<T> extends AbstractListModel { // Java 7 has a ge
|
|||||||
fireContentsChanged(this, 0, getSize() - 1);
|
fireContentsChanged(this, 0, getSize() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked") // Java 7 has type parameterized ListModel
|
public void addAll(ListModel<T> otherModel) {
|
||||||
public void addAll(ListModel otherModel) {
|
|
||||||
Collection<T> elements = new ArrayList<T>();
|
Collection<T> elements = new ArrayList<T>();
|
||||||
int size = otherModel.getSize();
|
int size = otherModel.getSize();
|
||||||
for (int i = 0; size > i; ++i) {
|
for (int i = 0; size > i; ++i) {
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ public enum VCardCatalog implements IVDoc<CCardCatalog>, ITableContainer {
|
|||||||
.text("Add filter")
|
.text("Add filter")
|
||||||
.tooltip("Click to add custom filters to the card list")
|
.tooltip("Click to add custom filters to the card list")
|
||||||
.reactOnMouseDown().build();
|
.reactOnMouseDown().build();
|
||||||
private final JComboBox cbSearchMode = new JComboBox();
|
private final JComboBox<String> cbSearchMode = new JComboBox<String>();
|
||||||
private final JTextField txfSearch = new FTextField.Builder().build();
|
private final JTextField txfSearch = new FTextField.Builder().build();
|
||||||
private final FLabel lblName = new FLabel.Builder().text("Name").hoverable().selectable().selected().build();
|
private final FLabel lblName = new FLabel.Builder().text("Name").hoverable().selectable().selected().build();
|
||||||
private final FLabel lblType = new FLabel.Builder().text("Type").hoverable().selectable().selected().build();
|
private final FLabel lblType = new FLabel.Builder().text("Type").hoverable().selectable().selected().build();
|
||||||
@@ -252,7 +252,7 @@ public enum VCardCatalog implements IVDoc<CCardCatalog>, ITableContainer {
|
|||||||
public FLabel getLblText() { return lblText; }
|
public FLabel getLblText() { return lblText; }
|
||||||
|
|
||||||
public FLabel getBtnAddRestriction() { return btnAddRestriction; }
|
public FLabel getBtnAddRestriction() { return btnAddRestriction; }
|
||||||
public JComboBox getCbSearchMode() { return cbSearchMode; }
|
public JComboBox<String> getCbSearchMode() { return cbSearchMode; }
|
||||||
public JTextField getTxfSearch() { return txfSearch; }
|
public JTextField getTxfSearch() { return txfSearch; }
|
||||||
|
|
||||||
public Map<SEditorUtil.StatTypes, FLabel> getStatLabels() {
|
public Map<SEditorUtil.StatTypes, FLabel> getStatLabels() {
|
||||||
|
|||||||
@@ -41,10 +41,11 @@ public enum CSubmenuGauntletContests implements ICDoc {
|
|||||||
private final VSubmenuGauntletContests view = VSubmenuGauntletContests.SINGLETON_INSTANCE;
|
private final VSubmenuGauntletContests view = VSubmenuGauntletContests.SINGLETON_INSTANCE;
|
||||||
|
|
||||||
private final MouseAdapter madDecklist = new MouseAdapter() {
|
private final MouseAdapter madDecklist = new MouseAdapter() {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(final MouseEvent e) {
|
public void mouseClicked(final MouseEvent e) {
|
||||||
if (e.getClickCount() == 2) {
|
if (e.getClickCount() == 2) {
|
||||||
DeckgenUtil.showDecklist(((JList) e.getSource())); }
|
DeckgenUtil.showDecklist(((JList<String>) e.getSource())); }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public enum VSubmenuGauntletBuild implements IVSubmenu<CSubmenuGauntletBuild> {
|
|||||||
private final JPanel pnlDirections = new JPanel();
|
private final JPanel pnlDirections = new JPanel();
|
||||||
|
|
||||||
private final FDeckChooser lstLeft = new FDeckChooser("Deck", false);
|
private final FDeckChooser lstLeft = new FDeckChooser("Deck", false);
|
||||||
private final JList lstRight = new FList();
|
private final JList<String> lstRight = new FList<String>();
|
||||||
|
|
||||||
private final JScrollPane scrRight = new FScrollPane(lstRight,
|
private final JScrollPane scrRight = new FScrollPane(lstRight,
|
||||||
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
||||||
@@ -210,7 +210,7 @@ public enum VSubmenuGauntletBuild implements IVSubmenu<CSubmenuGauntletBuild> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @return {@link javax.swing.JList} */
|
/** @return {@link javax.swing.JList} */
|
||||||
public JList getLstRight() {
|
public JList<String> getLstRight() {
|
||||||
return this.lstRight;
|
return this.lstRight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -123,8 +123,8 @@ public class DialogChooseSets {
|
|||||||
|
|
||||||
private JPanel makeCheckBoxList(List<FCheckBox> sets, String title, boolean focused) {
|
private JPanel makeCheckBoxList(List<FCheckBox> sets, String title, boolean focused) {
|
||||||
choices.addAll(sets);
|
choices.addAll(sets);
|
||||||
final FCheckBoxList cbl = new FCheckBoxList(false);
|
final FCheckBoxList<FCheckBox> cbl = new FCheckBoxList<FCheckBox>(false);
|
||||||
cbl.setListData(sets.toArray());
|
cbl.setListData(sets.toArray(new FCheckBox[]{}));
|
||||||
cbl.setVisibleRowCount(Math.min(20, sets.size()));
|
cbl.setVisibleRowCount(Math.min(20, sets.size()));
|
||||||
|
|
||||||
if (focused) {
|
if (focused) {
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public interface IVQuestStats {
|
|||||||
JLabel getLblWinStreak();
|
JLabel getLblWinStreak();
|
||||||
|
|
||||||
/** @return {@link javax.swing.JComboBox} */
|
/** @return {@link javax.swing.JComboBox} */
|
||||||
JComboBox getCbxPet();
|
JComboBox<String> getCbxPet();
|
||||||
|
|
||||||
/** @return {@link javax.swing.JCheckBox} */
|
/** @return {@link javax.swing.JCheckBox} */
|
||||||
JCheckBox getCbPlant();
|
JCheckBox getCbPlant();
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public enum VSubmenuChallenges implements IVSubmenu<CSubmenuChallenges>, IVQuest
|
|||||||
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
||||||
|
|
||||||
private final JButton btnStart = new StartButton();
|
private final JButton btnStart = new StartButton();
|
||||||
private final JComboBox cbxPet = new JComboBox();
|
private final JComboBox<String> cbxPet = new JComboBox<String>();
|
||||||
private final JCheckBox cbPlant = new FCheckBox("Summon Plant");
|
private final JCheckBox cbPlant = new FCheckBox("Summon Plant");
|
||||||
private final JLabel lblZep = new FLabel.Builder().text("<html>Launch<br>Zeppelin</html>")
|
private final JLabel lblZep = new FLabel.Builder().text("<html>Launch<br>Zeppelin</html>")
|
||||||
.hoverable(true).icon(FSkin.getIcon(FSkin.QuestIcons.ICO_ZEP))
|
.hoverable(true).icon(FSkin.getIcon(FSkin.QuestIcons.ICO_ZEP))
|
||||||
@@ -248,7 +248,7 @@ public enum VSubmenuChallenges implements IVSubmenu<CSubmenuChallenges>, IVQuest
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JComboBox getCbxPet() {
|
public JComboBox<String> getCbxPet() {
|
||||||
return cbxPet;
|
return cbxPet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public enum VSubmenuDuels implements IVSubmenu<CSubmenuDuels>, IVQuestStats {
|
|||||||
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
||||||
|
|
||||||
private final JButton btnStart = new StartButton();
|
private final JButton btnStart = new StartButton();
|
||||||
private final JComboBox cbxPet = new JComboBox();
|
private final JComboBox<String> cbxPet = new JComboBox<String>();
|
||||||
private final JCheckBox cbPlant = new FCheckBox("Summon Plant");
|
private final JCheckBox cbPlant = new FCheckBox("Summon Plant");
|
||||||
private final JLabel lblZep = new FLabel.Builder().text("Launch Zeppelin").fontSize(14).build();
|
private final JLabel lblZep = new FLabel.Builder().text("Launch Zeppelin").fontSize(14).build();
|
||||||
|
|
||||||
@@ -241,7 +241,7 @@ public enum VSubmenuDuels implements IVSubmenu<CSubmenuDuels>, IVQuestStats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JComboBox getCbxPet() {
|
public JComboBox<String> getCbxPet() {
|
||||||
return cbxPet;
|
return cbxPet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,33 +79,33 @@ public enum VSubmenuQuestData implements IVSubmenu<CSubmenuQuestData> {
|
|||||||
private final JCheckBox boxFantasy = new FCheckBox("Fantasy Mode");
|
private final JCheckBox boxFantasy = new FCheckBox("Fantasy Mode");
|
||||||
|
|
||||||
private final JLabel lblStartingWorld = new FLabel.Builder().text("Starting world:").build();
|
private final JLabel lblStartingWorld = new FLabel.Builder().text("Starting world:").build();
|
||||||
private final JComboBox cbxStartingWorld = new JComboBox();
|
private final JComboBox<QuestWorld> cbxStartingWorld = new JComboBox<QuestWorld>();
|
||||||
|
|
||||||
|
|
||||||
/* Second column */
|
/* Second column */
|
||||||
|
|
||||||
private final JLabel lblStartingPool = new FLabel.Builder().text("Starting pool:").build();
|
private final JLabel lblStartingPool = new FLabel.Builder().text("Starting pool:").build();
|
||||||
private final JComboBox cbxStartingPool = new JComboBox();
|
private final JComboBox<StartingPoolType> cbxStartingPool = new JComboBox<StartingPoolType>();
|
||||||
|
|
||||||
private final JLabel lblUnrestricted = new FLabel.Builder().text("All cards will be available to play.").build();
|
private final JLabel lblUnrestricted = new FLabel.Builder().text("All cards will be available to play.").build();
|
||||||
|
|
||||||
private final JLabel lblPreconDeck = new FLabel.Builder().text("Starter/Event deck:").build();
|
private final JLabel lblPreconDeck = new FLabel.Builder().text("Starter/Event deck:").build();
|
||||||
private final JComboBox cbxPreconDeck = new JComboBox();
|
private final JComboBox<String> cbxPreconDeck = new JComboBox<String>();
|
||||||
|
|
||||||
private final JLabel lblFormat = new FLabel.Builder().text("Sanctioned format:").build();
|
private final JLabel lblFormat = new FLabel.Builder().text("Sanctioned format:").build();
|
||||||
private final JComboBox cbxFormat = new JComboBox();
|
private final JComboBox<GameFormat> cbxFormat = new JComboBox<GameFormat>();
|
||||||
|
|
||||||
private final JLabel lblCustomDeck = new FLabel.Builder().text("Custom deck:").build();
|
private final JLabel lblCustomDeck = new FLabel.Builder().text("Custom deck:").build();
|
||||||
private final JComboBox cbxCustomDeck = new JComboBox();
|
private final JComboBox<Deck> cbxCustomDeck = new JComboBox<Deck>();
|
||||||
|
|
||||||
private final FLabel btnDefineCustomFormat = new FLabel.Builder().opaque(true).hoverable(true).text("Define custom format").build();
|
private final FLabel btnDefineCustomFormat = new FLabel.Builder().opaque(true).hoverable(true).text("Define custom format").build();
|
||||||
private final FLabel btnPrizeDefineCustomFormat = new FLabel.Builder().opaque(true).hoverable(true).text("Define custom format").build();
|
private final FLabel btnPrizeDefineCustomFormat = new FLabel.Builder().opaque(true).hoverable(true).text("Define custom format").build();
|
||||||
|
|
||||||
private final JLabel lblPrizedCards = new FLabel.Builder().text("Prized cards:").build();
|
private final JLabel lblPrizedCards = new FLabel.Builder().text("Prized cards:").build();
|
||||||
private final JComboBox cbxPrizedCards = new JComboBox();
|
private final JComboBox<Object> cbxPrizedCards = new JComboBox<Object>();
|
||||||
|
|
||||||
private final JLabel lblPrizeFormat = new FLabel.Builder().text("Sanctioned format:").build();
|
private final JLabel lblPrizeFormat = new FLabel.Builder().text("Sanctioned format:").build();
|
||||||
private final JComboBox cbxPrizeFormat = new JComboBox();
|
private final JComboBox<GameFormat> cbxPrizeFormat = new JComboBox<GameFormat>();
|
||||||
|
|
||||||
private final JLabel lblPrizeUnrestricted = new FLabel.Builder().text("All cards will be available to win.").build();
|
private final JLabel lblPrizeUnrestricted = new FLabel.Builder().text("All cards will be available to win.").build();
|
||||||
private final JLabel lblPrizeSameAsStarting = new FLabel.Builder().text("Only sets found in starting pool will be available.").build();
|
private final JLabel lblPrizeSameAsStarting = new FLabel.Builder().text("Only sets found in starting pool will be available.").build();
|
||||||
@@ -197,6 +197,7 @@ public enum VSubmenuQuestData implements IVSubmenu<CSubmenuQuestData> {
|
|||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private VSubmenuQuestData() {
|
private VSubmenuQuestData() {
|
||||||
lblTitle.setBackground(FSkin.getColor(FSkin.Colors.CLR_THEME2));
|
lblTitle.setBackground(FSkin.getColor(FSkin.Colors.CLR_THEME2));
|
||||||
lblTitleNew.setBackground(FSkin.getColor(FSkin.Colors.CLR_THEME2));
|
lblTitleNew.setBackground(FSkin.getColor(FSkin.Colors.CLR_THEME2));
|
||||||
@@ -260,9 +261,11 @@ public enum VSubmenuQuestData implements IVSubmenu<CSubmenuQuestData> {
|
|||||||
preconDescriptions.put(name, description);
|
preconDescriptions.put(name, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The cbx needs strictly typed renderer
|
||||||
cbxPreconDeck.setRenderer(new BasicComboBoxRenderer() {
|
cbxPreconDeck.setRenderer(new BasicComboBoxRenderer() {
|
||||||
private static final long serialVersionUID = 3477357932538947199L;
|
private static final long serialVersionUID = 3477357932538947199L;
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
@Override
|
@Override
|
||||||
public Component getListCellRendererComponent(
|
public Component getListCellRendererComponent(
|
||||||
JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public enum VSubmenuDraft implements IVSubmenu<CSubmenuDraft> {
|
|||||||
private final StartButton btnStart = new StartButton();
|
private final StartButton btnStart = new StartButton();
|
||||||
|
|
||||||
private final DeckLister lstDecks = new DeckLister(GameType.Draft);
|
private final DeckLister lstDecks = new DeckLister(GameType.Draft);
|
||||||
private final JList lstAI = new FList();
|
private final JList<String> lstAI = new FList<String>();
|
||||||
|
|
||||||
private final JRadioButton radSingle = new FRadioButton("Play one opponent");
|
private final JRadioButton radSingle = new FRadioButton("Play one opponent");
|
||||||
private final JRadioButton radAll = new FRadioButton("Play all 7 opponents");
|
private final JRadioButton radAll = new FRadioButton("Play all 7 opponents");
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import java.io.File;
|
|||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.ArrayUtils;
|
||||||
import org.apache.commons.lang3.text.WordUtils;
|
import org.apache.commons.lang3.text.WordUtils;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
@@ -154,7 +155,7 @@ public enum CSubmenuPreferences implements ICDoc {
|
|||||||
|
|
||||||
private void updateSkinNames() {
|
private void updateSkinNames() {
|
||||||
final VSubmenuPreferences view = VSubmenuPreferences.SINGLETON_INSTANCE;
|
final VSubmenuPreferences view = VSubmenuPreferences.SINGLETON_INSTANCE;
|
||||||
final String[] uglyNames = FSkin.getSkins().toArray(new String[0]);
|
final String[] uglyNames = FSkin.getSkins().toArray(ArrayUtils.EMPTY_STRING_ARRAY);
|
||||||
final String[] prettyNames = new String[uglyNames.length];
|
final String[] prettyNames = new String[uglyNames.length];
|
||||||
final String currentName = Singletons.getModel().getPreferences().getPref(FPref.UI_SKIN);
|
final String currentName = Singletons.getModel().getPreferences().getPref(FPref.UI_SKIN);
|
||||||
int currentIndex = 0;
|
int currentIndex = 0;
|
||||||
@@ -171,7 +172,7 @@ public enum CSubmenuPreferences implements ICDoc {
|
|||||||
|
|
||||||
private void updateAIProfiles() {
|
private void updateAIProfiles() {
|
||||||
final VSubmenuPreferences view = VSubmenuPreferences.SINGLETON_INSTANCE;
|
final VSubmenuPreferences view = VSubmenuPreferences.SINGLETON_INSTANCE;
|
||||||
final ArrayList<String> profileNames = AiProfileUtil.getProfilesDisplayList();
|
final List<String> profileNames = AiProfileUtil.getProfilesDisplayList();
|
||||||
final String currentName = Singletons.getModel().getPreferences().getPref(FPref.UI_CURRENT_AI_PROFILE);
|
final String currentName = Singletons.getModel().getPreferences().getPref(FPref.UI_CURRENT_AI_PROFILE);
|
||||||
int currentIndex = 0;
|
int currentIndex = 0;
|
||||||
|
|
||||||
@@ -179,7 +180,7 @@ public enum CSubmenuPreferences implements ICDoc {
|
|||||||
if (currentName.equalsIgnoreCase(profileNames.get(i))) { currentIndex = i; }
|
if (currentName.equalsIgnoreCase(profileNames.get(i))) { currentIndex = i; }
|
||||||
}
|
}
|
||||||
|
|
||||||
view.getLstChooseAIProfile().setListData(profileNames.toArray());
|
view.getLstChooseAIProfile().setListData(profileNames.toArray(ArrayUtils.EMPTY_STRING_ARRAY));
|
||||||
view.getLstChooseAIProfile().setSelectedIndex(currentIndex);
|
view.getLstChooseAIProfile().setSelectedIndex(currentIndex);
|
||||||
view.getLstChooseAIProfile().ensureIndexIsVisible(view.getLstChooseAIProfile().getSelectedIndex());
|
view.getLstChooseAIProfile().ensureIndexIsVisible(view.getLstChooseAIProfile().getSelectedIndex());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
|
|||||||
private final FLabel lblTitleSkin = new FLabel.Builder()
|
private final FLabel lblTitleSkin = new FLabel.Builder()
|
||||||
.text("Choose Skin").fontStyle(Font.BOLD).fontSize(14).build();
|
.text("Choose Skin").fontStyle(Font.BOLD).fontSize(14).build();
|
||||||
|
|
||||||
private final JList lstChooseSkin = new FList();
|
private final JList<String> lstChooseSkin = new FList<String>();
|
||||||
private final FLabel lblChooseSkin = new FLabel.Builder().fontSize(12).fontStyle(Font.ITALIC)
|
private final FLabel lblChooseSkin = new FLabel.Builder().fontSize(12).fontStyle(Font.ITALIC)
|
||||||
.text("Various user-created themes for Forge backgrounds, fonts, and colors.")
|
.text("Various user-created themes for Forge backgrounds, fonts, and colors.")
|
||||||
.fontAlign(SwingConstants.LEFT).build();
|
.fontAlign(SwingConstants.LEFT).build();
|
||||||
@@ -77,7 +77,7 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
|
|||||||
private final FLabel lblTitleAIProfile = new FLabel.Builder()
|
private final FLabel lblTitleAIProfile = new FLabel.Builder()
|
||||||
.text("Choose AI Personality").fontStyle(Font.BOLD).fontSize(14).build();
|
.text("Choose AI Personality").fontStyle(Font.BOLD).fontSize(14).build();
|
||||||
|
|
||||||
private final JList lstChooseAIProfile = new FList();
|
private final JList<String> lstChooseAIProfile = new FList<String>();
|
||||||
private final FLabel lblChooseAIProfile = new FLabel.Builder().fontSize(12).fontStyle(Font.ITALIC)
|
private final FLabel lblChooseAIProfile = new FLabel.Builder().fontSize(12).fontStyle(Font.ITALIC)
|
||||||
.text("AI Opponent Personality.")
|
.text("AI Opponent Personality.")
|
||||||
.fontAlign(SwingConstants.LEFT).build();
|
.fontAlign(SwingConstants.LEFT).build();
|
||||||
@@ -376,7 +376,7 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @return {@link javax.swing.JList} */
|
/** @return {@link javax.swing.JList} */
|
||||||
public final JList getLstChooseSkin() {
|
public final JList<String> getLstChooseSkin() {
|
||||||
return lstChooseSkin;
|
return lstChooseSkin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -391,7 +391,7 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @return {@link javax.swing.JList} */
|
/** @return {@link javax.swing.JList} */
|
||||||
public final JList getLstChooseAIProfile() {
|
public final JList<String> getLstChooseAIProfile() {
|
||||||
return lstChooseAIProfile;
|
return lstChooseAIProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public enum CSubmenuArchenemy implements ICDoc {
|
|||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
// reinit deck list and restore last selections (if any)
|
// reinit deck list and restore last selections (if any)
|
||||||
FList deckList = view.getArchenemySchemes();
|
FList<Object> deckList = view.getArchenemySchemes();
|
||||||
Vector<Object> listData = new Vector<Object>();
|
Vector<Object> listData = new Vector<Object>();
|
||||||
listData.add("Random");
|
listData.add("Random");
|
||||||
listData.add("Generate");
|
listData.add("Generate");
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public enum CSubmenuPlanechase implements ICDoc {
|
|||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
// reinit deck lists and restore last selections (if any)
|
// reinit deck lists and restore last selections (if any)
|
||||||
for (FList deckList : view.getPlanarDeckLists()) {
|
for (FList<Object> deckList : view.getPlanarDeckLists()) {
|
||||||
Vector<Object> listData = new Vector<Object>();
|
Vector<Object> listData = new Vector<Object>();
|
||||||
listData.add("Random");
|
listData.add("Random");
|
||||||
listData.add("Generate");
|
listData.add("Generate");
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public enum VSubmenuArchenemy implements IVSubmenu<CSubmenuArchenemy> {
|
|||||||
private final FTabbedPane tabPane = new FTabbedPane();
|
private final FTabbedPane tabPane = new FTabbedPane();
|
||||||
private final List<FPanel> playerPanels = new ArrayList<FPanel>();
|
private final List<FPanel> playerPanels = new ArrayList<FPanel>();
|
||||||
private final List<FDeckChooser> deckChoosers = new ArrayList<FDeckChooser>();
|
private final List<FDeckChooser> deckChoosers = new ArrayList<FDeckChooser>();
|
||||||
private final FList archenemySchemes = new FList();
|
private final FList<Object> archenemySchemes = new FList<Object>();
|
||||||
private final List<Deck> allSchemeDecks = new ArrayList<Deck>();
|
private final List<Deck> allSchemeDecks = new ArrayList<Deck>();
|
||||||
private final JCheckBox cbUseDefaultSchemes = new FCheckBox("Use default scheme decks if possible.");
|
private final JCheckBox cbUseDefaultSchemes = new FCheckBox("Use default scheme decks if possible.");
|
||||||
private final List<JRadioButton> fieldRadios = new ArrayList<JRadioButton>();
|
private final List<JRadioButton> fieldRadios = new ArrayList<JRadioButton>();
|
||||||
@@ -314,7 +314,7 @@ public enum VSubmenuArchenemy implements IVSubmenu<CSubmenuArchenemy> {
|
|||||||
/**
|
/**
|
||||||
* @return the archenemySchemes
|
* @return the archenemySchemes
|
||||||
*/
|
*/
|
||||||
public FList getArchenemySchemes() {
|
public FList<Object> getArchenemySchemes() {
|
||||||
return archenemySchemes;
|
return archenemySchemes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ public enum VSubmenuPlanechase implements IVSubmenu<CSubmenuPlanechase> {
|
|||||||
private final FTabbedPane tabPane = new FTabbedPane();
|
private final FTabbedPane tabPane = new FTabbedPane();
|
||||||
private final List<FPanel> playerPanels = new ArrayList<FPanel>();
|
private final List<FPanel> playerPanels = new ArrayList<FPanel>();
|
||||||
private final List<FDeckChooser> deckChoosers = new ArrayList<FDeckChooser>();
|
private final List<FDeckChooser> deckChoosers = new ArrayList<FDeckChooser>();
|
||||||
private final List<FList> planarDeckLists = new ArrayList<FList>();
|
private final List<FList<Object>> planarDeckLists = new ArrayList<FList<Object>>();
|
||||||
private final List<Deck> allPlanarDecks = new ArrayList<Deck>();
|
private final List<Deck> allPlanarDecks = new ArrayList<Deck>();
|
||||||
private final JCheckBox cbUseDefaultPlanes = new FCheckBox("Use default planar decks if possible.");
|
private final JCheckBox cbUseDefaultPlanes = new FCheckBox("Use default planar decks if possible.");
|
||||||
private final List<JRadioButton> fieldRadios = new ArrayList<JRadioButton>();
|
private final List<JRadioButton> fieldRadios = new ArrayList<JRadioButton>();
|
||||||
@@ -96,7 +96,7 @@ public enum VSubmenuPlanechase implements IVSubmenu<CSubmenuPlanechase> {
|
|||||||
FRadioButton tempRadio = null;
|
FRadioButton tempRadio = null;
|
||||||
FPanel tempPanel;
|
FPanel tempPanel;
|
||||||
FDeckChooser tempChooser;
|
FDeckChooser tempChooser;
|
||||||
FList tempPlanarDeckList;
|
FList<Object> tempPlanarDeckList;
|
||||||
|
|
||||||
//Settings panel
|
//Settings panel
|
||||||
FPanel settingsPanel = new FPanel();
|
FPanel settingsPanel = new FPanel();
|
||||||
@@ -133,7 +133,7 @@ public enum VSubmenuPlanechase implements IVSubmenu<CSubmenuPlanechase> {
|
|||||||
|
|
||||||
tempPanel.add(new FLabel.Builder().text("Select Planar deck:").build(), "gap 0px 0px 10px 10px, flowy");
|
tempPanel.add(new FLabel.Builder().text("Select Planar deck:").build(), "gap 0px 0px 10px 10px, flowy");
|
||||||
|
|
||||||
tempPlanarDeckList = new FList();
|
tempPlanarDeckList = new FList<Object>();
|
||||||
|
|
||||||
tempPlanarDeckList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
|
tempPlanarDeckList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
|
||||||
|
|
||||||
@@ -315,7 +315,7 @@ public enum VSubmenuPlanechase implements IVSubmenu<CSubmenuPlanechase> {
|
|||||||
/**
|
/**
|
||||||
* @return the archenemySchemes
|
* @return the archenemySchemes
|
||||||
*/
|
*/
|
||||||
public List<FList> getPlanarDeckLists() {
|
public List<FList<Object>> getPlanarDeckLists() {
|
||||||
return planarDeckLists;
|
return planarDeckLists;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ public enum VSubmenuVanguard implements IVSubmenu<CSubmenuVanguard> {
|
|||||||
private final FTabbedPane tabPane = new FTabbedPane();
|
private final FTabbedPane tabPane = new FTabbedPane();
|
||||||
private final List<FPanel> playerPanels = new ArrayList<FPanel>();
|
private final List<FPanel> playerPanels = new ArrayList<FPanel>();
|
||||||
private final List<FDeckChooser> deckChoosers = new ArrayList<FDeckChooser>();
|
private final List<FDeckChooser> deckChoosers = new ArrayList<FDeckChooser>();
|
||||||
private final List<FList> avatarLists = new ArrayList<FList>();
|
private final List<FList<Object>> avatarLists = new ArrayList<FList<Object>>();
|
||||||
|
|
||||||
private final List<JRadioButton> fieldRadios = new ArrayList<JRadioButton>();
|
private final List<JRadioButton> fieldRadios = new ArrayList<JRadioButton>();
|
||||||
private final ButtonGroup grpFields = new ButtonGroup();
|
private final ButtonGroup grpFields = new ButtonGroup();
|
||||||
@@ -142,7 +142,7 @@ public enum VSubmenuVanguard implements IVSubmenu<CSubmenuVanguard> {
|
|||||||
FRadioButton tempRadio = null;
|
FRadioButton tempRadio = null;
|
||||||
FPanel tempPanel;
|
FPanel tempPanel;
|
||||||
FDeckChooser tempChooser;
|
FDeckChooser tempChooser;
|
||||||
FList tempList;
|
FList<Object> tempList;
|
||||||
CardDetailPanel tempDetail;
|
CardDetailPanel tempDetail;
|
||||||
|
|
||||||
//Settings panel
|
//Settings panel
|
||||||
@@ -173,7 +173,7 @@ public enum VSubmenuVanguard implements IVSubmenu<CSubmenuVanguard> {
|
|||||||
tempChooser = new FDeckChooser("Select deck:", i != 0);
|
tempChooser = new FDeckChooser("Select deck:", i != 0);
|
||||||
tempChooser.initialize();
|
tempChooser.initialize();
|
||||||
|
|
||||||
tempList = new FList();
|
tempList = new FList<Object>();
|
||||||
|
|
||||||
tempList.setListData(i == 0 ? humanListData : aiListData);
|
tempList.setListData(i == 0 ? humanListData : aiListData);
|
||||||
tempList.setSelectedIndex(0);
|
tempList.setSelectedIndex(0);
|
||||||
@@ -348,7 +348,7 @@ public enum VSubmenuVanguard implements IVSubmenu<CSubmenuVanguard> {
|
|||||||
/**
|
/**
|
||||||
* @return the avatarLists
|
* @return the avatarLists
|
||||||
*/
|
*/
|
||||||
public List<FList> getAvatarLists() {
|
public List<FList<Object>> getAvatarLists() {
|
||||||
return avatarLists;
|
return avatarLists;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class QuestWinLoseCardViewer extends FPanel {
|
|||||||
private final List<PaperCard> list;
|
private final List<PaperCard> list;
|
||||||
|
|
||||||
// initialized before; listeners may be added to it
|
// initialized before; listeners may be added to it
|
||||||
private final JList jList;
|
private final JList<PaperCard> jList;
|
||||||
private final CardDetailPanel detail;
|
private final CardDetailPanel detail;
|
||||||
private final CardPicturePanel picture;
|
private final CardPicturePanel picture;
|
||||||
private final FScrollPane scroller;
|
private final FScrollPane scroller;
|
||||||
@@ -60,7 +60,7 @@ public class QuestWinLoseCardViewer extends FPanel {
|
|||||||
*/
|
*/
|
||||||
public QuestWinLoseCardViewer(final List<PaperCard> list) {
|
public QuestWinLoseCardViewer(final List<PaperCard> list) {
|
||||||
this.list = Collections.unmodifiableList(list);
|
this.list = Collections.unmodifiableList(list);
|
||||||
this.jList = new FList(new ChooserListModel());
|
this.jList = new FList<PaperCard>(new ChooserListModel());
|
||||||
this.detail = new CardDetailPanel(null);
|
this.detail = new CardDetailPanel(null);
|
||||||
this.picture = new CardPicturePanel();
|
this.picture = new CardPicturePanel();
|
||||||
this.scroller = new FScrollPane(this.jList);
|
this.scroller = new FScrollPane(this.jList);
|
||||||
@@ -81,7 +81,7 @@ public class QuestWinLoseCardViewer extends FPanel {
|
|||||||
this.jList.setSelectedIndex(0);
|
this.jList.setSelectedIndex(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ChooserListModel extends AbstractListModel {
|
private class ChooserListModel extends AbstractListModel<PaperCard> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 3871965346333840556L;
|
private static final long serialVersionUID = 3871965346333840556L;
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ public class QuestWinLoseCardViewer extends FPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getElementAt(final int index) {
|
public PaperCard getElementAt(final int index) {
|
||||||
return QuestWinLoseCardViewer.this.list.get(index);
|
return QuestWinLoseCardViewer.this.list.get(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class CardViewer extends JPanel {
|
|||||||
private final List<PaperCard> list;
|
private final List<PaperCard> list;
|
||||||
|
|
||||||
// initialized before; listeners may be added to it
|
// initialized before; listeners may be added to it
|
||||||
private JList jList = null;
|
private JList<PaperCard> jList = null;
|
||||||
private final CardDetailPanel detail;
|
private final CardDetailPanel detail;
|
||||||
private final CardPicturePanel picture;
|
private final CardPicturePanel picture;
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ public class CardViewer extends JPanel {
|
|||||||
*/
|
*/
|
||||||
public CardViewer(final List<PaperCard> list) {
|
public CardViewer(final List<PaperCard> list) {
|
||||||
this.list = Collections.unmodifiableList(list);
|
this.list = Collections.unmodifiableList(list);
|
||||||
this.jList = new JList(new ChooserListModel());
|
this.jList = new JList<PaperCard>(new ChooserListModel());
|
||||||
this.detail = new CardDetailPanel(null);
|
this.detail = new CardDetailPanel(null);
|
||||||
this.picture = new CardPicturePanel();
|
this.picture = new CardPicturePanel();
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ public class CardViewer extends JPanel {
|
|||||||
this.jList.setSelectedIndex(0);
|
this.jList.setSelectedIndex(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ChooserListModel extends AbstractListModel {
|
private class ChooserListModel extends AbstractListModel<PaperCard> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 3871965346333840556L;
|
private static final long serialVersionUID = 3871965346333840556L;
|
||||||
|
|
||||||
@@ -80,7 +80,7 @@ public class CardViewer extends JPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getElementAt(final int index) {
|
public PaperCard getElementAt(final int index) {
|
||||||
return CardViewer.this.list.get(index);
|
return CardViewer.this.list.get(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,11 +22,11 @@ import javax.swing.border.EmptyBorder;
|
|||||||
* based on code at http://www.devx.com/tips/Tip/5342
|
* based on code at http://www.devx.com/tips/Tip/5342
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class FCheckBoxList extends JList {
|
public class FCheckBoxList<E> extends JList<E> {
|
||||||
protected static Border noFocusBorder = new EmptyBorder(1, 1, 1, 1);
|
protected static Border noFocusBorder = new EmptyBorder(1, 1, 1, 1);
|
||||||
|
|
||||||
public FCheckBoxList(boolean keepSelectionWhenFocusLost) {
|
public FCheckBoxList(boolean keepSelectionWhenFocusLost) {
|
||||||
setCellRenderer(new CellRenderer());
|
setCellRenderer(new CellRenderer<E>());
|
||||||
|
|
||||||
addMouseListener(new MouseAdapter() {
|
addMouseListener(new MouseAdapter() {
|
||||||
@Override
|
@Override
|
||||||
@@ -80,8 +80,8 @@ public class FCheckBoxList extends JList {
|
|||||||
setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class CellRenderer implements ListCellRenderer {
|
protected class CellRenderer<E1> implements ListCellRenderer<E1> {
|
||||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
public Component getListCellRendererComponent(JList<? extends E1> list, E1 value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
FCheckBox checkbox = (FCheckBox)value;
|
FCheckBox checkbox = (FCheckBox)value;
|
||||||
checkbox.setBackground(isSelected ? getSelectionBackground() : getBackground());
|
checkbox.setBackground(isSelected ? getSelectionBackground() : getBackground());
|
||||||
checkbox.setForeground(isSelected ? getSelectionForeground() : getForeground());
|
checkbox.setForeground(isSelected ? getSelectionForeground() : getForeground());
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import java.awt.Font;
|
|||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.swing.JList;
|
import javax.swing.JList;
|
||||||
@@ -42,7 +41,7 @@ public class FDeckChooser extends JPanel {
|
|||||||
private final JRadioButton radQuests = new FRadioButton("Quest opponent deck");
|
private final JRadioButton radQuests = new FRadioButton("Quest opponent deck");
|
||||||
private final JRadioButton radPrecons = new FRadioButton("Decks from quest shop");
|
private final JRadioButton radPrecons = new FRadioButton("Decks from quest shop");
|
||||||
|
|
||||||
private final JList lstDecks = new FList();
|
private final JList<String> lstDecks = new FList<String>();
|
||||||
private final FLabel btnRandom = new FLabel.ButtonBuilder().text("Random").fontSize(16).build();
|
private final FLabel btnRandom = new FLabel.ButtonBuilder().text("Random").fontSize(16).build();
|
||||||
private final FLabel btnChange = new FLabel.ButtonBuilder().text("Change player type").fontSize(16).build();
|
private final FLabel btnChange = new FLabel.ButtonBuilder().text("Change player type").fontSize(16).build();
|
||||||
|
|
||||||
@@ -59,10 +58,11 @@ public class FDeckChooser extends JPanel {
|
|||||||
private boolean isAi;
|
private boolean isAi;
|
||||||
|
|
||||||
private final MouseAdapter madDecklist = new MouseAdapter() {
|
private final MouseAdapter madDecklist = new MouseAdapter() {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(final MouseEvent e) {
|
public void mouseClicked(final MouseEvent e) {
|
||||||
if (MouseEvent.BUTTON1 == e.getButton() && e.getClickCount() == 2) {
|
if (MouseEvent.BUTTON1 == e.getButton() && e.getClickCount() == 2) {
|
||||||
final JList src = ((JList) e.getSource());
|
final JList<String> src = ((JList<String>) e.getSource());
|
||||||
if (getRadColors().isSelected() || getRadThemes().isSelected()) { return; }
|
if (getRadColors().isSelected() || getRadThemes().isSelected()) { return; }
|
||||||
DeckgenUtil.showDecklist(src);
|
DeckgenUtil.showDecklist(src);
|
||||||
}
|
}
|
||||||
@@ -137,7 +137,7 @@ public class FDeckChooser extends JPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private JList getLstDecks() { return lstDecks; }
|
private JList<String> getLstDecks() { return lstDecks; }
|
||||||
private FLabel getBtnRandom() { return btnRandom; }
|
private FLabel getBtnRandom() { return btnRandom; }
|
||||||
private JRadioButton getRadColors() { return radColors; }
|
private JRadioButton getRadColors() { return radColors; }
|
||||||
private JRadioButton getRadThemes() { return radThemes; }
|
private JRadioButton getRadThemes() { return radThemes; }
|
||||||
@@ -147,7 +147,7 @@ public class FDeckChooser extends JPanel {
|
|||||||
|
|
||||||
/** Handles all control for "colors" radio button click. */
|
/** Handles all control for "colors" radio button click. */
|
||||||
private void updateColors() {
|
private void updateColors() {
|
||||||
final JList lst = getLstDecks();
|
final JList<String> lst = getLstDecks();
|
||||||
lst.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
|
lst.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
|
||||||
|
|
||||||
lst.setListData(new String[] {"Random 1", "Random 2", "Random 3", "Black", "Blue", "Green", "Red", "White"});
|
lst.setListData(new String[] {"Random 1", "Random 2", "Random 3", "Black", "Blue", "Green", "Red", "White"});
|
||||||
@@ -165,7 +165,7 @@ public class FDeckChooser extends JPanel {
|
|||||||
|
|
||||||
/** Handles all control for "themes" radio button click. */
|
/** Handles all control for "themes" radio button click. */
|
||||||
private void updateThemes() {
|
private void updateThemes() {
|
||||||
final JList lst = getLstDecks();
|
final JList<String> lst = getLstDecks();
|
||||||
lst.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
lst.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||||
|
|
||||||
lst.removeMouseListener(madDecklist);
|
lst.removeMouseListener(madDecklist);
|
||||||
@@ -188,7 +188,7 @@ public class FDeckChooser extends JPanel {
|
|||||||
|
|
||||||
/** Handles all control for "custom" radio button click. */
|
/** Handles all control for "custom" radio button click. */
|
||||||
private void updateCustom() {
|
private void updateCustom() {
|
||||||
final JList lst = getLstDecks();
|
final JList<String> lst = getLstDecks();
|
||||||
lst.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
lst.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||||
|
|
||||||
final List<String> customNames = new ArrayList<String>();
|
final List<String> customNames = new ArrayList<String>();
|
||||||
@@ -210,7 +210,7 @@ public class FDeckChooser extends JPanel {
|
|||||||
|
|
||||||
/** Handles all control for "custom" radio button click. */
|
/** Handles all control for "custom" radio button click. */
|
||||||
private void updatePrecons() {
|
private void updatePrecons() {
|
||||||
final JList lst = getLstDecks();
|
final JList<String> lst = getLstDecks();
|
||||||
lst.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
lst.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||||
|
|
||||||
final List<String> customNames = new ArrayList<String>();
|
final List<String> customNames = new ArrayList<String>();
|
||||||
@@ -232,7 +232,7 @@ public class FDeckChooser extends JPanel {
|
|||||||
|
|
||||||
/** Handles all control for "quest event" radio button click. */
|
/** Handles all control for "quest event" radio button click. */
|
||||||
private void updateQuestEvents() {
|
private void updateQuestEvents() {
|
||||||
final JList lst = getLstDecks();
|
final JList<String> lst = getLstDecks();
|
||||||
lst.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
lst.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||||
|
|
||||||
final List<String> eventNames = new ArrayList<String>();
|
final List<String> eventNames = new ArrayList<String>();
|
||||||
@@ -263,14 +263,14 @@ public class FDeckChooser extends JPanel {
|
|||||||
public RegisteredPlayer getDeck() {
|
public RegisteredPlayer getDeck() {
|
||||||
|
|
||||||
|
|
||||||
JList lst0 = getLstDecks();
|
JList<String> lst0 = getLstDecks();
|
||||||
final String[] selection = Arrays.copyOf(lst0.getSelectedValues(), lst0.getSelectedValues().length, String[].class);
|
final List<String> selection = lst0.getSelectedValuesList();
|
||||||
|
|
||||||
if (selection.length == 0) { return null; }
|
if (selection.isEmpty()) { return null; }
|
||||||
|
|
||||||
// Special branch for quest events
|
// Special branch for quest events
|
||||||
if (lst0.getName().equals(DeckgenUtil.DeckTypes.QUESTEVENTS.toString())) {
|
if (lst0.getName().equals(DeckgenUtil.DeckTypes.QUESTEVENTS.toString())) {
|
||||||
QuestEvent event = DeckgenUtil.getQuestEvent(selection[0]);
|
QuestEvent event = DeckgenUtil.getQuestEvent(selection.get(0));
|
||||||
RegisteredPlayer result = new RegisteredPlayer(event.getEventDeck());
|
RegisteredPlayer result = new RegisteredPlayer(event.getEventDeck());
|
||||||
if( event instanceof QuestEventChallenge ) {
|
if( event instanceof QuestEventChallenge ) {
|
||||||
result.setStartingLife(((QuestEventChallenge) event).getAiLife());
|
result.setStartingLife(((QuestEventChallenge) event).getAiLife());
|
||||||
@@ -283,11 +283,11 @@ public class FDeckChooser extends JPanel {
|
|||||||
if (lst0.getName().equals(DeckgenUtil.DeckTypes.COLORS.toString()) && DeckgenUtil.colorCheck(selection)) {
|
if (lst0.getName().equals(DeckgenUtil.DeckTypes.COLORS.toString()) && DeckgenUtil.colorCheck(selection)) {
|
||||||
deck = DeckgenUtil.buildColorDeck(selection, isAi);
|
deck = DeckgenUtil.buildColorDeck(selection, isAi);
|
||||||
} else if (lst0.getName().equals(DeckgenUtil.DeckTypes.THEMES.toString())) {
|
} else if (lst0.getName().equals(DeckgenUtil.DeckTypes.THEMES.toString())) {
|
||||||
deck = DeckgenUtil.buildThemeDeck(selection);
|
deck = DeckgenUtil.buildThemeDeck(selection.get(0));
|
||||||
} else if (lst0.getName().equals(DeckgenUtil.DeckTypes.CUSTOM.toString())) {
|
} else if (lst0.getName().equals(DeckgenUtil.DeckTypes.CUSTOM.toString())) {
|
||||||
deck = DeckgenUtil.getConstructedDeck(selection);
|
deck = DeckgenUtil.getConstructedDeck(selection.get(0));
|
||||||
} else if (lst0.getName().equals(DeckgenUtil.DeckTypes.PRECON.toString())) {
|
} else if (lst0.getName().equals(DeckgenUtil.DeckTypes.PRECON.toString())) {
|
||||||
deck = DeckgenUtil.getPreconDeck(selection);
|
deck = DeckgenUtil.getPreconDeck(selection.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
return RegisteredPlayer.fromDeck(deck);
|
return RegisteredPlayer.fromDeck(deck);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package forge.gui.toolbox;
|
package forge.gui.toolbox;
|
||||||
|
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
|
|
||||||
import javax.swing.DefaultListCellRenderer;
|
import javax.swing.DefaultListCellRenderer;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JList;
|
import javax.swing.JList;
|
||||||
@@ -14,35 +13,21 @@ import javax.swing.border.EmptyBorder;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class FList extends JList {
|
public class FList<E> extends JList<E> {
|
||||||
/**
|
|
||||||
* A JList object using Forge skin properties.
|
|
||||||
* This constructor assumes list contents are null and will be set later.
|
|
||||||
*/
|
|
||||||
public FList() {
|
public FList() {
|
||||||
this(new Object[] {});
|
super();
|
||||||
|
applySkin();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* A JList object using Forge skin properties.
|
|
||||||
* This constructor assumes list contents are null and will be set later.
|
|
||||||
* This constructor is used for naming a list at instantiation.
|
|
||||||
* @param name0   {@link java.lang.String}
|
|
||||||
*/
|
|
||||||
public FList(final String name0) {
|
|
||||||
this(new Object[] {});
|
|
||||||
this.setName(name0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A JList object using Forge skin properties.
|
* A JList object using Forge skin properties.
|
||||||
* This constructor assumes list contents are null and will be set later.
|
* This constructor assumes list contents are null and will be set later.
|
||||||
* This constructor is used for applying a list model at instantiation.
|
* This constructor is used for applying a list model at instantiation.
|
||||||
* @param model0   {@link javax.swing.ListModel}
|
* @param model0   {@link javax.swing.ListModel}
|
||||||
*/
|
*/
|
||||||
public FList(final ListModel model0) {
|
public FList(final ListModel<E> model0) {
|
||||||
this(new Object[] {});
|
super(model0);
|
||||||
this.setModel(model0);
|
applySkin();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -51,19 +36,26 @@ public class FList extends JList {
|
|||||||
*
|
*
|
||||||
* @param o0 {@link java.lang.Object}[]
|
* @param o0 {@link java.lang.Object}[]
|
||||||
*/
|
*/
|
||||||
public FList(Object[] o0) {
|
public FList(E[] o0) {
|
||||||
super(o0);
|
super(o0);
|
||||||
|
applySkin();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Write javadoc for this method.
|
||||||
|
*/
|
||||||
|
private void applySkin() {
|
||||||
setBackground(FSkin.getColor(FSkin.Colors.CLR_THEME2));
|
setBackground(FSkin.getColor(FSkin.Colors.CLR_THEME2));
|
||||||
|
|
||||||
ListCellRenderer renderer = new ComplexCellRenderer();
|
ListCellRenderer<E> renderer = new ComplexCellRenderer<E>();
|
||||||
setCellRenderer(renderer);
|
setCellRenderer(renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ComplexCellRenderer implements ListCellRenderer {
|
private class ComplexCellRenderer<E1> implements ListCellRenderer<E1> {
|
||||||
private DefaultListCellRenderer defaultRenderer = new DefaultListCellRenderer();
|
private DefaultListCellRenderer defaultRenderer = new DefaultListCellRenderer();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component getListCellRendererComponent(JList lst0, Object val0, int i0,
|
public Component getListCellRendererComponent(JList<? extends E1> lst0, E1 val0, int i0,
|
||||||
boolean isSelected, boolean cellHasFocus) {
|
boolean isSelected, boolean cellHasFocus) {
|
||||||
|
|
||||||
JLabel lblItem = (JLabel) defaultRenderer.getListCellRendererComponent(
|
JLabel lblItem = (JLabel) defaultRenderer.getListCellRendererComponent(
|
||||||
|
|||||||
Reference in New Issue
Block a user