Huge cleanup of gui and desktop code 2
| Index: forge-gui/src/main/java/forge/download/GuiDownloadService.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui/src/main/java/forge/download/GuiDownloadService.java (revision 29316) | |
| +++ forge-gui/src/main/java/forge/download/GuiDownloadService.java (revision 29317) | |
| @@ -320,12 +320,10 @@ | |
| protected Proxy getProxy() { | |
| if (type == 0) { | |
| return Proxy.NO_PROXY; | |
| - } | |
| - else { | |
| + } else { | |
| try { | |
| return new Proxy(TYPES[type], new InetSocketAddress(txtAddress.getText(), Integer.parseInt(txtPort.getText()))); | |
| - } | |
| - catch (final Exception ex) { | |
| + } catch (final Exception ex) { | |
| BugReporter.reportException(ex, | |
| "Proxy connection could not be established!\nProxy address: %s\nProxy port: %s", | |
| txtAddress.getText(), txtPort.getText()); | |
| Index: forge-gui-desktop/src/main/java/forge/gui/CardListViewer.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/gui/CardListViewer.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/gui/CardListViewer.java (revision 29317) | |
| @@ -6,12 +6,12 @@ | |
| * 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 <http://www.gnu.org/licenses/>. | |
| */ | |
| @@ -43,7 +43,7 @@ | |
| /** | |
| * A simple class that shows a list of cards in a dialog with preview in its | |
| * right part. | |
| - * | |
| + * | |
| * @author Forge | |
| * @version $Id: ListChooser.java 9708 2011-08-09 19:34:12Z jendave $ | |
| */ | |
| @@ -60,7 +60,7 @@ | |
| /** | |
| * Instantiates a new card list viewer. | |
| - * | |
| + * | |
| * @param title | |
| * the title | |
| * @param list | |
| @@ -72,7 +72,7 @@ | |
| /** | |
| * Instantiates a new card list viewer. | |
| - * | |
| + * | |
| * @param title | |
| * the title | |
| * @param message | |
| @@ -86,7 +86,7 @@ | |
| /** | |
| * Instantiates a new card list viewer. | |
| - * | |
| + * | |
| * @param title | |
| * the title | |
| * @param message | |
| @@ -104,16 +104,16 @@ | |
| this.picture.setOpaque(false); | |
| this.setTitle(title); | |
| - | |
| + | |
| if (FModel.getPreferences().getPrefBoolean(FPref.UI_LARGE_CARD_VIEWERS)) { | |
| this.setSize(1200, 825); | |
| } else { | |
| this.setSize(720, 374); | |
| } | |
| - | |
| + | |
| this.addWindowFocusListener(new CardListFocuser()); | |
| - FButton btnOK = new FButton("OK"); | |
| + final FButton btnOK = new FButton("OK"); | |
| btnOK.addActionListener(new ActionListener() { | |
| @Override | |
| public void actionPerformed(final ActionEvent e) { | |
| Index: forge-gui-desktop/src/main/java/forge/toolbox/FList.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/toolbox/FList.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/toolbox/FList.java (revision 29317) | |
| @@ -1,16 +1,21 @@ | |
| package forge.toolbox; | |
| -import forge.Singletons; | |
| -import forge.toolbox.FSkin.SkinnedList; | |
| +import java.awt.Component; | |
| +import java.awt.FontMetrics; | |
| +import java.awt.event.FocusEvent; | |
| +import java.awt.event.FocusListener; | |
| -import javax.swing.*; | |
| +import javax.swing.DefaultListCellRenderer; | |
| +import javax.swing.JLabel; | |
| +import javax.swing.JList; | |
| +import javax.swing.ListCellRenderer; | |
| +import javax.swing.ListModel; | |
| import javax.swing.border.EmptyBorder; | |
| -import java.awt.*; | |
| -import java.awt.event.FocusEvent; | |
| -import java.awt.event.FocusListener; | |
| +import forge.Singletons; | |
| +import forge.toolbox.FSkin.SkinnedList; | |
| -/** | |
| +/** | |
| * A JList object using Forge skin properties. | |
| * | |
| */ | |
| @@ -22,7 +27,8 @@ | |
| super(); | |
| initialize(); | |
| } | |
| + | |
| - /** | |
| + /** | |
| * A JList object using Forge skin properties. | |
| * This constructor assumes list contents are null and will be set later. | |
| * This constructor is used for applying a list model at instantiation. | |
| @@ -33,17 +39,6 @@ | |
| initialize(); | |
| } | |
| - /** | |
| - * A JList object using Forge skin properties. | |
| - * This constructor may be passed an object array of list contents. | |
| - * | |
| - * @param o0 {@link java.lang.Object}[] | |
| - */ | |
| - public FList(E[] o0) { | |
| - super(o0); | |
| - initialize(); | |
| - } | |
| - | |
| private void initialize() { | |
| this.setBackground(FSkin.getColor(FSkin.Colors.CLR_THEME2)); | |
| this.setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT)); | |
| @@ -53,12 +48,12 @@ | |
| this.addFocusListener(new FocusListener() { | |
| @Override | |
| - public void focusGained(FocusEvent arg0) { | |
| + public void focusGained(final FocusEvent arg0) { | |
| updateSelectionBackground(); | |
| } | |
| @Override | |
| - public void focusLost(FocusEvent arg0) { | |
| + public void focusLost(final FocusEvent arg0) { | |
| updateSelectionBackground(); | |
| } | |
| }); | |
| @@ -70,22 +65,22 @@ | |
| } | |
| public int getAutoSizeWidth() { | |
| - FontMetrics metrics = this.getFontMetrics(this.getFont()); | |
| + final FontMetrics metrics = this.getFontMetrics(this.getFont()); | |
| int width = 0; | |
| for (int i = 0; i < this.getModel().getSize(); i++) { | |
| - int itemWidth = metrics.stringWidth(this.getModel().getElementAt(i).toString()); | |
| + final int itemWidth = metrics.stringWidth(this.getModel().getElementAt(i).toString()); | |
| if (itemWidth > width) { | |
| width = itemWidth; | |
| } | |
| } | |
| width += itemBorder.getBorderInsets().left + itemBorder.getBorderInsets().right; //account for item border insets | |
| - int minWidth = 150; | |
| + final int minWidth = 150; | |
| if (width < minWidth) { | |
| width = minWidth; | |
| } | |
| else { | |
| - int maxWidth = Singletons.getView().getFrame().getWidth() - 50; | |
| + final int maxWidth = Singletons.getView().getFrame().getWidth() - 50; | |
| if (width > maxWidth) { | |
| width = maxWidth; | |
| } | |
| @@ -98,13 +93,13 @@ | |
| } | |
| private class ComplexCellRenderer<E1> implements ListCellRenderer<E1> { | |
| - private DefaultListCellRenderer defaultRenderer = new DefaultListCellRenderer(); | |
| + private final DefaultListCellRenderer defaultRenderer = new DefaultListCellRenderer(); | |
| @Override | |
| - public Component getListCellRendererComponent(JList<? extends E1> lst0, E1 val0, int i0, | |
| - boolean isSelected, boolean cellHasFocus) { | |
| + public Component getListCellRendererComponent(final JList<? extends E1> lst0, final E1 val0, final int i0, | |
| + final boolean isSelected, final boolean cellHasFocus) { | |
| - JLabel lblItem = (JLabel) defaultRenderer.getListCellRendererComponent( | |
| + final JLabel lblItem = (JLabel) defaultRenderer.getListCellRendererComponent( | |
| lst0, val0, i0, isSelected, cellHasFocus); | |
| lblItem.setBorder(itemBorder); | |
| return lblItem; | |
| Index: forge-gui-desktop/src/test/java/forge/GuiDownloadPicturesLQTest.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/test/java/forge/GuiDownloadPicturesLQTest.java (revision 29316) | |
| +++ forge-gui-desktop/src/test/java/forge/GuiDownloadPicturesLQTest.java (revision 29317) | |
| @@ -1,10 +1,10 @@ | |
| package forge; | |
| +import org.testng.annotations.Test; | |
| + | |
| import forge.download.GuiDownloadPicturesLQ; | |
| import forge.download.GuiDownloader; | |
| -import org.testng.annotations.Test; | |
| - | |
| /** | |
| * Created by IntelliJ IDEA. User: dhudson | |
| */ | |
| @@ -16,6 +16,6 @@ | |
| */ | |
| @Test(enabled = false, timeOut = 1000) | |
| public void guiDownloadPicturesTest1() { | |
| - new GuiDownloader(new GuiDownloadPicturesLQ()); | |
| + new GuiDownloader(new GuiDownloadPicturesLQ()).show(); | |
| } | |
| } | |
| Index: forge-core/src/main/java/forge/util/storage/IStorage.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-core/src/main/java/forge/util/storage/IStorage.java (revision 29316) | |
| +++ forge-core/src/main/java/forge/util/storage/IStorage.java (revision 29317) | |
| @@ -6,35 +6,31 @@ | |
| * 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 <http://www.gnu.org/licenses/>. | |
| */ | |
| package forge.util.storage; | |
| +import java.util.Collection; | |
| + | |
| import com.google.common.base.Predicate; | |
| + | |
| import forge.util.IHasName; | |
| -import java.util.Collection; | |
| - | |
| -/** | |
| - * TODO: Write javadoc for this type. | |
| - * | |
| - * @param <T> the generic type | |
| - */ | |
| public interface IStorage<T> extends Iterable<T>, IHasName { | |
| - T get(final String name); | |
| - T find(final Predicate<T> condition); | |
| + T get(String name); | |
| + T find(Predicate<T> condition); | |
| Collection<String> getItemNames(); | |
| - boolean contains(final String name); | |
| + boolean contains(String name); | |
| int size(); | |
| - void add(final T deck); | |
| - void delete(final String deckName); | |
| + void add(T item); | |
| + void delete(String deckName); | |
| IStorage<IStorage<T>> getFolders(); | |
| IStorage<T> tryGetFolder(String path); | |
| IStorage<T> getFolderOrCreate(String path); | |
| \ No newline at end of file | |
| Index: forge-gui-desktop/src/main/java/forge/screens/workshop/CWorkshopUI.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/workshop/CWorkshopUI.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/workshop/CWorkshopUI.java (revision 29317) | |
| @@ -6,12 +6,12 @@ | |
| * 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 <http://www.gnu.org/licenses/>. | |
| */ | |
| @@ -22,7 +22,6 @@ | |
| import javax.swing.JMenu; | |
| import forge.Singletons; | |
| -import forge.UiCommand; | |
| import forge.gui.framework.EDocID; | |
| import forge.gui.framework.ICDoc; | |
| import forge.menus.IMenuProvider; | |
| @@ -35,7 +34,7 @@ | |
| * 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. | |
| - * | |
| + * | |
| * <br><br><i>(C at beginning of class name denotes a control class.)</i> | |
| */ | |
| public enum CWorkshopUI implements ICDoc, IMenuProvider { | |
| @@ -51,14 +50,6 @@ | |
| @Override | |
| public List<JMenu> getMenus() { | |
| return new CWorkshopUIMenus().getMenus(); | |
| - } | |
| - | |
| - /* (non-Javadoc) | |
| - * @see forge.gui.framework.ICDoc#getCommandOnSelect() | |
| - */ | |
| - @Override | |
| - public UiCommand getCommandOnSelect() { | |
| - return null; | |
| } | |
| @Override | |
| Index: forge-gui/src/main/java/forge/limited/GauntletMini.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui/src/main/java/forge/limited/GauntletMini.java (revision 29316) | |
| +++ forge-gui/src/main/java/forge/limited/GauntletMini.java (revision 29317) | |
| @@ -6,12 +6,12 @@ | |
| * 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 <http://www.gnu.org/licenses/>. | |
| */ | |
| @@ -33,7 +33,7 @@ | |
| * <p> | |
| * GauntletMini class. | |
| * </p> | |
| - * | |
| + * | |
| * @author Forge | |
| * @version $Id: GauntletMini.java $ | |
| * @since 1.2.xx | |
| @@ -47,7 +47,7 @@ | |
| private int losses; | |
| private boolean gauntletDraft; // Means: Draft game is in Gauntlet-mode, not a single match | |
| private GameType gauntletType; | |
| - private List<RegisteredPlayer> aiOpponents = new ArrayList<RegisteredPlayer>(); | |
| + private final List<RegisteredPlayer> aiOpponents = new ArrayList<RegisteredPlayer>(); | |
| public GauntletMini() { | |
| currentRound = 1; | |
| @@ -87,10 +87,10 @@ | |
| } | |
| /** | |
| - * | |
| + * | |
| * Setup and launch the gauntlet. | |
| * Note: The AI decks are connected to the human deck. | |
| - * | |
| + * | |
| * @param rounds0 | |
| * the number of rounds (opponent decks) in this tournament | |
| * @param humanDeck0 | |
| @@ -98,7 +98,7 @@ | |
| * @param gauntletType0 | |
| * game type (Sealed, Draft, Constructed...) | |
| */ | |
| - public void launch(int rounds0, Deck humanDeck0, final GameType gauntletType0) { | |
| + public void launch(final int rounds0, final Deck humanDeck0, final GameType gauntletType0) { | |
| rounds = rounds0; | |
| humanDeck = humanDeck0; | |
| gauntletType = gauntletType0; | |
| Index: forge-gui-desktop/src/main/java/forge/toolbox/LayoutHelper.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/toolbox/LayoutHelper.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/toolbox/LayoutHelper.java (revision 29317) | |
| @@ -1,19 +1,20 @@ | |
| package forge.toolbox; | |
| -import javax.swing.*; | |
| +import javax.swing.JComponent; | |
| -/** | |
| +/** | |
| * Helper class for doing custom layout | |
| * | |
| */ | |
| public final class LayoutHelper { | |
| private final int parentWidth, parentHeight; | |
| - private int x, y, lineBottom, gapX, gapY; | |
| + private int x, y, lineBottom; | |
| + private final int gapX, gapY; | |
| - public LayoutHelper(JComponent parent) { | |
| + public LayoutHelper(final JComponent parent) { | |
| this(parent, 3, 3); | |
| } | |
| - public LayoutHelper(JComponent parent, int gapX0, int gapY0) { | |
| + public LayoutHelper(final JComponent parent, final int gapX0, final int gapY0) { | |
| parentWidth = parent.getWidth(); | |
| parentHeight = parent.getHeight(); | |
| gapX = gapX0; | |
| @@ -34,7 +35,7 @@ | |
| * @param comp | |
| * @param height | |
| */ | |
| - public void fillLine(final JComponent comp, int height) { | |
| + public void fillLine(final JComponent comp, final int height) { | |
| fillLine(comp, height, 0); | |
| } | |
| @@ -44,7 +45,7 @@ | |
| * @param height | |
| * @param rightPadding | |
| */ | |
| - public void fillLine(final JComponent comp, int height, int rightPadding) { | |
| + public void fillLine(final JComponent comp, final int height, final int rightPadding) { | |
| if (x >= parentWidth) { | |
| newLine(); | |
| } | |
| @@ -57,7 +58,7 @@ | |
| * @param widthPercent | |
| * @param height | |
| */ | |
| - public void include(final JComponent comp, float widthPercent, int height) { | |
| + public void include(final JComponent comp, final float widthPercent, final int height) { | |
| include(comp, Math.round(parentWidth * widthPercent), height); | |
| } | |
| @@ -67,7 +68,7 @@ | |
| * @param width | |
| * @param heightPercent | |
| */ | |
| - public void include(final JComponent comp, int width, float heightPercent) { | |
| + public void include(final JComponent comp, final int width, final float heightPercent) { | |
| include(comp, width, Math.round(parentHeight * heightPercent)); | |
| } | |
| @@ -77,7 +78,7 @@ | |
| * @param widthPercent | |
| * @param heightPercent | |
| */ | |
| - public void include(final JComponent comp, float widthPercent, float heightPercent) { | |
| + public void include(final JComponent comp, final float widthPercent, final float heightPercent) { | |
| include(comp, Math.round(parentWidth * widthPercent), Math.round(parentHeight * heightPercent)); | |
| } | |
| @@ -87,7 +88,7 @@ | |
| * @param width | |
| * @param height | |
| */ | |
| - public void include(final JComponent comp, int width, int height) { | |
| + public void include(final JComponent comp, int width, final int height) { | |
| if (width <= 0 || height <= 0) { return; } | |
| if (x + width > parentWidth) { | |
| @@ -112,7 +113,7 @@ | |
| * @param dx | |
| * @param dy | |
| */ | |
| - public void offset(int dx, int dy) { | |
| + public void offset(final int dx, final int dy) { | |
| x += dx; | |
| y += dy; | |
| } | |
| @@ -130,7 +131,7 @@ | |
| /** | |
| * Start new line of layout | |
| */ | |
| - public void newLine(int dy) { | |
| + public void newLine(final int dy) { | |
| x = 0; | |
| y = lineBottom + gapY + dy; | |
| lineBottom = y; | |
| Index: forge-gui-desktop/src/main/java/forge/screens/match/views/VLog.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/match/views/VLog.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/match/views/VLog.java (revision 29317) | |
| @@ -6,12 +6,12 @@ | |
| * 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 <http://www.gnu.org/licenses/>. | |
| */ | |
| @@ -59,7 +59,7 @@ | |
| private final DragTab tab = new DragTab("Log"); | |
| // Other fields | |
| - private GameLogPanel gameLog; | |
| + private final GameLogPanel gameLog; | |
| private JPanel p = null; | |
| private final CLog controller; | |
| @@ -168,17 +168,17 @@ | |
| } | |
| private void displayNewGameLogEntries(final GameView model) { | |
| - List<GameLogEntry> newLogEntries = Lists.reverse(getNewGameLogEntries(model)); | |
| + final List<GameLogEntry> newLogEntries = Lists.reverse(getNewGameLogEntries(model)); | |
| if (newLogEntries.size() > 0) { | |
| addNewLogEntriesToJPanel(newLogEntries); | |
| } | |
| } | |
| private List<GameLogEntry> getNewGameLogEntries(final GameView model) { | |
| - String logEntryType = FModel.getPreferences().getPref(FPref.DEV_LOG_ENTRY_TYPE); | |
| - GameLogEntryType logVerbosityFilter = GameLogEntryType.valueOf(logEntryType); | |
| + final String logEntryType = FModel.getPreferences().getPref(FPref.DEV_LOG_ENTRY_TYPE); | |
| + final GameLogEntryType logVerbosityFilter = GameLogEntryType.valueOf(logEntryType); | |
| if (model != null && model.getGameLog() != null) { | |
| - List<GameLogEntry> logEntries = model.getGameLog().getLogEntries(logVerbosityFilter); | |
| + final List<GameLogEntry> logEntries = model.getGameLog().getLogEntries(logVerbosityFilter); | |
| // Set subtraction - remove all log entries from new list which are already displayed. | |
| logEntries.removeAll(this.displayedLogEntries); | |
| return logEntries; | |
| @@ -186,16 +186,16 @@ | |
| return new ArrayList<GameLogEntry>(); | |
| } | |
| - private void addNewLogEntriesToJPanel(List<GameLogEntry> newLogEntries) { | |
| - for (GameLogEntry logEntry : newLogEntries) { | |
| + private void addNewLogEntriesToJPanel(final List<GameLogEntry> newLogEntries) { | |
| + for (final GameLogEntry logEntry : newLogEntries) { | |
| gameLog.setTextFont(getJTextAreaFont(logEntry.type)); | |
| gameLog.addLogEntry(logEntry.message); | |
| this.displayedLogEntries.add(logEntry); | |
| } | |
| } | |
| - private SkinFont getJTextAreaFont(GameLogEntryType logEntryType) { | |
| - boolean isNewTurn = (logEntryType == GameLogEntryType.TURN); | |
| + private static SkinFont getJTextAreaFont(final GameLogEntryType logEntryType) { | |
| + final boolean isNewTurn = (logEntryType == GameLogEntryType.TURN); | |
| return (isNewTurn ? FSkin.getBoldFont() : FSkin.getFont()); | |
| } | |
| } | |
| Index: forge-gui/src/main/java/forge/gauntlet/GauntletIO.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui/src/main/java/forge/gauntlet/GauntletIO.java (revision 29316) | |
| +++ forge-gui/src/main/java/forge/gauntlet/GauntletIO.java (revision 29317) | |
| @@ -45,35 +45,35 @@ | |
| return xStream; | |
| } | |
| - public static File getGauntletFile(String name) { | |
| + public static File getGauntletFile(final String name) { | |
| return new File(ForgeConstants.GAUNTLET_DIR.userPrefLoc, name + SUFFIX_DATA); | |
| } | |
| - public static File getGauntletFile(GauntletData gd) { | |
| + public static File getGauntletFile(final GauntletData gd) { | |
| return getGauntletFile(gd.getName()); | |
| } | |
| public static File[] getGauntletFilesUnlocked(final String prefix) { | |
| final FilenameFilter filter = new FilenameFilter() { | |
| @Override | |
| - public boolean accept(File dir, String name) { | |
| + public boolean accept(final File dir, final String name) { | |
| return ((prefix == null || name.startsWith(prefix)) && name.endsWith(SUFFIX_DATA)); | |
| } | |
| }; | |
| - File folder = new File(ForgeConstants.GAUNTLET_DIR.userPrefLoc); | |
| + final File folder = new File(ForgeConstants.GAUNTLET_DIR.userPrefLoc); | |
| return folder.listFiles(filter); | |
| } | |
| public static File[] getGauntletFilesLocked() { | |
| final FilenameFilter filter = new FilenameFilter() { | |
| @Override | |
| - public boolean accept(File dir, String name) { | |
| + public boolean accept(final File dir, final String name) { | |
| return (name.startsWith(PREFIX_LOCKED) && name.endsWith(SUFFIX_DATA)); | |
| } | |
| }; | |
| - File folder = new File(ForgeConstants.GAUNTLET_DIR.defaultLoc); | |
| + final File folder = new File(ForgeConstants.GAUNTLET_DIR.defaultLoc); | |
| return folder.listFiles(filter); | |
| } | |
| @@ -101,8 +101,7 @@ | |
| if (zin != null) { | |
| try { | |
| zin.close(); | |
| - } | |
| - catch (IOException e) { | |
| + } catch (final IOException e) { | |
| System.out.println("error closing gauntlet data reader: " + e); | |
| } | |
| } | |
| @@ -110,8 +109,7 @@ | |
| if (isCorrupt) { | |
| try { | |
| xmlSaveFile.delete(); | |
| - } | |
| - catch (Exception e) { | |
| + } catch (final Exception e) { | |
| System.out.println("error delete corrupt gauntlet file: " + e); | |
| } | |
| } | |
| @@ -145,7 +143,7 @@ | |
| @Override | |
| public void marshal(final Object source, final HierarchicalStreamWriter writer, final MarshallingContext context) { | |
| for (final Entry<PaperCard, Integer> e : (CardPool) source) { | |
| - this.writeCardPrinted(e.getKey(), e.getValue(), writer); | |
| + writeCardPrinted(e.getKey(), e.getValue(), writer); | |
| } | |
| } | |
| @@ -161,15 +159,15 @@ | |
| if ("string".equals(nodename)) { | |
| result.add(FModel.getMagicDb().getCommonCards().getCard(reader.getValue())); | |
| } else if ("card".equals(nodename)) { // new format | |
| - result.add(this.readCardPrinted(reader), cnt); | |
| + result.add(readCardPrinted(reader), cnt); | |
| } | |
| reader.moveUp(); | |
| } | |
| - | |
| + | |
| return result; | |
| } | |
| - private void writeCardPrinted(final PaperCard cref, final Integer count, final HierarchicalStreamWriter writer) { | |
| + private static void writeCardPrinted(final PaperCard cref, final Integer count, final HierarchicalStreamWriter writer) { | |
| writer.startNode("card"); | |
| writer.addAttribute("c", cref.getName()); | |
| writer.addAttribute("s", cref.getEdition()); | |
| @@ -181,17 +179,19 @@ | |
| writer.endNode(); | |
| } | |
| - private PaperCard readCardPrinted(final HierarchicalStreamReader reader) { | |
| + private static PaperCard readCardPrinted(final HierarchicalStreamReader reader) { | |
| final String name = reader.getAttribute("c"); | |
| final String set = reader.getAttribute("s"); | |
| final String sIndex = reader.getAttribute("i"); | |
| final short index = StringUtils.isNumeric(sIndex) ? Short.parseShort(sIndex) : 0; | |
| final boolean foil = "1".equals(reader.getAttribute("foil")); | |
| PaperCard card = FModel.getMagicDb().getCommonCards().getCard(name, set, index); | |
| - if ( null == card ) | |
| + if (null == card) { | |
| card = FModel.getMagicDb().getCommonCards().getCard(name, set, -1); | |
| - if ( null == card ) | |
| + } | |
| + if (null == card) { | |
| throw new RuntimeException("Unsupported card found in quest save: " + name + " from edition " + set); | |
| + } | |
| return foil ? FModel.getMagicDb().getCommonCards().getFoiled(card) : card; | |
| } | |
| } | |
| Index: forge-gui-desktop/src/main/java/forge/itemmanager/filters/DeckQuestWorldFilter.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/itemmanager/filters/DeckQuestWorldFilter.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/itemmanager/filters/DeckQuestWorldFilter.java (revision 29317) | |
| @@ -1,22 +1,22 @@ | |
| package forge.itemmanager.filters; | |
| +import java.util.HashSet; | |
| +import java.util.Set; | |
| + | |
| +import forge.deck.DeckProxy; | |
| import forge.game.GameFormat; | |
| import forge.itemmanager.ItemManager; | |
| -import forge.deck.DeckProxy; | |
| import forge.model.FModel; | |
| import forge.quest.QuestWorld; | |
| -import java.util.HashSet; | |
| -import java.util.Set; | |
| - | |
| public class DeckQuestWorldFilter extends DeckFormatFilter { | |
| private final Set<QuestWorld> questWorlds = new HashSet<QuestWorld>(); | |
| - public DeckQuestWorldFilter(ItemManager<? super DeckProxy> itemManager0) { | |
| + public DeckQuestWorldFilter(final ItemManager<? super DeckProxy> itemManager0) { | |
| super(itemManager0); | |
| } | |
| - public DeckQuestWorldFilter(ItemManager<? super DeckProxy> itemManager0, QuestWorld questWorld0) { | |
| + public DeckQuestWorldFilter(final ItemManager<? super DeckProxy> itemManager0, final QuestWorld questWorld0) { | |
| super(itemManager0); | |
| this.questWorlds.add(questWorld0); | |
| this.formats.add(getQuestWorldFormat(questWorld0)); | |
| @@ -24,9 +24,9 @@ | |
| @Override | |
| public ItemFilter<DeckProxy> createCopy() { | |
| - DeckQuestWorldFilter copy = new DeckQuestWorldFilter(itemManager); | |
| + final DeckQuestWorldFilter copy = new DeckQuestWorldFilter(itemManager); | |
| copy.questWorlds.addAll(this.questWorlds); | |
| - for (QuestWorld w : this.questWorlds) { | |
| + for (final QuestWorld w : this.questWorlds) { | |
| copy.formats.add(getQuestWorldFormat(w)); | |
| } | |
| return copy; | |
| @@ -38,7 +38,7 @@ | |
| super.reset(); | |
| } | |
| - public static boolean canAddQuestWorld(QuestWorld questWorld, ItemFilter<DeckProxy> existingFilter) { | |
| + public static boolean canAddQuestWorld(final QuestWorld questWorld, final ItemFilter<DeckProxy> existingFilter) { | |
| if (questWorld.getFormat() == null && FModel.getQuest().getMainFormat() == null) { | |
| return false; //must have format | |
| } | |
| @@ -51,10 +51,10 @@ | |
| * @return true if filter merged in or to suppress adding a new filter, false to allow adding new filter | |
| */ | |
| @Override | |
| - public boolean merge(ItemFilter<?> filter) { | |
| - DeckQuestWorldFilter cardQuestWorldFilter = (DeckQuestWorldFilter)filter; | |
| + public boolean merge(final ItemFilter<?> filter) { | |
| + final DeckQuestWorldFilter cardQuestWorldFilter = (DeckQuestWorldFilter)filter; | |
| this.questWorlds.addAll(cardQuestWorldFilter.questWorlds); | |
| - for (QuestWorld w : cardQuestWorldFilter.questWorlds) { | |
| + for (final QuestWorld w : cardQuestWorldFilter.questWorlds) { | |
| this.formats.add(getQuestWorldFormat(w)); | |
| } | |
| return true; | |
| @@ -72,14 +72,14 @@ | |
| @Override | |
| protected Iterable<String> getList() { | |
| - Set<String> strings = new HashSet<String>(); | |
| - for (QuestWorld w : this.questWorlds) { | |
| + final Set<String> strings = new HashSet<String>(); | |
| + for (final QuestWorld w : this.questWorlds) { | |
| strings.add(w.getName()); | |
| } | |
| return strings; | |
| } | |
| - private GameFormat getQuestWorldFormat(QuestWorld w) { | |
| + private static GameFormat getQuestWorldFormat(final QuestWorld w) { | |
| GameFormat format = w.getFormat(); | |
| if (format == null) { | |
| //assumes that no world other than the main world will have a null format | |
| Index: forge-gui-desktop/src/main/java/forge/screens/home/sanctioned/CSubmenuDraft.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/home/sanctioned/CSubmenuDraft.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/home/sanctioned/CSubmenuDraft.java (revision 29317) | |
| @@ -31,15 +31,13 @@ | |
| import forge.screens.deckeditor.controllers.CEditorDraftingProcess; | |
| import forge.toolbox.FOptionPane; | |
| -/** | |
| +/** | |
| * Controls the draft submenu in the home UI. | |
| - * | |
| + * | |
| * <br><br><i>(C at beginning of class name denotes a control class.)</i> | |
| - * | |
| */ | |
| @SuppressWarnings("serial") | |
| public enum CSubmenuDraft implements ICDoc { | |
| - /** */ | |
| SINGLETON_INSTANCE; | |
| private final UiCommand cmdDeckSelect = new UiCommand() { | |
| @@ -114,7 +112,7 @@ | |
| } | |
| if (FModel.getPreferences().getPrefBoolean(FPref.ENFORCE_DECK_LEGALITY)) { | |
| - String errorMessage = gameType.getDeckFormat().getDeckConformanceProblem(humanDeck.getDeck()); | |
| + final String errorMessage = gameType.getDeckFormat().getDeckConformanceProblem(humanDeck.getDeck()); | |
| if (null != errorMessage) { | |
| FOptionPane.showErrorDialog("Your deck " + errorMessage + " Please edit or choose a different deck.", "Invalid Deck"); | |
| return; | |
| @@ -124,7 +122,7 @@ | |
| FModel.getGauntletMini().resetGauntletDraft(); | |
| if (gauntlet) { | |
| - int rounds = FModel.getDecks().getDraft().get(humanDeck.getName()).getAiDecks().size(); | |
| + final int rounds = FModel.getDecks().getDraft().get(humanDeck.getName()).getAiDecks().size(); | |
| FModel.getGauntletMini().launch(rounds, humanDeck.getDeck(), gameType); | |
| return; | |
| } | |
| @@ -147,7 +145,7 @@ | |
| final RegisteredPlayer human = new RegisteredPlayer(humanDeck.getDeck()).setPlayer(GamePlayerUtil.getGuiPlayer()); | |
| starter.add(human); | |
| starter.add(new RegisteredPlayer(aiDeck).setPlayer(GamePlayerUtil.createAiPlayer())); | |
| - for (RegisteredPlayer pl : starter) { | |
| + for (final RegisteredPlayer pl : starter) { | |
| pl.assignConspiracies(); | |
| } | |
| @@ -168,7 +166,7 @@ | |
| final LimitedPoolType poolType = GuiChoose.oneOrNone("Choose Draft Format", LimitedPoolType.values()); | |
| if (poolType == null) { return; } | |
| - BoosterDraft draft = BoosterDraft.createDraft(poolType); | |
| + final BoosterDraft draft = BoosterDraft.createDraft(poolType); | |
| if (draft == null) { return; } | |
| final CEditorDraftingProcess draftController = new CEditorDraftingProcess(CDeckEditorUI.SINGLETON_INSTANCE.getCDetailPicture()); | |
| @@ -178,11 +176,4 @@ | |
| CDeckEditorUI.SINGLETON_INSTANCE.setEditorController(draftController); | |
| } | |
| - /* (non-Javadoc) | |
| - * @see forge.gui.framework.ICDoc#getCommandOnSelect() | |
| - */ | |
| - @Override | |
| - public UiCommand getCommandOnSelect() { | |
| - return null; | |
| - } | |
| } | |
| Index: forge-gui/src/main/java/forge/match/input/InputConfirmMulligan.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui/src/main/java/forge/match/input/InputConfirmMulligan.java (revision 29316) | |
| +++ forge-gui/src/main/java/forge/match/input/InputConfirmMulligan.java (revision 29317) | |
| @@ -6,12 +6,12 @@ | |
| * 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 <http://www.gnu.org/licenses/>. | |
| */ | |
| @@ -30,15 +30,15 @@ | |
| import forge.util.ITriggerEvent; | |
| import forge.util.Lang; | |
| import forge.util.ThreadUtil; | |
| - | |
| + | |
| /** | |
| - * <p> | |
| - * InputConfirmMulligan class. | |
| - * </p> | |
| - * | |
| - * @author Forge | |
| - * @version $Id: InputConfirmMulligan.java 24769 2014-02-09 13:56:04Z Hellfish $ | |
| - */ | |
| + * <p> | |
| + * InputConfirmMulligan class. | |
| + * </p> | |
| + * | |
| + * @author Forge | |
| + * @version $Id: InputConfirmMulligan.java 24769 2014-02-09 13:56:04Z Hellfish $ | |
| + */ | |
| public class InputConfirmMulligan extends InputSyncronizedBase { | |
| /** Constant <code>serialVersionUID=-8112954303001155622L</code>. */ | |
| private static final long serialVersionUID = -8112954303001155622L; | |
| @@ -60,9 +60,9 @@ | |
| /** {@inheritDoc} */ | |
| @Override | |
| public final void showMessage() { | |
| - Game game = player.getGame(); | |
| + final Game game = player.getGame(); | |
| - StringBuilder sb = new StringBuilder(); | |
| + final StringBuilder sb = new StringBuilder(); | |
| if (startingPlayer == player) { | |
| sb.append(player).append(", you are going first!\n\n"); | |
| } | |
| @@ -116,9 +116,9 @@ | |
| @Override | |
| protected boolean onCardSelected(final Card c0, final List<Card> otherCardsToSelect, final ITriggerEvent triggerEvent) { // the only place that would cause troubles - input is supposed only to confirm, not to fire abilities | |
| - boolean fromHand = player.getZone(ZoneType.Hand).contains(c0); | |
| - boolean isSerumPowder = c0.getName().equals("Serum Powder"); | |
| - boolean isLegalChoice = fromHand && (isCommander || isSerumPowder); | |
| + final boolean fromHand = player.getZone(ZoneType.Hand).contains(c0); | |
| + final boolean isSerumPowder = c0.getName().equals("Serum Powder"); | |
| + final boolean isLegalChoice = fromHand && (isCommander || isSerumPowder); | |
| if (!isLegalChoice || cardSelectLocked) { | |
| return false; | |
| } | |
| @@ -127,9 +127,9 @@ | |
| if (isSerumPowder && getController().getGui().confirm(cView, "Use " + cView + "'s ability?")) { | |
| cardSelectLocked = true; | |
| ThreadUtil.invokeInGameThread(new Runnable() { | |
| - public void run() { | |
| - CardCollection hand = new CardCollection(c0.getController().getCardsIn(ZoneType.Hand)); | |
| - for (Card c : hand) { | |
| + @Override public void run() { | |
| + final CardCollection hand = new CardCollection(c0.getController().getCardsIn(ZoneType.Hand)); | |
| + for (final Card c : hand) { | |
| player.getGame().getAction().exile(c); | |
| } | |
| c0.getController().drawCards(hand.size()); | |
| @@ -162,7 +162,7 @@ | |
| } | |
| @Override | |
| - public String getActivateAction(Card card) { | |
| + public String getActivateAction(final Card card) { | |
| return null; | |
| } | |
| } | |
| Index: forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CCardCatalog.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CCardCatalog.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CCardCatalog.java (revision 29317) | |
| @@ -1,11 +1,10 @@ | |
| package forge.screens.deckeditor.controllers; | |
| -import forge.UiCommand; | |
| import forge.gui.framework.ICDoc; | |
| -/** | |
| +/** | |
| * Controls the "card catalog" panel in the deck editor UI. | |
| - * | |
| + * | |
| * <br><br><i>(C at beginning of class name denotes a control class.)</i> | |
| * | |
| */ | |
| @@ -17,14 +16,6 @@ | |
| } | |
| //========== Overridden methods | |
| - | |
| - /* (non-Javadoc) | |
| - * @see forge.gui.framework.ICDoc#getCommandOnSelect() | |
| - */ | |
| - @Override | |
| - public UiCommand getCommandOnSelect() { | |
| - return null; | |
| - } | |
| @Override | |
| public void register() { | |
| @@ -36,7 +27,7 @@ | |
| @Override | |
| public void initialize() { | |
| } | |
| - | |
| + | |
| /* (non-Javadoc) | |
| * @see forge.gui.framework.ICDoc#update() | |
| */ | |
| Index: forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/ACEditorBase.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/ACEditorBase.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/ACEditorBase.java (revision 29317) | |
| @@ -6,17 +6,29 @@ | |
| * 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 <http://www.gnu.org/licenses/>. | |
| */ | |
| package forge.screens.deckeditor.controllers; | |
| +import java.awt.Toolkit; | |
| +import java.awt.event.InputEvent; | |
| +import java.awt.event.KeyEvent; | |
| +import java.util.Arrays; | |
| +import java.util.List; | |
| +import java.util.Map.Entry; | |
| + | |
| +import javax.swing.JMenu; | |
| +import javax.swing.JPopupMenu; | |
| +import javax.swing.KeyStroke; | |
| +import javax.swing.SwingUtilities; | |
| + | |
| import forge.UiCommand; | |
| import forge.assets.FSkinProp; | |
| import forge.deck.Deck; | |
| @@ -24,7 +36,11 @@ | |
| import forge.deck.DeckSection; | |
| import forge.gui.GuiChoose; | |
| import forge.gui.GuiUtils; | |
| -import forge.gui.framework.*; | |
| +import forge.gui.framework.DragCell; | |
| +import forge.gui.framework.FScreen; | |
| +import forge.gui.framework.ICDoc; | |
| +import forge.gui.framework.IVDoc; | |
| +import forge.gui.framework.SRearrangingUtil; | |
| import forge.item.InventoryItem; | |
| import forge.item.PaperCard; | |
| import forge.itemmanager.ItemManager; | |
| @@ -43,15 +59,6 @@ | |
| import forge.util.ItemPool; | |
| import forge.view.FView; | |
| -import javax.swing.*; | |
| - | |
| -import java.awt.*; | |
| -import java.awt.event.InputEvent; | |
| -import java.awt.event.KeyEvent; | |
| -import java.util.Arrays; | |
| -import java.util.List; | |
| -import java.util.Map.Entry; | |
| - | |
| /** | |
| * Maintains a generically typed architecture for various editing | |
| * environments. A basic editor instance requires a card catalog, the | |
| @@ -60,7 +67,7 @@ | |
| * These requirements are collected in this class and manipulated | |
| * in subclasses for different environments. There are two generic | |
| * types for all card display and filter predicates. | |
| - * | |
| + * | |
| * <br><br><i>(A at beginning of class name denotes an abstract class.)</i> | |
| * <br><br><i>(C at beginning of class name denotes a control class.)</i> | |
| * | |
| @@ -138,41 +145,35 @@ | |
| return new CDeckEditorUIMenus().getMenus(); | |
| } | |
| - public final void addItem(TItem item) { | |
| + public final void addItem(final TItem item) { | |
| onAddItems(createPoolForItem(item, 1), false); | |
| } | |
| - public final void addItem(TItem item, int qty) { | |
| + public final void addItem(final TItem item, final int qty) { | |
| onAddItems(createPoolForItem(item, qty), false); | |
| } | |
| - public final void addItem(TItem item, int qty, boolean toAlternate) { | |
| - onAddItems(createPoolForItem(item, qty), toAlternate); | |
| - } | |
| - public final void removeItem(TItem item) { | |
| + public final void removeItem(final TItem item) { | |
| onRemoveItems(createPoolForItem(item, 1), false); | |
| } | |
| - public final void removeItem(TItem item, int qty) { | |
| + public final void removeItem(final TItem item, final int qty) { | |
| onRemoveItems(createPoolForItem(item, qty), false); | |
| } | |
| - public final void removeItem(TItem item, int qty, boolean toAlternate) { | |
| - onRemoveItems(createPoolForItem(item, qty), toAlternate); | |
| - } | |
| @SuppressWarnings("unchecked") | |
| private ItemPool<TItem> createPoolForItem(final TItem item, final int qty) { | |
| if (item == null || qty <= 0) { return null; } | |
| - ItemPool<TItem> pool = new ItemPool<TItem>((Class<TItem>)item.getClass()); | |
| + final ItemPool<TItem> pool = new ItemPool<TItem>((Class<TItem>)item.getClass()); | |
| pool.add(item, qty); | |
| return pool; | |
| } | |
| - public final void addItems(Iterable<Entry<TItem, Integer>> items, boolean toAlternate) { | |
| + public final void addItems(final Iterable<Entry<TItem, Integer>> items, final boolean toAlternate) { | |
| if (items == null || !items.iterator().hasNext()) { return; } //do nothing if no items | |
| onAddItems(items, toAlternate); | |
| } | |
| - public final void removeItems(Iterable<Entry<TItem, Integer>> items, boolean toAlternate) { | |
| + public final void removeItems(final Iterable<Entry<TItem, Integer>> items, final boolean toAlternate) { | |
| if (items == null || !items.iterator().hasNext()) { return; } //do nothing if no items | |
| onRemoveItems(items, toAlternate); | |
| } | |
| @@ -189,15 +190,15 @@ | |
| /** | |
| * @return pool of additions allowed to deck | |
| */ | |
| - protected ItemPool<TItem> getAllowedAdditions(Iterable<Entry<TItem, Integer>> itemsToAdd) { | |
| - ItemPool<TItem> additions = new ItemPool<TItem>(getCatalogManager().getGenericType()); | |
| - CardLimit limit = getCardLimit(); | |
| - DeckController<TModel> controller = getDeckController(); | |
| - Deck deck = controller != null && controller.getModel() instanceof Deck ? (Deck)controller.getModel() : null; | |
| + protected ItemPool<TItem> getAllowedAdditions(final Iterable<Entry<TItem, Integer>> itemsToAdd) { | |
| + final ItemPool<TItem> additions = new ItemPool<TItem>(getCatalogManager().getGenericType()); | |
| + final CardLimit limit = getCardLimit(); | |
| + final DeckController<TModel> controller = getDeckController(); | |
| + final Deck deck = controller != null && controller.getModel() instanceof Deck ? (Deck)controller.getModel() : null; | |
| - for (Entry<TItem, Integer> itemEntry : itemsToAdd) { | |
| - TItem item = itemEntry.getKey(); | |
| - PaperCard card = item instanceof PaperCard ? (PaperCard)item : null; | |
| + for (final Entry<TItem, Integer> itemEntry : itemsToAdd) { | |
| + final TItem item = itemEntry.getKey(); | |
| + final PaperCard card = item instanceof PaperCard ? (PaperCard)item : null; | |
| int qty = itemEntry.getValue(); | |
| int max; | |
| @@ -228,7 +229,7 @@ | |
| protected abstract CardLimit getCardLimit(); | |
| - /** | |
| + /** | |
| * Operation to add selected items to current deck. | |
| */ | |
| protected abstract void onAddItems(Iterable<Entry<TItem, Integer>> items, boolean toAlternate); | |
| @@ -255,7 +256,7 @@ | |
| /** | |
| * Called when switching away from or closing the editor wants to exit. Should confirm save options. | |
| - * | |
| + * | |
| * @return boolean   true if safe to exit | |
| */ | |
| public abstract boolean canSwitchAway(boolean isClosing); | |
| @@ -272,7 +273,7 @@ | |
| /** | |
| * Gets the ItemManager holding the cards in the current deck. | |
| - * | |
| + * | |
| * @return {@link forge.itemmanager.ItemManager} | |
| */ | |
| public ItemManager<TItem> getDeckManager() { | |
| @@ -281,7 +282,7 @@ | |
| /** | |
| * Sets the ItemManager holding the cards in the current deck. | |
| - * | |
| + * | |
| * @param itemManager   {@link forge.itemmanager.ItemManager} | |
| */ | |
| @SuppressWarnings("serial") | |
| @@ -289,14 +290,12 @@ | |
| this.deckManager = itemManager; | |
| btnRemove.setCommand(new UiCommand() { | |
| - @Override | |
| - public void run() { | |
| + @Override public void run() { | |
| CDeckEditorUI.SINGLETON_INSTANCE.removeSelectedCards(false, 1); | |
| } | |
| }); | |
| btnRemove4.setCommand(new UiCommand() { | |
| - @Override | |
| - public void run() { | |
| + @Override public void run() { | |
| CDeckEditorUI.SINGLETON_INSTANCE.removeSelectedCards(false, 4); | |
| } | |
| }); | |
| @@ -307,7 +306,7 @@ | |
| /** | |
| * Gets the ItemManager holding the cards in the current catalog. | |
| - * | |
| + * | |
| * @return {@link forge.itemmanager.ItemManager} | |
| */ | |
| public ItemManager<TItem> getCatalogManager() { | |
| @@ -316,7 +315,7 @@ | |
| /** | |
| * Sets the ItemManager holding the cards in the current catalog. | |
| - * | |
| + * | |
| * @param itemManager   {@link forge.itemmanager.ItemManager} | |
| */ | |
| @SuppressWarnings("serial") | |
| @@ -324,14 +323,12 @@ | |
| this.catalogManager = itemManager; | |
| btnAdd.setCommand(new UiCommand() { | |
| - @Override | |
| - public void run() { | |
| + @Override public void run() { | |
| CDeckEditorUI.SINGLETON_INSTANCE.addSelectedCards(false, 1); | |
| } | |
| }); | |
| btnAdd4.setCommand(new UiCommand() { | |
| - @Override | |
| - public void run() { | |
| + @Override public void run() { | |
| CDeckEditorUI.SINGLETON_INSTANCE.addSelectedCards(false, 4); | |
| } | |
| }); | |
| @@ -342,7 +339,7 @@ | |
| /** | |
| * Removes the specified tab and returns its parent for later re-adding | |
| */ | |
| - protected DragCell removeTab (IVDoc<? extends ICDoc> tab) { | |
| + protected DragCell removeTab (final IVDoc<? extends ICDoc> tab) { | |
| final DragCell parent; | |
| if (tab.getParentCell() == null) { | |
| parent = null; | |
| @@ -398,7 +395,7 @@ | |
| public FLabel getBtnRemove4() { return btnRemove4; } | |
| public FLabel getBtnCycleSection() { return btnCycleSection; } | |
| - public ContextMenuBuilder createContextMenuBuilder(boolean isAddContextMenu0) { | |
| + public ContextMenuBuilder createContextMenuBuilder(final boolean isAddContextMenu0) { | |
| return new EditorContextMenuBuilder(isAddContextMenu0); | |
| } | |
| @@ -406,7 +403,7 @@ | |
| private final boolean isAddContextMenu; | |
| private JPopupMenu menu; | |
| - private EditorContextMenuBuilder(boolean isAddContextMenu0) { | |
| + private EditorContextMenuBuilder(final boolean isAddContextMenu0) { | |
| isAddContextMenu = isAddContextMenu0; | |
| } | |
| @@ -419,7 +416,7 @@ | |
| } | |
| @Override | |
| - public void buildContextMenu(JPopupMenu menu) { | |
| + public void buildContextMenu(final JPopupMenu menu) { | |
| this.menu = menu; //cache menu while controller populates menu | |
| if (isAddContextMenu) { | |
| buildAddContextMenu(this); | |
| @@ -459,28 +456,27 @@ | |
| }); | |
| } | |
| - private void addItem(String verb, String dest, final boolean toAlternate, final int qty, int shortcutModifiers) { | |
| + private void addItem(final String verb, final String dest, final boolean toAlternate, final int qty, final int shortcutModifiers) { | |
| String label = verb + " " + SItemManagerUtil.getItemDisplayString(getItemManager().getSelectedItems(), qty, false); | |
| if (dest != null && !dest.isEmpty()) { | |
| label += " " + dest; | |
| } | |
| GuiUtils.addMenuItem(menu, label, | |
| KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, shortcutModifiers), new Runnable() { | |
| - @Override | |
| - public void run() { | |
| + @Override public void run() { | |
| - Integer quantity = qty; | |
| - if (quantity < 0) { | |
| - quantity = GuiChoose.getInteger("Choose a value for X", 1, -quantity, 20); | |
| - if (quantity == null) { return; } | |
| - } | |
| - if (isAddContextMenu) { | |
| - CDeckEditorUI.SINGLETON_INSTANCE.addSelectedCards(toAlternate, quantity); | |
| - } | |
| - else { | |
| - CDeckEditorUI.SINGLETON_INSTANCE.removeSelectedCards(toAlternate, quantity); | |
| - } | |
| - } | |
| - }, true, shortcutModifiers == 0); | |
| + Integer quantity = qty; | |
| + if (quantity < 0) { | |
| + quantity = GuiChoose.getInteger("Choose a value for X", 1, -quantity, 20); | |
| + if (quantity == null) { return; } | |
| + } | |
| + if (isAddContextMenu) { | |
| + CDeckEditorUI.SINGLETON_INSTANCE.addSelectedCards(toAlternate, quantity); | |
| + } | |
| + else { | |
| + CDeckEditorUI.SINGLETON_INSTANCE.removeSelectedCards(toAlternate, quantity); | |
| + } | |
| + } | |
| + }, true, shortcutModifiers == 0); | |
| } | |
| private int getMaxMoveQuantity() { | |
| @@ -492,7 +488,7 @@ | |
| return 0; | |
| } | |
| int max = Integer.MAX_VALUE; | |
| - for (Entry<TItem, Integer> itemEntry : selectedItemPool) { | |
| + for (final Entry<TItem, Integer> itemEntry : selectedItemPool) { | |
| if (itemEntry.getValue() < max) { | |
| max = itemEntry.getValue(); | |
| } | |
| @@ -500,8 +496,8 @@ | |
| return max; | |
| } | |
| - private void addItems(String verb, String dest, boolean toAlternate, int shortcutModifiers1, int shortcutModifiers2, int shortcutModifiers3) { | |
| - int max = getMaxMoveQuantity(); | |
| + private void addItems(final String verb, final String dest, final boolean toAlternate, final int shortcutModifiers1, final int shortcutModifiers2, final int shortcutModifiers3) { | |
| + final int max = getMaxMoveQuantity(); | |
| if (max == 0) { return; } | |
| addItem(verb, dest, toAlternate, 1, shortcutModifiers1); | |
| @@ -518,11 +514,11 @@ | |
| addItem(verb, dest, toAlternate, -max, shortcutModifiers3); //pass -max as quantity to indicate to prompt for specific quantity | |
| } | |
| - public void addMoveItems(String verb, String dest) { | |
| + public void addMoveItems(final String verb, final String dest) { | |
| addItems(verb, dest, false, 0, InputEvent.SHIFT_DOWN_MASK, InputEvent.ALT_MASK); | |
| } | |
| - public void addMoveAlternateItems(String verb, String dest) { | |
| + public void addMoveAlternateItems(final String verb, final String dest) { | |
| if (this.menu.getComponentCount() > 0) { | |
| this.menu.addSeparator(); | |
| } | |
| Index: forge-gui/src/main/java/forge/sound/SoundSystem.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui/src/main/java/forge/sound/SoundSystem.java (revision 29316) | |
| +++ forge-gui/src/main/java/forge/sound/SoundSystem.java (revision 29317) | |
| @@ -14,9 +14,8 @@ | |
| import forge.properties.ForgeConstants; | |
| import forge.properties.ForgePreferences.FPref; | |
| -/** | |
| +/** | |
| * Manages playback of all sounds for the client. | |
| - * | |
| */ | |
| public class SoundSystem { | |
| public static final SoundSystem instance = new SoundSystem(); | |
| @@ -32,25 +31,25 @@ | |
| private SoundSystem() { | |
| this.visualizer = new EventVisualizer(GamePlayerUtil.getGuiPlayer()); | |
| } | |
| - private boolean isUsingAltSystem() { | |
| + private static boolean isUsingAltSystem() { | |
| return FModel.getPreferences().getPrefBoolean(FPref.UI_ALT_SOUND_SYSTEM); | |
| } | |
| /** | |
| * Fetch a resource based on the sound effect type from the SoundEffectType enumeration. | |
| - * | |
| + * | |
| * @param type the sound effect type. | |
| * @return a clip associated with the loaded resource, or emptySound if the resource | |
| * was unavailable or failed to load. | |
| */ | |
| - protected IAudioClip fetchResource(SoundEffectType type) { | |
| + protected IAudioClip fetchResource(final SoundEffectType type) { | |
| if (!FModel.getPreferences().getPrefBoolean(FPref.UI_ENABLE_SOUNDS)) { | |
| return emptySound; | |
| } | |
| IAudioClip clip = loadedClips.get(type); | |
| if (clip == null) { // cache miss | |
| - String resource = type.getResourceFileName(); | |
| + final String resource = type.getResourceFileName(); | |
| clip = GuiBase.getInterface().createAudioClip(resource); | |
| if (clip == null) { | |
| clip = emptySound; | |
| @@ -66,7 +65,7 @@ | |
| * @return a clip associated with the loaded resource, or emptySound if the resource | |
| * was unavailable or failed to load. | |
| */ | |
| - protected IAudioClip fetchResource(String fileName) { | |
| + protected IAudioClip fetchResource(final String fileName) { | |
| if (!FModel.getPreferences().getPrefBoolean(FPref.UI_ENABLE_SOUNDS)) { | |
| return emptySound; | |
| } | |
| @@ -86,12 +85,12 @@ | |
| * Play the sound associated with the resource specified by the file name | |
| * ("synchronized" with other sounds of the same kind means: only one can play at a time). | |
| */ | |
| - public void play(String resourceFileName, boolean isSynchronized) { | |
| + public void play(final String resourceFileName, final boolean isSynchronized) { | |
| if (isUsingAltSystem()) { | |
| GuiBase.getInterface().startAltSoundSystem(ForgeConstants.SOUND_DIR + resourceFileName, isSynchronized); | |
| } | |
| else { | |
| - IAudioClip snd = fetchResource(resourceFileName); | |
| + final IAudioClip snd = fetchResource(resourceFileName); | |
| if (!isSynchronized || snd.isDone()) { | |
| snd.play(); | |
| } | |
| @@ -101,12 +100,12 @@ | |
| /** | |
| * Play the sound associated with the Sounds enumeration element. | |
| */ | |
| - public void play(SoundEffectType type, boolean isSynchronized) { | |
| + public void play(final SoundEffectType type, final boolean isSynchronized) { | |
| if (isUsingAltSystem()) { | |
| GuiBase.getInterface().startAltSoundSystem(ForgeConstants.SOUND_DIR + type.getResourceFileName(), isSynchronized); | |
| } | |
| else { | |
| - IAudioClip snd = fetchResource(type); | |
| + final IAudioClip snd = fetchResource(type); | |
| if (!isSynchronized || snd.isDone()) { | |
| snd.play(); | |
| } | |
| @@ -116,39 +115,39 @@ | |
| /** | |
| * Play the sound in a looping manner until 'stop' is called. | |
| */ | |
| - public void loop(String resourceFileName) { | |
| + public void loop(final String resourceFileName) { | |
| fetchResource(resourceFileName).loop(); | |
| } | |
| /** | |
| * Play the sound in a looping manner until 'stop' is called. | |
| */ | |
| - public void loop(SoundEffectType type) { | |
| + public void loop(final SoundEffectType type) { | |
| fetchResource(type).loop(); | |
| } | |
| /** | |
| * Stop the sound associated with the given resource file name. | |
| */ | |
| - public void stop(String resourceFileName) { | |
| + public void stop(final String resourceFileName) { | |
| fetchResource(resourceFileName).stop(); | |
| } | |
| /** | |
| * Stop the sound associated with the Sounds enumeration element. | |
| */ | |
| - public void stop(SoundEffectType type) { | |
| + public void stop(final SoundEffectType type) { | |
| fetchResource(type).stop(); | |
| } | |
| @Subscribe | |
| - public void receiveEvent(GameEvent evt) { | |
| - SoundEffectType effect = evt.visit(visualizer); | |
| + public void receiveEvent(final GameEvent evt) { | |
| + final SoundEffectType effect = evt.visit(visualizer); | |
| if (null == effect) { | |
| return; | |
| } | |
| if (effect == SoundEffectType.ScriptedEffect) { | |
| - String resourceName = visualizer.getScriptedSoundEffectName(evt); | |
| + final String resourceName = visualizer.getScriptedSoundEffectName(evt); | |
| if (!resourceName.isEmpty()) { | |
| play(resourceName, false); | |
| } | |
| @@ -156,20 +155,20 @@ | |
| play(effect, effect.isSynced()); | |
| } | |
| } | |
| - | |
| + | |
| @Subscribe | |
| - public void receiveEvent(UiEvent evt) { | |
| - SoundEffectType effect = evt.visit(visualizer); | |
| + public void receiveEvent(final UiEvent evt) { | |
| + final SoundEffectType effect = evt.visit(visualizer); | |
| if (null != effect) { | |
| play(effect, effect.isSynced()); | |
| } | |
| } | |
| - | |
| + | |
| //Background Music | |
| private IAudioMusic currentTrack; | |
| private MusicPlaylist currentPlaylist; | |
| - public void setBackgroundMusic(MusicPlaylist playlist) { | |
| + public void setBackgroundMusic(final MusicPlaylist playlist) { | |
| currentPlaylist = playlist; | |
| changeBackgroundTrack(); | |
| } | |
| @@ -185,25 +184,22 @@ | |
| return; | |
| } | |
| - String filename = currentPlaylist.getRandomFilename(); | |
| + final String filename = currentPlaylist.getRandomFilename(); | |
| if (filename == null) { return; } | |
| try { | |
| currentTrack = GuiBase.getInterface().createAudioMusic(filename); | |
| currentTrack.play(new Runnable() { | |
| - @Override | |
| - public void run() { | |
| + @Override public void run() { | |
| try { | |
| Thread.sleep(SoundSystem.DELAY); | |
| - } | |
| - catch (InterruptedException ex) { | |
| + } catch (final InterruptedException ex) { | |
| ex.printStackTrace(); | |
| } | |
| changeBackgroundTrack(); //change track when music completes on its own | |
| } | |
| }); | |
| - } | |
| - catch (Exception ex) { | |
| + } catch (final Exception ex) { | |
| System.err.println("Unable to load music file: " + filename); | |
| } | |
| } | |
| Index: forge-gui-desktop/src/main/java/forge/toolbox/ToolTipListener.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/toolbox/ToolTipListener.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/toolbox/ToolTipListener.java (revision 29317) | |
| @@ -6,21 +6,31 @@ | |
| * 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 <http://www.gnu.org/licenses/>. | |
| */ | |
| package forge.toolbox; | |
| -import javax.swing.*; | |
| -import java.awt.*; | |
| -import java.awt.event.*; | |
| +import java.awt.Component; | |
| +import java.awt.Point; | |
| +import java.awt.event.AdjustmentEvent; | |
| +import java.awt.event.AdjustmentListener; | |
| +import java.awt.event.ComponentEvent; | |
| +import java.awt.event.ComponentListener; | |
| +import java.awt.event.MouseEvent; | |
| +import java.awt.event.MouseWheelEvent; | |
| +import java.awt.event.MouseWheelListener; | |
| +import javax.swing.JScrollBar; | |
| +import javax.swing.JScrollPane; | |
| +import javax.swing.ToolTipManager; | |
| + | |
| // based on code from http://tips4java.wordpress.com/2009/11/08/tooltips-and-scrollpanes/ | |
| /** | |
| @@ -57,57 +67,60 @@ | |
| /** | |
| * Create a mouseMoved event to pass to the ToolTipManager. | |
| */ | |
| - private void phantomMouseMoved(Component component) | |
| - { | |
| + private void phantomMouseMoved(final Component component) { | |
| if (null == component) { | |
| return; | |
| } | |
| // mouse is in the bounds of the component, generate phantom | |
| // mouseMoved event for the ToolTipManager | |
| - Point mouseLocation = component.getMousePosition(); | |
| - if (mouseLocation != null) | |
| - { | |
| - MouseEvent phantom = new MouseEvent( | |
| + final Point mouseLocation = component.getMousePosition(); | |
| + if (mouseLocation != null) { | |
| + final MouseEvent phantom = new MouseEvent( | |
| - component, | |
| - MouseEvent.MOUSE_MOVED, | |
| - System.currentTimeMillis(), | |
| - 0, | |
| - mouseLocation.x, | |
| - mouseLocation.y, | |
| - 0, | |
| - false); | |
| + component, | |
| + MouseEvent.MOUSE_MOVED, | |
| + System.currentTimeMillis(), | |
| + 0, | |
| + mouseLocation.x, | |
| + mouseLocation.y, | |
| + 0, | |
| + false); | |
| ToolTipManager.sharedInstance().mouseMoved(phantom); | |
| } | |
| } | |
| // implement ComponentListener | |
| - public void componentMoved(ComponentEvent e) | |
| - { | |
| + @Override | |
| + public void componentMoved(final ComponentEvent e) { | |
| phantomMouseMoved(e.getComponent()); | |
| } | |
| - public void componentResized(ComponentEvent e) | |
| - { | |
| + @Override | |
| + public void componentResized(final ComponentEvent e) { | |
| phantomMouseMoved(e.getComponent()); | |
| } | |
| - public void componentHidden(ComponentEvent e) { } | |
| - public void componentShown(ComponentEvent e) { } | |
| + @Override | |
| + public void componentHidden(final ComponentEvent e) { | |
| + } | |
| - | |
| + | |
| + @Override | |
| + public void componentShown(final ComponentEvent e) { | |
| + } | |
| + | |
| // implement MouseWheelListener | |
| - public void mouseWheelMoved(MouseWheelEvent e) | |
| - { | |
| - JScrollPane scrollPane = (JScrollPane)e.getSource(); | |
| + @Override | |
| + public void mouseWheelMoved(final MouseWheelEvent e) { | |
| + final JScrollPane scrollPane = (JScrollPane)e.getSource(); | |
| phantomMouseMoved(scrollPane.getViewport().getView()); | |
| } | |
| // implement AdjustmentListener | |
| - public void adjustmentValueChanged(AdjustmentEvent e) | |
| - { | |
| - JScrollBar scrollBar = (JScrollBar)e.getSource(); | |
| - JScrollPane scrollPane = (JScrollPane)scrollBar.getParent(); | |
| + @Override | |
| + public void adjustmentValueChanged(final AdjustmentEvent e) { | |
| + final JScrollBar scrollBar = (JScrollBar)e.getSource(); | |
| + final JScrollPane scrollPane = (JScrollPane)scrollBar.getParent(); | |
| phantomMouseMoved(scrollPane.getViewport().getView()); | |
| } | |
| } | |
| Index: forge-gui-desktop/src/main/java/forge/screens/home/sanctioned/CSubmenuWinston.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/home/sanctioned/CSubmenuWinston.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/home/sanctioned/CSubmenuWinston.java (revision 29317) | |
| @@ -113,7 +113,7 @@ | |
| } | |
| if (FModel.getPreferences().getPrefBoolean(FPref.ENFORCE_DECK_LEGALITY)) { | |
| - String errorMessage = gameType.getDeckFormat().getDeckConformanceProblem(humanDeck.getDeck()); | |
| + final String errorMessage = gameType.getDeckFormat().getDeckConformanceProblem(humanDeck.getDeck()); | |
| if (null != errorMessage) { | |
| FOptionPane.showErrorDialog("Your deck " + errorMessage + " Please edit or choose a different deck.", "Invalid Deck"); | |
| return; | |
| @@ -156,7 +156,7 @@ | |
| final LimitedPoolType poolType = GuiChoose.oneOrNone("Choose Draft Format", LimitedPoolType.values()); | |
| if (poolType == null) { return; } | |
| - WinstonDraft draft = WinstonDraft.createDraft(poolType); | |
| + final WinstonDraft draft = WinstonDraft.createDraft(poolType); | |
| if (draft == null) { return; } | |
| final CEditorWinstonProcess draftController = new CEditorWinstonProcess(CDeckEditorUI.SINGLETON_INSTANCE.getCDetailPicture()); | |
| @@ -166,11 +166,4 @@ | |
| CDeckEditorUI.SINGLETON_INSTANCE.setEditorController(draftController); | |
| } | |
| - /* (non-Javadoc) | |
| - * @see forge.gui.framework.ICDoc#getCommandOnSelect() | |
| - */ | |
| - @Override | |
| - public UiCommand getCommandOnSelect() { | |
| - return null; | |
| - } | |
| } | |
| Index: forge-gui-desktop/src/main/java/forge/screens/home/sanctioned/AvatarSelector.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/home/sanctioned/AvatarSelector.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/home/sanctioned/AvatarSelector.java (revision 29317) | |
| @@ -1,5 +1,15 @@ | |
| package forge.screens.home.sanctioned; | |
| +import java.awt.Dimension; | |
| +import java.util.ArrayList; | |
| +import java.util.Collection; | |
| +import java.util.List; | |
| +import java.util.Map; | |
| + | |
| +import javax.swing.JPanel; | |
| +import javax.swing.ScrollPaneConstants; | |
| +import javax.swing.SwingConstants; | |
| + | |
| import forge.gui.WrapLayout; | |
| import forge.toolbox.FLabel; | |
| import forge.toolbox.FScrollPane; | |
| @@ -7,18 +17,10 @@ | |
| import forge.toolbox.FSkin.SkinImage; | |
| import forge.view.FDialog; | |
| -import javax.swing.*; | |
| - | |
| -import java.awt.*; | |
| -import java.util.ArrayList; | |
| -import java.util.Collection; | |
| -import java.util.List; | |
| -import java.util.Map; | |
| - | |
| @SuppressWarnings("serial") | |
| public class AvatarSelector extends FDialog { | |
| - private List<FLabel> selectables = new ArrayList<FLabel>(); | |
| + private final List<FLabel> selectables = new ArrayList<FLabel>(); | |
| - private final Map<Integer, SkinImage> avatarMap = FSkin.getAvatars(); | |
| + private final Map<Integer, SkinImage> avatarMap = FSkin.getAvatars(); | |
| public AvatarSelector(final String playerName, final int currentIndex, final Collection<Integer> usedIndices) { | |
| this.setTitle("Select avatar for " + playerName); | |
| @@ -28,21 +30,21 @@ | |
| pnlAvatarPics.setOpaque(false); | |
| pnlAvatarPics.setOpaque(false); | |
| - FLabel initialSelection = makeAvatarLabel(avatarMap.get(currentIndex), currentIndex, currentIndex); | |
| + final FLabel initialSelection = makeAvatarLabel(avatarMap.get(currentIndex), currentIndex, currentIndex); | |
| pnlAvatarPics.add(initialSelection); | |
| - for (final Integer i : avatarMap.keySet()) { | |
| - //if (!usedIndices.contains(i)) { // Decided to allow duplicate avatars when manually selecting | |
| - if (currentIndex != i) { | |
| + for (final Integer i : avatarMap.keySet()) { | |
| + //if (!usedIndices.contains(i)) { // Decided to allow duplicate avatars when manually selecting | |
| + if (currentIndex != i) { | |
| pnlAvatarPics.add(makeAvatarLabel(avatarMap.get(i), i, currentIndex)); | |
| - } | |
| + } | |
| } | |
| - final int width = this.getOwner().getWidth() * 3 / 4; | |
| + final int width = this.getOwner().getWidth() * 3 / 4; | |
| final int height = this.getOwner().getHeight() * 3 / 4; | |
| this.setPreferredSize(new Dimension(width, height)); | |
| this.setSize(width, height); | |
| - FScrollPane scroller = new FScrollPane(pnlAvatarPics, false); | |
| + final FScrollPane scroller = new FScrollPane(pnlAvatarPics, false); | |
| scroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); | |
| this.add(scroller, "w 100%-24px!, pushy, growy, gap 12px 0 0 0"); | |
| this.setDefaultFocus(initialSelection); | |
| @@ -50,8 +52,8 @@ | |
| private FLabel makeAvatarLabel(final SkinImage img0, final int index0, final int oldIndex) { | |
| final FLabel lbl = new FLabel.Builder().icon(img0).iconScaleFactor(0.95).iconAlignX(SwingConstants.CENTER) | |
| - .iconInBackground(true).hoverable(true).selectable(true).selected(oldIndex == index0) | |
| - .unhoveredAlpha(oldIndex == index0 ? 0.9f : 0.7f).build(); | |
| + .iconInBackground(true).hoverable(true).selectable(true).selected(oldIndex == index0) | |
| + .unhoveredAlpha(oldIndex == index0 ? 0.9f : 0.7f).build(); | |
| final Dimension size = new Dimension(80, 80); | |
| lbl.setPreferredSize(size); | |
| @@ -60,7 +62,7 @@ | |
| lbl.setName("AvatarLabel" + index0); | |
| if (oldIndex == index0) { | |
| - lbl.setBorder(new FSkin.LineSkinBorder(FSkin.getColor(FSkin.Colors.CLR_BORDERS).alphaColor(255), 3)); | |
| + lbl.setBorder(new FSkin.LineSkinBorder(FSkin.getColor(FSkin.Colors.CLR_BORDERS).alphaColor(255), 3)); | |
| } | |
| selectables.add(lbl); | |
| @@ -69,6 +71,6 @@ | |
| } | |
| public List<FLabel> getSelectables() { | |
| - return this.selectables; | |
| + return this.selectables; | |
| } | |
| } | |
| Index: forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/DeckHtmlSerializer.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/DeckHtmlSerializer.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/DeckHtmlSerializer.java (revision 29317) | |
| @@ -1,5 +1,16 @@ | |
| package forge.screens.deckeditor.controllers; | |
| +import java.io.BufferedWriter; | |
| +import java.io.File; | |
| +import java.io.FileWriter; | |
| +import java.io.IOException; | |
| +import java.util.ArrayList; | |
| +import java.util.HashMap; | |
| +import java.util.List; | |
| +import java.util.Map; | |
| +import java.util.Map.Entry; | |
| +import java.util.TreeMap; | |
| + | |
| import forge.deck.Deck; | |
| import forge.item.PaperCard; | |
| import forge.properties.ForgeConstants; | |
| @@ -9,94 +20,87 @@ | |
| import freemarker.template.Template; | |
| import freemarker.template.TemplateException; | |
| -import java.io.BufferedWriter; | |
| -import java.io.File; | |
| -import java.io.FileWriter; | |
| -import java.io.IOException; | |
| -import java.util.*; | |
| -import java.util.Map.Entry; | |
| - | |
| public class DeckHtmlSerializer { | |
| - public static void writeDeckHtml(final Deck d, final File f) { | |
| - try { | |
| - final BufferedWriter writer = new BufferedWriter(new FileWriter(f)); | |
| - writeDeckHtml(d, writer); | |
| - writer.close(); | |
| - } catch (final IOException e) { | |
| - throw new RuntimeException(e); | |
| - } | |
| - } | |
| + public static void writeDeckHtml(final Deck d, final File f) { | |
| + try { | |
| + final BufferedWriter writer = new BufferedWriter(new FileWriter(f)); | |
| + writeDeckHtml(d, writer); | |
| + writer.close(); | |
| + } catch (final IOException e) { | |
| + throw new RuntimeException(e); | |
| + } | |
| + } | |
| - /** | |
| - * <p> | |
| - * writeDeck. | |
| - * </p> | |
| - * | |
| - * @param d | |
| - * a {@link forge.deck.Deck} object. | |
| - * @param out | |
| - * a {@link java.io.BufferedWriter} object. | |
| - * @throws java.io.IOException | |
| - * if any. | |
| - */ | |
| + /** | |
| + * <p> | |
| + * writeDeck. | |
| + * </p> | |
| + * | |
| + * @param d | |
| + * a {@link forge.deck.Deck} object. | |
| + * @param out | |
| + * a {@link java.io.BufferedWriter} object. | |
| + * @throws java.io.IOException | |
| + * if any. | |
| + */ | |
| - private static void writeDeckHtml(final Deck d, final BufferedWriter out) throws IOException { | |
| + private static void writeDeckHtml(final Deck d, final BufferedWriter out) { | |
| - Template temp = null; | |
| - final int cardBorder = 0; | |
| - final int height = 319; | |
| - final int width = 222; | |
| - | |
| - /* Create and adjust the configuration */ | |
| - final Configuration cfg = new Configuration(); | |
| - try { | |
| - cfg.setClassForTemplateLoading(DeckHtmlSerializer.class, "/"); | |
| - cfg.setObjectWrapper(new DefaultObjectWrapper()); | |
| - | |
| - /* | |
| - * ------------------------------------------------------------------ | |
| - * - | |
| - */ | |
| - /* | |
| - * You usually do these for many times in the application | |
| - * life-cycle: | |
| - */ | |
| - | |
| - /* Get or create a template */ | |
| - temp = cfg.getTemplate("proxy-template.ftl"); | |
| - | |
| - /* Create a data-model */ | |
| - final Map<String, Object> root = new HashMap<String, Object>(); | |
| - root.put("title", d.getName()); | |
| - final List<String> list = new ArrayList<String>(); | |
| - for (final Entry<PaperCard, Integer> card : d.getMain()) { | |
| - // System.out.println(card.getSets().get(card.getSets().size() - 1).URL); | |
| - for (int i = card.getValue().intValue(); i > 0; --i ) { | |
| + Template temp = null; | |
| + final int cardBorder = 0; | |
| + final int height = 319; | |
| + final int width = 222; | |
| + | |
| + /* Create and adjust the configuration */ | |
| + final Configuration cfg = new Configuration(); | |
| + try { | |
| + cfg.setClassForTemplateLoading(DeckHtmlSerializer.class, "/"); | |
| + cfg.setObjectWrapper(new DefaultObjectWrapper()); | |
| + | |
| + /* | |
| + * ------------------------------------------------------------------ | |
| + * - | |
| + */ | |
| + /* | |
| + * You usually do these for many times in the application | |
| + * life-cycle: | |
| + */ | |
| + | |
| + /* Get or create a template */ | |
| + temp = cfg.getTemplate("proxy-template.ftl"); | |
| + | |
| + /* Create a data-model */ | |
| + final Map<String, Object> root = new HashMap<String, Object>(); | |
| + root.put("title", d.getName()); | |
| + final List<String> list = new ArrayList<String>(); | |
| + for (final Entry<PaperCard, Integer> card : d.getMain()) { | |
| + // System.out.println(card.getSets().get(card.getSets().size() - 1).URL); | |
| + for (int i = card.getValue().intValue(); i > 0; --i ) { | |
| - PaperCard r = card.getKey(); | |
| - String url = ForgeConstants.URL_PIC_DOWNLOAD + ImageUtil.getDownloadUrl(r, false); | |
| + final PaperCard r = card.getKey(); | |
| + final String url = ForgeConstants.URL_PIC_DOWNLOAD + ImageUtil.getDownloadUrl(r, false); | |
| - list.add(url); | |
| - } | |
| - } | |
| - | |
| - final TreeMap<String, Integer> map = new TreeMap<String, Integer>(); | |
| - for (final Entry<PaperCard, Integer> entry : d.getMain()) { | |
| - map.put(entry.getKey().getName(), entry.getValue()); | |
| - // System.out.println(entry.getValue() + " " + | |
| - // entry.getKey().getName()); | |
| - } | |
| - | |
| - root.put("urls", list); | |
| - root.put("cardBorder", cardBorder); | |
| - root.put("height", height); | |
| - root.put("width", width); | |
| - root.put("cardlistWidth", width - 11); | |
| - root.put("cardList", map); | |
| - | |
| - /* Merge data-model with template */ | |
| - temp.process(root, out); | |
| - out.flush(); | |
| - } catch (final IOException e) { | |
| - System.out.println(e.toString()); | |
| - } catch (final TemplateException e) { | |
| - System.out.println(e.toString()); | |
| - } | |
| - } | |
| + list.add(url); | |
| + } | |
| + } | |
| + | |
| + final TreeMap<String, Integer> map = new TreeMap<String, Integer>(); | |
| + for (final Entry<PaperCard, Integer> entry : d.getMain()) { | |
| + map.put(entry.getKey().getName(), entry.getValue()); | |
| + // System.out.println(entry.getValue() + " " + | |
| + // entry.getKey().getName()); | |
| + } | |
| + | |
| + root.put("urls", list); | |
| + root.put("cardBorder", cardBorder); | |
| + root.put("height", height); | |
| + root.put("width", width); | |
| + root.put("cardlistWidth", width - 11); | |
| + root.put("cardList", map); | |
| + | |
| + /* Merge data-model with template */ | |
| + temp.process(root, out); | |
| + out.flush(); | |
| + } catch (final IOException e) { | |
| + System.out.println(e.toString()); | |
| + } catch (final TemplateException e) { | |
| + System.out.println(e.toString()); | |
| + } | |
| + } | |
| } | |
| \ No newline at end of file | |
| Index: forge-gui/src/main/java/forge/match/input/InputQueue.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui/src/main/java/forge/match/input/InputQueue.java (revision 29316) | |
| +++ forge-gui/src/main/java/forge/match/input/InputQueue.java (revision 29317) | |
| @@ -6,12 +6,12 @@ | |
| * 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 <http://www.gnu.org/licenses/>. | |
| */ | |
| @@ -28,7 +28,7 @@ | |
| * <p> | |
| * InputControl class. | |
| * </p> | |
| - * | |
| + * | |
| * @author Forge | |
| * @version $Id: InputQueue.java 24769 2014-02-09 13:56:04Z Hellfish $ | |
| */ | |
| @@ -50,8 +50,8 @@ | |
| return inputStack.isEmpty() ? null : inputStack.peek(); | |
| } | |
| - public final void removeInput(Input inp) { | |
| - Input topMostInput = inputStack.isEmpty() ? null : inputStack.pop(); | |
| + public final void removeInput(final Input inp) { | |
| + final Input topMostInput = inputStack.isEmpty() ? null : inputStack.pop(); | |
| if (topMostInput != inp) { | |
| throw new RuntimeException("Cannot remove input " + inp.getClass().getSimpleName() + " because it's not on top of stack. Stack = " + inputStack ); | |
| Index: forge-gui-desktop/src/main/java/forge/screens/home/online/COnlineLobby.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/home/online/COnlineLobby.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/home/online/COnlineLobby.java (revision 29317) | |
| @@ -1,6 +1,5 @@ | |
| package forge.screens.home.online; | |
| -import forge.UiCommand; | |
| import forge.gui.framework.ICDoc; | |
| import forge.screens.home.CLobby; | |
| import forge.screens.home.VLobby; | |
| @@ -10,7 +9,7 @@ | |
| private CLobby lobby; | |
| - void setLobby(VLobby lobbyView) { | |
| + void setLobby(final VLobby lobbyView) { | |
| lobby = new CLobby(lobbyView); | |
| initialize(); | |
| } | |
| @@ -37,14 +36,6 @@ | |
| if (lobby != null) { | |
| lobby.initialize(); | |
| } | |
| - } | |
| - | |
| - /* (non-Javadoc) | |
| - * @see forge.gui.framework.ICDoc#getCommandOnSelect() | |
| - */ | |
| - @Override | |
| - public UiCommand getCommandOnSelect() { | |
| - return null; | |
| } | |
| } | |
| Index: forge-gui-desktop/src/main/java/forge/toolbox/FOverlay.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/toolbox/FOverlay.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/toolbox/FOverlay.java (revision 29317) | |
| @@ -6,38 +6,39 @@ | |
| * 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 <http://www.gnu.org/licenses/>. | |
| */ | |
| package forge.toolbox; | |
| -import forge.gui.SOverlayUtils; | |
| -import forge.toolbox.FSkin.SkinnedPanel; | |
| - | |
| -import javax.swing.*; | |
| - | |
| -import java.awt.*; | |
| +import java.awt.Color; | |
| +import java.awt.Graphics; | |
| import java.awt.event.KeyAdapter; | |
| import java.awt.event.MouseAdapter; | |
| import java.awt.event.MouseEvent; | |
| import java.awt.event.MouseMotionAdapter; | |
| +import javax.swing.BorderFactory; | |
| +import javax.swing.JButton; | |
| + | |
| +import forge.gui.SOverlayUtils; | |
| +import forge.toolbox.FSkin.SkinnedPanel; | |
| + | |
| /** | |
| * Semi-transparent overlay panel. Should be used with layered panes. | |
| - * | |
| + * | |
| */ | |
| // Currently used only once, in top level UI, with layering already in place. | |
| // Getter in AllZone: getOverlay() | |
| @SuppressWarnings("serial") | |
| public enum FOverlay { | |
| - /** */ | |
| SINGLETON_INSTANCE; | |
| private final JButton btnClose = new JButton("X"); | |
| @@ -74,7 +75,7 @@ | |
| * Gets the close button, which must be added dynamically since different | |
| * overlays have different layouts. The overlay does not have the close | |
| * button by default, but a fully working instance is available if required. | |
| - * | |
| + * | |
| * @return JButton | |
| */ | |
| public JButton getBtnClose() { | |
| @@ -90,7 +91,7 @@ | |
| * For some reason, the alpha channel background doesn't work properly on | |
| * Windows 7, so the paintComponent override is required for a | |
| * semi-transparent overlay. | |
| - * | |
| + * | |
| * @param g | |
| *   Graphics object | |
| */ | |
| Index: forge-gui-desktop/src/main/java/forge/screens/deckeditor/DeckImport.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/deckeditor/DeckImport.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/deckeditor/DeckImport.java (revision 29317) | |
| @@ -6,17 +6,26 @@ | |
| * 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 <http://www.gnu.org/licenses/>. | |
| */ | |
| package forge.screens.deckeditor; | |
| +import java.awt.event.ActionEvent; | |
| +import java.awt.event.ActionListener; | |
| +import java.awt.event.WindowEvent; | |
| +import java.util.List; | |
| + | |
| +import javax.swing.BorderFactory; | |
| +import javax.swing.event.DocumentEvent; | |
| +import javax.swing.event.DocumentListener; | |
| + | |
| import forge.deck.Deck; | |
| import forge.deck.DeckBase; | |
| import forge.deck.DeckImportController; | |
| @@ -24,19 +33,18 @@ | |
| import forge.deck.DeckRecognizer.TokenType; | |
| import forge.item.InventoryItem; | |
| import forge.screens.deckeditor.controllers.ACEditorBase; | |
| -import forge.toolbox.*; | |
| +import forge.toolbox.FButton; | |
| +import forge.toolbox.FCheckBox; | |
| +import forge.toolbox.FComboBox; | |
| +import forge.toolbox.FHtmlViewer; | |
| +import forge.toolbox.FLabel; | |
| +import forge.toolbox.FScrollPane; | |
| +import forge.toolbox.FSkin; | |
| +import forge.toolbox.FTextArea; | |
| import forge.view.FDialog; | |
| -import javax.swing.*; | |
| -import javax.swing.event.DocumentEvent; | |
| -import javax.swing.event.DocumentListener; | |
| -import java.awt.event.ActionEvent; | |
| -import java.awt.event.ActionListener; | |
| -import java.awt.event.WindowEvent; | |
| -import java.util.List; | |
| - | |
| /** | |
| - * | |
| + * | |
| * Dialog for quick import of decks. | |
| * | |
| * @param <TItem> | |
| @@ -87,7 +95,7 @@ | |
| private final ACEditorBase<TItem, TModel> host; | |
| - public DeckImport(final ACEditorBase<TItem, TModel> g, boolean allowCardsFromAllSets) { | |
| + public DeckImport(final ACEditorBase<TItem, TModel> g, final boolean allowCardsFromAllSets) { | |
| this.controller = new DeckImportController(!g.getDeckController().isEmpty(), | |
| newEditionCheck, dateTimeCheck, onlyCoreExpCheck, monthDropdown, yearDropdown); | |
| this.host = g; | |
| @@ -102,7 +110,7 @@ | |
| txtInput.setFocusable(true); | |
| txtInput.setEditable(true); | |
| - FSkin.SkinColor foreColor = FSkin.getColor(FSkin.Colors.CLR_TEXT); | |
| + final FSkin.SkinColor foreColor = FSkin.getColor(FSkin.Colors.CLR_TEXT); | |
| this.scrollInput.setBorder(new FSkin.TitledSkinBorder(BorderFactory.createEtchedBorder(), "Paste or type a decklist", foreColor)); | |
| this.scrollOutput.setBorder(new FSkin.TitledSkinBorder(BorderFactory.createEtchedBorder(), "Expect the recognized lines to appear", foreColor)); | |
| this.scrollInput.setViewportBorder(BorderFactory.createLoweredBevelBorder()); | |
| @@ -144,10 +152,9 @@ | |
| } | |
| }); | |
| - ActionListener updateDateCheck = new ActionListener() { | |
| - @Override | |
| - public void actionPerformed(ActionEvent e) { | |
| - boolean isSel = dateTimeCheck.isSelected(); | |
| + final ActionListener updateDateCheck = new ActionListener() { | |
| + @Override public void actionPerformed(final ActionEvent e) { | |
| + final boolean isSel = dateTimeCheck.isSelected(); | |
| monthDropdown.setEnabled(isSel); | |
| yearDropdown.setEnabled(isSel); | |
| parseAndDisplay(); | |
| @@ -155,8 +162,10 @@ | |
| }; | |
| this.dateTimeCheck.addActionListener(updateDateCheck); | |
| - ActionListener reparse = new ActionListener() { | |
| - @Override public void actionPerformed(ActionEvent e) { parseAndDisplay(); } | |
| + final ActionListener reparse = new ActionListener() { | |
| + @Override public void actionPerformed(final ActionEvent e) { | |
| + parseAndDisplay(); | |
| + } | |
| }; | |
| this.newEditionCheck.addActionListener(reparse); | |
| this.onlyCoreExpCheck.addActionListener(reparse); | |
| @@ -192,12 +201,12 @@ | |
| } | |
| private void parseAndDisplay() { | |
| - List<DeckRecognizer.Token> tokens = controller.parseInput(txtInput.getText()); | |
| + final List<DeckRecognizer.Token> tokens = controller.parseInput(txtInput.getText()); | |
| displayTokens(tokens); | |
| updateSummaries(tokens); | |
| } | |
| - private void displayTokens(List<DeckRecognizer.Token> tokens) { | |
| + private void displayTokens(final List<DeckRecognizer.Token> tokens) { | |
| if (tokens.isEmpty()) { | |
| htmlOutput.setText(HTML_WELCOME_TEXT); | |
| } | |
| @@ -212,7 +221,7 @@ | |
| } | |
| } | |
| - private void updateSummaries(List<DeckRecognizer.Token> tokens) { | |
| + private void updateSummaries(final List<DeckRecognizer.Token> tokens) { | |
| final int[] cardsOk = new int[2]; | |
| final int[] cardsUnknown = new int[2]; | |
| int idx = 0; | |
| @@ -232,7 +241,7 @@ | |
| cmdAccept.setEnabled(cardsOk[0] > 0); | |
| } | |
| - private String makeHtmlViewOfToken(final DeckRecognizer.Token token) { | |
| + private static String makeHtmlViewOfToken(final DeckRecognizer.Token token) { | |
| switch (token.getType()) { | |
| case KnownCard: | |
| return String.format("<div class='knowncard'>%s * %s [%s] %s</div>", token.getNumber(), token.getCard() | |
| Index: forge-gui-desktop/src/main/java/forge/toolbox/FTextArea.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/toolbox/FTextArea.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/toolbox/FTextArea.java (revision 29317) | |
| @@ -1,18 +1,16 @@ | |
| package forge.toolbox; | |
| +import java.awt.FontMetrics; | |
| + | |
| import forge.toolbox.FSkin.SkinnedTextArea; | |
| -import java.awt.*; | |
| - | |
| -/** | |
| +/** | |
| * A custom instance of JTextArea using Forge skin properties. | |
| - * | |
| */ | |
| @SuppressWarnings("serial") | |
| public class FTextArea extends SkinnedTextArea { | |
| private boolean autoSize; | |
| - /** */ | |
| public FTextArea() { | |
| super(); | |
| this.setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT)); | |
| @@ -23,7 +21,7 @@ | |
| this.setFocusable(false); | |
| this.setEditable(false); | |
| } | |
| - /** @param str {@java.lang.String} */ | |
| + | |
| public FTextArea(final String str) { | |
| this(); | |
| this.setText(str); | |
| @@ -33,7 +31,7 @@ | |
| return this.autoSize; | |
| } | |
| - public void setAutoSize(boolean autoSize0) { | |
| + public void setAutoSize(final boolean autoSize0) { | |
| if (this.autoSize == autoSize0) { return; } | |
| this.autoSize = autoSize0; | |
| if (autoSize0) { | |
| @@ -51,10 +49,10 @@ | |
| } | |
| int maxLineWidth = 0; | |
| - FontMetrics metrics = this.getGraphics().getFontMetrics(this.getFont()); | |
| - String[] lines = this.getText().split("(\r\n)|(\n)"); | |
| + final FontMetrics metrics = this.getGraphics().getFontMetrics(this.getFont()); | |
| + final String[] lines = this.getText().split("(\r\n)|(\n)"); | |
| for (int i = 0; i < lines.length; i++) { | |
| - int lineWidth = metrics.stringWidth(lines[i]); | |
| + final int lineWidth = metrics.stringWidth(lines[i]); | |
| if (lineWidth > maxLineWidth) { | |
| maxLineWidth = lineWidth; | |
| } | |
| Index: forge-gui-desktop/src/main/java/forge/screens/home/settings/CSubmenuReleaseNotes.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/home/settings/CSubmenuReleaseNotes.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/home/settings/CSubmenuReleaseNotes.java (revision 29317) | |
| @@ -6,26 +6,25 @@ | |
| * 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 <http://www.gnu.org/licenses/>. | |
| */ | |
| package forge.screens.home.settings; | |
| -import forge.UiCommand; | |
| import forge.gui.framework.ICDoc; | |
| import forge.properties.ForgeConstants; | |
| import forge.util.FileUtil; | |
| -/** | |
| +/** | |
| * Controller for VSubmenuReleaseNotes submenu in the home UI. | |
| - * | |
| + * | |
| * @version $Id$ | |
| * | |
| */ | |
| @@ -45,7 +44,7 @@ | |
| * @see forge.control.home.IControlSubmenu#update() | |
| */ | |
| @Override | |
| - public void initialize() { | |
| + public void initialize() { | |
| this.view = VSubmenuReleaseNotes.SINGLETON_INSTANCE; | |
| //this.prefs = FModel.getPreferences(); | |
| } | |
| @@ -54,40 +53,32 @@ | |
| * @see forge.control.home.IControlSubmenu#update() | |
| */ | |
| @Override | |
| - public void update() { | |
| - this.view = VSubmenuReleaseNotes.SINGLETON_INSTANCE; | |
| - //this.prefs = FModel.getPreferences(); | |
| - setReleaseNotesContent(); | |
| + public void update() { | |
| + this.view = VSubmenuReleaseNotes.SINGLETON_INSTANCE; | |
| + //this.prefs = FModel.getPreferences(); | |
| + setReleaseNotesContent(); | |
| } | |
| - | |
| + | |
| private void setReleaseNotesContent() { | |
| if (!this.isReleaseNotesUpdated) { | |
| this.view.setReleaseNotesContent(getReleaseNotes()); | |
| this.isReleaseNotesUpdated = true; | |
| - } | |
| + } | |
| } | |
| - /* (non-Javadoc) | |
| - * @see forge.gui.framework.ICDoc#getCommandOnSelect() | |
| - */ | |
| - @Override | |
| - public UiCommand getCommandOnSelect() { | |
| - return null; | |
| - } | |
| - | |
| /** | |
| * Returns content of CHANGES.txt. | |
| */ | |
| - private String getReleaseNotes() { | |
| + private static String getReleaseNotes() { | |
| // !! Linux is case-sensitive so file name and extension need to match exactly !! | |
| - String filename = ForgeConstants.CHANGES_FILE; | |
| - String filePath = FileUtil.pathCombine(System.getProperty("user.dir"), filename); | |
| + final String filename = ForgeConstants.CHANGES_FILE; | |
| + final String filePath = FileUtil.pathCombine(System.getProperty("user.dir"), filename); | |
| String notes; | |
| - | |
| + | |
| if (FileUtil.doesFileExist(filePath)) { | |
| - notes = filePath + "\n\n" + FileUtil.readFileToString(filePath); | |
| + notes = filePath + "\n\n" + FileUtil.readFileToString(filePath); | |
| } else { | |
| - notes = filePath + "\nis MISSING!"; | |
| + notes = filePath + "\nis MISSING!"; | |
| } | |
| return notes; | |
| Index: forge-gui-desktop/src/main/java/forge/screens/home/CHomeUI.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/home/CHomeUI.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/home/CHomeUI.java (revision 29317) | |
| @@ -5,7 +5,6 @@ | |
| import javax.swing.JMenu; | |
| import forge.Singletons; | |
| -import forge.UiCommand; | |
| import forge.gui.framework.EDocID; | |
| import forge.gui.framework.ICDoc; | |
| import forge.menus.IMenuProvider; | |
| @@ -32,7 +31,7 @@ | |
| /** Programatically selects a menu item. | |
| * @param id0 {@link forge.gui.framework.EDocID} */ | |
| - public void itemClick(EDocID id0) { | |
| + public void itemClick(final EDocID id0) { | |
| final ForgePreferences prefs = FModel.getPreferences(); | |
| if (lblSelected != null) { | |
| @@ -87,14 +86,6 @@ | |
| */ | |
| @Override | |
| public void update() { | |
| - } | |
| - | |
| - /* (non-Javadoc) | |
| - * @see forge.view.home.ICDoc#getCommandOnSelect() | |
| - */ | |
| - @Override | |
| - public UiCommand getCommandOnSelect() { | |
| - return null; | |
| } | |
| /** | |
| Index: forge-gui-desktop/src/main/java/forge/toolbox/FComboBoxWrapper.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/toolbox/FComboBoxWrapper.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/toolbox/FComboBoxWrapper.java (revision 29317) | |
| @@ -5,7 +5,6 @@ | |
| import java.awt.event.ItemListener; | |
| import java.awt.event.KeyListener; | |
| import java.util.ArrayList; | |
| -import java.util.Vector; | |
| import javax.swing.ComboBoxModel; | |
| import javax.swing.JComponent; | |
| @@ -17,7 +16,7 @@ | |
| import forge.toolbox.FComboBox.TextAlignment; | |
| import forge.toolbox.FSkin.SkinFont; | |
| -/** | |
| +/** | |
| * Wrapper for combo box with extra logic (either FComboBoxWrapper or FComboBoxPanel should be used instead of FComboBox so skinning works) | |
| * | |
| */ | |
| @@ -26,7 +25,7 @@ | |
| private static final ArrayList<FComboBoxWrapper<?>> allWrappers = new ArrayList<FComboBoxWrapper<?>>(); | |
| public static void refreshAllSkins() { | |
| - for (FComboBoxWrapper<?> wrapper : allWrappers) { | |
| + for (final FComboBoxWrapper<?> wrapper : allWrappers) { | |
| wrapper.refreshSkin(); | |
| } | |
| } | |
| @@ -41,62 +40,50 @@ | |
| allWrappers.add(this); | |
| } | |
| - public FComboBoxWrapper(E[] items) { | |
| - super(); | |
| - comboBox = new FComboBox<E>(items); | |
| - allWrappers.add(this); | |
| - } | |
| - | |
| - public FComboBoxWrapper(Vector<E> items) { | |
| - super(); | |
| - comboBox = new FComboBox<E>(items); | |
| - allWrappers.add(this); | |
| - } | |
| - | |
| - public FComboBoxWrapper(ComboBoxModel<E> aModel) { | |
| - super(); | |
| - comboBox = new FComboBox<E>(aModel); | |
| - allWrappers.add(this); | |
| - } | |
| - | |
| - public void addItem(E item) { | |
| + @Override | |
| + public void addItem(final E item) { | |
| comboBox.addItem(item); | |
| } | |
| - public void removeItem(E item) { | |
| + public void removeItem(final E item) { | |
| comboBox.removeItem(item); | |
| } | |
| + @Override | |
| public void removeAllItems() { | |
| comboBox.removeAllItems(); | |
| } | |
| + @Override | |
| @SuppressWarnings("unchecked") | |
| public E getSelectedItem() { | |
| - Object res = comboBox.getSelectedItem(); | |
| + final Object res = comboBox.getSelectedItem(); | |
| return res == null ? null : (E) res; | |
| } | |
| - public void setSelectedItem(Object item) { | |
| + @Override | |
| + public void setSelectedItem(final Object item) { | |
| comboBox.setSelectedItem(item); | |
| } | |
| + @Override | |
| public int getSelectedIndex() { | |
| return comboBox.getSelectedIndex(); | |
| } | |
| - public void setSelectedIndex(int index) { | |
| + @Override | |
| + public void setSelectedIndex(final int index) { | |
| comboBox.setSelectedIndex(index); | |
| } | |
| public String getText() { | |
| return comboBox.getText(); | |
| } | |
| - public void setText(String text0) { | |
| + public void setText(final String text0) { | |
| comboBox.setText(text0); | |
| } | |
| - public void setMaximumRowCount(int count) { | |
| + public void setMaximumRowCount(final int count) { | |
| comboBox.setMaximumRowCount(count); | |
| } | |
| @@ -104,15 +91,15 @@ | |
| return comboBox.getItemCount(); | |
| } | |
| - public E getItemAt(int index) { | |
| + public E getItemAt(final int index) { | |
| return comboBox.getItemAt(index); | |
| } | |
| - public void addActionListener(ActionListener l) { | |
| + public void addActionListener(final ActionListener l) { | |
| comboBox.addActionListener(l); | |
| } | |
| - public void addItemListener(ItemListener l) { | |
| + public void addItemListener(final ItemListener l) { | |
| comboBox.addItemListener(l); | |
| } | |
| @@ -123,7 +110,7 @@ | |
| } | |
| suppressedActionListeners = suppressedActionListeners == null | |
| ? listeners | |
| - : ObjectArrays.concat(suppressedActionListeners, listeners, ActionListener.class); | |
| + : ObjectArrays.concat(suppressedActionListeners, listeners, ActionListener.class); | |
| } | |
| public void unsuppressActionListeners() { | |
| if (suppressedActionListeners != null) { | |
| @@ -134,23 +121,23 @@ | |
| } | |
| } | |
| - public void addKeyListener(KeyListener l) { | |
| + public void addKeyListener(final KeyListener l) { | |
| comboBox.addKeyListener(l); | |
| } | |
| - public void setRenderer(ListCellRenderer<? super E> aRenderer) { | |
| + public void setRenderer(final ListCellRenderer<? super E> aRenderer) { | |
| comboBox.setRenderer(aRenderer); | |
| } | |
| - public void setModel(ComboBoxModel<E> aModel) { | |
| + public void setModel(final ComboBoxModel<E> aModel) { | |
| comboBox.setModel(aModel); | |
| } | |
| - public void setTextAlignment(TextAlignment align) { | |
| + public void setTextAlignment(final TextAlignment align) { | |
| comboBox.setTextAlignment(align); | |
| } | |
| - public void setSkinFont(SkinFont skinFont) { | |
| + public void setSkinFont(final SkinFont skinFont) { | |
| comboBox.setSkinFont(skinFont); | |
| } | |
| @@ -160,7 +147,7 @@ | |
| } | |
| @Override | |
| - public void setVisible(boolean aFlag) { | |
| + public void setVisible(final boolean aFlag) { | |
| comboBox.setVisible(aFlag); | |
| } | |
| @@ -170,7 +157,7 @@ | |
| } | |
| @Override | |
| - public void setEnabled(boolean aFlag) { | |
| + public void setEnabled(final boolean aFlag) { | |
| comboBox.setEnabled(aFlag); | |
| } | |
| @@ -178,10 +165,10 @@ | |
| return comboBox.getAutoSizeWidth(); | |
| } | |
| - public void addTo(Container container) { | |
| + public void addTo(final Container container) { | |
| addTo(container, null); | |
| } | |
| - public void addTo(Container container, Object constraints0) { | |
| + public void addTo(final Container container, final Object constraints0) { | |
| container.add(comboBox, constraints0); | |
| constraints = constraints0; | |
| } | |
| @@ -198,12 +185,12 @@ | |
| //refresh combo box skin by replacing it with a copy of itself | |
| //TODO: Figure out if there's a better way, as calling updateUI doesn't seem to work | |
| - public static <E> FComboBox<E> refreshComboBoxSkin(FComboBox<E> comboBox) { | |
| + public static <E> FComboBox<E> refreshComboBoxSkin(final FComboBox<E> comboBox) { | |
| return refreshComboBoxSkin(comboBox, null); | |
| } | |
| - public static <E> FComboBox<E> refreshComboBoxSkin(FComboBox<E> comboBox, Object constraints) { | |
| + public static <E> FComboBox<E> refreshComboBoxSkin(final FComboBox<E> comboBox, final Object constraints) { | |
| //find index of combo box within parent | |
| - Container parent = comboBox.getParent(); | |
| + final Container parent = comboBox.getParent(); | |
| if (parent == null) { return comboBox; } | |
| int index; | |
| @@ -214,36 +201,36 @@ | |
| } | |
| //create copy of combo box | |
| - FComboBox<E> newComboBox = new FComboBox<E>(); | |
| + final FComboBox<E> newComboBox = new FComboBox<E>(); | |
| for (int i = 0; i < comboBox.getItemCount(); i++) { | |
| newComboBox.addItem(comboBox.getItemAt(i)); | |
| } | |
| newComboBox.setSelectedIndex(comboBox.getSelectedIndex()); | |
| ActionListener[] actionListeners = newComboBox.getActionListeners(); | |
| - for (ActionListener l : actionListeners) { | |
| + for (final ActionListener l : actionListeners) { | |
| newComboBox.removeActionListener(l); //remove default action listeners to prevent duplicates | |
| } | |
| actionListeners = comboBox.getActionListeners(); | |
| - for (ActionListener l : actionListeners) { | |
| + for (final ActionListener l : actionListeners) { | |
| newComboBox.addActionListener(l); | |
| } | |
| ItemListener[] itemListeners = newComboBox.getItemListeners(); | |
| - for (ItemListener l : itemListeners) { | |
| + for (final ItemListener l : itemListeners) { | |
| newComboBox.removeItemListener(l); //remove default item listener to prevent duplicates | |
| } | |
| itemListeners = comboBox.getItemListeners(); | |
| - for (ItemListener l : itemListeners) { | |
| + for (final ItemListener l : itemListeners) { | |
| newComboBox.addItemListener(l); | |
| } | |
| KeyListener[] keyListeners = newComboBox.getKeyListeners(); | |
| - for (KeyListener l : keyListeners) { | |
| + for (final KeyListener l : keyListeners) { | |
| newComboBox.removeKeyListener(l); //remove default key listeners to prevent duplicates | |
| } | |
| keyListeners = comboBox.getKeyListeners(); | |
| - for (KeyListener l : keyListeners) { | |
| + for (final KeyListener l : keyListeners) { | |
| newComboBox.addKeyListener(l); | |
| } | |
| \ No newline at end of file | |
| Index: forge-gui/src/main/java/forge/match/input/InputSyncronizedBase.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui/src/main/java/forge/match/input/InputSyncronizedBase.java (revision 29316) | |
| +++ forge-gui/src/main/java/forge/match/input/InputSyncronizedBase.java (revision 29317) | |
| @@ -15,16 +15,17 @@ | |
| cdlDone = new CountDownLatch(1); | |
| } | |
| + @Override | |
| public void awaitLatchRelease() { | |
| FThreads.assertExecutedByEdt(false); | |
| try{ | |
| cdlDone.await(); | |
| - } | |
| - catch (InterruptedException e) { | |
| + } catch (final InterruptedException e) { | |
| BugReporter.reportException(e); | |
| } | |
| } | |
| + @Override | |
| public final void relaseLatchWhenGameIsOver() { | |
| cdlDone.countDown(); | |
| } | |
| @@ -33,7 +34,7 @@ | |
| getController().getInputQueue().setInput(this); | |
| awaitLatchRelease(); | |
| } | |
| - | |
| + | |
| protected final void stop() { | |
| onStop(); | |
| \ No newline at end of file | |
| Index: forge-gui-desktop/src/main/java/forge/screens/match/controllers/CAntes.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/match/controllers/CAntes.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/match/controllers/CAntes.java (revision 29317) | |
| @@ -1,13 +1,12 @@ | |
| package forge.screens.match.controllers; | |
| -import forge.UiCommand; | |
| import forge.gui.framework.ICDoc; | |
| import forge.screens.match.CMatchUI; | |
| import forge.screens.match.views.VAntes; | |
| -/** | |
| +/** | |
| * Controls the ante panel in the match UI. | |
| - * | |
| + * | |
| * <br><br><i>(C at beginning of class name denotes a control class.)</i> | |
| * | |
| */ | |
| @@ -17,14 +16,6 @@ | |
| public CAntes(final CMatchUI matchUI) { | |
| this.matchUI = matchUI; | |
| this.view = new VAntes(this); | |
| - } | |
| - | |
| - /* (non-Javadoc) | |
| - * @see forge.gui.framework.ICDoc#getCommandOnSelect() | |
| - */ | |
| - @Override | |
| - public UiCommand getCommandOnSelect() { | |
| - return null; | |
| } | |
| @Override | |
| Index: forge-gui/src/main/java/forge/card/CardScriptInfo.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui/src/main/java/forge/card/CardScriptInfo.java (revision 29316) | |
| +++ forge-gui/src/main/java/forge/card/CardScriptInfo.java (revision 29317) | |
| @@ -6,12 +6,12 @@ | |
| * 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 <http://www.gnu.org/licenses/>. | |
| */ | |
| @@ -19,21 +19,17 @@ | |
| import java.io.File; | |
| import java.io.PrintWriter; | |
| -import java.util.List; | |
| import java.util.Map; | |
| import java.util.concurrent.ConcurrentHashMap; | |
| -import org.apache.commons.lang3.StringUtils; | |
| - | |
| -import forge.CardStorageReader; | |
| import forge.properties.ForgeConstants; | |
| import forge.util.FileUtil; | |
| public final class CardScriptInfo { | |
| private String text; | |
| - private File file; | |
| + private final File file; | |
| - public CardScriptInfo(String text0, File file0) { | |
| + public CardScriptInfo(final String text0, final File file0) { | |
| text = text0; | |
| file = file0; | |
| } | |
| @@ -43,18 +39,18 @@ | |
| } | |
| public File getFile() { | |
| - return file; | |
| + return file; | |
| } | |
| public boolean canEdit() { | |
| - return file != null; | |
| + return file != null; | |
| } | |
| - public boolean trySetText(String text0) { | |
| + public boolean trySetText(final String text0) { | |
| if (file == null) { return false; } | |
| try { | |
| - PrintWriter p = new PrintWriter(file); | |
| + final PrintWriter p = new PrintWriter(file); | |
| p.print(text0); | |
| p.close(); | |
| @@ -69,15 +65,11 @@ | |
| } | |
| private static Map<String, CardScriptInfo> allScripts = new ConcurrentHashMap<>(); | |
| - public static void addCard(String name, String script, File file) { | |
| - allScripts.put(name, new CardScriptInfo(script, file)); | |
| - } | |
| - | |
| - public static CardScriptInfo getScriptFor(String name) { | |
| + public static CardScriptInfo getScriptFor(final String name) { | |
| CardScriptInfo script = allScripts.get(name); | |
| if (script == null) { //attempt to load script if not previously loaded | |
| - String filename = name.toLowerCase().replace(' ', '_').replace('-', '_').replace("'", "").replace(",", "") + ".txt"; | |
| - File file = new File(ForgeConstants.CARD_DATA_DIR + filename.charAt(0) + File.separator + filename); | |
| + final String filename = name.toLowerCase().replace(' ', '_').replace('-', '_').replace("'", "").replace(",", "") + ".txt"; | |
| + final File file = new File(ForgeConstants.CARD_DATA_DIR + filename.charAt(0) + File.separator + filename); | |
| if (file.exists()) { | |
| script = new CardScriptInfo(FileUtil.readFileToString(file), file); | |
| allScripts.put(name, script); | |
| @@ -86,10 +78,4 @@ | |
| return script; | |
| } | |
| - public static CardStorageReader.Observer readerObserver = new CardStorageReader.Observer() { | |
| - @Override | |
| - public void cardLoaded(CardRules rules, List<String> lines, File fileOnDisk) { | |
| - allScripts.put(rules.getName(), new CardScriptInfo(StringUtils.join(lines, '\n'), fileOnDisk)); | |
| - } | |
| - }; | |
| } | |
| Index: forge-gui-desktop/src/main/java/forge/toolbox/FPasswordField.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/toolbox/FPasswordField.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/toolbox/FPasswordField.java (revision 29317) | |
| @@ -1,14 +1,21 @@ | |
| package forge.toolbox; | |
| +import java.awt.Cursor; | |
| +import java.awt.FontMetrics; | |
| +import java.awt.Graphics; | |
| +import java.awt.Graphics2D; | |
| +import java.awt.Insets; | |
| +import java.awt.RenderingHints; | |
| +import java.awt.event.FocusAdapter; | |
| +import java.awt.event.FocusEvent; | |
| + | |
| +import javax.swing.SwingUtilities; | |
| +import javax.swing.event.DocumentEvent; | |
| +import javax.swing.event.DocumentListener; | |
| + | |
| import forge.gui.MouseUtil; | |
| import forge.interfaces.ITextField; | |
| import forge.toolbox.FSkin.SkinnedPasswordField; | |
| -import javax.swing.*; | |
| -import javax.swing.event.DocumentEvent; | |
| -import javax.swing.event.DocumentListener; | |
| -import java.awt.*; | |
| -import java.awt.event.FocusAdapter; | |
| -import java.awt.event.FocusEvent; | |
| /** | |
| * A custom instance of JPasswordField using Forge skin properties. | |
| @@ -16,7 +23,6 @@ | |
| */ | |
| @SuppressWarnings("serial") | |
| public class FPasswordField extends SkinnedPasswordField implements ITextField { | |
| - public static final int HEIGHT = 25; //TODO: calculate this somehow instead of hard-coding it | |
| private static final FSkin.SkinColor textColor = FSkin.getColor(FSkin.Colors.CLR_TEXT); | |
| private static final FSkin.SkinColor ghostTextColor = textColor.stepColor(20); | |
| private static final FSkin.SkinColor backColor = FSkin.getColor(FSkin.Colors.CLR_THEME2); | |
| @@ -114,10 +120,6 @@ | |
| if (this.isEmpty() && this.hasFocus()) { | |
| this.repaint(); | |
| } | |
| - } | |
| - | |
| - public void addChangeListener(ChangeListener listener) { | |
| - this.getDocument().addDocumentListener(listener); | |
| } | |
| public static abstract class ChangeListener implements DocumentListener { | |
| Index: forge-gui-desktop/src/main/java/forge/screens/home/settings/CSubmenuDownloaders.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/home/settings/CSubmenuDownloaders.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/home/settings/CSubmenuDownloaders.java (revision 29317) | |
| @@ -1,5 +1,7 @@ | |
| package forge.screens.home.settings; | |
| +import javax.swing.SwingUtilities; | |
| + | |
| import forge.UiCommand; | |
| import forge.download.GuiDownloadPicturesLQ; | |
| import forge.download.GuiDownloadPrices; | |
| @@ -10,8 +12,6 @@ | |
| import forge.gui.ImportDialog; | |
| import forge.gui.framework.ICDoc; | |
| -import javax.swing.*; | |
| - | |
| /** | |
| * Controls the utilities submenu in the home UI. | |
| * | |
| @@ -22,23 +22,46 @@ | |
| public enum CSubmenuDownloaders implements ICDoc { | |
| SINGLETON_INSTANCE; | |
| - private final UiCommand cmdLicensing = new UiCommand() { @Override | |
| - public void run() { VSubmenuDownloaders.SINGLETON_INSTANCE.showLicensing(); } }; | |
| - private final UiCommand cmdPicDownload = new UiCommand() { @Override | |
| - public void run() { new GuiDownloader(new GuiDownloadPicturesLQ()); } }; | |
| - private final UiCommand cmdSetDownload = new UiCommand() { @Override | |
| - public void run() { new GuiDownloader(new GuiDownloadSetPicturesLQ()); } }; | |
| - private final UiCommand cmdQuestImages = new UiCommand() { @Override | |
| - public void run() { new GuiDownloader(new GuiDownloadQuestImages()); } }; | |
| - private final UiCommand cmdDownloadPrices = new UiCommand() { @Override | |
| - public void run() { new GuiDownloader(new GuiDownloadPrices()); } }; | |
| - private final UiCommand cmdHowToPlay = new UiCommand() { @Override | |
| - public void run() { VSubmenuDownloaders.SINGLETON_INSTANCE.showHowToPlay(); } }; | |
| - private final UiCommand cmdImportPictures = new UiCommand() { @Override | |
| - public void run() { new ImportDialog(null, null); } }; | |
| - private final UiCommand cmdReportBug = new UiCommand() { @Override | |
| - public void run() { BugReporter.reportBug(null); } | |
| + private final UiCommand cmdLicensing = new UiCommand() { | |
| + @Override public void run() { | |
| + VSubmenuDownloaders.SINGLETON_INSTANCE.showLicensing(); | |
| + } | |
| }; | |
| + private final UiCommand cmdPicDownload = new UiCommand() { | |
| + @Override public void run() { | |
| + new GuiDownloader(new GuiDownloadPicturesLQ()).show(); | |
| + } | |
| + }; | |
| + private final UiCommand cmdSetDownload = new UiCommand() { | |
| + @Override public void run() { | |
| + new GuiDownloader(new GuiDownloadSetPicturesLQ()).show(); | |
| + } | |
| + }; | |
| + private final UiCommand cmdQuestImages = new UiCommand() { | |
| + @Override public void run() { | |
| + new GuiDownloader(new GuiDownloadQuestImages()).show(); | |
| + } | |
| + }; | |
| + private final UiCommand cmdDownloadPrices = new UiCommand() { | |
| + @Override public void run() { | |
| + new GuiDownloader(new GuiDownloadPrices()).show(); | |
| + } | |
| + }; | |
| + private final UiCommand cmdHowToPlay = new UiCommand() { | |
| + @Override public void run() { | |
| + VSubmenuDownloaders.SINGLETON_INSTANCE.showHowToPlay(); | |
| + } | |
| + }; | |
| + private final UiCommand cmdImportPictures = new UiCommand() { | |
| + @Override public void run() { | |
| + new ImportDialog(null, null).show(); | |
| + } | |
| + }; | |
| + private final UiCommand cmdReportBug = new UiCommand() { | |
| + @Override public void run() { | |
| + BugReporter.reportBug(null); | |
| + } | |
| + }; | |
| @Override | |
| public void register() { | |
| @@ -73,11 +96,4 @@ | |
| }); | |
| } | |
| - /* (non-Javadoc) | |
| - * @see forge.gui.framework.ICDoc#getCommandOnSelect() | |
| - */ | |
| - @Override | |
| - public UiCommand getCommandOnSelect() { | |
| - return null; | |
| - } | |
| } | |
| Index: forge-gui-mobile/src/forge/screens/settings/GuiDownloader.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-mobile/src/forge/screens/settings/GuiDownloader.java (revision 29316) | |
| +++ forge-gui-mobile/src/forge/screens/settings/GuiDownloader.java (revision 29317) | |
| @@ -6,12 +6,12 @@ | |
| * 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 <http://www.gnu.org/licenses/>. | |
| */ | |
| @@ -23,9 +23,13 @@ | |
| import forge.UiCommand; | |
| import forge.download.GuiDownloadService; | |
| import forge.download.GuiDownloadZipService; | |
| -import forge.toolbox.*; | |
| +import forge.toolbox.FDialog; | |
| +import forge.toolbox.FEvent; | |
| import forge.toolbox.FEvent.FEventHandler; | |
| +import forge.toolbox.FProgressBar; | |
| +import forge.toolbox.FRadioButton; | |
| import forge.toolbox.FRadioButton.RadioButtonGroup; | |
| +import forge.toolbox.FTextField; | |
| import forge.util.Callback; | |
| import forge.util.Utils; | |
| @@ -42,8 +46,7 @@ | |
| @SuppressWarnings("serial") | |
| private final UiCommand cmdClose = new UiCommand() { | |
| - @Override | |
| - public void run() { | |
| + @Override public void run() { | |
| Forge.stopContinuousRendering(); | |
| service.setCancel(true); | |
| hide(); | |
| @@ -56,10 +59,10 @@ | |
| private final GuiDownloadService service; | |
| private final Callback<Boolean> callback; | |
| - public GuiDownloader(GuiDownloadService service0) { | |
| + public GuiDownloader(final GuiDownloadService service0) { | |
| this(service0, null); | |
| } | |
| - public GuiDownloader(GuiDownloadService service0, Callback<Boolean> callback0) { | |
| + public GuiDownloader(final GuiDownloadService service0, final Callback<Boolean> callback0) { | |
| super(service0.getTitle(), 2); | |
| service = service0; | |
| callback = callback0; | |
| @@ -69,7 +72,7 @@ | |
| txtAddress.setEnabled(false); | |
| txtPort.setEnabled(false); | |
| - RadioButtonGroup group = new RadioButtonGroup(); | |
| + final RadioButtonGroup group = new RadioButtonGroup(); | |
| radProxyNone.setGroup(group); | |
| radProxyHTTP.setGroup(group); | |
| radProxySocks.setGroup(group); | |
| @@ -81,8 +84,7 @@ | |
| getButton(0).setText("Start"); | |
| initButton(1, "Cancel", new FEventHandler() { | |
| - @Override | |
| - public void handleEvent(FEvent e) { | |
| + @Override public void handleEvent(final FEvent e) { | |
| cmdClose.run(); | |
| } | |
| }); | |
| @@ -90,6 +92,10 @@ | |
| progressBar.reset(); | |
| progressBar.setShowProgressTrail(true); | |
| progressBar.setDescription("Scanning for existing items..."); | |
| + } | |
| + | |
| + @Override | |
| + public void show() { | |
| Forge.startContinuousRendering(); | |
| show(); | |
| @@ -113,7 +119,7 @@ | |
| } | |
| @Override | |
| - public void handleEvent(FEvent e) { | |
| + public void handleEvent(final FEvent e) { | |
| if (((FRadioButton) e.getSource()).isSelected()) { | |
| service.setType(this.type); | |
| txtAddress.setEnabled(this.type != 0); | |
| @@ -123,12 +129,12 @@ | |
| } | |
| @Override | |
| - protected float layoutAndGetHeight(float width, float maxHeight) { | |
| + protected float layoutAndGetHeight(final float width, final float maxHeight) { | |
| float x = PADDING; | |
| float y = PADDING; | |
| - float w = width - 2 * PADDING; | |
| - float radioButtonWidth = w / 3; | |
| - float radioButtonHeight = radProxyNone.getAutoSizeBounds().height; | |
| + final float w = width - 2 * PADDING; | |
| + final float radioButtonWidth = w / 3; | |
| + final float radioButtonHeight = radProxyNone.getAutoSizeBounds().height; | |
| radProxyNone.setBounds(x, y, radioButtonWidth, radioButtonHeight); | |
| x += radioButtonWidth; | |
| Index: forge-gui-desktop/src/main/java/forge/screens/match/controllers/CHand.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/match/controllers/CHand.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/match/controllers/CHand.java (revision 29317) | |
| @@ -6,12 +6,12 @@ | |
| * 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 <http://www.gnu.org/licenses/>. | |
| */ | |
| @@ -22,7 +22,6 @@ | |
| import java.awt.event.MouseEvent; | |
| import java.util.ArrayList; | |
| import java.util.List; | |
| -import java.util.Observable; | |
| import javax.swing.JLayeredPane; | |
| import javax.swing.SwingUtilities; | |
| @@ -32,7 +31,6 @@ | |
| import forge.FThreads; | |
| import forge.Singletons; | |
| -import forge.UiCommand; | |
| import forge.game.card.CardView; | |
| import forge.game.player.PlayerView; | |
| import forge.gui.framework.ICDoc; | |
| @@ -55,9 +53,6 @@ | |
| /** | |
| * Controls Swing components of a player's hand instance. | |
| - * | |
| - * @param p0   {@link forge.game.player.Player} | |
| - * @param v0   {@link forge.screens.match.views.VHand} | |
| */ | |
| public CHand(final CMatchUI matchUI, final PlayerView p0, final VHand v0) { | |
| this.matchUI = matchUI; | |
| @@ -65,7 +60,7 @@ | |
| this.view = v0; | |
| v0.getHandArea().addCardPanelMouseListener(new CardPanelMouseAdapter() { | |
| @Override | |
| - public void mouseDragEnd(CardPanel dragPanel, MouseEvent evt) { | |
| + public void mouseDragEnd(final CardPanel dragPanel, final MouseEvent evt) { | |
| //update index of dragged card in hand zone to match new index within hand area | |
| final int index = CHand.this.view.getHandArea().getCardPanels().indexOf(dragPanel); | |
| synchronized (ordering) { | |
| @@ -85,14 +80,6 @@ | |
| public void initialize() { | |
| } | |
| - public void update(final Observable a, final Object b) { | |
| - FThreads.invokeInEdtNowOrLater(updateRoutine); | |
| - } | |
| - | |
| - private final Runnable updateRoutine = new Runnable() { | |
| - @Override public void run() { updateHand(); } | |
| - }; | |
| - | |
| public void updateHand() { | |
| FThreads.assertExecutedByEdt(true); | |
| @@ -149,7 +136,7 @@ | |
| p.setCardPanels(cardPanels); | |
| //animate new cards into positions defined by placeholders | |
| - JLayeredPane layeredPane = Singletons.getView().getFrame().getLayeredPane(); | |
| + final JLayeredPane layeredPane = Singletons.getView().getFrame().getLayeredPane(); | |
| int fromZoneX = 0, fromZoneY = 0; | |
| final Point zoneLocation = SwingUtilities.convertPoint(vf.getDetailsPanel().getLblLibrary(), | |
| @@ -178,14 +165,6 @@ | |
| Animation.moveCard(placeholder); | |
| } | |
| } | |
| - } | |
| - | |
| - /* (non-Javadoc) | |
| - * @see forge.gui.framework.ICDoc#getCommandOnSelect() | |
| - */ | |
| - @Override | |
| - public UiCommand getCommandOnSelect() { | |
| - return null; | |
| } | |
| @Override | |
| Index: forge-gui-desktop/src/main/java/forge/sound/AudioClip.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/sound/AudioClip.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/sound/AudioClip.java (revision 29317) | |
| @@ -67,6 +67,7 @@ | |
| throw new MissingResourceException("Sound clip failed to load", this.getClass().getName(), filename); | |
| } | |
| + @Override | |
| public final void play() { | |
| if (null == clip) { | |
| return; | |
| @@ -80,6 +81,7 @@ | |
| clip.start(); | |
| } | |
| + @Override | |
| public final void loop() { | |
| if (null == clip) { | |
| return; | |
| @@ -93,6 +95,7 @@ | |
| clip.loop(Clip.LOOP_CONTINUOUSLY); | |
| } | |
| + @Override | |
| public final void stop() { | |
| if (null == clip) { | |
| return; | |
| @@ -100,6 +103,7 @@ | |
| clip.stop(); | |
| } | |
| + @Override | |
| public final boolean isDone() { | |
| if (null == clip) { | |
| return false; | |
| Index: forge-gui-desktop/src/main/java/forge/gui/MultiLineLabel.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/gui/MultiLineLabel.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/gui/MultiLineLabel.java (revision 29317) | |
| @@ -6,19 +6,21 @@ | |
| * 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 <http://www.gnu.org/licenses/>. | |
| */ | |
| package forge.gui; | |
| -import javax.swing.*; | |
| -import java.awt.*; | |
| +import java.awt.Rectangle; | |
| + | |
| +import javax.swing.JLabel; | |
| +import javax.swing.SwingConstants; | |
| /** | |
| * A {@link JLabel} with support for multi-line text that wraps when the line | |
| @@ -26,7 +28,7 @@ | |
| * {@link MultiLineLabelUI}, the default UI delegate of this component. The text | |
| * in the label can be horizontally and vertically aligned, relative to the | |
| * bounds of the component. | |
| - * | |
| + * | |
| * @author Samuel Sjoberg, http://samuelsjoberg.com | |
| * @version 1.0.0 | |
| */ | |
| @@ -62,7 +64,7 @@ | |
| /** | |
| * Creates a new label with <code>text</code> value. | |
| - * | |
| + * | |
| * @param text | |
| * the value of the label | |
| */ | |
| @@ -73,7 +75,7 @@ | |
| /** | |
| * {@inheritDoc} | |
| - * | |
| + * | |
| * @return a {@link java.awt.Rectangle} object. | |
| */ | |
| @Override | |
| @@ -86,7 +88,7 @@ | |
| /** | |
| * Set the vertical text alignment. | |
| - * | |
| + * | |
| * @param alignment | |
| * vertical alignment | |
| */ | |
| @@ -97,7 +99,7 @@ | |
| /** | |
| * Set the horizontal text alignment. | |
| - * | |
| + * | |
| * @param alignment | |
| * horizontal alignment | |
| */ | |
| @@ -108,7 +110,7 @@ | |
| /** | |
| * Get the vertical text alignment. | |
| - * | |
| + * | |
| * @return vertical text alignment | |
| */ | |
| public int getVerticalTextAlignment() { | |
| @@ -117,7 +119,7 @@ | |
| /** | |
| * Get the horizontal text alignment. | |
| - * | |
| + * | |
| * @return horizontal text alignment | |
| */ | |
| public int getHorizontalTextAlignment() { | |
| Index: forge-gui-desktop/src/main/java/forge/screens/match/controllers/CLog.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/match/controllers/CLog.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/match/controllers/CLog.java (revision 29317) | |
| @@ -1,17 +1,16 @@ | |
| package forge.screens.match.controllers; | |
| -import forge.UiCommand; | |
| +import java.util.Observable; | |
| +import java.util.Observer; | |
| + | |
| import forge.FThreads; | |
| import forge.gui.framework.ICDoc; | |
| import forge.screens.match.CMatchUI; | |
| import forge.screens.match.views.VLog; | |
| -import java.util.Observable; | |
| -import java.util.Observer; | |
| - | |
| -/** | |
| +/** | |
| * Controls the combat panel in the match UI. | |
| - * | |
| + * | |
| * <br><br><i>(C at beginning of class name denotes a control class.)</i> | |
| * | |
| */ | |
| @@ -29,14 +28,6 @@ | |
| } | |
| public final VLog getView() { | |
| return view; | |
| - } | |
| - | |
| - /* (non-Javadoc) | |
| - * @see forge.gui.framework.ICDoc#getCommandOnSelect() | |
| - */ | |
| - @Override | |
| - public UiCommand getCommandOnSelect() { | |
| - return null; | |
| } | |
| @Override | |
| @@ -50,7 +41,7 @@ | |
| public void initialize() { | |
| } | |
| - | |
| + | |
| private final Runnable r = new Runnable() { | |
| @Override | |
| public void run() { | |
| Index: forge-gui-desktop/src/main/java/forge/toolbox/FCheckBoxList.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/toolbox/FCheckBoxList.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/toolbox/FCheckBoxList.java (revision 29317) | |
| @@ -1,31 +1,40 @@ | |
| package forge.toolbox; | |
| -import javax.swing.*; | |
| +import java.awt.Component; | |
| +import java.awt.event.FocusEvent; | |
| +import java.awt.event.FocusListener; | |
| +import java.awt.event.KeyAdapter; | |
| +import java.awt.event.KeyEvent; | |
| +import java.awt.event.MouseAdapter; | |
| +import java.awt.event.MouseEvent; | |
| + | |
| +import javax.swing.JList; | |
| +import javax.swing.ListCellRenderer; | |
| +import javax.swing.ListSelectionModel; | |
| +import javax.swing.UIManager; | |
| import javax.swing.border.Border; | |
| import javax.swing.border.EmptyBorder; | |
| -import java.awt.*; | |
| -import java.awt.event.*; | |
| /** | |
| * A list of FCheckBox items using Forge skin properties. | |
| * Call setListData() with an array of FCheckBox items to populate. | |
| - * | |
| + * | |
| * based on code at http://www.devx.com/tips/Tip/5342 | |
| */ | |
| @SuppressWarnings("serial") | |
| public class FCheckBoxList<E> extends JList<E> { | |
| protected static Border noFocusBorder = new EmptyBorder(1, 1, 1, 1); | |
| - public FCheckBoxList(boolean keepSelectionWhenFocusLost) { | |
| + public FCheckBoxList(final boolean keepSelectionWhenFocusLost) { | |
| setCellRenderer(new CellRenderer<E>()); | |
| addMouseListener(new MouseAdapter() { | |
| @Override | |
| - public void mousePressed(MouseEvent e) { | |
| - int index = locationToIndex(e.getPoint()); | |
| + public void mousePressed(final MouseEvent e) { | |
| + final int index = locationToIndex(e.getPoint()); | |
| if (index != -1) { | |
| - FCheckBox checkbox = (FCheckBox)getModel().getElementAt(index); | |
| + final FCheckBox checkbox = (FCheckBox)getModel().getElementAt(index); | |
| if (checkbox.isEnabled()) { | |
| checkbox.setSelected(!checkbox.isSelected()); | |
| repaint(); | |
| @@ -33,34 +42,34 @@ | |
| } | |
| } | |
| }); | |
| - | |
| + | |
| addKeyListener(new KeyAdapter() { | |
| @Override | |
| - public void keyPressed(KeyEvent e) { | |
| + public void keyPressed(final KeyEvent e) { | |
| if (e.getKeyChar() == ' ') { | |
| - FCheckBox item = (FCheckBox)getSelectedValue(); | |
| + final FCheckBox item = (FCheckBox)getSelectedValue(); | |
| if (null == item || !item.isEnabled()) { | |
| return; | |
| } | |
| - | |
| + | |
| item.setSelected(!item.isSelected()); | |
| repaint(); | |
| } | |
| } | |
| }); | |
| - | |
| + | |
| if (!keepSelectionWhenFocusLost) { | |
| addFocusListener(new FocusListener() { | |
| int lastSelectedIdx; | |
| - | |
| + | |
| @Override | |
| - public void focusLost(FocusEvent arg0) { | |
| + public void focusLost(final FocusEvent arg0) { | |
| lastSelectedIdx = Math.max(0, getSelectedIndex()); | |
| clearSelection(); | |
| } | |
| - | |
| + | |
| @Override | |
| - public void focusGained(FocusEvent arg0) { | |
| + public void focusGained(final FocusEvent arg0) { | |
| if (-1 == getSelectedIndex()) { | |
| setSelectedIndex(lastSelectedIdx); | |
| } | |
| @@ -70,10 +79,11 @@ | |
| setSelectionMode(ListSelectionModel.SINGLE_SELECTION); | |
| } | |
| - | |
| + | |
| protected class CellRenderer<E1> implements ListCellRenderer<E1> { | |
| - public Component getListCellRendererComponent(JList<? extends E1> list, E1 value, int index, boolean isSelected, boolean cellHasFocus) { | |
| - FCheckBox checkbox = (FCheckBox)value; | |
| + @Override | |
| + public Component getListCellRendererComponent(final JList<? extends E1> list, final E1 value, final int index, final boolean isSelected, final boolean cellHasFocus) { | |
| + final FCheckBox checkbox = (FCheckBox)value; | |
| checkbox.setBackground(isSelected ? getSelectionBackground() : getBackground()); | |
| checkbox.setForeground(isSelected ? getSelectionForeground() : getForeground()); | |
| checkbox.setFont(getFont()); | |
| Index: forge-gui/src/main/java/forge/interfaces/ICheckBox.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui/src/main/java/forge/interfaces/ICheckBox.java (revision 29316) | |
| +++ forge-gui/src/main/java/forge/interfaces/ICheckBox.java (revision 29317) | |
| @@ -1,10 +1,6 @@ | |
| package forge.interfaces; | |
| -public interface ICheckBox { | |
| - boolean isEnabled(); | |
| - void setEnabled(boolean b0); | |
| - boolean isVisible(); | |
| - void setVisible(boolean b0); | |
| +public interface ICheckBox extends IComponent { | |
| boolean isSelected(); | |
| void setSelected(boolean b0); | |
| } | |
| Index: forge-gui/src/main/java/forge/limited/LimitedDeckBuilder.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui/src/main/java/forge/limited/LimitedDeckBuilder.java (revision 29316) | |
| +++ forge-gui/src/main/java/forge/limited/LimitedDeckBuilder.java (revision 29317) | |
| @@ -1,11 +1,28 @@ | |
| package forge.limited; | |
| +import java.util.ArrayList; | |
| +import java.util.Collections; | |
| +import java.util.HashMap; | |
| +import java.util.HashSet; | |
| +import java.util.List; | |
| +import java.util.ListIterator; | |
| +import java.util.Map; | |
| +import java.util.Set; | |
| + | |
| +import org.apache.commons.lang3.tuple.Pair; | |
| + | |
| import com.google.common.base.Predicate; | |
| import com.google.common.base.Predicates; | |
| import com.google.common.collect.Iterables; | |
| import com.google.common.collect.Lists; | |
| -import forge.card.*; | |
| +import forge.card.CardAiHints; | |
| +import forge.card.CardEdition; | |
| +import forge.card.CardRules; | |
| +import forge.card.CardRulesPredicates; | |
| +import forge.card.ColorSet; | |
| +import forge.card.DeckHints; | |
| +import forge.card.MagicColor; | |
| import forge.card.mana.ManaCost; | |
| import forge.card.mana.ManaCostShard; | |
| import forge.deck.CardPool; | |
| @@ -18,25 +35,20 @@ | |
| import forge.model.FModel; | |
| import forge.util.MyRandom; | |
| -import org.apache.commons.lang3.tuple.Pair; | |
| - | |
| -import java.util.*; | |
| - | |
| /** | |
| * Limited format deck. | |
| - * | |
| */ | |
| public class LimitedDeckBuilder extends DeckGeneratorBase{ | |
| - private int numSpellsNeeded = 22; | |
| + private final int numSpellsNeeded = 22; | |
| private int landsNeeded = 18; | |
| private final DeckColors deckColors; | |
| private Predicate<CardRules> hasColor; | |
| private final List<PaperCard> availableList; | |
| private final List<PaperCard> aiPlayables; | |
| - private List<PaperCard> deckList = new ArrayList<PaperCard>(); | |
| - private List<String> setsWithBasicLands = new ArrayList<String>(); | |
| + private final List<PaperCard> deckList = new ArrayList<PaperCard>(); | |
| + private final List<String> setsWithBasicLands = new ArrayList<String>(); | |
| // Views for aiPlayable | |
| private Iterable<PaperCard> colorList; | |
| @@ -44,24 +56,24 @@ | |
| private Iterable<PaperCard> onColorNonCreatures; | |
| private static final boolean logToConsole = false; | |
| - | |
| + | |
| /** | |
| - * | |
| + * | |
| * Constructor. | |
| - * | |
| + * | |
| * @param dList | |
| * Cards to build the deck from. | |
| * @param pClrs | |
| * Chosen colors. | |
| */ | |
| - public LimitedDeckBuilder(List<PaperCard> dList, DeckColors pClrs) { | |
| + public LimitedDeckBuilder(final List<PaperCard> dList, final DeckColors pClrs) { | |
| super(FModel.getMagicDb().getCommonCards(), DeckFormat.Limited); | |
| this.availableList = dList; | |
| this.deckColors = pClrs; | |
| this.colors = pClrs.getChosenColors(); | |
| // removeUnplayables(); | |
| - Iterable<PaperCard> playables = Iterables.filter(availableList, | |
| + final Iterable<PaperCard> playables = Iterables.filter(availableList, | |
| Predicates.compose(CardRulesPredicates.IS_KEPT_IN_AI_DECKS, PaperCard.FN_GET_RULES)); | |
| this.aiPlayables = Lists.newArrayList(playables); | |
| this.availableList.removeAll(getAiPlayables()); | |
| @@ -72,19 +84,19 @@ | |
| /** | |
| * Constructor. | |
| - * | |
| + * | |
| * @param list | |
| * Cards to build the deck from. | |
| */ | |
| - public LimitedDeckBuilder(List<PaperCard> list) { | |
| + public LimitedDeckBuilder(final List<PaperCard> list) { | |
| this(list, new DeckColors()); | |
| } | |
| @Override | |
| - public CardPool getDeck(int size, boolean forAi) { | |
| + public CardPool getDeck(final int size, final boolean forAi) { | |
| return buildDeck().getMain(); | |
| } | |
| - | |
| + | |
| /** | |
| * <p> | |
| * buildDeck. | |
| @@ -105,7 +117,7 @@ | |
| * the set to take basic lands from (pass 'null' for random). | |
| * @return the new Deck. | |
| */ | |
| - public Deck buildDeck(String landSetCode) { | |
| + public Deck buildDeck(final String landSetCode) { | |
| // 1. Prepare | |
| hasColor = Predicates.or(new MatchColorIdentity(colors), COLORLESS_CARDS); | |
| colorList = Iterables.filter(aiPlayables, Predicates.compose(hasColor, PaperCard.FN_GET_RULES)); | |
| @@ -118,9 +130,9 @@ | |
| // aiPlayable has changed, there is no need to create a new iterable. | |
| // 2. Add any planeswalkers | |
| - Iterable<PaperCard> onColorWalkers = Iterables.filter(colorList, | |
| + final Iterable<PaperCard> onColorWalkers = Iterables.filter(colorList, | |
| Predicates.compose(CardRulesPredicates.Presets.IS_PLANESWALKER, PaperCard.FN_GET_RULES)); | |
| - List<PaperCard> walkers = Lists.newArrayList(onColorWalkers); | |
| + final List<PaperCard> walkers = Lists.newArrayList(onColorWalkers); | |
| deckList.addAll(walkers); | |
| aiPlayables.removeAll(walkers); | |
| @@ -140,12 +152,12 @@ | |
| // 6. If there are still on-color cards, and the average cmc is low, add | |
| // a 23rd card. | |
| - Iterable<PaperCard> nonLands = Iterables.filter(colorList, | |
| + final Iterable<PaperCard> nonLands = Iterables.filter(colorList, | |
| Predicates.compose(CardRulesPredicates.Presets.IS_NON_LAND, PaperCard.FN_GET_RULES)); | |
| if (deckList.size() == numSpellsNeeded && getAverageCMC(deckList) < 3) { | |
| - List<Pair<Double, PaperCard>> list = rankCards(nonLands); | |
| + final List<Pair<Double, PaperCard>> list = rankCards(nonLands); | |
| if (!list.isEmpty()) { | |
| - PaperCard c = list.get(0).getValue(); | |
| + final PaperCard c = list.get(0).getValue(); | |
| deckList.add(c); | |
| getAiPlayables().remove(c); | |
| landsNeeded--; | |
| @@ -178,9 +190,9 @@ | |
| fixDeckSize(clrCnts, landSetCode); | |
| if (deckList.size() == 40) { | |
| - Deck result = new Deck(generateName()); | |
| + final Deck result = new Deck(generateName()); | |
| result.getMain().add(deckList); | |
| - CardPool cp = result.getOrCreate(DeckSection.Sideboard); | |
| + final CardPool cp = result.getOrCreate(DeckSection.Sideboard); | |
| cp.add(aiPlayables); | |
| cp.add(availableList); | |
| if (logToConsole) { | |
| @@ -194,7 +206,7 @@ | |
| /** | |
| * Generate a descriptive name. | |
| - * | |
| + * | |
| * @return name | |
| */ | |
| private String generateName() { | |
| @@ -207,19 +219,19 @@ | |
| private void debugFinalDeck() { | |
| int i = 0; | |
| System.out.println("DECK"); | |
| - for (PaperCard c : deckList) { | |
| + for (final PaperCard c : deckList) { | |
| i++; | |
| System.out.println(i + ". " + c.toString() + ": " + c.getRules().getManaCost().toString()); | |
| } | |
| i = 0; | |
| System.out.println("NOT PLAYABLE"); | |
| - for (PaperCard c : availableList) { | |
| + for (final PaperCard c : availableList) { | |
| i++; | |
| System.out.println(i + ". " + c.toString() + ": " + c.getRules().getManaCost().toString()); | |
| } | |
| i = 0; | |
| System.out.println("NOT PICKED"); | |
| - for (PaperCard c : getAiPlayables()) { | |
| + for (final PaperCard c : getAiPlayables()) { | |
| i++; | |
| System.out.println(i + ". " + c.toString() + ": " + c.getRules().getManaCost().toString()); | |
| } | |
| @@ -228,13 +240,13 @@ | |
| /** | |
| * If the deck does not have 40 cards, fix it. This method should not be | |
| * called if the stuff above it is working correctly. | |
| - * | |
| + * | |
| * @param clrCnts | |
| * color counts needed | |
| * @param landSetCode | |
| * the set to take basic lands from (pass 'null' for random). | |
| */ | |
| - private void fixDeckSize(final int[] clrCnts, String landSetCode) { | |
| + private void fixDeckSize(final int[] clrCnts, final String landSetCode) { | |
| while (deckList.size() > 40) { | |
| System.out.println("WARNING: Fixing deck size, currently " + deckList.size() + " cards."); | |
| final PaperCard c = deckList.get(MyRandom.getRandom().nextInt(deckList.size() - 1)); | |
| @@ -273,12 +285,13 @@ | |
| * Find the sets that have basic lands for the available cards. | |
| */ | |
| private void findBasicLandSets() { | |
| - Set<String> sets = new HashSet<String>(); | |
| - for (PaperCard cp : aiPlayables) { | |
| - CardEdition ee = FModel.getMagicDb().getEditions().get(cp.getEdition()); | |
| - if( !sets.contains(cp.getEdition()) && CardEdition.Predicates.hasBasicLands.apply(ee)) | |
| + final Set<String> sets = new HashSet<String>(); | |
| + for (final PaperCard cp : aiPlayables) { | |
| + final CardEdition ee = FModel.getMagicDb().getEditions().get(cp.getEdition()); | |
| + if( !sets.contains(cp.getEdition()) && CardEdition.Predicates.hasBasicLands.apply(ee)) { | |
| sets.add(cp.getEdition()); | |
| - } | |
| + } | |
| + } | |
| setsWithBasicLands.addAll(sets); | |
| if (setsWithBasicLands.isEmpty()) { | |
| setsWithBasicLands.add("M13"); | |
| @@ -287,15 +300,15 @@ | |
| /** | |
| * Add lands to fulfill the given color counts. | |
| - * | |
| + * | |
| * @param clrCnts | |
| * @param landSetCode | |
| * the set to take basic lands from (pass 'null' for random). | |
| */ | |
| - private void addLands(final int[] clrCnts, String landSetCode) { | |
| + private void addLands(final int[] clrCnts, final String landSetCode) { | |
| // basic lands that are available in the deck | |
| - Iterable<PaperCard> basicLands = Iterables.filter(aiPlayables, Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND, PaperCard.FN_GET_RULES)); | |
| - Set<PaperCard> snowLands = new HashSet<PaperCard>(); | |
| + final Iterable<PaperCard> basicLands = Iterables.filter(aiPlayables, Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND, PaperCard.FN_GET_RULES)); | |
| + final Set<PaperCard> snowLands = new HashSet<PaperCard>(); | |
| // total of all ClrCnts | |
| int totalColor = 0; | |
| @@ -318,13 +331,13 @@ | |
| } | |
| // if appropriate snow-covered lands are available, add them | |
| - for (PaperCard cp : basicLands) { | |
| + for (final PaperCard cp : basicLands) { | |
| if (cp.getName().equals(MagicColor.Constant.SNOW_LANDS.get(i))) { | |
| snowLands.add(cp); | |
| nLand--; | |
| } | |
| } | |
| - | |
| + | |
| for (int j = 0; j < nLand; j++) { | |
| deckList.add(getBasicLand(i, landSetCode)); | |
| } | |
| @@ -337,13 +350,13 @@ | |
| /** | |
| * Get basic land. | |
| - * | |
| + * | |
| * @param basicLand | |
| * @param landSetCode | |
| * the set to take basic lands from (pass 'null' for random). | |
| * @return card | |
| */ | |
| - private PaperCard getBasicLand(int basicLand, String landSetCode) { | |
| + private PaperCard getBasicLand(final int basicLand, final String landSetCode) { | |
| String set; | |
| if (landSetCode == null) { | |
| if (setsWithBasicLands.size() > 1) { | |
| @@ -362,25 +375,26 @@ | |
| * Only consider colors that are supposed to be in the deck. It's not worth | |
| * putting one land in for that random off-color card we had to stick in at | |
| * the end... | |
| - * | |
| + * | |
| * @return CCnt | |
| */ | |
| private int[] calculateLandNeeds() { | |
| final int[] clrCnts = { 0,0,0,0,0 }; | |
| // count each card color using mana costs | |
| - for (PaperCard cp : deckList) { | |
| + for (final PaperCard cp : deckList) { | |
| final ManaCost mc = cp.getRules().getManaCost(); | |
| // count each mana symbol in the mana cost | |
| - for (ManaCostShard shard : mc) { | |
| + for (final ManaCostShard shard : mc) { | |
| for ( int i = 0 ; i < MagicColor.WUBRG.length; i++ ) { | |
| - byte c = MagicColor.WUBRG[i]; | |
| - if ( shard.canBePaidWithManaOfColor(c) && colors.hasAnyColor(c)) | |
| + final byte c = MagicColor.WUBRG[i]; | |
| + if ( shard.canBePaidWithManaOfColor(c) && colors.hasAnyColor(c)) { | |
| clrCnts[i]++; | |
| - } | |
| - } | |
| - } | |
| + } | |
| + } | |
| + } | |
| + } | |
| return clrCnts; | |
| } | |
| @@ -388,11 +402,11 @@ | |
| * Add non-basic lands to the deck. | |
| */ | |
| private void addNonBasicLands() { | |
| - List<String> inverseDuals = getInverseDualLandList(); | |
| - Iterable<PaperCard> lands = Iterables.filter(aiPlayables, | |
| + final List<String> inverseDuals = getInverseDualLandList(); | |
| + final Iterable<PaperCard> lands = Iterables.filter(aiPlayables, | |
| Predicates.compose(CardRulesPredicates.Presets.IS_NONBASIC_LAND, PaperCard.FN_GET_RULES)); | |
| - List<Pair<Double, PaperCard>> ranked = rankCards(lands); | |
| - for (Pair<Double, PaperCard> bean : ranked) { | |
| + final List<Pair<Double, PaperCard>> ranked = rankCards(lands); | |
| + for (final Pair<Double, PaperCard> bean : ranked) { | |
| if (landsNeeded > 0) { | |
| // Throw out any dual-lands for the wrong colors. Assume | |
| // everything else is either | |
| @@ -413,17 +427,17 @@ | |
| /** | |
| * Add a third color to the deck. | |
| - * | |
| + * | |
| * @param nCards | |
| */ | |
| private void addThirdColorCards(int nCards) { | |
| if (nCards > 0) { | |
| - Iterable<PaperCard> others = Iterables.filter(aiPlayables, | |
| + final Iterable<PaperCard> others = Iterables.filter(aiPlayables, | |
| Predicates.compose(CardRulesPredicates.Presets.IS_NON_LAND, PaperCard.FN_GET_RULES)); | |
| List<Pair<Double, PaperCard>> ranked = rankCards(others); | |
| - for (Pair<Double, PaperCard> bean : ranked) { | |
| + for (final Pair<Double, PaperCard> bean : ranked) { | |
| // Want a card that has just one "off" color. | |
| - ColorSet off = colors.getOffColors(bean.getValue().getRules().getColor()); | |
| + final ColorSet off = colors.getOffColors(bean.getValue().getRules().getColor()); | |
| if (off.isMonoColor()) { | |
| colors = ColorSet.fromMask(colors.getColor() | off.getColor()); | |
| break; | |
| @@ -432,10 +446,10 @@ | |
| hasColor = Predicates.or(new DeckGeneratorBase.MatchColorIdentity(colors), | |
| DeckGeneratorBase.COLORLESS_CARDS); | |
| - Iterable<PaperCard> threeColorList = Iterables.filter(aiPlayables, | |
| + final Iterable<PaperCard> threeColorList = Iterables.filter(aiPlayables, | |
| Predicates.compose(hasColor, PaperCard.FN_GET_RULES)); | |
| ranked = rankCards(threeColorList); | |
| - for (Pair<Double, PaperCard> bean : ranked) { | |
| + for (final Pair<Double, PaperCard> bean : ranked) { | |
| if (nCards > 0) { | |
| deckList.add(bean.getValue()); | |
| aiPlayables.remove(bean.getValue()); | |
| @@ -453,14 +467,14 @@ | |
| /** | |
| * Add random cards to the deck. | |
| - * | |
| + * | |
| * @param nCards | |
| */ | |
| private void addRandomCards(int nCards) { | |
| - Iterable<PaperCard> others = Iterables.filter(aiPlayables, | |
| + final Iterable<PaperCard> others = Iterables.filter(aiPlayables, | |
| Predicates.compose(CardRulesPredicates.Presets.IS_NON_LAND, PaperCard.FN_GET_RULES)); | |
| - List<Pair<Double, PaperCard>> ranked = rankCards(others); | |
| - for (Pair<Double, PaperCard> bean : ranked) { | |
| + final List<Pair<Double, PaperCard>> ranked = rankCards(others); | |
| + for (final Pair<Double, PaperCard> bean : ranked) { | |
| if (nCards > 0) { | |
| deckList.add(bean.getValue()); | |
| aiPlayables.remove(bean.getValue()); | |
| @@ -477,15 +491,15 @@ | |
| /** | |
| * Add highest ranked non-creatures to the deck. | |
| - * | |
| + * | |
| * @param nonCreatures | |
| * cards to choose from | |
| * @param num | |
| */ | |
| - private void addNonCreatures(List<Pair<Double, PaperCard>> nonCreatures, int num) { | |
| - for (Pair<Double, PaperCard> bean : nonCreatures) { | |
| + private void addNonCreatures(final List<Pair<Double, PaperCard>> nonCreatures, int num) { | |
| + for (final Pair<Double, PaperCard> bean : nonCreatures) { | |
| if (num > 0) { | |
| - PaperCard cardToAdd = bean.getValue(); | |
| + final PaperCard cardToAdd = bean.getValue(); | |
| deckList.add(cardToAdd); | |
| num--; | |
| getAiPlayables().remove(cardToAdd); | |
| @@ -502,29 +516,29 @@ | |
| /** | |
| * Add cards that work well with the given card. | |
| - * | |
| + * | |
| * @param cardToAdd | |
| * card being checked | |
| * @param num | |
| * number of cards | |
| * @return number left after adding | |
| */ | |
| - private int addDeckHintsCards(PaperCard cardToAdd, int num) { | |
| + private int addDeckHintsCards(final PaperCard cardToAdd, int num) { | |
| // cards with DeckHints will try to grab additional cards from the pool | |
| - DeckHints hints = cardToAdd.getRules().getAiHints().getDeckHints(); | |
| + final DeckHints hints = cardToAdd.getRules().getAiHints().getDeckHints(); | |
| if (hints != null && hints.getType() != DeckHints.Type.NONE) { | |
| - Iterable<PaperCard> onColor = Iterables.filter(aiPlayables, Predicates.compose(hasColor, PaperCard.FN_GET_RULES)); | |
| - List<PaperCard> comboCards = hints.filter(onColor); | |
| + final Iterable<PaperCard> onColor = Iterables.filter(aiPlayables, Predicates.compose(hasColor, PaperCard.FN_GET_RULES)); | |
| + final List<PaperCard> comboCards = hints.filter(onColor); | |
| if (logToConsole) { | |
| System.out.println("Found " + comboCards.size() + " cards for " + cardToAdd.getName()); | |
| } | |
| - for (Pair<Double, PaperCard> comboBean : rankCards(comboCards)) { | |
| + for (final Pair<Double, PaperCard> comboBean : rankCards(comboCards)) { | |
| if (num > 0) { | |
| // This is not exactly right, because the | |
| // rankedComboCards could include creatures and | |
| // non-creatures. | |
| // This code could add too many of one or the other. | |
| - PaperCard combo = comboBean.getValue(); | |
| + final PaperCard combo = comboBean.getValue(); | |
| deckList.add(combo); | |
| num--; | |
| getAiPlayables().remove(combo); | |
| @@ -548,19 +562,19 @@ | |
| private void checkRemRandomDeckCards() { | |
| int numCreatures = 0; | |
| int numOthers = 0; | |
| - for (ListIterator<PaperCard> it = deckList.listIterator(); it.hasNext();) { | |
| - PaperCard card = it.next(); | |
| - CardAiHints ai = card.getRules().getAiHints(); | |
| + for (final ListIterator<PaperCard> it = deckList.listIterator(); it.hasNext();) { | |
| + final PaperCard card = it.next(); | |
| + final CardAiHints ai = card.getRules().getAiHints(); | |
| if (ai.getRemRandomDecks()) { | |
| - List<PaperCard> comboCards = new ArrayList<PaperCard>(); | |
| + final List<PaperCard> comboCards = new ArrayList<PaperCard>(); | |
| if (ai.getDeckNeeds() != null | |
| && ai.getDeckNeeds().getType() != DeckHints.Type.NONE) { | |
| - DeckHints needs = ai.getDeckNeeds(); | |
| + final DeckHints needs = ai.getDeckNeeds(); | |
| comboCards.addAll(needs.filter(deckList)); | |
| } | |
| if (ai.getDeckHints() != null | |
| && ai.getDeckHints().getType() != DeckHints.Type.NONE) { | |
| - DeckHints hints = ai.getDeckHints(); | |
| + final DeckHints hints = ai.getDeckHints(); | |
| comboCards.addAll(hints.filter(deckList)); | |
| } | |
| if (comboCards.isEmpty()) { | |
| @@ -597,15 +611,15 @@ | |
| /** | |
| * Add creatures to the deck. | |
| - * | |
| + * | |
| * @param creatures | |
| * cards to choose from | |
| * @param num | |
| */ | |
| - private void addCreatures(List<Pair<Double, PaperCard>> creatures, int num) { | |
| - for (Pair<Double, PaperCard> bean : creatures) { | |
| + private void addCreatures(final List<Pair<Double, PaperCard>> creatures, int num) { | |
| + for (final Pair<Double, PaperCard> bean : creatures) { | |
| if (num > 0) { | |
| - PaperCard c = bean.getValue(); | |
| + final PaperCard c = bean.getValue(); | |
| deckList.add(c); | |
| num--; | |
| getAiPlayables().remove(c); | |
| @@ -623,19 +637,19 @@ | |
| * Add creatures to the deck, trying to follow some mana curve. Trying to | |
| * have generous limits at each cost, but perhaps still too strict. But | |
| * we're trying to prevent the AI from adding everything at a single cost. | |
| - * | |
| + * | |
| * @param creatures | |
| * cards to choose from | |
| * @param num | |
| */ | |
| - private void addManaCurveCreatures(List<Pair<Double, PaperCard>> creatures, int num) { | |
| - Map<Integer, Integer> creatureCosts = new HashMap<Integer, Integer>(); | |
| + private void addManaCurveCreatures(final List<Pair<Double, PaperCard>> creatures, int num) { | |
| + final Map<Integer, Integer> creatureCosts = new HashMap<Integer, Integer>(); | |
| for (int i = 1; i < 7; i++) { | |
| creatureCosts.put(i, 0); | |
| } | |
| - Predicate<PaperCard> filter = Predicates.compose(CardRulesPredicates.Presets.IS_CREATURE, | |
| + final Predicate<PaperCard> filter = Predicates.compose(CardRulesPredicates.Presets.IS_CREATURE, | |
| PaperCard.FN_GET_RULES); | |
| - for (IPaperCard creature : Iterables.filter(deckList, filter)) { | |
| + for (final IPaperCard creature : Iterables.filter(deckList, filter)) { | |
| int cmc = creature.getRules().getManaCost().getCMC(); | |
| if (cmc < 1) { | |
| cmc = 1; | |
| @@ -645,15 +659,15 @@ | |
| creatureCosts.put(cmc, creatureCosts.get(cmc) + 1); | |
| } | |
| - for (Pair<Double, PaperCard> bean : creatures) { | |
| - PaperCard c = bean.getValue(); | |
| + for (final Pair<Double, PaperCard> bean : creatures) { | |
| + final PaperCard c = bean.getValue(); | |
| int cmc = c.getRules().getManaCost().getCMC(); | |
| if (cmc < 1) { | |
| cmc = 1; | |
| } else if (cmc > 6) { | |
| cmc = 6; | |
| } | |
| - Integer currentAtCmc = creatureCosts.get(cmc); | |
| + final Integer currentAtCmc = creatureCosts.get(cmc); | |
| boolean willAddCreature = false; | |
| if (cmc <= 1 && currentAtCmc < 2) { | |
| willAddCreature = true; | |
| @@ -693,15 +707,15 @@ | |
| /** | |
| * Rank cards. | |
| - * | |
| + * | |
| * @param cards | |
| * CardPrinteds to rank | |
| * @return List of beans with card rankings | |
| */ | |
| - protected List<Pair<Double, PaperCard>> rankCards(Iterable<PaperCard> cards) { | |
| - List<Pair<Double, PaperCard>> ranked = new ArrayList<Pair<Double, PaperCard>>(); | |
| - for (PaperCard card : cards) { | |
| - Double rkg = DraftRankCache.getRanking(card.getName(), card.getEdition()); | |
| + protected List<Pair<Double, PaperCard>> rankCards(final Iterable<PaperCard> cards) { | |
| + final List<Pair<Double, PaperCard>> ranked = new ArrayList<Pair<Double, PaperCard>>(); | |
| + for (final PaperCard card : cards) { | |
| + final Double rkg = DraftRankCache.getRanking(card.getName(), card.getEdition()); | |
| if (rkg != null) { | |
| ranked.add(Pair.of(rkg, card)); | |
| } else { | |
| @@ -714,13 +728,13 @@ | |
| /** | |
| * Calculate average CMC. | |
| - * | |
| + * | |
| * @param cards | |
| * @return the average | |
| */ | |
| - private double getAverageCMC(List<PaperCard> cards) { | |
| + private static double getAverageCMC(final List<PaperCard> cards) { | |
| double sum = 0.0; | |
| - for (IPaperCard cardPrinted : cards) { | |
| + for (final IPaperCard cardPrinted : cards) { | |
| sum += cardPrinted.getRules().getManaCost().getCMC(); | |
| } | |
| return sum / cards.size(); | |
| @@ -737,7 +751,7 @@ | |
| * @param colors | |
| * the colors to set | |
| */ | |
| - public void setColors(ColorSet colors) { | |
| + public void setColors(final ColorSet colors) { | |
| this.colors = colors; | |
| } | |
| Index: forge-gui-desktop/src/main/java/forge/toolbox/SmartScroller.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/toolbox/SmartScroller.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/toolbox/SmartScroller.java (revision 29317) | |
| @@ -1,43 +1,47 @@ | |
| - | |
| -// based on code from http://tips4java.wordpress.com/2013/03/03/smart-scrolling/ | |
| package forge.toolbox; | |
| -import javax.swing.*; | |
| -import javax.swing.text.DefaultCaret; | |
| -import javax.swing.text.JTextComponent; | |
| -import java.awt.*; | |
| +import java.awt.Component; | |
| import java.awt.event.AdjustmentEvent; | |
| import java.awt.event.AdjustmentListener; | |
| +import javax.swing.BoundedRangeModel; | |
| +import javax.swing.JScrollBar; | |
| +import javax.swing.JScrollPane; | |
| +import javax.swing.SwingUtilities; | |
| +import javax.swing.text.DefaultCaret; | |
| +import javax.swing.text.JTextComponent; | |
| + | |
| /** | |
| - * The SmartScroller will attempt to keep the viewport positioned based on | |
| - * the users interaction with the scrollbar. The normal behaviour is to keep | |
| - * the viewport positioned to see new data as it is dynamically added. | |
| + * The SmartScroller will attempt to keep the viewport positioned based on the | |
| + * users interaction with the scrollbar. The normal behaviour is to keep the | |
| + * viewport positioned to see new data as it is dynamically added. | |
| * | |
| - * Assuming vertical scrolling and data is added to the bottom: | |
| + * Assuming vertical scrolling and data is added to the bottom: | |
| * | |
| - * - when the viewport is at the bottom and new data is added, | |
| - * then automatically scroll the viewport to the bottom | |
| - * - when the viewport is not at the bottom and new data is added, | |
| - * then do nothing with the viewport | |
| + * - when the viewport is at the bottom and new data is added, then | |
| + * automatically scroll the viewport to the bottom - when the viewport is not at | |
| + * the bottom and new data is added, then do nothing with the viewport | |
| * | |
| - * Assuming vertical scrolling and data is added to the top: | |
| + * Assuming vertical scrolling and data is added to the top: | |
| * | |
| - * - when the viewport is at the top and new data is added, | |
| - * then do nothing with the viewport | |
| - * - when the viewport is not at the top and new data is added, then adjust | |
| - * the viewport to the relative position it was at before the data was added | |
| + * - when the viewport is at the top and new data is added, then do nothing with | |
| + * the viewport - when the viewport is not at the top and new data is added, | |
| + * then adjust the viewport to the relative position it was at before the data | |
| + * was added | |
| * | |
| - * Similiar logic would apply for horizontal scrolling. | |
| + * Similar logic would apply for horizontal scrolling. | |
| + * | |
| + * Based on code from {@code | |
| + * http://tips4java.wordpress.com/2013/03/03/smart-scrolling/}. | |
| */ | |
| -public class SmartScroller implements AdjustmentListener { | |
| +public final class SmartScroller implements AdjustmentListener { | |
| public final static int HORIZONTAL = 0; | |
| public final static int VERTICAL = 1; | |
| public final static int START = 0; | |
| public final static int END = 1; | |
| - private int viewportPosition; | |
| + private final int viewportPosition; | |
| private JScrollBar scrollBar; | |
| private boolean adjustScrollBar = true; | |
| @@ -51,7 +55,7 @@ | |
| * | |
| * @param scrollPane the scroll pane to monitor | |
| */ | |
| - public SmartScroller(JScrollPane scrollPane) { | |
| + public SmartScroller(final JScrollPane scrollPane) { | |
| this(scrollPane, VERTICAL, END); | |
| } | |
| @@ -62,7 +66,7 @@ | |
| * @param scrollPane the scroll pane to monitor | |
| * @param viewportPosition valid values are START and END | |
| */ | |
| - public SmartScroller(JScrollPane scrollPane, int viewportPosition) { | |
| + public SmartScroller(final JScrollPane scrollPane, final int viewportPosition) { | |
| this(scrollPane, VERTICAL, viewportPosition); | |
| } | |
| @@ -76,37 +80,42 @@ | |
| * positioned as data is added. | |
| * Valid values are START and END | |
| */ | |
| - public SmartScroller(JScrollPane scrollPane, int scrollDirection, int viewportPosition) { | |
| - if (scrollDirection != HORIZONTAL && scrollDirection != VERTICAL) | |
| + public SmartScroller(final JScrollPane scrollPane, final int scrollDirection, final int viewportPosition) { | |
| + if (scrollDirection != HORIZONTAL && scrollDirection != VERTICAL) { | |
| throw new IllegalArgumentException("invalid scroll direction specified"); | |
| + } | |
| - if (viewportPosition != START && viewportPosition != END) | |
| + if (viewportPosition != START && viewportPosition != END) { | |
| throw new IllegalArgumentException("invalid viewport position specified"); | |
| + } | |
| this.viewportPosition = viewportPosition; | |
| - if (scrollDirection == HORIZONTAL) | |
| + if (scrollDirection == HORIZONTAL) { | |
| scrollBar = scrollPane.getHorizontalScrollBar(); | |
| - else | |
| + } else { | |
| scrollBar = scrollPane.getVerticalScrollBar(); | |
| + } | |
| - scrollBar.addAdjustmentListener(this); | |
| - | |
| // Turn off automatic scrolling for text components | |
| - | |
| - Component view = scrollPane.getViewport().getView(); | |
| - | |
| + final Component view = scrollPane.getViewport().getView(); | |
| if (view instanceof JTextComponent) { | |
| - JTextComponent textComponent = (JTextComponent)view; | |
| - DefaultCaret caret = (DefaultCaret)textComponent.getCaret(); | |
| + final JTextComponent textComponent = (JTextComponent) view; | |
| + final DefaultCaret caret = (DefaultCaret) textComponent.getCaret(); | |
| caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE); | |
| } | |
| } | |
| + public void attach() { | |
| + scrollBar.addAdjustmentListener(this); | |
| + } | |
| + | |
| @Override | |
| public void adjustmentValueChanged(final AdjustmentEvent e) { | |
| SwingUtilities.invokeLater(new Runnable() { | |
| - @Override public void run() { checkScrollBar(e); } | |
| + @Override public void run() { | |
| + checkScrollBar(e); | |
| + } | |
| }); | |
| } | |
| @@ -114,26 +123,27 @@ | |
| * Analyze every adjustment event to determine when the viewport | |
| * needs to be repositioned. | |
| */ | |
| - private void checkScrollBar(AdjustmentEvent e) { | |
| + private void checkScrollBar(final AdjustmentEvent e) { | |
| // The scroll bar listModel contains information needed to determine | |
| // whether the viewport should be repositioned or not. | |
| - JScrollBar scrollBar = (JScrollBar)e.getSource(); | |
| - BoundedRangeModel listModel = scrollBar.getModel(); | |
| + final JScrollBar scrollBar = (JScrollBar)e.getSource(); | |
| + final BoundedRangeModel listModel = scrollBar.getModel(); | |
| int value = listModel.getValue(); | |
| - int extent = listModel.getExtent(); | |
| - int maximum = listModel.getMaximum(); | |
| + final int extent = listModel.getExtent(); | |
| + final int maximum = listModel.getMaximum(); | |
| - boolean valueChanged = previousValue != value; | |
| - boolean maximumChanged = previousMaximum != maximum; | |
| + final boolean valueChanged = previousValue != value; | |
| + final boolean maximumChanged = previousMaximum != maximum; | |
| // Check if the user has manually repositioned the scrollbar | |
| if (valueChanged && !maximumChanged) { | |
| - if (viewportPosition == START) | |
| + if (viewportPosition == START) { | |
| adjustScrollBar = value != 0; | |
| - else | |
| + } else { | |
| adjustScrollBar = value + extent >= maximum; | |
| + } | |
| } | |
| // Reset the "value" so we can reposition the viewport and | |
| Index: forge-gui-desktop/src/main/java/forge/screens/home/sanctioned/CSubmenuSealed.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/home/sanctioned/CSubmenuSealed.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/home/sanctioned/CSubmenuSealed.java (revision 29317) | |
| @@ -24,9 +24,9 @@ | |
| import forge.screens.deckeditor.controllers.CEditorLimited; | |
| import forge.toolbox.FOptionPane; | |
| -/** | |
| +/** | |
| * Controls the sealed submenu in the home UI. | |
| - * | |
| + * | |
| * <br><br><i>(C at beginning of class name denotes a control class.)</i> | |
| * | |
| */ | |
| @@ -88,7 +88,7 @@ | |
| SwingUtilities.invokeLater(new Runnable() { | |
| @Override public void run() { | |
| - JButton btnStart = view.getBtnStart(); | |
| + final JButton btnStart = view.getBtnStart(); | |
| if (btnStart.isEnabled()) { | |
| view.getBtnStart().requestFocusInWindow(); | |
| } else { | |
| @@ -107,14 +107,14 @@ | |
| } | |
| if (FModel.getPreferences().getPrefBoolean(FPref.ENFORCE_DECK_LEGALITY)) { | |
| - String errorMessage = gameType.getDeckFormat().getDeckConformanceProblem(human.getDeck()); | |
| + final String errorMessage = gameType.getDeckFormat().getDeckConformanceProblem(human.getDeck()); | |
| if (null != errorMessage) { | |
| FOptionPane.showErrorDialog("Your deck " + errorMessage + " Please edit or choose a different deck.", "Invalid Deck"); | |
| return; | |
| } | |
| } | |
| - int matches = FModel.getDecks().getSealed().get(human.getName()).getAiDecks().size(); | |
| + final int matches = FModel.getDecks().getSealed().get(human.getName()).getAiDecks().size(); | |
| FModel.getGauntletMini().launch(matches, human.getDeck(), gameType); | |
| } | |
| @@ -131,11 +131,4 @@ | |
| editor.getDeckController().setModel((T) sealed); | |
| } | |
| - /* (non-Javadoc) | |
| - * @see forge.gui.framework.ICDoc#getCommandOnSelect() | |
| - */ | |
| - @Override | |
| - public UiCommand getCommandOnSelect() { | |
| - return null; | |
| - } | |
| } | |
| Index: forge-gui-desktop/src/main/java/forge/deckchooser/DecksComboBox.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/deckchooser/DecksComboBox.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/deckchooser/DecksComboBox.java (revision 29317) | |
| @@ -1,21 +1,22 @@ | |
| package forge.deckchooser; | |
| -import forge.deck.DeckType; | |
| -import forge.gui.MouseUtil; | |
| -import forge.toolbox.FComboBoxWrapper; | |
| -import forge.toolbox.FSkin; | |
| -import forge.toolbox.FComboBox.TextAlignment; | |
| - | |
| -import javax.swing.*; | |
| - | |
| import java.awt.Cursor; | |
| import java.awt.event.ActionEvent; | |
| import java.awt.event.ActionListener; | |
| -import java.util.ArrayList; | |
| import java.util.List; | |
| +import javax.swing.DefaultComboBoxModel; | |
| + | |
| +import com.google.common.collect.Lists; | |
| + | |
| +import forge.deck.DeckType; | |
| +import forge.gui.MouseUtil; | |
| +import forge.toolbox.FComboBox.TextAlignment; | |
| +import forge.toolbox.FComboBoxWrapper; | |
| +import forge.toolbox.FSkin; | |
| + | |
| public class DecksComboBox extends FComboBoxWrapper<DeckType> { | |
| - private List<IDecksComboBoxListener> _listeners = new ArrayList<>(); | |
| + private final List<IDecksComboBoxListener> _listeners = Lists.newArrayList(); | |
| private DeckType selectedDeckType = null; | |
| public DecksComboBox() { | |
| @@ -24,19 +25,18 @@ | |
| addActionListener(getDeckTypeComboListener()); | |
| } | |
| - public void refresh(DeckType deckType) { | |
| + public void refresh(final DeckType deckType) { | |
| setModel(new DefaultComboBoxModel<DeckType>(DeckType.values())); | |
| setSelectedItem(deckType); | |
| } | |
| private ActionListener getDeckTypeComboListener() { | |
| return new ActionListener() { | |
| - @Override | |
| - public void actionPerformed(ActionEvent e) { | |
| - Object selectedItem = getSelectedItem(); | |
| + @Override public void actionPerformed(final ActionEvent e) { | |
| + final Object selectedItem = getSelectedItem(); | |
| if (selectedItem instanceof DeckType) { | |
| MouseUtil.setCursor(Cursor.WAIT_CURSOR); | |
| - DeckType newDeckType = (DeckType)selectedItem; | |
| + final DeckType newDeckType = (DeckType)selectedItem; | |
| if (newDeckType != selectedDeckType) { | |
| selectedDeckType = newDeckType; | |
| notifyDeckTypeSelected(newDeckType); | |
| @@ -47,17 +47,13 @@ | |
| }; | |
| } | |
| - public synchronized void addListener(IDecksComboBoxListener obj) { | |
| + public synchronized void addListener(final IDecksComboBoxListener obj) { | |
| _listeners.add(obj); | |
| } | |
| - public synchronized void removeListener(IDecksComboBoxListener obj) { | |
| - _listeners.remove(obj); | |
| - } | |
| - | |
| - private synchronized void notifyDeckTypeSelected(DeckType deckType) { | |
| + private synchronized void notifyDeckTypeSelected(final DeckType deckType) { | |
| if (deckType != null) { | |
| - for (IDecksComboBoxListener listener : _listeners) { | |
| + for (final IDecksComboBoxListener listener : _listeners) { | |
| listener.deckTypeSelected(new DecksComboBoxEvent(this, deckType)); | |
| } | |
| } | |
| @@ -67,13 +63,13 @@ | |
| return selectedDeckType; | |
| } | |
| - public void setDeckType(DeckType valueOf) { | |
| + public void setDeckType(final DeckType valueOf) { | |
| selectedDeckType = valueOf; | |
| setSelectedItem(selectedDeckType); | |
| } | |
| @Override | |
| - public void setText(String text0) { | |
| + public void setText(final String text0) { | |
| selectedDeckType = null; //ensure selecting current deck type again raises event | |
| super.setText(text0); | |
| } |
| Index: forge-gui-desktop/src/main/java/forge/gui/ImportDialog.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/gui/ImportDialog.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/gui/ImportDialog.java (revision 29317) | |
| @@ -6,36 +6,18 @@ | |
| * 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 <http://www.gnu.org/licenses/>. | |
| */ | |
| package forge.gui; | |
| -import forge.UiCommand; | |
| -import forge.assets.FSkinProp; | |
| -import forge.error.BugReporter; | |
| -import forge.gui.ImportSourceAnalyzer.OpType; | |
| -import forge.properties.ForgeConstants; | |
| -import forge.toolbox.*; | |
| -import net.miginfocom.swing.MigLayout; | |
| - | |
| -import org.apache.commons.lang3.StringUtils; | |
| -import org.apache.commons.lang3.tuple.Pair; | |
| - | |
| -import javax.swing.*; | |
| -import javax.swing.Timer; | |
| -import javax.swing.event.ChangeEvent; | |
| -import javax.swing.event.ChangeListener; | |
| -import javax.swing.event.DocumentEvent; | |
| -import javax.swing.event.DocumentListener; | |
| - | |
| -import java.awt.*; | |
| +import java.awt.Font; | |
| import java.awt.event.ActionEvent; | |
| import java.awt.event.ActionListener; | |
| import java.io.File; | |
| @@ -43,10 +25,53 @@ | |
| import java.io.FileOutputStream; | |
| import java.io.IOException; | |
| import java.nio.channels.FileChannel; | |
| -import java.util.*; | |
| +import java.util.ArrayList; | |
| +import java.util.HashMap; | |
| +import java.util.HashSet; | |
| import java.util.List; | |
| +import java.util.Map; | |
| +import java.util.Set; | |
| +import java.util.TreeMap; | |
| import java.util.concurrent.ConcurrentSkipListMap; | |
| +import javax.swing.JFileChooser; | |
| +import javax.swing.JOptionPane; | |
| +import javax.swing.JPanel; | |
| +import javax.swing.JProgressBar; | |
| +import javax.swing.JScrollBar; | |
| +import javax.swing.JScrollPane; | |
| +import javax.swing.JTextArea; | |
| +import javax.swing.ScrollPaneConstants; | |
| +import javax.swing.SwingUtilities; | |
| +import javax.swing.SwingWorker; | |
| +import javax.swing.Timer; | |
| +import javax.swing.event.ChangeEvent; | |
| +import javax.swing.event.ChangeListener; | |
| +import javax.swing.event.DocumentEvent; | |
| +import javax.swing.event.DocumentListener; | |
| + | |
| +import net.miginfocom.swing.MigLayout; | |
| + | |
| +import org.apache.commons.lang3.StringUtils; | |
| +import org.apache.commons.lang3.tuple.Pair; | |
| + | |
| +import forge.UiCommand; | |
| +import forge.assets.FSkinProp; | |
| +import forge.error.BugReporter; | |
| +import forge.gui.ImportSourceAnalyzer.OpType; | |
| +import forge.properties.ForgeConstants; | |
| +import forge.toolbox.FButton; | |
| +import forge.toolbox.FCheckBox; | |
| +import forge.toolbox.FComboBoxWrapper; | |
| +import forge.toolbox.FLabel; | |
| +import forge.toolbox.FOptionPane; | |
| +import forge.toolbox.FOverlay; | |
| +import forge.toolbox.FPanel; | |
| +import forge.toolbox.FScrollPane; | |
| +import forge.toolbox.FSkin; | |
| +import forge.toolbox.FTextField; | |
| +import forge.toolbox.SmartScroller; | |
| + | |
| /** | |
| * This class implements an overlay-based dialog that imports data from a user-selected directory | |
| * into the correct locations in the user and cache directories. There is a lot of I/O and data | |
| @@ -58,63 +83,69 @@ | |
| private final FLabel _btnChooseDir; | |
| private final FPanel _topPanel; | |
| private final JPanel _selectionPanel; | |
| + private final FTextField _txfSrc; | |
| - | |
| + | |
| + private final String forcedSrcDir; | |
| + private final boolean isMigration; | |
| + | |
| // volatile since it is checked from multiple threads | |
| private volatile boolean _cancel; | |
| - | |
| + | |
| @SuppressWarnings("serial") | |
| - public ImportDialog(String forcedSrcDir, final Runnable onDialogClose) { | |
| + public ImportDialog(final String forcedSrcDir, final Runnable onDialogClose) { | |
| + this.forcedSrcDir = forcedSrcDir; | |
| + | |
| _topPanel = new FPanel(new MigLayout("insets dialog, gap 0, center, wrap, fill")); | |
| _topPanel.setOpaque(false); | |
| _topPanel.setBackgroundTexture(FSkin.getIcon(FSkinProp.BG_TEXTURE)); | |
| - final boolean isMigration = !StringUtils.isEmpty(forcedSrcDir); | |
| + isMigration = !StringUtils.isEmpty(forcedSrcDir); | |
| - | |
| + | |
| // header | |
| _topPanel.add(new FLabel.Builder().text((isMigration ? "Migrate" : "Import") + " profile data").fontSize(15).build(), "center"); | |
| - | |
| + | |
| // add some help text if this is for the initial data migration | |
| if (isMigration) { | |
| - FPanel blurbPanel = new FPanel(new MigLayout("insets panel, gap 10, fill")); | |
| + final FPanel blurbPanel = new FPanel(new MigLayout("insets panel, gap 10, fill")); | |
| blurbPanel.setOpaque(false); | |
| - JPanel blurbPanelInterior = new JPanel(new MigLayout("insets dialog, gap 10, center, wrap, fill")); | |
| + final JPanel blurbPanelInterior = new JPanel(new MigLayout("insets dialog, gap 10, center, wrap, fill")); | |
| blurbPanelInterior.setOpaque(false); | |
| blurbPanelInterior.add(new FLabel.Builder().text("<html><b>What's this?</b></html>").build(), "growx, w 50:50:"); | |
| blurbPanelInterior.add(new FLabel.Builder().text( | |
| "<html>Over the last several years, people have had to jump through a lot of hoops to" + | |
| - " update to the most recent version. We hope to reduce this workload to a point where a new" + | |
| - " user will find that it is fairly painless to update. In order to make this happen, Forge" + | |
| - " has changed where it stores your data so that it is outside of the program installation directory." + | |
| - " This way, when you upgrade, you will no longer need to import your data every time to get things" + | |
| - " working. There are other benefits to having user data separate from program data, too, and it" + | |
| + " update to the most recent version. We hope to reduce this workload to a point where a new" + | |
| + " user will find that it is fairly painless to update. In order to make this happen, Forge" + | |
| + " has changed where it stores your data so that it is outside of the program installation directory." + | |
| + " This way, when you upgrade, you will no longer need to import your data every time to get things" + | |
| + " working. There are other benefits to having user data separate from program data, too, and it" + | |
| " lays the groundwork for some cool new features.</html>").build(), "growx, w 50:50:"); | |
| blurbPanelInterior.add(new FLabel.Builder().text("<html><b>So where's my data going?</b></html>").build(), "growx, w 50:50:"); | |
| blurbPanelInterior.add(new FLabel.Builder().text( | |
| "<html>Forge will now store your data in the same place as other applications on your system." + | |
| - " Specifically, your personal data, like decks, quest progress, and program preferences will be" + | |
| - " stored in <b>" + ForgeConstants.USER_DIR + "</b> and all downloaded content, such as card pictures," + | |
| - " skins, and quest world prices will be under <b>" + ForgeConstants.CACHE_DIR + "</b>. If, for whatever" + | |
| - " reason, you need to set different paths, cancel out of this dialog, exit Forge, and find the <b>" + | |
| - ForgeConstants.PROFILE_TEMPLATE_FILE + "</b> file in the program installation directory. Copy or rename" + | |
| - " it to <b>" + ForgeConstants.PROFILE_FILE + "</b> and edit the paths inside it. Then restart Forge and use" + | |
| - " this dialog to move your data to the paths that you set. Keep in mind that if you install a future" + | |
| - " version of Forge into a different directory, you'll need to copy this file over so Forge will know" + | |
| + " Specifically, your personal data, like decks, quest progress, and program preferences will be" + | |
| + " stored in <b>" + ForgeConstants.USER_DIR + "</b> and all downloaded content, such as card pictures," + | |
| + " skins, and quest world prices will be under <b>" + ForgeConstants.CACHE_DIR + "</b>. If, for whatever" + | |
| + " reason, you need to set different paths, cancel out of this dialog, exit Forge, and find the <b>" + | |
| + ForgeConstants.PROFILE_TEMPLATE_FILE + "</b> file in the program installation directory. Copy or rename" + | |
| + " it to <b>" + ForgeConstants.PROFILE_FILE + "</b> and edit the paths inside it. Then restart Forge and use" + | |
| + " this dialog to move your data to the paths that you set. Keep in mind that if you install a future" + | |
| + " version of Forge into a different directory, you'll need to copy this file over so Forge will know" + | |
| " where to find your data.</html>").build(), "growx, w 50:50:"); | |
| blurbPanelInterior.add(new FLabel.Builder().text( | |
| "<html><b>Remember, your data won't be available until you complete this step!</b></html>").build(), "growx, w 50:50:"); | |
| - | |
| + | |
| - FScrollPane blurbScroller = new FScrollPane(blurbPanelInterior, true, | |
| + final FScrollPane blurbScroller = new FScrollPane(blurbPanelInterior, true, | |
| ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); | |
| blurbPanel.add(blurbScroller, "hmin 150, growy, growx, center, gap 0 0 5 5"); | |
| _topPanel.add(blurbPanel, "gap 10 10 20 0, growy, growx, w 50:50:"); | |
| } | |
| - | |
| + | |
| // import source widgets | |
| - JPanel importSourcePanel = new JPanel(new MigLayout("insets 0, gap 10")); | |
| + final JPanel importSourcePanel = new JPanel(new MigLayout("insets 0, gap 10")); | |
| importSourcePanel.setOpaque(false); | |
| importSourcePanel.add(new FLabel.Builder().text("Import from:").build()); | |
| - final FTextField txfSrc = new FTextField.Builder().readonly().build(); | |
| - importSourcePanel.add(txfSrc, "pushx, growx"); | |
| + _txfSrc = new FTextField.Builder().readonly().build(); | |
| + importSourcePanel.add(_txfSrc, "pushx, growx"); | |
| _btnChooseDir = new FLabel.ButtonBuilder().text("Choose directory...").enabled(!isMigration).build(); | |
| final JFileChooser _fileChooser = new JFileChooser(); | |
| _fileChooser.setMultiSelectionEnabled(false); | |
| @@ -124,57 +155,58 @@ | |
| // bring up a file open dialog and, if the OK button is selected, apply the filename | |
| // to the import source text field | |
| if (JFileChooser.APPROVE_OPTION == _fileChooser.showOpenDialog(JOptionPane.getRootFrame())) { | |
| - File f = _fileChooser.getSelectedFile(); | |
| + final File f = _fileChooser.getSelectedFile(); | |
| if (!f.canRead()) { | |
| FOptionPane.showErrorDialog("Cannot access selected directory (Permission denied)."); | |
| } | |
| else { | |
| - txfSrc.setText(f.getAbsolutePath()); | |
| + _txfSrc.setText(f.getAbsolutePath()); | |
| } | |
| } | |
| } | |
| }); | |
| importSourcePanel.add(_btnChooseDir, "h pref+8!, w pref+12!"); | |
| - | |
| + | |
| // add change handler to the import source text field that starts up a | |
| // new analyzer. it also interacts with the current active analyzer, | |
| // if any, to make sure it cancels out before the new one is initiated | |
| - txfSrc.getDocument().addDocumentListener(new DocumentListener() { | |
| + _txfSrc.getDocument().addDocumentListener(new DocumentListener() { | |
| boolean _analyzerActive; // access synchronized on _onAnalyzerDone | |
| String prevText; | |
| - | |
| + | |
| private final Runnable _onAnalyzerDone = new Runnable() { | |
| + @Override | |
| public synchronized void run() { | |
| _analyzerActive = false; | |
| notify(); | |
| } | |
| }; | |
| - | |
| + | |
| - @Override public void removeUpdate(DocumentEvent e) { } | |
| - @Override public void changedUpdate(DocumentEvent e) { } | |
| - @Override public void insertUpdate(DocumentEvent e) { | |
| + @Override public void removeUpdate(final DocumentEvent e) { } | |
| + @Override public void changedUpdate(final DocumentEvent e) { } | |
| + @Override public void insertUpdate(final DocumentEvent e) { | |
| // text field is read-only, so the only time this will get updated | |
| - // is when _btnChooseDir does it | |
| + // is when _btnChooseDir does it | |
| - final String text = txfSrc.getText(); | |
| + final String text = _txfSrc.getText(); | |
| if (text.equals(prevText)) { | |
| // only restart the analyzer if the directory has changed | |
| return; | |
| } | |
| prevText = text; | |
| - | |
| + | |
| // cancel any active analyzer | |
| _cancel = true; | |
| - | |
| + | |
| if (!text.isEmpty()) { | |
| // ensure we don't get two instances of this function running at the same time | |
| _btnChooseDir.setEnabled(false); | |
| - | |
| + | |
| // re-disable the start button. it will be enabled if the previous analyzer has | |
| // already successfully finished | |
| _btnStart.setEnabled(false); | |
| - | |
| + | |
| // we have to wait in a background thread since we can't block in the GUI thread | |
| - SwingWorker<Void, Void> analyzerStarter = new SwingWorker<Void, Void>() { | |
| + final SwingWorker<Void, Void> analyzerStarter = new SwingWorker<Void, Void>() { | |
| @Override | |
| protected Void doInBackground() throws Exception { | |
| // wait for active analyzer (if any) to quit | |
| @@ -185,14 +217,14 @@ | |
| } | |
| return null; | |
| } | |
| - | |
| + | |
| // executes in gui event loop thread | |
| @Override | |
| protected void done() { | |
| _cancel = false; | |
| synchronized (_onAnalyzerDone) { | |
| // this will populate the panel with data selection widgets | |
| - _AnalyzerUpdater analyzer = new _AnalyzerUpdater(text, _onAnalyzerDone, isMigration); | |
| + final _AnalyzerUpdater analyzer = new _AnalyzerUpdater(text, _onAnalyzerDone, isMigration); | |
| analyzer.run(); | |
| _analyzerActive = true; | |
| } | |
| @@ -208,12 +240,12 @@ | |
| } | |
| }); | |
| _topPanel.add(importSourcePanel, "gaptop 20, pushx, growx"); | |
| - | |
| + | |
| // prepare import selection panel (will be cleared and filled in later by an analyzer) | |
| _selectionPanel = new JPanel(); | |
| _selectionPanel.setOpaque(false); | |
| _topPanel.add(_selectionPanel, "growx, growy, gaptop 10"); | |
| - | |
| + | |
| // action button widgets | |
| final Runnable cleanup = new Runnable() { | |
| @Override public void run() { SOverlayUtils.hideOverlay(); } | |
| @@ -222,7 +254,7 @@ | |
| _btnStart.setEnabled(false); | |
| _btnCancel = new FButton("Cancel"); | |
| _btnCancel.addActionListener(new ActionListener() { | |
| - @Override public void actionPerformed(ActionEvent e) { | |
| + @Override public void actionPerformed(final ActionEvent e) { | |
| _cancel = true; | |
| cleanup.run(); | |
| if (null != onDialogClose) { | |
| @@ -231,43 +263,45 @@ | |
| } | |
| }); | |
| - JPanel southPanel = new JPanel(new MigLayout("ax center")); | |
| + final JPanel southPanel = new JPanel(new MigLayout("ax center")); | |
| southPanel.setOpaque(false); | |
| southPanel.add(_btnStart, "center, w pref+144!, h pref+12!"); | |
| southPanel.add(_btnCancel, "center, w pref+144!, h pref+12!, gap 72"); | |
| _topPanel.add(southPanel, "growx"); | |
| + } | |
| - | |
| + | |
| - JPanel overlay = FOverlay.SINGLETON_INSTANCE.getPanel(); | |
| + public void show() { | |
| + final JPanel overlay = FOverlay.SINGLETON_INSTANCE.getPanel(); | |
| overlay.setLayout(new MigLayout("insets 0, gap 0, wrap, ax center, ay center")); | |
| overlay.add(_topPanel, "w 500::90%, h 100::90%"); | |
| SOverlayUtils.showOverlay(); | |
| - | |
| + | |
| // focus cancel button after the dialog is shown | |
| SwingUtilities.invokeLater(new Runnable() { | |
| @Override public void run() { _btnCancel.requestFocusInWindow(); } | |
| }); | |
| - | |
| + | |
| // if our source dir is provided, set the text, which will fire off an analyzer | |
| if (isMigration) { | |
| - File srcDirFile = new File(forcedSrcDir); | |
| - txfSrc.setText(srcDirFile.getAbsolutePath()); | |
| + final File srcDirFile = new File(forcedSrcDir); | |
| + _txfSrc.setText(srcDirFile.getAbsolutePath()); | |
| } | |
| } | |
| - | |
| + | |
| // encapsulates the choices in the combobox for choosing the destination paths for | |
| // decks of unknown type | |
| private class _UnknownDeckChoice { | |
| public final String name; | |
| public final String path; | |
| - | |
| + | |
| - public _UnknownDeckChoice(String name0, String path0) { | |
| + public _UnknownDeckChoice(final String name0, final String path0) { | |
| name = name0; | |
| path = path0; | |
| } | |
| - | |
| + | |
| @Override public String toString() { return name; } | |
| } | |
| - | |
| + | |
| // this class owns the import selection widgets and bridges them with the running | |
| // MigrationSourceAnalyzer instance | |
| private class _AnalyzerUpdater extends SwingWorker<Void, Void> { | |
| @@ -275,12 +309,14 @@ | |
| // of file move/copy operations that enabling it would entail | |
| private final Map<OpType, Pair<FCheckBox, ? extends Map<File, File>>> _selections = | |
| new HashMap<OpType, Pair<FCheckBox, ? extends Map<File, File>>>(); | |
| - | |
| + | |
| // attached to all changeable widgets to keep the UI in sync | |
| private final ChangeListener _stateChangedListener = new ChangeListener() { | |
| - @Override public void stateChanged(ChangeEvent arg0) { _updateUI(); } | |
| + @Override public void stateChanged(final ChangeEvent arg0) { | |
| + _updateUI(); | |
| + } | |
| }; | |
| - | |
| + | |
| private final String _srcDir; | |
| private final Runnable _onAnalyzerDone; | |
| private final boolean _isMigration; | |
| @@ -291,23 +327,23 @@ | |
| private final JTextArea _operationLog; | |
| private final JScrollPane _operationLogScroller; | |
| private final JProgressBar _progressBar; | |
| - | |
| + | |
| // updates the _operationLog widget asynchronously to keep the UI responsive | |
| private final _OperationLogAsyncUpdater _operationLogUpdater; | |
| - | |
| + | |
| - public _AnalyzerUpdater(String srcDir, Runnable onAnalyzerDone, boolean isMigration) { | |
| + public _AnalyzerUpdater(final String srcDir, final Runnable onAnalyzerDone, final boolean isMigration) { | |
| _srcDir = srcDir; | |
| _onAnalyzerDone = onAnalyzerDone; | |
| _isMigration = isMigration; | |
| - | |
| + | |
| _selectionPanel.removeAll(); | |
| _selectionPanel.setLayout(new MigLayout("insets 0, gap 5, wrap, fill")); | |
| - | |
| + | |
| - JPanel cbPanel = new JPanel(new MigLayout("insets 0, gap 5")); | |
| + final JPanel cbPanel = new JPanel(new MigLayout("insets 0, gap 5")); | |
| cbPanel.setOpaque(false); | |
| - | |
| + | |
| // add deck selections | |
| - JPanel knownDeckPanel = new JPanel(new MigLayout("insets 0, gap 5, wrap 2")); | |
| + final JPanel knownDeckPanel = new JPanel(new MigLayout("insets 0, gap 5, wrap 2")); | |
| knownDeckPanel.setOpaque(false); | |
| knownDeckPanel.add(new FLabel.Builder().text("Decks").build(), "wrap"); | |
| _addSelectionWidget(knownDeckPanel, OpType.CONSTRUCTED_DECK, "Constructed decks"); | |
| @@ -316,7 +352,7 @@ | |
| _addSelectionWidget(knownDeckPanel, OpType.SCHEME_DECK, "Scheme decks"); | |
| _addSelectionWidget(knownDeckPanel, OpType.SEALED_DECK, "Sealed decks"); | |
| _addSelectionWidget(knownDeckPanel, OpType.UNKNOWN_DECK, "Unknown decks"); | |
| - JPanel unknownDeckPanel = new JPanel(new MigLayout("insets 0, gap 5")); | |
| + final JPanel unknownDeckPanel = new JPanel(new MigLayout("insets 0, gap 5")); | |
| unknownDeckPanel.setOpaque(false); | |
| _unknownDeckCombo = new FComboBoxWrapper<_UnknownDeckChoice>(); | |
| _unknownDeckCombo.addItem(new _UnknownDeckChoice("Constructed", ForgeConstants.DECK_CONSTRUCTED_DIR)); | |
| @@ -325,25 +361,27 @@ | |
| _unknownDeckCombo.addItem(new _UnknownDeckChoice("Scheme", ForgeConstants.DECK_SCHEME_DIR)); | |
| _unknownDeckCombo.addItem(new _UnknownDeckChoice("Sealed", ForgeConstants.DECK_SEALED_DIR)); | |
| _unknownDeckCombo.addActionListener(new ActionListener() { | |
| - @Override public void actionPerformed(ActionEvent arg0) { _updateUI(); } | |
| + @Override public void actionPerformed(final ActionEvent arg0) { | |
| + _updateUI(); | |
| + } | |
| }); | |
| _unknownDeckLabel = new FLabel.Builder().text("Treat unknown decks as:").build(); | |
| unknownDeckPanel.add(_unknownDeckLabel); | |
| _unknownDeckCombo.addTo(unknownDeckPanel); | |
| knownDeckPanel.add(unknownDeckPanel, "span"); | |
| cbPanel.add(knownDeckPanel, "aligny top"); | |
| - | |
| + | |
| // add other userDir data elements | |
| - JPanel dataPanel = new JPanel(new MigLayout("insets 0, gap 5, wrap")); | |
| + final JPanel dataPanel = new JPanel(new MigLayout("insets 0, gap 5, wrap")); | |
| dataPanel.setOpaque(false); | |
| dataPanel.add(new FLabel.Builder().text("Other data").build()); | |
| _addSelectionWidget(dataPanel, OpType.GAUNTLET_DATA, "Gauntlet data"); | |
| _addSelectionWidget(dataPanel, OpType.QUEST_DATA, "Quest saves"); | |
| _addSelectionWidget(dataPanel, OpType.PREFERENCE_FILE, "Preference files"); | |
| cbPanel.add(dataPanel, "aligny top"); | |
| - | |
| + | |
| // add cacheDir data elements | |
| - JPanel cachePanel = new JPanel(new MigLayout("insets 0, gap 5, wrap 2")); | |
| + final JPanel cachePanel = new JPanel(new MigLayout("insets 0, gap 5, wrap 2")); | |
| cachePanel.setOpaque(false); | |
| cachePanel.add(new FLabel.Builder().text("Cached data").build(), "wrap"); | |
| _addSelectionWidget(cachePanel, OpType.DEFAULT_CARD_PIC, "Default card pics"); | |
| @@ -351,18 +389,18 @@ | |
| _addSelectionWidget(cachePanel, OpType.TOKEN_PIC, "Card token pics"); | |
| _addSelectionWidget(cachePanel, OpType.QUEST_PIC, "Quest-related pics"); | |
| _addSelectionWidget(cachePanel, OpType.DB_FILE, "Database files", true, null, "wrap"); | |
| - | |
| + | |
| _addSelectionWidget(cachePanel, OpType.POSSIBLE_SET_CARD_PIC, | |
| - "Import possible set pics from as-yet unsupported cards", false, | |
| + "Import possible set pics from as-yet unsupported cards", false, | |
| "<html>Picture files that are not recognized as belonging to any known card.<br>" + | |
| - "It could be that these pictures belong to cards that are not yet supported<br>" + | |
| - "by Forge. If you know this to be the case and want the pictures imported for<br>" + | |
| - "future use, select this option.<html>", "span"); | |
| + "It could be that these pictures belong to cards that are not yet supported<br>" + | |
| + "by Forge. If you know this to be the case and want the pictures imported for<br>" + | |
| + "future use, select this option.<html>", "span"); | |
| cbPanel.add(cachePanel, "aligny top"); | |
| _selectionPanel.add(cbPanel, "center"); | |
| - | |
| + | |
| // add move/copy and overwrite checkboxes | |
| - JPanel ioOptionPanel = new JPanel(new MigLayout("insets 0, gap 10")); | |
| + final JPanel ioOptionPanel = new JPanel(new MigLayout("insets 0, gap 10")); | |
| ioOptionPanel.setOpaque(false); | |
| _moveCheckbox = new FCheckBox("Remove source files after copy"); | |
| _moveCheckbox.setToolTipText("Move files into the data directories instead of just copying them"); | |
| @@ -374,7 +412,7 @@ | |
| _overwriteCheckbox.addChangeListener(_stateChangedListener); | |
| ioOptionPanel.add(_overwriteCheckbox); | |
| _selectionPanel.add(ioOptionPanel); | |
| - | |
| + | |
| // add operation summary textfield | |
| _operationLog = new JTextArea(); | |
| _operationLog.setFont(new Font("Monospaced", Font.PLAIN, 10)); | |
| @@ -385,112 +423,112 @@ | |
| // autoscroll when we set/add text unless the user has intentionally scrolled somewhere else | |
| _operationLogScroller = new JScrollPane(_operationLog); | |
| _operationLogScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); | |
| - new SmartScroller(_operationLogScroller); | |
| + new SmartScroller(_operationLogScroller).attach(); | |
| _selectionPanel.add(_operationLogScroller, "w 400:400:, hmin 60, growy, growx"); | |
| - | |
| + | |
| // add progress bar | |
| _progressBar = new JProgressBar(); | |
| _progressBar.setString("Preparing to analyze source directory..."); | |
| _progressBar.setStringPainted(true); | |
| _selectionPanel.add(_progressBar, "w 100%!"); | |
| - | |
| + | |
| // start the op log updater | |
| _operationLogUpdater = new _OperationLogAsyncUpdater(_selections, _operationLog); | |
| _operationLogUpdater.start(); | |
| - | |
| + | |
| // set initial checkbox labels | |
| _updateUI(); | |
| - | |
| + | |
| // resize the panel properly now that the _selectionPanel is filled in | |
| _selectionPanel.getParent().validate(); | |
| _selectionPanel.getParent().invalidate(); | |
| } | |
| - | |
| + | |
| - private void _addSelectionWidget(JPanel parent, OpType type, String name) { | |
| + private void _addSelectionWidget(final JPanel parent, final OpType type, final String name) { | |
| _addSelectionWidget(parent, type, name, true, null, null); | |
| } | |
| - | |
| + | |
| - private void _addSelectionWidget(JPanel parent, OpType type, String name, boolean selected, | |
| - String tooltip, String constraints) { | |
| - FCheckBox cb = new FCheckBox(); | |
| + private void _addSelectionWidget(final JPanel parent, final OpType type, final String name, final boolean selected, | |
| + final String tooltip, final String constraints) { | |
| + final FCheckBox cb = new FCheckBox(); | |
| cb.setName(name); | |
| cb.setSelected(selected); | |
| cb.setToolTipText(tooltip); | |
| cb.addChangeListener(_stateChangedListener); | |
| - | |
| + | |
| // use a skip list map instead of a regular hashmap so that the files are sorted | |
| // alphabetically in the logs. note that this is a concurrent data structure | |
| // since it will be modified and read simultaneously by different threads | |
| _selections.put(type, Pair.of(cb, new ConcurrentSkipListMap<File, File>())); | |
| parent.add(cb, constraints); | |
| } | |
| - | |
| + | |
| // must be called from GUI event loop thread | |
| private void _updateUI() { | |
| // update checkbox text labels with current totals | |
| - Set<OpType> selectedOptions = new HashSet<OpType>(); | |
| - for (Map.Entry<OpType, Pair<FCheckBox, ? extends Map<File, File>>> entry : _selections.entrySet()) { | |
| - Pair<FCheckBox, ? extends Map<File, File>> selection = entry.getValue(); | |
| - FCheckBox cb = selection.getLeft(); | |
| + final Set<OpType> selectedOptions = new HashSet<OpType>(); | |
| + for (final Map.Entry<OpType, Pair<FCheckBox, ? extends Map<File, File>>> entry : _selections.entrySet()) { | |
| + final Pair<FCheckBox, ? extends Map<File, File>> selection = entry.getValue(); | |
| + final FCheckBox cb = selection.getLeft(); | |
| - | |
| + | |
| if (cb.isSelected()) { | |
| selectedOptions.add(entry.getKey()); | |
| } | |
| - | |
| + | |
| cb.setText(String.format("%s (%d)", cb.getName(), selection.getRight().size())); | |
| } | |
| - | |
| + | |
| // asynchronously update the text in the op log, which may be many tens of thousands of lines long | |
| // if this were done synchronously the UI would slow to a crawl | |
| - _operationLogUpdater.requestUpdate(selectedOptions, (_UnknownDeckChoice)_unknownDeckCombo.getSelectedItem(), | |
| + _operationLogUpdater.requestUpdate(selectedOptions, _unknownDeckCombo.getSelectedItem(), | |
| _moveCheckbox.isSelected(), _overwriteCheckbox.isSelected()); | |
| } | |
| - | |
| + | |
| @Override | |
| protected Void doInBackground() throws Exception { | |
| Timer timer = null; | |
| - | |
| + | |
| try { | |
| - Map<OpType, Map<File, File>> selections = new HashMap<OpType, Map<File, File>>(); | |
| - for (Map.Entry<OpType, Pair<FCheckBox, ? extends Map<File, File>>> entry : _selections.entrySet()) { | |
| + final Map<OpType, Map<File, File>> selections = new HashMap<OpType, Map<File, File>>(); | |
| + for (final Map.Entry<OpType, Pair<FCheckBox, ? extends Map<File, File>>> entry : _selections.entrySet()) { | |
| selections.put(entry.getKey(), entry.getValue().getRight()); | |
| } | |
| - | |
| + | |
| - ImportSourceAnalyzer.AnalysisCallback cb = new ImportSourceAnalyzer.AnalysisCallback() { | |
| - @Override | |
| - public boolean checkCancel() { return _cancel; } | |
| + final ImportSourceAnalyzer.AnalysisCallback cb = new ImportSourceAnalyzer.AnalysisCallback() { | |
| + @Override public boolean checkCancel() { | |
| + return _cancel; | |
| + } | |
| - | |
| + | |
| - @Override | |
| - public void addOp(OpType type, File src, File dest) { | |
| + @Override public void addOp(final OpType type, final File src, final File dest) { | |
| // add to concurrent map | |
| _selections.get(type).getRight().put(src, dest); | |
| } | |
| }; | |
| - | |
| + | |
| final ImportSourceAnalyzer msa = new ImportSourceAnalyzer(_srcDir, cb); | |
| final int numFilesToAnalyze = msa.getNumFilesToAnalyze(); | |
| - | |
| + | |
| // update only once every half-second so we're not flooding the UI with updates | |
| timer = new Timer(500, null); | |
| timer.setInitialDelay(100); | |
| final Timer finalTimer = timer; | |
| timer.addActionListener(new ActionListener() { | |
| - @Override public void actionPerformed(ActionEvent arg0) { | |
| + @Override public void actionPerformed(final ActionEvent arg0) { | |
| if (_cancel) { | |
| finalTimer.stop(); | |
| return; | |
| } | |
| - | |
| + | |
| // timers run in the gui event loop, so it's ok to interact with widgets | |
| _progressBar.setValue(msa.getNumFilesAnalyzed()); | |
| _updateUI(); | |
| - | |
| + | |
| // allow the the panel to resize to accommodate additional text | |
| _selectionPanel.getParent().validate(); | |
| _selectionPanel.getParent().invalidate(); | |
| } | |
| }); | |
| - | |
| + | |
| // update the progress bar widget from the GUI event loop | |
| SwingUtilities.invokeLater(new Runnable() { | |
| @Override public void run() { | |
| @@ -499,17 +537,17 @@ | |
| _progressBar.setMaximum(numFilesToAnalyze); | |
| _progressBar.setValue(0); | |
| _progressBar.setIndeterminate(false); | |
| - | |
| + | |
| // start update timer | |
| finalTimer.start(); | |
| } | |
| }); | |
| - | |
| + | |
| // does not return until analysis is complete or has been canceled | |
| msa.doAnalysis(); | |
| } catch (final Exception e) { | |
| _cancel = true; | |
| - | |
| + | |
| SwingUtilities.invokeLater(new Runnable() { | |
| @Override public void run() { | |
| _progressBar.setString("Error"); | |
| @@ -522,7 +560,7 @@ | |
| timer.stop(); | |
| } | |
| } | |
| - | |
| + | |
| return null; | |
| } | |
| @@ -533,25 +571,25 @@ | |
| _progressBar.setValue(_progressBar.getMaximum()); | |
| _updateUI(); | |
| _progressBar.setString("Analysis complete"); | |
| - | |
| + | |
| // clear any previously-set action listeners on the start button | |
| // in case we've previously completed an analysis but changed the directory | |
| // instead of starting the import | |
| - for (ActionListener a : _btnStart.getActionListeners()) { | |
| + for (final ActionListener a : _btnStart.getActionListeners()) { | |
| _btnStart.removeActionListener(a); | |
| } | |
| - | |
| + | |
| // deselect and disable all options that have 0 operations associated with | |
| // them to highlight the important options | |
| - for (Pair<FCheckBox, ? extends Map<File, File>> p : _selections.values()) { | |
| - FCheckBox cb = p.getLeft(); | |
| + for (final Pair<FCheckBox, ? extends Map<File, File>> p : _selections.values()) { | |
| + final FCheckBox cb = p.getLeft(); | |
| if (0 == p.getRight().size()) { | |
| cb.removeChangeListener(_stateChangedListener); | |
| cb.setSelected(false); | |
| cb.setEnabled(false); | |
| } | |
| } | |
| - | |
| + | |
| if (0 == _selections.get(OpType.UNKNOWN_DECK).getRight().size()) { | |
| _unknownDeckLabel.setEnabled(false); | |
| _unknownDeckCombo.setEnabled(false); | |
| @@ -559,47 +597,47 @@ | |
| // set up the start button to start the prepared import on click | |
| _btnStart.addActionListener(new ActionListener() { | |
| - @Override public void actionPerformed(ActionEvent arg0) { | |
| + @Override public void actionPerformed(final ActionEvent arg0) { | |
| // if this is a migration, warn if active settings will not complete a migration and give the | |
| // user an option to fix | |
| if (_isMigration) { | |
| // assemble a list of selections that need to be selected to complete a full migration | |
| - List<String> unselectedButShouldBe = new ArrayList<String>(); | |
| - for (Map.Entry<OpType, Pair<FCheckBox, ? extends Map<File, File>>> entry : _selections.entrySet()) { | |
| + final List<String> unselectedButShouldBe = new ArrayList<String>(); | |
| + for (final Map.Entry<OpType, Pair<FCheckBox, ? extends Map<File, File>>> entry : _selections.entrySet()) { | |
| if (OpType.POSSIBLE_SET_CARD_PIC == entry.getKey()) { | |
| continue; | |
| } | |
| - | |
| + | |
| // add name to list if checkbox is unselected, but contains operations | |
| - Pair<FCheckBox, ? extends Map<File, File>> p = entry.getValue(); | |
| - FCheckBox cb = p.getLeft(); | |
| + final Pair<FCheckBox, ? extends Map<File, File>> p = entry.getValue(); | |
| + final FCheckBox cb = p.getLeft(); | |
| if (!cb.isSelected() && 0 < p.getRight().size()) { | |
| unselectedButShouldBe.add(cb.getName()); | |
| } | |
| } | |
| if (!unselectedButShouldBe.isEmpty() || !_moveCheckbox.isSelected()) { | |
| - StringBuilder sb = new StringBuilder("<html>"); | |
| + final StringBuilder sb = new StringBuilder("<html>"); | |
| if (!unselectedButShouldBe.isEmpty()) { | |
| sb.append("It looks like the following options are not selected, which will result in an incomplete migration:"); | |
| sb.append("<ul>"); | |
| - for (String cbName : unselectedButShouldBe) { | |
| + for (final String cbName : unselectedButShouldBe) { | |
| sb.append("<li><b>").append(cbName).append("</b></li>"); | |
| } | |
| sb.append("</ul>"); | |
| } | |
| - | |
| + | |
| if (!_moveCheckbox.isSelected()) { | |
| sb.append(unselectedButShouldBe.isEmpty() ? "It " : "It also ").append("looks like the <b>"); | |
| sb.append(_moveCheckbox.getText()).append("</b> option is not selected.<br><br>"); | |
| } | |
| - | |
| + | |
| sb.append("You can continue anyway, but the migration will be incomplete, and the data migration prompt<br>"); | |
| sb.append("will come up again the next time you start Forge in order to migrate the remaining files<br>"); | |
| sb.append("unless you move or delete them manually.</html>"); | |
| - | |
| + | |
| - String[] options = { "Whoops, let me fix that!", "Continue with the import, I know what I'm doing." }; | |
| - int chosen = FOptionPane.showOptionDialog(sb.toString(), "Migration warning", FOptionPane.WARNING_ICON, options); | |
| + final String[] options = { "Whoops, let me fix that!", "Continue with the import, I know what I'm doing." }; | |
| + final int chosen = FOptionPane.showOptionDialog(sb.toString(), "Migration warning", FOptionPane.WARNING_ICON, options); | |
| if (chosen != 1) { | |
| // i.e. option 0 was chosen or the dialog was otherwise closed | |
| @@ -611,47 +649,47 @@ | |
| // ensure no other actions (except for cancel) can be taken while the import is in progress | |
| _btnStart.setEnabled(false); | |
| _btnChooseDir.setEnabled(false); | |
| - | |
| + | |
| - for (Pair<FCheckBox, ? extends Map<File, File>> selection : _selections.values()) { | |
| + for (final Pair<FCheckBox, ? extends Map<File, File>> selection : _selections.values()) { | |
| selection.getLeft().setEnabled(false); | |
| } | |
| _unknownDeckCombo.setEnabled(false); | |
| _moveCheckbox.setEnabled(false); | |
| _overwriteCheckbox.setEnabled(false); | |
| - | |
| + | |
| // stop updating the operation log -- the importer needs it now | |
| _operationLogUpdater.requestStop(); | |
| - | |
| + | |
| // jump to the bottom of the log text area so it starts autoscrolling again | |
| // note that since it is controlled by a SmartScroller, just setting the caret position will not work | |
| - JScrollBar scrollBar = _operationLogScroller.getVerticalScrollBar(); | |
| + final JScrollBar scrollBar = _operationLogScroller.getVerticalScrollBar(); | |
| scrollBar.setValue(scrollBar.getMaximum()); | |
| - | |
| + | |
| // start importing! | |
| - _Importer importer = new _Importer( | |
| + final _Importer importer = new _Importer( | |
| _srcDir, _selections, _unknownDeckCombo, _operationLog, _progressBar, | |
| _moveCheckbox.isSelected(), _overwriteCheckbox.isSelected()); | |
| importer.run(); | |
| - | |
| + | |
| _btnCancel.requestFocusInWindow(); | |
| } | |
| }); | |
| - | |
| + | |
| // import ready to proceed: enable the start button | |
| _btnStart.setEnabled(true); | |
| } | |
| - | |
| + | |
| // report to the Choose Directory button that this analysis run has stopped | |
| _onAnalyzerDone.run(); | |
| } | |
| } | |
| - | |
| + | |
| // asynchronously iterates through the given concurrent maps and populates the operation log with | |
| // the proposed operations | |
| private class _OperationLogAsyncUpdater extends Thread { | |
| final Map<OpType, Map<File, File>> _selections; | |
| final JTextArea _operationLog; // safe to set text from another thread | |
| - | |
| + | |
| // synchronized-access data | |
| private int _updateCallCnt = 0; | |
| private Set<OpType> _selectedOptions; | |
| @@ -659,62 +697,61 @@ | |
| private boolean _isMove; | |
| private boolean _isOverwrite; | |
| private boolean _stop; | |
| - | |
| + | |
| // only accessed from the event loop thread | |
| int _maxLogLength = 0; | |
| - | |
| + | |
| - public _OperationLogAsyncUpdater(Map<OpType, Pair<FCheckBox, ? extends Map<File, File>>> selections, JTextArea operationLog) { | |
| + public _OperationLogAsyncUpdater(final Map<OpType, Pair<FCheckBox, ? extends Map<File, File>>> selections, final JTextArea operationLog) { | |
| super("OperationLogUpdater"); | |
| setDaemon(true); | |
| - | |
| + | |
| _selections = new HashMap<OpType, Map<File, File>>(); | |
| _operationLog = operationLog; | |
| - | |
| + | |
| // remove references to FCheckBox when populating map -- we can't safely access it from a thread | |
| // anyway and it's better to keep our data structure clean to prevent mistakes | |
| - for (Map.Entry<OpType, Pair<FCheckBox, ? extends Map<File, File>>> entry : selections.entrySet()) { | |
| + for (final Map.Entry<OpType, Pair<FCheckBox, ? extends Map<File, File>>> entry : selections.entrySet()) { | |
| _selections.put(entry.getKey(), entry.getValue().getRight()); | |
| } | |
| } | |
| // updates the synchronized data with values for the next iteration in _run | |
| - public synchronized void requestUpdate( | |
| - Set<OpType> selectedOptions, _UnknownDeckChoice unknownDeckChoice, boolean isMove, boolean isOverwrite) { | |
| + public synchronized void requestUpdate(final Set<OpType> selectedOptions, final _UnknownDeckChoice unknownDeckChoice, final boolean isMove, final boolean isOverwrite) { | |
| ++_updateCallCnt; | |
| _selectedOptions = selectedOptions; | |
| _unknownDeckChoice = unknownDeckChoice; | |
| _isMove = isMove; | |
| _isOverwrite = isOverwrite; | |
| - | |
| + | |
| // notify waiter | |
| notify(); | |
| } | |
| - | |
| + | |
| public synchronized void requestStop() { | |
| _stop = true; | |
| - | |
| + | |
| // notify waiter | |
| notify(); | |
| } | |
| - | |
| + | |
| private void _run() throws InterruptedException { | |
| int lastUpdateCallCnt = _updateCallCnt; | |
| Set<OpType> selectedOptions; | |
| _UnknownDeckChoice unknownDeckChoice; | |
| boolean isMove; | |
| boolean isOverwrite; | |
| - | |
| + | |
| while (true) { | |
| synchronized (this) { | |
| // can't check _stop in the while condition since we have to do it in a synchronized block | |
| if (_stop) { break; } | |
| - | |
| + | |
| // if we're stopped while looping here, run through the update one last time | |
| // before returning | |
| while (lastUpdateCallCnt == _updateCallCnt && !_stop) { | |
| wait(); | |
| } | |
| - | |
| + | |
| // safely copy synchronized data to local values that we will use for this runthrough | |
| lastUpdateCallCnt = _updateCallCnt; | |
| selectedOptions = _selectedOptions; | |
| @@ -722,15 +759,15 @@ | |
| isMove = _isMove; | |
| isOverwrite = _isOverwrite; | |
| } | |
| - | |
| + | |
| // build operation log | |
| final StringBuilder log = new StringBuilder(); | |
| int totalOps = 0; | |
| - for (OpType opType : selectedOptions) { | |
| - Map<File, File> ops = _selections.get(opType); | |
| + for (final OpType opType : selectedOptions) { | |
| + final Map<File, File> ops = _selections.get(opType); | |
| totalOps += ops.size(); | |
| - | |
| + | |
| - for (Map.Entry<File, File> op : ops.entrySet()) { | |
| + for (final Map.Entry<File, File> op : ops.entrySet()) { | |
| File dest = op.getValue(); | |
| if (OpType.UNKNOWN_DECK == opType) { | |
| dest = new File(unknownDeckChoice.path, dest.getName()); | |
| @@ -739,7 +776,7 @@ | |
| log.append(dest.getAbsolutePath()).append("\n"); | |
| } | |
| } | |
| - | |
| + | |
| // append summary | |
| if (0 < totalOps) { | |
| log.append("\n"); | |
| @@ -751,14 +788,14 @@ | |
| SwingUtilities.invokeLater(new Runnable() { | |
| @Override | |
| public void run() { | |
| - String logText = log.toString(); | |
| + final String logText = log.toString(); | |
| - | |
| + | |
| // setText is thread-safe, but the resizing is not, so might as well do this in the swing event loop thread | |
| _operationLog.setText(log.toString()); | |
| if (_maxLogLength < logText.length()) { | |
| _maxLogLength = logText.length(); | |
| - | |
| + | |
| // resize the panel properly for the new log contents | |
| _selectionPanel.getParent().validate(); | |
| _selectionPanel.getParent().invalidate(); | |
| @@ -769,7 +806,7 @@ | |
| }); | |
| } | |
| } | |
| - | |
| + | |
| @Override | |
| public void run() { | |
| try { _run(); } catch (final InterruptedException e) { | |
| @@ -792,54 +829,54 @@ | |
| private final JProgressBar _progressBar; | |
| private final boolean _move; | |
| private final boolean _overwrite; | |
| - | |
| + | |
| - public _Importer(String srcDir, Map<OpType, Pair<FCheckBox, ? extends Map<File, File>>> selections, FComboBoxWrapper<_UnknownDeckChoice> unknownDeckCombo, | |
| - JTextArea operationLog, JProgressBar progressBar, boolean move, boolean overwrite) { | |
| + public _Importer(final String srcDir, final Map<OpType, Pair<FCheckBox, ? extends Map<File, File>>> selections, final FComboBoxWrapper<_UnknownDeckChoice> unknownDeckCombo, | |
| + final JTextArea operationLog, final JProgressBar progressBar, final boolean move, final boolean overwrite) { | |
| _srcDir = srcDir; | |
| _operationLog = operationLog; | |
| _progressBar = progressBar; | |
| _move = move; | |
| _overwrite = overwrite; | |
| - | |
| + | |
| // build local operations map that only includes data that we can access from the background thread | |
| // use a tree map to maintain alphabetical order | |
| _operations = new TreeMap<File, File>(); | |
| - for (Map.Entry<OpType, Pair<FCheckBox, ? extends Map<File, File>>> entry : selections.entrySet()) { | |
| - Pair<FCheckBox, ? extends Map<File, File>> selection = entry.getValue(); | |
| + for (final Map.Entry<OpType, Pair<FCheckBox, ? extends Map<File, File>>> entry : selections.entrySet()) { | |
| + final Pair<FCheckBox, ? extends Map<File, File>> selection = entry.getValue(); | |
| if (selection.getLeft().isSelected()) { | |
| if (OpType.UNKNOWN_DECK != entry.getKey()) { | |
| _operations.putAll(selection.getRight()); | |
| } else { | |
| // map unknown decks to selected directory | |
| - for (Map.Entry<File, File> op : selection.getRight().entrySet()) { | |
| - _UnknownDeckChoice choice = (_UnknownDeckChoice)unknownDeckCombo.getSelectedItem(); | |
| + for (final Map.Entry<File, File> op : selection.getRight().entrySet()) { | |
| + final _UnknownDeckChoice choice = unknownDeckCombo.getSelectedItem(); | |
| _operations.put(op.getKey(), new File(choice.path, op.getValue().getName())); | |
| } | |
| } | |
| } | |
| } | |
| - | |
| + | |
| // set progress bar bounds | |
| _progressBar.setString(_move ? "Moving files..." : "Copying files..."); | |
| _progressBar.setMinimum(0); | |
| _progressBar.setMaximum(_operations.size()); | |
| } | |
| - | |
| + | |
| @Override | |
| protected Void doInBackground() throws Exception { | |
| try { | |
| // working with textbox text is thread safe | |
| _operationLog.setText(""); | |
| - | |
| + | |
| // only update the text box once very half second, but make the first | |
| // update after only 100ms | |
| final long updateIntervalMs = 500; | |
| long lastUpdateTimestampMs = System.currentTimeMillis() - 400; | |
| - StringBuffer opLogBuf = new StringBuffer(); | |
| + final StringBuffer opLogBuf = new StringBuffer(); | |
| - | |
| + | |
| // only update the progress bar when we expect the visual value to change | |
| final long progressInterval = Math.max(1, _operations.size() / _progressBar.getWidth()); | |
| - | |
| + | |
| // the length of the prefix to remove from source paths | |
| final int srcPathPrefixLen; | |
| if (_srcDir.endsWith("/") || _srcDir.endsWith(File.separator)) { | |
| @@ -848,15 +885,15 @@ | |
| { | |
| srcPathPrefixLen = _srcDir.length() + 1; | |
| } | |
| - | |
| + | |
| // stats maintained during import sequence | |
| int numOps = 0; | |
| int numExisting = 0; | |
| int numSucceeded = 0; | |
| int numFailed = 0; | |
| - for (Map.Entry<File, File> op : _operations.entrySet()) { | |
| + for (final Map.Entry<File, File> op : _operations.entrySet()) { | |
| if (_cancel) { break; } | |
| - | |
| + | |
| final int curOpNum = ++numOps; | |
| if (0 == curOpNum % progressInterval) { | |
| SwingUtilities.invokeLater(new Runnable() { | |
| @@ -866,19 +903,19 @@ | |
| } | |
| }); | |
| } | |
| - | |
| + | |
| - long curTimeMs = System.currentTimeMillis(); | |
| + final long curTimeMs = System.currentTimeMillis(); | |
| if (updateIntervalMs <= curTimeMs - lastUpdateTimestampMs) { | |
| lastUpdateTimestampMs = curTimeMs; | |
| - | |
| + | |
| // working with textbox text is thread safe | |
| _operationLog.append(opLogBuf.toString()); | |
| opLogBuf.setLength(0); | |
| } | |
| - | |
| + | |
| - File srcFile = op.getKey(); | |
| - File destFile = op.getValue(); | |
| + final File srcFile = op.getKey(); | |
| + final File destFile = op.getValue(); | |
| - | |
| + | |
| try { | |
| // simplify logged source path and log next attempted operation | |
| String srcPath = srcFile.getAbsolutePath(); | |
| @@ -901,20 +938,20 @@ | |
| } | |
| ++numExisting; | |
| } | |
| - | |
| + | |
| if (_move) { | |
| // source file may have been deleted already if _copyFile was called | |
| srcFile.delete(); | |
| opLogBuf.append(" Removed source file after successful copy\n"); | |
| } | |
| - | |
| + | |
| ++numSucceeded; | |
| - } catch (IOException e) { | |
| + } catch (final IOException e) { | |
| opLogBuf.append(" Operation failed: ").append(e.getMessage()).append("\n"); | |
| ++numFailed; | |
| } | |
| } | |
| - | |
| + | |
| // append summary footer | |
| opLogBuf.append("\nImport complete: "); | |
| opLogBuf.append(numSucceeded).append(" operation").append(1 == numSucceeded ? "" : "s").append(" succeeded, "); | |
| @@ -930,7 +967,7 @@ | |
| _operationLog.append(opLogBuf.toString()); | |
| } catch (final Exception e) { | |
| _cancel = true; | |
| - | |
| + | |
| // report any exceptions in a standard dialog | |
| // note that regular I/O errors don't throw, they'll just be mentioned in the log | |
| SwingUtilities.invokeLater(new Runnable() { | |
| @@ -940,7 +977,7 @@ | |
| } | |
| }); | |
| } | |
| - | |
| + | |
| return null; | |
| } | |
| @@ -948,24 +985,24 @@ | |
| protected void done() { | |
| _btnCancel.requestFocusInWindow(); | |
| if (_cancel) { return; } | |
| - | |
| + | |
| _progressBar.setValue(_progressBar.getMaximum()); | |
| _progressBar.setString("Import complete"); | |
| _btnCancel.setText("Done"); | |
| } | |
| } | |
| - | |
| + | |
| // when copying is required, uses java nio classes for ultra-fast I/O | |
| - private static void _copyFile(File srcFile, File destFile, boolean deleteSrcAfter) throws IOException { | |
| + private static void _copyFile(final File srcFile, final File destFile, final boolean deleteSrcAfter) throws IOException { | |
| destFile.getParentFile().mkdirs(); | |
| - | |
| + | |
| // if this is a move, try a simple rename first | |
| if (deleteSrcAfter) { | |
| if (srcFile.renameTo(destFile)) { | |
| return; | |
| } | |
| } | |
| - | |
| + | |
| if (!destFile.exists()) { | |
| destFile.createNewFile(); | |
| } | |
| Index: forge-gui/src/main/java/forge/FThreads.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui/src/main/java/forge/FThreads.java (revision 29316) | |
| +++ forge-gui/src/main/java/forge/FThreads.java (revision 29317) | |
| @@ -1,7 +1,5 @@ | |
| package forge; | |
| -import java.io.PrintStream; | |
| - | |
| import forge.util.ThreadUtil; | |
| public class FThreads { | |
| @@ -10,15 +8,15 @@ | |
| /** Checks if calling method uses event dispatch thread. | |
| * Exception thrown if method is on "wrong" thread. | |
| * A boolean is passed to indicate if the method must be EDT or not. | |
| - * | |
| + * | |
| * @param methodName   String, part of the custom exception message. | |
| * @param mustBeEDT   boolean: true = exception if not EDT, false = exception if EDT | |
| */ | |
| public static void assertExecutedByEdt(final boolean mustBeEDT) { | |
| if (isGuiThread() != mustBeEDT) { | |
| - StackTraceElement[] trace = Thread.currentThread().getStackTrace(); | |
| + final StackTraceElement[] trace = Thread.currentThread().getStackTrace(); | |
| final String methodName = trace[2].getClassName() + "." + trace[2].getMethodName(); | |
| - String modalOperator = mustBeEDT ? " must be" : " may not be"; | |
| + final String modalOperator = mustBeEDT ? " must be" : " may not be"; | |
| throw new IllegalStateException(methodName + modalOperator + " accessed from the event dispatch thread."); | |
| } | |
| } | |
| @@ -40,10 +38,10 @@ | |
| * Invoke the given Runnable in an Event Dispatch Thread and wait for it to | |
| * finish; but <B>try to use SwingUtilities.invokeLater instead whenever | |
| * feasible.</B> | |
| - * | |
| + * | |
| * Exceptions generated by SwingUtilities.invokeAndWait (if used), are | |
| * rethrown as RuntimeExceptions. | |
| - * | |
| + * | |
| * @param proc | |
| * the Runnable to run | |
| * @see fgd.SwingUtilities#invokeLater(Runnable) | |
| @@ -64,7 +62,7 @@ | |
| } | |
| public static void delayInEDT(final int milliseconds, final Runnable inputUpdater) { | |
| - Runnable runInEdt = new Runnable() { | |
| + final Runnable runInEdt = new Runnable() { | |
| @Override | |
| public void run() { | |
| FThreads.invokeInEdtNowOrLater(inputUpdater); | |
| @@ -77,23 +75,8 @@ | |
| return isGuiThread() ? "EDT" : Thread.currentThread().getName(); | |
| } | |
| - public static String prependThreadId(String message) { | |
| - return debugGetCurrThreadId() + " > " + message; | |
| - } | |
| - | |
| - public static void dumpStackTrace(final PrintStream stream) { | |
| - StackTraceElement[] trace = Thread.currentThread().getStackTrace(); | |
| - stream.printf("%s > %s called from %s%n", debugGetCurrThreadId(), | |
| - trace[2].getClassName() + "." + trace[2].getMethodName(), trace[3].toString()); | |
| - int i = 0; | |
| - for (StackTraceElement se : trace) { | |
| - if (i<2) { i++; } | |
| - else { stream.println(se.toString()); } | |
| - } | |
| - } | |
| - | |
| public static String debugGetStackTraceItem(final int depth, final boolean shorter) { | |
| - StackTraceElement[] trace = Thread.currentThread().getStackTrace(); | |
| + final StackTraceElement[] trace = Thread.currentThread().getStackTrace(); | |
| String lastItem = trace[depth].toString(); | |
| if (shorter) { | |
| int lastPeriod = lastItem.lastIndexOf('.'); | |
| Index: forge-gui-desktop/src/main/java/forge/itemmanager/ItemManager.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>UTF-8 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/itemmanager/ItemManager.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/itemmanager/ItemManager.java (revision 29317) | |
| @@ -6,17 +6,44 @@ | |
| * 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 <http://www.gnu.org/licenses/>. | |
| */ | |
| package forge.itemmanager; | |
| +import java.awt.Component; | |
| +import java.awt.Toolkit; | |
| +import java.awt.event.ItemEvent; | |
| +import java.awt.event.ItemListener; | |
| +import java.awt.event.KeyAdapter; | |
| +import java.awt.event.KeyEvent; | |
| +import java.awt.event.MouseEvent; | |
| +import java.util.ArrayList; | |
| +import java.util.Arrays; | |
| +import java.util.Collection; | |
| +import java.util.HashMap; | |
| +import java.util.List; | |
| +import java.util.Map; | |
| +import java.util.Map.Entry; | |
| + | |
| +import javax.swing.JMenu; | |
| +import javax.swing.JPanel; | |
| +import javax.swing.JPopupMenu; | |
| +import javax.swing.KeyStroke; | |
| +import javax.swing.SwingConstants; | |
| +import javax.swing.SwingUtilities; | |
| +import javax.swing.event.ListSelectionListener; | |
| +import javax.swing.event.PopupMenuEvent; | |
| +import javax.swing.event.PopupMenuListener; | |
| + | |
| +import net.miginfocom.swing.MigLayout; | |
| + | |
| import com.google.common.base.Predicate; | |
| import com.google.common.base.Predicates; | |
| import com.google.common.collect.Iterables; | |
| @@ -25,38 +52,28 @@ | |
| import forge.assets.FSkinProp; | |
| import forge.gui.GuiUtils; | |
| import forge.item.InventoryItem; | |
| -import forge.itemmanager.ColumnDef; | |
| -import forge.itemmanager.IItemManager; | |
| -import forge.itemmanager.ItemManagerConfig; | |
| -import forge.itemmanager.ItemManagerModel; | |
| import forge.itemmanager.filters.ItemFilter; | |
| -import forge.itemmanager.views.*; | |
| +import forge.itemmanager.views.ImageView; | |
| +import forge.itemmanager.views.ItemListView; | |
| +import forge.itemmanager.views.ItemTableColumn; | |
| +import forge.itemmanager.views.ItemView; | |
| import forge.screens.match.controllers.CDetailPicture; | |
| -import forge.toolbox.*; | |
| +import forge.toolbox.ContextMenuBuilder; | |
| +import forge.toolbox.FLabel; | |
| +import forge.toolbox.FSkin; | |
| import forge.toolbox.FSkin.Colors; | |
| import forge.toolbox.FSkin.SkinIcon; | |
| import forge.toolbox.FSkin.SkinnedCheckBox; | |
| import forge.toolbox.FSkin.SkinnedPanel; | |
| +import forge.toolbox.FTextField; | |
| +import forge.toolbox.LayoutHelper; | |
| import forge.util.Aggregates; | |
| import forge.util.ItemPool; | |
| import forge.util.ReflectionUtil; | |
| -import net.miginfocom.swing.MigLayout; | |
| -import javax.swing.*; | |
| -import javax.swing.event.ListSelectionListener; | |
| -import javax.swing.event.PopupMenuEvent; | |
| -import javax.swing.event.PopupMenuListener; | |
| - | |
| -import java.awt.*; | |
| -import java.awt.event.*; | |
| -import java.util.*; | |
| -import java.util.List; | |
| -import java.util.Map.Entry; | |
| - | |
| - | |
| /** | |
| * ItemManager. | |
| - * | |
| + * | |
| * @param <T> | |
| * the generic type | |
| */ | |
| @@ -108,7 +125,8 @@ | |
| private static final SkinIcon VIEW_OPTIONS_ICON = FSkin.getIcon(FSkinProp.ICO_SETTINGS).resize(20, 20); | |
| private final FLabel btnViewOptions = new FLabel.Builder() | |
| - .hoverable().selectable(true) | |
| + .hoverable() | |
| + .selectable(true) | |
| .icon(VIEW_OPTIONS_ICON).iconScaleAuto(false) | |
| .tooltip("Toggle to show/hide options for current view") | |
| .build(); | |
| @@ -122,7 +140,7 @@ | |
| /** | |
| * ItemManager Constructor. | |
| - * | |
| + * | |
| * @param genericType0 the class of item that this table will contain | |
| * @param statLabels0 stat labels for this item manager | |
| * @param wantUnique0 whether this table should display only one item with the same name | |
| @@ -167,11 +185,10 @@ | |
| this.chkEnableFilters.setText("(*)"); | |
| this.chkEnableFilters.setSelected(true); | |
| this.chkEnableFilters.addItemListener(new ItemListener() { | |
| - @Override | |
| - public void itemStateChanged(ItemEvent arg0) { | |
| + @Override public void itemStateChanged(final ItemEvent arg0) { | |
| lockFiltering = true; | |
| - boolean enabled = chkEnableFilters.isSelected(); | |
| - for (ItemFilter<? extends T> filter : orderedFilters) { | |
| + final boolean enabled = chkEnableFilters.isSelected(); | |
| + for (final ItemFilter<? extends T> filter : orderedFilters) { | |
| filter.setEnabled(enabled); | |
| } | |
| txtFilterLogic.setEnabled(enabled); | |
| @@ -194,7 +211,7 @@ | |
| this.add(this.btnFilters); | |
| this.add(this.lblCaption); | |
| this.add(this.lblRatio); | |
| - for (ItemView<T> view : this.views) { | |
| + for (final ItemView<T> view : this.views) { | |
| this.add(view.getButton()); | |
| view.getButton().setSelected(view == this.currentView); | |
| } | |
| @@ -204,9 +221,8 @@ | |
| this.add(this.currentView.getScroller()); | |
| final Runnable cmdAddCurrentSearch = new Runnable() { | |
| - @Override | |
| - public void run() { | |
| - ItemFilter<? extends T> searchFilter = mainSearchFilter.createCopy(); | |
| + @Override public void run() { | |
| + final ItemFilter<? extends T> searchFilter = mainSearchFilter.createCopy(); | |
| if (searchFilter != null) { | |
| lockFiltering = true; //prevent updating filtering from this change | |
| addFilter(searchFilter); | |
| @@ -216,8 +232,7 @@ | |
| } | |
| }; | |
| final Runnable cmdResetFilters = new Runnable() { | |
| - @Override | |
| - public void run() { | |
| + @Override public void run() { | |
| resetFilters(); | |
| SwingUtilities.invokeLater(new Runnable() { | |
| @Override | |
| @@ -228,8 +243,7 @@ | |
| } | |
| }; | |
| final Runnable cmdHideFilters = new Runnable() { | |
| - @Override | |
| - public void run() { | |
| + @Override public void run() { | |
| setHideFilters(!getHideFilters()); | |
| SwingUtilities.invokeLater(new Runnable() { | |
| @Override | |
| @@ -241,8 +255,7 @@ | |
| }; | |
| this.mainSearchFilter.getMainComponent().addKeyListener(new KeyAdapter() { | |
| - @Override | |
| - public void keyPressed(KeyEvent e) { | |
| + @Override public void keyPressed(final KeyEvent e) { | |
| if (e.getKeyCode() == 10) { | |
| if (e.isControlDown() || e.isMetaDown()) { | |
| cmdAddCurrentSearch.run(); | |
| @@ -253,14 +266,12 @@ | |
| //setup command for btnFilters | |
| final UiCommand cmdBuildFilterMenu = new UiCommand() { | |
| - @Override | |
| - public void run() { | |
| - JPopupMenu menu = new JPopupMenu("FilterMenu"); | |
| + @Override public void run() { | |
| + final JPopupMenu menu = new JPopupMenu("FilterMenu"); | |
| if (hideFilters) { | |
| GuiUtils.addMenuItem(menu, "Show Filters", null, cmdHideFilters); | |
| - } | |
| - else { | |
| - JMenu addMenu = GuiUtils.createMenu("Add"); | |
| + } else { | |
| + final JMenu addMenu = GuiUtils.createMenu("Add"); | |
| if (mainSearchFilter.isEnabled()) { | |
| GuiUtils.addMenuItem(addMenu, "Current text search", | |
| KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), | |
| @@ -268,8 +279,7 @@ | |
| if (config != ItemManagerConfig.STRING_ONLY) { | |
| buildAddFilterMenu(addMenu); | |
| } | |
| - } | |
| - else { | |
| + } else { | |
| addMenu.setEnabled(false); | |
| } | |
| menu.add(addMenu); | |
| @@ -284,8 +294,7 @@ | |
| this.btnFilters.setRightClickCommand(cmdBuildFilterMenu); //show menu on right-click too | |
| this.btnViewOptions.setCommand(new Runnable() { | |
| - @Override | |
| - public void run() { | |
| + @Override public void run() { | |
| currentView.getPnlOptions().setVisible(!currentView.getPnlOptions().isVisible()); | |
| revalidate(); | |
| } | |
| @@ -302,26 +311,28 @@ | |
| } | |
| } | |
| + @Override | |
| public ItemManagerConfig getConfig() { | |
| return this.config; | |
| } | |
| - public void setup(ItemManagerConfig config0) { | |
| + @Override | |
| + public void setup(final ItemManagerConfig config0) { | |
| this.setup(config0, null); | |
| } | |
| - public void setup(ItemManagerConfig config0, Map<ColumnDef, ItemTableColumn> colOverrides) { | |
| + public void setup(final ItemManagerConfig config0, final Map<ColumnDef, ItemTableColumn> colOverrides) { | |
| this.config = config0; | |
| this.setWantUnique(config0.getUniqueCardsOnly()); | |
| - for (ItemView<T> view : this.views) { | |
| + for (final ItemView<T> view : this.views) { | |
| view.setup(config0, colOverrides); | |
| } | |
| this.setViewIndex(config0.getViewIndex()); | |
| this.setHideFilters(config0.getHideFilters()); | |
| } | |
| - public void setViewIndex(int viewIndex) { | |
| + public void setViewIndex(final int viewIndex) { | |
| if (viewIndex < 0 || viewIndex >= this.views.size()) { return; } | |
| - ItemView<T> view = this.views.get(viewIndex); | |
| + final ItemView<T> view = this.views.get(viewIndex); | |
| if (this.currentView == view) { return; } | |
| if (this.config != null) { | |
| @@ -355,19 +366,19 @@ | |
| this.focus(); | |
| } | |
| - public void setHideViewOptions(int viewIndex, boolean hideViewOptions) { | |
| + public void setHideViewOptions(final int viewIndex, final boolean hideViewOptions) { | |
| if (viewIndex < 0 || viewIndex >= this.views.size()) { return; } | |
| this.views.get(viewIndex).getPnlOptions().setVisible(!hideViewOptions); | |
| } | |
| @Override | |
| public void doLayout() { | |
| - int buttonPanelHeight = 32; | |
| - LayoutHelper helper = new LayoutHelper(this); | |
| + final int buttonPanelHeight = 32; | |
| + final LayoutHelper helper = new LayoutHelper(this); | |
| boolean showButtonPanel = false; | |
| if (this.pnlButtons.isVisible()) { | |
| - for (Component comp : this.pnlButtons.getComponents()) { | |
| + for (final Component comp : this.pnlButtons.getComponents()) { | |
| if (comp.isVisible()) { | |
| showButtonPanel = true; | |
| break; | |
| @@ -379,15 +390,13 @@ | |
| if (showButtonPanel) { | |
| helper.offset(0, -4); | |
| helper.fillLine(this.pnlButtons, buttonPanelHeight); | |
| - } | |
| - else { | |
| + } else { | |
| this.pnlButtons.setBounds(0, 0, 0, 0); //prevent horizontal line appearing | |
| } | |
| - } | |
| - else { | |
| + } else { | |
| int number = 0; | |
| - StringBuilder logicBuilder = new StringBuilder(); | |
| - for (ItemFilter<? extends T> filter : this.orderedFilters) { | |
| + final StringBuilder logicBuilder = new StringBuilder(); | |
| + for (final ItemFilter<? extends T> filter : this.orderedFilters) { | |
| filter.setNumber(++number); | |
| logicBuilder.append(number + "&"); | |
| helper.fillLine(filter.getPanel(), ItemFilter.PANEL_HEIGHT); | |
| @@ -405,20 +414,19 @@ | |
| helper.offset(1, 0); //align filters button with expand/collapse all button | |
| helper.include(this.btnFilters, 61, FTextField.HEIGHT); | |
| int captionWidth = this.lblCaption.getAutoSizeWidth(); | |
| - int ratioWidth = this.lblRatio.getAutoSizeWidth(); | |
| - int viewButtonWidth = FTextField.HEIGHT; | |
| - int viewButtonCount = this.views.size() + 1; | |
| - int availableCaptionWidth = helper.getParentWidth() - viewButtonWidth * viewButtonCount - ratioWidth - helper.getX() - (viewButtonCount + 2) * helper.getGapX(); | |
| + final int ratioWidth = this.lblRatio.getAutoSizeWidth(); | |
| + final int viewButtonWidth = FTextField.HEIGHT; | |
| + final int viewButtonCount = this.views.size() + 1; | |
| + final int availableCaptionWidth = helper.getParentWidth() - viewButtonWidth * viewButtonCount - ratioWidth - helper.getX() - (viewButtonCount + 2) * helper.getGapX(); | |
| if (captionWidth > availableCaptionWidth) { //truncate caption if not enough room for it | |
| this.lblCaption.setToolTipText(this.lblCaption.getText()); | |
| captionWidth = availableCaptionWidth; | |
| - } | |
| - else { | |
| + } else { | |
| this.lblCaption.setToolTipText(null); | |
| } | |
| helper.include(this.lblCaption, captionWidth, FTextField.HEIGHT); | |
| helper.fillLine(this.lblRatio, FTextField.HEIGHT, (viewButtonWidth + helper.getGapX()) * viewButtonCount - viewButtonCount + 1); //leave room for view buttons | |
| - for (ItemView<T> view : this.views) { | |
| + for (final ItemView<T> view : this.views) { | |
| helper.include(view.getButton(), viewButtonWidth, FTextField.HEIGHT); | |
| helper.offset(-1, 0); | |
| } | |
| @@ -431,78 +439,85 @@ | |
| } | |
| /** | |
| - * | |
| + * | |
| * getGenericType. | |
| - * | |
| + * | |
| * @return generic type of items | |
| */ | |
| + @Override | |
| public Class<T> getGenericType() { | |
| return this.genericType; | |
| } | |
| /** | |
| - * | |
| + * | |
| * getCaption. | |
| - * | |
| + * | |
| * @return caption to display before ratio | |
| */ | |
| + @Override | |
| public String getCaption() { | |
| return this.lblCaption.getText(); | |
| } | |
| /** | |
| - * | |
| + * | |
| * setCaption. | |
| - * | |
| + * | |
| * @param caption - caption to display before ratio | |
| */ | |
| - public void setCaption(String caption) { | |
| + @Override | |
| + public void setCaption(final String caption) { | |
| this.lblCaption.setText(caption); | |
| } | |
| /** | |
| - * | |
| + * | |
| * Gets the item pool. | |
| - * | |
| + * | |
| * @return ItemPoolView | |
| */ | |
| + @Override | |
| public ItemPool<T> getPool() { | |
| return this.pool; | |
| } | |
| /** | |
| - * | |
| + * | |
| * Sets the item pool. | |
| - * | |
| + * | |
| * @param items | |
| */ | |
| + @Override | |
| public void setPool(final Iterable<T> items) { | |
| this.setPool(ItemPool.createFrom(items, this.genericType), false); | |
| } | |
| /** | |
| - * | |
| + * | |
| * Sets the item pool. | |
| - * | |
| + * | |
| * @param poolView | |
| * @param infinite | |
| */ | |
| - public void setPool(final ItemPool<T> poolView, boolean infinite) { | |
| + @Override | |
| + public void setPool(final ItemPool<T> poolView, final boolean infinite) { | |
| this.setPoolImpl(ItemPool.createFrom(poolView, this.genericType), infinite); | |
| } | |
| + @Override | |
| public void setPool(final ItemPool<T> pool0) { | |
| this.setPoolImpl(pool0, false); | |
| } | |
| /** | |
| - * | |
| + * | |
| * Sets the item pool. | |
| - * | |
| + * | |
| * @param pool0 | |
| * @param infinite | |
| */ | |
| - private void setPoolImpl(final ItemPool<T> pool0, boolean infinite) { | |
| + private void setPoolImpl(final ItemPool<T> pool0, final boolean infinite) { | |
| this.model.clear(); | |
| this.pool = pool0; | |
| this.model.addItems(this.pool); | |
| @@ -515,89 +530,99 @@ | |
| } | |
| /** | |
| - * | |
| + * | |
| * getItemCount. | |
| - * | |
| + * | |
| * @return int | |
| */ | |
| + @Override | |
| public int getItemCount() { | |
| return this.currentView.getCount(); | |
| } | |
| /** | |
| - * | |
| + * | |
| * getSelectionCount. | |
| - * | |
| + * | |
| * @return int | |
| */ | |
| + @Override | |
| public int getSelectionCount() { | |
| return this.currentView.getSelectionCount(); | |
| } | |
| /** | |
| - * | |
| + * | |
| * getSelectedItem. | |
| - * | |
| + * | |
| * @return T | |
| */ | |
| + @Override | |
| public T getSelectedItem() { | |
| return this.currentView.getSelectedItem(); | |
| } | |
| /** | |
| - * | |
| + * | |
| * getSelectedItems. | |
| - * | |
| + * | |
| * @return Iterable<T> | |
| */ | |
| + @Override | |
| public Collection<T> getSelectedItems() { | |
| return this.currentView.getSelectedItems(); | |
| } | |
| /** | |
| - * | |
| + * | |
| * getSelectedItems. | |
| - * | |
| + * | |
| * @return ItemPool<T> | |
| */ | |
| + @Override | |
| public ItemPool<T> getSelectedItemPool() { | |
| - ItemPool<T> selectedItemPool = new ItemPool<T>(this.genericType); | |
| - for (T item : getSelectedItems()) { | |
| + final ItemPool<T> selectedItemPool = new ItemPool<T>(this.genericType); | |
| + for (final T item : getSelectedItems()) { | |
| selectedItemPool.add(item, getItemCount(item)); | |
| } | |
| return selectedItemPool; | |
| } | |
| /** | |
| - * | |
| + * | |
| * setSelectedItem. | |
| - * | |
| + * | |
| * @param item - Item to select | |
| */ | |
| - public boolean setSelectedItem(T item) { | |
| + @Override | |
| + public boolean setSelectedItem(final T item) { | |
| - return this.currentView.setSelectedItem(item); | |
| + return this.currentView.setSelectedItem(item); | |
| } | |
| /** | |
| - * | |
| + * | |
| * setSelectedItems. | |
| - * | |
| + * | |
| * @param items - Items to select | |
| */ | |
| - public boolean setSelectedItems(Iterable<T> items) { | |
| + @Override | |
| + public boolean setSelectedItems(final Iterable<T> items) { | |
| return this.currentView.setSelectedItems(items); | |
| } | |
| /** | |
| - * | |
| + * | |
| * stringToItem. | |
| - * | |
| + * | |
| * @param str - String to get item corresponding to | |
| */ | |
| - public T stringToItem(String str) { | |
| - if (this.pool == null) { return null; } | |
| + @Override | |
| + public T stringToItem(final String str) { | |
| + if (this.pool == null) { | |
| + return null; | |
| + } | |
| - for (Entry<T, Integer> itemEntry : this.pool) { | |
| + for (final Entry<T, Integer> itemEntry : this.pool) { | |
| if (itemEntry.getKey().toString().equals(str)) { | |
| return itemEntry.getKey(); | |
| } | |
| @@ -606,13 +631,14 @@ | |
| } | |
| /** | |
| - * | |
| + * | |
| * setSelectedString. | |
| - * | |
| + * | |
| * @param str - String to select | |
| */ | |
| - public boolean setSelectedString(String str) { | |
| - T item = stringToItem(str); | |
| + @Override | |
| + public boolean setSelectedString(final String str) { | |
| + final T item = stringToItem(str); | |
| if (item != null) { | |
| return this.setSelectedItem(item); | |
| } | |
| @@ -620,15 +646,16 @@ | |
| } | |
| /** | |
| - * | |
| + * | |
| * setSelectedStrings. | |
| - * | |
| + * | |
| * @param strings - Strings to select | |
| */ | |
| - public boolean setSelectedStrings(Iterable<String> strings) { | |
| - List<T> items = new ArrayList<T>(); | |
| - for (String str : strings) { | |
| - T item = stringToItem(str); | |
| + @Override | |
| + public boolean setSelectedStrings(final Iterable<String> strings) { | |
| + final List<T> items = new ArrayList<T>(); | |
| + for (final String str : strings) { | |
| + final T item = stringToItem(str); | |
| if (item != null) { | |
| items.add(item); | |
| } | |
| @@ -637,115 +664,126 @@ | |
| } | |
| /** | |
| - * | |
| + * | |
| * selectItemEntrys. | |
| - * | |
| + * | |
| * @param itemEntrys - Item entrys to select | |
| */ | |
| - public boolean selectItemEntrys(Iterable<Entry<T, Integer>> itemEntrys) { | |
| - List<T> items = new ArrayList<T>(); | |
| - for (Entry<T, Integer> itemEntry : itemEntrys) { | |
| + @Override | |
| + public boolean selectItemEntrys(final Iterable<Entry<T, Integer>> itemEntrys) { | |
| + final List<T> items = new ArrayList<T>(); | |
| + for (final Entry<T, Integer> itemEntry : itemEntrys) { | |
| items.add(itemEntry.getKey()); | |
| } | |
| return this.setSelectedItems(items); | |
| } | |
| /** | |
| - * | |
| + * | |
| * selectAll. | |
| - * | |
| + * | |
| */ | |
| + @Override | |
| public void selectAll() { | |
| this.currentView.selectAll(); | |
| } | |
| /** | |
| - * | |
| + * | |
| * getSelectedItem. | |
| - * | |
| + * | |
| * @return T | |
| */ | |
| + @Override | |
| public int getSelectedIndex() { | |
| return this.currentView.getSelectedIndex(); | |
| } | |
| /** | |
| - * | |
| + * | |
| * getSelectedItems. | |
| - * | |
| + * | |
| * @return Iterable<Integer> | |
| */ | |
| + @Override | |
| public Iterable<Integer> getSelectedIndices() { | |
| return this.currentView.getSelectedIndices(); | |
| } | |
| /** | |
| - * | |
| + * | |
| * setSelectedIndex. | |
| - * | |
| + * | |
| * @param index - Index to select | |
| */ | |
| - public void setSelectedIndex(int index) { | |
| + @Override | |
| + public void setSelectedIndex(final int index) { | |
| this.currentView.setSelectedIndex(index); | |
| } | |
| /** | |
| - * | |
| + * | |
| * setSelectedIndices. | |
| - * | |
| + * | |
| * @param indices - Indices to select | |
| */ | |
| - public void setSelectedIndices(Integer[] indices) { | |
| + @Override | |
| + public void setSelectedIndices(final Integer[] indices) { | |
| this.currentView.setSelectedIndices(Arrays.asList(indices)); | |
| } | |
| - public void setSelectedIndices(Iterable<Integer> indices) { | |
| + | |
| + @Override | |
| + public void setSelectedIndices(final Iterable<Integer> indices) { | |
| this.currentView.setSelectedIndices(indices); | |
| } | |
| /** | |
| - * | |
| + * | |
| * addItem. | |
| - * | |
| + * | |
| * @param item | |
| * @param qty | |
| */ | |
| - public void addItem(final T item, int qty) { | |
| + @Override | |
| + public void addItem(final T item, final int qty) { | |
| this.pool.add(item, qty); | |
| if (this.isUnfiltered()) { | |
| this.model.addItem(item, qty); | |
| } | |
| - List<T> items = new ArrayList<T>(); | |
| + final List<T> items = new ArrayList<T>(); | |
| items.add(item); | |
| this.updateView(false, items); | |
| } | |
| /** | |
| - * | |
| + * | |
| * addItems. | |
| - * | |
| + * | |
| * @param itemsToAdd | |
| */ | |
| - public void addItems(Iterable<Entry<T, Integer>> itemsToAdd) { | |
| + @Override | |
| + public void addItems(final Iterable<Entry<T, Integer>> itemsToAdd) { | |
| this.pool.addAll(itemsToAdd); | |
| if (this.isUnfiltered()) { | |
| this.model.addItems(itemsToAdd); | |
| } | |
| - List<T> items = new ArrayList<T>(); | |
| - for (Map.Entry<T, Integer> item : itemsToAdd) { | |
| + final List<T> items = new ArrayList<T>(); | |
| + for (final Map.Entry<T, Integer> item : itemsToAdd) { | |
| items.add(item.getKey()); | |
| } | |
| this.updateView(false, items); | |
| } | |
| /** | |
| - * | |
| + * | |
| * removeItem. | |
| - * | |
| + * | |
| * @param item | |
| * @param qty | |
| */ | |
| - public void removeItem(final T item, int qty) { | |
| + @Override | |
| + public void removeItem(final T item, final int qty) { | |
| final Iterable<T> itemsToSelect = this.currentView == this.listView ? this.getSelectedItems() : null; | |
| this.pool.remove(item, qty); | |
| @@ -756,15 +794,16 @@ | |
| } | |
| /** | |
| - * | |
| + * | |
| * removeItems. | |
| - * | |
| + * | |
| * @param itemsToRemove | |
| */ | |
| - public void removeItems(Iterable<Map.Entry<T, Integer>> itemsToRemove) { | |
| + @Override | |
| + public void removeItems(final Iterable<Map.Entry<T, Integer>> itemsToRemove) { | |
| final Iterable<T> itemsToSelect = this.currentView == this.listView ? this.getSelectedItems() : null; | |
| - for (Map.Entry<T, Integer> item : itemsToRemove) { | |
| + for (final Map.Entry<T, Integer> item : itemsToRemove) { | |
| this.pool.remove(item.getKey(), item.getValue()); | |
| if (this.isUnfiltered()) { | |
| this.model.removeItem(item.getKey(), item.getValue()); | |
| @@ -774,10 +813,11 @@ | |
| } | |
| /** | |
| - * | |
| + * | |
| * removeAllItems. | |
| - * | |
| + * | |
| */ | |
| + @Override | |
| public void removeAllItems() { | |
| this.pool.clear(); | |
| this.model.clear(); | |
| @@ -785,29 +825,32 @@ | |
| } | |
| /** | |
| - * | |
| + * | |
| * scrollSelectionIntoView. | |
| - * | |
| + * | |
| */ | |
| + @Override | |
| public void scrollSelectionIntoView() { | |
| this.currentView.scrollSelectionIntoView(); | |
| } | |
| /** | |
| - * | |
| + * | |
| * getItemCount. | |
| - * | |
| + * | |
| * @param item | |
| */ | |
| + @Override | |
| public int getItemCount(final T item) { | |
| return this.model.isInfinite() ? Integer.MAX_VALUE : this.pool.count(item); | |
| } | |
| /** | |
| * Gets all filtered items in the model. | |
| - * | |
| + * | |
| * @return ItemPoolView<T> | |
| */ | |
| + @Override | |
| public ItemPool<T> getFilteredItems() { | |
| return this.model.getItems(); | |
| } | |
| @@ -816,7 +859,7 @@ | |
| protected abstract ItemFilter<? extends T> createSearchFilter(); | |
| protected abstract void buildAddFilterMenu(JMenu menu); | |
| - protected <F extends ItemFilter<? extends T>> F getFilter(Class<F> filterClass) { | |
| + protected <F extends ItemFilter<? extends T>> F getFilter(final Class<F> filterClass) { | |
| return ReflectionUtil.safeCast(this.filters.get(filterClass), filterClass); | |
| } | |
| @@ -844,7 +887,7 @@ | |
| orderedFilters.add(filter); | |
| this.add(filter.getPanel()); | |
| - boolean visible = !this.hideFilters; | |
| + final boolean visible = !this.hideFilters; | |
| filter.getPanel().setVisible(visible); | |
| if (visible && this.initialized) { | |
| this.revalidate(); | |
| @@ -872,7 +915,7 @@ | |
| public void restoreDefaultFilters() { | |
| lockFiltering = true; | |
| - for (ItemFilter<? extends T> filter : this.orderedFilters) { | |
| + for (final ItemFilter<? extends T> filter : this.orderedFilters) { | |
| this.remove(filter.getPanel()); | |
| } | |
| this.filters.clear(); | |
| @@ -884,7 +927,7 @@ | |
| } | |
| @SuppressWarnings("unchecked") | |
| - public void removeFilter(ItemFilter<? extends T> filter) { | |
| + public void removeFilter(final ItemFilter<? extends T> filter) { | |
| final Class<? extends ItemFilter<? extends T>> filterClass = (Class<? extends ItemFilter<? extends T>>) filter.getClass(); | |
| final List<ItemFilter<? extends T>> classFilters = this.filters.get(filterClass); | |
| if (classFilters != null && classFilters.remove(filter)) { | |
| @@ -898,11 +941,12 @@ | |
| } | |
| } | |
| + @Override | |
| public boolean applyFilters() { | |
| if (this.lockFiltering || !this.initialized) { return false; } | |
| - List<Predicate<? super T>> predicates = new ArrayList<Predicate<? super T>>(); | |
| - for (ItemFilter<? extends T> filter : this.orderedFilters) { //TODO: Support custom filter logic | |
| + final List<Predicate<? super T>> predicates = new ArrayList<Predicate<? super T>>(); | |
| + for (final ItemFilter<? extends T> filter : this.orderedFilters) { //TODO: Support custom filter logic | |
| if (filter.isEnabled() && !filter.isEmpty()) { | |
| predicates.add(filter.buildPredicate(this.genericType)); | |
| } | |
| @@ -911,7 +955,7 @@ | |
| predicates.add(mainSearchFilter.buildPredicate(this.genericType)); | |
| } | |
| - Predicate<? super T> newFilterPredicate = predicates.size() == 0 ? null : Predicates.and(predicates); | |
| + final Predicate<? super T> newFilterPredicate = predicates.size() == 0 ? null : Predicates.and(predicates); | |
| if (this.filterPredicate == newFilterPredicate) { return false; } | |
| this.filterPredicate = newFilterPredicate; | |
| @@ -922,18 +966,18 @@ | |
| } | |
| /** | |
| - * | |
| + * | |
| * isUnfiltered. | |
| - * | |
| + * | |
| */ | |
| private boolean isUnfiltered() { | |
| return this.filterPredicate == null; | |
| } | |
| /** | |
| - * | |
| + * | |
| * getHideFilters. | |
| - * | |
| + * | |
| * @return true if filters are hidden, false otherwise | |
| */ | |
| public boolean getHideFilters() { | |
| @@ -941,17 +985,17 @@ | |
| } | |
| /** | |
| - * | |
| + * | |
| * setHideFilters. | |
| - * | |
| + * | |
| * @param hideFilters0 - if true, hide the filters, otherwise show them | |
| */ | |
| - public void setHideFilters(boolean hideFilters0) { | |
| + public void setHideFilters(final boolean hideFilters0) { | |
| if (this.hideFilters == hideFilters0) { return; } | |
| this.hideFilters = hideFilters0; | |
| - boolean visible = !hideFilters0; | |
| - for (ItemFilter<? extends T> filter : this.orderedFilters) { | |
| + final boolean visible = !hideFilters0; | |
| + for (final ItemFilter<? extends T> filter : this.orderedFilters) { | |
| filter.getPanel().setVisible(visible); | |
| } | |
| this.chkEnableFilters.setVisible(visible); | |
| @@ -960,7 +1004,7 @@ | |
| if (this.initialized) { | |
| this.revalidate(); | |
| - | |
| + | |
| if (hideFilters0) { | |
| this.resetFilters(); //reset filters when they're hidden | |
| } | |
| @@ -975,13 +1019,13 @@ | |
| } | |
| /** | |
| - * | |
| + * | |
| * resetFilters. | |
| - * | |
| + * | |
| */ | |
| public void resetFilters() { | |
| lockFiltering = true; //prevent updating filtering from this change until all filters reset | |
| - for (ItemFilter<? extends T> filter : orderedFilters) { | |
| + for (final ItemFilter<? extends T> filter : orderedFilters) { | |
| filter.setEnabled(true); | |
| filter.reset(); | |
| } | |
| @@ -1003,14 +1047,14 @@ | |
| this.updateView(true, this.getSelectedItems()); | |
| } | |
| - protected Iterable<Entry<T, Integer>> getUnique(Iterable<Entry<T, Integer>> items) { | |
| + protected Iterable<Entry<T, Integer>> getUnique(final Iterable<Entry<T, Integer>> items) { | |
| return Aggregates.uniqueByLast(items, this.pool.FN_GET_NAME); | |
| } | |
| /** | |
| - * | |
| + * | |
| * updateView. | |
| - * | |
| + * | |
| * @param bForceFilter | |
| */ | |
| public void updateView(final boolean forceFilter, final Iterable<T> itemsToSelect) { | |
| @@ -1021,16 +1065,16 @@ | |
| } | |
| if (useFilter && this.wantUnique) { | |
| - Predicate<Entry<T, Integer>> filterForPool = Predicates.compose(this.filterPredicate, this.pool.FN_GET_KEY); | |
| - Iterable<Entry<T, Integer>> items = getUnique(Iterables.filter(this.pool, filterForPool)); | |
| + final Predicate<Entry<T, Integer>> filterForPool = Predicates.compose(this.filterPredicate, this.pool.FN_GET_KEY); | |
| + final Iterable<Entry<T, Integer>> items = getUnique(Iterables.filter(this.pool, filterForPool)); | |
| this.model.addItems(items); | |
| } | |
| else if (useFilter) { | |
| - Predicate<Entry<T, Integer>> pred = Predicates.compose(this.filterPredicate, this.pool.FN_GET_KEY); | |
| + final Predicate<Entry<T, Integer>> pred = Predicates.compose(this.filterPredicate, this.pool.FN_GET_KEY); | |
| this.model.addItems(Iterables.filter(this.pool, pred)); | |
| } | |
| else if (this.wantUnique) { | |
| - Iterable<Entry<T, Integer>> items = getUnique(this.pool); | |
| + final Iterable<Entry<T, Integer>> items = getUnique(this.pool); | |
| this.model.addItems(items); | |
| } | |
| else if (!useFilter && forceFilter) { | |
| @@ -1039,7 +1083,7 @@ | |
| this.currentView.refresh(itemsToSelect, this.getSelectedIndex(), forceFilter ? 0 : this.currentView.getScrollValue()); | |
| - for (ItemFilter<? extends T> filter : this.orderedFilters) { | |
| + for (final ItemFilter<? extends T> filter : this.orderedFilters) { | |
| filter.afterFiltersApplied(); | |
| } | |
| @@ -1050,8 +1094,8 @@ | |
| } | |
| else if (this.wantUnique) { | |
| total = 0; | |
| - Iterable<Entry<T, Integer>> items = Aggregates.uniqueByLast(this.pool, this.pool.FN_GET_NAME); | |
| - for (Entry<T, Integer> entry : items) { | |
| + final Iterable<Entry<T, Integer>> items = Aggregates.uniqueByLast(this.pool, this.pool.FN_GET_NAME); | |
| + for (final Entry<T, Integer> entry : items) { | |
| total += entry.getValue(); | |
| } | |
| } | |
| @@ -1062,9 +1106,9 @@ | |
| } | |
| /** | |
| - * | |
| + * | |
| * getPnlButtons. | |
| - * | |
| + * | |
| * @return panel to put any custom buttons on | |
| */ | |
| public JPanel getPnlButtons() { | |
| @@ -1072,9 +1116,9 @@ | |
| } | |
| /** | |
| - * | |
| + * | |
| * isIncrementalSearchActive. | |
| - * | |
| + * | |
| * @return true if an incremental search is currently active | |
| */ | |
| public boolean isIncrementalSearchActive() { | |
| @@ -1082,9 +1126,9 @@ | |
| } | |
| /** | |
| - * | |
| + * | |
| * getWantUnique. | |
| - * | |
| + * | |
| * @return true if the editor is in "unique item names only" mode. | |
| */ | |
| public boolean getWantUnique() { | |
| @@ -1092,19 +1136,19 @@ | |
| } | |
| /** | |
| - * | |
| + * | |
| * setWantUnique. | |
| - * | |
| + * | |
| * @param unique - if true, the editor will be set to the "unique item names only" mode. | |
| */ | |
| - public void setWantUnique(boolean unique) { | |
| + public void setWantUnique(final boolean unique) { | |
| this.wantUnique = this.alwaysNonUnique ? false : unique; | |
| } | |
| /** | |
| - * | |
| + * | |
| * getAlwaysNonUnique. | |
| - * | |
| + * | |
| * @return if true, this editor must always show non-unique items (e.g. quest editor). | |
| */ | |
| public boolean getAlwaysNonUnique() { | |
| @@ -1112,43 +1156,43 @@ | |
| } | |
| /** | |
| - * | |
| + * | |
| * setAlwaysNonUnique. | |
| - * | |
| + * | |
| * @param nonUniqueOnly - if true, this editor must always show non-unique items (e.g. quest editor). | |
| */ | |
| - public void setAlwaysNonUnique(boolean nonUniqueOnly) { | |
| + public void setAlwaysNonUnique(final boolean nonUniqueOnly) { | |
| this.alwaysNonUnique = nonUniqueOnly; | |
| } | |
| /** | |
| - * | |
| + * | |
| * getAllowMultipleSelections. | |
| - * | |
| + * | |
| * @return if true, multiple items can be selected at once | |
| */ | |
| public boolean getAllowMultipleSelections() { | |
| - return this.allowMultipleSelections; | |
| + return this.allowMultipleSelections; | |
| } | |
| /** | |
| - * | |
| + * | |
| * setAllowMultipleSelections. | |
| - * | |
| + * | |
| * @return allowMultipleSelections0 - if true, multiple items can be selected at once | |
| */ | |
| - public void setAllowMultipleSelections(boolean allowMultipleSelections0) { | |
| + public void setAllowMultipleSelections(final boolean allowMultipleSelections0) { | |
| - if (this.allowMultipleSelections == allowMultipleSelections0) { return; } | |
| - this.allowMultipleSelections = allowMultipleSelections0; | |
| + if (this.allowMultipleSelections == allowMultipleSelections0) { return; } | |
| + this.allowMultipleSelections = allowMultipleSelections0; | |
| - for (ItemView<T> view : views) { | |
| + for (final ItemView<T> view : views) { | |
| - view.setAllowMultipleSelections(allowMultipleSelections0); | |
| - } | |
| + view.setAllowMultipleSelections(allowMultipleSelections0); | |
| + } | |
| } | |
| /** | |
| - * | |
| + * | |
| * isInfinite. | |
| - * | |
| + * | |
| * @return whether item manager's pool of items is in infinite supply | |
| */ | |
| public boolean isInfinite() { | |
| @@ -1156,38 +1200,34 @@ | |
| } | |
| /** | |
| - * | |
| + * | |
| * focus. | |
| - * | |
| + * | |
| */ | |
| public void focus() { | |
| this.currentView.focus(); | |
| } | |
| /** | |
| - * | |
| + * | |
| * focusSearch. | |
| - * | |
| + * | |
| */ | |
| public void focusSearch() { | |
| this.setHideFilters(false); //ensure filters shown | |
| this.mainSearchFilter.getMainComponent().requestFocusInWindow(); | |
| } | |
| - public void addSelectionListener(ListSelectionListener listener) { | |
| + public void addSelectionListener(final ListSelectionListener listener) { | |
| - selectionListeners.remove(listener); //ensure listener not added multiple times | |
| - selectionListeners.add(listener); | |
| + selectionListeners.remove(listener); //ensure listener not added multiple times | |
| + selectionListeners.add(listener); | |
| } | |
| - public void removeSelectionListener(ListSelectionListener listener) { | |
| - selectionListeners.remove(listener); | |
| - } | |
| - | |
| public Iterable<ListSelectionListener> getSelectionListeners() { | |
| - return selectionListeners; | |
| + return selectionListeners; | |
| } | |
| - public void setItemActivateCommand(UiCommand itemActivateCommand0) { | |
| + public void setItemActivateCommand(final UiCommand itemActivateCommand0) { | |
| this.itemActivateCommand = itemActivateCommand0; | |
| } | |
| @@ -1197,21 +1237,21 @@ | |
| } | |
| } | |
| - public void setContextMenuBuilder(ContextMenuBuilder contextMenuBuilder0) { | |
| + public void setContextMenuBuilder(final ContextMenuBuilder contextMenuBuilder0) { | |
| this.contextMenuBuilder = contextMenuBuilder0; | |
| } | |
| - public void showContextMenu(MouseEvent e) { | |
| + public void showContextMenu(final MouseEvent e) { | |
| showContextMenu(e, null); | |
| } | |
| - public void showContextMenu(MouseEvent e, final Runnable onClose) { | |
| + public void showContextMenu(final MouseEvent e, final Runnable onClose) { | |
| //ensure the item manager has focus | |
| this.focus(); | |
| //if item under the cursor is not selected, select it | |
| - int index = this.currentView.getIndexAtPoint(e.getPoint()); | |
| + final int index = this.currentView.getIndexAtPoint(e.getPoint()); | |
| boolean needSelection = true; | |
| - for (Integer selectedIndex : this.getSelectedIndices()) { | |
| + for (final Integer selectedIndex : this.getSelectedIndices()) { | |
| if (selectedIndex == index) { | |
| needSelection = false; | |
| break; | |
| @@ -1228,23 +1268,23 @@ | |
| return; | |
| } | |
| - JPopupMenu menu = new JPopupMenu("ItemManagerContextMenu"); | |
| + final JPopupMenu menu = new JPopupMenu("ItemManagerContextMenu"); | |
| this.contextMenuBuilder.buildContextMenu(menu); | |
| if (onClose != null) { | |
| menu.addPopupMenuListener(new PopupMenuListener() { | |
| @Override | |
| - public void popupMenuCanceled(PopupMenuEvent arg0) { | |
| + public void popupMenuCanceled(final PopupMenuEvent arg0) { | |
| onClose.run(); | |
| } | |
| @Override | |
| - public void popupMenuWillBecomeInvisible(PopupMenuEvent arg0) { | |
| + public void popupMenuWillBecomeInvisible(final PopupMenuEvent arg0) { | |
| onClose.run(); | |
| } | |
| @Override | |
| - public void popupMenuWillBecomeVisible(PopupMenuEvent arg0) { | |
| + public void popupMenuWillBecomeVisible(final PopupMenuEvent arg0) { | |
| } | |
| }); | |
| } | |
| Index: forge-gui-desktop/src/main/java/forge/toolbox/FCheckBox.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/toolbox/FCheckBox.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/toolbox/FCheckBox.java (revision 29317) | |
| @@ -3,7 +3,7 @@ | |
| import forge.interfaces.ICheckBox; | |
| import forge.toolbox.FSkin.SkinnedCheckBox; | |
| -/** | |
| +/** | |
| * A custom instance of JCheckBox using Forge skin properties. | |
| */ | |
| @SuppressWarnings("serial") | |
| @@ -19,8 +19,8 @@ | |
| this.setOpaque(false); | |
| this.setFocusable(false); | |
| } | |
| - | |
| + | |
| - public FCheckBox(final String s0, boolean checked) { | |
| + public FCheckBox(final String s0, final boolean checked) { | |
| this(s0); | |
| setSelected(checked); | |
| } | |
| Index: forge-gui-desktop/src/main/java/forge/screens/home/online/VOnlineLobby.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/home/online/VOnlineLobby.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/home/online/VOnlineLobby.java (revision 29317) | |
| @@ -34,9 +34,6 @@ | |
| private VOnlineLobby() { | |
| } | |
| - VLobby getLobby() { | |
| - return lobby; | |
| - } | |
| VLobby setLobby(final GameLobby lobby) { | |
| this.lobby = new VLobby(lobby); | |
| getLayoutControl().setLobby(this.lobby); | |
| Index: forge-gui/src/main/java/forge/control/WatchLocalGame.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui/src/main/java/forge/control/WatchLocalGame.java (revision 29316) | |
| +++ forge-gui/src/main/java/forge/control/WatchLocalGame.java (revision 29317) | |
| @@ -1,5 +1,5 @@ | |
| /** | |
| - * | |
| + * | |
| */ | |
| package forge.control; | |
| @@ -27,6 +27,7 @@ | |
| public void updateAchievements() { | |
| } | |
| + @Override | |
| public boolean canUndoLastAction() { | |
| return false; | |
| } | |
| Index: forge-gui-desktop/src/main/java/forge/screens/home/quest/CSubmenuChallenges.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/home/quest/CSubmenuChallenges.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/home/quest/CSubmenuChallenges.java (revision 29317) | |
| @@ -1,8 +1,22 @@ | |
| package forge.screens.home.quest; | |
| -import forge.UiCommand; | |
| +import java.awt.Color; | |
| +import java.awt.event.ActionEvent; | |
| +import java.awt.event.ActionListener; | |
| +import java.awt.event.KeyAdapter; | |
| +import java.awt.event.KeyEvent; | |
| +import java.awt.event.MouseAdapter; | |
| +import java.awt.event.MouseEvent; | |
| +import java.util.ArrayList; | |
| +import java.util.List; | |
| + | |
| +import javax.swing.JRadioButton; | |
| +import javax.swing.SwingConstants; | |
| +import javax.swing.SwingUtilities; | |
| +import javax.swing.border.EmptyBorder; | |
| + | |
| import forge.Singletons; | |
| -import forge.gui.framework.EDocID; | |
| +import forge.UiCommand; | |
| import forge.gui.framework.ICDoc; | |
| import forge.model.FModel; | |
| import forge.quest.QuestController; | |
| @@ -10,21 +24,12 @@ | |
| import forge.quest.QuestUtil; | |
| import forge.quest.bazaar.QuestItemType; | |
| import forge.quest.bazaar.QuestPetController; | |
| -import forge.screens.home.CHomeUI; | |
| import forge.toolbox.FLabel; | |
| import forge.toolbox.JXButtonPanel; | |
| -import javax.swing.*; | |
| -import javax.swing.border.EmptyBorder; | |
| - | |
| -import java.awt.*; | |
| -import java.awt.event.*; | |
| -import java.util.ArrayList; | |
| -import java.util.List; | |
| - | |
| -/** | |
| +/** | |
| * Controls the quest challenges submenu in the home UI. | |
| - * | |
| + * | |
| * <br><br><i>(C at beginning of class name denotes a control class.)</i> | |
| * | |
| */ | |
| @@ -62,9 +67,9 @@ | |
| view.getBtnStart().addActionListener( | |
| new ActionListener() { @Override | |
| - public void actionPerformed(final ActionEvent e) { QuestUtil.startGame(); } }); | |
| + public void actionPerformed(final ActionEvent e) { QuestUtil.startGame(); } }); | |
| - ((FLabel) view.getLblZep()).setCommand( | |
| + view.getLblZep().setCommand( | |
| new UiCommand() { | |
| @Override | |
| public void run() { | |
| @@ -80,7 +85,7 @@ | |
| final QuestController quest = FModel.getQuest(); | |
| view.getCbPlant().addActionListener(new ActionListener() { | |
| @Override | |
| - public void actionPerformed(ActionEvent arg0) { | |
| + public void actionPerformed(final ActionEvent arg0) { | |
| quest.selectPet(0, view.getCbPlant().isSelected() ? "Plant" : null); | |
| quest.save(); | |
| } | |
| @@ -88,28 +93,28 @@ | |
| view.getCbxPet().addActionListener(new ActionListener() { | |
| @Override | |
| - public void actionPerformed(ActionEvent arg0) { | |
| + public void actionPerformed(final ActionEvent arg0) { | |
| final int slot = 1; | |
| final int index = view.getCbxPet().getSelectedIndex(); | |
| - List<QuestPetController> pets = quest.getPetsStorage().getAvaliablePets(slot, quest.getAssets()); | |
| - String petName = index <= 0 || index > pets.size() ? null : pets.get(index - 1).getName(); | |
| + final List<QuestPetController> pets = quest.getPetsStorage().getAvaliablePets(slot, quest.getAssets()); | |
| + final String petName = index <= 0 || index > pets.size() ? null : pets.get(index - 1).getName(); | |
| quest.selectPet(slot, petName); | |
| quest.save(); | |
| } | |
| }); | |
| view.getCbCharm().addActionListener(new ActionListener() { | |
| - @Override | |
| + @Override | |
| - public void actionPerformed(ActionEvent arg0) { | |
| + public void actionPerformed(final ActionEvent arg0) { | |
| - quest.setCharmState(view.getCbCharm().isSelected()); | |
| - quest.save(); | |
| - } | |
| + quest.setCharmState(view.getCbCharm().isSelected()); | |
| + quest.save(); | |
| + } | |
| }); | |
| } | |
| private final KeyAdapter _startOnEnter = new KeyAdapter() { | |
| @Override | |
| - public void keyPressed(KeyEvent e) { | |
| + public void keyPressed(final KeyEvent e) { | |
| if (KeyEvent.VK_ENTER == e.getKeyChar()) { | |
| VSubmenuChallenges.SINGLETON_INSTANCE.getBtnStart().doClick(); | |
| } | |
| @@ -117,7 +122,7 @@ | |
| }; | |
| private final MouseAdapter _startOnDblClick = new MouseAdapter() { | |
| @Override | |
| - public void mouseClicked(MouseEvent e) { | |
| + public void mouseClicked(final MouseEvent e) { | |
| if (MouseEvent.BUTTON1 == e.getButton() && 2 == e.getClickCount()) { | |
| VSubmenuChallenges.SINGLETON_INSTANCE.getBtnStart().doClick(); | |
| } | |
| @@ -134,21 +139,23 @@ | |
| final VSubmenuChallenges view = VSubmenuChallenges.SINGLETON_INSTANCE; | |
| final QuestController qCtrl = FModel.getQuest(); | |
| - if (qCtrl.getAchievements() == null) return; | |
| + if (qCtrl.getAchievements() == null) { | |
| + return; | |
| + } | |
| view.getLblTitle().setText("Challenges: " + qCtrl.getRank()); | |
| view.getPnlChallenges().removeAll(); | |
| qCtrl.regenerateChallenges(); | |
| final List<QuestEventChallenge> challenges = new ArrayList<QuestEventChallenge>(); | |
| - for(Object id : qCtrl.getAchievements().getCurrentChallenges()) { | |
| + for(final Object id : qCtrl.getAchievements().getCurrentChallenges()) { | |
| challenges.add(qCtrl.getChallenges().get(id.toString())); | |
| } | |
| - JXButtonPanel grpPanel = new JXButtonPanel(); | |
| + final JXButtonPanel grpPanel = new JXButtonPanel(); | |
| boolean haveAnyChallenges = true; | |
| - for (QuestEventChallenge qc : challenges) { | |
| + for (final QuestEventChallenge qc : challenges) { | |
| final PnlEvent temp = new PnlEvent(qc); | |
| final JRadioButton rad = temp.getRad(); | |
| if (haveAnyChallenges) { | |
| @@ -166,8 +173,8 @@ | |
| if (!haveAnyChallenges) { | |
| final FLabel lbl = new FLabel.Builder() | |
| - .text(VSubmenuChallenges.SINGLETON_INSTANCE.getLblNextChallengeInWins().getText()) | |
| - .fontAlign(SwingConstants.CENTER).build(); | |
| + .text(VSubmenuChallenges.SINGLETON_INSTANCE.getLblNextChallengeInWins().getText()) | |
| + .fontAlign(SwingConstants.CENTER).build(); | |
| lbl.setForeground(Color.red); | |
| lbl.setBackground(Color.white); | |
| lbl.setBorder(new EmptyBorder(10, 10, 10, 10)); | |
| @@ -182,20 +189,4 @@ | |
| } | |
| - /* (non-Javadoc) | |
| - * @see forge.gui.framework.ICDoc#getCommandOnSelect() | |
| - */ | |
| - @SuppressWarnings("serial") | |
| - @Override | |
| - public UiCommand getCommandOnSelect() { | |
| - final QuestController qc = FModel.getQuest(); | |
| - return new UiCommand() { | |
| - @Override | |
| - public void run() { | |
| - if (qc.getAchievements() == null) { | |
| - CHomeUI.SINGLETON_INSTANCE.itemClick(EDocID.HOME_QUESTDATA); | |
| - } | |
| - } | |
| - }; | |
| - } | |
| } | |
| Index: forge-gui/src/main/java/forge/player/PlayerControllerHuman.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui/src/main/java/forge/player/PlayerControllerHuman.java (revision 29316) | |
| +++ forge-gui/src/main/java/forge/player/PlayerControllerHuman.java (revision 29317) | |
| @@ -113,14 +113,14 @@ | |
| import forge.util.TextUtil; | |
| import forge.util.gui.SOptionPane; | |
| -/** | |
| +/** | |
| * A prototype for player controller class | |
| - * | |
| + * | |
| * Handles phase skips for now. | |
| */ | |
| public class PlayerControllerHuman | |
| - extends PlayerController | |
| - implements IGameController { | |
| +extends PlayerController | |
| +implements IGameController { | |
| /** | |
| * Cards this player may look at right now, for example when searching a | |
| * library. | |
| @@ -166,7 +166,7 @@ | |
| public boolean getDisableAutoYields() { | |
| return disableAutoYields; | |
| } | |
| - public void setDisableAutoYields(boolean disableAutoYields0) { | |
| + public void setDisableAutoYields(final boolean disableAutoYields0) { | |
| disableAutoYields = disableAutoYields0; | |
| } | |
| @@ -191,7 +191,7 @@ | |
| } | |
| private void tempShowCards(final Iterable<Card> cards) { | |
| if (mayLookAtAllCards) { return; } //no needed if this is set | |
| - | |
| + | |
| for (final Card c : cards) { | |
| tempShowCard(c); | |
| } | |
| @@ -218,40 +218,41 @@ | |
| /** | |
| * Uses GUI to learn which spell the player (human in our case) would like to play | |
| - */ | |
| + */ | |
| + @Override | |
| public SpellAbility getAbilityToPlay(final Card hostCard, final List<SpellAbility> abilities, final ITriggerEvent triggerEvent) { | |
| final SpellAbilityView resultView = getGui().getAbilityToPlay(CardView.get(hostCard), SpellAbilityView.getCollection(abilities), triggerEvent); | |
| return getGame().getSpellAbility(resultView); | |
| } | |
| @Override | |
| - public void playSpellAbilityForFree(SpellAbility copySA, boolean mayChoseNewTargets) { | |
| + public void playSpellAbilityForFree(final SpellAbility copySA, final boolean mayChoseNewTargets) { | |
| HumanPlay.playSaWithoutPayingManaCost(this, player.getGame(), copySA, mayChoseNewTargets); | |
| } | |
| @Override | |
| - public void playSpellAbilityNoStack(SpellAbility effectSA, boolean canSetupTargets) { | |
| + public void playSpellAbilityNoStack(final SpellAbility effectSA, final boolean canSetupTargets) { | |
| HumanPlay.playSpellAbilityNoStack(this, player, effectSA, !canSetupTargets); | |
| } | |
| @Override | |
| - public List<PaperCard> sideboard(Deck deck, GameType gameType) { | |
| + public List<PaperCard> sideboard(final Deck deck, final GameType gameType) { | |
| CardPool sideboard = deck.get(DeckSection.Sideboard); | |
| if (sideboard == null) { | |
| // Use an empty cardpool instead of null for 75/0 sideboarding scenario. | |
| sideboard = new CardPool(); | |
| } | |
| - CardPool main = deck.get(DeckSection.Main); | |
| + final CardPool main = deck.get(DeckSection.Main); | |
| - int mainSize = main.countAll(); | |
| - int sbSize = sideboard.countAll(); | |
| - int combinedDeckSize = mainSize + sbSize; | |
| + final int mainSize = main.countAll(); | |
| + final int sbSize = sideboard.countAll(); | |
| + final int combinedDeckSize = mainSize + sbSize; | |
| - int deckMinSize = Math.min(mainSize, gameType.getDeckFormat().getMainRange().getMinimum()); | |
| - Range<Integer> sbRange = gameType.getDeckFormat().getSideRange(); | |
| + final int deckMinSize = Math.min(mainSize, gameType.getDeckFormat().getMainRange().getMinimum()); | |
| + final Range<Integer> sbRange = gameType.getDeckFormat().getSideRange(); | |
| // Limited doesn't have a sideboard max, so let the Main min take care of things. | |
| - int sbMax = sbRange == null ? combinedDeckSize : sbRange.getMaximum(); | |
| + final int sbMax = sbRange == null ? combinedDeckSize : sbRange.getMaximum(); | |
| List<PaperCard> newMain = null; | |
| @@ -259,7 +260,7 @@ | |
| if (sbSize == 0 && mainSize == deckMinSize) { return null; } | |
| // conformance should not be checked here | |
| - boolean conform = FModel.getPreferences().getPrefBoolean(FPref.ENFORCE_DECK_LEGALITY); | |
| + final boolean conform = FModel.getPreferences().getPrefBoolean(FPref.ENFORCE_DECK_LEGALITY); | |
| do { | |
| if (newMain != null) { | |
| String errMsg; | |
| @@ -313,35 +314,35 @@ | |
| } | |
| @Override | |
| - public Integer announceRequirements(SpellAbility ability, String announce, boolean canChooseZero) { | |
| - int min = canChooseZero ? 0 : 1; | |
| + public Integer announceRequirements(final SpellAbility ability, final String announce, final boolean canChooseZero) { | |
| + final int min = canChooseZero ? 0 : 1; | |
| return getGui().getInteger("Choose " + announce + " for " + ability.getHostCard().getName(), | |
| min, Integer.MAX_VALUE, min + 9); | |
| } | |
| @Override | |
| - public CardCollectionView choosePermanentsToSacrifice(SpellAbility sa, int min, int max, CardCollectionView valid, String message) { | |
| + public CardCollectionView choosePermanentsToSacrifice(final SpellAbility sa, final int min, final int max, final CardCollectionView valid, final String message) { | |
| return choosePermanentsTo(min, max, valid, message, "sacrifice"); | |
| } | |
| @Override | |
| - public CardCollectionView choosePermanentsToDestroy(SpellAbility sa, int min, int max, CardCollectionView valid, String message) { | |
| + public CardCollectionView choosePermanentsToDestroy(final SpellAbility sa, final int min, final int max, final CardCollectionView valid, final String message) { | |
| return choosePermanentsTo(min, max, valid, message, "destroy"); | |
| } | |
| - private CardCollectionView choosePermanentsTo(int min, int max, CardCollectionView valid, String message, String action) { | |
| + private CardCollectionView choosePermanentsTo(final int min, int max, final CardCollectionView valid, final String message, final String action) { | |
| max = Math.min(max, valid.size()); | |
| if (max <= 0) { | |
| return CardCollection.EMPTY; | |
| } | |
| - StringBuilder builder = new StringBuilder("Select "); | |
| + final StringBuilder builder = new StringBuilder("Select "); | |
| if (min == 0) { | |
| builder.append("up to "); | |
| } | |
| builder.append("%d " + message + "(s) to " + action + "."); | |
| - InputSelectCardsFromList inp = new InputSelectCardsFromList(this, min, max, valid); | |
| + final InputSelectCardsFromList inp = new InputSelectCardsFromList(this, min, max, valid); | |
| inp.setMessage(builder.toString()); | |
| inp.setCancelAllowed(min == 0); | |
| inp.showAndWait(); | |
| @@ -349,21 +350,21 @@ | |
| } | |
| @Override | |
| - public CardCollectionView chooseCardsForEffect(CardCollectionView sourceList, SpellAbility sa, String title, int min, int max, boolean isOptional) { | |
| + public CardCollectionView chooseCardsForEffect(final CardCollectionView sourceList, final SpellAbility sa, final String title, final int min, final int max, final boolean isOptional) { | |
| // If only one card to choose, use a dialog box. | |
| // Otherwise, use the order dialog to be able to grab multiple cards in one shot | |
| if (max == 1) { | |
| - Card singleChosen = chooseSingleEntityForEffect(sourceList, sa, title, isOptional); | |
| + final Card singleChosen = chooseSingleEntityForEffect(sourceList, sa, title, isOptional); | |
| return singleChosen == null ? CardCollection.EMPTY : new CardCollection(singleChosen); | |
| } | |
| getGui().setPanelSelection(CardView.get(sa.getHostCard())); | |
| - // try to use InputSelectCardsFromList when possible | |
| + // try to use InputSelectCardsFromList when possible | |
| boolean cardsAreInMyHandOrBattlefield = true; | |
| - for (Card c : sourceList) { | |
| - Zone z = c.getZone(); | |
| + for (final Card c : sourceList) { | |
| + final Zone z = c.getZone(); | |
| if (z != null && (z.is(ZoneType.Battlefield) || z.is(ZoneType.Hand, player))) { | |
| continue; | |
| } | |
| @@ -372,7 +373,7 @@ | |
| } | |
| if (cardsAreInMyHandOrBattlefield) { | |
| - InputSelectCardsFromList sc = new InputSelectCardsFromList(this, min, max, sourceList); | |
| + final InputSelectCardsFromList sc = new InputSelectCardsFromList(this, min, max, sourceList); | |
| sc.setMessage(title); | |
| sc.setCancelAllowed(isOptional); | |
| sc.showAndWait(); | |
| @@ -388,7 +389,7 @@ | |
| @SuppressWarnings("unchecked") | |
| @Override | |
| - public <T extends GameEntity> T chooseSingleEntityForEffect(FCollectionView<T> optionList, DelayedReveal delayedReveal, SpellAbility sa, String title, boolean isOptional, Player targetedPlayer) { | |
| + public <T extends GameEntity> T chooseSingleEntityForEffect(final FCollectionView<T> optionList, final DelayedReveal delayedReveal, final SpellAbility sa, final String title, final boolean isOptional, final Player targetedPlayer) { | |
| // Human is supposed to read the message and understand from it what to choose | |
| if (optionList.isEmpty()) { | |
| if (delayedReveal != null) { | |
| @@ -404,13 +405,13 @@ | |
| } | |
| boolean canUseSelectCardsInput = true; | |
| - for (GameEntity c : optionList) { | |
| + for (final GameEntity c : optionList) { | |
| if (c instanceof Player) { | |
| continue; | |
| } | |
| - Zone cz = ((Card)c).getZone(); | |
| + final Zone cz = ((Card)c).getZone(); | |
| // can point at cards in own hand and anyone's battlefield | |
| - boolean canUiPointAtCards = cz != null && (cz.is(ZoneType.Hand) && cz.getPlayer() == player || cz.is(ZoneType.Battlefield)); | |
| + final boolean canUiPointAtCards = cz != null && (cz.is(ZoneType.Hand) && cz.getPlayer() == player || cz.is(ZoneType.Battlefield)); | |
| if (!canUiPointAtCards) { | |
| canUseSelectCardsInput = false; | |
| break; | |
| @@ -421,7 +422,7 @@ | |
| if (delayedReveal != null) { | |
| reveal(delayedReveal.getCards(), delayedReveal.getZone(), delayedReveal.getOwner(), delayedReveal.getMessagePrefix()); | |
| } | |
| - InputSelectEntitiesFromList<T> input = new InputSelectEntitiesFromList<T>(this, isOptional ? 0 : 1, 1, optionList); | |
| + final InputSelectEntitiesFromList<T> input = new InputSelectEntitiesFromList<T>(this, isOptional ? 0 : 1, 1, optionList); | |
| input.setCancelAllowed(isOptional); | |
| input.setMessage(MessageUtil.formatMessage(title, player, targetedPlayer)); | |
| input.showAndWait(); | |
| @@ -442,7 +443,7 @@ | |
| } | |
| @Override | |
| - public int chooseNumber(SpellAbility sa, String title, int min, int max) { | |
| + public int chooseNumber(final SpellAbility sa, final String title, final int min, final int max) { | |
| if (min >= max) { | |
| return min; | |
| } | |
| @@ -454,12 +455,12 @@ | |
| } | |
| @Override | |
| - public int chooseNumber(SpellAbility sa, String title, List<Integer> choices, Player relatedPlayer) { | |
| + public int chooseNumber(final SpellAbility sa, final String title, final List<Integer> choices, final Player relatedPlayer) { | |
| return getGui().one(title, choices).intValue(); | |
| } | |
| @Override | |
| - public SpellAbility chooseSingleSpellForEffect(java.util.List<SpellAbility> spells, SpellAbility sa, String title) { | |
| + public SpellAbility chooseSingleSpellForEffect(final java.util.List<SpellAbility> spells, final SpellAbility sa, final String title) { | |
| if (spells.size() < 2) { | |
| return spells.get(0); | |
| } | |
| @@ -472,23 +473,23 @@ | |
| * @see forge.game.player.PlayerController#confirmAction(forge.card.spellability.SpellAbility, java.lang.String, java.lang.String) | |
| */ | |
| @Override | |
| - public boolean confirmAction(SpellAbility sa, PlayerActionConfirmMode mode, String message) { | |
| + public boolean confirmAction(final SpellAbility sa, final PlayerActionConfirmMode mode, final String message) { | |
| return getGui().confirm(CardView.get(sa.getHostCard()), message); | |
| } | |
| @Override | |
| - public boolean confirmBidAction(SpellAbility sa, PlayerActionConfirmMode bidlife, | |
| - String string, int bid, Player winner) { | |
| + public boolean confirmBidAction(final SpellAbility sa, final PlayerActionConfirmMode bidlife, | |
| + final String string, final int bid, final Player winner) { | |
| return getGui().confirm(CardView.get(sa.getHostCard()), string + " Highest Bidder " + winner); | |
| } | |
| @Override | |
| - public boolean confirmStaticApplication(Card hostCard, GameEntity affected, String logic, String message) { | |
| + public boolean confirmStaticApplication(final Card hostCard, final GameEntity affected, final String logic, final String message) { | |
| return getGui().confirm(CardView.get(hostCard), message); | |
| } | |
| @Override | |
| - public boolean confirmTrigger(SpellAbility sa, Trigger regtrig, Map<String, String> triggerParams, boolean isMandatory) { | |
| + public boolean confirmTrigger(final SpellAbility sa, final Trigger regtrig, final Map<String, String> triggerParams, final boolean isMandatory) { | |
| if (getGui().shouldAlwaysAcceptTrigger(regtrig.getId())) { | |
| return true; | |
| } | |
| @@ -498,9 +499,9 @@ | |
| // triggers with costs can always be declined by not paying the cost | |
| if (sa.hasParam("Cost") && !sa.getParam("Cost").equals("0")) { | |
| - return true; | |
| + return true; | |
| } | |
| - | |
| + | |
| final StringBuilder buildQuestion = new StringBuilder("Use triggered ability of "); | |
| buildQuestion.append(regtrig.getHostCard().toString()).append("?"); | |
| if (!FModel.getPreferences().getPrefBoolean(FPref.UI_COMPACT_PROMPT)) { | |
| @@ -509,34 +510,34 @@ | |
| buildQuestion.append(triggerParams.get("TriggerDescription").replace("CARDNAME", regtrig.getHostCard().getName())); | |
| buildQuestion.append(")"); | |
| } | |
| - HashMap<String, Object> tos = sa.getTriggeringObjects(); | |
| + final Map<String, Object> tos = sa.getTriggeringObjects(); | |
| if (tos.containsKey("Attacker")) { | |
| buildQuestion.append("\nAttacker: " + tos.get("Attacker")); | |
| } | |
| if (tos.containsKey("Card")) { | |
| - Card card = (Card) tos.get("Card"); | |
| + final Card card = (Card) tos.get("Card"); | |
| if (card != null && (card.getController() == player || game.getZoneOf(card) == null | |
| || game.getZoneOf(card).getZoneType().isKnown())) { | |
| buildQuestion.append("\nTriggered by: " + tos.get("Card")); | |
| } | |
| } | |
| - InputConfirm inp = new InputConfirm(this, buildQuestion.toString()); | |
| + final InputConfirm inp = new InputConfirm(this, buildQuestion.toString()); | |
| inp.showAndWait(); | |
| return inp.getResult(); | |
| } | |
| @Override | |
| - public Player chooseStartingPlayer(boolean isFirstGame) { | |
| + public Player chooseStartingPlayer(final boolean isFirstGame) { | |
| if (game.getPlayers().size() == 2) { | |
| - final String prompt = String.format("%s, you %s\n\nWould you like to play or draw?", | |
| + final String prompt = String.format("%s, you %s\n\nWould you like to play or draw?", | |
| player.getName(), isFirstGame ? " have won the coin toss." : " lost the last game."); | |
| final InputConfirm inp = new InputConfirm(this, prompt, "Play", "Draw"); | |
| inp.showAndWait(); | |
| return inp.getResult() ? this.player : this.player.getOpponents().get(0); | |
| } | |
| else { | |
| - final String prompt = String.format("%s, you %s\n\nWho would you like to start this game? (Click on the portrait.)", | |
| + final String prompt = String.format("%s, you %s\n\nWho would you like to start this game? (Click on the portrait.)", | |
| player.getName(), isFirstGame ? " have won the coin toss." : " lost the last game."); | |
| final InputSelectEntitiesFromList<Player> input = new InputSelectEntitiesFromList<Player>(this, 1, 1, new FCollection<Player>(game.getPlayersInTurnOrder())); | |
| input.setMessage(prompt); | |
| @@ -567,18 +568,18 @@ | |
| } | |
| @Override | |
| - public void reveal(CardCollectionView cards, ZoneType zone, Player owner, String message) { | |
| + public void reveal(final CardCollectionView cards, final ZoneType zone, final Player owner, final String message) { | |
| reveal(CardView.getCollection(cards), zone, PlayerView.get(owner), message); | |
| } | |
| @Override | |
| - public void reveal(Collection<CardView> cards, ZoneType zone, PlayerView owner, String message) { | |
| + public void reveal(final Collection<CardView> cards, final ZoneType zone, final PlayerView owner, String message) { | |
| if (StringUtils.isBlank(message)) { | |
| message = "Looking at cards in {player's} " + zone.name().toLowerCase(); | |
| } else { | |
| message += "{player's} " + zone.name().toLowerCase(); | |
| } | |
| - String fm = MessageUtil.formatMessage(message, getLocalPlayerView(), owner); | |
| + final String fm = MessageUtil.formatMessage(message, getLocalPlayerView(), owner); | |
| if (!cards.isEmpty()) { | |
| tempShowCards(game.getCardList(cards)); | |
| getGui().reveal(fm, cards); | |
| @@ -590,7 +591,7 @@ | |
| } | |
| @Override | |
| - public ImmutablePair<CardCollection, CardCollection> arrangeForScry(CardCollection topN) { | |
| + public ImmutablePair<CardCollection, CardCollection> arrangeForScry(final CardCollection topN) { | |
| CardCollection toBottom = null; | |
| CardCollection toTop = null; | |
| @@ -627,44 +628,44 @@ | |
| tempShowCard(c); | |
| final boolean result = getGui().confirm(view, "Put " + view + " on the top or bottom of your library?", new String[]{"Top", "Bottom"}); | |
| endTempShowCards(); | |
| - | |
| + | |
| return result; | |
| } | |
| @Override | |
| - public CardCollectionView orderMoveToZoneList(CardCollectionView cards, ZoneType destinationZone) { | |
| + public CardCollectionView orderMoveToZoneList(final CardCollectionView cards, final ZoneType destinationZone) { | |
| List<CardView> choices; | |
| tempShowCards(cards); | |
| switch (destinationZone) { | |
| - case Library: | |
| - choices = getGui().order("Choose order of cards to put into the library", "Closest to top", CardView.getCollection(cards), null); | |
| - break; | |
| - case Battlefield: | |
| - choices = getGui().order("Choose order of cards to put onto the battlefield", "Put first", CardView.getCollection(cards), null); | |
| - break; | |
| - case Graveyard: | |
| - choices = getGui().order("Choose order of cards to put into the graveyard", "Closest to bottom", CardView.getCollection(cards), null); | |
| - break; | |
| - case PlanarDeck: | |
| - choices = getGui().order("Choose order of cards to put into the planar deck", "Closest to top", CardView.getCollection(cards), null); | |
| - break; | |
| - case SchemeDeck: | |
| - choices = getGui().order("Choose order of cards to put into the scheme deck", "Closest to top", CardView.getCollection(cards), null); | |
| - break; | |
| - case Stack: | |
| - choices = getGui().order("Choose order of copies to cast", "Put first", CardView.getCollection(cards), null); | |
| - break; | |
| - default: | |
| - System.out.println("ZoneType " + destinationZone + " - Not Ordered"); | |
| - endTempShowCards(); | |
| - return cards; | |
| + case Library: | |
| + choices = getGui().order("Choose order of cards to put into the library", "Closest to top", CardView.getCollection(cards), null); | |
| + break; | |
| + case Battlefield: | |
| + choices = getGui().order("Choose order of cards to put onto the battlefield", "Put first", CardView.getCollection(cards), null); | |
| + break; | |
| + case Graveyard: | |
| + choices = getGui().order("Choose order of cards to put into the graveyard", "Closest to bottom", CardView.getCollection(cards), null); | |
| + break; | |
| + case PlanarDeck: | |
| + choices = getGui().order("Choose order of cards to put into the planar deck", "Closest to top", CardView.getCollection(cards), null); | |
| + break; | |
| + case SchemeDeck: | |
| + choices = getGui().order("Choose order of cards to put into the scheme deck", "Closest to top", CardView.getCollection(cards), null); | |
| + break; | |
| + case Stack: | |
| + choices = getGui().order("Choose order of copies to cast", "Put first", CardView.getCollection(cards), null); | |
| + break; | |
| + default: | |
| + System.out.println("ZoneType " + destinationZone + " - Not Ordered"); | |
| + endTempShowCards(); | |
| + return cards; | |
| } | |
| endTempShowCards(); | |
| return game.getCardList(choices); | |
| } | |
| @Override | |
| - public CardCollectionView chooseCardsToDiscardFrom(Player p, SpellAbility sa, CardCollection valid, int min, int max) { | |
| + public CardCollectionView chooseCardsToDiscardFrom(final Player p, final SpellAbility sa, final CardCollection valid, final int min, final int max) { | |
| if (p != player) { | |
| tempShowCards(valid); | |
| final CardCollection choices = game.getCardList(getGui().many("Choose " + min + " card" + (min != 1 ? "s" : "") + " to discard", | |
| @@ -673,7 +674,7 @@ | |
| return choices; | |
| } | |
| - InputSelectCardsFromList inp = new InputSelectCardsFromList(this, min, max, valid); | |
| + final InputSelectCardsFromList inp = new InputSelectCardsFromList(this, min, max, valid); | |
| inp.setMessage(sa.hasParam("AnyNumber") ? "Discard up to %d card(s)" : "Discard %d card(s)"); | |
| inp.showAndWait(); | |
| return new CardCollection(inp.getSelected()); | |
| @@ -709,7 +710,7 @@ | |
| break; | |
| } | |
| - Card card = game.getCard(nowChosen); | |
| + final Card card = game.getCard(nowChosen); | |
| grave.remove(card); | |
| toExile.add(card); | |
| } | |
| @@ -720,13 +721,13 @@ | |
| * @see forge.game.player.PlayerController#chooseTargets(forge.card.spellability.SpellAbility, forge.card.spellability.SpellAbilityStackInstance) | |
| */ | |
| @Override | |
| - public TargetChoices chooseNewTargetsFor(SpellAbility ability) { | |
| - SpellAbility sa = ability.isWrapper() ? ((WrappedAbility) ability).getWrappedAbility() : ability; | |
| + public TargetChoices chooseNewTargetsFor(final SpellAbility ability) { | |
| + final SpellAbility sa = ability.isWrapper() ? ((WrappedAbility) ability).getWrappedAbility() : ability; | |
| if (sa.getTargetRestrictions() == null) { | |
| return null; | |
| } | |
| - TargetChoices oldTarget = sa.getTargets(); | |
| - TargetSelection select = new TargetSelection(this, sa); | |
| + final TargetChoices oldTarget = sa.getTargets(); | |
| + final TargetSelection select = new TargetSelection(this, sa); | |
| sa.resetTargets(); | |
| if (select.chooseTargets(oldTarget.getNumTargeted())) { | |
| return sa.getTargets(); | |
| @@ -741,13 +742,13 @@ | |
| * @see forge.game.player.PlayerController#chooseCardsToDiscardUnlessType(int, java.lang.String, forge.card.spellability.SpellAbility) | |
| */ | |
| @Override | |
| - public CardCollectionView chooseCardsToDiscardUnlessType(int num, CardCollectionView hand, final String uType, SpellAbility sa) { | |
| + public CardCollectionView chooseCardsToDiscardUnlessType(final int num, final CardCollectionView hand, final String uType, final SpellAbility sa) { | |
| final InputSelectEntitiesFromList<Card> target = new InputSelectEntitiesFromList<Card>(this, num, num, hand) { | |
| private static final long serialVersionUID = -5774108410928795591L; | |
| @Override | |
| protected boolean hasAllTargets() { | |
| - for (Card c : selected) { | |
| + for (final Card c : selected) { | |
| if (c.getType().hasStringType(uType)) { | |
| return true; | |
| } | |
| @@ -764,14 +765,14 @@ | |
| * @see forge.game.player.PlayerController#chooseManaFromPool(java.util.List) | |
| */ | |
| @Override | |
| - public Mana chooseManaFromPool(List<Mana> manaChoices) { | |
| - List<String> options = new ArrayList<String>(); | |
| + public Mana chooseManaFromPool(final List<Mana> manaChoices) { | |
| + final List<String> options = new ArrayList<String>(); | |
| for (int i = 0; i < manaChoices.size(); i++) { | |
| - Mana m = manaChoices.get(i); | |
| + final Mana m = manaChoices.get(i); | |
| options.add(String.format("%d. %s mana from %s", 1+i, MagicColor.toLongString(m.getColor()), m.getSourceCard())); | |
| } | |
| - String chosen = getGui().one("Pay Mana from Mana Pool", options); | |
| - String idx = TextUtil.split(chosen, '.')[0]; | |
| + final String chosen = getGui().one("Pay Mana from Mana Pool", options); | |
| + final String idx = TextUtil.split(chosen, '.')[0]; | |
| return manaChoices.get(Integer.parseInt(idx)-1); | |
| } | |
| @@ -779,7 +780,7 @@ | |
| * @see forge.game.player.PlayerController#chooseSomeType(java.lang.String, java.lang.String, java.util.List, java.util.List, java.lang.String) | |
| */ | |
| @Override | |
| - public String chooseSomeType(final String kindOfType, final SpellAbility sa, final List<String> validTypes, List<String> invalidTypes, final boolean isOptional) { | |
| + public String chooseSomeType(final String kindOfType, final SpellAbility sa, final List<String> validTypes, final List<String> invalidTypes, final boolean isOptional) { | |
| final List<String> types = Lists.newArrayList(validTypes); | |
| if (invalidTypes != null && !invalidTypes.isEmpty()) { | |
| Iterables.removeAll(types, invalidTypes); | |
| @@ -791,7 +792,7 @@ | |
| } | |
| @Override | |
| - public Object vote(SpellAbility sa, String prompt, List<Object> options, ArrayListMultimap<Object, Player> votes) { | |
| + public Object vote(final SpellAbility sa, final String prompt, final List<Object> options, final ArrayListMultimap<Object, Player> votes) { | |
| return getGui().one(prompt, options); | |
| } | |
| @@ -799,12 +800,12 @@ | |
| * @see forge.game.player.PlayerController#confirmReplacementEffect(forge.card.replacement.ReplacementEffect, forge.card.spellability.SpellAbility, java.lang.String) | |
| */ | |
| @Override | |
| - public boolean confirmReplacementEffect(ReplacementEffect replacementEffect, SpellAbility effectSA, String question) { | |
| + public boolean confirmReplacementEffect(final ReplacementEffect replacementEffect, final SpellAbility effectSA, final String question) { | |
| return getGui().confirm(CardView.get(replacementEffect.getHostCard()), question); | |
| } | |
| @Override | |
| - public CardCollectionView getCardsToMulligan(boolean isCommander, Player firstPlayer) { | |
| + public CardCollectionView getCardsToMulligan(final boolean isCommander, final Player firstPlayer) { | |
| final InputConfirmMulligan inp = new InputConfirmMulligan(this, player, firstPlayer, isCommander); | |
| inp.showAndWait(); | |
| return inp.isKeepHand() ? null : isCommander ? inp.getSelectedCards() : player.getCardsIn(ZoneType.Hand); | |
| @@ -826,7 +827,7 @@ | |
| } | |
| @Override | |
| - public void declareBlockers(Player defender, Combat combat) { | |
| + public void declareBlockers(final Player defender, final Combat combat) { | |
| // This input should not modify combat object itself, but should return user choice | |
| final InputBlock inpBlock = new InputBlock(this, defender, combat); | |
| inpBlock.showAndWait(); | |
| @@ -856,7 +857,7 @@ | |
| try { | |
| Thread.sleep(delay); | |
| } | |
| - catch (InterruptedException e) { | |
| + catch (final InterruptedException e) { | |
| e.printStackTrace(); | |
| } | |
| } | |
| @@ -874,7 +875,7 @@ | |
| try { | |
| Thread.sleep(FControlGamePlayback.resolveDelay); | |
| } | |
| - catch (InterruptedException e) { | |
| + catch (final InterruptedException e) { | |
| e.printStackTrace(); | |
| } | |
| return null; | |
| @@ -887,16 +888,16 @@ | |
| } | |
| @Override | |
| - public void playChosenSpellAbility(SpellAbility chosenSa) { | |
| + public void playChosenSpellAbility(final SpellAbility chosenSa) { | |
| HumanPlay.playSpellAbility(this, player, chosenSa); | |
| } | |
| @Override | |
| - public CardCollection chooseCardsToDiscardToMaximumHandSize(int nDiscard) { | |
| + public CardCollection chooseCardsToDiscardToMaximumHandSize(final int nDiscard) { | |
| final int max = player.getMaxHandSize(); | |
| - InputSelectCardsFromList inp = new InputSelectCardsFromList(this, nDiscard, nDiscard, player.getZone(ZoneType.Hand).getCards()); | |
| - String message = "Cleanup Phase\nSelect " + nDiscard + " card" + (nDiscard > 1 ? "s" : "") + | |
| + final InputSelectCardsFromList inp = new InputSelectCardsFromList(this, nDiscard, nDiscard, player.getZone(ZoneType.Hand).getCards()); | |
| + final String message = "Cleanup Phase\nSelect " + nDiscard + " card" + (nDiscard > 1 ? "s" : "") + | |
| " to discard to bring your hand down to the maximum of " + max + " cards."; | |
| inp.setMessage(message); | |
| inp.setCancelAllowed(false); | |
| @@ -905,18 +906,18 @@ | |
| } | |
| @Override | |
| - public CardCollectionView chooseCardsToRevealFromHand(int min, int max, CardCollectionView valid) { | |
| + public CardCollectionView chooseCardsToRevealFromHand(int min, int max, final CardCollectionView valid) { | |
| max = Math.min(max, valid.size()); | |
| min = Math.min(min, max); | |
| - InputSelectCardsFromList inp = new InputSelectCardsFromList(this, min, max, valid); | |
| + final InputSelectCardsFromList inp = new InputSelectCardsFromList(this, min, max, valid); | |
| inp.setMessage("Choose Which Cards to Reveal"); | |
| inp.showAndWait(); | |
| return new CardCollection(inp.getSelected()); | |
| } | |
| @Override | |
| - public boolean payManaOptional(Card c, Cost cost, SpellAbility sa, String prompt, ManaPaymentPurpose purpose) { | |
| + public boolean payManaOptional(final Card c, final Cost cost, final SpellAbility sa, final String prompt, final ManaPaymentPurpose purpose) { | |
| - if (sa == null && cost.isOnlyManaCost() && cost.getTotalMana().isZero() | |
| + if (sa == null && cost.isOnlyManaCost() && cost.getTotalMana().isZero() | |
| && !FModel.getPreferences().getPrefBoolean(FPref.MATCHPREF_PROMPT_FREE_BLOCKS)) { | |
| return true; | |
| } | |
| @@ -924,19 +925,19 @@ | |
| } | |
| @Override | |
| - public List<SpellAbility> chooseSaToActivateFromOpeningHand(List<SpellAbility> usableFromOpeningHand) { | |
| - CardCollection srcCards = new CardCollection(); | |
| - for (SpellAbility sa : usableFromOpeningHand) { | |
| + public List<SpellAbility> chooseSaToActivateFromOpeningHand(final List<SpellAbility> usableFromOpeningHand) { | |
| + final CardCollection srcCards = new CardCollection(); | |
| + for (final SpellAbility sa : usableFromOpeningHand) { | |
| srcCards.add(sa.getHostCard()); | |
| } | |
| - List<SpellAbility> result = new ArrayList<SpellAbility>(); | |
| + final List<SpellAbility> result = new ArrayList<SpellAbility>(); | |
| if (srcCards.isEmpty()) { | |
| return result; | |
| } | |
| final List<CardView> chosen = getGui().many("Choose cards to activate from opening hand and their order", "Activate first", -1, CardView.getCollection(srcCards), null); | |
| for (final CardView view : chosen) { | |
| final Card c = game.getCard(view); | |
| - for (SpellAbility sa : usableFromOpeningHand) { | |
| + for (final SpellAbility sa : usableFromOpeningHand) { | |
| if (sa.getHostCard() == c) { | |
| result.add(sa); | |
| break; | |
| @@ -947,24 +948,24 @@ | |
| } | |
| @Override | |
| - public boolean chooseBinary(SpellAbility sa, String question, BinaryChoiceType kindOfChoice, Boolean defaultVal) { | |
| - String[] labels = new String[]{"Option1", "Option2"}; | |
| + public boolean chooseBinary(final SpellAbility sa, final String question, final BinaryChoiceType kindOfChoice, final Boolean defaultVal) { | |
| + final String[] labels; | |
| switch (kindOfChoice) { | |
| - case HeadsOrTails: labels = new String[]{"Heads", "Tails"}; break; | |
| + case HeadsOrTails: labels = new String[]{"Heads", "Tails"}; break; | |
| - case TapOrUntap: labels = new String[]{"Tap", "Untap"}; break; | |
| + case TapOrUntap: labels = new String[]{"Tap", "Untap"}; break; | |
| - case OddsOrEvens: labels = new String[]{"Odds", "Evens"}; break; | |
| + case OddsOrEvens: labels = new String[]{"Odds", "Evens"}; break; | |
| - case UntapOrLeaveTapped: labels = new String[]{"Untap", "Leave tapped"}; break; | |
| + case UntapOrLeaveTapped: labels = new String[]{"Untap", "Leave tapped"}; break; | |
| - case UntapTimeVault: labels = new String[]{"Untap (and skip this turn)", "Leave tapped"}; break; | |
| + case UntapTimeVault: labels = new String[]{"Untap (and skip this turn)", "Leave tapped"}; break; | |
| - case PlayOrDraw: labels = new String[]{"Play", "Draw"}; break; | |
| + case PlayOrDraw: labels = new String[]{"Play", "Draw"}; break; | |
| - default: labels = kindOfChoice.toString().split("Or"); | |
| + default: labels = kindOfChoice.toString().split("Or"); | |
| } | |
| return getGui().confirm(CardView.get(sa.getHostCard()), question, defaultVal == null || defaultVal.booleanValue(), labels); | |
| } | |
| @Override | |
| - public boolean chooseFlipResult(SpellAbility sa, Player flipper, boolean[] results, boolean call) { | |
| - String[] labelsSrc = call ? new String[]{"heads", "tails"} : new String[]{"win the flip", "lose the flip"}; | |
| - String[] strResults = new String[results.length]; | |
| + public boolean chooseFlipResult(final SpellAbility sa, final Player flipper, final boolean[] results, final boolean call) { | |
| + final String[] labelsSrc = call ? new String[]{"heads", "tails"} : new String[]{"win the flip", "lose the flip"}; | |
| + final String[] strResults = new String[results.length]; | |
| for (int i = 0; i < results.length; i++) { | |
| strResults[i] = labelsSrc[results[i] ? 0 : 1]; | |
| } | |
| @@ -972,22 +973,22 @@ | |
| } | |
| @Override | |
| - public Card chooseProtectionShield(GameEntity entityBeingDamaged, List<String> options, Map<String, Card> choiceMap) { | |
| - String title = entityBeingDamaged + " - select which prevention shield to use"; | |
| + public Card chooseProtectionShield(final GameEntity entityBeingDamaged, final List<String> options, final Map<String, Card> choiceMap) { | |
| + final String title = entityBeingDamaged + " - select which prevention shield to use"; | |
| return choiceMap.get(getGui().one(title, options)); | |
| } | |
| @Override | |
| - public Pair<CounterType,String> chooseAndRemoveOrPutCounter(Card cardWithCounter) { | |
| + public Pair<CounterType,String> chooseAndRemoveOrPutCounter(final Card cardWithCounter) { | |
| if (!cardWithCounter.hasCounters()) { | |
| System.out.println("chooseCounterType was reached with a card with no counters on it. Consider filtering this card out earlier"); | |
| return null; | |
| } | |
| - String counterChoiceTitle = "Choose a counter type on " + cardWithCounter; | |
| + final String counterChoiceTitle = "Choose a counter type on " + cardWithCounter; | |
| final CounterType chosen = getGui().one(counterChoiceTitle, cardWithCounter.getCounters().keySet()); | |
| - String putOrRemoveTitle = "What to do with that '" + chosen.getName() + "' counter "; | |
| + final String putOrRemoveTitle = "What to do with that '" + chosen.getName() + "' counter "; | |
| final String putString = "Put another " + chosen.getName() + " counter on " + cardWithCounter; | |
| final String removeString = "Remove a " + chosen.getName() + " counter from " + cardWithCounter; | |
| final String addOrRemove = getGui().one(putOrRemoveTitle, new String[]{putString,removeString}); | |
| @@ -996,7 +997,7 @@ | |
| } | |
| @Override | |
| - public Pair<SpellAbilityStackInstance, GameObject> chooseTarget(SpellAbility saSpellskite, List<Pair<SpellAbilityStackInstance, GameObject>> allTargets) { | |
| + public Pair<SpellAbilityStackInstance, GameObject> chooseTarget(final SpellAbility saSpellskite, final List<Pair<SpellAbilityStackInstance, GameObject>> allTargets) { | |
| if (allTargets.size() < 2) { | |
| return Iterables.getFirst(allTargets, null); | |
| } | |
| @@ -1014,8 +1015,8 @@ | |
| } | |
| @Override | |
| - public void notifyOfValue(SpellAbility sa, GameObject realtedTarget, String value) { | |
| - String message = MessageUtil.formatNotificationMessage(sa, player, realtedTarget, value); | |
| + public void notifyOfValue(final SpellAbility sa, final GameObject realtedTarget, final String value) { | |
| + final String message = MessageUtil.formatNotificationMessage(sa, player, realtedTarget, value); | |
| if (sa != null && sa.isManaAbility()) { | |
| game.getGameLog().add(GameLogEntryType.LAND, message); | |
| } else { | |
| @@ -1029,10 +1030,10 @@ | |
| * @see forge.game.player.PlayerController#chooseModeForAbility(forge.card.spellability.SpellAbility, java.util.List, int, int) | |
| */ | |
| @Override | |
| - public List<AbilitySub> chooseModeForAbility(SpellAbility sa, int min, int num) { | |
| - List<AbilitySub> choices = CharmEffect.makePossibleOptions(sa); | |
| - String modeTitle = String.format("%s activated %s - Choose a mode", sa.getActivatingPlayer(), sa.getHostCard()); | |
| - List<AbilitySub> chosen = Lists.newArrayListWithCapacity(num); | |
| + public List<AbilitySub> chooseModeForAbility(final SpellAbility sa, final int min, final int num) { | |
| + final List<AbilitySub> choices = CharmEffect.makePossibleOptions(sa); | |
| + final String modeTitle = String.format("%s activated %s - Choose a mode", sa.getActivatingPlayer(), sa.getHostCard()); | |
| + final List<AbilitySub> chosen = Lists.newArrayListWithCapacity(num); | |
| for (int i = 0; i < num; i++) { | |
| AbilitySub a; | |
| if (i < min) { | |
| @@ -1052,57 +1053,59 @@ | |
| } | |
| @Override | |
| - public List<String> chooseColors(String message, SpellAbility sa, int min, int max, List<String> options) { | |
| + public List<String> chooseColors(final String message, final SpellAbility sa, final int min, final int max, final List<String> options) { | |
| return getGui().getChoices(message, min, max, options); | |
| } | |
| @Override | |
| - public byte chooseColor(String message, SpellAbility sa, ColorSet colors) { | |
| - int cntColors = colors.countColors(); | |
| + public byte chooseColor(final String message, final SpellAbility sa, final ColorSet colors) { | |
| + final int cntColors = colors.countColors(); | |
| switch (cntColors) { | |
| - case 0: return 0; | |
| - case 1: return colors.getColor(); | |
| - default: return chooseColorCommon(message, sa == null ? null : sa.getHostCard(), colors, false); | |
| + case 0: return 0; | |
| + case 1: return colors.getColor(); | |
| + default: return chooseColorCommon(message, sa == null ? null : sa.getHostCard(), colors, false); | |
| } | |
| } | |
| - | |
| + | |
| @Override | |
| - public byte chooseColorAllowColorless(String message, Card c, ColorSet colors) { | |
| - int cntColors = 1 + colors.countColors(); | |
| + public byte chooseColorAllowColorless(final String message, final Card c, final ColorSet colors) { | |
| + final int cntColors = 1 + colors.countColors(); | |
| switch (cntColors) { | |
| - case 1: return 0; | |
| - default: return chooseColorCommon(message, c, colors, true); | |
| + case 1: return 0; | |
| + default: return chooseColorCommon(message, c, colors, true); | |
| } | |
| } | |
| - | |
| + | |
| - private byte chooseColorCommon(String message, Card c, ColorSet colors, boolean withColorless) { | |
| + private byte chooseColorCommon(final String message, final Card c, final ColorSet colors, final boolean withColorless) { | |
| int cntColors = colors.countColors(); | |
| - if(withColorless) cntColors++; | |
| - String[] colorNames = new String[cntColors]; | |
| + if(withColorless) { | |
| + cntColors++; | |
| + } | |
| + final String[] colorNames = new String[cntColors]; | |
| int i = 0; | |
| if (withColorless) { | |
| colorNames[i++] = MagicColor.toLongString((byte)0); | |
| } | |
| - for (byte b : colors) { | |
| + for (final byte b : colors) { | |
| colorNames[i++] = MagicColor.toLongString(b); | |
| } | |
| if (colorNames.length > 2) { | |
| return MagicColor.fromName(getGui().one(message, colorNames)); | |
| } | |
| - int idxChosen = getGui().confirm(CardView.get(c), message, colorNames) ? 0 : 1; | |
| + final int idxChosen = getGui().confirm(CardView.get(c), message, colorNames) ? 0 : 1; | |
| return MagicColor.fromName(colorNames[idxChosen]); | |
| } | |
| @Override | |
| - public PaperCard chooseSinglePaperCard(SpellAbility sa, String message, Predicate<PaperCard> cpp, String name) { | |
| - Iterable<PaperCard> cardsFromDb = FModel.getMagicDb().getCommonCards().getUniqueCards(); | |
| - List<PaperCard> cards = Lists.newArrayList(Iterables.filter(cardsFromDb, cpp)); | |
| + public PaperCard chooseSinglePaperCard(final SpellAbility sa, final String message, final Predicate<PaperCard> cpp, final String name) { | |
| + final Iterable<PaperCard> cardsFromDb = FModel.getMagicDb().getCommonCards().getUniqueCards(); | |
| + final List<PaperCard> cards = Lists.newArrayList(Iterables.filter(cardsFromDb, cpp)); | |
| Collections.sort(cards); | |
| return getGui().one(message, cards); | |
| } | |
| @Override | |
| - public CounterType chooseCounterType(Collection<CounterType> options, SpellAbility sa, String prompt) { | |
| + public CounterType chooseCounterType(final Collection<CounterType> options, final SpellAbility sa, final String prompt) { | |
| if (options.size() <= 1) { | |
| return Iterables.getFirst(options, null); | |
| } | |
| @@ -1110,19 +1113,19 @@ | |
| } | |
| @Override | |
| - public boolean confirmPayment(CostPart costPart, String question) { | |
| - InputConfirm inp = new InputConfirm(this, question); | |
| + public boolean confirmPayment(final CostPart costPart, final String question) { | |
| + final InputConfirm inp = new InputConfirm(this, question); | |
| inp.showAndWait(); | |
| return inp.getResult(); | |
| } | |
| @Override | |
| - public ReplacementEffect chooseSingleReplacementEffect(String prompt, List<ReplacementEffect> possibleReplacers, HashMap<String, Object> runParams) { | |
| - ReplacementEffect first = possibleReplacers.get(0); | |
| + public ReplacementEffect chooseSingleReplacementEffect(final String prompt, final List<ReplacementEffect> possibleReplacers, final HashMap<String, Object> runParams) { | |
| + final ReplacementEffect first = possibleReplacers.get(0); | |
| if (possibleReplacers.size() == 1) { | |
| return first; | |
| } | |
| - String firstStr = first.toString(); | |
| + final String firstStr = first.toString(); | |
| for (int i = 1; i < possibleReplacers.size(); i++) { | |
| if (!possibleReplacers.get(i).toString().equals(firstStr)) { | |
| return getGui().one(prompt, possibleReplacers); //prompt user if there are multiple different options | |
| @@ -1132,21 +1135,21 @@ | |
| } | |
| @Override | |
| - public String chooseProtectionType(String string, SpellAbility sa, List<String> choices) { | |
| + public String chooseProtectionType(final String string, final SpellAbility sa, final List<String> choices) { | |
| return getGui().one(string, choices); | |
| } | |
| @Override | |
| - public boolean payCostToPreventEffect(Cost cost, SpellAbility sa, boolean alreadyPaid, FCollectionView<Player> allPayers) { | |
| + public boolean payCostToPreventEffect(final Cost cost, final SpellAbility sa, final boolean alreadyPaid, final FCollectionView<Player> allPayers) { | |
| // if it's paid by the AI already the human can pay, but it won't change anything | |
| return HumanPlay.payCostDuringAbilityResolve(this, player, sa.getHostCard(), cost, sa, null); | |
| } | |
| @Override | |
| - public void orderAndPlaySimultaneousSa(List<SpellAbility> activePlayerSAs) { | |
| + public void orderAndPlaySimultaneousSa(final List<SpellAbility> activePlayerSAs) { | |
| List<SpellAbility> orderedSAs = activePlayerSAs; | |
| if (activePlayerSAs.size() > 1) { // give a dual list form to create instead of needing to do it one at a time | |
| - String firstStr = orderedSAs.get(0).toString(); | |
| + final String firstStr = orderedSAs.get(0).toString(); | |
| for (int i = 1; i < orderedSAs.size(); i++) { //don't prompt user if all options are the same | |
| if (!orderedSAs.get(i).toString().equals(firstStr)) { | |
| orderedSAs = getGui().order("Select order for simultaneous abilities", "Resolve first", activePlayerSAs, null); | |
| @@ -1154,9 +1157,9 @@ | |
| } | |
| } | |
| } | |
| - int size = orderedSAs.size(); | |
| + final int size = orderedSAs.size(); | |
| for (int i = size - 1; i >= 0; i--) { | |
| - SpellAbility next = orderedSAs.get(i); | |
| + final SpellAbility next = orderedSAs.get(i); | |
| if (next.isTrigger()) { | |
| HumanPlay.playSpellAbility(this, player, next); | |
| } | |
| @@ -1167,19 +1170,19 @@ | |
| } | |
| @Override | |
| - public void playTrigger(Card host, WrappedAbility wrapperAbility, boolean isMandatory) { | |
| + public void playTrigger(final Card host, final WrappedAbility wrapperAbility, final boolean isMandatory) { | |
| HumanPlay.playSpellAbilityNoStack(this, player, wrapperAbility); | |
| } | |
| @Override | |
| - public boolean playSaFromPlayEffect(SpellAbility tgtSA) { | |
| + public boolean playSaFromPlayEffect(final SpellAbility tgtSA) { | |
| HumanPlay.playSpellAbility(this, player, tgtSA); | |
| return true; | |
| } | |
| @Override | |
| public Map<GameEntity, CounterType> chooseProliferation() { | |
| - InputProliferate inp = new InputProliferate(this); | |
| + final InputProliferate inp = new InputProliferate(this); | |
| inp.setCancelAllowed(true); | |
| inp.showAndWait(); | |
| if (inp.hasCancelled()) { | |
| @@ -1189,13 +1192,13 @@ | |
| } | |
| @Override | |
| - public boolean chooseTargetsFor(SpellAbility currentAbility) { | |
| + public boolean chooseTargetsFor(final SpellAbility currentAbility) { | |
| final TargetSelection select = new TargetSelection(this, currentAbility); | |
| return select.chooseTargets(null); | |
| } | |
| @Override | |
| - public boolean chooseCardsPile(SpellAbility sa, CardCollectionView pile1, CardCollectionView pile2, boolean faceUp) { | |
| + public boolean chooseCardsPile(final SpellAbility sa, final CardCollectionView pile1, final CardCollectionView pile2, final boolean faceUp) { | |
| if (!faceUp) { | |
| final String p1Str = String.format("Pile 1 (%s cards)", pile1.size()); | |
| final String p2Str = String.format("Pile 2 (%s cards)", pile2.size()); | |
| @@ -1234,46 +1237,46 @@ | |
| } | |
| @Override | |
| - public void revealAnte(String message, Multimap<Player, PaperCard> removedAnteCards) { | |
| - for (Player p : removedAnteCards.keySet()) { | |
| + public void revealAnte(final String message, final Multimap<Player, PaperCard> removedAnteCards) { | |
| + for (final Player p : removedAnteCards.keySet()) { | |
| getGui().reveal(message + " from " + Lang.getPossessedObject(MessageUtil.mayBeYou(player, p), "deck"), removedAnteCards.get(p)); | |
| } | |
| } | |
| @Override | |
| - public CardShields chooseRegenerationShield(Card c) { | |
| + public CardShields chooseRegenerationShield(final Card c) { | |
| if (c.getShieldCount() < 2) { | |
| return Iterables.getFirst(c.getShields(), null); | |
| } | |
| - ArrayList<CardShields> shields = new ArrayList<CardShields>(); | |
| - for (CardShields shield : c.getShields()) { | |
| + final List<CardShields> shields = new ArrayList<CardShields>(); | |
| + for (final CardShields shield : c.getShields()) { | |
| shields.add(shield); | |
| } | |
| return getGui().one("Choose a regeneration shield:", shields); | |
| } | |
| @Override | |
| - public List<PaperCard> chooseCardsYouWonToAddToDeck(List<PaperCard> losses) { | |
| + public List<PaperCard> chooseCardsYouWonToAddToDeck(final List<PaperCard> losses) { | |
| return getGui().many("Select cards to add to your deck", "Add these to my deck", 0, losses.size(), losses, null); | |
| } | |
| @Override | |
| - public boolean payManaCost(ManaCost toPay, CostPartMana costPartMana, SpellAbility sa, String prompt, boolean isActivatedSa) { | |
| + public boolean payManaCost(final ManaCost toPay, final CostPartMana costPartMana, final SpellAbility sa, final String prompt, final boolean isActivatedSa) { | |
| return HumanPlay.payManaCost(this, toPay, costPartMana, sa, player, prompt, isActivatedSa); | |
| } | |
| @Override | |
| - public Map<Card, ManaCostShard> chooseCardsForConvoke(SpellAbility sa, ManaCost manaCost, CardCollectionView untappedCreats) { | |
| - InputSelectCardsForConvoke inp = new InputSelectCardsForConvoke(this, player, manaCost, untappedCreats); | |
| + public Map<Card, ManaCostShard> chooseCardsForConvoke(final SpellAbility sa, final ManaCost manaCost, final CardCollectionView untappedCreats) { | |
| + final InputSelectCardsForConvoke inp = new InputSelectCardsForConvoke(this, player, manaCost, untappedCreats); | |
| inp.showAndWait(); | |
| return inp.getConvokeMap(); | |
| } | |
| @Override | |
| - public String chooseCardName(SpellAbility sa, Predicate<PaperCard> cpp, String valid, String message) { | |
| + public String chooseCardName(final SpellAbility sa, final Predicate<PaperCard> cpp, final String valid, final String message) { | |
| while (true) { | |
| - PaperCard cp = chooseSinglePaperCard(sa, message, cpp, sa.getHostCard().getName()); | |
| - Card instanceForPlayer = Card.fromPaperCard(cp, player); // the Card instance for test needs a game to be tested | |
| + final PaperCard cp = chooseSinglePaperCard(sa, message, cpp, sa.getHostCard().getName()); | |
| + final Card instanceForPlayer = Card.fromPaperCard(cp, player); // the Card instance for test needs a game to be tested | |
| if (instanceForPlayer.isValid(valid, sa.getHostCard().getController(), sa.getHostCard())) { | |
| return cp.getName(); | |
| } | |
| @@ -1281,10 +1284,11 @@ | |
| } | |
| @Override | |
| - public Card chooseSingleCardForZoneChange(ZoneType destination, List<ZoneType> origin, SpellAbility sa, CardCollection fetchList, DelayedReveal delayedReveal, String selectPrompt, boolean isOptional, Player decider) { | |
| + public Card chooseSingleCardForZoneChange(final ZoneType destination, final List<ZoneType> origin, final SpellAbility sa, final CardCollection fetchList, final DelayedReveal delayedReveal, final String selectPrompt, final boolean isOptional, final Player decider) { | |
| return chooseSingleEntityForEffect(fetchList, delayedReveal, sa, selectPrompt, isOptional, decider); | |
| } | |
| + @Override | |
| public boolean isGuiPlayer() { | |
| return lobbyPlayer == GamePlayerUtil.getGuiPlayer(); | |
| } | |
| @@ -1325,10 +1329,12 @@ | |
| return false; | |
| } | |
| + @Override | |
| public void selectButtonOk() { | |
| inputProxy.selectButtonOK(); | |
| } | |
| + @Override | |
| public void selectButtonCancel() { | |
| inputProxy.selectButtonCancel(); | |
| } | |
| @@ -1339,9 +1345,11 @@ | |
| } | |
| } | |
| + @Override | |
| public void passPriority() { | |
| passPriority(false); | |
| } | |
| + @Override | |
| public void passPriorityUntilEndOfTurn() { | |
| passPriority(true); | |
| } | |
| @@ -1361,6 +1369,7 @@ | |
| } | |
| } | |
| + @Override | |
| public void useMana(final byte mana) { | |
| final Input input = inputQueue.getInput(); | |
| if (input instanceof InputPayMana) { | |
| @@ -1368,18 +1377,22 @@ | |
| } | |
| } | |
| + @Override | |
| public void selectPlayer(final PlayerView playerView, final ITriggerEvent triggerEvent) { | |
| inputProxy.selectPlayer(playerView, triggerEvent); | |
| } | |
| + @Override | |
| public boolean selectCard(final CardView cardView, final List<CardView> otherCardViewsToSelect, final ITriggerEvent triggerEvent) { | |
| return inputProxy.selectCard(cardView, otherCardViewsToSelect, triggerEvent); | |
| } | |
| + @Override | |
| public void selectAbility(final SpellAbilityView sa) { | |
| inputProxy.selectAbility(getGame().getSpellAbility(sa)); | |
| } | |
| + @Override | |
| public void alphaStrike() { | |
| inputProxy.alphaStrike(); | |
| } | |
| @@ -1396,6 +1409,7 @@ | |
| return canPlayUnlimitedLands; | |
| } | |
| private IDevModeCheats cheats; | |
| + @Override | |
| public IDevModeCheats cheat() { | |
| if (cheats == null) { | |
| cheats = new DevModeCheats(); | |
| @@ -1414,7 +1428,7 @@ | |
| * @see forge.player.IDevModeCheats#setCanPlayUnlimitedLands(boolean) | |
| */ | |
| @Override | |
| - public void setCanPlayUnlimitedLands(boolean canPlayUnlimitedLands0) { | |
| + public void setCanPlayUnlimitedLands(final boolean canPlayUnlimitedLands0) { | |
| canPlayUnlimitedLands = canPlayUnlimitedLands0; | |
| } | |
| @@ -1434,7 +1448,7 @@ | |
| */ | |
| @Override | |
| public void generateMana() { | |
| - Player pPriority = game.getPhaseHandler().getPriorityPlayer(); | |
| + final Player pPriority = game.getPhaseHandler().getPriorityPlayer(); | |
| if (pPriority == null) { | |
| getGui().message("No player has priority at the moment, so mana cannot be added to their pool."); | |
| return; | |
| @@ -1442,7 +1456,7 @@ | |
| final Card dummy = new Card(-777777, game); | |
| dummy.setOwner(pPriority); | |
| - Map<String, String> produced = new HashMap<String, String>(); | |
| + final Map<String, String> produced = new HashMap<String, String>(); | |
| produced.put("Produced", "W W W W W W W U U U U U U U B B B B B B B G G G G G G G R R R R R R R 7"); | |
| final AbilityManaPart abMana = new AbilityManaPart(dummy, produced); | |
| game.getAction().invoke(new Runnable() { | |
| @@ -1452,8 +1466,7 @@ | |
| private GameState createGameStateObject() { | |
| return new GameState() { | |
| - @Override | |
| - public IPaperCard getPaperCard(String cardName) { | |
| + @Override public IPaperCard getPaperCard(final String cardName) { | |
| return FModel.getMagicDb().getCommonCards().getCard(cardName); | |
| } | |
| }; | |
| @@ -1467,13 +1480,13 @@ | |
| final GameState state = createGameStateObject(); | |
| try { | |
| state.initFromGame(game); | |
| - File f = GuiBase.getInterface().getSaveFile(new File(ForgeConstants.USER_GAMES_DIR, "state.txt")); | |
| + final File f = GuiBase.getInterface().getSaveFile(new File(ForgeConstants.USER_GAMES_DIR, "state.txt")); | |
| if (f != null && (!f.exists() || getGui().showConfirmDialog("Overwrite existing file?", "File exists!"))) { | |
| final BufferedWriter bw = new BufferedWriter(new FileWriter(f)); | |
| bw.write(state.toString()); | |
| bw.close(); | |
| } | |
| - } catch (Exception e) { | |
| + } catch (final Exception e) { | |
| String err = e.getClass().getName(); | |
| if (e.getMessage() != null) { | |
| err += ": " + e.getMessage(); | |
| @@ -1488,12 +1501,12 @@ | |
| */ | |
| @Override | |
| public void setupGameState() { | |
| - File gamesDir = new File(ForgeConstants.USER_GAMES_DIR); | |
| + final File gamesDir = new File(ForgeConstants.USER_GAMES_DIR); | |
| if (!gamesDir.exists()) { // if the directory does not exist, try to create it | |
| gamesDir.mkdir(); | |
| } | |
| - | |
| + | |
| - String filename = GuiBase.getInterface().showFileDialog("Select Game State File", ForgeConstants.USER_GAMES_DIR); | |
| + final String filename = GuiBase.getInterface().showFileDialog("Select Game State File", ForgeConstants.USER_GAMES_DIR); | |
| if (filename == null) { | |
| return; | |
| } | |
| @@ -1512,7 +1525,7 @@ | |
| return; | |
| } | |
| - Player pPriority = game.getPhaseHandler().getPriorityPlayer(); | |
| + final Player pPriority = game.getPhaseHandler().getPriorityPlayer(); | |
| if (pPriority == null) { | |
| getGui().message("No player has priority at the moment, so game state cannot be setup."); | |
| return; | |
| @@ -1525,7 +1538,7 @@ | |
| */ | |
| @Override | |
| public void tutorForCard() { | |
| - Player pPriority = game.getPhaseHandler().getPriorityPlayer(); | |
| + final Player pPriority = game.getPhaseHandler().getPriorityPlayer(); | |
| if (pPriority == null) { | |
| getGui().message("No player has priority at the moment, so their deck can't be tutored from."); | |
| return; | |
| @@ -1534,7 +1547,7 @@ | |
| final CardCollection lib = (CardCollection)pPriority.getCardsIn(ZoneType.Library); | |
| final List<ZoneType> origin = new ArrayList<ZoneType>(); | |
| origin.add(ZoneType.Library); | |
| - SpellAbility sa = new SpellAbility.EmptySa(new Card(-1, game)); | |
| + final SpellAbility sa = new SpellAbility.EmptySa(new Card(-1, game)); | |
| final Card card = chooseSingleCardForZoneChange(ZoneType.Hand, origin, sa, lib, null, "Choose a card", true, pPriority); | |
| if (card == null) { return; } | |
| @@ -1560,7 +1573,7 @@ | |
| final Integer count = getGui().getInteger("How many counters?", 1, Integer.MAX_VALUE, 10); | |
| if (count == null) { return; } | |
| - | |
| + | |
| card.addCounter(counter, count, false); | |
| } | |
| @@ -1573,12 +1586,12 @@ | |
| @Override | |
| public void run() { | |
| final CardCollectionView untapped = CardLists.filter(game.getCardsIn(ZoneType.Battlefield), Predicates.not(CardPredicates.Presets.TAPPED)); | |
| - InputSelectCardsFromList inp = new InputSelectCardsFromList(PlayerControllerHuman.this, 0, Integer.MAX_VALUE, untapped); | |
| + final InputSelectCardsFromList inp = new InputSelectCardsFromList(PlayerControllerHuman.this, 0, Integer.MAX_VALUE, untapped); | |
| inp.setCancelAllowed(true); | |
| inp.setMessage("Choose permanents to tap"); | |
| inp.showAndWait(); | |
| if (!inp.hasCancelled()) { | |
| - for (Card c : inp.getSelected()) { | |
| + for (final Card c : inp.getSelected()) { | |
| c.tap(); | |
| } | |
| } | |
| @@ -1595,12 +1608,12 @@ | |
| @Override | |
| public void run() { | |
| final CardCollectionView tapped = CardLists.filter(game.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.TAPPED); | |
| - InputSelectCardsFromList inp = new InputSelectCardsFromList(PlayerControllerHuman.this, 0, Integer.MAX_VALUE, tapped); | |
| + final InputSelectCardsFromList inp = new InputSelectCardsFromList(PlayerControllerHuman.this, 0, Integer.MAX_VALUE, tapped); | |
| inp.setCancelAllowed(true); | |
| inp.setMessage("Choose permanents to untap"); | |
| inp.showAndWait(); | |
| if (!inp.hasCancelled()) { | |
| - for (Card c : inp.getSelected()) { | |
| + for (final Card c : inp.getSelected()) { | |
| c.untap(); | |
| } | |
| } | |
| @@ -1627,7 +1640,7 @@ | |
| */ | |
| @Override | |
| public void winGame() { | |
| - Input input = inputQueue.getInput(); | |
| + final Input input = inputQueue.getInput(); | |
| if (!(input instanceof InputPassPriority)) { | |
| getGui().message("You must have priority to use this feature.", "Win Game"); | |
| return; | |
| @@ -1636,7 +1649,7 @@ | |
| //set life of all other players to 0 | |
| final LobbyPlayer guiPlayer = getLobbyPlayer(); | |
| final FCollectionView<Player> players = game.getPlayers(); | |
| - for (Player player : players) { | |
| + for (final Player player : players) { | |
| if (player.getLobbyPlayer() != guiPlayer) { | |
| player.setLife(0, null); | |
| } | |
| @@ -1755,7 +1768,7 @@ | |
| final Player p = game.getPhaseHandler().getPlayerTurn(); | |
| final List<PaperCard> allPlanars = new ArrayList<PaperCard>(); | |
| - for (PaperCard c : FModel.getMagicDb().getVariantCards().getAllCards()) { | |
| + for (final PaperCard c : FModel.getMagicDb().getVariantCards().getAllCards()) { | |
| if (c.getRules().getType().isPlane() || c.getRules().getType().isPhenomenon()) { | |
| allPlanars.add(c); | |
| } | |
| @@ -1768,9 +1781,8 @@ | |
| final Card forgeCard = Card.fromPaperCard(c, p); | |
| forgeCard.setOwner(p); | |
| - game.getAction().invoke(new Runnable() { | |
| + game.getAction().invoke(new Runnable() { | |
| - @Override | |
| - public void run() { | |
| + @Override public void run() { | |
| game.getAction().changeZone(null, p.getZone(ZoneType.PlanarDeck), forgeCard, 0); | |
| PlanarDice.roll(p, PlanarDice.Planeswalk); | |
| } | |
| @@ -1813,8 +1825,8 @@ | |
| } | |
| @Override | |
| - public void reorderHand(CardView card, int index) { | |
| - PlayerZone hand = player.getZone(ZoneType.Hand); | |
| + public void reorderHand(final CardView card, final int index) { | |
| + final PlayerZone hand = player.getZone(ZoneType.Hand); | |
| hand.reorder(game.getCard(card), index); | |
| player.updateZoneForView(hand); | |
| } | |
| Index: forge-gui/src/main/java/forge/limited/BoosterDraftAI.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui/src/main/java/forge/limited/BoosterDraftAI.java (revision 29316) | |
| +++ forge-gui/src/main/java/forge/limited/BoosterDraftAI.java (revision 29317) | |
| @@ -6,17 +6,23 @@ | |
| * 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 <http://www.gnu.org/licenses/>. | |
| */ | |
| package forge.limited; | |
| +import java.util.ArrayList; | |
| +import java.util.List; | |
| + | |
| +import org.apache.commons.lang3.tuple.MutablePair; | |
| +import org.apache.commons.lang3.tuple.Pair; | |
| + | |
| import forge.card.ColorSet; | |
| import forge.card.MagicColor; | |
| import forge.deck.Deck; | |
| @@ -24,19 +30,13 @@ | |
| import forge.properties.ForgePreferences; | |
| import forge.util.Aggregates; | |
| -import org.apache.commons.lang3.tuple.MutablePair; | |
| -import org.apache.commons.lang3.tuple.Pair; | |
| - | |
| -import java.util.ArrayList; | |
| -import java.util.List; | |
| - | |
| /** | |
| * <p> | |
| * BoosterDraftAI class. | |
| * </p> | |
| - * | |
| + * | |
| * @author Forge | |
| - * @version $Id: BoosterDraftAI.java 28556 2015-01-06 00:52:13Z -gz $ | |
| + * @version $Id: BoosterDraftAI.java 29317 2015-05-01 19:27:48Z elcnesh $ | |
| */ | |
| public class BoosterDraftAI { | |
| @@ -62,7 +62,7 @@ | |
| * <p> | |
| * Choose a CardPrinted from the list given. | |
| * </p> | |
| - * | |
| + * | |
| * @param chooseFrom | |
| * List of CardPrinted | |
| * @param player | |
| @@ -74,22 +74,24 @@ | |
| System.out.println("Player[" + player + "] pack: " + chooseFrom.toString()); | |
| } | |
| - DeckColors deckCols = this.playerColors.get(player); | |
| - ColorSet currentChoice = deckCols.getChosenColors(); | |
| - boolean canAddMoreColors = deckCols.canChoseMoreColors(); | |
| + final DeckColors deckCols = this.playerColors.get(player); | |
| + final ColorSet currentChoice = deckCols.getChosenColors(); | |
| + final boolean canAddMoreColors = deckCols.canChoseMoreColors(); | |
| - | |
| + | |
| - List<Pair<PaperCard, Double>> rankedCards = rankCards(chooseFrom); | |
| + final List<Pair<PaperCard, Double>> rankedCards = rankCards(chooseFrom); | |
| - | |
| + | |
| - for(Pair<PaperCard, Double> p : rankedCards) { | |
| + for (final Pair<PaperCard, Double> p : rankedCards) { | |
| double valueBoost = 0; | |
| // If a card is not ai playable, somewhat decrease its rating | |
| - if( p.getKey().getRules().getAiHints().getRemAIDecks() ) | |
| + if( p.getKey().getRules().getAiHints().getRemAIDecks() ) { | |
| valueBoost = TAKE_BEST_THRESHOLD; | |
| + } | |
| // if I cannot choose more colors, and the card cannot be played with chosen colors, decrease its rating. | |
| - if( !canAddMoreColors && !p.getKey().getRules().getManaCost().canBePaidWithAvaliable(currentChoice.getColor())) | |
| + if( !canAddMoreColors && !p.getKey().getRules().getManaCost().canBePaidWithAvaliable(currentChoice.getColor())) { | |
| valueBoost = TAKE_BEST_THRESHOLD * 3; | |
| + } | |
| if (valueBoost > 0) { | |
| p.setValue(p.getValue() + valueBoost); | |
| @@ -100,11 +102,11 @@ | |
| double bestRanking = Double.MAX_VALUE; | |
| PaperCard bestPick = null; | |
| final List<PaperCard> possiblePick = new ArrayList<PaperCard>(); | |
| - for(Pair<PaperCard, Double> p : rankedCards) { | |
| - double rating = p.getValue(); | |
| + for (final Pair<PaperCard, Double> p : rankedCards) { | |
| + final double rating = p.getValue(); | |
| if(rating <= bestRanking + .01) { | |
| if (rating < bestRanking) { | |
| - // found a better card start a new list | |
| + // found a better card start a new list | |
| possiblePick.clear(); | |
| bestRanking = rating; | |
| } | |
| @@ -114,12 +116,13 @@ | |
| bestPick = Aggregates.random(possiblePick); | |
| - if (canAddMoreColors) | |
| + if (canAddMoreColors) { | |
| deckCols.addColorsOf(bestPick); | |
| + } | |
| - | |
| + | |
| System.out.println("Player[" + player + "] picked: " + bestPick + " ranking of " + bestRanking); | |
| this.deck.get(player).add(bestPick); | |
| - | |
| + | |
| return bestPick; | |
| } | |
| @@ -127,14 +130,14 @@ | |
| * Sort cards by rank. Note that if pack has cards from different editions, | |
| * they could have the same rank. Basic lands and unrecognised cards are | |
| * rated worse than all other possible picks. | |
| - * | |
| + * | |
| * @param chooseFrom | |
| * List of cards | |
| * @return map of rankings | |
| */ | |
| - private List<Pair<PaperCard, Double>> rankCards(final Iterable<PaperCard> chooseFrom) { | |
| - List<Pair<PaperCard, Double>> rankedCards = new ArrayList<Pair<PaperCard,Double>>(); | |
| - for (PaperCard card : chooseFrom) { | |
| + private static List<Pair<PaperCard, Double>> rankCards(final Iterable<PaperCard> chooseFrom) { | |
| + final List<Pair<PaperCard, Double>> rankedCards = new ArrayList<Pair<PaperCard,Double>>(); | |
| + for (final PaperCard card : chooseFrom) { | |
| Double rank; | |
| if (MagicColor.Constant.BASIC_LANDS.contains(card.getName())) { | |
| rank = RANK_UNPICKABLE; | |
| @@ -155,7 +158,7 @@ | |
| * <p> | |
| * getDecks. | |
| * </p> | |
| - * | |
| + * | |
| * @return an array of {@link forge.deck.Deck} objects. | |
| */ | |
| public Deck[] getDecks() { | |
| @@ -186,7 +189,7 @@ | |
| /** | |
| * Gets the bd. | |
| - * | |
| + * | |
| * @return the bd | |
| */ | |
| public IBoosterDraft getBd() { | |
| @@ -195,7 +198,7 @@ | |
| /** | |
| * Sets the bd. | |
| - * | |
| + * | |
| * @param bd0 | |
| * the bd to set | |
| */ | |
| Index: forge-gui/src/main/java/forge/util/gui/SGuiChoose.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui/src/main/java/forge/util/gui/SGuiChoose.java (revision 29316) | |
| +++ forge-gui/src/main/java/forge/util/gui/SGuiChoose.java (revision 29317) | |
| @@ -3,24 +3,20 @@ | |
| import java.util.ArrayList; | |
| import java.util.Arrays; | |
| import java.util.Collection; | |
| -import java.util.Collections; | |
| -import java.util.Comparator; | |
| import java.util.List; | |
| import org.apache.commons.lang3.StringUtils; | |
| import com.google.common.base.Function; | |
| import com.google.common.collect.Iterables; | |
| -import com.google.common.collect.Lists; | |
| import forge.GuiBase; | |
| public class SGuiChoose { | |
| - public static final String[] defaultConfirmOptions = { "Yes", "No" }; | |
| /** | |
| * Convenience for getChoices(message, 0, 1, choices). | |
| - * | |
| + * | |
| * @param <T> | |
| * is automatically inferred. | |
| * @param message | |
| @@ -48,26 +44,6 @@ | |
| return choice.isEmpty() ? null : choice.get(0); | |
| } | |
| - // returned Object will never be null | |
| - /** | |
| - * <p> | |
| - * getChoice. | |
| - * </p> | |
| - * | |
| - * @param <T> | |
| - * a T object. | |
| - * @param message | |
| - * a {@link java.lang.String} object. | |
| - * @param choices | |
| - * a T object. | |
| - * @return a T object. | |
| - */ | |
| - public static <T> T one(final String message, final T[] choices) { | |
| - final List<T> choice = SGuiChoose.getChoices(message, 1, 1, choices); | |
| - assert choice.size() == 1; | |
| - return choice.get(0); | |
| - } | |
| - | |
| public static <T> T one(final String message, final Collection<T> choices) { | |
| if (choices == null || choices.isEmpty()) { | |
| return null; | |
| @@ -81,42 +57,25 @@ | |
| return choice.get(0); | |
| } | |
| - public static <T> List<T> noneOrMany(final String message, final Collection<T> choices) { | |
| - return SGuiChoose.getChoices(message, 0, choices.size(), choices, null, null); | |
| - } | |
| - | |
| // Nothing to choose here. Code uses this to just reveal one or more items | |
| - public static <T> void reveal(final String message, final T item) { | |
| - List<T> items = new ArrayList<T>(); | |
| - items.add(item); | |
| - reveal(message, items); | |
| - } | |
| - public static <T> void reveal(final String message, final T[] items) { | |
| - SGuiChoose.getChoices(message, -1, -1, items); | |
| - } | |
| public static <T> void reveal(final String message, final Collection<T> items) { | |
| SGuiChoose.getChoices(message, -1, -1, items); | |
| } | |
| // Get Integer in range | |
| - public static Integer getInteger(final String message) { | |
| - return getInteger(message, 0, Integer.MAX_VALUE, false); | |
| - } | |
| - public static Integer getInteger(final String message, int min) { | |
| - return getInteger(message, min, Integer.MAX_VALUE, false); | |
| - } | |
| - public static Integer getInteger(final String message, int min, int max) { | |
| + public static Integer getInteger(final String message, final int min, final int max) { | |
| return getInteger(message, min, max, false); | |
| } | |
| - public static Integer getInteger(final String message, int min, int max, boolean sortDesc) { | |
| + | |
| + public static Integer getInteger(final String message, final int min, final int max, final boolean sortDesc) { | |
| if (max <= min) { return min; } //just return min if max <= min | |
| //force cutting off after 100 numbers at most | |
| if (max == Integer.MAX_VALUE) { | |
| return getInteger(message, min, max, min + 99); | |
| } | |
| - int count = max - min + 1; | |
| + final int count = max - min + 1; | |
| - if (count > 100) { | |
| + if (count > 100) { | |
| return getInteger(message, min, max, min + 99); | |
| } | |
| @@ -133,20 +92,21 @@ | |
| } | |
| return SGuiChoose.oneOrNone(message, choices); | |
| } | |
| - public static Integer getInteger(final String message, int min, int max, int cutoff) { | |
| + | |
| + public static Integer getInteger(final String message, final int min, final int max, final int cutoff) { | |
| if (max <= min || cutoff < min) { return min; } //just return min if max <= min or cutoff < min | |
| if (cutoff >= max) { //fallback to regular integer prompt if cutoff at or after max | |
| return getInteger(message, min, max); | |
| } | |
| - List<Object> choices = new ArrayList<Object>(); | |
| + final List<Object> choices = new ArrayList<Object>(); | |
| for (int i = min; i <= cutoff; i++) { | |
| choices.add(Integer.valueOf(i)); | |
| } | |
| choices.add("..."); | |
| - Object choice = SGuiChoose.oneOrNone(message, choices); | |
| + final Object choice = SGuiChoose.oneOrNone(message, choices); | |
| if (choice instanceof Integer || choice == null) { | |
| return (Integer)choice; | |
| } | |
| @@ -167,11 +127,11 @@ | |
| prompt += ":"; | |
| while (true) { | |
| - String str = SOptionPane.showInputDialog(prompt, message); | |
| + final String str = SOptionPane.showInputDialog(prompt, message); | |
| if (str == null) { return null; } // that is 'cancel' | |
| if (StringUtils.isNumeric(str)) { | |
| - Integer val = Integer.valueOf(str); | |
| + final Integer val = Integer.valueOf(str); | |
| if (val >= min && val <= max) { | |
| return val; | |
| } | |
| @@ -192,13 +152,13 @@ | |
| return GuiBase.getInterface().getChoices(message, min, max, choices, selected, display); | |
| } | |
| - public static <T> List<T> many(final String title, final String topCaption, int cnt, final List<T> sourceChoices) { | |
| + public static <T> List<T> many(final String title, final String topCaption, final int cnt, final List<T> sourceChoices) { | |
| return many(title, topCaption, cnt, cnt, sourceChoices); | |
| } | |
| - public static <T> List<T> many(final String title, final String topCaption, int min, int max, final List<T> sourceChoices) { | |
| - int m2 = min >= 0 ? sourceChoices.size() - min : -1; | |
| - int m1 = max >= 0 ? sourceChoices.size() - max : -1; | |
| + public static <T> List<T> many(final String title, final String topCaption, final int min, final int max, final List<T> sourceChoices) { | |
| + final int m2 = min >= 0 ? sourceChoices.size() - min : -1; | |
| + final int m1 = max >= 0 ? sourceChoices.size() - max : -1; | |
| return order(title, topCaption, m1, m2, sourceChoices, null); | |
| } | |
| @@ -206,81 +166,9 @@ | |
| return order(title, top, 0, 0, sourceChoices, null); | |
| } | |
| - /** | |
| - * Ask the user to insert an object into a list of other objects. The | |
| - * current implementation requires the user to cancel in order to get the | |
| - * new item to be the first item in the resulting list. | |
| - * | |
| - * @param title the dialog title. | |
| - * @param newItem the object to insert. | |
| - * @param oldItems the list of objects. | |
| - * @return A shallow copy of the list of objects, with newItem inserted. | |
| - */ | |
| - public static <T> List<T> insertInList(final String title, final T newItem, final List<T> oldItems) { | |
| - final T placeAfter = oneOrNone(title, oldItems); | |
| - final int indexAfter = (placeAfter == null ? 0 : oldItems.indexOf(placeAfter) + 1); | |
| - final List<T> result = Lists.newArrayListWithCapacity(oldItems.size() + 1); | |
| - result.addAll(oldItems); | |
| - result.add(indexAfter, newItem); | |
| - return result; | |
| - } | |
| - | |
| private static <T> List<T> order(final String title, final String top, final int remainingObjectsMin, final int remainingObjectsMax, | |
| final List<T> sourceChoices, final List<T> destChoices) { | |
| return GuiBase.getInterface().order(title, top, remainingObjectsMin, remainingObjectsMax, sourceChoices, destChoices); | |
| } | |
| - // If comparer is NULL, T has to be comparable. Otherwise you'll get an exception from inside the Arrays.sort() routine | |
| - public static <T> T sortedOneOrNone(final String message, final T[] choices, Comparator<T> comparer) { | |
| - if ((choices == null) || (choices.length == 0)) { | |
| - return null; | |
| - } | |
| - final List<T> choice = SGuiChoose.sortedGetChoices(message, 0, 1, choices, comparer); | |
| - return choice.isEmpty() ? null : choice.get(0); | |
| - } | |
| - | |
| - // If comparer is NULL, T has to be comparable. Otherwise you'll get an exception from inside the Arrays.sort() routine | |
| - public static <T> T sortedOneOrNone(final String message, final List<T> choices, Comparator<T> comparer) { | |
| - if ((choices == null) || choices.isEmpty()) { | |
| - return null; | |
| - } | |
| - final List<T> choice = SGuiChoose.sortedGetChoices(message, 0, 1, choices, comparer); | |
| - return choice.isEmpty() ? null : choice.get(0); | |
| - } | |
| - | |
| - // If comparer is NULL, T has to be comparable. Otherwise you'll get an exception from inside the Arrays.sort() routine | |
| - public static <T> T sortedOne(final String message, final T[] choices, Comparator<T> comparer) { | |
| - final List<T> choice = SGuiChoose.sortedGetChoices(message, 1, 1, choices, comparer); | |
| - assert choice.size() == 1; | |
| - return choice.get(0); | |
| - } | |
| - | |
| - // If comparer is NULL, T has to be comparable. Otherwise you'll get an exception from inside the Arrays.sort() routine | |
| - public static <T> T sortedOne(final String message, final List<T> choices, Comparator<T> comparer) { | |
| - if ((choices == null) || (choices.size() == 0)) { | |
| - return null; | |
| - } | |
| - final List<T> choice = SGuiChoose.sortedGetChoices(message, 1, 1, choices, comparer); | |
| - assert choice.size() == 1; | |
| - return choice.get(0); | |
| - } | |
| - | |
| - // If comparer is NULL, T has to be comparable. Otherwise you'll get an exception from inside the Arrays.sort() routine | |
| - public static <T> List<T> sortedNoneOrMany(final String message, final List<T> choices, Comparator<T> comparer) { | |
| - return SGuiChoose.sortedGetChoices(message, 0, choices.size(), choices, comparer); | |
| - } | |
| - | |
| - // If comparer is NULL, T has to be comparable. Otherwise you'll get an exception from inside the Arrays.sort() routine | |
| - public static <T> List<T> sortedGetChoices(final String message, final int min, final int max, final T[] choices, Comparator<T> comparer) { | |
| - // You may create a copy of source array if callers expect the collection to be unchanged | |
| - Arrays.sort(choices, comparer); | |
| - return getChoices(message, min, max, choices); | |
| - } | |
| - | |
| - // If comparer is NULL, T has to be comparable. Otherwise you'll get an exception from inside the Arrays.sort() routine | |
| - public static <T> List<T> sortedGetChoices(final String message, final int min, final int max, final List<T> choices, Comparator<T> comparer) { | |
| - // You may create a copy of source list if callers expect the collection to be unchanged | |
| - Collections.sort(choices, comparer); | |
| - return getChoices(message, min, max, choices); | |
| - } | |
| } | |
| Index: forge-gui-desktop/src/main/java/forge/screens/home/quest/VSubmenuChallenges.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/home/quest/VSubmenuChallenges.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/home/quest/VSubmenuChallenges.java (revision 29317) | |
| @@ -1,18 +1,30 @@ | |
| package forge.screens.home.quest; | |
| +import java.awt.Font; | |
| + | |
| +import javax.swing.JButton; | |
| +import javax.swing.JLabel; | |
| +import javax.swing.JPanel; | |
| +import javax.swing.ScrollPaneConstants; | |
| +import javax.swing.SwingConstants; | |
| + | |
| +import net.miginfocom.swing.MigLayout; | |
| import forge.assets.FSkinProp; | |
| import forge.gui.framework.DragCell; | |
| import forge.gui.framework.DragTab; | |
| import forge.gui.framework.EDocID; | |
| import forge.quest.IVQuestStats; | |
| -import forge.screens.home.*; | |
| -import forge.toolbox.*; | |
| -import net.miginfocom.swing.MigLayout; | |
| +import forge.screens.home.EMenuGroup; | |
| +import forge.screens.home.IVSubmenu; | |
| +import forge.screens.home.LblHeader; | |
| +import forge.screens.home.StartButton; | |
| +import forge.screens.home.VHomeUI; | |
| +import forge.toolbox.FCheckBox; | |
| +import forge.toolbox.FComboBoxWrapper; | |
| +import forge.toolbox.FLabel; | |
| +import forge.toolbox.FScrollPanel; | |
| +import forge.toolbox.FSkin; | |
| -import javax.swing.*; | |
| - | |
| -import java.awt.*; | |
| - | |
| /** | |
| * Assembles Swing components of quest challenges submenu singleton. | |
| * | |
| @@ -268,7 +280,7 @@ | |
| * @see forge.gui.framework.IVDoc#setParentCell(forge.gui.framework.DragCell) | |
| */ | |
| @Override | |
| - public void setParentCell(DragCell cell0) { | |
| + public void setParentCell(final DragCell cell0) { | |
| this.parentCell = cell0; | |
| } | |
| @@ -280,12 +292,13 @@ | |
| return parentCell; | |
| } | |
| - /** | |
| - * @return the cbCharm | |
| - */ | |
| + /** | |
| + * @return the cbCharm | |
| + */ | |
| + @Override | |
| - public FCheckBox getCbCharm() { | |
| - return cbCharm; | |
| - } | |
| + public FCheckBox getCbCharm() { | |
| + return cbCharm; | |
| + } | |
| @Override | |
| public FLabel getBtnRandomOpponent() { | |
| Index: forge-gui-desktop/src/main/java/forge/screens/match/controllers/CPicture.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/match/controllers/CPicture.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/match/controllers/CPicture.java (revision 29317) | |
| @@ -6,12 +6,12 @@ | |
| * 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 <http://www.gnu.org/licenses/>. | |
| */ | |
| @@ -23,7 +23,6 @@ | |
| import javax.swing.JLabel; | |
| -import forge.UiCommand; | |
| import forge.game.card.CardView; | |
| import forge.game.card.CardView.CardStateView; | |
| import forge.gui.CardPicturePanel; | |
| @@ -68,7 +67,7 @@ | |
| /** | |
| * Shows card details and/or picture in sidebar cardview tabber. | |
| - * | |
| + * | |
| */ | |
| void showCard(final CardView c, final boolean isInAltState, final boolean mayView, final boolean mayFlip) { | |
| final CardStateView toShow = c != null && mayView ? c.getState(isInAltState) : null; | |
| @@ -79,11 +78,6 @@ | |
| void showItem(final InventoryItem item) { | |
| flipIndicator.setVisible(false); | |
| picturePanel.setCard(item); | |
| - } | |
| - | |
| - @Override | |
| - public UiCommand getCommandOnSelect() { | |
| - return null; | |
| } | |
| @Override | |
| Index: forge-gui/src/main/java/forge/interfaces/ITextField.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui/src/main/java/forge/interfaces/ITextField.java (revision 29316) | |
| +++ forge-gui/src/main/java/forge/interfaces/ITextField.java (revision 29317) | |
| @@ -1,11 +1,5 @@ | |
| package forge.interfaces; | |
| -public interface ITextField { | |
| - boolean isEnabled(); | |
| - void setEnabled(boolean b0); | |
| - boolean isVisible(); | |
| - void setVisible(boolean b0); | |
| - String getText(); | |
| - void setText(String text0); | |
| +public interface ITextField extends ITextComponent { | |
| boolean requestFocusInWindow(); | |
| } | |
| Index: forge-gui-desktop/src/main/java/forge/screens/match/views/VStack.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/match/views/VStack.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/match/views/VStack.java (revision 29317) | |
| @@ -6,12 +6,12 @@ | |
| * 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 <http://www.gnu.org/licenses/>. | |
| */ | |
| @@ -51,7 +51,7 @@ | |
| import forge.toolbox.FSkin.SkinnedTextArea; | |
| import forge.util.FCollectionView; | |
| -/** | |
| +/** | |
| * Assembles Swing components of stack report. | |
| * | |
| * <br><br><i>(V at beginning of class name denotes a view class.)</i> | |
| @@ -129,7 +129,7 @@ | |
| boolean isFirst = true; | |
| for (final StackItemView item : items) { | |
| - final StackInstanceTextArea tar = new StackInstanceTextArea(model, item); | |
| + final StackInstanceTextArea tar = new StackInstanceTextArea(item); | |
| scroller.add(tar, "pushx, growx" + (isFirst ? "" : ", gaptop 2px")); | |
| @@ -167,8 +167,7 @@ | |
| public Point getLocationOnScreen() { | |
| try { | |
| return super.getLocationOnScreen(); | |
| - } | |
| - catch (Exception e) { | |
| + } catch (final Exception e) { | |
| //suppress exception that can occur if stack hidden while over an item | |
| if (hoveredItem == this) { | |
| hoveredItem = null; //reset this if this happens | |
| @@ -177,7 +176,7 @@ | |
| } | |
| } | |
| - public StackInstanceTextArea(final GameView gameView, final StackItemView item0) { | |
| + public StackInstanceTextArea(final StackItemView item0) { | |
| item = item0; | |
| final String txt = (item.isOptionalTrigger() && controller.getMatchUI().isLocalPlayer(item.getActivatingPlayer()) | |
| @@ -213,14 +212,14 @@ | |
| if (item.isAbility()) { | |
| addMouseListener(new FMouseAdapter() { | |
| @Override | |
| - public void onLeftClick(MouseEvent e) { | |
| + public void onLeftClick(final MouseEvent e) { | |
| onClick(e); | |
| } | |
| @Override | |
| - public void onRightClick(MouseEvent e) { | |
| + public void onRightClick(final MouseEvent e) { | |
| onClick(e); | |
| } | |
| - private void onClick(MouseEvent e) { | |
| + private void onClick(final MouseEvent e) { | |
| abilityMenu.setStackInstance(item); | |
| abilityMenu.show(e.getComponent(), e.getX(), e.getY()); | |
| } | |
| @@ -233,7 +232,7 @@ | |
| } | |
| @Override | |
| - public void paintComponent(Graphics g) { | |
| + public void paintComponent(final Graphics g) { | |
| super.paintComponent(g); | |
| final Graphics2D g2d = (Graphics2D) g; | |
| @@ -261,7 +260,7 @@ | |
| jmiAutoYield = new JCheckBoxMenuItem("Auto-Yield"); | |
| jmiAutoYield.addActionListener(new ActionListener() { | |
| @Override | |
| - public void actionPerformed(ActionEvent arg0) { | |
| + public void actionPerformed(final ActionEvent arg0) { | |
| final String key = item.getKey(); | |
| final boolean autoYield = controller.getMatchUI().shouldAutoYield(key); | |
| controller.getMatchUI().setShouldAutoYield(key, !autoYield); | |
| @@ -276,7 +275,7 @@ | |
| jmiAlwaysYes = new JCheckBoxMenuItem("Always Yes"); | |
| jmiAlwaysYes.addActionListener(new ActionListener() { | |
| @Override | |
| - public void actionPerformed(ActionEvent arg0) { | |
| + public void actionPerformed(final ActionEvent arg0) { | |
| if (controller.getMatchUI().shouldAlwaysAcceptTrigger(triggerID)) { | |
| controller.getMatchUI().setShouldAlwaysAskTrigger(triggerID); | |
| } | |
| @@ -294,7 +293,7 @@ | |
| jmiAlwaysNo = new JCheckBoxMenuItem("Always No"); | |
| jmiAlwaysNo.addActionListener(new ActionListener() { | |
| @Override | |
| - public void actionPerformed(ActionEvent arg0) { | |
| + public void actionPerformed(final ActionEvent arg0) { | |
| if (controller.getMatchUI().shouldAlwaysDeclineTrigger(triggerID)) { | |
| controller.getMatchUI().setShouldAlwaysAskTrigger(triggerID); | |
| } | |
| Index: forge-gui/src/main/java/forge/interfaces/IGuiGame.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui/src/main/java/forge/interfaces/IGuiGame.java (revision 29316) | |
| +++ forge-gui/src/main/java/forge/interfaces/IGuiGame.java (revision 29317) | |
| @@ -68,24 +68,18 @@ | |
| String showInputDialog(String message, String title); | |
| String showInputDialog(String message, String title, FSkinProp icon); | |
| - String showInputDialog(String message, String title, FSkinProp icon, | |
| - String initialInput); | |
| - String showInputDialog(String message, String title, FSkinProp icon, | |
| - String initialInput, String[] inputOptions); | |
| + String showInputDialog(String message, String title, FSkinProp icon, String initialInput); | |
| + String showInputDialog(String message, String title, FSkinProp icon, String initialInput, String[] inputOptions); | |
| boolean confirm(CardView c, String question); | |
| - boolean confirm(CardView c, String question, boolean defaultChoice); | |
| boolean confirm(CardView c, String question, String[] options); | |
| boolean confirm(CardView c, String question, boolean defaultIsYes, String[] options); | |
| <T> List<T> getChoices(String message, int min, int max, T[] choices); | |
| - <T> List<T> getChoices(String message, int min, int max, | |
| - Collection<T> choices); | |
| - <T> List<T> getChoices(String message, int min, int max, | |
| - Collection<T> choices, T selected, Function<T, String> display); | |
| + <T> List<T> getChoices(String message, int min, int max, Collection<T> choices); | |
| + <T> List<T> getChoices(String message, int min, int max, Collection<T> choices, T selected, Function<T, String> display); | |
| // Get Integer in range | |
| - Integer getInteger(String message); | |
| Integer getInteger(String message, int min); | |
| Integer getInteger(String message, int min, int max); | |
| Integer getInteger(String message, int min, int max, boolean sortDesc); | |
| @@ -93,7 +87,7 @@ | |
| /** | |
| * Convenience for getChoices(message, 0, 1, choices). | |
| - * | |
| + * | |
| * @param <T> | |
| * is automatically inferred. | |
| * @param message | |
| @@ -108,50 +102,47 @@ | |
| <T> T oneOrNone(String message, T[] choices); | |
| <T> T oneOrNone(String message, Collection<T> choices); | |
| - // returned Object will never be null | |
| /** | |
| * <p> | |
| * getChoice. | |
| * </p> | |
| - * | |
| + * | |
| * @param <T> | |
| * a T object. | |
| * @param message | |
| * a {@link java.lang.String} object. | |
| * @param choices | |
| * a T object. | |
| - * @return a T object. | |
| + * @return One of {@code choices}. Can only be {@code null} if {@code choices} is empty. | |
| */ | |
| <T> T one(String message, T[] choices); | |
| <T> T one(String message, Collection<T> choices); | |
| - <T> List<T> noneOrMany(String message, Collection<T> choices); | |
| - <T> void reveal(String message, T item); | |
| - <T> void reveal(String message, T[] items); | |
| <T> void reveal(String message, Collection<T> items); | |
| - <T> List<T> many(String title, String topCaption, int min, int max, | |
| - List<T> sourceChoices); | |
| - <T> List<T> many(String title, String topCaption, int cnt, | |
| - List<T> sourceChoices); | |
| - <T> List<T> many(String title, String topCaption, int cnt, | |
| - List<T> sourceChoices, CardView c); | |
| - <T> List<T> many(String title, String topCaption, int min, int max, | |
| - List<T> sourceChoices, CardView c); | |
| + <T> List<T> many(String title, String topCaption, int cnt, List<T> sourceChoices, CardView c); | |
| + <T> List<T> many(String title, String topCaption, int min, int max, List<T> sourceChoices, CardView c); | |
| - <T> List<T> order(String title, String top, List<T> sourceChoices); | |
| <T> List<T> order(String title, String top, List<T> sourceChoices, CardView c); | |
| - <T> List<T> order(String title, String top, int remainingObjectsMin, | |
| - int remainingObjectsMax, List<T> sourceChoices, | |
| - List<T> destChoices, CardView referenceCard, | |
| - boolean sideboardingMode); | |
| + <T> List<T> order(String title, String top, int remainingObjectsMin, int remainingObjectsMax, List<T> sourceChoices, List<T> destChoices, CardView referenceCard, boolean sideboardingMode); | |
| + | |
| + /** | |
| + * Ask the user to insert an object into a list of other objects. The | |
| + * current implementation requires the user to cancel in order to get the | |
| + * new item to be the first item in the resulting list. | |
| + * | |
| + * @param title | |
| + * the dialog title. | |
| + * @param newItem | |
| + * the object to insert. | |
| + * @param oldItems | |
| + * the list of objects. | |
| + * @return A shallow copy of the list of objects, with newItem inserted. | |
| + */ | |
| <T> List<T> insertInList(String title, T newItem, List<T> oldItems); | |
| List<PaperCard> sideboard(CardPool sideboard, CardPool main); | |
| - GameEntityView chooseSingleEntityForEffect(String title, | |
| - Collection<? extends GameEntityView> optionList, | |
| - DelayedReveal delayedReveal, boolean isOptional); | |
| - void setCard(CardView card); | |
| + GameEntityView chooseSingleEntityForEffect(String title, Collection<? extends GameEntityView> optionList, DelayedReveal delayedReveal, boolean isOptional); void setCard(CardView card); | |
| void setPlayerAvatar(LobbyPlayer player, IHasIcon ihi); | |
| boolean openZones(Collection<ZoneType> zones, Map<PlayerView, Object> players); | |
| void restoreOldZones(Map<PlayerView, Object> playersToRestoreZonesFor); | |
| @@ -170,7 +161,6 @@ | |
| void setShouldAutoYield(String key, boolean autoYield); | |
| boolean shouldAlwaysAcceptTrigger(int trigger); | |
| boolean shouldAlwaysDeclineTrigger(int trigger); | |
| - boolean shouldAlwaysAskTrigger(int trigger); | |
| void setShouldAlwaysAcceptTrigger(int trigger); | |
| void setShouldAlwaysDeclineTrigger(int trigger); | |
| void setShouldAlwaysAskTrigger(int trigger); |
| Index: forge-gui/src/main/java/forge/achievement/Achievement.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui/src/main/java/forge/achievement/Achievement.java (revision 29316) | |
| +++ forge-gui/src/main/java/forge/achievement/Achievement.java (revision 29317) | |
| @@ -25,15 +25,15 @@ | |
| private int best; | |
| //use this constructor for special achievements without tiers | |
| - protected Achievement(String key0, String displayName0, String description0, String flavorText0, int defaultValue0) { | |
| + protected Achievement(final String key0, final String displayName0, final String description0, final String flavorText0, final int defaultValue0) { | |
| this(key0, displayName0, description0, defaultValue0, null, 1, null, 1, null, 1, "(" + flavorText0 + ")", 1); //pass flavor text as mythic description so it appears below description faded out | |
| } | |
| //use this constructor for regular tiered achievements | |
| - protected Achievement(String key0, String displayName0, String sharedDesc0, int defaultValue0, | |
| - String commonDesc0, int commonThreshold0, | |
| - String uncommonDesc0, int uncommonThreshold0, | |
| - String rareDesc0, int rareThreshold0, | |
| - String mythicDesc0, int mythicThreshold0) { | |
| + protected Achievement(final String key0, final String displayName0, final String sharedDesc0, final int defaultValue0, | |
| + final String commonDesc0, final int commonThreshold0, | |
| + final String uncommonDesc0, final int uncommonThreshold0, | |
| + final String rareDesc0, final int rareThreshold0, | |
| + final String mythicDesc0, final int mythicThreshold0) { | |
| key = key0; | |
| displayName = displayName0; | |
| sharedDesc = sharedDesc0; | |
| @@ -152,18 +152,18 @@ | |
| image = GuiBase.getInterface().createLayeredImage(background, ForgeConstants.CACHE_ACHIEVEMENTS_DIR + "/" + key + ".png", opacity); | |
| } | |
| - public int update(Player player) { | |
| - int value = evaluate(player, player.getGame()); | |
| + public int update(final Player player) { | |
| + final int value = evaluate(player, player.getGame()); | |
| if (checkGreaterThan) { | |
| if (value <= best) { return value; } | |
| } | |
| else if (value >= best) { return value; } | |
| - boolean hadEarnedSpecial = earnedSpecial(); | |
| - boolean hadEarnedMythic = earnedMythic(); | |
| - boolean hadEarnedRare = earnedRare(); | |
| - boolean hadEarnedUncommon = earnedUncommon(); | |
| - boolean hadEarnedCommon = earnedCommon(); | |
| + final boolean hadEarnedSpecial = earnedSpecial(); | |
| + final boolean hadEarnedMythic = earnedMythic(); | |
| + final boolean hadEarnedRare = earnedRare(); | |
| + final boolean hadEarnedUncommon = earnedUncommon(); | |
| + final boolean hadEarnedCommon = earnedCommon(); | |
| best = value; | |
| timestamp = new Date().getTime(); | |
| @@ -216,39 +216,39 @@ | |
| return best != defaultValue; | |
| } | |
| - public void saveToXml(Element el) { | |
| + public void saveToXml(final Element el) { | |
| el.setAttribute("best", String.valueOf(best)); | |
| el.setAttribute("time", String.valueOf(timestamp)); | |
| } | |
| - public void loadFromXml(Element el) { | |
| + public void loadFromXml(final Element el) { | |
| best = getIntAttribute(el, "best"); | |
| timestamp = getLongAttribute(el, "time"); | |
| best = performConversion(best, timestamp); | |
| } | |
| //give derived classes a chance to perform a conversion if needed | |
| - protected int performConversion(int value, long timestamp) { | |
| + protected int performConversion(final int value, final long timestamp) { | |
| return value; | |
| } | |
| - protected int getIntAttribute(Element el, String name) { | |
| - String value = el.getAttribute(name); | |
| + protected int getIntAttribute(final Element el, final String name) { | |
| + final String value = el.getAttribute(name); | |
| if (value.length() > 0) { | |
| try { | |
| return Integer.parseInt(value); | |
| } | |
| - catch (Exception ex) {} | |
| + catch (final Exception ex) {} | |
| } | |
| return 0; | |
| } | |
| - protected long getLongAttribute(Element el, String name) { | |
| - String value = el.getAttribute(name); | |
| + protected long getLongAttribute(final Element el, final String name) { | |
| + final String value = el.getAttribute(name); | |
| if (value.length() > 0) { | |
| try { | |
| return Long.parseLong(value); | |
| } | |
| - catch (Exception ex) {} | |
| + catch (final Exception ex) {} | |
| } | |
| return 0; | |
| } | |
| @@ -265,11 +265,11 @@ | |
| protected final String getFormattedTimestamp() { | |
| if (timestamp == 0) { return null; } | |
| - DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.getDefault()); | |
| + final DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.getDefault()); | |
| return formatter.format(new Date(timestamp)); | |
| } | |
| - public String getSubTitle(boolean includeTimestamp) { | |
| + public String getSubTitle(final boolean includeTimestamp) { | |
| if (best == defaultValue) { return null; } | |
| String subTitle; | |
| @@ -280,7 +280,7 @@ | |
| subTitle = "Best: " + best + " " + (pluralizeNoun() ? Lang.getPlural(getNoun()) : getNoun()); | |
| } | |
| if (includeTimestamp) { | |
| - String formattedTimestamp = getFormattedTimestamp(); | |
| + final String formattedTimestamp = getFormattedTimestamp(); | |
| if (formattedTimestamp != null) { | |
| subTitle += " (" + formattedTimestamp + ")"; | |
| } | |
| Index: forge-gui/src/main/java/forge/quest/QuestRewardCardDuplicate.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui/src/main/java/forge/quest/QuestRewardCardDuplicate.java (revision 29316) | |
| +++ forge-gui/src/main/java/forge/quest/QuestRewardCardDuplicate.java (revision 29317) | |
| @@ -1,15 +1,15 @@ | |
| package forge.quest; | |
| -import forge.item.PaperCard; | |
| -import forge.model.FModel; | |
| -import forge.util.ItemPool; | |
| - | |
| import java.util.ArrayList; | |
| import java.util.Collections; | |
| import java.util.List; | |
| import java.util.Map; | |
| +import forge.item.PaperCard; | |
| +import forge.model.FModel; | |
| +import forge.util.ItemPool; | |
| + | |
| -/** | |
| +/** | |
| * Allows the player to choose a duplicate copy of a currently owned card. | |
| * | |
| */ | |
| @@ -17,7 +17,7 @@ | |
| private final String description; | |
| /** | |
| - * | |
| + * | |
| * The constructor. No parameters. | |
| */ | |
| public QuestRewardCardDuplicate() { | |
| @@ -26,7 +26,7 @@ | |
| /** | |
| * The name. | |
| - * | |
| + * | |
| * @return the name | |
| */ | |
| @Override | |
| @@ -36,7 +36,7 @@ | |
| /** | |
| * The item type. | |
| - * | |
| + * | |
| * @return item type | |
| */ | |
| @Override | |
| @@ -52,14 +52,15 @@ | |
| /** | |
| * Produces a list of options to choose from, in this case, | |
| * the player's current cards. | |
| - * | |
| + * | |
| * @return a List<CardPrinted> or null if could not create a list. | |
| */ | |
| + @Override | |
| public final List<PaperCard> getChoices() { | |
| final ItemPool<PaperCard> playerCards = FModel.getQuest().getAssets().getCardPool(); | |
| if (!playerCards.isEmpty()) { // Maybe a redundant check since it's hard to win a duel without any cards... | |
| - List<PaperCard> cardChoices = new ArrayList<PaperCard>(); | |
| + final List<PaperCard> cardChoices = new ArrayList<PaperCard>(); | |
| for (final Map.Entry<PaperCard, Integer> card : playerCards) { | |
| cardChoices.add(card.getKey()); | |
| } | |
| Index: forge-gui/src/main/java/forge/match/input/InputLockUI.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui/src/main/java/forge/match/input/InputLockUI.java (revision 29316) | |
| +++ forge-gui/src/main/java/forge/match/input/InputLockUI.java (revision 29317) | |
| @@ -30,31 +30,33 @@ | |
| return null; | |
| } | |
| + @Override | |
| public void showMessageInitial() { | |
| - int ixCall = 1 + iCall.getAndIncrement(); | |
| + final int ixCall = 1 + iCall.getAndIncrement(); | |
| ThreadUtil.delay(500, new InputUpdater(ixCall)); | |
| } | |
| @Override | |
| public String toString() { | |
| - return "lockUI"; | |
| + return "lockUI"; | |
| } | |
| - | |
| + | |
| private class InputUpdater implements Runnable { | |
| final int ixCall; | |
| - | |
| + | |
| public InputUpdater(final int idxCall) { | |
| ixCall = idxCall; | |
| } | |
| - | |
| + | |
| @Override | |
| public void run() { | |
| - if ( ixCall != iCall.get() || !isActive()) // cancel the message if it's not from latest call or input is gone already | |
| + if ( ixCall != iCall.get() || !isActive()) { | |
| return; | |
| + } | |
| FThreads.invokeInEdtLater(showMessageFromEdt); | |
| } | |
| }; | |
| - | |
| + | |
| private final Runnable showMessageFromEdt = new Runnable() { | |
| @Override | |
| public void run() { | |
| @@ -67,20 +69,20 @@ | |
| return inputQueue.getInput() == this; | |
| } | |
| - protected void showMessage(String message) { | |
| + protected void showMessage(final String message) { | |
| controller.getGui().showPromptMessage(getOwner(), message); | |
| } | |
| @Override | |
| - public boolean selectCard(Card c, final List<Card> otherCardsToSelect, ITriggerEvent triggerEvent) { | |
| + public boolean selectCard(final Card c, final List<Card> otherCardsToSelect, final ITriggerEvent triggerEvent) { | |
| return false; | |
| } | |
| @Override | |
| - public boolean selectAbility(SpellAbility ab) { | |
| + public boolean selectAbility(final SpellAbility ab) { | |
| return false; | |
| } | |
| @Override | |
| - public void selectPlayer(Player player, ITriggerEvent triggerEvent) { | |
| + public void selectPlayer(final Player player, final ITriggerEvent triggerEvent) { | |
| } | |
| @Override | |
| public void selectButtonOK() { | |
| @@ -88,13 +90,13 @@ | |
| @Override | |
| public void selectButtonCancel() { | |
| //cancel auto pass for all players | |
| - for (Player player : game.getPlayers()) { | |
| + for (final Player player : game.getPlayers()) { | |
| player.getController().autoPassCancel(); | |
| } | |
| } | |
| @Override | |
| - public String getActivateAction(Card card) { | |
| + public String getActivateAction(final Card card) { | |
| return null; | |
| } | |
| } | |
| Index: forge-gui-desktop/src/main/java/forge/toolbox/FAbsolutePositioner.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/toolbox/FAbsolutePositioner.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/toolbox/FAbsolutePositioner.java (revision 29317) | |
| @@ -17,12 +17,16 @@ | |
| */ | |
| package forge.toolbox; | |
| -import javax.swing.*; | |
| -import java.awt.*; | |
| +import java.awt.Component; | |
| +import java.awt.Point; | |
| +import java.awt.Rectangle; | |
| +import javax.swing.JLayeredPane; | |
| +import javax.swing.JPanel; | |
| + | |
| /** | |
| * Utility to manage absolutely positioned components | |
| - * | |
| + * | |
| */ | |
| // Currently used only once, in top level UI, with layering already in place. | |
| @@ -36,55 +40,55 @@ | |
| panel.setOpaque(false); | |
| panel.setLayout(null); | |
| } | |
| - | |
| + | |
| - public void initialize(JLayeredPane parent, Integer index) { | |
| + public void initialize(final JLayeredPane parent, final Integer index) { | |
| parent.add(panel, index); | |
| } | |
| - | |
| + | |
| - public void containerResized(Rectangle mainBounds) { | |
| + public void containerResized(final Rectangle mainBounds) { | |
| panel.setBounds(mainBounds); | |
| panel.validate(); | |
| } | |
| - | |
| + | |
| /** | |
| * Show the given component absolutely positioned at the given screen location | |
| - * | |
| + * | |
| * @param comp   Component to absolutely position | |
| * @param screenX   Screen X location to show component at | |
| * @param screenY   Screen Y location to show component at | |
| */ | |
| - public void show(Component comp, int screenX, int screenY) { | |
| + public void show(final Component comp, final int screenX, final int screenY) { | |
| if (comp.getParent() != panel) { | |
| comp.setVisible(false); | |
| panel.add(comp); | |
| } | |
| - Point panelScreenLocation = panel.getLocationOnScreen(); | |
| + final Point panelScreenLocation = panel.getLocationOnScreen(); | |
| comp.setLocation(screenX - panelScreenLocation.x, screenY - panelScreenLocation.y); | |
| comp.setVisible(true); | |
| } | |
| - | |
| + | |
| /** | |
| * Show the given component absolutely positioned relative to another component | |
| - * | |
| + * | |
| * @param comp   Component to absolutely position | |
| * @param relativeToComp   Component to position relative to | |
| * @param offsetX   X offset of relative location | |
| * @param offsetY   Y offset of relative location | |
| */ | |
| - public void show(Component comp, Component relativeToComp, int offsetX, int offsetY) { | |
| - Point screenLocation = relativeToComp.getLocationOnScreen(); | |
| + public void show(final Component comp, final Component relativeToComp, final int offsetX, final int offsetY) { | |
| + final Point screenLocation = relativeToComp.getLocationOnScreen(); | |
| show(comp, screenLocation.x + offsetX, screenLocation.y + offsetY); | |
| } | |
| - | |
| + | |
| /** | |
| * Hide given absolutely positioned component | |
| - * | |
| + * | |
| * @param comp   Component to hide | |
| */ | |
| - public void hide(Component comp) { | |
| + public void hide(final Component comp) { | |
| panel.remove(comp); | |
| } | |
| - | |
| + | |
| /** | |
| * Hide all absolutely positioned components | |
| */ | |
| Index: forge-gui/src/main/java/forge/properties/ForgeProfileProperties.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui/src/main/java/forge/properties/ForgeProfileProperties.java (revision 29316) | |
| +++ forge-gui/src/main/java/forge/properties/ForgeProfileProperties.java (revision 29317) | |
| @@ -6,12 +6,12 @@ | |
| * 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 <http://www.gnu.org/licenses/>. | |
| */ | |
| @@ -40,7 +40,7 @@ | |
| private static String cacheDir; | |
| private static String cardPicsDir; | |
| private static Map<String, String> cardPicsSubDirs; | |
| - private static int serverPort; | |
| + private static int serverPort; | |
| private static final String USER_DIR_KEY = "userDir"; | |
| private static final String CACHE_DIR_KEY = "cacheDir"; | |
| @@ -52,22 +52,18 @@ | |
| //prevent initializing static class | |
| } | |
| - public static void init() { | |
| - } | |
| - | |
| public static void load() { | |
| - Properties props = new Properties(); | |
| - File propFile = new File(ForgeConstants.PROFILE_FILE); | |
| + final Properties props = new Properties(); | |
| + final File propFile = new File(ForgeConstants.PROFILE_FILE); | |
| try { | |
| if (propFile.canRead()) { | |
| props.load(new FileInputStream(propFile)); | |
| } | |
| - } | |
| - catch (IOException e) { | |
| + } catch (final IOException e) { | |
| System.err.println("error while reading from profile properties file"); | |
| } | |
| - Pair<String, String> defaults = getDefaultDirs(); | |
| + final Pair<String, String> defaults = getDefaultDirs(); | |
| userDir = getDir(props, USER_DIR_KEY, defaults.getLeft()); | |
| cacheDir = getDir(props, CACHE_DIR_KEY, defaults.getRight()); | |
| cardPicsDir = getDir(props, CARD_PICS_DIR_KEY, cacheDir + "pics" + File.separator + "cards" + File.separator); | |
| @@ -83,7 +79,7 @@ | |
| public static String getUserDir() { | |
| return userDir; | |
| } | |
| - public static void setUserDir(String userDir0) { | |
| + public static void setUserDir(final String userDir0) { | |
| userDir = userDir0; | |
| save(); | |
| } | |
| @@ -91,8 +87,8 @@ | |
| public static String getCacheDir() { | |
| return cacheDir; | |
| } | |
| - public static void setCacheDir(String cacheDir0) { | |
| - int idx = cardPicsDir.indexOf(cacheDir); //ensure card pics directory is updated too if within cache directory | |
| + public static void setCacheDir(final String cacheDir0) { | |
| + final int idx = cardPicsDir.indexOf(cacheDir); //ensure card pics directory is updated too if within cache directory | |
| if (idx != -1) { | |
| cardPicsDir = cacheDir0 + cardPicsDir.substring(idx + cacheDir.length()); | |
| } | |
| @@ -103,8 +99,8 @@ | |
| public static String getCardPicsDir() { | |
| return cardPicsDir; | |
| } | |
| - public static void setCardPicsDir(String cardPicsDir0) { | |
| + public static void setCardPicsDir(final String cardPicsDir0) { | |
| - cardPicsDir = cardPicsDir0; | |
| + cardPicsDir = cardPicsDir0; | |
| save(); | |
| } | |
| @@ -116,28 +112,29 @@ | |
| return serverPort; | |
| } | |
| - private static Map<String, String> getMap(Properties props, String propertyKey) { | |
| - String strMap = props.getProperty(propertyKey, "").trim(); | |
| + private static Map<String, String> getMap(final Properties props, final String propertyKey) { | |
| + final String strMap = props.getProperty(propertyKey, "").trim(); | |
| return FileSection.parseToMap(strMap, "->", "|"); | |
| } | |
| - private static int getInt(Properties props, String propertyKey, int defaultValue) { | |
| - String strValue = props.getProperty(propertyKey, "").trim(); | |
| - if ( StringUtils.isNotBlank(strValue) && StringUtils.isNumeric(strValue) ) | |
| + private static int getInt(final Properties props, final String propertyKey, final int defaultValue) { | |
| + final String strValue = props.getProperty(propertyKey, "").trim(); | |
| + if (StringUtils.isNotBlank(strValue) && StringUtils.isNumeric(strValue)) { | |
| return Integer.parseInt(strValue); | |
| + } | |
| return defaultValue; | |
| - } | |
| + } | |
| - private static String getDir(Properties props, String propertyKey, String defaultVal) { | |
| + private static String getDir(final Properties props, final String propertyKey, final String defaultVal) { | |
| String retDir = props.getProperty(propertyKey, defaultVal).trim(); | |
| if (retDir.isEmpty()) { | |
| // use default if dir is "defined" as an empty string in the properties file | |
| retDir = defaultVal; | |
| } | |
| - | |
| + | |
| // canonicalize | |
| retDir = new File(retDir).getAbsolutePath(); | |
| - | |
| + | |
| // ensure path ends in a slash | |
| if (File.separatorChar == retDir.charAt(retDir.length() - 1)) { | |
| return retDir; | |
| @@ -148,18 +145,18 @@ | |
| // returns a pair <userDir, cacheDir> | |
| private static Pair<String, String> getDefaultDirs() { | |
| if (!GuiBase.getInterface().isRunningOnDesktop()) { //special case for mobile devices | |
| - String assetsDir = ForgeConstants.ASSETS_DIR; | |
| + final String assetsDir = ForgeConstants.ASSETS_DIR; | |
| return Pair.of(assetsDir + "data" + File.separator, assetsDir + "cache" + File.separator); | |
| } | |
| - String osName = System.getProperty("os.name"); | |
| - String homeDir = System.getProperty("user.home"); | |
| + final String osName = System.getProperty("os.name"); | |
| + final String homeDir = System.getProperty("user.home"); | |
| if (StringUtils.isEmpty(osName) || StringUtils.isEmpty(homeDir)) { | |
| throw new RuntimeException("cannot determine OS and user home directory"); | |
| } | |
| - | |
| + | |
| - String fallbackDataDir = String.format("%s/.forge", homeDir); | |
| + final String fallbackDataDir = String.format("%s/.forge", homeDir); | |
| if (StringUtils.containsIgnoreCase(osName, "windows")) { | |
| // the split between appdata and localappdata on windows is relatively recent. If | |
| @@ -179,7 +176,7 @@ | |
| } | |
| else if (StringUtils.containsIgnoreCase(osName, "mac os x")) { | |
| return Pair.of(String.format("%s/Library/Application Support/Forge", homeDir), | |
| - String.format("%s/Library/Caches/Forge", homeDir)); | |
| + String.format("%s/Library/Caches/Forge", homeDir)); | |
| } | |
| // Linux and everything else | |
| @@ -187,13 +184,13 @@ | |
| } | |
| private static void save() { | |
| - Pair<String, String> defaults = getDefaultDirs(); | |
| - String defaultUserDir = defaults.getLeft() + File.separator; | |
| - String defaultCacheDir = defaults.getRight() + File.separator; | |
| - String defaultCardPicsDir = defaultCacheDir + "pics" + File.separator + "cards" + File.separator; | |
| + final Pair<String, String> defaults = getDefaultDirs(); | |
| + final String defaultUserDir = defaults.getLeft() + File.separator; | |
| + final String defaultCacheDir = defaults.getRight() + File.separator; | |
| + final String defaultCardPicsDir = defaultCacheDir + "pics" + File.separator + "cards" + File.separator; | |
| //only append values that aren't equal to defaults | |
| - StringBuilder sb = new StringBuilder(); | |
| + final StringBuilder sb = new StringBuilder(); | |
| if (!userDir.equals(defaultUserDir)) { //ensure backslashes are escaped | |
| sb.append(USER_DIR_KEY + "=" + userDir.replace("\\", "\\\\") + "\n"); | |
| } | |
| @@ -205,8 +202,8 @@ | |
| } | |
| if (cardPicsSubDirs.size() > 0) { | |
| sb.append(CARD_PICS_SUB_DIRS_KEY + "="); | |
| - boolean needDelim = false; | |
| - for (Map.Entry<String, String> entry : cardPicsSubDirs.entrySet()) { | |
| + final boolean needDelim = false; | |
| + for (final Map.Entry<String, String> entry : cardPicsSubDirs.entrySet()) { | |
| if (needDelim) { | |
| sb.append("|"); | |
| } | |
| @@ -222,12 +219,11 @@ | |
| } | |
| else { //delete file if empty | |
| try { | |
| - File file = new File(ForgeConstants.PROFILE_FILE); | |
| + final File file = new File(ForgeConstants.PROFILE_FILE); | |
| if (file.exists()) { | |
| file.delete(); | |
| } | |
| - } | |
| - catch (Exception e) { | |
| + } catch (final Exception e) { | |
| e.printStackTrace(); | |
| } | |
| } | |
| Index: forge-gui/src/main/java/forge/match/GameLobby.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui/src/main/java/forge/match/GameLobby.java (revision 29316) | |
| +++ forge-gui/src/main/java/forge/match/GameLobby.java (revision 29317) | |
| @@ -167,10 +167,10 @@ | |
| } | |
| return NameGenerator.getRandomName("Any", "Any", names); | |
| } | |
| - protected final String localName() { | |
| + protected final static String localName() { | |
| return FModel.getPreferences().getPref(FPref.PLAYER_NAME); | |
| } | |
| - protected final int[] localAvatarIndices() { | |
| + protected final static int[] localAvatarIndices() { | |
| final String[] sAvatars = FModel.getPreferences().getPref(FPref.UI_AVATARS).split(","); | |
| final int[] result = new int[sAvatars.length]; | |
| for (int i = 0; i < sAvatars.length; i++) { | |
| @@ -323,14 +323,14 @@ | |
| } | |
| } | |
| - boolean checkLegality = FModel.getPreferences().getPrefBoolean(FPref.ENFORCE_DECK_LEGALITY); | |
| + final boolean checkLegality = FModel.getPreferences().getPrefBoolean(FPref.ENFORCE_DECK_LEGALITY); | |
| //Auto-generated decks don't need to be checked here | |
| //Commander deck replaces regular deck and is checked later | |
| if (checkLegality && autoGenerateVariant == null && !isCommanderMatch) { | |
| for (final LobbySlot slot : activeSlots) { | |
| final String name = slot.getName(); | |
| - String errMsg = GameType.Constructed.getDeckFormat().getDeckConformanceProblem(slot.getDeck()); | |
| + final String errMsg = GameType.Constructed.getDeckFormat().getDeckConformanceProblem(slot.getDeck()); | |
| if (null != errMsg) { | |
| SOptionPane.showErrorDialog(name + "'s deck " + errMsg, "Invalid Deck"); | |
| return; | |
| @@ -374,7 +374,7 @@ | |
| if (isCommanderMatch) { | |
| final GameType commanderGameType = isTinyLeadersMatch ? GameType.TinyLeaders : GameType.Commander; | |
| if (checkLegality) { | |
| - String errMsg = commanderGameType.getDeckFormat().getDeckConformanceProblem(deck); | |
| + final String errMsg = commanderGameType.getDeckFormat().getDeckConformanceProblem(deck); | |
| if (null != errMsg) { | |
| SOptionPane.showErrorDialog(name + "'s deck " + errMsg, "Invalid " + commanderGameType + " Deck"); | |
| return; | |
| @@ -400,7 +400,7 @@ | |
| || (variantTypes.contains(GameType.Archenemy) && isArchenemy)) { | |
| final CardPool schemePool = deck.get(DeckSection.Schemes); | |
| if (checkLegality) { | |
| - String errMsg = DeckFormat.getSchemeSectionConformanceProblem(schemePool); | |
| + final String errMsg = DeckFormat.getSchemeSectionConformanceProblem(schemePool); | |
| if (null != errMsg) { | |
| SOptionPane.showErrorDialog(name + "'s deck " + errMsg, "Invalid Scheme Deck"); | |
| return; | |
| @@ -413,7 +413,7 @@ | |
| if (variantTypes.contains(GameType.Planechase)) { | |
| final CardPool planePool = deck.get(DeckSection.Planes); | |
| if (checkLegality) { | |
| - String errMsg = DeckFormat.getPlaneSectionConformanceProblem(planePool); | |
| + final String errMsg = DeckFormat.getPlaneSectionConformanceProblem(planePool); | |
| if (null != errMsg) { | |
| SOptionPane.showErrorDialog(name + "'s deck " + errMsg, "Invalid Planar Deck"); | |
| return; | |
| Index: forge-gui-desktop/src/main/java/forge/screens/home/quest/VSubmenuQuestData.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/home/quest/VSubmenuQuestData.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/home/quest/VSubmenuQuestData.java (revision 29317) | |
| @@ -1,5 +1,20 @@ | |
| package forge.screens.home.quest; | |
| +import java.awt.Component; | |
| +import java.awt.event.ActionEvent; | |
| +import java.awt.event.ActionListener; | |
| +import java.util.HashMap; | |
| +import java.util.Map; | |
| + | |
| +import javax.swing.JList; | |
| +import javax.swing.JPanel; | |
| +import javax.swing.SwingConstants; | |
| +import javax.swing.plaf.basic.BasicComboBoxRenderer; | |
| + | |
| +import net.miginfocom.swing.MigLayout; | |
| + | |
| +import org.apache.commons.lang3.text.WordUtils; | |
| + | |
| import forge.card.MagicColor; | |
| import forge.deck.Deck; | |
| import forge.deck.DeckGroup; | |
| @@ -17,21 +32,15 @@ | |
| import forge.screens.home.EMenuGroup; | |
| import forge.screens.home.IVSubmenu; | |
| import forge.screens.home.VHomeUI; | |
| -import forge.toolbox.*; | |
| +import forge.toolbox.FCheckBox; | |
| +import forge.toolbox.FComboBoxWrapper; | |
| +import forge.toolbox.FLabel; | |
| +import forge.toolbox.FRadioButton; | |
| +import forge.toolbox.FScrollPane; | |
| +import forge.toolbox.FSkin; | |
| +import forge.toolbox.JXButtonPanel; | |
| import forge.util.storage.IStorage; | |
| -import net.miginfocom.swing.MigLayout; | |
| -import org.apache.commons.lang3.text.WordUtils; | |
| - | |
| -import javax.swing.*; | |
| -import javax.swing.plaf.basic.BasicComboBoxRenderer; | |
| - | |
| -import java.awt.*; | |
| -import java.awt.event.ActionEvent; | |
| -import java.awt.event.ActionListener; | |
| -import java.util.HashMap; | |
| -import java.util.Map; | |
| - | |
| /** | |
| * Assembles Swing components of quest data submenu singleton. | |
| * | |
| @@ -47,8 +56,8 @@ | |
| /** */ | |
| private final FLabel lblTitle = new FLabel.Builder() | |
| - .text("Load Quest Data").fontAlign(SwingConstants.CENTER) | |
| - .opaque(true).fontSize(16).build(); | |
| + .text("Load Quest Data").fontAlign(SwingConstants.CENTER) | |
| + .opaque(true).fontSize(16).build(); | |
| private final FLabel lblTitleNew = new FLabel.Builder().text("Start a new Quest") | |
| .opaque(true).fontSize(16).build(); | |
| @@ -67,7 +76,7 @@ | |
| private final FRadioButton radHard = new FRadioButton("Hard"); | |
| private final FRadioButton radExpert = new FRadioButton("Expert"); | |
| private final FCheckBox boxFantasy = new FCheckBox("Fantasy Mode"); | |
| - private final FCheckBox boxCompleteSet = new FCheckBox("Start with all cards in selected sets"); | |
| + private final FCheckBox boxCompleteSet = new FCheckBox("Start with all cards in selected sets"); | |
| private final FLabel lblStartingWorld = new FLabel.Builder().text("Starting world:").build(); | |
| private final FComboBoxWrapper<QuestWorld> cbxStartingWorld = new FComboBoxWrapper<QuestWorld>(); | |
| @@ -115,8 +124,8 @@ | |
| private final ActionListener alStartingPool = new ActionListener() { | |
| @SuppressWarnings("incomplete-switch") | |
| @Override | |
| - public void actionPerformed(ActionEvent e) { | |
| - StartingPoolType newVal = getStartingPoolType(); | |
| + public void actionPerformed(final ActionEvent e) { | |
| + final StartingPoolType newVal = getStartingPoolType(); | |
| lblUnrestricted.setVisible(newVal == StartingPoolType.Complete); | |
| lblPreconDeck.setVisible(newVal == StartingPoolType.Precon); | |
| @@ -128,23 +137,23 @@ | |
| btnDefineCustomFormat.setVisible(newVal == StartingPoolType.CustomFormat); | |
| - boolean usesDeckList = newVal == StartingPoolType.SealedDeck || newVal == StartingPoolType.DraftDeck || newVal == StartingPoolType.Cube; | |
| + final boolean usesDeckList = newVal == StartingPoolType.SealedDeck || newVal == StartingPoolType.DraftDeck || newVal == StartingPoolType.Cube; | |
| lblCustomDeck.setVisible(usesDeckList); | |
| cbxCustomDeck.setVisible(usesDeckList); | |
| if (usesDeckList) { | |
| cbxCustomDeck.removeAllItems(); | |
| - CardCollections decks = FModel.getDecks(); | |
| + final CardCollections decks = FModel.getDecks(); | |
| switch (newVal) { | |
| - case SealedDeck: | |
| + case SealedDeck: | |
| - for (DeckGroup d : decks.getSealed()) { cbxCustomDeck.addItem(d.getHumanDeck()); } | |
| + for (final DeckGroup d : decks.getSealed()) { cbxCustomDeck.addItem(d.getHumanDeck()); } | |
| - break; | |
| - case DraftDeck: | |
| + break; | |
| + case DraftDeck: | |
| - for (DeckGroup d : decks.getDraft()) { cbxCustomDeck.addItem(d.getHumanDeck()); } | |
| + for (final DeckGroup d : decks.getDraft()) { cbxCustomDeck.addItem(d.getHumanDeck()); } | |
| - break; | |
| - case Cube: | |
| + break; | |
| + case Cube: | |
| - for (Deck d : decks.getCubes()) { cbxCustomDeck.addItem(d); } | |
| + for (final Deck d : decks.getCubes()) { cbxCustomDeck.addItem(d); } | |
| - break; | |
| + break; | |
| } | |
| } | |
| } | |
| @@ -153,8 +162,8 @@ | |
| /* Listeners */ | |
| private final ActionListener alPrizesPool = new ActionListener() { | |
| @Override | |
| - public void actionPerformed(ActionEvent e) { | |
| - StartingPoolType newVal = getPrizedPoolType(); | |
| + public void actionPerformed(final ActionEvent e) { | |
| + final StartingPoolType newVal = getPrizedPoolType(); | |
| lblPrizeUnrestricted.setVisible(newVal == StartingPoolType.Complete); | |
| cboAllowUnlocks.setVisible(newVal != StartingPoolType.Complete); | |
| @@ -168,7 +177,7 @@ | |
| /* Listeners */ | |
| private final ActionListener alStartingWorld = new ActionListener() { | |
| @Override | |
| - public void actionPerformed(ActionEvent e) { | |
| + public void actionPerformed(final ActionEvent e) { | |
| updateEnabledFormats(); | |
| } | |
| }; | |
| @@ -205,7 +214,7 @@ | |
| difficultyPanel.add(radExpert, difficulty_constraints); | |
| radEasy.setSelected(true); | |
| - boxCompleteSet.setToolTipText("You will start the quest with 4 of each card in the sets you have selected."); | |
| + boxCompleteSet.setToolTipText("You will start the quest with 4 of each card in the sets you have selected."); | |
| cbxStartingPool.addItem(StartingPoolType.Complete); | |
| cbxStartingPool.addItem(StartingPoolType.Rotating); | |
| @@ -226,7 +235,7 @@ | |
| cbxPrizedCards.addItem(StartingPoolType.CustomFormat); | |
| cbxPrizedCards.addActionListener(alPrizesPool); | |
| - for (GameFormat gf : FModel.getFormats().getOrderedList()) { | |
| + for (final GameFormat gf : FModel.getFormats().getOrderedList()) { | |
| cbxFormat.addItem(gf); | |
| cbxPrizeFormat.addItem(gf); | |
| } | |
| @@ -241,7 +250,7 @@ | |
| cbxPreferredColor.addItem(MagicColor.Constant.GREEN + stringBias); | |
| cbxPreferredColor.addItem(MagicColor.Constant.COLORLESS + stringBias); | |
| - for (QuestWorld qw : FModel.getWorlds()) { | |
| + for (final QuestWorld qw : FModel.getWorlds()) { | |
| cbxStartingWorld.addItem(qw); | |
| } | |
| // Default to 'Main world' | |
| @@ -253,13 +262,13 @@ | |
| cboAllowUnlocks.setSelected(true); | |
| final Map<String, String> preconDescriptions = new HashMap<String, String>(); | |
| - IStorage<PreconDeck> preconDecks = QuestController.getPrecons(); | |
| + final IStorage<PreconDeck> preconDecks = QuestController.getPrecons(); | |
| - for (PreconDeck preconDeck : preconDecks) { | |
| + for (final PreconDeck preconDeck : preconDecks) { | |
| if (QuestController.getPreconDeals(preconDeck).getMinWins() > 0) { | |
| continue; | |
| } | |
| - String name = preconDeck.getName(); | |
| + final String name = preconDeck.getName(); | |
| cbxPreconDeck.addItem(name); | |
| String description = preconDeck.getDescription(); | |
| description = "<html>" + WordUtils.wrap(description, 40, "<br>", false) + "</html>"; | |
| @@ -273,11 +282,11 @@ | |
| @SuppressWarnings("rawtypes") | |
| @Override | |
| public Component getListCellRendererComponent( | |
| - JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { | |
| - Component defaultComponent = | |
| + final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) { | |
| + final Component defaultComponent = | |
| super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); | |
| if (-1 < index && null != value) { | |
| - String val = (String) value; | |
| + final String val = (String) value; | |
| list.setToolTipText(preconDescriptions.get(val)); | |
| } | |
| return defaultComponent; | |
| @@ -287,21 +296,21 @@ | |
| // Fantasy box enabled by Default | |
| boxFantasy.setSelected(true); | |
| boxFantasy.setEnabled(true); | |
| - boxCompleteSet.setEnabled(true); | |
| + boxCompleteSet.setEnabled(true); | |
| cbxPreferredColor.setEnabled(true); | |
| pnlOptions.setOpaque(false); | |
| pnlOptions.setLayout(new MigLayout("insets 0, gap 10px, fillx, wrap 2")); | |
| - JPanel pnlDifficultyMode = new JPanel(new MigLayout("insets 0, gap 1%, flowy")); | |
| + final JPanel pnlDifficultyMode = new JPanel(new MigLayout("insets 0, gap 1%, flowy")); | |
| pnlDifficultyMode.add(difficultyPanel, "gapright 4%"); | |
| pnlDifficultyMode.add(boxFantasy, difficulty_constraints + ", gapright 4%"); | |
| pnlDifficultyMode.setOpaque(false); | |
| pnlOptions.add(pnlDifficultyMode, "w 40%"); | |
| - JPanel pnlRestrictions = new JPanel(); | |
| + final JPanel pnlRestrictions = new JPanel(); | |
| final String constraints = "h 27px!, "; | |
| final String lblWidth = "w 40%, "; | |
| final String hidemode = "hidemode 3, "; | |
| @@ -340,7 +349,7 @@ | |
| pnlRestrictions.add(lblPrizeUnrestricted, constraints + hidemode + "spanx 2"); | |
| pnlRestrictions.add(cboAllowUnlocks, constraints + "spanx 2, ax right"); | |
| - pnlRestrictions.add(boxCompleteSet, constraints + "spanx 2, ax right"); | |
| + pnlRestrictions.add(boxCompleteSet, constraints + "spanx 2, ax right"); | |
| pnlRestrictions.add(lblPreferredColor, constraints + lblWidthStart); | |
| @@ -349,7 +358,7 @@ | |
| pnlRestrictions.add(lblStartingWorld, constraints + lblWidthStart); | |
| cbxStartingWorld.addTo(pnlRestrictions, constraints + cboWidthStart); | |
| -// cboAllowUnlocks.setOpaque(false); | |
| + // cboAllowUnlocks.setOpaque(false); | |
| pnlRestrictions.setOpaque(false); | |
| pnlOptions.add(pnlRestrictions, "pushx, ay top"); | |
| @@ -442,7 +451,7 @@ | |
| * @see forge.gui.framework.IVDoc#setParentCell(forge.gui.framework.DragCell) | |
| */ | |
| @Override | |
| - public void setParentCell(DragCell cell0) { | |
| + public void setParentCell(final DragCell cell0) { | |
| this.parentCell = cell0; | |
| } | |
| @@ -472,7 +481,7 @@ | |
| } | |
| public Deck getSelectedDeck() { | |
| - Object sel = cbxCustomDeck.getSelectedItem(); | |
| + final Object sel = cbxCustomDeck.getSelectedItem(); | |
| return sel instanceof Deck ? (Deck) sel : null; | |
| } | |
| @@ -481,12 +490,12 @@ | |
| } | |
| public StartingPoolType getStartingPoolType() { | |
| - return (StartingPoolType) cbxStartingPool.getSelectedItem(); | |
| + return cbxStartingPool.getSelectedItem(); | |
| } | |
| public StartingPoolType getPrizedPoolType() { | |
| - Object v = cbxPrizedCards.getSelectedItem(); | |
| + final Object v = cbxPrizedCards.getSelectedItem(); | |
| - return v instanceof StartingPoolType ? (StartingPoolType) v : null; | |
| + return v instanceof StartingPoolType ? (StartingPoolType) v : null; | |
| } | |
| public String getStartingWorldName() { | |
| @@ -496,10 +505,10 @@ | |
| public boolean isFantasy() { | |
| return boxFantasy.isSelected(); | |
| } | |
| - | |
| - public boolean startWithCompleteSet() { | |
| - return boxCompleteSet.isSelected(); | |
| - } | |
| + | |
| + public boolean startWithCompleteSet() { | |
| + return boxCompleteSet.isSelected(); | |
| + } | |
| public boolean randomizeColorDistribution() { | |
| return stringRandomizedDistribution.equals(cbxPreferredColor.getSelectedItem()); | |
| @@ -514,11 +523,11 @@ | |
| } | |
| public GameFormat getRotatingFormat() { | |
| - return (GameFormat) cbxFormat.getSelectedItem(); | |
| + return cbxFormat.getSelectedItem(); | |
| } | |
| public GameFormat getPrizedRotatingFormat() { | |
| - return (GameFormat) cbxPrizeFormat.getSelectedItem(); | |
| + return cbxPrizeFormat.getSelectedItem(); | |
| } | |
| public FLabel getBtnCustomFormat() { | |
| Index: forge-gui-desktop/src/main/java/forge/toolbox/FTextEditor.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/toolbox/FTextEditor.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/toolbox/FTextEditor.java (revision 29317) | |
| @@ -1,51 +1,52 @@ | |
| package forge.toolbox; | |
| -import forge.gui.MouseUtil; | |
| -import forge.toolbox.FSkin.SkinnedScrollPane; | |
| -import forge.toolbox.FSkin.SkinnedTextArea; | |
| +import java.awt.Cursor; | |
| +import java.awt.Insets; | |
| +import java.awt.event.KeyAdapter; | |
| +import java.awt.event.KeyEvent; | |
| import javax.swing.border.Border; | |
| import javax.swing.event.DocumentListener; | |
| -import java.awt.*; | |
| -import java.awt.event.KeyAdapter; | |
| -import java.awt.event.KeyEvent; | |
| +import forge.gui.MouseUtil; | |
| +import forge.toolbox.FSkin.SkinnedScrollPane; | |
| +import forge.toolbox.FSkin.SkinnedTextArea; | |
| @SuppressWarnings("serial") | |
| public class FTextEditor extends SkinnedScrollPane { | |
| - private final SkinnedTextArea tarEditor; | |
| - private final FUndoManager undoManager; | |
| - | |
| - public FTextEditor() { | |
| - tarEditor = new SkinnedTextArea(); | |
| - tarEditor.setFont(FSkin.getFixedFont(16)); | |
| - tarEditor.setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT)); | |
| - tarEditor.setBackground(FSkin.getColor(FSkin.Colors.CLR_THEME2)); | |
| - tarEditor.setCaretColor(FSkin.getColor(FSkin.Colors.CLR_TEXT)); | |
| + private final SkinnedTextArea tarEditor; | |
| + private final FUndoManager undoManager; | |
| + | |
| + public FTextEditor() { | |
| + tarEditor = new SkinnedTextArea(); | |
| + tarEditor.setFont(FSkin.getFixedFont(16)); | |
| + tarEditor.setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT)); | |
| + tarEditor.setBackground(FSkin.getColor(FSkin.Colors.CLR_THEME2)); | |
| + tarEditor.setCaretColor(FSkin.getColor(FSkin.Colors.CLR_TEXT)); | |
| undoManager = new FUndoManager(tarEditor); | |
| - | |
| + | |
| tarEditor.setMargin(new Insets(3, 3, 3, 3)); | |
| tarEditor.addKeyListener(new KeyAdapter() { | |
| - @Override | |
| + @Override | |
| - public void keyPressed(KeyEvent e) { | |
| + public void keyPressed(final KeyEvent e) { | |
| - if (e.isControlDown() && !e.isMetaDown()) { | |
| - switch (e.getKeyCode()) { | |
| - case KeyEvent.VK_Z: | |
| - if (e.isShiftDown()) { | |
| - undoManager.redo(); | |
| - } | |
| - else { | |
| - undoManager.undo(); | |
| - } | |
| - break; | |
| - case KeyEvent.VK_Y: | |
| - if (!e.isShiftDown()) { | |
| - undoManager.redo(); | |
| - } | |
| - break; | |
| - } | |
| - } | |
| + if (e.isControlDown() && !e.isMetaDown()) { | |
| + switch (e.getKeyCode()) { | |
| + case KeyEvent.VK_Z: | |
| + if (e.isShiftDown()) { | |
| + undoManager.redo(); | |
| + } | |
| + else { | |
| + undoManager.undo(); | |
| + } | |
| + break; | |
| + case KeyEvent.VK_Y: | |
| + if (!e.isShiftDown()) { | |
| + undoManager.redo(); | |
| + } | |
| + break; | |
| + } | |
| + } | |
| } | |
| }); | |
| @@ -56,37 +57,37 @@ | |
| if (this.isEditable()) { | |
| MouseUtil.setComponentCursor(tarEditor, Cursor.TEXT_CURSOR); | |
| } | |
| - } | |
| - | |
| - //Mapped functions to JTextArea | |
| - @Override | |
| - public boolean isEnabled() { | |
| - return tarEditor.isEnabled(); | |
| - } | |
| - @Override | |
| + } | |
| + | |
| + //Mapped functions to JTextArea | |
| + @Override | |
| + public boolean isEnabled() { | |
| + return tarEditor.isEnabled(); | |
| + } | |
| + @Override | |
| - public void setEnabled(boolean enabled) { | |
| + public void setEnabled(final boolean enabled) { | |
| - tarEditor.setEnabled(enabled); | |
| - } | |
| - public String getText() { | |
| - return tarEditor.getText(); | |
| - } | |
| + tarEditor.setEnabled(enabled); | |
| + } | |
| + public String getText() { | |
| + return tarEditor.getText(); | |
| + } | |
| - public void setText(String t) { | |
| + public void setText(final String t) { | |
| - tarEditor.setText(t); | |
| - undoManager.discardAllEdits(); | |
| - } | |
| - public boolean isEditable() { | |
| - return tarEditor.isEditable(); | |
| - } | |
| + tarEditor.setText(t); | |
| + undoManager.discardAllEdits(); | |
| + } | |
| + public boolean isEditable() { | |
| + return tarEditor.isEditable(); | |
| + } | |
| - public void setEditable(boolean b) { | |
| + public void setEditable(final boolean b) { | |
| - tarEditor.setEditable(b); | |
| - } | |
| - public int getCaretPosition() { | |
| - return tarEditor.getCaretPosition(); | |
| - } | |
| + tarEditor.setEditable(b); | |
| + } | |
| + public int getCaretPosition() { | |
| + return tarEditor.getCaretPosition(); | |
| + } | |
| - public void setCaretPosition(int position) { | |
| + public void setCaretPosition(final int position) { | |
| - tarEditor.setCaretPosition(position); | |
| - } | |
| + tarEditor.setCaretPosition(position); | |
| + } | |
| - public void addDocumentListener(DocumentListener listener) { | |
| + public void addDocumentListener(final DocumentListener listener) { | |
| - tarEditor.getDocument().addDocumentListener(listener); | |
| - } | |
| + tarEditor.getDocument().addDocumentListener(listener); | |
| + } | |
| } | |
| Index: forge-gui-desktop/src/main/java/forge/toolbox/FComboBoxPanel.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/toolbox/FComboBoxPanel.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/toolbox/FComboBoxPanel.java (revision 29317) | |
| @@ -1,13 +1,13 @@ | |
| package forge.toolbox; | |
| -import forge.toolbox.FSkin.SkinnedLabel; | |
| +import java.awt.FlowLayout; | |
| +import java.util.ArrayList; | |
| -import javax.swing.*; | |
| +import javax.swing.JPanel; | |
| -import java.awt.*; | |
| -import java.util.ArrayList; | |
| +import forge.toolbox.FSkin.SkinnedLabel; | |
| -/** | |
| +/** | |
| * Panel with combo box and caption (either FComboBoxWrapper or FComboBoxPanel should be used instead of FComboBox so skinning works) | |
| * | |
| */ | |
| @@ -17,57 +17,57 @@ | |
| private static final ArrayList<FComboBoxPanel<?>> allPanels = new ArrayList<FComboBoxPanel<?>>(); | |
| public static void refreshAllSkins() { | |
| - for (FComboBoxPanel<?> panel : allPanels) { | |
| + for (final FComboBoxPanel<?> panel : allPanels) { | |
| panel.refreshSkin(); | |
| } | |
| } | |
| private String comboBoxCaption = ""; | |
| private FComboBox<E> comboBox = null; | |
| - | |
| + | |
| - public FComboBoxPanel(String comboBoxCaption) { | |
| + public FComboBoxPanel(final String comboBoxCaption) { | |
| super(); | |
| this.comboBoxCaption = comboBoxCaption; | |
| applyLayoutAndSkin(); | |
| allPanels.add(this); | |
| } | |
| - | |
| + | |
| - public void setComboBox(FComboBox<E> comboBox, E selectedItem) { | |
| + public void setComboBox(final FComboBox<E> comboBox, final E selectedItem) { | |
| removeExistingComboBox(); | |
| this.comboBox = comboBox; | |
| - this.comboBox.setSelectedItem(selectedItem); | |
| - setComboBoxLayout(); | |
| + this.comboBox.setSelectedItem(selectedItem); | |
| + setComboBoxLayout(); | |
| } | |
| - | |
| + | |
| private void removeExistingComboBox() { | |
| if (this.comboBox != null) { | |
| this.remove(this.comboBox); | |
| this.comboBox = null; | |
| - } | |
| + } | |
| } | |
| - | |
| - private void applyLayoutAndSkin() { | |
| + | |
| + private void applyLayoutAndSkin() { | |
| setPanelLayout(); | |
| setLabelLayout(); | |
| setComboBoxLayout(); | |
| } | |
| - | |
| + | |
| private void setPanelLayout() { | |
| - FlowLayout panelLayout = new FlowLayout(FlowLayout.LEFT); | |
| + final FlowLayout panelLayout = new FlowLayout(FlowLayout.LEFT); | |
| panelLayout.setVgap(0); | |
| this.setLayout(panelLayout); | |
| - this.setOpaque(false); | |
| + this.setOpaque(false); | |
| } | |
| - | |
| + | |
| private void setLabelLayout() { | |
| if (this.comboBoxCaption != null && !this.comboBoxCaption.isEmpty()) { | |
| - SkinnedLabel comboLabel = new SkinnedLabel(this.comboBoxCaption); | |
| + final SkinnedLabel comboLabel = new SkinnedLabel(this.comboBoxCaption); | |
| comboLabel.setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT)); | |
| comboLabel.setFont(FSkin.getBoldFont(12)); | |
| - this.add(comboLabel); | |
| + this.add(comboLabel); | |
| } | |
| } | |
| - | |
| + | |
| private void setComboBoxLayout() { | |
| if (this.comboBox != null) { | |
| this.comboBox.setBackground(FSkin.getColor(FSkin.Colors.CLR_THEME2)); | |
| @@ -75,19 +75,19 @@ | |
| this.comboBox.setFont(FSkin.getFont(12)); | |
| this.comboBox.setEditable(false); | |
| this.comboBox.setFocusable(true); | |
| - this.comboBox.setOpaque(true); | |
| + this.comboBox.setOpaque(true); | |
| this.add(this.comboBox); | |
| } | |
| } | |
| - | |
| + | |
| - public void setSelectedItem(Object item) { | |
| + public void setSelectedItem(final Object item) { | |
| this.comboBox.setSelectedItem(item); | |
| } | |
| - | |
| + | |
| public Object getSelectedItem() { | |
| return this.comboBox.getSelectedItem(); | |
| } | |
| - | |
| + | |
| private void refreshSkin() { | |
| this.comboBox = FComboBoxWrapper.refreshComboBoxSkin(this.comboBox); | |
| } | |
| Index: forge-gui/src/main/java/forge/properties/ForgePreferences.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui/src/main/java/forge/properties/ForgePreferences.java (revision 29316) | |
| +++ forge-gui/src/main/java/forge/properties/ForgePreferences.java (revision 29317) | |
| @@ -6,12 +6,12 @@ | |
| * 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 <http://www.gnu.org/licenses/>. | |
| */ | |
| @@ -82,7 +82,7 @@ | |
| UI_VIBRATE_ON_LIFE_LOSS("true"), | |
| UI_VIBRATE_ON_LONG_PRESS("true"), | |
| - | |
| + | |
| UI_LANGUAGE("en-US"), | |
| MATCH_HOT_SEAT_MODE("false"), //this only applies to mobile game | |
| @@ -162,12 +162,10 @@ | |
| private final String strDefaultVal; | |
| - /** @param s0   {@link java.lang.String} */ | |
| - FPref(String s0) { | |
| + private FPref(final String s0) { | |
| this.strDefaultVal = s0; | |
| } | |
| - /** @return {@link java.lang.String} */ | |
| public String getDefault() { | |
| return strDefaultVal; | |
| } | |
| @@ -179,39 +177,28 @@ | |
| CONSTRUCTED_P7_DECK_STATE, CONSTRUCTED_P8_DECK_STATE }; | |
| } | |
| - public static enum CardSizeType { | |
| - tiny, smaller, small, medium, large, huge | |
| - } | |
| - | |
| - | |
| - public static enum StackOffsetType { | |
| - tiny, small, medium, large | |
| - } | |
| - | |
| - | |
| - public static enum HomeMenus { | |
| - constructed, draft, sealed, quest, settings, utilities | |
| - } | |
| - | |
| /** Instantiates a ForgePreferences object. */ | |
| public ForgePreferences() { | |
| super(ForgeConstants.MAIN_PREFS_FILE, FPref.class); | |
| } | |
| + @Override | |
| protected FPref[] getEnumValues() { | |
| return FPref.values(); | |
| } | |
| - protected FPref valueOf(String name) { | |
| + @Override | |
| + protected FPref valueOf(final String name) { | |
| try { | |
| return FPref.valueOf(name); | |
| } | |
| - catch (Exception e) { | |
| + catch (final Exception e) { | |
| return null; | |
| } | |
| } | |
| - protected String getPrefDefault(FPref key) { | |
| + @Override | |
| + protected String getPrefDefault(final FPref key) { | |
| return key.getDefault(); | |
| } | |
| Index: forge-gui-desktop/src/main/java/forge/screens/home/quest/CSubmenuQuestData.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/home/quest/CSubmenuQuestData.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/home/quest/CSubmenuQuestData.java (revision 29317) | |
| @@ -1,5 +1,17 @@ | |
| package forge.screens.home.quest; | |
| +import java.io.File; | |
| +import java.io.FilenameFilter; | |
| +import java.util.ArrayList; | |
| +import java.util.HashMap; | |
| +import java.util.HashSet; | |
| +import java.util.List; | |
| +import java.util.Map; | |
| +import java.util.Map.Entry; | |
| +import java.util.Set; | |
| + | |
| +import javax.swing.SwingUtilities; | |
| + | |
| import forge.UiCommand; | |
| import forge.deck.Deck; | |
| import forge.deck.DeckSection; | |
| @@ -8,29 +20,26 @@ | |
| import forge.item.PaperCard; | |
| import forge.model.FModel; | |
| import forge.properties.ForgeConstants; | |
| -import forge.quest.*; | |
| +import forge.quest.QuestController; | |
| +import forge.quest.QuestMode; | |
| +import forge.quest.QuestUtil; | |
| +import forge.quest.QuestWorld; | |
| +import forge.quest.StartingPoolPreferences; | |
| +import forge.quest.StartingPoolType; | |
| import forge.quest.data.GameFormatQuest; | |
| import forge.quest.data.QuestData; | |
| import forge.quest.data.QuestPreferences.QPref; | |
| import forge.quest.io.QuestDataIO; | |
| import forge.toolbox.FOptionPane; | |
| -import javax.swing.*; | |
| - | |
| -import java.io.File; | |
| -import java.io.FilenameFilter; | |
| -import java.util.*; | |
| -import java.util.Map.Entry; | |
| - | |
| -/** | |
| +/** | |
| * Controls the quest data submenu in the home UI. | |
| - * | |
| + * | |
| * <br><br><i>(C at beginning of class name denotes a control class.)</i> | |
| * | |
| */ | |
| @SuppressWarnings("serial") | |
| public enum CSubmenuQuestData implements ICDoc { | |
| - /** */ | |
| SINGLETON_INSTANCE; | |
| private final Map<String, QuestData> arrQuests = new HashMap<String, QuestData>(); | |
| @@ -39,12 +48,17 @@ | |
| private final List<String> customFormatCodes = new ArrayList<String>(); | |
| private final List<String> customPrizeFormatCodes = new ArrayList<String>(); | |
| - private final UiCommand cmdQuestSelect = new UiCommand() { @Override | |
| - public void run() { changeQuest(); } }; | |
| + private final UiCommand cmdQuestSelect = new UiCommand() { | |
| + @Override public final void run() { | |
| + changeQuest(); | |
| + } | |
| + }; | |
| + private final UiCommand cmdQuestUpdate = new UiCommand() { | |
| + @Override public final void run() { | |
| + update(); | |
| + } | |
| + }; | |
| - private final UiCommand cmdQuestUpdate = new UiCommand() { @Override | |
| - public void run() { update(); } }; | |
| - | |
| @Override | |
| public void register() { | |
| } | |
| @@ -99,15 +113,15 @@ | |
| final QuestController qc = FModel.getQuest(); | |
| // Iterate over files and load quest data for each. | |
| - FilenameFilter takeDatFiles = new FilenameFilter() { | |
| + final FilenameFilter takeDatFiles = new FilenameFilter() { | |
| @Override | |
| public boolean accept(final File dir, final String name) { | |
| return name.endsWith(".dat"); | |
| } | |
| }; | |
| - File[] arrFiles = dirQuests.listFiles(takeDatFiles); | |
| + final File[] arrFiles = dirQuests.listFiles(takeDatFiles); | |
| arrQuests.clear(); | |
| - for (File f : arrFiles) { | |
| + for (final File f : arrFiles) { | |
| arrQuests.put(f.getName(), QuestDataIO.loadData(f)); | |
| } | |
| @@ -147,15 +161,15 @@ | |
| */ | |
| private void newQuest() { | |
| final VSubmenuQuestData view = VSubmenuQuestData.SINGLETON_INSTANCE; | |
| - int difficulty = view.getSelectedDifficulty(); | |
| + final int difficulty = view.getSelectedDifficulty(); | |
| final QuestMode mode = view.isFantasy() ? QuestMode.Fantasy : QuestMode.Classic; | |
| Deck dckStartPool = null; | |
| GameFormat fmtStartPool = null; | |
| - QuestWorld startWorld = FModel.getWorlds().get(view.getStartingWorldName()); | |
| + final QuestWorld startWorld = FModel.getWorlds().get(view.getStartingWorldName()); | |
| - GameFormat worldFormat = (startWorld == null ? null : startWorld.getFormat()); | |
| + final GameFormat worldFormat = (startWorld == null ? null : startWorld.getFormat()); | |
| if (worldFormat == null) { | |
| switch(view.getStartingPoolType()) { | |
| @@ -200,16 +214,16 @@ | |
| // The starting QuestWorld format should NOT affect what you get if you travel to a world that doesn't have one... | |
| // if (worldFormat == null) { | |
| - StartingPoolType prizedPoolType = view.getPrizedPoolType(); | |
| + final StartingPoolType prizedPoolType = view.getPrizedPoolType(); | |
| if (null == prizedPoolType) { | |
| fmtPrizes = fmtStartPool; | |
| if (null == fmtPrizes && dckStartPool != null) { // build it form deck | |
| - Set<String> sets = new HashSet<String>(); | |
| - for (Entry<PaperCard, Integer> c : dckStartPool.getMain()) { | |
| + final Set<String> sets = new HashSet<String>(); | |
| + for (final Entry<PaperCard, Integer> c : dckStartPool.getMain()) { | |
| sets.add(c.getKey().getEdition()); | |
| } | |
| if (dckStartPool.has(DeckSection.Sideboard)) { | |
| - for (Entry<PaperCard, Integer> c : dckStartPool.get(DeckSection.Sideboard)) { | |
| + for (final Entry<PaperCard, Integer> c : dckStartPool.get(DeckSection.Sideboard)) { | |
| sets.add(c.getKey().getEdition()); | |
| } | |
| } | |
| @@ -258,8 +272,8 @@ | |
| } | |
| break; | |
| } | |
| - | |
| + | |
| - QuestController qc = FModel.getQuest(); | |
| + final QuestController qc = FModel.getQuest(); | |
| qc.newGame(questName, difficulty, mode, fmtPrizes, view.isUnlockSetsAllowed(), dckStartPool, fmtStartPool, view.getStartingWorldName(), userPrefs); | |
| FModel.getQuest().save(); | |
| @@ -294,11 +308,4 @@ | |
| return arrQuests; | |
| } | |
| - /* (non-Javadoc) | |
| - * @see forge.gui.framework.ICDoc#getCommandOnSelect() | |
| - */ | |
| - @Override | |
| - public UiCommand getCommandOnSelect() { | |
| - return null; | |
| - } | |
| } | |
| Index: forge-gui/src/main/java/forge/card/CardScriptParser.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui/src/main/java/forge/card/CardScriptParser.java (revision 29316) | |
| +++ forge-gui/src/main/java/forge/card/CardScriptParser.java (revision 29317) | |
| @@ -38,17 +38,13 @@ | |
| } | |
| } | |
| - public boolean hasErrors() { | |
| - return !getErrorRegions(true).isEmpty(); | |
| - } | |
| - | |
| public Map<Integer, Integer> getErrorRegions() { | |
| return getErrorRegions(false); | |
| } | |
| /** | |
| * Find all erroneous regions of this script. | |
| - * | |
| + * | |
| * @param quick | |
| * if {@code true}, stop when the first region is found. | |
| * @return a {@link Map} mapping the starting index of each error region to | |
| @@ -299,9 +295,9 @@ | |
| private static final Predicate<String> startsWith(final String s) { | |
| return new Predicate<String>() { | |
| - public boolean apply(final String input) { | |
| + @Override public boolean apply(final String input) { | |
| - return s.startsWith(input); | |
| - }}; | |
| + return s.startsWith(input); | |
| + }}; | |
| } | |
| /** | |
| Index: forge-gui-desktop/src/main/java/forge/gui/GuiDialog.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/gui/GuiDialog.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/gui/GuiDialog.java (revision 29317) | |
| @@ -1,10 +1,9 @@ | |
| package forge.gui; | |
| import java.util.concurrent.Callable; | |
| +import java.util.concurrent.ExecutionException; | |
| import java.util.concurrent.FutureTask; | |
| -import javax.swing.UIManager; | |
| - | |
| import org.apache.commons.lang3.StringUtils; | |
| import forge.FThreads; | |
| @@ -12,70 +11,35 @@ | |
| import forge.screens.match.CMatchUI; | |
| import forge.toolbox.FOptionPane; | |
| -/** | |
| - * Holds player interactions using standard windows | |
| +/** | |
| + * Holds player interactions using standard windows | |
| * | |
| */ | |
| public class GuiDialog { | |
| private static final String[] defaultConfirmOptions = { "Yes", "No" }; | |
| - public static boolean confirm(final CardView c, final String question) { | |
| - return confirm(c, question, true, null); | |
| - } | |
| - public static boolean confirm(final CardView c, final String question, final boolean defaultChoice) { | |
| - return confirm(c, question, defaultChoice, null); | |
| - } | |
| - public static boolean confirm(final CardView c, final String question, String[] options) { | |
| - return confirm(c, question, true, options); | |
| - } | |
| - | |
| - public static boolean confirm(final CardView c, final String question, final boolean defaultIsYes, final String[] options) { | |
| - return confirm(c, question, defaultIsYes, options, null); | |
| - } | |
| public static boolean confirm(final CardView c, final String question, final boolean defaultIsYes, final String[] options, final CMatchUI matchUI) { | |
| - Callable<Boolean> confirmTask = new Callable<Boolean>() { | |
| - @Override | |
| - public Boolean call() throws Exception { | |
| + final Callable<Boolean> confirmTask = new Callable<Boolean>() { | |
| + @Override public final Boolean call() { | |
| if (matchUI != null && c != null) { | |
| matchUI.setCard(c); | |
| } | |
| final String title = c == null ? "Question" : c + " - Ability"; | |
| - String questionToUse = StringUtils.isBlank(question) ? "Activate card's ability?" : question; | |
| - String[] opts = options == null ? defaultConfirmOptions : options; | |
| - int answer = FOptionPane.showOptionDialog(questionToUse, title, FOptionPane.QUESTION_ICON, opts, defaultIsYes ? 0 : 1); | |
| - return answer == 0; | |
| + final String questionToUse = StringUtils.isBlank(question) ? "Activate card's ability?" : question; | |
| + final String[] opts = options == null ? defaultConfirmOptions : options; | |
| + final int answer = FOptionPane.showOptionDialog(questionToUse, title, FOptionPane.QUESTION_ICON, opts, defaultIsYes ? 0 : 1); | |
| + return Boolean.valueOf(answer == 0); | |
| }}; | |
| - FutureTask<Boolean> future = new FutureTask<Boolean>(confirmTask); | |
| + final FutureTask<Boolean> future = new FutureTask<Boolean>(confirmTask); | |
| FThreads.invokeInEdtAndWait(future); | |
| - try { | |
| + try { | |
| return future.get().booleanValue(); | |
| - } | |
| - catch (Exception e) { // should be no exception here | |
| + } catch (final InterruptedException | ExecutionException e) { // should be no exception here | |
| e.printStackTrace(); | |
| } | |
| return false; | |
| } | |
| - /** | |
| - * <p> | |
| - * showInfoDialg. | |
| - * </p> | |
| - * | |
| - * @param message | |
| - * a {@link java.lang.String} object. | |
| - */ | |
| - public static void message(final String message) { | |
| - message(message, UIManager.getString("OptionPane.messageDialogTitle")); | |
| - } | |
| - | |
| - public static void message(final String message, final String title) { | |
| - FThreads.invokeInEdtAndWait(new Runnable() { | |
| - @Override | |
| - public void run() { | |
| - FOptionPane.showMessageDialog(message, title, null); | |
| - } | |
| - }); | |
| - } | |
| } | |
| Index: forge-gui-desktop/src/main/java/forge/gui/framework/DragCell.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/gui/framework/DragCell.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/gui/framework/DragCell.java (revision 29317) | |
| @@ -1,5 +1,20 @@ | |
| package forge.gui.framework; | |
| +import java.awt.Color; | |
| +import java.awt.Dimension; | |
| +import java.awt.Font; | |
| +import java.awt.Graphics; | |
| +import java.awt.event.MouseAdapter; | |
| +import java.awt.event.MouseEvent; | |
| +import java.util.ArrayList; | |
| +import java.util.List; | |
| + | |
| +import javax.swing.JLabel; | |
| +import javax.swing.JPanel; | |
| +import javax.swing.SwingConstants; | |
| + | |
| +import net.miginfocom.swing.MigLayout; | |
| + | |
| import com.google.common.collect.Lists; | |
| import forge.assets.FSkinProp; | |
| @@ -10,16 +25,7 @@ | |
| import forge.toolbox.FSkin; | |
| import forge.toolbox.FSkin.SkinImage; | |
| import forge.view.FView; | |
| -import net.miginfocom.swing.MigLayout; | |
| -import javax.swing.*; | |
| - | |
| -import java.awt.*; | |
| -import java.awt.event.MouseAdapter; | |
| -import java.awt.event.MouseEvent; | |
| -import java.util.ArrayList; | |
| -import java.util.List; | |
| - | |
| /** | |
| * Top-level container in drag layout. A cell holds | |
| * tabs, a drag handle, and a tab overflow selector. | |
| @@ -49,9 +55,6 @@ | |
| private final JLabel lblOverflow = new JLabel(); | |
| private IVDoc<? extends ICDoc> docSelected = null; | |
| - /** | |
| - * | |
| - */ | |
| public DragCell() { | |
| super(new MigLayout("insets 0, gap 0, wrap 2")); | |
| @@ -89,10 +92,10 @@ | |
| * <p> | |
| * Primarily used to toggle visibility of tabs. | |
| */ | |
| - public void doCellLayout(boolean showTabs) { | |
| + public void doCellLayout(final boolean showTabs) { | |
| this.removeAll(); | |
| - int borderT = SLayoutConstants.BORDER_T; | |
| - int headH = ((showTabs || allDocs.size() > 1) ? SLayoutConstants.HEAD_H : 0); | |
| + final int borderT = SLayoutConstants.BORDER_T; | |
| + final int headH = ((showTabs || allDocs.size() > 1) ? SLayoutConstants.HEAD_H : 0); | |
| this.add(pnlHead, | |
| "w 100% - " + borderT + "px!" + ", " + "h " + headH + "px!"); | |
| this.add(pnlBorderRight, | |
| @@ -109,8 +112,8 @@ | |
| /** | |
| * Determines visibility of tabs on game screen. | |
| */ | |
| - private boolean showGameTabs() { | |
| - ForgePreferences prefs = FModel.getPreferences(); | |
| + private static boolean showGameTabs() { | |
| + final ForgePreferences prefs = FModel.getPreferences(); | |
| return !prefs.getPrefBoolean(FPref.UI_HIDE_GAME_TABS); | |
| } | |
| @@ -229,7 +232,7 @@ | |
| * @param w0   double | |
| * @param h0   double | |
| */ | |
| - public void setRoughBounds(RectangleOfDouble rectangleOfDouble) { | |
| + public void setRoughBounds(final RectangleOfDouble rectangleOfDouble) { | |
| this.roughSize = rectangleOfDouble; | |
| } | |
| @@ -283,7 +286,7 @@ | |
| /** Removes a document from the layout and tabs. | |
| * @param doc0   {@link forge.gui.framework.IVDoc} */ | |
| public void removeDoc(final IVDoc<? extends ICDoc> doc0) { | |
| - boolean wasSelected = (docSelected == doc0); | |
| + final boolean wasSelected = (docSelected == doc0); | |
| allDocs.remove(doc0); | |
| pnlHead.remove(doc0.getTabLabel()); | |
| if (wasSelected) { //after removing selected doc, select most recent doc if possible | |
| @@ -296,10 +299,10 @@ | |
| /** - Deselects previous selection, if there is one<br> | |
| * - Decrements the priorities of all other tabs<br> | |
| * - Sets selected as priority 1<br> | |
| - * | |
| + * | |
| * <br><b>null</b> will reset | |
| * (deselect all tabs, and then select the first in the group). | |
| - * | |
| + * | |
| * <br><br>Unless there are no tab docs in this cell, there | |
| * will always be a selection. | |
| * | |
| @@ -340,32 +343,6 @@ | |
| * @return {@link forge.gui.framework.IVDoc} */ | |
| public IVDoc<? extends ICDoc> getSelected() { | |
| return docSelected; | |
| - } | |
| - | |
| - /** | |
| - * Enable/disable resize on the X axis for this cell. | |
| - * | |
| - * @param enable0   boolean | |
| - */ | |
| - public void toggleResizeX(final boolean enable0) { | |
| - this.removeMouseListener(SResizingUtil.getResizeXListener()); | |
| - | |
| - if (enable0) { | |
| - this.addMouseListener(SResizingUtil.getResizeXListener()); | |
| - } | |
| - } | |
| - | |
| - /** | |
| - * Enable/disable resize on the Y axis for this cell. | |
| - * | |
| - * @param enable0   boolean | |
| - */ | |
| - public void toggleResizeY(final boolean enable0) { | |
| - this.removeMouseListener(SResizingUtil.getResizeYListener()); | |
| - | |
| - if (enable0) { | |
| - this.addMouseListener(SResizingUtil.getResizeYListener()); | |
| - } | |
| } | |
| /** | |
| @@ -464,8 +441,8 @@ | |
| public void paintComponent(final Graphics g) { | |
| super.paintComponent(g); | |
| if (!hovered) { return; } | |
| - | |
| - final Dimension imgSize = img.getSizeForPaint(g); | |
| + | |
| + final Dimension imgSize = img.getSizeForPaint(g); | |
| final int imgW = imgSize.width; | |
| if (imgW < 1) { return; } | |
| final int imgH = imgSize.height; | |
| Index: forge-gui-desktop/src/main/java/forge/screens/deckeditor/views/VCurrentDeck.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/deckeditor/views/VCurrentDeck.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/deckeditor/views/VCurrentDeck.java (revision 29317) | |
| @@ -1,5 +1,9 @@ | |
| package forge.screens.deckeditor.views; | |
| +import javax.swing.JPanel; | |
| +import javax.swing.SwingConstants; | |
| + | |
| +import net.miginfocom.swing.MigLayout; | |
| import forge.assets.FSkinProp; | |
| import forge.gui.framework.DragCell; | |
| import forge.gui.framework.DragTab; | |
| @@ -12,18 +16,13 @@ | |
| import forge.toolbox.FLabel; | |
| import forge.toolbox.FSkin; | |
| import forge.toolbox.FTextField; | |
| -import net.miginfocom.swing.MigLayout; | |
| -import javax.swing.*; | |
| - | |
| - | |
| -/** | |
| +/** | |
| * Assembles Swing components of current deck being edited in deck editor. | |
| * | |
| * <br><br><i>(V at beginning of class name denotes a view class.)</i> | |
| */ | |
| public enum VCurrentDeck implements IVDoc<CCurrentDeck> { | |
| - /** */ | |
| SINGLETON_INSTANCE; | |
| // Fields used with interface IVDoc | |
| @@ -157,11 +156,11 @@ | |
| parentBody.add(pnlHeader, "pushx, growx"); | |
| parentBody.add(itemManagerContainer, "push, grow"); | |
| } | |
| - | |
| + | |
| public ItemManager<? extends InventoryItem> getItemManager() { | |
| return this.itemManager; | |
| } | |
| - | |
| + | |
| public void setItemManager(final ItemManager<? extends InventoryItem> itemManager0) { | |
| this.itemManager = itemManager0; | |
| itemManagerContainer.setItemManager(itemManager0); | |
| @@ -211,7 +210,6 @@ | |
| * @return | |
| */ | |
| public FLabel getBtnImport() { | |
| - // TODO Auto-generated method stub | |
| - return (FLabel) btnImport; | |
| + return btnImport; | |
| } | |
| } | |
| Index: forge-gui-desktop/src/main/java/forge/gui/FNetOverlay.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/gui/FNetOverlay.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/gui/FNetOverlay.java (revision 29317) | |
| @@ -114,7 +114,7 @@ | |
| FScrollPane _operationLogScroller = new FScrollPane(txtLog, false); | |
| _operationLogScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); | |
| - new SmartScroller(_operationLogScroller); | |
| + new SmartScroller(_operationLogScroller).attach(); | |
| window.add(_operationLogScroller, "pushx, hmin 24, pushy, growy, growx, gap 2px 2px 2px 0, sx 2"); | |
| //txtInput.setBorder(new FSkin.LineSkinBorder(FSkin.getColor(FSkin.Colors.CLR_BORDERS))); | |
| Index: forge-gui-desktop/src/main/java/forge/itemmanager/DeckManager.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/itemmanager/DeckManager.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/itemmanager/DeckManager.java (revision 29317) | |
| @@ -53,7 +53,7 @@ | |
| import forge.toolbox.FOptionPane; | |
| import forge.toolbox.FSkin; | |
| -/** | |
| +/** | |
| * ItemManager for decks | |
| * | |
| */ | |
| @@ -78,8 +78,7 @@ | |
| this.gameType = gt; | |
| this.addSelectionListener(new ListSelectionListener() { | |
| - @Override | |
| - public void valueChanged(ListSelectionEvent e) { | |
| + @Override public void valueChanged(final ListSelectionEvent e) { | |
| if (cmdSelect != null) { | |
| cmdSelect.run(); | |
| } | |
| @@ -94,18 +93,19 @@ | |
| }); | |
| } | |
| + @Override | |
| public GameType getGameType() { | |
| return gameType; | |
| } | |
| @Override | |
| - public void setup(ItemManagerConfig config0) { | |
| - boolean wasStringOnly = (this.getConfig() == ItemManagerConfig.STRING_ONLY); | |
| - boolean isStringOnly = (config0 == ItemManagerConfig.STRING_ONLY); | |
| + public void setup(final ItemManagerConfig config0) { | |
| + final boolean wasStringOnly = (this.getConfig() == ItemManagerConfig.STRING_ONLY); | |
| + final boolean isStringOnly = (config0 == ItemManagerConfig.STRING_ONLY); | |
| Map<ColumnDef, ItemTableColumn> colOverrides = null; | |
| if (config0.getCols().containsKey(ColumnDef.DECK_ACTIONS)) { | |
| - ItemTableColumn column = new ItemTableColumn(new ItemColumn(config0.getCols().get(ColumnDef.DECK_ACTIONS))); | |
| + final ItemTableColumn column = new ItemTableColumn(new ItemColumn(config0.getCols().get(ColumnDef.DECK_ACTIONS))); | |
| column.setCellRenderer(new DeckActionsRenderer()); | |
| colOverrides = new HashMap<ColumnDef, ItemTableColumn>(); | |
| colOverrides.put(ColumnDef.DECK_ACTIONS, column); | |
| @@ -148,17 +148,17 @@ | |
| } | |
| @Override | |
| - protected void buildAddFilterMenu(JMenu menu) { | |
| + protected void buildAddFilterMenu(final JMenu menu) { | |
| GuiUtils.addSeparator(menu); //separate from current search item | |
| - Set<String> folders = new HashSet<String>(); | |
| + final Set<String> folders = new HashSet<String>(); | |
| for (final Entry<DeckProxy, Integer> deckEntry : getPool()) { | |
| - String path = deckEntry.getKey().getPath(); | |
| + final String path = deckEntry.getKey().getPath(); | |
| if (StringUtils.isNotEmpty(path)) { //don't include root folder as option | |
| folders.add(path); | |
| } | |
| } | |
| - JMenu folder = GuiUtils.createMenu("Folder"); | |
| + final JMenu folder = GuiUtils.createMenu("Folder"); | |
| if (folders.size() > 0) { | |
| for (final String f : folders) { | |
| GuiUtils.addMenuItem(folder, f, null, new Runnable() { | |
| @@ -174,7 +174,7 @@ | |
| } | |
| menu.add(folder); | |
| - JMenu fmt = GuiUtils.createMenu("Format"); | |
| + final JMenu fmt = GuiUtils.createMenu("Format"); | |
| for (final GameFormat f : FModel.getFormats().getOrderedList()) { | |
| GuiUtils.addMenuItem(fmt, f.getName(), null, new Runnable() { | |
| @Override | |
| @@ -186,18 +186,15 @@ | |
| menu.add(fmt); | |
| GuiUtils.addMenuItem(menu, "Sets...", null, new Runnable() { | |
| - @Override | |
| - public void run() { | |
| - DeckSetFilter existingFilter = getFilter(DeckSetFilter.class); | |
| + @Override public void run() { | |
| + final DeckSetFilter existingFilter = getFilter(DeckSetFilter.class); | |
| if (existingFilter != null) { | |
| existingFilter.edit(); | |
| - } | |
| - else { | |
| + } else { | |
| final DialogChooseSets dialog = new DialogChooseSets(null, null, true); | |
| dialog.setOkCallback(new Runnable() { | |
| - @Override | |
| - public void run() { | |
| - List<String> sets = dialog.getSelectedSets(); | |
| + @Override public void run() { | |
| + final List<String> sets = dialog.getSelectedSets(); | |
| if (!sets.isEmpty()) { | |
| addFilter(new DeckSetFilter(DeckManager.this, sets, dialog.getWantReprints())); | |
| } | |
| @@ -207,11 +204,10 @@ | |
| } | |
| }); | |
| - JMenu world = GuiUtils.createMenu("Quest world"); | |
| + final JMenu world = GuiUtils.createMenu("Quest world"); | |
| for (final QuestWorld w : FModel.getWorlds()) { | |
| GuiUtils.addMenuItem(world, w.getName(), null, new Runnable() { | |
| - @Override | |
| - public void run() { | |
| + @Override public void run() { | |
| addFilter(new DeckQuestWorldFilter(DeckManager.this, w)); | |
| } | |
| }, DeckQuestWorldFilter.canAddQuestWorld(w, getFilter(DeckQuestWorldFilter.class))); | |
| @@ -235,30 +231,30 @@ | |
| FScreen screen = null; | |
| switch (this.gameType) { | |
| - case Quest: | |
| - screen = FScreen.DECK_EDITOR_QUEST; | |
| - editorCtrl = new CEditorQuest(FModel.getQuest(), getCDetailPicture()); | |
| - break; | |
| - case Constructed: | |
| - screen = FScreen.DECK_EDITOR_CONSTRUCTED; | |
| - DeckPreferences.setCurrentDeck(deck.toString()); | |
| - //re-use constructed controller | |
| - break; | |
| - case Sealed: | |
| - screen = FScreen.DECK_EDITOR_SEALED; | |
| - editorCtrl = new CEditorLimited(FModel.getDecks().getSealed(), screen, getCDetailPicture()); | |
| - break; | |
| - case Draft: | |
| - screen = FScreen.DECK_EDITOR_DRAFT; | |
| - editorCtrl = new CEditorLimited(FModel.getDecks().getDraft(), screen, getCDetailPicture()); | |
| - break; | |
| - case Winston: | |
| - screen = FScreen.DECK_EDITOR_DRAFT; | |
| - editorCtrl = new CEditorLimited(FModel.getDecks().getWinston(), screen, getCDetailPicture()); | |
| - break; | |
| + case Quest: | |
| + screen = FScreen.DECK_EDITOR_QUEST; | |
| + editorCtrl = new CEditorQuest(FModel.getQuest(), getCDetailPicture()); | |
| + break; | |
| + case Constructed: | |
| + screen = FScreen.DECK_EDITOR_CONSTRUCTED; | |
| + DeckPreferences.setCurrentDeck(deck.toString()); | |
| + //re-use constructed controller | |
| + break; | |
| + case Sealed: | |
| + screen = FScreen.DECK_EDITOR_SEALED; | |
| + editorCtrl = new CEditorLimited(FModel.getDecks().getSealed(), screen, getCDetailPicture()); | |
| + break; | |
| + case Draft: | |
| + screen = FScreen.DECK_EDITOR_DRAFT; | |
| + editorCtrl = new CEditorLimited(FModel.getDecks().getDraft(), screen, getCDetailPicture()); | |
| + break; | |
| + case Winston: | |
| + screen = FScreen.DECK_EDITOR_DRAFT; | |
| + editorCtrl = new CEditorLimited(FModel.getDecks().getWinston(), screen, getCDetailPicture()); | |
| + break; | |
| - default: | |
| - return; | |
| + default: | |
| + return; | |
| } | |
| if (!Singletons.getControl().ensureScreenActive(screen)) { return; } | |
| @@ -272,7 +268,7 @@ | |
| CDeckEditorUI.SINGLETON_INSTANCE.getCurrentEditorController().getDeckController().load(deck.getPath(), deck.getName()); | |
| } | |
| - public boolean deleteDeck(DeckProxy deck) { | |
| + public boolean deleteDeck(final DeckProxy deck) { | |
| if (deck == null) { return false; } | |
| if (!FOptionPane.showConfirmDialog( | |
| @@ -283,17 +279,17 @@ | |
| // consider using deck proxy's method to delete deck | |
| switch(this.gameType) { | |
| - case Constructed: | |
| - case Draft: | |
| - case Sealed: | |
| - deck.deleteFromStorage(); | |
| - break; | |
| - case Quest: | |
| - deck.deleteFromStorage(); | |
| - FModel.getQuest().save(); | |
| - break; | |
| - default: | |
| - throw new UnsupportedOperationException("Delete not implemented for game type = " + gameType.toString()); | |
| + case Constructed: | |
| + case Draft: | |
| + case Sealed: | |
| + deck.deleteFromStorage(); | |
| + break; | |
| + case Quest: | |
| + deck.deleteFromStorage(); | |
| + FModel.getQuest().save(); | |
| + break; | |
| + default: | |
| + throw new UnsupportedOperationException("Delete not implemented for game type = " + gameType.toString()); | |
| } | |
| this.removeItem(deck, 1); | |
| @@ -305,7 +301,7 @@ | |
| } | |
| public class DeckActionsRenderer extends ItemCellRenderer { | |
| - private int overActionIndex = -1; | |
| + private final int overActionIndex = -1; | |
| private static final int imgSize = 20; | |
| @Override | |
| @@ -315,7 +311,7 @@ | |
| /* | |
| * (non-Javadoc) | |
| - * | |
| + * | |
| * @see | |
| * javax.swing.table.DefaultTableCellRenderer#getTableCellRendererComponent | |
| * (javax.swing.JTable, java.lang.Object, boolean, boolean, int, int) | |
| @@ -329,11 +325,11 @@ | |
| @Override | |
| public <T extends InventoryItem> void processMouseEvent(final MouseEvent e, final ItemListView<T> listView, final Object value, final int row, final int column) { | |
| - Rectangle cellBounds = listView.getTable().getCellRect(row, column, false); | |
| - int x = e.getX() - cellBounds.x; | |
| + final Rectangle cellBounds = listView.getTable().getCellRect(row, column, false); | |
| + final int x = e.getX() - cellBounds.x; | |
| if (e.getID() == MouseEvent.MOUSE_PRESSED && e.getButton() == 1) { | |
| - DeckProxy deck = (DeckProxy) value; | |
| + final DeckProxy deck = (DeckProxy) value; | |
| if (x >= 0 && x < imgSize) { //delete button | |
| if (DeckManager.this.deleteDeck(deck)) { | |
| @@ -370,7 +366,7 @@ | |
| /* | |
| * (non-Javadoc) | |
| - * | |
| + * | |
| * @see javax.swing.JComponent#paint(java.awt.Graphics) | |
| */ | |
| @Override | |
| Index: forge-gui/src/main/java/forge/download/GuiDownloadPicturesLQ.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui/src/main/java/forge/download/GuiDownloadPicturesLQ.java (revision 29316) | |
| +++ forge-gui/src/main/java/forge/download/GuiDownloadPicturesLQ.java (revision 29317) | |
| @@ -6,29 +6,29 @@ | |
| * 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 <http://www.gnu.org/licenses/>. | |
| */ | |
| package forge.download; | |
| +import java.io.File; | |
| +import java.util.Map; | |
| +import java.util.TreeMap; | |
| + | |
| +import org.apache.commons.lang3.StringUtils; | |
| + | |
| import forge.card.CardRules; | |
| import forge.item.PaperCard; | |
| import forge.model.FModel; | |
| import forge.properties.ForgeConstants; | |
| import forge.util.ImageUtil; | |
| -import org.apache.commons.lang3.StringUtils; | |
| - | |
| -import java.io.File; | |
| -import java.util.Map; | |
| -import java.util.TreeMap; | |
| - | |
| public class GuiDownloadPicturesLQ extends GuiDownloadService { | |
| @Override | |
| public String getTitle() { | |
| @@ -37,39 +37,40 @@ | |
| @Override | |
| protected final Map<String, String> getNeededFiles() { | |
| - Map<String, String> downloads = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER); | |
| + final Map<String, String> downloads = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER); | |
| - for (PaperCard c : FModel.getMagicDb().getCommonCards().getAllCards()) { | |
| + for (final PaperCard c : FModel.getMagicDb().getCommonCards().getAllCards()) { | |
| addDLObject(c, downloads, false); | |
| if (ImageUtil.hasBackFacePicture(c)) { | |
| addDLObject(c, downloads, true); | |
| } | |
| } | |
| - for (PaperCard c : FModel.getMagicDb().getVariantCards().getAllCards()) { | |
| + for (final PaperCard c : FModel.getMagicDb().getVariantCards().getAllCards()) { | |
| addDLObject(c, downloads, false); | |
| } | |
| - | |
| + | |
| // Add missing tokens to the list of things to download. | |
| addMissingItems(downloads, ForgeConstants.IMAGE_LIST_TOKENS_FILE, ForgeConstants.CACHE_TOKEN_PICS_DIR); | |
| return downloads; | |
| } | |
| - private void addDLObject(PaperCard c, Map<String, String> downloads, boolean backFace) { | |
| - CardRules cardRules = c.getRules(); | |
| - String urls = cardRules.getPictureUrl(backFace); | |
| + private static void addDLObject(final PaperCard c, final Map<String, String> downloads, final boolean backFace) { | |
| + final CardRules cardRules = c.getRules(); | |
| + final String urls = cardRules.getPictureUrl(backFace); | |
| if (StringUtils.isEmpty(urls)) { | |
| return; | |
| } | |
| String filename = ImageUtil.getImageKey(c, backFace, false); | |
| - File destFile = new File(ForgeConstants.CACHE_CARD_PICS_DIR, filename + ".jpg"); | |
| - if (destFile.exists()) | |
| + final File destFile = new File(ForgeConstants.CACHE_CARD_PICS_DIR, filename + ".jpg"); | |
| + if (destFile.exists()) { | |
| return; | |
| + } | |
| - | |
| + | |
| filename = destFile.getAbsolutePath(); | |
| - | |
| + | |
| if (downloads.containsKey(filename)) { | |
| return; | |
| } | |
| @@ -77,10 +78,10 @@ | |
| final String urlToDownload; | |
| int urlIndex = 0; | |
| int allUrlsLen = 1; | |
| - if (urls.indexOf("\\") < 0) | |
| + if (urls.indexOf("\\") < 0) { | |
| urlToDownload = urls; | |
| - else { | |
| - String[] allUrls = urls.split("\\\\"); | |
| + } else { | |
| + final String[] allUrls = urls.split("\\\\"); | |
| allUrlsLen = allUrls.length; | |
| urlIndex = (c.getArtIndex()-1) % allUrlsLen; | |
| urlToDownload = allUrls[urlIndex]; | |
| Index: forge-gui-desktop/src/main/java/forge/toolbox/ContextMenuBuilder.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/toolbox/ContextMenuBuilder.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/toolbox/ContextMenuBuilder.java (revision 29317) | |
| @@ -1,6 +1,6 @@ | |
| package forge.toolbox; | |
| -import javax.swing.*; | |
| +import javax.swing.JPopupMenu; | |
| public interface ContextMenuBuilder { | |
| void buildContextMenu(JPopupMenu menu); | |
| \ No newline at end of file | |
| Index: forge-gui-desktop/src/main/java/forge/screens/match/controllers/CField.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/match/controllers/CField.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/match/controllers/CField.java (revision 29317) | |
| @@ -6,12 +6,12 @@ | |
| * 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 <http://www.gnu.org/licenses/>. | |
| */ | |
| @@ -24,11 +24,9 @@ | |
| import com.google.common.base.Function; | |
| import forge.Singletons; | |
| -import forge.UiCommand; | |
| import forge.game.player.PlayerView; | |
| import forge.game.zone.ZoneType; | |
| import forge.gui.framework.ICDoc; | |
| -import forge.match.MatchConstants; | |
| import forge.screens.match.CMatchUI; | |
| import forge.screens.match.ZoneAction; | |
| import forge.screens.match.views.VField; | |
| @@ -53,31 +51,31 @@ | |
| /** | |
| * Controls Swing components of a player's field instance. | |
| - * | |
| + * | |
| * @param player0   {@link forge.game.player.Player} | |
| * @param v0   {@link forge.screens.match.views.VField} | |
| - * @param playerViewer | |
| + * @param playerViewer | |
| */ | |
| public CField(final CMatchUI matchUI, final PlayerView player0, final VField v0) { | |
| this.matchUI = matchUI; | |
| this.player = player0; | |
| this.view = v0; | |
| - final ZoneAction handAction = new ZoneAction(matchUI, player, ZoneType.Hand, MatchConstants.HUMANHAND); | |
| - final ZoneAction libraryAction = new ZoneAction(matchUI, player, ZoneType.Library, MatchConstants.HUMANLIBRARY); | |
| - final ZoneAction exileAction = new ZoneAction(matchUI, player, ZoneType.Exile, MatchConstants.HUMANEXILED); | |
| - final ZoneAction graveAction = new ZoneAction(matchUI, player, ZoneType.Graveyard, MatchConstants.HUMANGRAVEYARD); | |
| - final ZoneAction flashBackAction = new ZoneAction(matchUI, player, ZoneType.Flashback, MatchConstants.HUMANFLASHBACK); | |
| - final ZoneAction commandAction = new ZoneAction(matchUI, player, ZoneType.Command, MatchConstants.HUMANCOMMAND); | |
| + final ZoneAction handAction = new ZoneAction(matchUI, player, ZoneType.Hand); | |
| + final ZoneAction libraryAction = new ZoneAction(matchUI, player, ZoneType.Library); | |
| + final ZoneAction exileAction = new ZoneAction(matchUI, player, ZoneType.Exile); | |
| + final ZoneAction graveAction = new ZoneAction(matchUI, player, ZoneType.Graveyard); | |
| + final ZoneAction flashBackAction = new ZoneAction(matchUI, player, ZoneType.Flashback); | |
| + final ZoneAction commandAction = new ZoneAction(matchUI, player, ZoneType.Command); | |
| final Function<Byte, Boolean> manaAction = new Function<Byte, Boolean>() { | |
| - public Boolean apply(final Byte colorCode) { | |
| + @Override public final Boolean apply(final Byte colorCode) { | |
| if (CField.this.player.isLobbyPlayer(Singletons.getControl().getGuiPlayer())) { | |
| final int oldMana = player.getMana(colorCode); | |
| matchUI.getGameController().useMana(colorCode.byteValue()); | |
| - return oldMana != player.getMana(colorCode); | |
| + return Boolean.valueOf(oldMana != player.getMana(colorCode)); | |
| } | |
| - return false; | |
| + return Boolean.FALSE; | |
| } | |
| }; | |
| @@ -106,11 +104,4 @@ | |
| public void update() { | |
| } | |
| - /* (non-Javadoc) | |
| - * @see forge.gui.framework.ICDoc#getCommandOnSelect() | |
| - */ | |
| - @Override | |
| - public UiCommand getCommandOnSelect() { | |
| - return null; | |
| - } | |
| } // End class CField | |
| Index: forge-gui-desktop/src/main/java/forge/gui/ListChooser.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/gui/ListChooser.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/gui/ListChooser.java (revision 29317) | |
| @@ -6,18 +6,36 @@ | |
| * 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 <http://www.gnu.org/licenses/>. | |
| */ | |
| package forge.gui; | |
| +import java.awt.Component; | |
| +import java.awt.Dimension; | |
| +import java.awt.event.KeyAdapter; | |
| +import java.awt.event.KeyEvent; | |
| +import java.awt.event.MouseEvent; | |
| +import java.util.Collection; | |
| +import java.util.List; | |
| + | |
| +import javax.swing.AbstractListModel; | |
| +import javax.swing.DefaultListCellRenderer; | |
| +import javax.swing.JList; | |
| +import javax.swing.ListCellRenderer; | |
| +import javax.swing.ListSelectionModel; | |
| +import javax.swing.SwingUtilities; | |
| +import javax.swing.WindowConstants; | |
| +import javax.swing.event.ListSelectionEvent; | |
| +import javax.swing.event.ListSelectionListener; | |
| + | |
| import com.google.common.base.Function; | |
| import com.google.common.collect.Lists; | |
| @@ -27,17 +45,6 @@ | |
| import forge.toolbox.FOptionPane; | |
| import forge.toolbox.FScrollPane; | |
| -import javax.swing.*; | |
| -import javax.swing.event.ListSelectionEvent; | |
| -import javax.swing.event.ListSelectionListener; | |
| - | |
| -import java.awt.*; | |
| -import java.awt.event.KeyAdapter; | |
| -import java.awt.event.KeyEvent; | |
| -import java.awt.event.MouseEvent; | |
| -import java.util.Collection; | |
| -import java.util.List; | |
| - | |
| /** | |
| * A simple class that shows a list of choices in a dialog. Two properties | |
| * influence the behavior of a list chooser: minSelection and maxSelection. | |
| @@ -46,8 +53,8 @@ | |
| * and the choice doesn't matter. | |
| * <ul> | |
| * <li>If minSelection is 0, there will be a Cancel button.</li> | |
| - * <li>If minSelection is -1, 0 or 1, double-clicking a choice will also close the | |
| - * dialog.</li> | |
| + * <li>If minSelection is -1, 0 or 1, double-clicking a choice will also close | |
| + * the dialog.</li> | |
| * <li>If the number of selections is out of bounds, the "OK" button is | |
| * disabled.</li> | |
| * <li>The dialog was "committed" if "OK" was clicked or a choice was double | |
| @@ -56,7 +63,7 @@ | |
| * <li>If the dialog was canceled, the selection will be empty.</li> | |
| * <li> | |
| * </ul> | |
| - * | |
| + * | |
| * @param <T> | |
| * the generic type | |
| * @author Forge | |
| @@ -64,15 +71,15 @@ | |
| */ | |
| public class ListChooser<T> { | |
| // Data and number of choices for the list | |
| - private List<T> list; | |
| - private int minChoices, maxChoices; | |
| + private final List<T> list; | |
| + private final int minChoices, maxChoices; | |
| // Flag: was the dialog already shown? | |
| private boolean called; | |
| // initialized before; listeners may be added to it | |
| - private FList<T> lstChoices; | |
| - private FOptionPane optionPane; | |
| + private final FList<T> lstChoices; | |
| + private final FOptionPane optionPane; | |
| public ListChooser(final String title, final int minChoices, final int maxChoices, final Collection<T> list, final Function<T, String> display) { | |
| FThreads.assertExecutedByEdt(true); | |
| @@ -97,7 +104,7 @@ | |
| this.lstChoices.setCellRenderer(new TransformedCellRenderer(display)); | |
| } | |
| - FScrollPane listScroller = new FScrollPane(this.lstChoices, true); | |
| + final FScrollPane listScroller = new FScrollPane(this.lstChoices, true); | |
| int minWidth = this.lstChoices.getAutoSizeWidth(); | |
| if (this.lstChoices.getModel().getSize() > this.lstChoices.getVisibleRowCount()) { | |
| minWidth += listScroller.getVerticalScrollBar().getPreferredSize().width; | |
| @@ -120,16 +127,14 @@ | |
| } | |
| this.lstChoices.addKeyListener(new KeyAdapter() { | |
| - @Override | |
| - public void keyPressed(KeyEvent e) { | |
| + @Override public void keyPressed(final KeyEvent e) { | |
| if (e.getKeyCode() == KeyEvent.VK_ENTER) { | |
| ListChooser.this.commit(); | |
| } | |
| } | |
| }); | |
| this.lstChoices.addMouseListener(new FMouseAdapter() { | |
| - @Override | |
| - public void onLeftClick(MouseEvent e) { | |
| + @Override public void onLeftClick(final MouseEvent e) { | |
| if (e.getClickCount() == 2) { | |
| ListChooser.this.commit(); | |
| } | |
| @@ -140,7 +145,7 @@ | |
| /** | |
| * Returns the FList used in the list chooser. this is useful for | |
| * registering listeners before showing the dialog. | |
| - * | |
| + * | |
| * @return a {@link javax.swing.JList} object. | |
| */ | |
| public FList<T> getLstChoices() { | |
| @@ -154,7 +159,7 @@ | |
| /** | |
| * Shows the dialog and returns after the dialog was closed. | |
| - * | |
| + * | |
| * @param index0 index to select when shown | |
| * @return a boolean. | |
| */ | |
| @@ -194,7 +199,7 @@ | |
| /** | |
| * Returns if the dialog was closed by pressing "OK" or double clicking an | |
| * option the last time. | |
| - * | |
| + * | |
| * @return a boolean. | |
| */ | |
| public boolean isCommitted() { | |
| @@ -206,7 +211,7 @@ | |
| /** | |
| * Returns the selected indices as a list of integers. | |
| - * | |
| + * | |
| * @return a {@link java.util.List} object. | |
| */ | |
| public int[] getSelectedIndices() { | |
| @@ -219,7 +224,7 @@ | |
| /** | |
| * Returns the selected values as a list of objects. no casts are necessary | |
| * when retrieving the objects. | |
| - * | |
| + * | |
| * @return a {@link java.util.List} object. | |
| */ | |
| public List<T> getSelectedValues() { | |
| @@ -231,7 +236,7 @@ | |
| /** | |
| * Returns the (minimum) selected index, or -1. | |
| - * | |
| + * | |
| * @return a int. | |
| */ | |
| public int getSelectedIndex() { | |
| @@ -243,14 +248,14 @@ | |
| /** | |
| * Returns the (first) selected value, or null. | |
| - * | |
| + * | |
| * @return a T object. | |
| */ | |
| public T getSelectedValue() { | |
| if (!this.called) { | |
| throw new IllegalStateException("not yet shown"); | |
| } | |
| - return (T) this.lstChoices.getSelectedValue(); | |
| + return this.lstChoices.getSelectedValue(); | |
| } | |
| /** | |
| @@ -302,7 +307,7 @@ | |
| * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean) | |
| */ | |
| @Override | |
| - public Component getListCellRendererComponent(JList<? extends T> list, T value, int index, boolean isSelected, boolean cellHasFocus) { | |
| + public Component getListCellRendererComponent(final JList<? extends T> list, final T value, final int index, final boolean isSelected, final boolean cellHasFocus) { | |
| // TODO Auto-generated method stub | |
| return defRenderer.getListCellRendererComponent(list, transformer.apply(value), index, isSelected, cellHasFocus); | |
| } | |
| Index: forge-gui/src/main/java/forge/interfaces/IProgressBar.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui/src/main/java/forge/interfaces/IProgressBar.java (revision 29316) | |
| +++ forge-gui/src/main/java/forge/interfaces/IProgressBar.java (revision 29317) | |
| @@ -1,12 +1,11 @@ | |
| package forge.interfaces; | |
| public interface IProgressBar { | |
| - void setDescription(final String s0); | |
| + void setDescription(String s0); | |
| void setValue(int value0); | |
| void reset(); | |
| void setShowETA(boolean b0); | |
| void setShowCount(boolean b0); | |
| - boolean isPercentMode(); | |
| void setPercentMode(boolean percentMode0); | |
| int getMaximum(); | |
| void setMaximum(int maximum0); | |
| Index: forge-gui-desktop/src/main/java/forge/screens/workshop/controllers/CCardScript.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/workshop/controllers/CCardScript.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/workshop/controllers/CCardScript.java (revision 29317) | |
| @@ -12,7 +12,6 @@ | |
| import javax.swing.text.StyledDocument; | |
| import forge.Singletons; | |
| -import forge.UiCommand; | |
| import forge.card.CardDb; | |
| import forge.card.CardRules; | |
| import forge.card.CardScriptInfo; | |
| @@ -29,9 +28,9 @@ | |
| import forge.screens.workshop.views.VWorkshopCatalog; | |
| import forge.toolbox.FOptionPane; | |
| -/** | |
| +/** | |
| * Controls the "card script" panel in the workshop UI. | |
| - * | |
| + * | |
| * <br><br><i>(C at beginning of class name denotes a control class.)</i> | |
| * | |
| */ | |
| @@ -56,7 +55,7 @@ | |
| } | |
| @Override | |
| public void changedUpdate(final DocumentEvent arg0) { | |
| - //Plain text components do not fire these events | |
| + //Plain text components do not fire these events | |
| } | |
| }); | |
| VCardScript.SINGLETON_INSTANCE.getTxtScript().addFocusListener(new FocusListener() { | |
| @@ -71,7 +70,7 @@ | |
| } | |
| private void updateDirtyFlag() { | |
| - boolean isTextNowDirty = !refreshing && currentScriptInfo != null && !VCardScript.SINGLETON_INSTANCE.getTxtScript().getText().equals(currentScriptInfo.getText()); | |
| + final boolean isTextNowDirty = !refreshing && currentScriptInfo != null && !VCardScript.SINGLETON_INSTANCE.getTxtScript().getText().equals(currentScriptInfo.getText()); | |
| if (isTextDirty == isTextNowDirty) { return; } | |
| isTextDirty = isTextNowDirty; | |
| VCardDesigner.SINGLETON_INSTANCE.getBtnSaveCard().setEnabled(isTextNowDirty); | |
| @@ -83,7 +82,7 @@ | |
| return currentCard; | |
| } | |
| - public void showCard(PaperCard card) { | |
| + public void showCard(final PaperCard card) { | |
| if (currentCard == card || switchInProgress) { return; } | |
| if (!canSwitchAway(true)) { //ensure current card saved before changing to a different card | |
| @@ -118,7 +117,7 @@ | |
| return (currentScriptInfo != null && isTextDirty); | |
| } | |
| - public boolean canSwitchAway(boolean isCardChanging) { | |
| + public boolean canSwitchAway(final boolean isCardChanging) { | |
| if (switchInProgress) { return false; } | |
| if (!hasChanges()) { return true; } | |
| @@ -144,24 +143,23 @@ | |
| public boolean saveChanges() { | |
| if (!hasChanges()) { return true; } //not need if text hasn't been changed | |
| - String text = VCardScript.SINGLETON_INSTANCE.getTxtScript().getText(); | |
| + final String text = VCardScript.SINGLETON_INSTANCE.getTxtScript().getText(); | |
| if (!currentScriptInfo.trySetText(text)) { | |
| return false; | |
| } | |
| updateDirtyFlag(); | |
| - String oldName = currentCard.getName(); | |
| + final String oldName = currentCard.getName(); | |
| - CardRules newRules = CardRules.fromScript(Arrays.asList(text.split("\n"))); | |
| - CardDb cardDb = newRules.isVariant() ? FModel.getMagicDb().getVariantCards() : | |
| + final CardRules newRules = CardRules.fromScript(Arrays.asList(text.split("\n"))); | |
| + final CardDb cardDb = newRules.isVariant() ? FModel.getMagicDb().getVariantCards() : | |
| FModel.getMagicDb().getCommonCards(); | |
| cardDb.getEditor().putCard(newRules); | |
| if (newRules.getName().equals(oldName)) { | |
| Card.updateCard(currentCard); | |
| - } | |
| - else { | |
| + } else { | |
| currentCard = cardDb.getCard(newRules.getName()); | |
| } | |
| @@ -172,14 +170,6 @@ | |
| } | |
| //========== Overridden methods | |
| - | |
| - /* (non-Javadoc) | |
| - * @see forge.gui.framework.ICDoc#getCommandOnSelect() | |
| - */ | |
| - @Override | |
| - public UiCommand getCommandOnSelect() { | |
| - return null; | |
| - } | |
| @Override | |
| public void register() { | |
| Index: forge-gui-desktop/src/main/java/forge/screens/match/CMatchUI.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/match/CMatchUI.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/match/CMatchUI.java (revision 29317) | |
| @@ -6,12 +6,12 @@ | |
| * 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 <http://www.gnu.org/licenses/>. | |
| */ | |
| @@ -42,7 +42,6 @@ | |
| import forge.ImageCache; | |
| import forge.LobbyPlayer; | |
| import forge.Singletons; | |
| -import forge.UiCommand; | |
| import forge.assets.FSkinProp; | |
| import forge.control.KeyboardShortcuts; | |
| import forge.deck.CardPool; | |
| @@ -109,7 +108,7 @@ | |
| * 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. | |
| - * | |
| + * | |
| * <br><br><i>(C at beginning of class name denotes a control class.)</i> | |
| */ | |
| public final class CMatchUI | |
| @@ -117,7 +116,7 @@ | |
| implements ICDoc, IMenuProvider { | |
| private final FScreen screen; | |
| - private VMatchUI view; | |
| + private final VMatchUI view; | |
| private final CMatchUIMenus menus = new CMatchUIMenus(this); | |
| private final Map<EDocID, IVDoc<? extends ICDoc>> myDocs; | |
| private final TargetingOverlay targetingOverlay = new TargetingOverlay(this); | |
| @@ -237,11 +236,11 @@ | |
| } | |
| private SkinImage getPlayerAvatar(final PlayerView p, final int defaultIndex) { | |
| - if (avatarImages.containsKey(p.getLobbyPlayerName())) { | |
| + if (avatarImages.containsKey(p.getLobbyPlayerName())) { | |
| return ImageCache.getIcon(avatarImages.get(p.getLobbyPlayerName())); | |
| } | |
| - int avatarIdx = p.getAvatarIndex(); | |
| + final int avatarIdx = p.getAvatarIndex(); | |
| return FSkin.getAvatars().get(avatarIdx >= 0 ? avatarIdx : defaultIndex); | |
| } | |
| @@ -335,7 +334,7 @@ | |
| cDetailPicture.showItem(item); | |
| } | |
| - private int getPlayerIndex(PlayerView player) { | |
| + private int getPlayerIndex(final PlayerView player) { | |
| return sortedPlayers.indexOf(player); | |
| } | |
| @@ -344,7 +343,7 @@ | |
| final CombatView combat = getGameView().getCombat(); | |
| if (combat != null && combat.getNumAttackers() > 0 && getGameView().peekStack() == null) { | |
| if (selectedDocBeforeCombat == null) { | |
| - IVDoc<? extends ICDoc> combatDoc = EDocID.REPORT_COMBAT.getDoc(); | |
| + final IVDoc<? extends ICDoc> combatDoc = EDocID.REPORT_COMBAT.getDoc(); | |
| if (combatDoc.getParentCell() != null) { | |
| selectedDocBeforeCombat = combatDoc.getParentCell().getSelected(); | |
| if (selectedDocBeforeCombat != combatDoc) { | |
| @@ -459,11 +458,6 @@ | |
| } | |
| @Override | |
| - public UiCommand getCommandOnSelect() { | |
| - return null; | |
| - } | |
| - | |
| - @Override | |
| public void register() { | |
| initHandViews(); | |
| registerDocs(); | |
| @@ -516,7 +510,7 @@ | |
| /** | |
| * Find the card panel belonging to a card, bringing up the corresponding | |
| * window or tab if necessary. | |
| - * | |
| + * | |
| * @param card | |
| * the {@link CardView} to find a panel for. | |
| * @return a {@link CardPanel}, or {@code null} if no corresponding panel is | |
| @@ -554,6 +548,7 @@ | |
| return null; | |
| } | |
| + @Override | |
| public void updateButtons(final PlayerView owner, final String label1, final String label2, final boolean enable1, final boolean enable2, final boolean focus1) { | |
| final FButton btn1 = view.getBtnOK(), btn2 = view.getBtnCancel(); | |
| btn1.setText(label1); | |
| @@ -574,7 +569,7 @@ | |
| @Override | |
| public void flashIncorrectAction() { | |
| - SDisplayUtil.remind(getCPrompt().getView()); | |
| + getCPrompt().remind(); | |
| } | |
| @Override | |
| @@ -591,7 +586,7 @@ | |
| @Override | |
| public void updateTurn(final PlayerView player) { | |
| - VField nextField = getFieldViewFor(player); | |
| + final VField nextField = getFieldViewFor(player); | |
| SDisplayUtil.showTab(nextField); | |
| cPrompt.updateText(); | |
| repaintCardOverlays(); | |
| @@ -622,7 +617,7 @@ | |
| FloatingCardArea.closeAll(); //ensure floating card areas cleared and closed after the game | |
| final GameView gameView = getGameView(); | |
| if (hasLocalPlayers() || gameView.isMatchOver()) { | |
| - new ViewWinLose(gameView, this); | |
| + new ViewWinLose(gameView, this).show(); | |
| } | |
| if (showOverlay) { | |
| SOverlayUtils.showOverlay(); | |
| @@ -652,7 +647,7 @@ | |
| /** | |
| * Highlight a card on the playfield. | |
| - * | |
| + * | |
| * @param card | |
| * a card to be highlighted | |
| */ | |
| @@ -759,6 +754,7 @@ | |
| cPrompt.setMessage(message); | |
| } | |
| + @Override | |
| public Object showManaPool(final PlayerView player) { | |
| return null; //not needed since mana pool icons are always visible | |
| } | |
| @@ -809,12 +805,6 @@ | |
| Singletons.getControl().setCurrentScreen(screen); | |
| SDisplayUtil.showTab(EDocID.REPORT_LOG.getDoc()); | |
| - // per player observers were set in CMatchUI.SINGLETON_INSTANCE.initMatch | |
| - //Set Field shown to current player. | |
| - //if (util.getHumanCount() > 0) { | |
| - final VField nextField = getFieldViewFor(gameView.getPlayers().get(0)); | |
| - SDisplayUtil.showTab(nextField); | |
| - //} | |
| SOverlayUtils.hideOverlay(); | |
| } | |
| @@ -951,7 +941,7 @@ | |
| final List<VField> fieldViews = getFieldViews(); | |
| // Human field is at index [0] | |
| - PhaseIndicator fvHuman = fieldViews.get(0).getPhaseIndicator(); | |
| + final PhaseIndicator fvHuman = fieldViews.get(0).getPhaseIndicator(); | |
| fvHuman.getLblUpkeep().setEnabled(prefs.getPrefBoolean(FPref.PHASE_HUMAN_UPKEEP)); | |
| fvHuman.getLblDraw().setEnabled(prefs.getPrefBoolean(FPref.PHASE_HUMAN_DRAW)); | |
| fvHuman.getLblMain1().setEnabled(prefs.getPrefBoolean(FPref.PHASE_HUMAN_MAIN1)); | |
| @@ -967,7 +957,7 @@ | |
| // AI field is at index [1], ... | |
| for (int i = 1; i < fieldViews.size(); i++) { | |
| - PhaseIndicator fvAi = fieldViews.get(i).getPhaseIndicator(); | |
| + final PhaseIndicator fvAi = fieldViews.get(i).getPhaseIndicator(); | |
| fvAi.getLblUpkeep().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_UPKEEP)); | |
| fvAi.getLblDraw().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_DRAW)); | |
| fvAi.getLblMain1().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_MAIN1)); | |
| @@ -981,17 +971,15 @@ | |
| fvAi.getLblEndTurn().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_EOT)); | |
| fvAi.getLblCleanup().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_CLEANUP)); | |
| } | |
| - | |
| - //Singletons.getView().getViewMatch().setLayoutParams(prefs.getPref(FPref.UI_LAYOUT_PARAMS)); | |
| } | |
| @Override | |
| - public void message(String message, String title) { | |
| + public void message(final String message, final String title) { | |
| SOptionPane.showMessageDialog(message, title); | |
| } | |
| @Override | |
| - public void showErrorDialog(String message, String title) { | |
| + public void showErrorDialog(final String message, final String title) { | |
| SOptionPane.showErrorDialog(message, title); | |
| } | |
| Index: forge-gui-desktop/src/main/java/forge/screens/home/VLobby.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/home/VLobby.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/home/VLobby.java (revision 29317) | |
| @@ -24,9 +24,7 @@ | |
| import com.google.common.collect.Lists; | |
| import forge.AIOption; | |
| -import forge.GuiBase; | |
| import forge.UiCommand; | |
| -import forge.assets.FSkinProp; | |
| import forge.deck.CardPool; | |
| import forge.deck.Deck; | |
| import forge.deck.DeckProxy; | |
| @@ -60,6 +58,7 @@ | |
| import forge.util.Aggregates; | |
| import forge.util.Lang; | |
| import forge.util.NameGenerator; | |
| +import forge.util.gui.SOptionPane; | |
| import forge.util.storage.IStorage; | |
| /** | |
| @@ -200,6 +199,7 @@ | |
| getPlayerPanelWithFocus().focusOnAvatar(); | |
| } | |
| + @Override | |
| public void update(final boolean fullUpdate) { | |
| activePlayersNum = lobby.getNumberOfSlots(); | |
| addPlayerBtn.setEnabled(activePlayersNum < MAX_PLAYERS); | |
| @@ -275,7 +275,7 @@ | |
| void setReady(final int index, final boolean ready) { | |
| if (ready && decks[index] == null) { | |
| - GuiBase.getInterface().showOptionDialog("Select a deck before readying!", "Error", FSkinProp.ICO_WARNING, new String[] { "Ok" }, 0); | |
| + SOptionPane.showErrorDialog("Select a deck before readying!"); | |
| update(false); | |
| return; | |
| } | |
| @@ -391,7 +391,7 @@ | |
| planarDeckPanels.add(planarDeckPanel); | |
| // Vanguard avatar list | |
| - FPanel vgdDeckPanel = new FPanel(); | |
| + final FPanel vgdDeckPanel = new FPanel(); | |
| vgdDeckPanel.setBorderToggle(false); | |
| final FList<Object> vgdAvatarList = new FList<Object>(); | |
| @@ -624,14 +624,6 @@ | |
| /** Gets the random deck checkbox for Artifacts. */ | |
| FCheckBox getCbArtifacts() { return cbArtifacts; } | |
| - FCheckBox getVntArchenemy() { return vntArchenemy; } | |
| - FCheckBox getVntArchenemyRumble() { return vntArchenemyRumble; } | |
| - FCheckBox getVntCommander() { return vntCommander; } | |
| - FCheckBox getVntMomirBasic() { return vntMomirBasic; } | |
| - FCheckBox getVntPlanechase() { return vntPlanechase; } | |
| - FCheckBox getVntTinyLeaders() { return vntTinyLeaders; } | |
| - FCheckBox getVntVanguard() { return vntVanguard; } | |
| - | |
| public final List<PlayerPanel> getPlayerPanels() { | |
| return playerPanels; | |
| } | |
| @@ -642,7 +634,7 @@ | |
| return iPlayer == playerWithFocus; | |
| } | |
| - public final FDeckChooser getDeckChooser(int playernum) { | |
| + public final FDeckChooser getDeckChooser(final int playernum) { | |
| return deckChoosers.get(playernum); | |
| } | |
| @@ -663,7 +655,7 @@ | |
| } | |
| /** Revalidates the player and deck sections. Necessary after adding or hiding any panels. */ | |
| - private void refreshPanels(boolean refreshPlayerFrame, boolean refreshDeckFrame) { | |
| + private void refreshPanels(final boolean refreshPlayerFrame, final boolean refreshDeckFrame) { | |
| if (refreshPlayerFrame) { | |
| playersScroll.validate(); | |
| playersScroll.repaint(); | |
| @@ -674,11 +666,11 @@ | |
| } | |
| } | |
| - public void changePlayerFocus(int newFocusOwner) { | |
| + public void changePlayerFocus(final int newFocusOwner) { | |
| changePlayerFocus(newFocusOwner, lobby.getGameType()); | |
| } | |
| - void changePlayerFocus(int newFocusOwner, GameType gType) { | |
| + void changePlayerFocus(final int newFocusOwner, final GameType gType) { | |
| final PlayerPanel oldFocus = getPlayerPanelWithFocus(); | |
| if (oldFocus != null) { | |
| oldFocus.setFocused(false); | |
| @@ -695,15 +687,15 @@ | |
| /** Saves avatar prefs for players one and two. */ | |
| void updateAvatarPrefs() { | |
| - int pOneIndex = playerPanels.get(0).getAvatarIndex(); | |
| - int pTwoIndex = playerPanels.get(1).getAvatarIndex(); | |
| + final int pOneIndex = playerPanels.get(0).getAvatarIndex(); | |
| + final int pTwoIndex = playerPanels.get(1).getAvatarIndex(); | |
| prefs.setPref(FPref.UI_AVATARS, pOneIndex + "," + pTwoIndex); | |
| prefs.save(); | |
| } | |
| /** Adds a pre-styled FLabel component with the specified title. */ | |
| - FLabel newLabel(String title) { | |
| + FLabel newLabel(final String title) { | |
| return new FLabel.Builder().text(title).fontSize(14).fontStyle(Font.ITALIC).build(); | |
| } | |
| @@ -735,7 +727,7 @@ | |
| final String type = typeOptions[typeIndex]; | |
| String confirmMsg, newName; | |
| - List<String> usedNames = getPlayerNames(); | |
| + final List<String> usedNames = getPlayerNames(); | |
| do { | |
| newName = NameGenerator.getRandomName(gender, type, usedNames); | |
| confirmMsg = "Would you like to use the name \"" + newName + "\", or try again?"; | |
| @@ -745,8 +737,8 @@ | |
| } | |
| List<String> getPlayerNames() { | |
| - List<String> names = new ArrayList<String>(); | |
| - for (PlayerPanel pp : playerPanels) { | |
| + final List<String> names = new ArrayList<String>(); | |
| + for (final PlayerPanel pp : playerPanels) { | |
| names.add(pp.getPlayerName()); | |
| } | |
| return names; | |
| @@ -776,8 +768,8 @@ | |
| final ActionListener nameListener = new ActionListener() { | |
| @Override | |
| - public void actionPerformed(ActionEvent e) { | |
| - FTextField nField = (FTextField)e.getSource(); | |
| + public void actionPerformed(final ActionEvent e) { | |
| + final FTextField nField = (FTextField)e.getSource(); | |
| nField.transferFocus(); | |
| } | |
| }; | |
| @@ -812,7 +804,7 @@ | |
| /** Return all the Vanguard avatars. */ | |
| public Iterable<PaperCard> getAllAvatars() { | |
| if (vgdAllAvatars.isEmpty()) { | |
| - for (PaperCard c : FModel.getMagicDb().getVariantCards().getAllCards()) { | |
| + for (final PaperCard c : FModel.getMagicDb().getVariantCards().getAllCards()) { | |
| if (c.getRules().getType().isVanguard()) { | |
| vgdAllAvatars.add(c); | |
| } | |
| @@ -842,7 +834,7 @@ | |
| humanListData.add("Random"); | |
| aiListData.add("Use deck's default avatar (random if unavailable)"); | |
| aiListData.add("Random"); | |
| - for (PaperCard cp : getAllAvatars()) { | |
| + for (final PaperCard cp : getAllAvatars()) { | |
| humanListData.add(cp); | |
| if (!cp.getRules().getAiHints().getRemRandomDecks()) { | |
| nonRandomHumanAvatars.add(cp); | |
| @@ -858,9 +850,9 @@ | |
| } | |
| /** update vanguard list. */ | |
| - public void updateVanguardList(int playerIndex) { | |
| - FList<Object> vgdList = getVanguardLists().get(playerIndex); | |
| - Object lastSelection = vgdList.getSelectedValue(); | |
| + public void updateVanguardList(final int playerIndex) { | |
| + final FList<Object> vgdList = getVanguardLists().get(playerIndex); | |
| + final Object lastSelection = vgdList.getSelectedValue(); | |
| vgdList.setListData(isPlayerAI(playerIndex) ? aiListData : humanListData); | |
| if (null != lastSelection) { | |
| vgdList.setSelectedValue(lastSelection, true); | |
| Index: forge-gui-desktop/src/main/java/forge/toolbox/FComboBox.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/toolbox/FComboBox.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/toolbox/FComboBox.java (revision 29317) | |
| @@ -1,17 +1,29 @@ | |
| package forge.toolbox; | |
| -import forge.interfaces.IComboBox; | |
| -import forge.toolbox.FSkin.SkinFont; | |
| -import forge.toolbox.FSkin.SkinnedComboBox; | |
| +import java.awt.Component; | |
| +import java.awt.FontMetrics; | |
| +import java.awt.Graphics; | |
| +import java.awt.Graphics2D; | |
| +import java.awt.LayoutManager; | |
| +import java.util.Vector; | |
| -import javax.swing.*; | |
| +import javax.swing.ComboBoxModel; | |
| +import javax.swing.DefaultListCellRenderer; | |
| +import javax.swing.JButton; | |
| +import javax.swing.JComponent; | |
| +import javax.swing.JLabel; | |
| +import javax.swing.JList; | |
| +import javax.swing.ListCellRenderer; | |
| +import javax.swing.SwingConstants; | |
| +import javax.swing.UIManager; | |
| import javax.swing.border.Border; | |
| import javax.swing.border.EmptyBorder; | |
| import javax.swing.plaf.basic.BasicComboBoxUI; | |
| import javax.swing.plaf.basic.ComboPopup; | |
| -import java.awt.*; | |
| -import java.util.Vector; | |
| +import forge.interfaces.IComboBox; | |
| +import forge.toolbox.FSkin.SkinFont; | |
| +import forge.toolbox.FSkin.SkinnedComboBox; | |
| @SuppressWarnings("serial") | |
| public class FComboBox<E> extends SkinnedComboBox<E> implements IComboBox<E> { | |
| @@ -20,7 +32,7 @@ | |
| RIGHT (SwingConstants.RIGHT), | |
| CENTER (SwingConstants.CENTER); | |
| private int value; | |
| - private TextAlignment(int value) { this.value = value; } | |
| + private TextAlignment(final int value) { this.value = value; } | |
| public int getInt() { return value; } | |
| } | |
| private TextAlignment textAlignment = TextAlignment.LEFT; | |
| @@ -31,15 +43,15 @@ | |
| super(); | |
| initialize(); | |
| } | |
| - public FComboBox(ComboBoxModel<E> model) { | |
| + public FComboBox(final ComboBoxModel<E> model) { | |
| super(model); | |
| initialize(); | |
| } | |
| - public FComboBox(E[] items) { | |
| + public FComboBox(final E[] items) { | |
| super(items); | |
| initialize(); | |
| } | |
| - public FComboBox(Vector<E> items) { | |
| + public FComboBox(final Vector<E> items) { | |
| super(items); | |
| initialize(); | |
| } | |
| @@ -49,18 +61,18 @@ | |
| setBorder(getDefaultBorder()); | |
| } | |
| - private Border getDefaultBorder() { | |
| + private static Border getDefaultBorder() { | |
| return UIManager.getBorder("ComboBox.border"); | |
| } | |
| public String getText() { | |
| - Object selectedItem = getSelectedItem(); | |
| + final Object selectedItem = getSelectedItem(); | |
| if (selectedItem == null) { | |
| return ""; | |
| } | |
| return selectedItem.toString(); | |
| } | |
| - public void setText(String text0) { | |
| + public void setText(final String text0) { | |
| setSelectedItem(null); | |
| dataModel.setSelectedItem(text0); //use this to get around inability to set selected item that's not in items | |
| } | |
| @@ -69,24 +81,24 @@ | |
| return textAlignment; | |
| } | |
| - public void setTextAlignment(TextAlignment align) { | |
| + public void setTextAlignment(final TextAlignment align) { | |
| textAlignment = align; | |
| } | |
| public SkinFont getSkinFont() { | |
| return this.skinFont; | |
| } | |
| - | |
| + | |
| - public void setSkinFont(SkinFont skinFont0) { | |
| + public void setSkinFont(final SkinFont skinFont0) { | |
| this.skinFont = skinFont0; | |
| this.setFont(skinFont0); | |
| } | |
| public int getAutoSizeWidth() { | |
| int maxWidth = 0; | |
| - FontMetrics metrics = this.getFontMetrics(this.getFont()); | |
| + final FontMetrics metrics = this.getFontMetrics(this.getFont()); | |
| for (int i = 0; i < this.getItemCount(); i++) { | |
| - int width = metrics.stringWidth(this.getItemAt(i).toString()); | |
| + final int width = metrics.stringWidth(this.getItemAt(i).toString()); | |
| if (width > maxWidth) { | |
| maxWidth = width; | |
| } | |
| @@ -101,9 +113,9 @@ | |
| } | |
| @Override | |
| - protected void paintComponent(Graphics g) { | |
| + protected void paintComponent(final Graphics g) { | |
| super.paintComponent(g); | |
| - Graphics2D g2d = (Graphics2D)g; | |
| + final Graphics2D g2d = (Graphics2D)g; | |
| g2d.setPaint(getForeground()); | |
| int shapeWidth = 8; | |
| int shapeHeight = 8; | |
| @@ -115,8 +127,8 @@ | |
| x -= 4; | |
| y--; | |
| } | |
| - int[] xPoints = {x, x + shapeWidth, x + (shapeWidth / 2)}; | |
| - int[] yPoints = {y, y, y + (shapeHeight / 2)}; | |
| + final int[] xPoints = {x, x + shapeWidth, x + (shapeWidth / 2)}; | |
| + final int[] yPoints = {y, y, y + (shapeHeight / 2)}; | |
| g2d.fillPolygon(xPoints, yPoints, 3); | |
| } | |
| @@ -128,8 +140,8 @@ | |
| @Override | |
| protected ComboPopup createPopup() { | |
| - ComboPopup p = super.createPopup(); | |
| - JComponent c = (JComponent)p; | |
| + final ComboPopup p = super.createPopup(); | |
| + final JComponent c = (JComponent)p; | |
| c.setBorder(getDefaultBorder()); | |
| return p; | |
| } | |
| @@ -137,10 +149,10 @@ | |
| @Override | |
| protected JButton createArrowButton() { | |
| return new JButton() { //return button that takes up no space | |
| - @Override | |
| - public int getWidth() { | |
| - return 0; | |
| - } | |
| + @Override | |
| + public int getWidth() { | |
| + return 0; | |
| + } | |
| }; | |
| } | |
| @@ -152,14 +164,14 @@ | |
| @SuppressWarnings("hiding") | |
| private class CustomCellRenderer<E> implements ListCellRenderer<E> { | |
| - private DefaultListCellRenderer defaultRenderer = new DefaultListCellRenderer(); | |
| + private final DefaultListCellRenderer defaultRenderer = new DefaultListCellRenderer(); | |
| @Override | |
| public Component getListCellRendererComponent( | |
| - JList<? extends E> list, E value, int index, | |
| - boolean isSelected, boolean cellHasFocus) { | |
| + final JList<? extends E> list, final E value, final int index, | |
| + final boolean isSelected, final boolean cellHasFocus) { | |
| - JLabel lblItem = (JLabel) defaultRenderer.getListCellRendererComponent( | |
| + final JLabel lblItem = (JLabel) defaultRenderer.getListCellRendererComponent( | |
| list, value, index, isSelected, cellHasFocus); | |
| lblItem.setBorder(new EmptyBorder(4, 3, 4, 3)); | |
| Index: forge-gui-desktop/src/main/java/forge/screens/home/online/CSubmenuOnlineLobby.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/home/online/CSubmenuOnlineLobby.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/home/online/CSubmenuOnlineLobby.java (revision 29317) | |
| @@ -5,9 +5,10 @@ | |
| import javax.swing.JMenu; | |
| +import org.apache.commons.lang3.StringUtils; | |
| + | |
| import forge.GuiBase; | |
| import forge.Singletons; | |
| -import forge.UiCommand; | |
| import forge.assets.FSkinProp; | |
| import forge.gui.FNetOverlay; | |
| import forge.gui.framework.FScreen; | |
| @@ -29,6 +30,7 @@ | |
| import forge.net.event.UpdateLobbyPlayerEvent; | |
| import forge.net.server.FServerManager; | |
| import forge.net.server.ServerGameLobby; | |
| +import forge.player.GamePlayerUtil; | |
| import forge.properties.ForgePreferences.FPref; | |
| import forge.screens.home.VLobby; | |
| import forge.screens.home.sanctioned.ConstructedGameMenu; | |
| @@ -38,6 +40,8 @@ | |
| SINGLETON_INSTANCE; | |
| final void host(final int portNumber) { | |
| + promptNameIfNeeded(); | |
| + | |
| final FServerManager server = FServerManager.getInstance(); | |
| final ServerGameLobby lobby = new ServerGameLobby(); | |
| final VLobby view = VOnlineLobby.SINGLETON_INSTANCE.setLobby(lobby); | |
| @@ -91,11 +95,13 @@ | |
| } | |
| final void join(final String hostname, final int port) { | |
| + promptNameIfNeeded(); | |
| + | |
| final IGuiGame gui = GuiBase.getInterface().getNewGuiGame(); | |
| final FGameClient client = new FGameClient(FModel.getPreferences().getPref(FPref.PLAYER_NAME), "0", gui); | |
| VOnlineLobby.SINGLETON_INSTANCE.setClient(client); | |
| FNetOverlay.SINGLETON_INSTANCE.setGameClient(client); | |
| - final ClientGameLobby lobby = new ClientGameLobby(); | |
| + final ClientGameLobby lobby = new ClientGameLobby(); | |
| final VLobby view = VOnlineLobby.SINGLETON_INSTANCE.setLobby(lobby); | |
| lobby.setListener(view); | |
| client.addLobbyListener(new ILobbyListener() { | |
| @@ -123,6 +129,13 @@ | |
| FNetOverlay.SINGLETON_INSTANCE.showUp(String.format("Connected to %s:%d", hostname, port)); | |
| } | |
| + private static void promptNameIfNeeded() { | |
| + //prompt user for player one name if needed | |
| + if (StringUtils.isBlank(FModel.getPreferences().getPref(FPref.PLAYER_NAME))) { | |
| + GamePlayerUtil.setPlayerName(); | |
| + } | |
| + } | |
| + | |
| @Override | |
| public void register() { | |
| } | |
| @@ -143,19 +156,11 @@ | |
| } | |
| /* (non-Javadoc) | |
| - * @see forge.gui.framework.ICDoc#getCommandOnSelect() | |
| - */ | |
| - @Override | |
| - public UiCommand getCommandOnSelect() { | |
| - return null; | |
| - } | |
| - | |
| - /* (non-Javadoc) | |
| * @see forge.gui.menubar.IMenuProvider#getMenus() | |
| */ | |
| @Override | |
| public List<JMenu> getMenus() { | |
| - List<JMenu> menus = new ArrayList<JMenu>(); | |
| + final List<JMenu> menus = new ArrayList<JMenu>(); | |
| menus.add(ConstructedGameMenu.getMenu()); | |
| return menus; | |
| } | |
| Index: forge-gui/src/main/java/forge/player/LobbyPlayerHuman.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui/src/main/java/forge/player/LobbyPlayerHuman.java (revision 29316) | |
| +++ forge-gui/src/main/java/forge/player/LobbyPlayerHuman.java (revision 29317) | |
| @@ -17,7 +17,7 @@ | |
| } | |
| @Override | |
| - public PlayerController createMindSlaveController(Player master, Player slave) { | |
| + public PlayerController createMindSlaveController(final Player master, final Player slave) { | |
| return new PlayerControllerHuman(slave, this, (PlayerControllerHuman)master.getController()); | |
| } | |
| @@ -29,7 +29,8 @@ | |
| return player; | |
| } | |
| - public void hear(LobbyPlayer player, String message) { | |
| - //ostedMatch.getController().hear(player, message); | |
| + @Override | |
| + public void hear(final LobbyPlayer player, final String message) { | |
| + //hostedMatch.getController().hear(player, message); | |
| } | |
| } | |
| \ No newline at end of file | |
| Index: forge-gui-desktop/src/main/java/forge/screens/bazaar/CBazaarUI.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/bazaar/CBazaarUI.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/bazaar/CBazaarUI.java (revision 29317) | |
| @@ -1,21 +1,18 @@ | |
| package forge.screens.bazaar; | |
| +import javax.swing.SwingUtilities; | |
| + | |
| import com.google.common.collect.Iterables; | |
| -import forge.UiCommand; | |
| import forge.gui.framework.ICDoc; | |
| import forge.quest.bazaar.QuestBazaarManager; | |
| import forge.toolbox.FLabel; | |
| -import javax.swing.*; | |
| - | |
| -/** | |
| - * TODO: Write javadoc for this type. | |
| - * | |
| - */ | |
| public enum CBazaarUI implements ICDoc { | |
| SINGLETON_INSTANCE; | |
| + private final VBazaarUI view = VBazaarUI.SINGLETON_INSTANCE; | |
| + | |
| /** | |
| * Controls top-level instance of bazaar. | |
| * @param v0   {@link forge.screens.bazaar.VBazaarUI} | |
| @@ -25,33 +22,23 @@ | |
| } | |
| /** Populate all stalls, and select first one. */ | |
| - public void initBazaar(QuestBazaarManager bazaar) { | |
| - VBazaarUI.SINGLETON_INSTANCE.populateStalls(); | |
| - ((FLabel) VBazaarUI.SINGLETON_INSTANCE.getPnlAllStalls().getComponent(0)).setSelected(true); | |
| + public void initBazaar(final QuestBazaarManager bazaar) { | |
| + view.populateStalls(); | |
| + ((FLabel) view.getPnlAllStalls().getComponent(0)).setSelected(true); | |
| showStall(Iterables.get(bazaar.getStallNames(), 0), bazaar); | |
| } | |
| /** @param s0   {@link java.lang.String} */ | |
| public void showStall(final String s0, final QuestBazaarManager bazaar) { | |
| SwingUtilities.invokeLater(new Runnable() { | |
| - @Override | |
| - public void run() { | |
| - VBazaarUI.SINGLETON_INSTANCE.getPnlSingleStall().setStall(bazaar.getStall(s0)); | |
| - VBazaarUI.SINGLETON_INSTANCE.getPnlSingleStall().updateStall(); | |
| + @Override public void run() { | |
| + view.getPnlSingleStall().setStall(bazaar.getStall(s0)); | |
| + view.getPnlSingleStall().updateStall(); | |
| } | |
| }); | |
| } | |
| - /* (non-Javadoc) | |
| - * @see forge.gui.framework.ICDoc#getCommandOnSelect() | |
| - */ | |
| @Override | |
| - public UiCommand getCommandOnSelect() { | |
| - // TODO Auto-generated method stub | |
| - return null; | |
| - } | |
| - | |
| - @Override | |
| public void register() { | |
| } | |
| @@ -60,8 +47,6 @@ | |
| */ | |
| @Override | |
| public void initialize() { | |
| - // TODO Auto-generated method stub | |
| - | |
| } | |
| /* (non-Javadoc) | |
| @@ -69,7 +54,5 @@ | |
| */ | |
| @Override | |
| public void update() { | |
| - // TODO Auto-generated method stub | |
| - | |
| } | |
| } | |
| Index: forge-gui-desktop/src/main/java/forge/screens/match/QuestDraftWinLose.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/match/QuestDraftWinLose.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/match/QuestDraftWinLose.java (revision 29317) | |
| @@ -5,12 +5,12 @@ | |
| * 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 <http://www.gnu.org/licenses/>. | |
| */ | |
| @@ -19,17 +19,12 @@ | |
| import java.awt.event.ActionEvent; | |
| import java.awt.event.ActionListener; | |
| -import forge.Singletons; | |
| import forge.assets.FSkinProp; | |
| import forge.game.GameView; | |
| -import forge.gui.SOverlayUtils; | |
| -import forge.gui.framework.FScreen; | |
| import forge.match.NextGameDecision; | |
| import forge.model.FModel; | |
| import forge.quest.QuestController; | |
| import forge.quest.QuestDraftUtils; | |
| -import forge.screens.home.quest.CSubmenuChallenges; | |
| -import forge.screens.home.quest.CSubmenuDuels; | |
| import forge.screens.home.quest.CSubmenuQuestDraft; | |
| import forge.screens.home.quest.VSubmenuQuestDraft; | |
| import forge.toolbox.FOptionPane; | |
| @@ -42,22 +37,20 @@ | |
| * Processes win/lose presentation for Quest events. This presentation is | |
| * displayed by WinLoseFrame. Components to be added to pnlCustom in | |
| * WinLoseFrame should use MigLayout. | |
| - * | |
| + * | |
| */ | |
| public class QuestDraftWinLose extends ControlWinLose { | |
| private final transient ViewWinLose view; | |
| - private final transient QuestController qData; | |
| /** | |
| * Instantiates a new quest win lose handler. | |
| - * | |
| + * | |
| * @param view0 ViewWinLose object | |
| * @param match2 | |
| */ | |
| public QuestDraftWinLose(final ViewWinLose view0, final GameView game0, final CMatchUI matchUI) { | |
| super(view0, game0, matchUI); | |
| this.view = view0; | |
| - qData = FModel.getQuest(); | |
| } | |
| /** | |
| @@ -66,17 +59,17 @@ | |
| * </p> | |
| * Checks conditions of win and fires various reward display methods | |
| * accordingly. | |
| - * | |
| + * | |
| * @return true, if successful | |
| */ | |
| @Override | |
| public final boolean populateCustomPanel() { | |
| - QuestController quest = FModel.getQuest(); | |
| + final QuestController quest = FModel.getQuest(); | |
| final boolean gameHadHumanPlayer = matchUI.hasLocalPlayers(); | |
| if (lastGame.isMatchOver()) { | |
| final String winner = lastGame.getWinningPlayerName(); | |
| - | |
| + | |
| quest.getAchievements().getCurrentDraft().setWinner(winner); | |
| quest.save(); | |
| } | |
| @@ -125,17 +118,4 @@ | |
| return false; //We're not awarding anything, so never display the custom panel. | |
| } | |
| - public final void actionOnQuitMatch() { | |
| - CSubmenuDuels.SINGLETON_INSTANCE.update(); | |
| - CSubmenuChallenges.SINGLETON_INSTANCE.update(); | |
| - | |
| - qData.setCurrentEvent(null); | |
| - qData.save(); | |
| - FModel.getQuestPreferences().save(); | |
| - matchUI.writeMatchPreferences(); | |
| - | |
| - Singletons.getControl().setCurrentScreen(FScreen.HOME_SCREEN); | |
| - | |
| - SOverlayUtils.hideOverlay(); | |
| - } | |
| } | |
| Index: forge-gui-desktop/src/main/java/forge/toolbox/SaveOpenDialog.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/toolbox/SaveOpenDialog.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/toolbox/SaveOpenDialog.java (revision 29317) | |
| @@ -6,39 +6,39 @@ | |
| * 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 <http://www.gnu.org/licenses/>. | |
| */ | |
| package forge.toolbox; | |
| -import javax.swing.*; | |
| +import java.io.File; | |
| + | |
| +import javax.swing.JFileChooser; | |
| +import javax.swing.JOptionPane; | |
| +import javax.swing.JPanel; | |
| import javax.swing.filechooser.FileFilter; | |
| import javax.swing.filechooser.FileNameExtensionFilter; | |
| -import java.io.File; | |
| -/** | |
| +/** | |
| * A class for showing open or save dialogs in Forge. | |
| - * | |
| - * | |
| - * | |
| */ | |
| @SuppressWarnings("serial") | |
| public class SaveOpenDialog extends JPanel { | |
| - private JFileChooser fc; | |
| + private final JFileChooser fc; | |
| /** | |
| * Enum to contain information for filetype filtering in the open/save dialog. | |
| * Add more entries to enum as needed. | |
| - * | |
| - * | |
| + * | |
| + * | |
| */ | |
| public enum Filetypes { | |
| LAYOUT ("Layout File", "xml"), | |
| @@ -46,14 +46,14 @@ | |
| private final String TypeName; | |
| private final String TypeExtension; | |
| - Filetypes(String Name, String Extension) { | |
| + Filetypes(final String Name, final String Extension) { | |
| this.TypeName = Name; | |
| this.TypeExtension = Extension; | |
| } | |
| } | |
| /** | |
| - * | |
| + * | |
| * constructor for a save or open dialog. | |
| */ | |
| public SaveOpenDialog() { | |
| @@ -65,7 +65,7 @@ | |
| * to Type to allow all files to be viewed/opened. | |
| * @param defFileName pass the default file to use, also determines directory | |
| * @param type label to tell what type of file to filter | |
| - * | |
| + * | |
| * | |
| */ | |
| public File OpenDialog(final File defFileName, final Filetypes type) { | |
| @@ -77,7 +77,7 @@ | |
| fc.addChoosableFileFilter(filter); | |
| } | |
| - int RetValue = fc.showOpenDialog(JOptionPane.getRootFrame()); | |
| + final int RetValue = fc.showOpenDialog(JOptionPane.getRootFrame()); | |
| if (RetValue == JFileChooser.APPROVE_OPTION) { | |
| final File RetFile = fc.getSelectedFile(); | |
| return RetFile; | |
| @@ -87,11 +87,11 @@ | |
| /** | |
| * Shows the save dialog. | |
| - * | |
| + * | |
| * @param defFileName default file name/directory to show when save dialog is opened | |
| * @param type file types to show in dialog | |
| - * | |
| - * | |
| + * | |
| + * | |
| */ | |
| public File SaveDialog(final File defFileName, final Filetypes type) { | |
| File RetFile = defFileName; | |
| @@ -104,7 +104,7 @@ | |
| fc.addChoosableFileFilter(filter); | |
| } | |
| - int RetValue = fc.showSaveDialog(JOptionPane.getRootFrame()); | |
| + final int RetValue = fc.showSaveDialog(JOptionPane.getRootFrame()); | |
| /* user picked save */ | |
| if (RetValue == JFileChooser.APPROVE_OPTION) { | |
| Index: forge-gui-desktop/src/main/java/forge/toolbox/FProgressBar.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/toolbox/FProgressBar.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/toolbox/FProgressBar.java (revision 29317) | |
| @@ -1,12 +1,13 @@ | |
| package forge.toolbox; | |
| -import forge.interfaces.IProgressBar; | |
| +import java.util.Date; | |
| -import javax.swing.*; | |
| +import javax.swing.JProgressBar; | |
| +import javax.swing.SwingUtilities; | |
| -import java.util.Date; | |
| +import forge.interfaces.IProgressBar; | |
| -/** | |
| +/** | |
| * A simple progress bar component using the Forge skin. | |
| */ | |
| @SuppressWarnings("serial") | |
| @@ -16,7 +17,7 @@ | |
| private String desc = ""; | |
| private boolean showETA = true; | |
| private boolean showCount = true; | |
| - | |
| + | |
| private boolean percentMode = false; | |
| public FProgressBar() { | |
| @@ -25,13 +26,14 @@ | |
| setStringPainted(true); | |
| } | |
| + @Override | |
| public void setDescription(final String s0) { | |
| desc = s0; | |
| setString(s0); | |
| } | |
| - | |
| + | |
| /** Increments bar, thread safe. Calculations executed on separate thread. */ | |
| - public void setValueThreadSafe(int value) { | |
| + public void setValueThreadSafe(final int value) { | |
| tempVal = value; | |
| SwingUtilities.invokeLater(barIncrementor); | |
| } | |
| @@ -45,14 +47,14 @@ | |
| }; | |
| @Override | |
| - public void setValue(int value0) { | |
| + public void setValue(final int value0) { | |
| super.setValue(value0); | |
| // String.format leads to StringBuilder anyway. Direct calls will be faster | |
| - StringBuilder sb = new StringBuilder(desc); | |
| + final StringBuilder sb = new StringBuilder(desc); | |
| if (showCount) { | |
| sb.append(" "); | |
| - int maximum = getMaximum(); | |
| + final int maximum = getMaximum(); | |
| if (percentMode) { | |
| sb.append(100 * value0 / maximum).append("%"); | |
| } | |
| @@ -69,6 +71,7 @@ | |
| } | |
| /** Resets the various values required for this class. */ | |
| + @Override | |
| public void reset() { | |
| setIndeterminate(true); | |
| setValue(0); | |
| @@ -79,24 +82,27 @@ | |
| setShowCount(true); | |
| } | |
| - public void setShowETA(boolean b0) { | |
| + @Override | |
| + public void setShowETA(final boolean b0) { | |
| showETA = b0; | |
| } | |
| - public void setShowCount(boolean b0) { | |
| + @Override | |
| + public void setShowCount(final boolean b0) { | |
| showCount = b0; | |
| } | |
| - private void calculateETA(int v0) { | |
| - float tempMillis = new Date().getTime(); | |
| - float timePerUnit = (tempMillis - startMillis) / v0; | |
| + private void calculateETA(final int v0) { | |
| + final float tempMillis = new Date().getTime(); | |
| + final float timePerUnit = (tempMillis - startMillis) / v0; | |
| etaSecs = (int) ((getMaximum() - v0) * timePerUnit) / 1000; | |
| } | |
| public boolean isPercentMode() { | |
| return percentMode; | |
| } | |
| - public void setPercentMode(boolean value) { | |
| + @Override | |
| + public void setPercentMode(final boolean value) { | |
| percentMode = value; | |
| } | |
| } | |
| Index: forge-gui-desktop/src/main/java/forge/screens/home/sanctioned/CSubmenuConstructed.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/home/sanctioned/CSubmenuConstructed.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/home/sanctioned/CSubmenuConstructed.java (revision 29317) | |
| @@ -5,7 +5,6 @@ | |
| import javax.swing.JMenu; | |
| -import forge.UiCommand; | |
| import forge.gui.framework.ICDoc; | |
| import forge.menus.IMenuProvider; | |
| import forge.menus.MenuUtil; | |
| @@ -13,7 +12,7 @@ | |
| /** | |
| * Controls the constructed submenu in the home UI. | |
| - * | |
| + * | |
| * <br><br><i>(C at beginning of class name denotes a control class.)</i> | |
| * | |
| */ | |
| @@ -46,19 +45,11 @@ | |
| } | |
| /* (non-Javadoc) | |
| - * @see forge.gui.framework.ICDoc#getCommandOnSelect() | |
| - */ | |
| - @Override | |
| - public UiCommand getCommandOnSelect() { | |
| - return null; | |
| - } | |
| - | |
| - /* (non-Javadoc) | |
| * @see forge.gui.menubar.IMenuProvider#getMenus() | |
| */ | |
| @Override | |
| public List<JMenu> getMenus() { | |
| - List<JMenu> menus = new ArrayList<JMenu>(); | |
| + final List<JMenu> menus = new ArrayList<JMenu>(); | |
| menus.add(ConstructedGameMenu.getMenu()); | |
| return menus; | |
| } | |
| Index: forge-gui-desktop/src/main/java/forge/screens/home/quest/VSubmenuQuestPrefs.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/home/quest/VSubmenuQuestPrefs.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/home/quest/VSubmenuQuestPrefs.java (revision 29317) | |
| @@ -46,8 +46,8 @@ | |
| /** */ | |
| private final FLabel lblTitle = new FLabel.Builder() | |
| - .text("Quest Preferences").fontAlign(SwingConstants.CENTER) | |
| - .opaque(true).fontSize(16).build(); | |
| + .text("Quest Preferences").fontAlign(SwingConstants.CENTER) | |
| + .opaque(true).fontSize(16).build(); | |
| private final JPanel pnlContent = new JPanel(); | |
| private final FScrollPane scrContent = new FScrollPane(pnlContent, false); | |
| Index: forge-gui-desktop/src/main/java/forge/toolbox/CardFaceSymbols.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/toolbox/CardFaceSymbols.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/toolbox/CardFaceSymbols.java (revision 29317) | |
| @@ -6,17 +6,22 @@ | |
| * 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 <http://www.gnu.org/licenses/>. | |
| */ | |
| package forge.toolbox; | |
| +import java.awt.Graphics; | |
| +import java.util.HashMap; | |
| +import java.util.Map; | |
| +import java.util.StringTokenizer; | |
| + | |
| import com.esotericsoftware.minlog.Log; | |
| import forge.assets.FSkinProp; | |
| @@ -24,24 +29,19 @@ | |
| import forge.card.mana.ManaCostShard; | |
| import forge.toolbox.FSkin.SkinImage; | |
| -import java.awt.*; | |
| -import java.util.HashMap; | |
| -import java.util.Map; | |
| -import java.util.StringTokenizer; | |
| - | |
| /** | |
| * <p> | |
| * CardFaceSymbols class. | |
| * </p> | |
| - * | |
| + * | |
| * @author Forge | |
| * @version $Id: CardFaceSymbols.java 24769 2014-02-09 13:56:04Z Hellfish $ | |
| */ | |
| public class CardFaceSymbols { | |
| /** Constant <code>manaImages</code>. */ | |
| private static final Map<String, SkinImage> MANA_IMAGES = new HashMap<String, SkinImage>(); | |
| - | |
| - private static final int manaImageSize = 13; | |
| + | |
| + private static final int manaImageSize = 13; | |
| /** | |
| * <p> | |
| @@ -122,7 +122,7 @@ | |
| * <p> | |
| * draw. | |
| * </p> | |
| - * | |
| + * | |
| * @param g | |
| * a {@link java.awt.Graphics} object. | |
| * @param manaCost | |
| @@ -132,7 +132,7 @@ | |
| * @param y | |
| * a int. | |
| */ | |
| - public static void draw(Graphics g, ManaCost manaCost, int x, int y) { | |
| + public static void draw(final Graphics g, final ManaCost manaCost, final int x, final int y) { | |
| if (manaCost.isNoCost()) { | |
| return; | |
| } | |
| @@ -153,7 +153,7 @@ | |
| final String sGeneric = Integer.toString(genericManaCost); | |
| CardFaceSymbols.drawSymbol(sGeneric, g, xpos, y); | |
| xpos += offset; | |
| - | |
| + | |
| for (final ManaCostShard s : manaCost) { //render non-X shards after generic | |
| if (s != ManaCostShard.X) { | |
| CardFaceSymbols.drawSymbol(s.getImageKey(), g, xpos, y); | |
| @@ -170,7 +170,7 @@ | |
| } | |
| /** | |
| - * | |
| + * | |
| * draw. | |
| * @param g a Graphics | |
| * @param s a STring | |
| @@ -179,15 +179,15 @@ | |
| * @param w an int | |
| * @param h and int | |
| */ | |
| - public static void drawOther(final Graphics g, String s, int x, final int y, final int w, final int h) { | |
| + public static void drawOther(final Graphics g, final String s, int x, final int y, final int w, final int h) { | |
| if (s.length() == 0) { | |
| return; | |
| } | |
| - StringTokenizer tok = new StringTokenizer(s, " "); | |
| + final StringTokenizer tok = new StringTokenizer(s, " "); | |
| while (tok.hasMoreTokens()) { | |
| - String symbol = tok.nextToken(); | |
| - SkinImage image = MANA_IMAGES.get(symbol); | |
| + final String symbol = tok.nextToken(); | |
| + final SkinImage image = MANA_IMAGES.get(symbol); | |
| if (image == null) { | |
| Log.info("Symbol not recognized \"" + symbol + "\" in string: " + s); | |
| continue; | |
| @@ -195,29 +195,13 @@ | |
| FSkin.drawImage(g, image, x, y, w, h); | |
| x += symbol.length() > 2 ? 10 : 14; // slash.png is only 10 pixels wide. | |
| } | |
| - } | |
| - | |
| - /** | |
| - * <p> | |
| - * drawAttack. | |
| - * </p> | |
| - * | |
| - * @param g | |
| - * a {@link java.awt.Graphics} object. | |
| - * @param x | |
| - * a int. | |
| - * @param y | |
| - * a int. | |
| - */ | |
| - public static void drawAttack(final Graphics g, final int x, final int y) { | |
| - FSkin.drawImage(g, MANA_IMAGES.get("attack"), x, y); | |
| } | |
| /** | |
| * <p> | |
| * drawSymbol. | |
| * </p> | |
| - * | |
| + * | |
| * @param imageName | |
| * a {@link java.lang.String} object. | |
| * @param g | |
| @@ -230,12 +214,12 @@ | |
| public static void drawSymbol(final String imageName, final Graphics g, final int x, final int y) { | |
| FSkin.drawImage(g, MANA_IMAGES.get(imageName), x, y); | |
| } | |
| - | |
| + | |
| /** | |
| * <p> | |
| * getWidth. | |
| * </p> | |
| - * | |
| + * | |
| * @param manaCost | |
| * a {@link java.lang.String} object. | |
| * @return a int. | |
| @@ -243,7 +227,7 @@ | |
| public static int getWidth(final ManaCost manaCost) { | |
| return manaCost.getGlyphCount() * 14; | |
| } | |
| - | |
| + | |
| public static int getHeight() { | |
| return 14; | |
| } | |
| Index: forge-gui-desktop/src/main/java/forge/screens/workshop/controllers/CCardDesigner.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/workshop/controllers/CCardDesigner.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/workshop/controllers/CCardDesigner.java (revision 29317) | |
| @@ -1,13 +1,11 @@ | |
| package forge.screens.workshop.controllers; | |
| -import forge.UiCommand; | |
| import forge.gui.framework.ICDoc; | |
| import forge.screens.workshop.views.VCardDesigner; | |
| - | |
| -/** | |
| +/** | |
| * Controls the "card designer" panel in the workshop UI. | |
| - * | |
| + * | |
| * <br><br><i>(C at beginning of class name denotes a control class.)</i> | |
| * | |
| */ | |
| @@ -16,23 +14,14 @@ | |
| SINGLETON_INSTANCE; | |
| private CCardDesigner() { | |
| - VCardDesigner.SINGLETON_INSTANCE.getBtnSaveCard().setCommand(new Runnable() { | |
| + VCardDesigner.SINGLETON_INSTANCE.getBtnSaveCard().setCommand(new Runnable() { | |
| - @Override | |
| - public void run() { | |
| + @Override public final void run() { | |
| - CCardScript.SINGLETON_INSTANCE.saveChanges(); | |
| - } | |
| - }); | |
| + CCardScript.SINGLETON_INSTANCE.saveChanges(); | |
| + } | |
| + }); | |
| } | |
| //========== Overridden methods | |
| - | |
| - /* (non-Javadoc) | |
| - * @see forge.gui.framework.ICDoc#getCommandOnSelect() | |
| - */ | |
| - @Override | |
| - public UiCommand getCommandOnSelect() { | |
| - return null; | |
| - } | |
| @Override | |
| public void register() { | |
| Index: forge-gui-desktop/src/main/java/forge/control/FControl.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/control/FControl.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/control/FControl.java (revision 29317) | |
| @@ -6,12 +6,12 @@ | |
| * 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 <http://www.gnu.org/licenses/>. | |
| */ | |
| @@ -43,7 +43,6 @@ | |
| import forge.LobbyPlayer; | |
| import forge.Singletons; | |
| import forge.assets.FSkinProp; | |
| -import forge.gui.GuiDialog; | |
| import forge.gui.SOverlayUtils; | |
| import forge.gui.framework.FScreen; | |
| import forge.gui.framework.InvalidLayoutFileException; | |
| @@ -62,6 +61,7 @@ | |
| import forge.screens.deckeditor.CDeckEditorUI; | |
| import forge.toolbox.FOptionPane; | |
| import forge.toolbox.FSkin; | |
| +import forge.util.gui.SOptionPane; | |
| import forge.view.FFrame; | |
| import forge.view.FView; | |
| @@ -81,7 +81,7 @@ | |
| private FScreen currentScreen; | |
| private boolean altKeyLastDown; | |
| private CloseAction closeAction; | |
| - private List<HostedMatch> currentMatches = Lists.newArrayList(); | |
| + private final List<HostedMatch> currentMatches = Lists.newArrayList(); | |
| public static enum CloseAction { | |
| NONE, | |
| @@ -126,8 +126,8 @@ | |
| public void windowClosing(final WindowEvent e) { | |
| switch (closeAction) { | |
| case NONE: //prompt user for close action if not previously specified | |
| - String[] options = {"Close Screen", "Exit Forge", "Cancel"}; | |
| - int reply = FOptionPane.showOptionDialog( | |
| + final String[] options = {"Close Screen", "Exit Forge", "Cancel"}; | |
| + final int reply = FOptionPane.showOptionDialog( | |
| "Forge now supports navigation tabs which allow closing and switching between different screens with ease. " | |
| + "As a result, you no longer need to use the X button in the upper right to close the current screen and go back." | |
| + "\n\n" | |
| @@ -300,8 +300,8 @@ | |
| screen.getController().register(); | |
| try { | |
| SLayoutIO.loadLayout(null); | |
| - } catch (InvalidLayoutFileException ex) { | |
| - GuiDialog.message("Your " + screen.getTabCaption() + " layout file could not be read. It will be deleted after you press OK.\nThe game will proceed with default layout."); | |
| + } catch (final InvalidLayoutFileException ex) { | |
| + SOptionPane.showMessageDialog(String.format("Your %s layout file could not be read. It will be deleted after you press OK.\nThe game will proceed with default layout.", screen.getTabCaption()), "Warning!"); | |
| if (screen.deleteLayoutFile()) { | |
| SLayoutIO.loadLayout(null); //try again | |
| } | |
| @@ -325,7 +325,7 @@ | |
| return FModel.getPreferences().getPrefBoolean(FPref.UI_MATCH_IMAGE_VISIBLE); | |
| } | |
| - public boolean ensureScreenActive(FScreen screen) { | |
| + public boolean ensureScreenActive(final FScreen screen) { | |
| if (currentScreen == screen) { return true; } | |
| return setCurrentScreen(screen); | |
| @@ -360,7 +360,7 @@ | |
| * @see java.awt.KeyEventDispatcher#dispatchKeyEvent(java.awt.event.KeyEvent) | |
| */ | |
| @Override | |
| - public boolean dispatchKeyEvent(KeyEvent e) { | |
| + public boolean dispatchKeyEvent(final KeyEvent e) { | |
| // Show Forge menu if Alt key pressed without modifiers and released without pressing any other keys in between | |
| if (e.getKeyCode() == KeyEvent.VK_ALT) { | |
| if (e.getID() == KeyEvent.KEY_RELEASED) { | |
| Index: forge-gui-desktop/src/main/java/forge/screens/match/controllers/CPrompt.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/match/controllers/CPrompt.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/match/controllers/CPrompt.java (revision 29317) | |
| @@ -6,12 +6,12 @@ | |
| * 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 <http://www.gnu.org/licenses/>. | |
| */ | |
| @@ -27,7 +27,6 @@ | |
| import javax.swing.JButton; | |
| import forge.FThreads; | |
| -import forge.UiCommand; | |
| import forge.game.GameView; | |
| import forge.gui.framework.ICDoc; | |
| import forge.gui.framework.SDisplayUtil; | |
| @@ -37,7 +36,7 @@ | |
| /** | |
| * Controls the prompt panel in the match UI. | |
| - * | |
| + * | |
| * <br><br><i>(C at beginning of class name denotes a control class.)</i> | |
| */ | |
| public class CPrompt implements ICDoc { | |
| @@ -69,7 +68,7 @@ | |
| private final FocusListener onFocus = new FocusAdapter() { | |
| @Override | |
| - public void focusGained(FocusEvent e) { | |
| + public void focusGained(final FocusEvent e) { | |
| if (null != view.getParentCell() && view == view.getParentCell().getSelected()) { | |
| // only record focus changes when we're showing -- otherwise it is due to a tab visibility change | |
| lastFocusedButton = e.getComponent(); | |
| @@ -77,7 +76,7 @@ | |
| } | |
| }; | |
| - private void _initButton(JButton button, ActionListener onClick) { | |
| + private void _initButton(final JButton button, final ActionListener onClick) { | |
| // remove to ensure listeners don't accumulate over many initializations | |
| button.removeActionListener(onClick); | |
| button.addActionListener(onClick); | |
| @@ -99,18 +98,15 @@ | |
| matchUI.getGameController().selectButtonCancel(); | |
| } | |
| - public void setMessage(String s0) { | |
| + public void setMessage(final String s0) { | |
| view.getTarMessage().setText(FSkin.encodeSymbols(s0, false)); | |
| } | |
| - /** Flashes animation on input panel if play is currently waiting on input. */ | |
| + /** | |
| + * Invoke a flashing animation on the prompt. | |
| + */ | |
| public void remind() { | |
| SDisplayUtil.remind(view); | |
| - } | |
| - | |
| - @Override | |
| - public UiCommand getCommandOnSelect() { | |
| - return null; | |
| } | |
| @Override | |
| Index: forge-gui-desktop/src/main/java/forge/screens/match/ZoneAction.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/match/ZoneAction.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/match/ZoneAction.java (revision 29317) | |
| @@ -1,19 +1,15 @@ | |
| package forge.screens.match; | |
| -import java.awt.event.ActionEvent; | |
| import forge.game.player.PlayerView; | |
| import forge.game.zone.ZoneType; | |
| -import forge.gui.ForgeAction; | |
| -import forge.match.MatchConstants; | |
| import forge.view.arcane.FloatingCardArea; | |
| /** | |
| * Receives click and programmatic requests for viewing data stacks in the | |
| * "zones" of a player field: hand, library, etc. | |
| - * | |
| + * | |
| */ | |
| -public class ZoneAction extends ForgeAction { | |
| - private static final long serialVersionUID = -5822976087772388839L; | |
| +public final class ZoneAction implements Runnable { | |
| private final CMatchUI matchUI; | |
| private final PlayerView player; | |
| private final ZoneType zone; | |
| @@ -23,15 +19,14 @@ | |
| * the "zones" of a player field: hand, graveyard, etc. The library | |
| * "zone" is an exception to the rule; it's handled in DeckListAction. | |
| */ | |
| - public ZoneAction(final CMatchUI matchUI, final PlayerView player0, final ZoneType zone0, final MatchConstants property) { | |
| - super(property); | |
| + public ZoneAction(final CMatchUI matchUI, final PlayerView player, final ZoneType zone) { | |
| this.matchUI = matchUI; | |
| - player = player0; | |
| - zone = zone0; | |
| + this.player = player; | |
| + this.zone = zone; | |
| } | |
| @Override | |
| - public void actionPerformed(final ActionEvent e) { | |
| + public void run() { | |
| FloatingCardArea.showOrHide(matchUI, player, zone); | |
| } | |
| } | |
| \ No newline at end of file | |
| Index: forge-gui/src/main/java/forge/quest/io/ReadPriceList.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui/src/main/java/forge/quest/io/ReadPriceList.java (revision 29316) | |
| +++ forge-gui/src/main/java/forge/quest/io/ReadPriceList.java (revision 29317) | |
| @@ -6,42 +6,43 @@ | |
| * 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 <http://www.gnu.org/licenses/>. | |
| */ | |
| package forge.quest.io; | |
| +import java.util.HashMap; | |
| +import java.util.List; | |
| +import java.util.Map; | |
| +import java.util.Random; | |
| + | |
| import com.esotericsoftware.minlog.Log; | |
| + | |
| import forge.card.MagicColor; | |
| import forge.properties.ForgeConstants; | |
| import forge.util.FileUtil; | |
| import forge.util.MyRandom; | |
| -import java.util.HashMap; | |
| -import java.util.List; | |
| -import java.util.Map; | |
| -import java.util.Random; | |
| - | |
| /** | |
| * <p> | |
| * ReadPriceList class. | |
| * </p> | |
| - * | |
| + * | |
| * @author Forge | |
| - * @version $Id: ReadPriceList.java 26691 2014-07-16 23:23:18Z drdev $ | |
| + * @version $Id: ReadPriceList.java 29317 2015-05-01 19:27:48Z elcnesh $ | |
| */ | |
| public class ReadPriceList { | |
| /** Constant <code>comment="//"</code>. */ | |
| private static final String COMMENT = "//"; | |
| - private HashMap<String, Integer> priceMap; | |
| + private Map<String, Integer> priceMap; | |
| /** | |
| * <p> | |
| @@ -66,17 +67,17 @@ | |
| * <p> | |
| * readFile. | |
| * </p> | |
| - * | |
| + * | |
| * @param file | |
| * a {@link java.io.File} object. | |
| * @return a {@link java.util.HashMap} object. | |
| */ | |
| - private HashMap<String, Integer> readFile(String file) { | |
| - final HashMap<String, Integer> map = new HashMap<String, Integer>(); | |
| + private Map<String, Integer> readFile(final String file) { | |
| + final Map<String, Integer> map = new HashMap<String, Integer>(); | |
| final Random r = MyRandom.getRandom(); | |
| - List<String> lines = FileUtil.readFile(file); | |
| - for (String line : lines) { | |
| + final List<String> lines = FileUtil.readFile(file); | |
| + for (final String line : lines) { | |
| if (line.trim().length() == 0) { | |
| break; | |
| } | |
| @@ -124,7 +125,7 @@ | |
| * <p> | |
| * getPriceList. | |
| * </p> | |
| - * | |
| + * | |
| * @return a {@link java.util.Map} object. | |
| */ | |
| public final Map<String, Integer> getPriceList() { | |
| Index: forge-gui/src/main/java/forge/limited/WinstonDraft.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui/src/main/java/forge/limited/WinstonDraft.java (revision 29316) | |
| +++ forge-gui/src/main/java/forge/limited/WinstonDraft.java (revision 29317) | |
| @@ -1,5 +1,10 @@ | |
| package forge.limited; | |
| +import java.util.ArrayList; | |
| +import java.util.Collections; | |
| +import java.util.List; | |
| +import java.util.Stack; | |
| + | |
| import com.google.common.base.Predicates; | |
| import com.google.common.base.Supplier; | |
| import com.google.common.collect.Iterables; | |
| @@ -9,8 +14,6 @@ | |
| import forge.item.PaperCard; | |
| import forge.util.MyRandom; | |
| -import java.util.*; | |
| - | |
| public class WinstonDraft extends BoosterDraft { | |
| private WinstonDraftAI draftAI = null; | |
| private static int NUM_PILES = 3; | |
| @@ -20,7 +23,7 @@ | |
| private List<List<PaperCard>> piles; // 3 piles to draft from | |
| public static WinstonDraft createDraft(final LimitedPoolType draftType) { | |
| - WinstonDraft draft = new WinstonDraft(draftType); | |
| + final WinstonDraft draft = new WinstonDraft(draftType); | |
| if (!draft.generateProduct()) { | |
| return null; | |
| } | |
| @@ -28,7 +31,7 @@ | |
| return draft; | |
| } | |
| - private WinstonDraft(LimitedPoolType draftType) { | |
| + private WinstonDraft(final LimitedPoolType draftType) { | |
| draftFormat = draftType; | |
| draftAI = new WinstonDraftAI(); | |
| @@ -37,10 +40,10 @@ | |
| private void initializeWinstonDraft() { | |
| this.deck = new Stack<PaperCard>(); | |
| for (int i = 0; i < this.product.size(); i++) { | |
| - Supplier<List<PaperCard>> supply = this.product.get(i); | |
| + final Supplier<List<PaperCard>> supply = this.product.get(i); | |
| for(int j = 0; j < NUM_PLAYERS; j++) { | |
| // Remove Basic Lands from draft for simplicity | |
| - for (PaperCard paperCard : Iterables.filter(supply.get(), Predicates.not(PaperCard.Predicates.Presets.IS_BASIC_LAND))) { | |
| + for (final PaperCard paperCard : Iterables.filter(supply.get(), Predicates.not(PaperCard.Predicates.Presets.IS_BASIC_LAND))) { | |
| this.deck.add(paperCard); | |
| } | |
| } | |
| @@ -50,7 +53,7 @@ | |
| // Create three Winston piles, adding the top card from the Winston deck to start each pile | |
| this.piles = new ArrayList<>(); | |
| for(int i = 0; i < NUM_PILES; i++) { | |
| - List<PaperCard> pile = new ArrayList<PaperCard>(); | |
| + final List<PaperCard> pile = new ArrayList<PaperCard>(); | |
| pile.add(this.deck.pop()); | |
| this.piles.add(pile); | |
| } | |
| @@ -77,8 +80,9 @@ | |
| } | |
| } | |
| - if (nextPile < 0 || nextPile > this.piles.size()) | |
| + if (nextPile < 0 || nextPile > this.piles.size()) { | |
| return null; | |
| + } | |
| nextBoosterGroup = nextPile; | |
| @@ -89,64 +93,72 @@ | |
| return getPoolByPile(this.nextBoosterGroup); | |
| } | |
| - private CardPool getPoolByPile(int i) { | |
| - CardPool result = new CardPool(); | |
| + private CardPool getPoolByPile(final int i) { | |
| + final CardPool result = new CardPool(); | |
| result.addAllFlat(this.piles.get(i)); | |
| return result; | |
| } | |
| + @Override | |
| public void computerChoose() { | |
| nextBoosterGroup = 0; | |
| draftAI.choose(); | |
| } | |
| - public void refillPile(List<PaperCard> pile) { | |
| - if (this.deck.size() > 0) | |
| + public void refillPile(final List<PaperCard> pile) { | |
| + if (this.deck.size() > 0) { | |
| pile.add(this.deck.pop()); | |
| - } | |
| + } | |
| + } | |
| - public int getNextChoice(int startPile) { | |
| + public int getNextChoice(final int startPile) { | |
| for(int i = startPile; i < NUM_PILES; i++) { | |
| - if (this.piles.get(i).size() > 0) | |
| + if (this.piles.get(i).size() > 0) { | |
| return i; | |
| - } | |
| + } | |
| + } | |
| // All piles are empty, so draft is about to end. | |
| return -1; | |
| } | |
| + @Override | |
| public boolean hasNextChoice() { | |
| return getNextChoice(0) >= 0; | |
| } | |
| - public boolean isLastPileAndEmptyDeck(int pile) { | |
| + public boolean isLastPileAndEmptyDeck(final int pile) { | |
| return this.deck.size() == 0 && getNextChoice(pile+1) >= 0; | |
| } | |
| + @Override | |
| public int getCurrentBoosterIndex() { | |
| return nextBoosterGroup; | |
| } | |
| - public CardPool takeActivePile(boolean humanAction) { | |
| - CardPool pool = getPoolByPile(this.nextBoosterGroup); | |
| + public CardPool takeActivePile(final boolean humanAction) { | |
| + final CardPool pool = getPoolByPile(this.nextBoosterGroup); | |
| this.piles.get(this.nextBoosterGroup).clear(); | |
| this.refillPile(this.piles.get(this.nextBoosterGroup)); | |
| this.nextBoosterGroup = 0; | |
| - if (humanAction) | |
| + if (humanAction) { | |
| computerChoose(); | |
| + } | |
| return pool; | |
| } | |
| - public CardPool passActivePile(boolean humanAction) { | |
| + public CardPool passActivePile(final boolean humanAction) { | |
| this.refillPile(this.piles.get(this.nextBoosterGroup)); | |
| this.nextBoosterGroup++; | |
| if (this.nextBoosterGroup >= this.piles.size()) { | |
| - CardPool pool = new CardPool(); | |
| - if (this.deck.size() > 0) | |
| + final CardPool pool = new CardPool(); | |
| + if (this.deck.size() > 0) { | |
| pool.add(this.deck.pop()); | |
| + } | |
| this.nextBoosterGroup = 0; | |
| - if (humanAction) | |
| + if (humanAction) { | |
| computerChoose(); | |
| + } | |
| return pool; | |
| } | |
| return null; |
| Index: forge-gui-desktop/src/main/java/forge/screens/deckeditor/CDeckEditorUI.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/deckeditor/CDeckEditorUI.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/deckeditor/CDeckEditorUI.java (revision 29317) | |
| @@ -6,12 +6,12 @@ | |
| * 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 <http://www.gnu.org/licenses/>. | |
| */ | |
| @@ -52,7 +52,7 @@ | |
| * 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. | |
| - * | |
| + * | |
| * <br><br><i>(C at beginning of class name denotes a control class.)</i> | |
| */ | |
| public enum CDeckEditorUI implements ICDoc { | |
| @@ -60,9 +60,9 @@ | |
| SINGLETON_INSTANCE; | |
| private final HashMap<FScreen, ACEditorBase<? extends InventoryItem, ? extends DeckBase>> screenChildControllers; | |
| - private ACEditorBase<? extends InventoryItem, ? extends DeckBase> childController; | |
| - private final CDetailPicture cDetailPicture; | |
| - private final VAllDecks vAllDecks; | |
| + private ACEditorBase<? extends InventoryItem, ? extends DeckBase> childController; | |
| + private final CDetailPicture cDetailPicture; | |
| + private final VAllDecks vAllDecks; | |
| private CDeckEditorUI() { | |
| screenChildControllers = new HashMap<FScreen, ACEditorBase<? extends InventoryItem, ? extends DeckBase>>(); | |
| @@ -92,7 +92,7 @@ | |
| return !deckController.isSaved(); | |
| } | |
| - public boolean canSwitchAway(boolean isClosing) { | |
| + public boolean canSwitchAway(final boolean isClosing) { | |
| if (this.childController != null) { | |
| if (!this.childController.canSwitchAway(isClosing)) { | |
| return false; | |
| @@ -117,8 +117,8 @@ | |
| /** | |
| * Set controller for a given editor screen. | |
| */ | |
| - public void setEditorController(ACEditorBase<? extends InventoryItem, ? extends DeckBase> childController0) { | |
| - FScreen screen = childController0.getScreen(); | |
| + public void setEditorController(final ACEditorBase<? extends InventoryItem, ? extends DeckBase> childController0) { | |
| + final FScreen screen = childController0.getScreen(); | |
| screenChildControllers.put(screen, childController0); | |
| if (screen == Singletons.getControl().getCurrentScreen()) { | |
| setCurrentEditorController(childController0); | |
| @@ -126,18 +126,18 @@ | |
| } | |
| @SuppressWarnings("unchecked") | |
| - public <T extends InventoryItem> void incrementDeckQuantity(T item, int delta) { | |
| + public <T extends InventoryItem> void incrementDeckQuantity(final T item, final int delta) { | |
| if (item == null || delta == 0) { return; } | |
| if (delta > 0) { //add items | |
| - int qty = Math.min(delta, ((ItemManager<T>)childController.getCatalogManager()).getItemCount(item)); | |
| + final int qty = Math.min(delta, ((ItemManager<T>)childController.getCatalogManager()).getItemCount(item)); | |
| if (qty == 0) { return; } | |
| - ((ACEditorBase<T, ?>)childController).addItem(item, qty, false); | |
| + ((ACEditorBase<T, ?>)childController).addItem(item, qty); | |
| } | |
| else { //remove items | |
| - int qty = Math.min(-delta, ((ItemManager<T>)childController.getDeckManager()).getItemCount(item)); | |
| + final int qty = Math.min(-delta, ((ItemManager<T>)childController.getDeckManager()).getItemCount(item)); | |
| if (qty == 0) { return; } | |
| - ((ACEditorBase<T, ?>)childController).removeItem(item, qty, false); | |
| + ((ACEditorBase<T, ?>)childController).removeItem(item, qty); | |
| } | |
| CStatistics.SINGLETON_INSTANCE.update(); | |
| @@ -148,12 +148,12 @@ | |
| public <T extends InventoryItem> void move(Iterable<Entry<T, Integer>> items); | |
| } | |
| - private <T extends InventoryItem> void moveSelectedItems(ItemManager<T> itemManager, _MoveAction moveAction, int maxQty) { | |
| + private <T extends InventoryItem> void moveSelectedItems(final ItemManager<T> itemManager, final _MoveAction moveAction, final int maxQty) { | |
| if (maxQty == 0) { return; } | |
| - ItemPool<T> items = new ItemPool<T>(itemManager.getGenericType()); | |
| - for (T item : itemManager.getSelectedItems()) { | |
| - int qty = Math.min(maxQty, itemManager.getItemCount(item)); | |
| + final ItemPool<T> items = new ItemPool<T>(itemManager.getGenericType()); | |
| + for (final T item : itemManager.getSelectedItems()) { | |
| + final int qty = Math.min(maxQty, itemManager.getItemCount(item)); | |
| if (qty > 0) { | |
| items.add(item, qty); | |
| } | |
| @@ -167,42 +167,28 @@ | |
| } | |
| @SuppressWarnings("unchecked") | |
| - public void addSelectedCards(final boolean toAlternate, int number) { | |
| + public void addSelectedCards(final boolean toAlternate, final int number) { | |
| moveSelectedItems(childController.getCatalogManager(), new _MoveAction() { | |
| - @Override | |
| - public <T extends InventoryItem> void move(Iterable<Entry<T, Integer>> items) { | |
| + @Override public <T extends InventoryItem> void move(final Iterable<Entry<T, Integer>> items) { | |
| ((ACEditorBase<T, ?>)childController).addItems(items, toAlternate); | |
| } | |
| }, number); | |
| } | |
| @SuppressWarnings("unchecked") | |
| - public void removeSelectedCards(final boolean toAlternate, int number) { | |
| + public void removeSelectedCards(final boolean toAlternate, final int number) { | |
| moveSelectedItems(childController.getDeckManager(), new _MoveAction() { | |
| - @Override | |
| - public <T extends InventoryItem> void move(Iterable<Entry<T, Integer>> items) { | |
| + @Override public <T extends InventoryItem> void move(final Iterable<Entry<T, Integer>> items) { | |
| ((ACEditorBase<T, ?>)childController).removeItems(items, toAlternate); | |
| } | |
| }, number); | |
| } | |
| - @SuppressWarnings("unchecked") | |
| - public void removeAllCards(final boolean toAlternate) { | |
| - ItemManager<?> v = childController.getDeckManager(); | |
| - v.selectAll(); | |
| - moveSelectedItems(v, new _MoveAction() { | |
| - @Override | |
| - public <T extends InventoryItem> void move(Iterable<Entry<T, Integer>> items) { | |
| - ((ACEditorBase<T, ?>)childController).removeItems(items, toAlternate); | |
| - } | |
| - }, Integer.MAX_VALUE); | |
| - } | |
| - | |
| /** | |
| * Set current editor controller | |
| */ | |
| @SuppressWarnings("serial") | |
| - private void setCurrentEditorController(ACEditorBase<? extends InventoryItem, ? extends DeckBase> childController0) { | |
| + private void setCurrentEditorController(final ACEditorBase<? extends InventoryItem, ? extends DeckBase> childController0) { | |
| this.childController = childController0; | |
| Singletons.getControl().getForgeMenu().setProvider(childController0); | |
| @@ -216,8 +202,7 @@ | |
| if (!childController.listenersHooked) { //hook listeners the first time the controller is updated | |
| catView.addKeyListener(new KeyAdapter() { | |
| - @Override | |
| - public void keyPressed(KeyEvent e) { | |
| + @Override public void keyPressed(final KeyEvent e) { | |
| if (!catView.isIncrementalSearchActive() && KeyEvent.VK_SPACE == e.getKeyCode()) { | |
| addSelectedCards(e.isControlDown() || e.isMetaDown(), e.isShiftDown() ? 4: 1); | |
| } | |
| @@ -229,8 +214,7 @@ | |
| }); | |
| deckView.addKeyListener(new KeyAdapter() { | |
| - @Override | |
| - public void keyPressed(KeyEvent e) { | |
| + @Override public void keyPressed(final KeyEvent e) { | |
| if (!catView.isIncrementalSearchActive() && KeyEvent.VK_SPACE == e.getKeyCode()) { | |
| removeSelectedCards(e.isControlDown() || e.isMetaDown(), e.isShiftDown() ? 4: 1); | |
| } | |
| @@ -265,18 +249,16 @@ | |
| //set card when selection changes | |
| catView.addSelectionListener(new ListSelectionListener() { | |
| - @Override | |
| - public void valueChanged(ListSelectionEvent e) { | |
| + @Override public void valueChanged(final ListSelectionEvent e) { | |
| - setCard(catView.getSelectedItem()); | |
| - } | |
| - }); | |
| + setCard(catView.getSelectedItem()); | |
| + } | |
| + }); | |
| deckView.addSelectionListener(new ListSelectionListener() { | |
| - @Override | |
| - public void valueChanged(ListSelectionEvent e) { | |
| + @Override public void valueChanged(final ListSelectionEvent e) { | |
| - setCard(deckView.getSelectedItem()); | |
| - } | |
| - }); | |
| + setCard(deckView.getSelectedItem()); | |
| + } | |
| + }); | |
| catView.setAllowMultipleSelections(true); | |
| deckView.setAllowMultipleSelections(true); | |
| @@ -296,15 +278,7 @@ | |
| }); | |
| } | |
| - /* (non-Javadoc) | |
| - * @see forge.gui.framework.ICDoc#getCommandOnSelect() | |
| - */ | |
| @Override | |
| - public UiCommand getCommandOnSelect() { | |
| - return null; | |
| - } | |
| - | |
| - @Override | |
| public void register() { | |
| EDocID.CARD_PICTURE.setDoc(cDetailPicture.getCPicture().getView()); | |
| EDocID.CARD_DETAIL.setDoc(cDetailPicture.getCDetail().getView()); | |
| @@ -316,17 +290,16 @@ | |
| @Override | |
| public void initialize() { | |
| //change to previously open child controller based on screen | |
| - FScreen screen = Singletons.getControl().getCurrentScreen(); | |
| - ACEditorBase<? extends InventoryItem, ? extends DeckBase> screenChildController = screenChildControllers.get(screen); | |
| + final FScreen screen = Singletons.getControl().getCurrentScreen(); | |
| + final ACEditorBase<? extends InventoryItem, ? extends DeckBase> screenChildController = screenChildControllers.get(screen); | |
| if (screenChildController != null) { | |
| setCurrentEditorController(screenChildController); | |
| - } | |
| - else if (screen == FScreen.DECK_EDITOR_CONSTRUCTED) { | |
| + } else if (screen == FScreen.DECK_EDITOR_CONSTRUCTED) { | |
| setEditorController(new CEditorConstructed(cDetailPicture)); //ensure Constructed deck editor controller initialized | |
| - String currentDeckStr = DeckPreferences.getCurrentDeck(); | |
| + final String currentDeckStr = DeckPreferences.getCurrentDeck(); | |
| if (currentDeckStr != null) { | |
| - DeckProxy deck = vAllDecks.getLstDecks().stringToItem(currentDeckStr); | |
| + final DeckProxy deck = vAllDecks.getLstDecks().stringToItem(currentDeckStr); | |
| if (deck != null) { | |
| vAllDecks.getLstDecks().setSelectedItem(deck); | |
| childController.getDeckController().load(deck.getPath(), deck.getName()); | |
| Index: forge-gui/src/main/java/forge/download/GuiDownloadSetPicturesLQ.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui/src/main/java/forge/download/GuiDownloadSetPicturesLQ.java (revision 29316) | |
| +++ forge-gui/src/main/java/forge/download/GuiDownloadSetPicturesLQ.java (revision 29317) | |
| @@ -6,17 +6,23 @@ | |
| * 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 <http://www.gnu.org/licenses/>. | |
| */ | |
| package forge.download; | |
| +import java.io.File; | |
| +import java.util.Map; | |
| +import java.util.TreeMap; | |
| + | |
| +import org.apache.commons.lang3.StringUtils; | |
| + | |
| import com.google.common.collect.Iterables; | |
| import forge.card.CardEdition; | |
| @@ -25,12 +31,6 @@ | |
| import forge.properties.ForgeConstants; | |
| import forge.util.ImageUtil; | |
| -import org.apache.commons.lang3.StringUtils; | |
| - | |
| -import java.io.File; | |
| -import java.util.Map; | |
| -import java.util.TreeMap; | |
| - | |
| public class GuiDownloadSetPicturesLQ extends GuiDownloadService { | |
| @Override | |
| public String getTitle() { | |
| @@ -39,12 +39,12 @@ | |
| @Override | |
| protected final Map<String, String> getNeededFiles() { | |
| - Map<String, String> downloads = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER); | |
| + final Map<String, String> downloads = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER); | |
| for (final PaperCard c : Iterables.concat(FModel.getMagicDb().getCommonCards().getAllCards(), FModel.getMagicDb().getVariantCards().getAllCards())) { | |
| final String setCode3 = c.getEdition(); | |
| if (StringUtils.isBlank(setCode3) || CardEdition.UNKNOWN.getCode().equals(setCode3)) { | |
| - // we don't want cards from unknown sets | |
| + // we don't want cards from unknown sets | |
| continue; | |
| } | |
| addDLObject(ImageUtil.getDownloadUrl(c, false), ImageUtil.getImageKey(c, false, true), downloads); | |
| @@ -60,8 +60,8 @@ | |
| return downloads; | |
| } | |
| - private void addDLObject(String urlPath, String filename, Map<String, String> downloads) { | |
| - File destFile = new File(ForgeConstants.CACHE_CARD_PICS_DIR, filename + ".jpg"); | |
| + private static void addDLObject(final String urlPath, final String filename, final Map<String, String> downloads) { | |
| + final File destFile = new File(ForgeConstants.CACHE_CARD_PICS_DIR, filename + ".jpg"); | |
| // System.out.println(filename); | |
| if (!destFile.exists()) { | |
| downloads.put(destFile.getAbsolutePath(), ForgeConstants.URL_PIC_DOWNLOAD + urlPath); | |
| Index: forge-gui-desktop/src/main/java/forge/screens/home/quest/CSubmenuQuestDecks.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/home/quest/CSubmenuQuestDecks.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/home/quest/CSubmenuQuestDecks.java (revision 29317) | |
| @@ -5,7 +5,6 @@ | |
| import forge.Singletons; | |
| import forge.UiCommand; | |
| import forge.deck.DeckProxy; | |
| -import forge.gui.framework.EDocID; | |
| import forge.gui.framework.FScreen; | |
| import forge.gui.framework.ICDoc; | |
| import forge.itemmanager.ItemManagerConfig; | |
| @@ -15,11 +14,10 @@ | |
| import forge.quest.data.QuestPreferences.QPref; | |
| import forge.screens.deckeditor.CDeckEditorUI; | |
| import forge.screens.deckeditor.controllers.CEditorQuest; | |
| -import forge.screens.home.CHomeUI; | |
| -/** | |
| +/** | |
| * Controls the quest decks submenu in the home UI. | |
| - * | |
| + * | |
| * <br><br><i>(C at beginning of class name denotes a control class.)</i> | |
| */ | |
| @SuppressWarnings("serial") | |
| @@ -30,7 +28,7 @@ | |
| private final UiCommand cmdDeckSelect = new UiCommand() { | |
| @Override | |
| public void run() { | |
| - DeckProxy deck = VSubmenuQuestDecks.SINGLETON_INSTANCE.getLstDecks().getSelectedItem(); | |
| + final DeckProxy deck = VSubmenuQuestDecks.SINGLETON_INSTANCE.getLstDecks().getSelectedItem(); | |
| if (deck != null) { | |
| FModel.getQuestPreferences().setPref(QPref.CURRENT_DECK, deck.toString()); | |
| } | |
| @@ -80,7 +78,7 @@ | |
| view.getLstDecks().setDeleteCommand(null); | |
| final QuestController qData = FModel.getQuest(); | |
| - boolean hasQuest = qData.getAssets() != null; | |
| + final boolean hasQuest = qData.getAssets() != null; | |
| // Retrieve and set all decks | |
| view.getLstDecks().setPool(DeckProxy.getAllQuestDecks(hasQuest ? qData.getMyDecks() : null)); | |
| view.getLstDecks().setup(ItemManagerConfig.QUEST_DECKS); | |
| @@ -106,19 +104,4 @@ | |
| }); | |
| } | |
| - /* (non-Javadoc) | |
| - * @see forge.gui.framework.ICDoc#getCommandOnSelect() | |
| - */ | |
| - @Override | |
| - public UiCommand getCommandOnSelect() { | |
| - final QuestController qc = FModel.getQuest(); | |
| - return new UiCommand() { | |
| - @Override | |
| - public void run() { | |
| - if (qc.getAchievements() == null) { | |
| - CHomeUI.SINGLETON_INSTANCE.itemClick(EDocID.HOME_QUESTDATA); | |
| - } | |
| - } | |
| - }; | |
| - } | |
| } | |
| Index: forge-gui/src/main/java/forge/interfaces/IButton.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui/src/main/java/forge/interfaces/IButton.java (revision 29316) | |
| +++ forge-gui/src/main/java/forge/interfaces/IButton.java (revision 29317) | |
| @@ -3,10 +3,7 @@ | |
| import forge.UiCommand; | |
| import forge.assets.FSkinProp; | |
| -public interface IButton { | |
| - void setEnabled(boolean b0); | |
| - void setVisible(boolean b0); | |
| - void setText(String text0); | |
| +public interface IButton extends ITextComponent { | |
| boolean isSelected(); | |
| void setSelected(boolean b0); | |
| boolean requestFocusInWindow(); | |
| Index: forge-gui-desktop/src/main/java/forge/screens/home/quest/CSubmenuDuels.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/home/quest/CSubmenuDuels.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/home/quest/CSubmenuDuels.java (revision 29317) | |
| @@ -1,24 +1,28 @@ | |
| package forge.screens.home.quest; | |
| +import java.awt.event.ActionEvent; | |
| +import java.awt.event.ActionListener; | |
| +import java.awt.event.KeyAdapter; | |
| +import java.awt.event.KeyEvent; | |
| +import java.awt.event.MouseAdapter; | |
| +import java.awt.event.MouseEvent; | |
| +import java.util.List; | |
| + | |
| +import javax.swing.JRadioButton; | |
| +import javax.swing.SwingUtilities; | |
| + | |
| import forge.UiCommand; | |
| -import forge.gui.framework.EDocID; | |
| import forge.gui.framework.ICDoc; | |
| import forge.model.FModel; | |
| import forge.quest.QuestController; | |
| import forge.quest.QuestEventDuel; | |
| import forge.quest.QuestUtil; | |
| import forge.quest.bazaar.QuestPetController; | |
| -import forge.screens.home.CHomeUI; | |
| import forge.toolbox.JXButtonPanel; | |
| -import javax.swing.*; | |
| - | |
| -import java.awt.event.*; | |
| -import java.util.List; | |
| - | |
| -/** | |
| +/** | |
| * Controls the quest duels submenu in the home UI. | |
| - * | |
| + * | |
| * <br><br><i>(C at beginning of class name denotes a control class.)</i> | |
| * | |
| */ | |
| @@ -56,12 +60,12 @@ | |
| view.getBtnStart().addActionListener( | |
| new ActionListener() { @Override | |
| - public void actionPerformed(final ActionEvent e) { QuestUtil.startGame(); } }); | |
| + public void actionPerformed(final ActionEvent e) { QuestUtil.startGame(); } }); | |
| final QuestController quest = FModel.getQuest(); | |
| view.getCbPlant().addActionListener(new ActionListener() { | |
| @Override | |
| - public void actionPerformed(ActionEvent arg0) { | |
| + public void actionPerformed(final ActionEvent arg0) { | |
| quest.selectPet(0, view.getCbPlant().isSelected() ? "Plant" : null); | |
| quest.save(); | |
| } | |
| @@ -69,7 +73,7 @@ | |
| view.getCbCharm().addActionListener(new ActionListener() { | |
| @Override | |
| - public void actionPerformed(ActionEvent arg0) { | |
| + public void actionPerformed(final ActionEvent arg0) { | |
| quest.setCharmState(view.getCbCharm().isSelected()); | |
| quest.save(); | |
| } | |
| @@ -77,11 +81,11 @@ | |
| view.getCbxPet().addActionListener(new ActionListener() { | |
| @Override | |
| - public void actionPerformed(ActionEvent arg0) { | |
| + public void actionPerformed(final ActionEvent arg0) { | |
| final int slot = 1; | |
| final int index = view.getCbxPet().getSelectedIndex(); | |
| - List<QuestPetController> pets = quest.getPetsStorage().getAvaliablePets(slot, quest.getAssets()); | |
| - String petName = index <= 0 || index > pets.size() ? null : pets.get(index - 1).getName(); | |
| + final List<QuestPetController> pets = quest.getPetsStorage().getAvaliablePets(slot, quest.getAssets()); | |
| + final String petName = index <= 0 || index > pets.size() ? null : pets.get(index - 1).getName(); | |
| quest.selectPet(slot, petName); | |
| quest.save(); | |
| } | |
| @@ -89,7 +93,7 @@ | |
| view.getBtnRandomOpponent().setCommand(new UiCommand() { | |
| @Override | |
| - public void run() { | |
| + public void run() { | |
| if (QuestUtil.canStartGame()) { | |
| FModel.getQuest().getDuelsManager().randomizeOpponents(); | |
| final List<QuestEventDuel> duels = FModel.getQuest().getDuelsManager().generateDuels(); | |
| @@ -98,12 +102,12 @@ | |
| } | |
| } | |
| }); | |
| - | |
| + | |
| } | |
| private final KeyAdapter _startOnEnter = new KeyAdapter() { | |
| @Override | |
| - public void keyPressed(KeyEvent e) { | |
| + public void keyPressed(final KeyEvent e) { | |
| if (KeyEvent.VK_ENTER == e.getKeyChar()) { | |
| VSubmenuDuels.SINGLETON_INSTANCE.getBtnStart().doClick(); | |
| } | |
| @@ -111,7 +115,7 @@ | |
| }; | |
| private final MouseAdapter _startOnDblClick = new MouseAdapter() { | |
| @Override | |
| - public void mouseClicked(MouseEvent e) { | |
| + public void mouseClicked(final MouseEvent e) { | |
| if (MouseEvent.BUTTON1 == e.getButton() && 2 == e.getClickCount()) { | |
| VSubmenuDuels.SINGLETON_INSTANCE.getBtnStart().doClick(); | |
| } | |
| @@ -133,7 +137,7 @@ | |
| view.getPnlDuels().removeAll(); | |
| final List<QuestEventDuel> duels = FModel.getQuest().getDuelsManager().generateDuels(); | |
| - JXButtonPanel grpPanel = new JXButtonPanel(); | |
| + final JXButtonPanel grpPanel = new JXButtonPanel(); | |
| for (int i = 0; i < duels.size(); i++) { | |
| final PnlEvent temp = new PnlEvent(duels.get(i)); | |
| @@ -152,20 +156,4 @@ | |
| } | |
| } | |
| - /* (non-Javadoc) | |
| - * @see forge.gui.framework.ICDoc#getCommandOnSelect() | |
| - */ | |
| - @SuppressWarnings("serial") | |
| - @Override | |
| - public UiCommand getCommandOnSelect() { | |
| - final QuestController qc = FModel.getQuest(); | |
| - return new UiCommand() { | |
| - @Override | |
| - public void run() { | |
| - if (qc.getAchievements() == null) { | |
| - CHomeUI.SINGLETON_INSTANCE.itemClick(EDocID.HOME_QUESTDATA); | |
| - } | |
| - } | |
| - }; | |
| - } | |
| } | |
| Index: forge-gui-mobile/src/forge/GuiMobile.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-mobile/src/forge/GuiMobile.java (revision 29316) | |
| +++ forge-gui-mobile/src/forge/GuiMobile.java (revision 29317) | |
| @@ -9,7 +9,6 @@ | |
| import com.badlogic.gdx.graphics.Texture; | |
| import com.google.common.base.Function; | |
| -import forge.animation.GuiTimer; | |
| import forge.assets.FBufferedImage; | |
| import forge.assets.FDelayLoadImage; | |
| import forge.assets.FImage; | |
| @@ -25,7 +24,6 @@ | |
| import forge.error.BugReportDialog; | |
| import forge.interfaces.IGuiBase; | |
| import forge.interfaces.IGuiGame; | |
| -import forge.interfaces.IGuiTimer; | |
| import forge.item.PaperCard; | |
| import forge.match.HostedMatch; | |
| import forge.properties.ForgeConstants; | |
| @@ -46,8 +44,8 @@ | |
| public class GuiMobile implements IGuiBase { | |
| private final String assetsDir; | |
| - | |
| + | |
| - public GuiMobile(String assetsDir0) { | |
| + public GuiMobile(final String assetsDir0) { | |
| assetsDir = assetsDir0; | |
| } | |
| @@ -67,7 +65,7 @@ | |
| } | |
| @Override | |
| - public void invokeInEdtLater(Runnable proc) { | |
| + public void invokeInEdtLater(final Runnable proc) { | |
| Gdx.app.postRunnable(proc); | |
| } | |
| @@ -92,18 +90,13 @@ | |
| } | |
| @Override | |
| - public IGuiTimer createGuiTimer(Runnable proc, int interval) { | |
| - return new GuiTimer(proc, interval); | |
| - } | |
| - | |
| - @Override | |
| - public ISkinImage getSkinIcon(FSkinProp skinProp) { | |
| + public ISkinImage getSkinIcon(final FSkinProp skinProp) { | |
| if (skinProp == null) { return null; } | |
| return FSkin.getImages().get(skinProp); | |
| } | |
| @Override | |
| - public ISkinImage getUnskinnedIcon(String path) { | |
| + public ISkinImage getUnskinnedIcon(final String path) { | |
| if (isGuiThread()) { | |
| return new FTextureImage(new Texture(Gdx.files.absolute(path))); | |
| } | |
| @@ -113,7 +106,7 @@ | |
| } | |
| @Override | |
| - public ISkinImage getCardArt(PaperCard card) { | |
| + public ISkinImage getCardArt(final PaperCard card) { | |
| return CardRenderer.getCardArt(card); | |
| } | |
| @@ -121,15 +114,15 @@ | |
| public ISkinImage createLayeredImage(final FSkinProp background, final String overlayFilename, final float opacity) { | |
| return new FBufferedImage(background.getWidth(), background.getHeight(), opacity) { | |
| @Override | |
| - protected void draw(Graphics g, float w, float h) { | |
| + protected void draw(final Graphics g, final float w, final float h) { | |
| g.drawImage(FSkin.getImages().get(background), 0, 0, background.getWidth(), background.getHeight()); | |
| if (FileUtil.doesFileExist(overlayFilename)) { | |
| try { | |
| - Texture overlay = new Texture(Gdx.files.absolute(overlayFilename)); | |
| + final Texture overlay = new Texture(Gdx.files.absolute(overlayFilename)); | |
| g.drawImage(overlay, (background.getWidth() - overlay.getWidth()) / 2, (background.getHeight() - overlay.getHeight()) / 2, overlay.getWidth(), overlay.getHeight()); | |
| + } catch (final Exception e) { | |
| } | |
| - catch (Exception e) {} | |
| } | |
| Gdx.graphics.requestRendering(); //ensure image appears right away | |
| @@ -189,20 +182,20 @@ | |
| } | |
| @Override | |
| - public void showBugReportDialog(String title, String text, boolean showExitAppBtn) { | |
| + public void showBugReportDialog(final String title, final String text, final boolean showExitAppBtn) { | |
| BugReportDialog.show(title, text, showExitAppBtn); | |
| } | |
| @Override | |
| public void showCardList(final String title, final String message, final List<PaperCard> list) { | |
| - Deck deck = new Deck(title + " - " + message); | |
| + final Deck deck = new Deck(title + " - " + message); | |
| deck.getMain().addAllFlat(list); | |
| FDeckViewer.show(deck); | |
| } | |
| @Override | |
| public boolean showBoxedProduct(final String title, final String message, final List<PaperCard> list) { | |
| - Deck deck = new Deck(title + " - " + message); //TODO: Make this nicer | |
| + final Deck deck = new Deck(title + " - " + message); //TODO: Make this nicer | |
| deck.getMain().addAllFlat(list); | |
| FDeckViewer.show(deck); | |
| return false; | |
| @@ -217,42 +210,42 @@ | |
| } | |
| @Override | |
| - public String showFileDialog(String title, String defaultDir) { | |
| + public String showFileDialog(final String title, final String defaultDir) { | |
| return ForgeConstants.USER_GAMES_DIR + "Test.fgs"; //TODO: Show dialog | |
| } | |
| @Override | |
| - public File getSaveFile(File defaultFile) { | |
| + public File getSaveFile(final File defaultFile) { | |
| return defaultFile; //TODO: Show dialog | |
| } | |
| @Override | |
| - public void download(GuiDownloadService service, Callback<Boolean> callback) { | |
| - new GuiDownloader(service, callback); | |
| + public void download(final GuiDownloadService service, final Callback<Boolean> callback) { | |
| + new GuiDownloader(service, callback).show(); | |
| } | |
| @Override | |
| - public void copyToClipboard(String text) { | |
| + public void copyToClipboard(final String text) { | |
| Forge.getClipboard().setContents(text); | |
| } | |
| @Override | |
| - public void browseToUrl(String url) { | |
| + public void browseToUrl(final String url) { | |
| Gdx.net.openURI(url); | |
| } | |
| @Override | |
| - public IAudioClip createAudioClip(String filename) { | |
| + public IAudioClip createAudioClip(final String filename) { | |
| return AudioClip.createClip(ForgeConstants.SOUND_DIR + filename); | |
| } | |
| @Override | |
| - public IAudioMusic createAudioMusic(String filename) { | |
| + public IAudioMusic createAudioMusic(final String filename) { | |
| return new AudioMusic(filename); | |
| } | |
| @Override | |
| - public void startAltSoundSystem(String filename, boolean isSynchronized) { | |
| + public void startAltSoundSystem(final String filename, final boolean isSynchronized) { | |
| //TODO: Support alt sound system | |
| } | |
| Index: forge-gui-desktop/src/main/java/forge/screens/match/GameLogPanel.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/match/GameLogPanel.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/match/GameLogPanel.java (revision 29317) | |
| @@ -1,28 +1,38 @@ | |
| package forge.screens.match; | |
| +import java.awt.AWTEvent; | |
| +import java.awt.Cursor; | |
| +import java.awt.Dimension; | |
| +import java.awt.Rectangle; | |
| +import java.awt.event.ComponentAdapter; | |
| +import java.awt.event.ComponentEvent; | |
| +import java.awt.event.MouseEvent; | |
| + | |
| +import javax.swing.JComponent; | |
| +import javax.swing.JLayer; | |
| +import javax.swing.JPanel; | |
| +import javax.swing.JScrollBar; | |
| +import javax.swing.JTextArea; | |
| +import javax.swing.ScrollPaneConstants; | |
| +import javax.swing.Scrollable; | |
| +import javax.swing.SwingUtilities; | |
| +import javax.swing.border.EmptyBorder; | |
| +import javax.swing.plaf.LayerUI; | |
| + | |
| +import net.miginfocom.swing.MigLayout; | |
| import forge.gui.MouseUtil; | |
| import forge.toolbox.FScrollPane; | |
| import forge.toolbox.FSkin; | |
| import forge.toolbox.FSkin.SkinFont; | |
| import forge.toolbox.FSkin.SkinnedTextArea; | |
| -import net.miginfocom.swing.MigLayout; | |
| -import javax.swing.*; | |
| -import javax.swing.border.EmptyBorder; | |
| -import javax.swing.plaf.LayerUI; | |
| - | |
| -import java.awt.*; | |
| -import java.awt.event.ComponentAdapter; | |
| -import java.awt.event.ComponentEvent; | |
| -import java.awt.event.MouseEvent; | |
| - | |
| @SuppressWarnings("serial") | |
| public class GameLogPanel extends JPanel { | |
| private FScrollPane scrollPane; | |
| private MyScrollablePanel scrollablePanel; | |
| private SkinFont textFont = FSkin.getFont(); | |
| - private LayerUI<FScrollPane> layerUI = new GameLogPanelLayerUI(); | |
| + private final LayerUI<FScrollPane> layerUI = new GameLogPanelLayerUI(); | |
| private JLayer<FScrollPane> layer; | |
| private boolean isScrollBarVisible = false; | |
| @@ -55,7 +65,7 @@ | |
| private void setResizeListener() { | |
| addComponentListener(new ComponentAdapter() { | |
| @Override | |
| - public void componentResized(ComponentEvent arg0) { | |
| + public void componentResized(final ComponentEvent arg0) { | |
| forceVerticalScrollbarToMax(); | |
| } | |
| }); | |
| @@ -101,7 +111,7 @@ | |
| SwingUtilities.invokeLater(new Runnable() { | |
| @Override | |
| public void run() { | |
| - JScrollBar scrollbar = scrollPane.getVerticalScrollBar(); | |
| + final JScrollBar scrollbar = scrollPane.getVerticalScrollBar(); | |
| scrollbar.setValue(scrollbar.getMaximum()); | |
| // This is needed to ensure scrollbar is set to max correctly. | |
| scrollPane.validate(); | |
| @@ -131,11 +141,11 @@ | |
| } | |
| - public void setTextFont(SkinFont newFont) { | |
| + public void setTextFont(final SkinFont newFont) { | |
| this.textFont = newFont; | |
| } | |
| - private JTextArea createNewLogEntryJTextArea(String text, boolean useAlternateBackColor) { | |
| + private JTextArea createNewLogEntryJTextArea(final String text, final boolean useAlternateBackColor) { | |
| final SkinnedTextArea tar = new SkinnedTextArea(text); | |
| tar.setFont(textFont); | |
| tar.setBorder(new EmptyBorder(3, 4, 3, 4)); | |
| @@ -155,23 +165,28 @@ | |
| protected final class MyScrollablePanel extends JPanel implements Scrollable { | |
| + @Override | |
| public Dimension getPreferredScrollableViewportSize() { | |
| return getPreferredSize(); | |
| } | |
| - public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) { | |
| + @Override | |
| + public int getScrollableUnitIncrement(final Rectangle visibleRect, final int orientation, final int direction) { | |
| return textFont.getSize(); | |
| } | |
| - public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) { | |
| + @Override | |
| + public int getScrollableBlockIncrement(final Rectangle visibleRect, final int orientation, final int direction) { | |
| return textFont.getSize(); | |
| } | |
| + @Override | |
| public boolean getScrollableTracksViewportWidth() { | |
| return true; | |
| } | |
| // we don't want to track the height, because we want to scroll vertically. | |
| + @Override | |
| public boolean getScrollableTracksViewportHeight() { | |
| return false; | |
| } | |
| @@ -181,25 +196,25 @@ | |
| @SuppressWarnings("unchecked") | |
| @Override | |
| - public void installUI(JComponent c) { | |
| + public void installUI(final JComponent c) { | |
| super.installUI(c); | |
| - JLayer<FScrollPane> l = (JLayer<FScrollPane>)c; | |
| + final JLayer<FScrollPane> l = (JLayer<FScrollPane>)c; | |
| l.setLayerEventMask(AWTEvent.MOUSE_EVENT_MASK); | |
| } | |
| @SuppressWarnings("unchecked") | |
| @Override | |
| - public void uninstallUI(JComponent c) { | |
| + public void uninstallUI(final JComponent c) { | |
| super.uninstallUI(c); | |
| - JLayer<FScrollPane> l = (JLayer<FScrollPane>)c; | |
| + final JLayer<FScrollPane> l = (JLayer<FScrollPane>)c; | |
| l.setLayerEventMask(0); | |
| } | |
| @Override | |
| - protected void processMouseEvent(MouseEvent e, JLayer<? extends FScrollPane> l) { | |
| + protected void processMouseEvent(final MouseEvent e, final JLayer<? extends FScrollPane> l) { | |
| - boolean isScrollBarRequired = scrollPane.getVerticalScrollBar().getMaximum() > getHeight(); | |
| - boolean isHoveringOverLogEntry = e.getSource() instanceof JTextArea; | |
| + final boolean isScrollBarRequired = scrollPane.getVerticalScrollBar().getMaximum() > getHeight(); | |
| + final boolean isHoveringOverLogEntry = e.getSource() instanceof JTextArea; | |
| switch (e.getID()) { | |
| case MouseEvent.MOUSE_ENTERED: | |
| Index: forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CProbabilities.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CProbabilities.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CProbabilities.java (revision 29317) | |
| @@ -1,5 +1,12 @@ | |
| package forge.screens.deckeditor.controllers; | |
| +import java.util.ArrayList; | |
| +import java.util.Collections; | |
| +import java.util.HashMap; | |
| +import java.util.Iterator; | |
| +import java.util.List; | |
| +import java.util.Map; | |
| + | |
| import forge.UiCommand; | |
| import forge.deck.DeckBase; | |
| import forge.gui.framework.ICDoc; | |
| @@ -10,11 +17,9 @@ | |
| import forge.util.ItemPool; | |
| import forge.util.MyRandom; | |
| -import java.util.*; | |
| - | |
| -/** | |
| +/** | |
| * Controls the "analysis" panel in the deck editor UI. | |
| - * | |
| + * | |
| * <br><br><i>(C at beginning of class name denotes a control class.)</i> | |
| * | |
| */ | |
| @@ -24,15 +29,7 @@ | |
| //========== Overridden methods | |
| - /* (non-Javadoc) | |
| - * @see forge.gui.framework.ICDoc#getCommandOnSelect() | |
| - */ | |
| @Override | |
| - public UiCommand getCommandOnSelect() { | |
| - return null; | |
| - } | |
| - | |
| - @Override | |
| public void register() { | |
| } | |
| @@ -65,7 +62,7 @@ | |
| CDeckEditorUI.SINGLETON_INSTANCE.getCurrentEditorController(); | |
| if (ed == null) { return new ArrayList<String>(); } | |
| - | |
| + | |
| final ItemPool<PaperCard> deck = ItemPool.createFrom(ed.getDeckManager().getPool(), PaperCard.class); | |
| final List<String> cardProbabilities = new ArrayList<String>(); | |
| @@ -84,12 +81,11 @@ | |
| // Formulas is (remaining instances of this card / total cards remaining) | |
| final Iterator<PaperCard> itr = shuffled.iterator(); | |
| PaperCard tmp; | |
| - // int prob; | |
| while (itr.hasNext()) { | |
| tmp = itr.next(); | |
| - // prob = SEditorUtil.calculatePercentage( | |
| + // int prob = SEditorUtil.calculatePercentage( | |
| - // cardTotals.get(tmp), shuffled.size()); | |
| + // cardTotals.get(tmp), shuffled.size()); | |
| cardTotals.put(tmp, cardTotals.get(tmp) - 1); | |
| cardProbabilities.add(tmp.getName()); // + " (" + prob + "%)"); | |
| Index: forge-gui/src/main/java/forge/deck/DeckProxy.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui/src/main/java/forge/deck/DeckProxy.java (revision 29316) | |
| +++ forge-gui/src/main/java/forge/deck/DeckProxy.java (revision 29317) | |
| @@ -31,7 +31,6 @@ | |
| import forge.util.BinaryUtil; | |
| import forge.util.IHasName; | |
| import forge.util.storage.IStorage; | |
| -import forge.util.storage.StorageImmediatelySerialized; | |
| // Adding a generic to this class creates compile problems in ItemManager (that I can not fix) | |
| public class DeckProxy implements InventoryItem { | |
| @@ -41,7 +40,7 @@ | |
| public static final Function<DeckProxy, String> FN_GET_NAME = new Function<DeckProxy, String>() { | |
| @Override | |
| - public String apply(DeckProxy arg0) { | |
| + public String apply(final DeckProxy arg0) { | |
| return arg0.getName(); | |
| } | |
| }; | |
| @@ -61,15 +60,15 @@ | |
| this(null, "", null, "", null, null); | |
| } | |
| - public DeckProxy(Deck deck, String deckType, GameType type, IStorage<? extends IHasName> storage) { | |
| + public DeckProxy(final Deck deck, final String deckType, final GameType type, final IStorage<? extends IHasName> storage) { | |
| this(deck, deckType, type, "", storage, null); | |
| } | |
| - public DeckProxy(IHasName deck, String deckType, Function<IHasName, Deck> fnGetDeck, GameType type, IStorage<? extends IHasName> storage) { | |
| + public DeckProxy(final IHasName deck, final String deckType, final Function<IHasName, Deck> fnGetDeck, final GameType type, final IStorage<? extends IHasName> storage) { | |
| this(deck, deckType, type, "", storage, fnGetDeck); | |
| } | |
| - private DeckProxy(IHasName deck, String deckType, GameType type, String path, IStorage<? extends IHasName> storage, Function<IHasName, Deck> fnGetDeck) { | |
| + private DeckProxy(final IHasName deck, final String deckType, final GameType type, final String path, final IStorage<? extends IHasName> storage, final Function<IHasName, Deck> fnGetDeck) { | |
| this.deck = deck; | |
| this.deckType = deckType; | |
| this.storage = storage; | |
| @@ -120,7 +119,7 @@ | |
| return getDeckString(path, deck.getName()); | |
| } | |
| - public static String getDeckString(String path, String name) { | |
| + public static String getDeckString(final String path, final String name) { | |
| if (StringUtils.isEmpty(path)) { | |
| return name; | |
| } | |
| @@ -143,17 +142,17 @@ | |
| byte landProfile = MagicColor.COLORLESS; | |
| HashSet<Byte> nonReqColors = null; | |
| - for (Entry<DeckSection, CardPool> deckEntry : getDeck()) { | |
| + for (final Entry<DeckSection, CardPool> deckEntry : getDeck()) { | |
| switch (deckEntry.getKey()) { | |
| case Main: | |
| case Commander: | |
| - for (Entry<PaperCard, Integer> poolEntry : deckEntry.getValue()) { | |
| - CardRules rules = poolEntry.getKey().getRules(); | |
| + for (final Entry<PaperCard, Integer> poolEntry : deckEntry.getValue()) { | |
| + final CardRules rules = poolEntry.getKey().getRules(); | |
| if (rules.getType().isLand()) { //track color identity of lands separately | |
| landProfile |= rules.getColorIdentity().getColor(); | |
| } | |
| else { | |
| - for (ManaCostShard shard : rules.getManaCost()) { | |
| + for (final ManaCostShard shard : rules.getManaCost()) { | |
| //track phyrexian and hybrid costs separately as they won't always affect color | |
| if (shard.isPhyrexian() || shard.isOr2Colorless() || !shard.isMonoColor()) { | |
| if (nonReqColors == null) { | |
| @@ -175,7 +174,7 @@ | |
| if (nonReqColors != null) { | |
| //if any non-required mana colors present, determine which colors, if any, | |
| //need to be accounted for in color profile of deck | |
| - for (Byte colorMask : nonReqColors) { | |
| + for (final Byte colorMask : nonReqColors) { | |
| colorProfile |= (colorMask & landProfile); | |
| } | |
| } | |
| @@ -188,12 +187,12 @@ | |
| if (colorIdentity == null) { | |
| byte colorProfile = MagicColor.COLORLESS; | |
| - for (Entry<DeckSection, CardPool> deckEntry : getDeck()) { | |
| + for (final Entry<DeckSection, CardPool> deckEntry : getDeck()) { | |
| switch (deckEntry.getKey()) { | |
| case Main: | |
| case Sideboard: | |
| case Commander: | |
| - for (Entry<PaperCard, Integer> poolEntry : deckEntry.getValue()) { | |
| + for (final Entry<PaperCard, Integer> poolEntry : deckEntry.getValue()) { | |
| colorProfile |= poolEntry.getKey().getRules().getColorIdentity().getColor(); | |
| } | |
| break; | |
| @@ -209,12 +208,12 @@ | |
| public CardRarity getHighestRarity() { | |
| if (highestRarity == null) { | |
| highestRarity = CardRarity.Common; | |
| - for (Entry<DeckSection, CardPool> deckEntry : getDeck()) { | |
| + for (final Entry<DeckSection, CardPool> deckEntry : getDeck()) { | |
| switch (deckEntry.getKey()) { | |
| case Main: | |
| case Sideboard: | |
| case Commander: | |
| - for (Entry<PaperCard, Integer> poolEntry : deckEntry.getValue()) { | |
| + for (final Entry<PaperCard, Integer> poolEntry : deckEntry.getValue()) { | |
| switch (poolEntry.getKey().getRarity()) { | |
| case MythicRare: | |
| highestRarity = CardRarity.MythicRare; | |
| @@ -262,11 +261,11 @@ | |
| mainSize = -1; | |
| } | |
| else { | |
| - Deck d = getDeck(); | |
| + final Deck d = getDeck(); | |
| mainSize = d.getMain().countAll(); | |
| //account for commander as part of main deck size | |
| - CardPool commander = d.get(DeckSection.Commander); | |
| + final CardPool commander = d.get(DeckSection.Commander); | |
| if (commander != null) { | |
| mainSize += commander.countAll(); | |
| } | |
| @@ -277,7 +276,7 @@ | |
| public int getSideSize() { | |
| if (sbSize == null) { | |
| - CardPool sb = getDeck().get(DeckSection.Sideboard); | |
| + final CardPool sb = getDeck().get(DeckSection.Sideboard); | |
| sbSize = sb == null ? -1 : sb.countAll(); | |
| if (sbSize == 0) { | |
| sbSize = -1; | |
| @@ -296,36 +295,36 @@ | |
| // TODO: The methods below should not take the decks collections from singletons, instead they are supposed to use data passed in parameters | |
| public static Iterable<DeckProxy> getAllConstructedDecks() { | |
| - List<DeckProxy> result = new ArrayList<DeckProxy>(); | |
| + final List<DeckProxy> result = new ArrayList<DeckProxy>(); | |
| addDecksRecursivelly("Constructed", GameType.Constructed, result, "", FModel.getDecks().getConstructed()); | |
| return result; | |
| } | |
| public static Iterable<DeckProxy> getAllCommanderDecks() { | |
| - List<DeckProxy> result = new ArrayList<DeckProxy>(); | |
| + final List<DeckProxy> result = new ArrayList<DeckProxy>(); | |
| addDecksRecursivelly("Commander", GameType.Commander, result, "", FModel.getDecks().getCommander()); | |
| return result; | |
| } | |
| public static Iterable<DeckProxy> getAllSchemeDecks() { | |
| - List<DeckProxy> result = new ArrayList<DeckProxy>(); | |
| + final List<DeckProxy> result = new ArrayList<DeckProxy>(); | |
| addDecksRecursivelly("Scheme", GameType.Archenemy, result, "", FModel.getDecks().getScheme()); | |
| return result; | |
| } | |
| public static Iterable<DeckProxy> getAllPlanarDecks() { | |
| - List<DeckProxy> result = new ArrayList<DeckProxy>(); | |
| + final List<DeckProxy> result = new ArrayList<DeckProxy>(); | |
| addDecksRecursivelly("Plane", GameType.Planechase, result, "", FModel.getDecks().getPlane()); | |
| return result; | |
| } | |
| - private static void addDecksRecursivelly(String deckType, GameType gameType, List<DeckProxy> list, String path, IStorage<Deck> folder) { | |
| - for (IStorage<Deck> f : folder.getFolders()) { | |
| - String subPath = (StringUtils.isBlank(path) ? "" : path) + "/" + f.getName(); | |
| + private static void addDecksRecursivelly(final String deckType, final GameType gameType, final List<DeckProxy> list, final String path, final IStorage<Deck> folder) { | |
| + for (final IStorage<Deck> f : folder.getFolders()) { | |
| + final String subPath = (StringUtils.isBlank(path) ? "" : path) + "/" + f.getName(); | |
| addDecksRecursivelly(deckType, gameType, list, subPath, f); | |
| } | |
| - for (Deck d : folder) { | |
| + for (final Deck d : folder) { | |
| list.add(new DeckProxy(d, deckType, gameType, path, folder, null)); | |
| } | |
| } | |
| @@ -334,13 +333,13 @@ | |
| public static final Predicate<DeckProxy> createPredicate(final Predicate<PaperCard> cardPredicate) { | |
| return new Predicate<DeckProxy>() { | |
| @Override | |
| - public boolean apply(DeckProxy input) { | |
| - for (Entry<DeckSection, CardPool> deckEntry : input.getDeck()) { | |
| + public boolean apply(final DeckProxy input) { | |
| + for (final Entry<DeckSection, CardPool> deckEntry : input.getDeck()) { | |
| switch (deckEntry.getKey()) { | |
| case Main: | |
| case Sideboard: | |
| case Commander: | |
| - for (Entry<PaperCard, Integer> poolEntry : deckEntry.getValue()) { | |
| + for (final Entry<PaperCard, Integer> poolEntry : deckEntry.getValue()) { | |
| if (!cardPredicate.apply(poolEntry.getKey())) { | |
| return false; //all cards in deck must pass card predicate to pass deck predicate | |
| } | |
| @@ -362,13 +361,6 @@ | |
| invalidateCache(); | |
| } | |
| - @SuppressWarnings("unchecked") | |
| - public void updateInStorage() { | |
| - if (storage instanceof StorageImmediatelySerialized<?>) { | |
| - ((StorageImmediatelySerialized<IHasName>)storage).add(deck); | |
| - } | |
| - } | |
| - | |
| public void deleteFromStorage() { | |
| if (storage != null) { | |
| storage.delete(getName()); | |
| @@ -377,7 +369,7 @@ | |
| private static class ThemeDeckGenerator extends DeckProxy { | |
| private final String name; | |
| - public ThemeDeckGenerator(String name0) { | |
| + public ThemeDeckGenerator(final String name0) { | |
| super(); | |
| name = name0; | |
| } | |
| @@ -388,7 +380,7 @@ | |
| final Deck deck = new Deck(); | |
| gen.setSingleton(FModel.getPreferences().getPrefBoolean(FPref.DECKGEN_SINGLETONS)); | |
| gen.setUseArtifacts(!FModel.getPreferences().getPrefBoolean(FPref.DECKGEN_ARTIFACTS)); | |
| - StringBuilder errorBuilder = new StringBuilder(); | |
| + final StringBuilder errorBuilder = new StringBuilder(); | |
| deck.getMain().addAll(gen.getThemeDeck(this.getName(), 60, errorBuilder)); | |
| if (errorBuilder.length() > 0) { | |
| throw new RuntimeException(errorBuilder.toString()); | |
| @@ -406,13 +398,14 @@ | |
| return name; | |
| } | |
| + @Override | |
| public boolean isGeneratedDeck() { | |
| return true; | |
| } | |
| } | |
| public static List<DeckProxy> getAllThemeDecks() { | |
| - ArrayList<DeckProxy> decks = new ArrayList<DeckProxy>(); | |
| + final List<DeckProxy> decks = new ArrayList<DeckProxy>(); | |
| for (final String s : DeckGeneratorTheme.getThemeNames()) { | |
| decks.add(new ThemeDeckGenerator(s)); | |
| } | |
| @@ -420,8 +413,8 @@ | |
| } | |
| @SuppressWarnings("unchecked") | |
| - public static List<DeckProxy> getAllPreconstructedDecks(IStorage<PreconDeck> iStorage) { | |
| - ArrayList<DeckProxy> decks = new ArrayList<DeckProxy>(); | |
| + public static List<DeckProxy> getAllPreconstructedDecks(final IStorage<PreconDeck> iStorage) { | |
| + final List<DeckProxy> decks = new ArrayList<DeckProxy>(); | |
| for (final PreconDeck preconDeck : iStorage) { | |
| decks.add(new DeckProxy(preconDeck, "Precon", (Function<IHasName, Deck>)(Object)PreconDeck.FN_GET_DECK, null, iStorage)); | |
| } | |
| @@ -429,12 +422,12 @@ | |
| } | |
| public static List<DeckProxy> getAllQuestEventAndChallenges() { | |
| - ArrayList<DeckProxy> decks = new ArrayList<DeckProxy>(); | |
| - QuestController quest = FModel.getQuest(); | |
| - for (QuestEvent e : quest.getDuelsManager().getAllDuels()) { | |
| + final List<DeckProxy> decks = new ArrayList<DeckProxy>(); | |
| + final QuestController quest = FModel.getQuest(); | |
| + for (final QuestEvent e : quest.getDuelsManager().getAllDuels()) { | |
| decks.add(new DeckProxy(e.getEventDeck(), "Quest Event", null, null)); | |
| } | |
| - for (QuestEvent e : quest.getChallenges()) { | |
| + for (final QuestEvent e : quest.getChallenges()) { | |
| decks.add(new DeckProxy(e.getEventDeck(), "Quest Event", null, null)); | |
| } | |
| return decks; | |
| @@ -453,8 +446,8 @@ | |
| return humanDecks; | |
| } | |
| - public static List<DeckProxy> getAllQuestDecks(IStorage<Deck> storage) { | |
| - ArrayList<DeckProxy> decks = new ArrayList<DeckProxy>(); | |
| + public static List<DeckProxy> getAllQuestDecks(final IStorage<Deck> storage) { | |
| + final List<DeckProxy> decks = new ArrayList<DeckProxy>(); | |
| if (storage != null) { | |
| for (final Deck deck : storage) { | |
| decks.add(new DeckProxy(deck, "Quest", GameType.Quest, storage)); | |
| @@ -465,25 +458,25 @@ | |
| @SuppressWarnings("unchecked") | |
| public static List<DeckProxy> getAllDraftDecks() { | |
| - ArrayList<DeckProxy> decks = new ArrayList<DeckProxy>(); | |
| - IStorage<DeckGroup> draft = FModel.getDecks().getDraft(); | |
| - for (DeckGroup d : draft) { | |
| + final List<DeckProxy> decks = new ArrayList<DeckProxy>(); | |
| + final IStorage<DeckGroup> draft = FModel.getDecks().getDraft(); | |
| + for (final DeckGroup d : draft) { | |
| decks.add(new DeckProxy(d, "Draft", ((Function<IHasName, Deck>)(Object)DeckGroup.FN_HUMAN_DECK), GameType.Draft, draft)); | |
| } | |
| return decks; | |
| } | |
| @SuppressWarnings("unchecked") | |
| - public static List<DeckProxy> getWinstonDecks(IStorage<DeckGroup> draft) { | |
| - ArrayList<DeckProxy> decks = new ArrayList<DeckProxy>(); | |
| - for (DeckGroup d : draft) { | |
| + public static List<DeckProxy> getWinstonDecks(final IStorage<DeckGroup> draft) { | |
| + final List<DeckProxy> decks = new ArrayList<DeckProxy>(); | |
| + for (final DeckGroup d : draft) { | |
| decks.add(new DeckProxy(d, "Winston", ((Function<IHasName, Deck>)(Object)DeckGroup.FN_HUMAN_DECK), GameType.Winston, draft)); | |
| } | |
| return decks; | |
| } | |
| - public static List<DeckProxy> getNetDecks(NetDeckCategory category) { | |
| - ArrayList<DeckProxy> decks = new ArrayList<DeckProxy>(); | |
| + public static List<DeckProxy> getNetDecks(final NetDeckCategory category) { | |
| + final List<DeckProxy> decks = new ArrayList<DeckProxy>(); | |
| if (category != null) { | |
| addDecksRecursivelly("Constructed", GameType.Constructed, decks, "", category); | |
| } | |
| @@ -493,49 +486,49 @@ | |
| public static final Predicate<DeckProxy> IS_WHITE = new Predicate<DeckProxy>() { | |
| @Override | |
| public boolean apply(final DeckProxy deck) { | |
| - ColorSet cs = deck.getColor(); | |
| + final ColorSet cs = deck.getColor(); | |
| return cs != null && cs.hasAnyColor(MagicColor.WHITE); | |
| } | |
| }; | |
| public static final Predicate<DeckProxy> IS_BLUE = new Predicate<DeckProxy>() { | |
| @Override | |
| public boolean apply(final DeckProxy deck) { | |
| - ColorSet cs = deck.getColor(); | |
| + final ColorSet cs = deck.getColor(); | |
| return cs != null && cs.hasAnyColor(MagicColor.BLUE); | |
| } | |
| }; | |
| public static final Predicate<DeckProxy> IS_BLACK = new Predicate<DeckProxy>() { | |
| @Override | |
| public boolean apply(final DeckProxy deck) { | |
| - ColorSet cs = deck.getColor(); | |
| + final ColorSet cs = deck.getColor(); | |
| return cs != null && cs.hasAnyColor(MagicColor.BLACK); | |
| } | |
| }; | |
| public static final Predicate<DeckProxy> IS_RED = new Predicate<DeckProxy>() { | |
| @Override | |
| public boolean apply(final DeckProxy deck) { | |
| - ColorSet cs = deck.getColor(); | |
| + final ColorSet cs = deck.getColor(); | |
| return cs != null && cs.hasAnyColor(MagicColor.RED); | |
| } | |
| }; | |
| public static final Predicate<DeckProxy> IS_GREEN = new Predicate<DeckProxy>() { | |
| @Override | |
| public boolean apply(final DeckProxy deck) { | |
| - ColorSet cs = deck.getColor(); | |
| + final ColorSet cs = deck.getColor(); | |
| return cs != null && cs.hasAnyColor(MagicColor.GREEN); | |
| } | |
| }; | |
| public static final Predicate<DeckProxy> IS_COLORLESS = new Predicate<DeckProxy>() { | |
| @Override | |
| public boolean apply(final DeckProxy deck) { | |
| - ColorSet cs = deck.getColor(); | |
| + final ColorSet cs = deck.getColor(); | |
| return cs != null && cs.getColor() == 0; | |
| } | |
| }; | |
| public static final Predicate<DeckProxy> IS_MULTICOLOR = new Predicate<DeckProxy>() { | |
| @Override | |
| public boolean apply(final DeckProxy deck) { | |
| - ColorSet cs = deck.getColor(); | |
| + final ColorSet cs = deck.getColor(); | |
| return cs != null && BinaryUtil.bitCount(cs.getColor()) > 1; | |
| } | |
| }; | |
| Index: forge-gui-desktop/src/main/java/forge/screens/workshop/controllers/CWorkshopCatalog.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/screens/workshop/controllers/CWorkshopCatalog.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/screens/workshop/controllers/CWorkshopCatalog.java (revision 29317) | |
| @@ -1,13 +1,12 @@ | |
| package forge.screens.workshop.controllers; | |
| -import forge.UiCommand; | |
| import forge.gui.framework.ICDoc; | |
| import forge.itemmanager.ItemManagerConfig; | |
| import forge.screens.workshop.views.VWorkshopCatalog; | |
| -/** | |
| +/** | |
| * Controls the "card catalog" panel in the workshop UI. | |
| - * | |
| + * | |
| * <br><br><i>(C at beginning of class name denotes a control class.)</i> | |
| * | |
| */ | |
| @@ -19,14 +18,6 @@ | |
| } | |
| //========== Overridden methods | |
| - | |
| - /* (non-Javadoc) | |
| - * @see forge.gui.framework.ICDoc#getCommandOnSelect() | |
| - */ | |
| - @Override | |
| - public UiCommand getCommandOnSelect() { | |
| - return null; | |
| - } | |
| @Override | |
| public void register() { | |
| @@ -38,7 +29,7 @@ | |
| @Override | |
| public void initialize() { | |
| } | |
| - | |
| + | |
| /* (non-Javadoc) | |
| * @see forge.gui.framework.ICDoc#update() | |
| */ | |
| Index: forge-gui-desktop/src/main/java/forge/toolbox/FRadioButton.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui-desktop/src/main/java/forge/toolbox/FRadioButton.java (revision 29316) | |
| +++ forge-gui-desktop/src/main/java/forge/toolbox/FRadioButton.java (revision 29317) | |
| @@ -2,7 +2,7 @@ | |
| import forge.toolbox.FSkin.SkinnedRadioButton; | |
| -/** | |
| +/** | |
| * A custom instance of JRadioButton using Forge skin properties. | |
| */ | |
| @SuppressWarnings("serial") | |
| @@ -12,16 +12,17 @@ | |
| this("", null); | |
| } | |
| - public FRadioButton(String s0) { | |
| + public FRadioButton(final String s0) { | |
| this(s0, null); | |
| } | |
| - | |
| + | |
| /** @param s0   {@link java.lang.String} */ | |
| - public FRadioButton(String s0, Boolean selected) { | |
| + public FRadioButton(final String s0, final Boolean selected) { | |
| super(); | |
| this.setText(s0); | |
| - if ( null != selected) | |
| + if (null != selected) { | |
| this.setSelected(selected.booleanValue()); | |
| + } | |
| this.setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT)); | |
| this.setFont(FSkin.getFont(14)); | |
| this.setOpaque(false); | |
| Index: forge-gui/src/main/java/forge/player/HumanCostDecision.java | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>ISO-8859-1 | |
| =================================================================== | |
| --- forge-gui/src/main/java/forge/player/HumanCostDecision.java (revision 29316) | |
| +++ forge-gui/src/main/java/forge/player/HumanCostDecision.java (revision 29317) | |
| @@ -82,14 +82,14 @@ | |
| return AbilityFactory.calculateAmount(card, "ChosenX", null); | |
| }*/ | |
| - int chosenX = player.getController().chooseNumber(ability, source.toString() + " - Choose a Value for X", 0, maxValue); | |
| + final int chosenX = player.getController().chooseNumber(ability, source.toString() + " - Choose a Value for X", 0, maxValue); | |
| ability.setSVar("ChosenX", Integer.toString(chosenX)); | |
| source.setSVar("ChosenX", Integer.toString(chosenX)); | |
| return chosenX; | |
| } | |
| @Override | |
| - public PaymentDecision visit(CostAddMana cost) { | |
| + public PaymentDecision visit(final CostAddMana cost) { | |
| Integer c = cost.convertAmount(); | |
| if (c == null) { | |
| c = AbilityUtils.calculateAmount(source, cost.getAmount(), ability); | |
| @@ -98,17 +98,18 @@ | |
| } | |
| @Override | |
| - public PaymentDecision visit(CostChooseCreatureType cost) { | |
| - String choice = controller.chooseSomeType("Creature", ability, new ArrayList<String>(CardType.Constant.CREATURE_TYPES), new ArrayList<String>(), true); | |
| - if (null == choice) | |
| + public PaymentDecision visit(final CostChooseCreatureType cost) { | |
| + final String choice = controller.chooseSomeType("Creature", ability, new ArrayList<String>(CardType.Constant.CREATURE_TYPES), new ArrayList<String>(), true); | |
| + if (null == choice) { | |
| return null; | |
| + } | |
| return PaymentDecision.type(choice); | |
| } | |
| @Override | |
| - public PaymentDecision visit(CostDiscard cost) { | |
| + public PaymentDecision visit(final CostDiscard cost) { | |
| CardCollectionView hand = player.getCardsIn(ZoneType.Hand); | |
| - String discardType = cost.getType(); | |
| + final String discardType = cost.getType(); | |
| final String amount = cost.getAmount(); | |
| if (cost.payCostFromSource()) { | |
| @@ -141,13 +142,13 @@ | |
| return PaymentDecision.card(Aggregates.random(hand, c, new CardCollection())); | |
| } | |
| if (discardType.contains("+WithSameName")) { | |
| - String type = discardType.replace("+WithSameName", ""); | |
| + final String type = discardType.replace("+WithSameName", ""); | |
| hand = CardLists.getValidCards(hand, type.split(";"), player, source); | |
| final CardCollectionView landList2 = hand; | |
| hand = CardLists.filter(hand, new Predicate<Card>() { | |
| @Override | |
| public boolean apply(final Card c) { | |
| - for (Card card : landList2) { | |
| + for (final Card card : landList2) { | |
| if (!card.equals(c) && card.getName().equals(c.getName())) { | |
| return true; | |
| } | |
| @@ -158,9 +159,9 @@ | |
| if (c == 0) { | |
| return PaymentDecision.card(new CardCollection()); | |
| } | |
| - CardCollection discarded = new CardCollection(); | |
| + final CardCollection discarded = new CardCollection(); | |
| while (c > 0) { | |
| - InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, 1, 1, hand); | |
| + final InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, 1, 1, hand); | |
| inp.setMessage("Select one of the cards with the same name to discard. Already chosen: " + discarded); | |
| inp.setCancelAllowed(true); | |
| inp.showAndWait(); | |
| @@ -169,15 +170,15 @@ | |
| } | |
| final Card first = inp.getFirstSelected(); | |
| discarded.add(first); | |
| - CardCollection filteredHand = CardLists.filter(hand, CardPredicates.nameEquals(first.getName())); | |
| + final CardCollection filteredHand = CardLists.filter(hand, CardPredicates.nameEquals(first.getName())); | |
| filteredHand.remove(first); | |
| hand = filteredHand; | |
| c--; | |
| } | |
| return PaymentDecision.card(discarded); | |
| } | |
| - | |
| + | |
| - String type = new String(discardType); | |
| + final String type = new String(discardType); | |
| final String[] validType = type.split(";"); | |
| hand = CardLists.getValidCards(hand, validType, player, source); | |
| @@ -192,7 +193,7 @@ | |
| } | |
| } | |
| - InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, c, c, hand); | |
| + final InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, c, c, hand); | |
| inp.setMessage("Select %d more " + cost.getDescriptiveType() + " to discard."); | |
| inp.setCancelAllowed(true); | |
| inp.showAndWait(); | |
| @@ -203,7 +204,7 @@ | |
| } | |
| @Override | |
| - public PaymentDecision visit(CostDamage cost) { | |
| + public PaymentDecision visit(final CostDamage cost) { | |
| final String amount = cost.getAmount(); | |
| final int life = player.getLife(); | |
| @@ -226,7 +227,7 @@ | |
| } | |
| @Override | |
| - public PaymentDecision visit(CostDraw cost) { | |
| + public PaymentDecision visit(final CostDraw cost) { | |
| final String amount = cost.getAmount(); | |
| Integer c = cost.convertAmount(); | |
| @@ -242,9 +243,9 @@ | |
| } | |
| @Override | |
| - public PaymentDecision visit(CostExile cost) { | |
| + public PaymentDecision visit(final CostExile cost) { | |
| final String amount = cost.getAmount(); | |
| - final Game game = player.getGame(); | |
| + final Game game = player.getGame(); | |
| Integer c = cost.convertAmount(); | |
| String type = cost.getType(); | |
| @@ -257,7 +258,7 @@ | |
| CardCollection list; | |
| if (cost.getFrom().equals(ZoneType.Stack)) { | |
| list = new CardCollection(); | |
| - for (SpellAbilityStackInstance si : game.getStack()) { | |
| + for (final SpellAbilityStackInstance si : game.getStack()) { | |
| list.add(si.getSourceCard()); | |
| } | |
| } | |
| @@ -288,7 +289,7 @@ | |
| } | |
| if (cost.from == ZoneType.Battlefield || cost.from == ZoneType.Hand) { | |
| - InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, c, c, list); | |
| + final InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, c, c, list); | |
| inp.setMessage("Exile %d card(s) from your" + cost.from); | |
| inp.setCancelAllowed(true); | |
| inp.showAndWait(); | |
| @@ -299,10 +300,10 @@ | |
| if (fromTopGrave) { return exileFromTopGraveType(ability, c, list); } | |
| if (!cost.sameZone) { return exileFromMiscZone(cost, ability, c, list); } | |
| - FCollectionView<Player> players = game.getPlayers(); | |
| - List<Player> payableZone = new ArrayList<Player>(); | |
| - for (Player p : players) { | |
| - CardCollection enoughType = CardLists.filter(list, CardPredicates.isOwner(p)); | |
| + final FCollectionView<Player> players = game.getPlayers(); | |
| + final List<Player> payableZone = new ArrayList<Player>(); | |
| + for (final Player p : players) { | |
| + final CardCollection enoughType = CardLists.filter(list, CardPredicates.isOwner(p)); | |
| if (enoughType.size() < c) { | |
| list.removeAll((CardCollectionView)enoughType); | |
| } | |
| @@ -312,7 +313,7 @@ | |
| } | |
| return exileFromSame(cost, list, c, payableZone); | |
| } | |
| - | |
| + | |
| // Inputs | |
| @@ -323,7 +324,7 @@ | |
| // ExileFromTop<Num/Type{/TypeDescription}> (of library) | |
| // ExileSameGrave<Num/Type{/TypeDescription}> | |
| - private PaymentDecision exileFromSame(CostExile cost, CardCollectionView list, int nNeeded, List<Player> payableZone) { | |
| + private PaymentDecision exileFromSame(final CostExile cost, final CardCollectionView list, final int nNeeded, final List<Player> payableZone) { | |
| if (nNeeded == 0) { | |
| return PaymentDecision.number(0); | |
| } | |
| @@ -342,18 +343,18 @@ | |
| final CardCollection toExile = game.getCardList(controller.getGui().many("Exile from " + cost.getFrom(), "To be exiled", nNeeded, CardView.getCollection(typeList), null)); | |
| return PaymentDecision.card(toExile); | |
| } | |
| - | |
| + | |
| @Override | |
| - public PaymentDecision visit(CostExileFromStack cost) { | |
| + public PaymentDecision visit(final CostExileFromStack cost) { | |
| final String amount = cost.getAmount(); | |
| - final Game game = player.getGame(); | |
| + final Game game = player.getGame(); | |
| Integer c = cost.convertAmount(); | |
| - String type = cost.getType(); | |
| - List<SpellAbility> saList = new ArrayList<SpellAbility>(); | |
| - ArrayList<String> descList = new ArrayList<String>(); | |
| + final String type = cost.getType(); | |
| + final List<SpellAbility> saList = new ArrayList<SpellAbility>(); | |
| + final List<String> descList = new ArrayList<String>(); | |
| - for (SpellAbilityStackInstance si : game.getStack()) { | |
| + for (final SpellAbilityStackInstance si : game.getStack()) { | |
| final Card stC = si.getSourceCard(); | |
| final SpellAbility stSA = si.getSpellAbility(true).getRootAbility(); | |
| if (stC.isValid(cost.getType().split(";"), ability.getActivatingPlayer(), source) && stSA.isSpell()) { | |
| @@ -383,8 +384,8 @@ | |
| if (saList.size() < c) { | |
| return null; | |
| } | |
| - | |
| + | |
| - List<SpellAbility> exiled = new ArrayList<SpellAbility>(); | |
| + final List<SpellAbility> exiled = new ArrayList<SpellAbility>(); | |
| for (int i = 0; i < c; i++) { | |
| //Have to use the stack descriptions here because some copied spells have no description otherwise | |
| final String o = controller.getGui().oneOrNone("Exile from Stack", descList); | |
| @@ -394,7 +395,7 @@ | |
| saList.remove(toExile); | |
| descList.remove(o); | |
| - | |
| + | |
| exiled.add(toExile); | |
| } else { | |
| return null; | |
| @@ -413,15 +414,15 @@ | |
| } | |
| return PaymentDecision.card(list); | |
| } | |
| - | |
| + | |
| - private Card getCard(CardView cardView) { | |
| + private Card getCard(final CardView cardView) { | |
| return controller.getGame().getCard(cardView); | |
| } | |
| - private PaymentDecision exileFromMiscZone(CostExile cost, SpellAbility sa, int nNeeded, CardCollection typeList) { | |
| + private PaymentDecision exileFromMiscZone(final CostExile cost, final SpellAbility sa, final int nNeeded, final CardCollection typeList) { | |
| if (typeList.size() < nNeeded) { return null; } | |
| - CardCollection exiled = new CardCollection(); | |
| + final CardCollection exiled = new CardCollection(); | |
| for (int i = 0; i < nNeeded; i++) { | |
| final Card c = getCard(controller.getGui().oneOrNone("Exile from " + cost.getFrom(), CardView.getCollection(typeList))); | |
| if (c == null) { return null; } | |
| @@ -432,22 +433,22 @@ | |
| return PaymentDecision.card(exiled); | |
| } | |
| - private PaymentDecision exileFromTopGraveType(SpellAbility sa, int nNeeded, CardCollection typeList) { | |
| + private PaymentDecision exileFromTopGraveType(final SpellAbility sa, final int nNeeded, final CardCollection typeList) { | |
| if (typeList.size() < nNeeded) { return null; } | |
| Collections.reverse(typeList); | |
| return PaymentDecision.card(Iterables.limit(typeList, nNeeded)); | |
| - } | |
| + } | |
| @Override | |
| - public PaymentDecision visit(CostExiledMoveToGrave cost) { | |
| + public PaymentDecision visit(final CostExiledMoveToGrave cost) { | |
| Integer c = cost.convertAmount(); | |
| if (c == null) { | |
| c = AbilityUtils.calculateAmount(source, cost.getAmount(), ability); | |
| } | |
| final Player activator = ability.getActivatingPlayer(); | |
| - CardCollection list = CardLists.getValidCards(activator.getGame().getCardsIn(ZoneType.Exile), cost.getType().split(";"), activator, source); | |
| + final CardCollection list = CardLists.getValidCards(activator.getGame().getCardsIn(ZoneType.Exile), cost.getType().split(";"), activator, source); | |
| if (list.size() < c) { | |
| return null; | |
| @@ -457,7 +458,7 @@ | |
| } | |
| @Override | |
| - public PaymentDecision visit(CostFlipCoin cost) { | |
| + public PaymentDecision visit(final CostFlipCoin cost) { | |
| final String amount = cost.getAmount(); | |
| Integer c = cost.convertAmount(); | |
| @@ -474,7 +475,7 @@ | |
| } | |
| @Override | |
| - public PaymentDecision visit(CostGainControl cost) { | |
| + public PaymentDecision visit(final CostGainControl cost) { | |
| final String amount = cost.getAmount(); | |
| Integer c = cost.convertAmount(); | |
| @@ -482,9 +483,9 @@ | |
| c = AbilityUtils.calculateAmount(source, amount, ability); | |
| } | |
| final CardCollectionView list = player.getCardsIn(ZoneType.Battlefield); | |
| - CardCollectionView validCards = CardLists.getValidCards(list, cost.getType().split(";"), player, source); | |
| + final CardCollectionView validCards = CardLists.getValidCards(list, cost.getType().split(";"), player, source); | |
| - InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, c, validCards); | |
| + final InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, c, validCards); | |
| final String desc = cost.getTypeDescription() == null ? cost.getType() : cost.getTypeDescription(); | |
| inp.setMessage("Gain control of %d " + desc); | |
| inp.showAndWait(); | |
| @@ -495,7 +496,7 @@ | |
| } | |
| @Override | |
| - public PaymentDecision visit(CostGainLife cost) { | |
| + public PaymentDecision visit(final CostGainLife cost) { | |
| final String amount = cost.getAmount(); | |
| final int life = player.getLife(); | |
| @@ -518,8 +519,9 @@ | |
| } | |
| } | |
| - if (cost.getCntPlayers() == Integer.MAX_VALUE) // applied to all players who can gain | |
| + if (cost.getCntPlayers() == Integer.MAX_VALUE) { | |
| return PaymentDecision.players(oppsThatCanGainLife); | |
| + } | |
| final StringBuilder sb = new StringBuilder(); | |
| sb.append(source.getName()).append(" - Choose an opponent to gain ").append(c).append(" life:"); | |
| @@ -532,7 +534,7 @@ | |
| } | |
| @Override | |
| - public PaymentDecision visit(CostMill cost) { | |
| + public PaymentDecision visit(final CostMill cost) { | |
| final String amount = cost.getAmount(); | |
| Integer c = cost.convertAmount(); | |
| @@ -546,14 +548,14 @@ | |
| } | |
| } | |
| - if (!player.getController().confirmPayment(cost, "Mill " + c + " card" + (c == 1 ? "" : "s") + " from your library?")) { | |
| + if (!player.getController().confirmPayment(cost, String.format("Mill %d card%s from your library?", c, c == 1 ? "" : "s"))) { | |
| return null; | |
| } | |
| return PaymentDecision.card(player.getCardsIn(ZoneType.Library, c)); | |
| } | |
| @Override | |
| - public PaymentDecision visit(CostPayLife cost) { | |
| + public PaymentDecision visit(final CostPayLife cost) { | |
| final String amount = cost.getAmount(); | |
| final int life = player.getLife(); | |
| @@ -566,7 +568,7 @@ | |
| if (sVar.contains("LimitMax")) { | |
| limit = AbilityUtils.calculateAmount(source, sVar.split("LimitMax.")[1], ability); | |
| } | |
| - int maxLifePayment = limit < life ? limit : life; | |
| + final int maxLifePayment = limit < life ? limit : life; | |
| c = chooseXValue(maxLifePayment); | |
| } else { | |
| c = AbilityUtils.calculateAmount(source, amount, ability); | |
| @@ -580,13 +582,13 @@ | |
| } | |
| @Override | |
| - public PaymentDecision visit(CostPartMana cost) { | |
| + public PaymentDecision visit(final CostPartMana cost) { | |
| // only interactive payment possible for now =( | |
| return new PaymentDecision(0); | |
| } | |
| @Override | |
| - public PaymentDecision visit(CostPutCardToLib cost) { | |
| + public PaymentDecision visit(final CostPutCardToLib cost) { | |
| final String amount = cost.getAmount(); | |
| Integer c = cost.convertAmount(); | |
| @@ -600,21 +602,21 @@ | |
| } | |
| } | |
| - CardCollection list = CardLists.getValidCards(cost.sameZone ? player.getGame().getCardsIn(cost.getFrom()) : player.getCardsIn(cost.getFrom()), cost.getType().split(";"), player, source); | |
| + final CardCollection list = CardLists.getValidCards(cost.sameZone ? player.getGame().getCardsIn(cost.getFrom()) : player.getCardsIn(cost.getFrom()), cost.getType().split(";"), player, source); | |
| if (cost.from == ZoneType.Hand) { | |
| - InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, c, c, list); | |
| + final InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, c, c, list); | |
| inp.setMessage("Put %d card(s) from your " + cost.from); | |
| inp.setCancelAllowed(true); | |
| inp.showAndWait(); | |
| return inp.hasCancelled() ? null : PaymentDecision.card(inp.getSelected()); | |
| } | |
| - | |
| + | |
| if (cost.sameZone){ | |
| - FCollectionView<Player> players = player.getGame().getPlayers(); | |
| - List<Player> payableZone = new ArrayList<Player>(); | |
| - for (Player p : players) { | |
| - CardCollectionView enoughType = CardLists.filter(list, CardPredicates.isOwner(p)); | |
| + final FCollectionView<Player> players = player.getGame().getPlayers(); | |
| + final List<Player> payableZone = new ArrayList<Player>(); | |
| + for (final Player p : players) { | |
| + final CardCollectionView enoughType = CardLists.filter(list, CardPredicates.isOwner(p)); | |
| if (enoughType.size() < c) { | |
| list.removeAll(enoughType); | |
| } else { | |
| @@ -627,12 +629,12 @@ | |
| } | |
| } | |
| - private PaymentDecision putFromMiscZone(SpellAbility sa, int nNeeded, CardCollection typeList, ZoneType fromZone) { | |
| + private PaymentDecision putFromMiscZone(final SpellAbility sa, final int nNeeded, final CardCollection typeList, final ZoneType fromZone) { | |
| if (typeList.size() < nNeeded) { | |
| return null; | |
| } | |
| - CardCollection chosen = new CardCollection(); | |
| + final CardCollection chosen = new CardCollection(); | |
| for (int i = 0; i < nNeeded; i++) { | |
| final Card c = getCard(controller.getGui().oneOrNone("Put from " + fromZone + " to library", CardView.getCollection(typeList))); | |
| if (c == null) { | |
| @@ -644,7 +646,7 @@ | |
| return PaymentDecision.card(chosen); | |
| } | |
| - private PaymentDecision putFromSame(CardCollectionView list, int nNeeded, List<Player> payableZone, ZoneType fromZone) { | |
| + private PaymentDecision putFromSame(final CardCollectionView list, final int nNeeded, final List<Player> payableZone, final ZoneType fromZone) { | |
| if (nNeeded == 0) { | |
| return PaymentDecision.number(0); | |
| } | |
| @@ -653,13 +655,13 @@ | |
| if (p == null) { | |
| return null; | |
| } | |
| - | |
| + | |
| - CardCollection typeList = CardLists.filter(list, CardPredicates.isOwner(p)); | |
| + final CardCollection typeList = CardLists.filter(list, CardPredicates.isOwner(p)); | |
| if (typeList.size() < nNeeded) { | |
| return null; | |
| } | |
| - CardCollection chosen = new CardCollection(); | |
| + final CardCollection chosen = new CardCollection(); | |
| for (int i = 0; i < nNeeded; i++) { | |
| final Card c = getCard(controller.getGui().oneOrNone("Put cards from " + fromZone + " to Library", CardView.getCollection(typeList))); | |
| if (c == null) { | |
| @@ -670,20 +672,20 @@ | |
| } | |
| return PaymentDecision.card(chosen); | |
| } | |
| - | |
| + | |
| @Override | |
| - public PaymentDecision visit(CostPutCounter cost) { | |
| - Integer c = cost.getNumberOfCounters(ability); | |
| + public PaymentDecision visit(final CostPutCounter cost) { | |
| + final Integer c = cost.getNumberOfCounters(ability); | |
| if (cost.payCostFromSource()) { | |
| cost.setLastPaidAmount(c); | |
| return PaymentDecision.number(c); | |
| - } | |
| + } | |
| - // Cards to use this branch: Scarscale Ritual, Wandering Mage - each adds only one counter | |
| + // Cards to use this branch: Scarscale Ritual, Wandering Mage - each adds only one counter | |
| - CardCollectionView typeList = CardLists.getValidCards(player.getCardsIn(ZoneType.Battlefield), cost.getType().split(";"), player, ability.getHostCard()); | |
| + final CardCollectionView typeList = CardLists.getValidCards(player.getCardsIn(ZoneType.Battlefield), cost.getType().split(";"), player, ability.getHostCard()); | |
| - | |
| + | |
| - InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, 1, 1, typeList); | |
| + final InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, 1, 1, typeList); | |
| inp.setMessage("Put " + Lang.nounWithAmount(c, cost.getCounter().getName() + " counter") + " on " + cost.getDescriptiveType()); | |
| inp.setCancelAllowed(true); | |
| inp.showAndWait(); | |
| @@ -695,7 +697,7 @@ | |
| } | |
| @Override | |
| - public PaymentDecision visit(CostReturn cost) { | |
| + public PaymentDecision visit(final CostReturn cost) { | |
| final String amount = cost.getAmount(); | |
| Integer c = cost.convertAmount(); | |
| @@ -717,9 +719,9 @@ | |
| } | |
| } | |
| else { | |
| - CardCollectionView validCards = CardLists.getValidCards(ability.getActivatingPlayer().getCardsIn(ZoneType.Battlefield), cost.getType().split(";"), ability.getActivatingPlayer(), ability.getHostCard()); | |
| + final CardCollectionView validCards = CardLists.getValidCards(ability.getActivatingPlayer().getCardsIn(ZoneType.Battlefield), cost.getType().split(";"), ability.getActivatingPlayer(), ability.getHostCard()); | |
| - InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, c, c, validCards); | |
| + final InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, c, c, validCards); | |
| inp.setCancelAllowed(true); | |
| inp.setMessage("Return %d " + cost.getType() + " " + cost.getType() + " card(s) to hand"); | |
| inp.showAndWait(); | |
| @@ -727,12 +729,12 @@ | |
| return null; | |
| } | |
| return PaymentDecision.card(inp.getSelected()); | |
| - } | |
| - return null; | |
| + } | |
| + return null; | |
| } | |
| @Override | |
| - public PaymentDecision visit(CostReveal cost) { | |
| + public PaymentDecision visit(final CostReveal cost) { | |
| final String amount = cost.getAmount(); | |
| if (cost.payCostFromSource()) { | |
| @@ -743,13 +745,13 @@ | |
| } | |
| InputSelectCardsFromList inp = null; | |
| if (cost.getType().equals("SameColor")) { | |
| - Integer num = cost.convertAmount(); | |
| + final Integer num = cost.convertAmount(); | |
| CardCollectionView hand = player.getCardsIn(ZoneType.Hand); | |
| final CardCollectionView hand2 = hand; | |
| hand = CardLists.filter(hand, new Predicate<Card>() { | |
| @Override | |
| public boolean apply(final Card c) { | |
| - for (Card card : hand2) { | |
| + for (final Card card : hand2) { | |
| if (!card.equals(c) && card.sharesColorWith(c)) { | |
| return true; | |
| } | |
| @@ -764,8 +766,8 @@ | |
| private static final long serialVersionUID = 8338626212893374798L; | |
| @Override | |
| - protected boolean onCardSelected(Card c, final List<Card> otherCardsToSelect, ITriggerEvent triggerEvent) { | |
| - Card firstCard = Iterables.getFirst(this.selected, null); | |
| + protected boolean onCardSelected(final Card c, final List<Card> otherCardsToSelect, final ITriggerEvent triggerEvent) { | |
| + final Card firstCard = Iterables.getFirst(this.selected, null); | |
| if (firstCard != null && !CardPredicates.sharesColorWith(firstCard).apply(c)) { | |
| return false; | |
| } | |
| @@ -788,9 +790,10 @@ | |
| num = AbilityUtils.calculateAmount(source, amount, ability); | |
| } | |
| } | |
| - if (num == 0) | |
| - return PaymentDecision.number(0);; | |
| + if (num == 0) { | |
| + return PaymentDecision.number(0); | |
| + }; | |
| - | |
| + | |
| inp = new InputSelectCardsFromList(controller, num, num, hand); | |
| inp.setMessage("Select %d more " + cost.getDescriptiveType() + " card(s) to reveal."); | |
| } | |
| @@ -803,7 +806,7 @@ | |
| } | |
| @Override | |
| - public PaymentDecision visit(CostRemoveAnyCounter cost) { | |
| + public PaymentDecision visit(final CostRemoveAnyCounter cost) { | |
| Integer c = cost.convertAmount(); | |
| final String type = cost.getType(); | |
| @@ -821,22 +824,22 @@ | |
| return card.hasCounters(); | |
| } | |
| }); | |
| - InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, 1, 1, list); | |
| + final InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, 1, 1, list); | |
| inp.setMessage("Select " + cost.getDescriptiveType() + " to remove a counter"); | |
| inp.setCancelAllowed(false); | |
| inp.showAndWait(); | |
| - Card selected = inp.getFirstSelected(); | |
| + final Card selected = inp.getFirstSelected(); | |
| final Map<CounterType, Integer> tgtCounters = selected.getCounters(); | |
| - final ArrayList<CounterType> typeChoices = new ArrayList<CounterType>(); | |
| - for (CounterType key : tgtCounters.keySet()) { | |
| + final List<CounterType> typeChoices = new ArrayList<CounterType>(); | |
| + for (final CounterType key : tgtCounters.keySet()) { | |
| if (tgtCounters.get(key) > 0) { | |
| typeChoices.add(key); | |
| } | |
| } | |
| - String prompt = "Select type counters to remove"; | |
| + final String prompt = "Select type counters to remove"; | |
| cost.setCounterType(controller.getGui().one(prompt, typeChoices)); | |
| - | |
| + | |
| return PaymentDecision.card(selected, cost.getCounter()); | |
| } | |
| @@ -847,20 +850,20 @@ | |
| private final CounterType counterType; | |
| private final CardCollectionView validChoices; | |
| - public InputSelectCardToRemoveCounter(final PlayerControllerHuman controller, int cntCounters, CounterType cType, CardCollectionView validCards) { | |
| + public InputSelectCardToRemoveCounter(final PlayerControllerHuman controller, final int cntCounters, final CounterType cType, final CardCollectionView validCards) { | |
| super(controller, cntCounters, cntCounters); | |
| this.validChoices = validCards; | |
| counterType = cType; | |
| - cardsChosen = cntCounters > 0 ? new HashMap<Card, Integer>() : null; | |
| + cardsChosen = cntCounters > 0 ? new HashMap<Card, Integer>() : null; | |
| } | |
| @Override | |
| - protected boolean onCardSelected(Card c, final List<Card> otherCardsToSelect, ITriggerEvent triggerEvent) { | |
| + protected boolean onCardSelected(final Card c, final List<Card> otherCardsToSelect, final ITriggerEvent triggerEvent) { | |
| if (!isValidChoice(c) || c.getCounters(counterType) <= getTimesSelected(c)) { | |
| return false; | |
| } | |
| - int tc = getTimesSelected(c); | |
| + final int tc = getTimesSelected(c); | |
| cardsChosen.put(c, tc + 1); | |
| onSelectStateChanged(c, true); | |
| @@ -869,7 +872,7 @@ | |
| } | |
| @Override | |
| - public String getActivateAction(Card c) { | |
| + public String getActivateAction(final Card c) { | |
| if (!isValidChoice(c) || c.getCounters(counterType) <= getTimesSelected(c)) { | |
| return null; | |
| } | |
| @@ -883,29 +886,30 @@ | |
| @Override | |
| protected boolean hasAllTargets() { | |
| - int sum = getDistibutedCounters(); | |
| + final int sum = getDistibutedCounters(); | |
| return sum >= max; | |
| } | |
| + @Override | |
| protected String getMessage() { | |
| return max == Integer.MAX_VALUE | |
| - ? String.format(message, getDistibutedCounters()) | |
| - : String.format(message, max - getDistibutedCounters()); | |
| + ? String.format(message, getDistibutedCounters()) | |
| + : String.format(message, max - getDistibutedCounters()); | |
| } | |
| private int getDistibutedCounters() { | |
| int sum = 0; | |
| - for (Entry<Card, Integer> kv : cardsChosen.entrySet()) { | |
| + for (final Entry<Card, Integer> kv : cardsChosen.entrySet()) { | |
| sum += kv.getValue().intValue(); | |
| } | |
| return sum; | |
| } | |
| - | |
| + | |
| - protected final boolean isValidChoice(GameEntity choice) { | |
| + protected final boolean isValidChoice(final GameEntity choice) { | |
| return validChoices.contains(choice); | |
| } | |
| - public int getTimesSelected(Card c) { | |
| + public int getTimesSelected(final Card c) { | |
| return cardsChosen.containsKey(c) ? cardsChosen.get(c).intValue() : 0; | |
| } | |
| @@ -914,23 +918,23 @@ | |
| return cardsChosen.keySet(); | |
| } | |
| } | |
| - | |
| + | |
| @Override | |
| - public PaymentDecision visit(CostRemoveCounter cost) { | |
| + public PaymentDecision visit(final CostRemoveCounter cost) { | |
| final String amount = cost.getAmount(); | |
| - Integer c = cost.convertAmount(); | |
| + final Integer c = cost.convertAmount(); | |
| final String type = cost.getType(); | |
| - String sVarAmount = ability.getSVar(amount); | |
| + final String sVarAmount = ability.getSVar(amount); | |
| int cntRemoved = 1; | |
| - if (c != null) | |
| + if (c != null) { | |
| cntRemoved = c.intValue(); | |
| - else if (!"XChoice".equals(sVarAmount)) { | |
| + } else if (!"XChoice".equals(sVarAmount)) { | |
| cntRemoved = AbilityUtils.calculateAmount(source, amount, ability); | |
| } | |
| if (cost.payCostFromSource()) { | |
| - int maxCounters = source.getCounters(cost.counter); | |
| + final int maxCounters = source.getCounters(cost.counter); | |
| if (amount.equals("All")) { | |
| final CardView view = CardView.get(ability.getHostCard()); | |
| if (!controller.getGui().confirm(view, "Remove all counters?")) { | |
| @@ -938,26 +942,28 @@ | |
| } | |
| cntRemoved = maxCounters; | |
| } | |
| - else if (c == null && "XChoice".equals(sVarAmount)) { | |
| + else if (c == null && "XChoice".equals(sVarAmount)) { | |
| cntRemoved = chooseXValue(maxCounters); | |
| } | |
| - if (maxCounters < cntRemoved) | |
| + if (maxCounters < cntRemoved) { | |
| return null; | |
| + } | |
| return PaymentDecision.card(source, cntRemoved >= 0 ? cntRemoved : maxCounters); | |
| - | |
| + | |
| } else if (type.equals("OriginalHost")) { | |
| - int maxCounters = ability.getOriginalHost().getCounters(cost.counter); | |
| + final int maxCounters = ability.getOriginalHost().getCounters(cost.counter); | |
| if (amount.equals("All")) { | |
| cntRemoved = maxCounters; | |
| } | |
| - if (maxCounters < cntRemoved) | |
| + if (maxCounters < cntRemoved) { | |
| return null; | |
| + } | |
| return PaymentDecision.card(ability.getOriginalHost(), cntRemoved >= 0 ? cntRemoved : maxCounters); | |
| } | |
| - CardCollectionView validCards = CardLists.getValidCards(player.getCardsIn(cost.zone), type.split(";"), player, source); | |
| + final CardCollectionView validCards = CardLists.getValidCards(player.getCardsIn(cost.zone), type.split(";"), player, source); | |
| if (cost.zone.equals(ZoneType.Battlefield)) { | |
| final InputSelectCardToRemoveCounter inp = new InputSelectCardToRemoveCounter(controller, cntRemoved, cost.counter, validCards); | |
| inp.setMessage("Remove %d " + cost.counter.getName() + " counters from " + cost.getDescriptiveType()); | |
| @@ -971,18 +977,20 @@ | |
| // triggers will fire when last is removed by executePayment. | |
| // They don't care how many were removed anyway | |
| // int sum = 0; | |
| - for (Card crd : inp.getSelected()) { | |
| - int removed = inp.getTimesSelected(crd); | |
| + for (final Card crd : inp.getSelected()) { | |
| + final int removed = inp.getTimesSelected(crd); | |
| - // sum += removed; | |
| + // sum += removed; | |
| - if (removed < 2) continue; | |
| - int oldVal = crd.getCounters().get(cost.counter).intValue(); | |
| + if (removed < 2) { | |
| + continue; | |
| + } | |
| + final int oldVal = crd.getCounters().get(cost.counter).intValue(); | |
| crd.getCounters().put(cost.counter, Integer.valueOf(oldVal - removed + 1)); | |
| } | |
| return PaymentDecision.card(inp.getSelected(), 1); | |
| - } | |
| + } | |
| // Rift Elemental only - always removes 1 counter, so there will be no code for N counters. | |
| - List<CardView> suspended = Lists.newArrayList(); | |
| + final List<CardView> suspended = Lists.newArrayList(); | |
| for (final Card crd : validCards) { | |
| if (crd.getCounters(cost.counter) > 0) { | |
| suspended.add(CardView.get(crd)); | |
| @@ -994,7 +1002,7 @@ | |
| } | |
| @Override | |
| - public PaymentDecision visit(CostSacrifice cost) { | |
| + public PaymentDecision visit(final CostSacrifice cost) { | |
| final String amount = cost.getAmount(); | |
| final String type = cost.getType(); | |
| @@ -1015,7 +1023,7 @@ | |
| if (amount.equals("All")) { | |
| return PaymentDecision.card(list); | |
| - } | |
| + } | |
| Integer c = cost.convertAmount(); | |
| if (c == null) { | |
| @@ -1032,19 +1040,20 @@ | |
| if (list.size() < c) { | |
| return null; | |
| } | |
| - InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, c, c, list); | |
| + final InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, c, c, list); | |
| inp.setMessage("Select a " + cost.getDescriptiveType() + " to sacrifice (%d left)"); | |
| inp.setCancelAllowed(true); | |
| inp.showAndWait(); | |
| - if (inp.hasCancelled()) | |
| + if (inp.hasCancelled()) { | |
| return null; | |
| + } | |
| return PaymentDecision.card(inp.getSelected()); | |
| } | |
| @Override | |
| - public PaymentDecision visit(CostTap cost) { | |
| + public PaymentDecision visit(final CostTap cost) { | |
| // if (!canPay(ability, source, ability.getActivatingPlayer(), | |
| // payment.getCost())) | |
| // return false; | |
| @@ -1052,7 +1061,7 @@ | |
| } | |
| @Override | |
| - public PaymentDecision visit(CostTapType cost) { | |
| + public PaymentDecision visit(final CostTapType cost) { | |
| String type = cost.getType(); | |
| final String amount = cost.getAmount(); | |
| Integer c = cost.convertAmount(); | |
| @@ -1088,7 +1097,7 @@ | |
| typeList = CardLists.filter(typeList, new Predicate<Card>() { | |
| @Override | |
| public boolean apply(final Card c) { | |
| - for (Card card : list2) { | |
| + for (final Card card : list2) { | |
| if (!card.equals(c) && card.sharesCreatureTypeWith(c)) { | |
| return true; | |
| } | |
| @@ -1096,10 +1105,12 @@ | |
| return false; | |
| } | |
| }); | |
| - if (c == 0) return PaymentDecision.number(0); | |
| - CardCollection tapped = new CardCollection(); | |
| + if (c == 0) { | |
| + return PaymentDecision.number(0); | |
| + } | |
| + final CardCollection tapped = new CardCollection(); | |
| while (c > 0) { | |
| - InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, 1, 1, typeList); | |
| + final InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, 1, 1, typeList); | |
| inp.setMessage("Select one of the cards to tap. Already chosen: " + tapped); | |
| inp.setCancelAllowed(true); | |
| inp.showAndWait(); | |
| @@ -1118,11 +1129,11 @@ | |
| c--; | |
| } | |
| return PaymentDecision.card(tapped); | |
| - } | |
| + } | |
| if (totalPower) { | |
| - int i = Integer.parseInt(totalP); | |
| - InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, 0, typeList.size(), typeList); | |
| + final int i = Integer.parseInt(totalP); | |
| + final InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, 0, typeList.size(), typeList); | |
| inp.setMessage("Select a card to tap."); | |
| inp.setCancelAllowed(true); | |
| inp.showAndWait(); | |
| @@ -1133,7 +1144,7 @@ | |
| return PaymentDecision.card(inp.getSelected()); | |
| } | |
| - InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, c, c, typeList); | |
| + final InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, c, c, typeList); | |
| inp.setCancelAllowed(true); | |
| inp.setMessage("Select a " + cost.getDescriptiveType() + " to tap (%d left)"); | |
| inp.showAndWait(); | |
| @@ -1144,7 +1155,7 @@ | |
| } | |
| @Override | |
| - public PaymentDecision visit(CostUntapType cost) { | |
| + public PaymentDecision visit(final CostUntapType cost) { | |
| CardCollection typeList = CardLists.getValidCards(player.getGame().getCardsIn(ZoneType.Battlefield), cost.getType().split(";"), | |
| player, ability.getHostCard()); | |
| typeList = CardLists.filter(typeList, Presets.TAPPED); | |
| @@ -1162,7 +1173,7 @@ | |
| c = AbilityUtils.calculateAmount(source, amount, ability); | |
| } | |
| } | |
| - InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, c, c, typeList); | |
| + final InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, c, c, typeList); | |
| inp.setCancelAllowed(true); | |
| inp.setMessage("Select a " + cost.getDescriptiveType() + " to untap (%d left)"); | |
| inp.showAndWait(); | |
| @@ -1173,15 +1184,15 @@ | |
| } | |
| @Override | |
| - public PaymentDecision visit(CostUntap cost) { | |
| + public PaymentDecision visit(final CostUntap cost) { | |
| return PaymentDecision.number(1); | |
| } | |
| @Override | |
| - public PaymentDecision visit(CostUnattach cost) { | |
| + public PaymentDecision visit(final CostUnattach cost) { | |
| final Card source = ability.getHostCard(); | |
| - | |
| + | |
| - Card cardToUnattach = cost.findCardToUnattach(source, player, ability); | |
| + final Card cardToUnattach = cost.findCardToUnattach(source, player, ability); | |
| if (cardToUnattach != null && player.getController().confirmPayment(cost, "Unattach " + cardToUnattach.getName() + "?")) { | |
| return PaymentDecision.card(cardToUnattach); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment