mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
Start FComboBox
This commit is contained in:
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -15017,6 +15017,7 @@ src/main/java/forge/gui/toolbox/CardFaceSymbols.java svneol=native#text/plain
|
|||||||
src/main/java/forge/gui/toolbox/FAbsolutePositioner.java -text
|
src/main/java/forge/gui/toolbox/FAbsolutePositioner.java -text
|
||||||
src/main/java/forge/gui/toolbox/FButton.java -text
|
src/main/java/forge/gui/toolbox/FButton.java -text
|
||||||
src/main/java/forge/gui/toolbox/FCheckBox.java -text
|
src/main/java/forge/gui/toolbox/FCheckBox.java -text
|
||||||
|
src/main/java/forge/gui/toolbox/FComboBox.java -text
|
||||||
src/main/java/forge/gui/toolbox/FComboBoxPanel.java -text
|
src/main/java/forge/gui/toolbox/FComboBoxPanel.java -text
|
||||||
src/main/java/forge/gui/toolbox/FLabel.java -text
|
src/main/java/forge/gui/toolbox/FLabel.java -text
|
||||||
src/main/java/forge/gui/toolbox/FList.java -text
|
src/main/java/forge/gui/toolbox/FList.java -text
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ import java.util.Set;
|
|||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
import java.util.concurrent.ConcurrentSkipListMap;
|
import java.util.concurrent.ConcurrentSkipListMap;
|
||||||
|
|
||||||
import javax.swing.JComboBox;
|
|
||||||
import javax.swing.JFileChooser;
|
import javax.swing.JFileChooser;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
@@ -61,6 +60,7 @@ import forge.error.BugReporter;
|
|||||||
import forge.gui.ImportSourceAnalyzer.OpType;
|
import forge.gui.ImportSourceAnalyzer.OpType;
|
||||||
import forge.gui.toolbox.FButton;
|
import forge.gui.toolbox.FButton;
|
||||||
import forge.gui.toolbox.FCheckBox;
|
import forge.gui.toolbox.FCheckBox;
|
||||||
|
import forge.gui.toolbox.FComboBox;
|
||||||
import forge.gui.toolbox.FLabel;
|
import forge.gui.toolbox.FLabel;
|
||||||
import forge.gui.toolbox.FOverlay;
|
import forge.gui.toolbox.FOverlay;
|
||||||
import forge.gui.toolbox.FPanel;
|
import forge.gui.toolbox.FPanel;
|
||||||
@@ -307,7 +307,7 @@ public class ImportDialog {
|
|||||||
private final Runnable _onAnalyzerDone;
|
private final Runnable _onAnalyzerDone;
|
||||||
private final boolean _isMigration;
|
private final boolean _isMigration;
|
||||||
private final FLabel _unknownDeckLabel;
|
private final FLabel _unknownDeckLabel;
|
||||||
private final JComboBox<_UnknownDeckChoice> _unknownDeckCombo;
|
private final FComboBox<_UnknownDeckChoice> _unknownDeckCombo;
|
||||||
private final FCheckBox _moveCheckbox;
|
private final FCheckBox _moveCheckbox;
|
||||||
private final FCheckBox _overwriteCheckbox;
|
private final FCheckBox _overwriteCheckbox;
|
||||||
private final JTextArea _operationLog;
|
private final JTextArea _operationLog;
|
||||||
@@ -340,7 +340,7 @@ public class ImportDialog {
|
|||||||
_addSelectionWidget(knownDeckPanel, OpType.UNKNOWN_DECK, "Unknown decks");
|
_addSelectionWidget(knownDeckPanel, OpType.UNKNOWN_DECK, "Unknown decks");
|
||||||
JPanel unknownDeckPanel = new JPanel(new MigLayout("insets 0, gap 5"));
|
JPanel unknownDeckPanel = new JPanel(new MigLayout("insets 0, gap 5"));
|
||||||
unknownDeckPanel.setOpaque(false);
|
unknownDeckPanel.setOpaque(false);
|
||||||
_unknownDeckCombo = new JComboBox<_UnknownDeckChoice>();
|
_unknownDeckCombo = new FComboBox<_UnknownDeckChoice>();
|
||||||
_unknownDeckCombo.addItem(new _UnknownDeckChoice("Constructed", NewConstants.DECK_CONSTRUCTED_DIR));
|
_unknownDeckCombo.addItem(new _UnknownDeckChoice("Constructed", NewConstants.DECK_CONSTRUCTED_DIR));
|
||||||
_unknownDeckCombo.addItem(new _UnknownDeckChoice("Draft", NewConstants.DECK_DRAFT_DIR));
|
_unknownDeckCombo.addItem(new _UnknownDeckChoice("Draft", NewConstants.DECK_DRAFT_DIR));
|
||||||
_unknownDeckCombo.addItem(new _UnknownDeckChoice("Planar", NewConstants.DECK_PLANE_DIR));
|
_unknownDeckCombo.addItem(new _UnknownDeckChoice("Planar", NewConstants.DECK_PLANE_DIR));
|
||||||
@@ -816,7 +816,7 @@ public class ImportDialog {
|
|||||||
private final boolean _move;
|
private final boolean _move;
|
||||||
private final boolean _overwrite;
|
private final boolean _overwrite;
|
||||||
|
|
||||||
public _Importer(String srcDir, Map<OpType, Pair<FCheckBox, ? extends Map<File, File>>> selections, JComboBox<_UnknownDeckChoice> unknownDeckCombo,
|
public _Importer(String srcDir, Map<OpType, Pair<FCheckBox, ? extends Map<File, File>>> selections, FComboBox<_UnknownDeckChoice> unknownDeckCombo,
|
||||||
JTextArea operationLog, JProgressBar progressBar, boolean move, boolean overwrite) {
|
JTextArea operationLog, JProgressBar progressBar, boolean move, boolean overwrite) {
|
||||||
_srcDir = srcDir;
|
_srcDir = srcDir;
|
||||||
_operationLog = operationLog;
|
_operationLog = operationLog;
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ import java.awt.FlowLayout;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.swing.JComboBox;
|
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JSpinner;
|
import javax.swing.JSpinner;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
@@ -23,6 +23,7 @@ import forge.gui.framework.DragCell;
|
|||||||
import forge.gui.framework.DragTab;
|
import forge.gui.framework.DragTab;
|
||||||
import forge.gui.framework.EDocID;
|
import forge.gui.framework.EDocID;
|
||||||
import forge.gui.framework.IVDoc;
|
import forge.gui.framework.IVDoc;
|
||||||
|
import forge.gui.toolbox.FComboBox;
|
||||||
import forge.gui.toolbox.FLabel;
|
import forge.gui.toolbox.FLabel;
|
||||||
import forge.gui.toolbox.FSkin;
|
import forge.gui.toolbox.FSkin;
|
||||||
import forge.gui.toolbox.FSpinner;
|
import forge.gui.toolbox.FSpinner;
|
||||||
@@ -81,7 +82,7 @@ public enum VCardCatalog implements IVDoc<CCardCatalog> {
|
|||||||
.text("Add filter")
|
.text("Add filter")
|
||||||
.tooltip("Click to add custom filters to the card list")
|
.tooltip("Click to add custom filters to the card list")
|
||||||
.reactOnMouseDown().build();
|
.reactOnMouseDown().build();
|
||||||
private final JComboBox<String> cbSearchMode = new JComboBox<String>();
|
private final FComboBox<String> cbSearchMode = new FComboBox<String>();
|
||||||
private final JTextField txfSearch = new FTextField.Builder().ghostText("Search").build();
|
private final JTextField txfSearch = new FTextField.Builder().ghostText("Search").build();
|
||||||
private final FLabel lblName = new FLabel.Builder().text("Name").hoverable().selectable().selected().build();
|
private final FLabel lblName = new FLabel.Builder().text("Name").hoverable().selectable().selected().build();
|
||||||
private final FLabel lblType = new FLabel.Builder().text("Type").hoverable().selectable().selected().build();
|
private final FLabel lblType = new FLabel.Builder().text("Type").hoverable().selectable().selected().build();
|
||||||
@@ -226,7 +227,7 @@ public enum VCardCatalog implements IVDoc<CCardCatalog> {
|
|||||||
public FLabel getLblText() { return lblText; }
|
public FLabel getLblText() { return lblText; }
|
||||||
|
|
||||||
public FLabel getBtnAddRestriction() { return btnAddRestriction; }
|
public FLabel getBtnAddRestriction() { return btnAddRestriction; }
|
||||||
public JComboBox<String> getCbSearchMode() { return cbSearchMode; }
|
public FComboBox<String> getCbSearchMode() { return cbSearchMode; }
|
||||||
public JTextField getTxfSearch() { return txfSearch; }
|
public JTextField getTxfSearch() { return txfSearch; }
|
||||||
|
|
||||||
public Map<SItemManagerUtil.StatTypes, FLabel> getStatLabels() {
|
public Map<SItemManagerUtil.StatTypes, FLabel> getStatLabels() {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package forge.gui.home.quest;
|
package forge.gui.home.quest;
|
||||||
|
|
||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
import javax.swing.JComboBox;
|
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
|
|
||||||
|
import forge.gui.toolbox.FComboBox;
|
||||||
import forge.gui.toolbox.FLabel;
|
import forge.gui.toolbox.FLabel;
|
||||||
|
|
||||||
/** Dictates methods required for a panel with stats/pet display. */
|
/** Dictates methods required for a panel with stats/pet display. */
|
||||||
@@ -45,8 +45,8 @@ public interface IVQuestStats {
|
|||||||
/** @return {@link javax.swing.JLabel} */
|
/** @return {@link javax.swing.JLabel} */
|
||||||
JLabel getLblWinStreak();
|
JLabel getLblWinStreak();
|
||||||
|
|
||||||
/** @return {@link javax.swing.JComboBox} */
|
/** @return {@link javax.swing.FComboBox} */
|
||||||
JComboBox<String> getCbxPet();
|
FComboBox<String> getCbxPet();
|
||||||
|
|
||||||
/** @return {@link javax.swing.JCheckBox} */
|
/** @return {@link javax.swing.JCheckBox} */
|
||||||
JCheckBox getCbPlant();
|
JCheckBox getCbPlant();
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import java.awt.Font;
|
|||||||
|
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
import javax.swing.JComboBox;
|
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.ScrollPaneConstants;
|
import javax.swing.ScrollPaneConstants;
|
||||||
@@ -20,6 +19,7 @@ import forge.gui.home.LblHeader;
|
|||||||
import forge.gui.home.StartButton;
|
import forge.gui.home.StartButton;
|
||||||
import forge.gui.home.VHomeUI;
|
import forge.gui.home.VHomeUI;
|
||||||
import forge.gui.toolbox.FCheckBox;
|
import forge.gui.toolbox.FCheckBox;
|
||||||
|
import forge.gui.toolbox.FComboBox;
|
||||||
import forge.gui.toolbox.FLabel;
|
import forge.gui.toolbox.FLabel;
|
||||||
import forge.gui.toolbox.FScrollPane;
|
import forge.gui.toolbox.FScrollPane;
|
||||||
import forge.gui.toolbox.FSkin;
|
import forge.gui.toolbox.FSkin;
|
||||||
@@ -46,7 +46,7 @@ public enum VSubmenuChallenges implements IVSubmenu<CSubmenuChallenges>, IVQuest
|
|||||||
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
||||||
|
|
||||||
private final JButton btnStart = new StartButton();
|
private final JButton btnStart = new StartButton();
|
||||||
private final JComboBox<String> cbxPet = new JComboBox<String>();
|
private final FComboBox<String> cbxPet = new FComboBox<String>();
|
||||||
private final JCheckBox cbPlant = new FCheckBox("Summon Plant");
|
private final JCheckBox cbPlant = new FCheckBox("Summon Plant");
|
||||||
private final JLabel lblZep = new FLabel.Builder().text("<html>Launch<br>Zeppelin</html>")
|
private final JLabel lblZep = new FLabel.Builder().text("<html>Launch<br>Zeppelin</html>")
|
||||||
.hoverable(true).icon(FSkin.getIcon(FSkin.QuestIcons.ICO_ZEP))
|
.hoverable(true).icon(FSkin.getIcon(FSkin.QuestIcons.ICO_ZEP))
|
||||||
@@ -248,7 +248,7 @@ public enum VSubmenuChallenges implements IVSubmenu<CSubmenuChallenges>, IVQuest
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JComboBox<String> getCbxPet() {
|
public FComboBox<String> getCbxPet() {
|
||||||
return cbxPet;
|
return cbxPet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import java.awt.Font;
|
|||||||
|
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
import javax.swing.JComboBox;
|
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.ScrollPaneConstants;
|
import javax.swing.ScrollPaneConstants;
|
||||||
@@ -20,6 +19,7 @@ import forge.gui.home.LblHeader;
|
|||||||
import forge.gui.home.StartButton;
|
import forge.gui.home.StartButton;
|
||||||
import forge.gui.home.VHomeUI;
|
import forge.gui.home.VHomeUI;
|
||||||
import forge.gui.toolbox.FCheckBox;
|
import forge.gui.toolbox.FCheckBox;
|
||||||
|
import forge.gui.toolbox.FComboBox;
|
||||||
import forge.gui.toolbox.FLabel;
|
import forge.gui.toolbox.FLabel;
|
||||||
import forge.gui.toolbox.FScrollPane;
|
import forge.gui.toolbox.FScrollPane;
|
||||||
import forge.gui.toolbox.FSkin;
|
import forge.gui.toolbox.FSkin;
|
||||||
@@ -45,7 +45,7 @@ public enum VSubmenuDuels implements IVSubmenu<CSubmenuDuels>, IVQuestStats {
|
|||||||
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
||||||
|
|
||||||
private final JButton btnStart = new StartButton();
|
private final JButton btnStart = new StartButton();
|
||||||
private final JComboBox<String> cbxPet = new JComboBox<String>();
|
private final FComboBox<String> cbxPet = new FComboBox<String>();
|
||||||
private final JCheckBox cbPlant = new FCheckBox("Summon Plant");
|
private final JCheckBox cbPlant = new FCheckBox("Summon Plant");
|
||||||
private final JLabel lblZep = new FLabel.Builder().text("Launch Zeppelin").fontSize(14).build();
|
private final JLabel lblZep = new FLabel.Builder().text("Launch Zeppelin").fontSize(14).build();
|
||||||
|
|
||||||
@@ -241,7 +241,7 @@ public enum VSubmenuDuels implements IVSubmenu<CSubmenuDuels>, IVQuestStats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JComboBox<String> getCbxPet() {
|
public FComboBox<String> getCbxPet() {
|
||||||
return cbxPet;
|
return cbxPet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
import javax.swing.JComboBox;
|
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JList;
|
import javax.swing.JList;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
@@ -31,6 +30,7 @@ import forge.gui.home.EMenuGroup;
|
|||||||
import forge.gui.home.IVSubmenu;
|
import forge.gui.home.IVSubmenu;
|
||||||
import forge.gui.home.VHomeUI;
|
import forge.gui.home.VHomeUI;
|
||||||
import forge.gui.toolbox.FCheckBox;
|
import forge.gui.toolbox.FCheckBox;
|
||||||
|
import forge.gui.toolbox.FComboBox;
|
||||||
import forge.gui.toolbox.FLabel;
|
import forge.gui.toolbox.FLabel;
|
||||||
import forge.gui.toolbox.FRadioButton;
|
import forge.gui.toolbox.FRadioButton;
|
||||||
import forge.gui.toolbox.FScrollPane;
|
import forge.gui.toolbox.FScrollPane;
|
||||||
@@ -79,33 +79,33 @@ public enum VSubmenuQuestData implements IVSubmenu<CSubmenuQuestData> {
|
|||||||
private final JCheckBox boxFantasy = new FCheckBox("Fantasy Mode");
|
private final JCheckBox boxFantasy = new FCheckBox("Fantasy Mode");
|
||||||
|
|
||||||
private final JLabel lblStartingWorld = new FLabel.Builder().text("Starting world:").build();
|
private final JLabel lblStartingWorld = new FLabel.Builder().text("Starting world:").build();
|
||||||
private final JComboBox<QuestWorld> cbxStartingWorld = new JComboBox<QuestWorld>();
|
private final FComboBox<QuestWorld> cbxStartingWorld = new FComboBox<QuestWorld>();
|
||||||
|
|
||||||
|
|
||||||
/* Second column */
|
/* Second column */
|
||||||
|
|
||||||
private final JLabel lblStartingPool = new FLabel.Builder().text("Starting pool:").build();
|
private final JLabel lblStartingPool = new FLabel.Builder().text("Starting pool:").build();
|
||||||
private final JComboBox<StartingPoolType> cbxStartingPool = new JComboBox<StartingPoolType>();
|
private final FComboBox<StartingPoolType> cbxStartingPool = new FComboBox<StartingPoolType>();
|
||||||
|
|
||||||
private final JLabel lblUnrestricted = new FLabel.Builder().text("All cards will be available to play.").build();
|
private final JLabel lblUnrestricted = new FLabel.Builder().text("All cards will be available to play.").build();
|
||||||
|
|
||||||
private final JLabel lblPreconDeck = new FLabel.Builder().text("Starter/Event deck:").build();
|
private final JLabel lblPreconDeck = new FLabel.Builder().text("Starter/Event deck:").build();
|
||||||
private final JComboBox<String> cbxPreconDeck = new JComboBox<String>();
|
private final FComboBox<String> cbxPreconDeck = new FComboBox<String>();
|
||||||
|
|
||||||
private final JLabel lblFormat = new FLabel.Builder().text("Sanctioned format:").build();
|
private final JLabel lblFormat = new FLabel.Builder().text("Sanctioned format:").build();
|
||||||
private final JComboBox<GameFormat> cbxFormat = new JComboBox<GameFormat>();
|
private final FComboBox<GameFormat> cbxFormat = new FComboBox<GameFormat>();
|
||||||
|
|
||||||
private final JLabel lblCustomDeck = new FLabel.Builder().text("Custom deck:").build();
|
private final JLabel lblCustomDeck = new FLabel.Builder().text("Custom deck:").build();
|
||||||
private final JComboBox<Deck> cbxCustomDeck = new JComboBox<Deck>();
|
private final FComboBox<Deck> cbxCustomDeck = new FComboBox<Deck>();
|
||||||
|
|
||||||
private final FLabel btnDefineCustomFormat = new FLabel.Builder().opaque(true).hoverable(true).text("Define custom format").build();
|
private final FLabel btnDefineCustomFormat = new FLabel.Builder().opaque(true).hoverable(true).text("Define custom format").build();
|
||||||
private final FLabel btnPrizeDefineCustomFormat = new FLabel.Builder().opaque(true).hoverable(true).text("Define custom format").build();
|
private final FLabel btnPrizeDefineCustomFormat = new FLabel.Builder().opaque(true).hoverable(true).text("Define custom format").build();
|
||||||
|
|
||||||
private final JLabel lblPrizedCards = new FLabel.Builder().text("Prized cards:").build();
|
private final JLabel lblPrizedCards = new FLabel.Builder().text("Prized cards:").build();
|
||||||
private final JComboBox<Object> cbxPrizedCards = new JComboBox<Object>();
|
private final FComboBox<Object> cbxPrizedCards = new FComboBox<Object>();
|
||||||
|
|
||||||
private final JLabel lblPrizeFormat = new FLabel.Builder().text("Sanctioned format:").build();
|
private final JLabel lblPrizeFormat = new FLabel.Builder().text("Sanctioned format:").build();
|
||||||
private final JComboBox<GameFormat> cbxPrizeFormat = new JComboBox<GameFormat>();
|
private final FComboBox<GameFormat> cbxPrizeFormat = new FComboBox<GameFormat>();
|
||||||
|
|
||||||
private final JLabel lblPrizeUnrestricted = new FLabel.Builder().text("All cards will be available to win.").build();
|
private final JLabel lblPrizeUnrestricted = new FLabel.Builder().text("All cards will be available to win.").build();
|
||||||
private final JLabel lblPrizeSameAsStarting = new FLabel.Builder().text("Only sets found in starting pool will be available.").build();
|
private final JLabel lblPrizeSameAsStarting = new FLabel.Builder().text("Only sets found in starting pool will be available.").build();
|
||||||
|
|||||||
96
src/main/java/forge/gui/toolbox/FComboBox.java
Normal file
96
src/main/java/forge/gui/toolbox/FComboBox.java
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
package forge.gui.toolbox;
|
||||||
|
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import javax.swing.JComboBox;
|
||||||
|
import javax.swing.JComponent;
|
||||||
|
import javax.swing.ListCellRenderer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper for combo box with extra logic (should be used instead of JComboBox)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
public class FComboBox<E> extends JComponent {
|
||||||
|
|
||||||
|
private JComboBox<E> innerComboBox;
|
||||||
|
private static ArrayList<FComboBox<?>> comboBoxes = new ArrayList<FComboBox<?>>();
|
||||||
|
|
||||||
|
public static void refreshAllSkins() {
|
||||||
|
for (FComboBox<?> comboBox : comboBoxes) {
|
||||||
|
comboBox.refreshSkin();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public FComboBox() {
|
||||||
|
super();
|
||||||
|
this.setOpaque(false);
|
||||||
|
innerComboBox = new JComboBox<E>();
|
||||||
|
this.add(innerComboBox);
|
||||||
|
comboBoxes.add(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addItem(E item) {
|
||||||
|
this.innerComboBox.addItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeItem(E item) {
|
||||||
|
this.innerComboBox.removeItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeAllItems() {
|
||||||
|
this.innerComboBox.removeAllItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getSelectedItem() {
|
||||||
|
return this.innerComboBox.getSelectedItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelectedItem(Object item) {
|
||||||
|
this.innerComboBox.setSelectedItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSelectedIndex() {
|
||||||
|
return this.innerComboBox.getSelectedIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelectedIndex(int index) {
|
||||||
|
this.innerComboBox.setSelectedIndex(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getItemCount() {
|
||||||
|
return this.innerComboBox.getItemCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
public E getItemAt(int index) {
|
||||||
|
return this.innerComboBox.getItemAt(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addActionListener(ActionListener l) {
|
||||||
|
this.innerComboBox.addActionListener(l);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRenderer(ListCellRenderer<? super E> aRenderer) {
|
||||||
|
this.innerComboBox.setRenderer(aRenderer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refreshSkin() {
|
||||||
|
//clone inner combo box
|
||||||
|
JComboBox<E> newInnerComboBox = new JComboBox<E>();
|
||||||
|
for (int i = 0; i < this.getItemCount(); i++) {
|
||||||
|
newInnerComboBox.addItem(this.getItemAt(i));
|
||||||
|
}
|
||||||
|
newInnerComboBox.setSelectedIndex(this.getSelectedIndex());
|
||||||
|
ActionListener[] listeners = this.innerComboBox.getActionListeners();
|
||||||
|
for (ActionListener l : listeners) {
|
||||||
|
newInnerComboBox.addActionListener(l);
|
||||||
|
}
|
||||||
|
newInnerComboBox.setRenderer(this.innerComboBox.getRenderer());
|
||||||
|
|
||||||
|
//replace inner combo box with its clone
|
||||||
|
this.remove(innerComboBox);
|
||||||
|
this.innerComboBox = newInnerComboBox;
|
||||||
|
this.add(innerComboBox);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,6 +19,7 @@ package forge.gui.toolbox;
|
|||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
|
import java.awt.Container;
|
||||||
import java.awt.Cursor;
|
import java.awt.Cursor;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
@@ -2016,6 +2017,9 @@ public enum FSkin {
|
|||||||
private void refreshComboBoxes(final JFrame appFrame) {
|
private void refreshComboBoxes(final JFrame appFrame) {
|
||||||
ArrayList<JComboBox> comboBoxes = TypeUtil.findAllComponents(JComboBox.class, appFrame);
|
ArrayList<JComboBox> comboBoxes = TypeUtil.findAllComponents(JComboBox.class, appFrame);
|
||||||
for (JComboBox comboBox : comboBoxes) {
|
for (JComboBox comboBox : comboBoxes) {
|
||||||
|
Container parent = comboBox.getParent();
|
||||||
|
if (parent == null) { continue; } //shouldn't happen
|
||||||
|
|
||||||
//backup model
|
//backup model
|
||||||
ComboBoxModel model = comboBox.getModel();
|
ComboBoxModel model = comboBox.getModel();
|
||||||
Object selectedItem = model.getSelectedItem();
|
Object selectedItem = model.getSelectedItem();
|
||||||
@@ -2024,10 +2028,8 @@ public enum FSkin {
|
|||||||
for(int i = 0; i < count; i++) {
|
for(int i = 0; i < count; i++) {
|
||||||
items.add(model.getElementAt(i));
|
items.add(model.getElementAt(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
comboBox.removeAllItems();
|
|
||||||
|
|
||||||
//restore model backup
|
//restore model backup in new combo box
|
||||||
for(int i = 0; i < count; i++) {
|
for(int i = 0; i < count; i++) {
|
||||||
comboBox.addItem(items.get(i));
|
comboBox.addItem(items.get(i));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user