add in user-settable preference (defaulting to false) for elastic resizing for deck editor columns

This commit is contained in:
myk
2013-01-28 10:35:47 +00:00
parent 211f4c53b6
commit ed070ca13c
8 changed files with 74 additions and 33 deletions

2
.gitignore vendored
View File

@@ -293,6 +293,7 @@ res/pics/ALA
res/pics/ALL res/pics/ALL
res/pics/APC res/pics/APC
res/pics/ARB res/pics/ARB
res/pics/ARC
res/pics/ARN res/pics/ARN
res/pics/ATQ res/pics/ATQ
res/pics/AVR res/pics/AVR
@@ -312,6 +313,7 @@ res/pics/FEM
res/pics/FUT res/pics/FUT
res/pics/GPT res/pics/GPT
res/pics/HML res/pics/HML
res/pics/HOP
res/pics/ICE res/pics/ICE
res/pics/INV res/pics/INV
res/pics/ISD res/pics/ISD

View File

@@ -1,33 +1,34 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<preferences type="editor"> <preferences type="editor">
<pref name="stats_catalog" value="true"></pref>
<pref name="stats_deck" value="true"></pref>
<pref name="display_unique_only" value="true"></pref> <pref name="display_unique_only" value="true"></pref>
<col enumval="CAT_QUANTITY" identifier="Quantity" show="true" sortpriority="1" sortstate="DESC" width="39"></col> <pref name="elastic_columns" value="false"></pref>
<col enumval="CAT_NAME" identifier="Name" show="true" sortpriority="2" sortstate="DESC" width="50"></col> <pref name="stats_catalog" value="true"></pref>
<col enumval="CAT_COST" identifier="Cost" show="true" sortpriority="3" sortstate="DESC" width="36"></col> <pref name="stats_deck" value="true"></pref>
<col enumval="CAT_COLOR" identifier="Color" show="true" sortpriority="0" sortstate="NONE" width="30"></col> <col enumval="CAT_QUANTITY" identifier="Quantity" show="true" sortpriority="3" sortstate="ASC" width="30"></col>
<col enumval="CAT_TYPE" identifier="Type" show="true" sortpriority="0" sortstate="NONE" width="37"></col> <col enumval="CAT_NAME" identifier="Name" show="true" sortpriority="0" sortstate="NONE" width="262"></col>
<col enumval="CAT_POWER" identifier="Power" show="true" sortpriority="0" sortstate="NONE" width="36"></col> <col enumval="CAT_COST" identifier="Cost" show="true" sortpriority="2" sortstate="DESC" width="82"></col>
<col enumval="CAT_TOUGHNESS" identifier="Toughness" show="true" sortpriority="0" sortstate="NONE" width="36"></col> <col enumval="CAT_COLOR" identifier="Color" show="true" sortpriority="3" sortstate="DESC" width="54"></col>
<col enumval="CAT_CMC" identifier="CMC" show="true" sortpriority="0" sortstate="NONE" width="34"></col> <col enumval="CAT_TYPE" identifier="Type" show="true" sortpriority="1" sortstate="ASC" width="217"></col>
<col enumval="CAT_RARITY" identifier="Rarity" show="true" sortpriority="0" sortstate="NONE" width="19"></col> <col enumval="CAT_POWER" identifier="Power" show="true" sortpriority="0" sortstate="NONE" width="30"></col>
<col enumval="CAT_SET" identifier="Set" show="true" sortpriority="0" sortstate="NONE" width="28"></col> <col enumval="CAT_TOUGHNESS" identifier="Toughness" show="true" sortpriority="0" sortstate="NONE" width="30"></col>
<col enumval="CAT_AI" identifier="AI" show="true" sortpriority="0" sortstate="NONE" width="39"></col> <col enumval="CAT_CMC" identifier="CMC" show="true" sortpriority="0" sortstate="NONE" width="30"></col>
<col enumval="CAT_NEW" identifier="New" show="true" sortpriority="0" sortstate="NONE" width="51"></col> <col enumval="CAT_RARITY" identifier="Rarity" show="true" sortpriority="0" sortstate="NONE" width="30"></col>
<col enumval="CAT_PURCHASE_PRICE" identifier="Purchase Price" show="true" sortpriority="0" sortstate="NONE" width="59"></col> <col enumval="CAT_SET" identifier="Set" show="true" sortpriority="0" sortstate="NONE" width="34"></col>
<col enumval="DECK_QUANTITY" identifier="Quantity" show="true" sortpriority="1" sortstate="ASC" width="35"></col> <col enumval="CAT_AI" identifier="AI" show="false" sortpriority="0" sortstate="NONE" width="30"></col>
<col enumval="DECK_NAME" identifier="Name" show="true" sortpriority="0" sortstate="NONE" width="37"></col> <col enumval="CAT_NEW" identifier="New" show="true" sortpriority="1" sortstate="ASC" width="34"></col>
<col enumval="DECK_COST" identifier="Cost" show="true" sortpriority="0" sortstate="NONE" width="34"></col> <col enumval="CAT_PURCHASE_PRICE" identifier="Purchase Price" show="true" sortpriority="2" sortstate="ASC" width="40"></col>
<col enumval="DECK_COLOR" identifier="Color" show="true" sortpriority="0" sortstate="NONE" width="25"></col> <col enumval="DECK_QUANTITY" identifier="Quantity" show="true" sortpriority="0" sortstate="NONE" width="30"></col>
<col enumval="DECK_TYPE" identifier="Type" show="true" sortpriority="0" sortstate="NONE" width="35"></col> <col enumval="DECK_NAME" identifier="Name" show="true" sortpriority="3" sortstate="ASC" width="262"></col>
<col enumval="DECK_POWER" identifier="Power" show="true" sortpriority="0" sortstate="NONE" width="35"></col> <col enumval="DECK_COST" identifier="Cost" show="true" sortpriority="1" sortstate="ASC" width="82"></col>
<col enumval="DECK_TOUGHNESS" identifier="Toughness" show="true" sortpriority="0" sortstate="NONE" width="35"></col> <col enumval="DECK_COLOR" identifier="Color" show="true" sortpriority="2" sortstate="ASC" width="54"></col>
<col enumval="DECK_CMC" identifier="CMC" show="true" sortpriority="2" sortstate="DESC" width="33"></col> <col enumval="DECK_TYPE" identifier="Type" show="true" sortpriority="0" sortstate="NONE" width="217"></col>
<col enumval="DECK_RARITY" identifier="Rarity" show="true" sortpriority="0" sortstate="NONE" width="43"></col> <col enumval="DECK_POWER" identifier="Power" show="true" sortpriority="0" sortstate="NONE" width="30"></col>
<col enumval="DECK_SET" identifier="Set" show="true" sortpriority="0" sortstate="NONE" width="34"></col> <col enumval="DECK_TOUGHNESS" identifier="Toughness" show="true" sortpriority="0" sortstate="NONE" width="30"></col>
<col enumval="DECK_AI" identifier="AI" show="true" sortpriority="2" sortstate="ASC" width="27"></col> <col enumval="DECK_CMC" identifier="CMC" show="true" sortpriority="0" sortstate="NONE" width="30"></col>
<col enumval="DECK_NEW" identifier="New" show="true" sortpriority="0" sortstate="NONE" width="36"></col> <col enumval="DECK_RARITY" identifier="Rarity" show="true" sortpriority="0" sortstate="NONE" width="30"></col>
<col enumval="DECK_SALE_PRICE" identifier="Sale Price" show="true" sortpriority="3" sortstate="ASC" width="50"></col> <col enumval="DECK_SET" identifier="Set" show="false" sortpriority="0" sortstate="NONE" width="34"></col>
<col enumval="DECK_DECKS" identifier="Decks" show="true" sortpriority="0" sortstate="NONE" width="35"></col> <col enumval="DECK_AI" identifier="AI" show="false" sortpriority="2" sortstate="ASC" width="30"></col>
<col enumval="DECK_NEW" identifier="New" show="true" sortpriority="0" sortstate="NONE" width="34"></col>
<col enumval="DECK_SALE_PRICE" identifier="Sale Price" show="true" sortpriority="0" sortstate="NONE" width="40"></col>
<col enumval="DECK_DECKS" identifier="Decks" show="true" sortpriority="0" sortstate="NONE" width="30"></col>
</preferences> </preferences>

View File

@@ -24,6 +24,7 @@ import java.awt.event.MouseEvent;
import forge.Card; import forge.Card;
import forge.gui.CardContainer; import forge.gui.CardContainer;
import forge.gui.deckeditor.SEditorIO.EditorPreference;
import forge.gui.deckeditor.controllers.ACEditorBase; import forge.gui.deckeditor.controllers.ACEditorBase;
import forge.gui.deckeditor.views.VFilters; import forge.gui.deckeditor.views.VFilters;
import forge.gui.match.controllers.CDetail; import forge.gui.match.controllers.CDetail;
@@ -84,6 +85,14 @@ public enum CDeckEditorUI implements CardContainer {
public void setCurrentEditorController(ACEditorBase<?, ?> editor0) { public void setCurrentEditorController(ACEditorBase<?, ?> editor0) {
this.childController = editor0; this.childController = editor0;
updateController(); updateController();
if (childController != null) {
boolean wantElastic = SEditorIO.getPref(EditorPreference.elastic_columns);
boolean wantUnique = SEditorIO.getPref(EditorPreference.display_unique_only);
childController.getTableCatalog().setWantElasticColumns(wantElastic);
childController.getTableDeck().setWantElasticColumns(wantElastic);
childController.getTableCatalog().setWantUnique(wantUnique);
childController.getTableDeck().setWantUnique(wantUnique);
}
VFilters.SINGLETON_INSTANCE.getLayoutControl().buildFilter(); VFilters.SINGLETON_INSTANCE.getLayoutControl().buildFilter();
} }

View File

@@ -50,7 +50,8 @@ public class SEditorIO {
public enum EditorPreference { /** */ public enum EditorPreference { /** */
stats_deck, /** */ stats_deck, /** */
stats_catalog, stats_catalog,
display_unique_only display_unique_only,
elastic_columns
} }
private static final XMLEventFactory EVENT_FACTORY = XMLEventFactory.newInstance(); private static final XMLEventFactory EVENT_FACTORY = XMLEventFactory.newInstance();

View File

@@ -88,6 +88,8 @@ public enum CEditorPreferences implements ICDoc {
SEditorIO.getPref(EditorPreference.stats_deck)); SEditorIO.getPref(EditorPreference.stats_deck));
VEditorPreferences.SINGLETON_INSTANCE.getChbCardDisplayUnique().setSelected( VEditorPreferences.SINGLETON_INSTANCE.getChbCardDisplayUnique().setSelected(
SEditorIO.getPref(EditorPreference.display_unique_only)); SEditorIO.getPref(EditorPreference.display_unique_only));
VEditorPreferences.SINGLETON_INSTANCE.getChbElasticColumns().setSelected(
SEditorIO.getPref(EditorPreference.elastic_columns));
if (!SEditorIO.getPref(EditorPreference.stats_deck)) { if (!SEditorIO.getPref(EditorPreference.stats_deck)) {
VCurrentDeck.SINGLETON_INSTANCE.getPnlStats().setVisible(false); VCurrentDeck.SINGLETON_INSTANCE.getPnlStats().setVisible(false);
@@ -96,9 +98,12 @@ public enum CEditorPreferences implements ICDoc {
VCardCatalog.SINGLETON_INSTANCE.getPnlStats().setVisible(false); VCardCatalog.SINGLETON_INSTANCE.getPnlStats().setVisible(false);
} }
boolean wantElastic = SEditorIO.getPref(EditorPreference.elastic_columns);
boolean wantUnique = SEditorIO.getPref(EditorPreference.display_unique_only); boolean wantUnique = SEditorIO.getPref(EditorPreference.display_unique_only);
ACEditorBase<?, ?> curEditor = CDeckEditorUI.SINGLETON_INSTANCE.getCurrentEditorController(); ACEditorBase<?, ?> curEditor = CDeckEditorUI.SINGLETON_INSTANCE.getCurrentEditorController();
if (curEditor != null) { if (curEditor != null) {
curEditor.getTableCatalog().setWantElasticColumns(wantElastic);
curEditor.getTableDeck().setWantElasticColumns(wantElastic);
curEditor.getTableCatalog().setWantUnique(wantUnique); curEditor.getTableCatalog().setWantUnique(wantUnique);
curEditor.getTableCatalog().updateView(true); curEditor.getTableCatalog().updateView(true);
curEditor.getTableDeck().setWantUnique(wantUnique); curEditor.getTableDeck().setWantUnique(wantUnique);
@@ -119,6 +124,17 @@ public enum CEditorPreferences implements ICDoc {
SEditorIO.setPref(EditorPreference.stats_deck, ((JCheckBox) e.getSource()).isSelected()); SEditorIO.setPref(EditorPreference.stats_deck, ((JCheckBox) e.getSource()).isSelected());
SEditorIO.savePreferences(); } }); SEditorIO.savePreferences(); } });
VEditorPreferences.SINGLETON_INSTANCE.getChbElasticColumns().addItemListener(new ItemListener() {
@Override public void itemStateChanged(final ItemEvent e) {
ACEditorBase<?, ?> curEditor = CDeckEditorUI.SINGLETON_INSTANCE.getCurrentEditorController();
boolean wantElastic = ((JCheckBox) e.getSource()).isSelected();
if (curEditor != null) {
curEditor.getTableCatalog().setWantElasticColumns(wantElastic);
curEditor.getTableDeck().setWantElasticColumns(wantElastic);
}
SEditorIO.setPref(EditorPreference.elastic_columns, wantElastic);
SEditorIO.savePreferences(); } });
VEditorPreferences.SINGLETON_INSTANCE.getChbCardDisplayUnique().addItemListener(new ItemListener() { VEditorPreferences.SINGLETON_INSTANCE.getChbCardDisplayUnique().addItemListener(new ItemListener() {
@Override public void itemStateChanged(final ItemEvent e) { @Override public void itemStateChanged(final ItemEvent e) {
ACEditorBase<?, ?> curEditor = CDeckEditorUI.SINGLETON_INSTANCE.getCurrentEditorController(); ACEditorBase<?, ?> curEditor = CDeckEditorUI.SINGLETON_INSTANCE.getCurrentEditorController();

View File

@@ -430,4 +430,7 @@ public final class EditorTableView<T extends InventoryItem> {
this.alwaysNonUnique = nonUniqueOnly; this.alwaysNonUnique = nonUniqueOnly;
} }
public void setWantElasticColumns(boolean value) {
table.setAutoResizeMode(value ? JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS : JTable.AUTO_RESIZE_NEXT_COLUMN);
}
} }

View File

@@ -30,7 +30,7 @@ public enum VEditorPreferences implements IVDoc<CEditorPreferences> {
private final DragTab tab = new DragTab("Preferences"); private final DragTab tab = new DragTab("Preferences");
private JLabel lblStats = new FLabel.Builder() private JLabel lblStats = new FLabel.Builder()
.text("Stat Bars").tooltip("Toggle statistics bars") .text("General").tooltip("Configure high-level UI components")
.fontSize(12).build(); .fontSize(12).build();
private JLabel lblCatalog = new FLabel.Builder() private JLabel lblCatalog = new FLabel.Builder()
@@ -63,6 +63,7 @@ public enum VEditorPreferences implements IVDoc<CEditorPreferences> {
private JCheckBox chbDeckStats = new FCheckBox("Show stats in current deck"); private JCheckBox chbDeckStats = new FCheckBox("Show stats in current deck");
private JCheckBox chbCatalogStats = new FCheckBox("Show stats in card catalog"); private JCheckBox chbCatalogStats = new FCheckBox("Show stats in card catalog");
private JCheckBox chbElasticColumns = new FCheckBox("Use elastic resizing when changing column widths");
private JCheckBox chbCardDisplayUnique = new FCheckBox("Show unique cards only (only affects Constructed)"); private JCheckBox chbCardDisplayUnique = new FCheckBox("Show unique cards only (only affects Constructed)");
@@ -94,8 +95,10 @@ public enum VEditorPreferences implements IVDoc<CEditorPreferences> {
chbDeckStats.setFont(FSkin.getFont(12)); chbDeckStats.setFont(FSkin.getFont(12));
chbCatalogStats.setFont(FSkin.getFont(12)); chbCatalogStats.setFont(FSkin.getFont(12));
chbElasticColumns.setFont(FSkin.getFont(12));
chbDeckStats.setSelected(true); chbDeckStats.setSelected(true);
chbCatalogStats.setSelected(true); chbCatalogStats.setSelected(true);
chbElasticColumns.setSelected(false);
chbCardDisplayUnique.setFont(FSkin.getFont(12)); chbCardDisplayUnique.setFont(FSkin.getFont(12));
chbCardDisplayUnique.setSelected(false); chbCardDisplayUnique.setSelected(false);
@@ -103,6 +106,7 @@ public enum VEditorPreferences implements IVDoc<CEditorPreferences> {
pnl.add(lblStats, "h 25px!, gap 5px 5px 5px 5px, ax center, span 2 1"); pnl.add(lblStats, "h 25px!, gap 5px 5px 5px 5px, ax center, span 2 1");
pnl.add(chbCatalogStats, "h 25px!, gap 5px 5px 5px 5px, ax center, span 2 1"); pnl.add(chbCatalogStats, "h 25px!, gap 5px 5px 5px 5px, ax center, span 2 1");
pnl.add(chbDeckStats, "h 25px!, gap 5px 5px 5px 5px, ax center, span 2 1"); pnl.add(chbDeckStats, "h 25px!, gap 5px 5px 5px 5px, ax center, span 2 1");
pnl.add(chbElasticColumns, "h 25px!, gap 5px 5px 5px 5px, ax center, span 2 1");
final String constraints = "w 75px, h 25px!, gap 5px 5px 5px 5px, ax center"; final String constraints = "w 75px, h 25px!, gap 5px 5px 5px 5px, ax center";
pnl.add(lblCatalog, constraints + ", span 2 1"); pnl.add(lblCatalog, constraints + ", span 2 1");
@@ -260,6 +264,11 @@ public enum VEditorPreferences implements IVDoc<CEditorPreferences> {
return chbDeckStats; return chbDeckStats;
} }
/** @return {@link javax.swing.JCheckBox} */
public JCheckBox getChbElasticColumns() {
return chbElasticColumns;
}
/** @return {@link javax.swing.JCheckBox} */ /** @return {@link javax.swing.JCheckBox} */
public JCheckBox getChbCatalogStats() { public JCheckBox getChbCatalogStats() {
return chbCatalogStats; return chbCatalogStats;

View File

@@ -104,7 +104,7 @@ public class QuestPreferencesHandler extends JPanel {
pnlDifficulty.setOpaque(false); pnlDifficulty.setOpaque(false);
pnlDifficulty.setLayout(new MigLayout("insets 0, gap 0, wrap 5")); pnlDifficulty.setLayout(new MigLayout("insets 0, gap 0, wrap 5"));
pnlDifficulty.add(new FLabel.Builder().text("Difficulty Adjustments").icon(new ImageIcon("res/images/icons/NotesIcon.png")), "w 100%!, h 30px!, span 5 1"); pnlDifficulty.add(new FLabel.Builder().text("Difficulty Adjustments").icon(new ImageIcon("res/images/icons/NotesIcon.png")).build(), "w 100%!, h 30px!, span 5 1");
pnlDifficulty.add(lblErrDifficulty, "w 100%!, h 30px!, span 5 1"); pnlDifficulty.add(lblErrDifficulty, "w 100%!, h 30px!, span 5 1");
constraints1 = "w 60px!, h 26px!"; constraints1 = "w 60px!, h 26px!";