mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
Prevent marking deck as modified when changing sections
Update item manager caption when changing section Show full catalog when in sideboard section Avoid hiding title and save buttons when changing sections
This commit is contained in:
@@ -106,8 +106,9 @@ public class Deck extends DeckBase implements Iterable<Entry<DeckSection, CardPo
|
|||||||
// will return new if it was absent
|
// will return new if it was absent
|
||||||
public CardPool getOrCreate(DeckSection deckSection) {
|
public CardPool getOrCreate(DeckSection deckSection) {
|
||||||
CardPool p = get(deckSection);
|
CardPool p = get(deckSection);
|
||||||
if ( p != null )
|
if (p != null) {
|
||||||
return p;
|
return p;
|
||||||
|
}
|
||||||
p = new CardPool();
|
p = new CardPool();
|
||||||
this.parts.put(deckSection, p);
|
this.parts.put(deckSection, p);
|
||||||
return p;
|
return p;
|
||||||
@@ -120,7 +121,7 @@ public class Deck extends DeckBase implements Iterable<Entry<DeckSection, CardPo
|
|||||||
protected void cloneFieldsTo(final DeckBase clone) {
|
protected void cloneFieldsTo(final DeckBase clone) {
|
||||||
super.cloneFieldsTo(clone);
|
super.cloneFieldsTo(clone);
|
||||||
final Deck result = (Deck) clone;
|
final Deck result = (Deck) clone;
|
||||||
for(Entry<DeckSection, CardPool> kv : parts.entrySet()) {
|
for (Entry<DeckSection, CardPool> kv : parts.entrySet()) {
|
||||||
CardPool cp = new CardPool();
|
CardPool cp = new CardPool();
|
||||||
result.parts.put(kv.getKey(), cp);
|
result.parts.put(kv.getKey(), cp);
|
||||||
cp.addAll(kv.getValue());
|
cp.addAll(kv.getValue());
|
||||||
@@ -165,7 +166,7 @@ public class Deck extends DeckBase implements Iterable<Entry<DeckSection, CardPo
|
|||||||
* @return the deck
|
* @return the deck
|
||||||
*/
|
*/
|
||||||
public static Deck fromSections(final Map<String, List<String>> sections, final boolean canThrowExtendedErrors) {
|
public static Deck fromSections(final Map<String, List<String>> sections, final boolean canThrowExtendedErrors) {
|
||||||
if ((sections == null) || sections.isEmpty()) {
|
if (sections == null || sections.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,18 +179,21 @@ public class Deck extends DeckBase implements Iterable<Entry<DeckSection, CardPo
|
|||||||
d.setComment(dh.getComment());
|
d.setComment(dh.getComment());
|
||||||
d.tags.addAll(dh.getTags());
|
d.tags.addAll(dh.getTags());
|
||||||
|
|
||||||
for(Entry<String, List<String>> s : sections.entrySet()) {
|
for (Entry<String, List<String>> s : sections.entrySet()) {
|
||||||
DeckSection sec = DeckSection.smartValueOf(s.getKey());
|
DeckSection sec = DeckSection.smartValueOf(s.getKey());
|
||||||
if ( null == sec )
|
if (sec == null) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
CardPool pool = CardPool.fromCardList(s.getValue());
|
CardPool pool = CardPool.fromCardList(s.getValue());
|
||||||
// I used to store planes and schemes under sideboard header, so this will assign them to a correct section
|
// I used to store planes and schemes under sideboard header, so this will assign them to a correct section
|
||||||
IPaperCard sample = pool.get(0);
|
IPaperCard sample = pool.get(0);
|
||||||
if ( sample != null && ( sample.getRules().getType().isPlane() || sample.getRules().getType().isPhenomenon() ) )
|
if (sample != null && ( sample.getRules().getType().isPlane() || sample.getRules().getType().isPhenomenon())) {
|
||||||
sec = DeckSection.Planes;
|
sec = DeckSection.Planes;
|
||||||
if ( sample != null && sample.getRules().getType().isScheme() )
|
}
|
||||||
|
if (sample != null && sample.getRules().getType().isScheme()) {
|
||||||
sec = DeckSection.Schemes;
|
sec = DeckSection.Schemes;
|
||||||
|
}
|
||||||
|
|
||||||
d.parts.put(sec, pool);
|
d.parts.put(sec, pool);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import javax.swing.SwingUtilities;
|
|||||||
|
|
||||||
import forge.Command;
|
import forge.Command;
|
||||||
import forge.deck.DeckBase;
|
import forge.deck.DeckBase;
|
||||||
|
import forge.deck.DeckSection;
|
||||||
import forge.gui.deckeditor.CDeckEditorUI;
|
import forge.gui.deckeditor.CDeckEditorUI;
|
||||||
import forge.gui.framework.DragCell;
|
import forge.gui.framework.DragCell;
|
||||||
import forge.gui.framework.FScreen;
|
import forge.gui.framework.FScreen;
|
||||||
@@ -69,6 +70,7 @@ public abstract class ACEditorBase<TItem extends InventoryItem, TModel extends D
|
|||||||
private final FScreen screen;
|
private final FScreen screen;
|
||||||
private ItemManager<TItem> catalogManager;
|
private ItemManager<TItem> catalogManager;
|
||||||
private ItemManager<TItem> deckManager;
|
private ItemManager<TItem> deckManager;
|
||||||
|
protected DeckSection sectionMode = DeckSection.Main;
|
||||||
|
|
||||||
// card transfer buttons
|
// card transfer buttons
|
||||||
private final FLabel btnAdd = new FLabel.Builder()
|
private final FLabel btnAdd = new FLabel.Builder()
|
||||||
@@ -113,6 +115,10 @@ public abstract class ACEditorBase<TItem extends InventoryItem, TModel extends D
|
|||||||
return this.screen;
|
return this.screen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DeckSection getSectionMode() {
|
||||||
|
return this.sectionMode;
|
||||||
|
}
|
||||||
|
|
||||||
public final void addItem(TItem item) {
|
public final void addItem(TItem item) {
|
||||||
onAddItems(createPoolForItem(item, 1), false);
|
onAddItems(createPoolForItem(item, 1), false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,8 +32,6 @@ import forge.deck.Deck;
|
|||||||
import forge.deck.DeckSection;
|
import forge.deck.DeckSection;
|
||||||
import forge.gui.deckeditor.SEditorIO;
|
import forge.gui.deckeditor.SEditorIO;
|
||||||
import forge.gui.deckeditor.views.VAllDecks;
|
import forge.gui.deckeditor.views.VAllDecks;
|
||||||
import forge.gui.deckeditor.views.VCardCatalog;
|
|
||||||
import forge.gui.deckeditor.views.VCurrentDeck;
|
|
||||||
import forge.gui.deckeditor.views.VDeckgen;
|
import forge.gui.deckeditor.views.VDeckgen;
|
||||||
import forge.gui.framework.DragCell;
|
import forge.gui.framework.DragCell;
|
||||||
import forge.gui.framework.FScreen;
|
import forge.gui.framework.FScreen;
|
||||||
@@ -65,7 +63,6 @@ public final class CEditorCommander extends ACEditorBase<PaperCard, Deck> {
|
|||||||
private DragCell deckGenParent = null;
|
private DragCell deckGenParent = null;
|
||||||
|
|
||||||
private List<DeckSection> allSections = new ArrayList<DeckSection>();
|
private List<DeckSection> allSections = new ArrayList<DeckSection>();
|
||||||
private DeckSection sectionMode = DeckSection.Main;
|
|
||||||
private final ItemPoolView<PaperCard> commanderPool;
|
private final ItemPoolView<PaperCard> commanderPool;
|
||||||
private final ItemPoolView<PaperCard> normalPool;
|
private final ItemPoolView<PaperCard> normalPool;
|
||||||
|
|
||||||
@@ -162,6 +159,7 @@ public final class CEditorCommander extends ACEditorBase<PaperCard, Deck> {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void resetTables() {
|
public void resetTables() {
|
||||||
|
this.sectionMode = DeckSection.Main;
|
||||||
this.getCatalogManager().setPool(normalPool,false);
|
this.getCatalogManager().setPool(normalPool,false);
|
||||||
this.getDeckManager().setPool(this.controller.getModel().getOrCreate(DeckSection.Main));
|
this.getDeckManager().setPool(this.controller.getModel().getOrCreate(DeckSection.Main));
|
||||||
}
|
}
|
||||||
@@ -240,52 +238,29 @@ public final class CEditorCommander extends ACEditorBase<PaperCard, Deck> {
|
|||||||
|
|
||||||
final List<TableColumnInfo<InventoryItem>> lstCatalogCols = SColumnUtil.getCatalogDefaultColumns();
|
final List<TableColumnInfo<InventoryItem>> lstCatalogCols = SColumnUtil.getCatalogDefaultColumns();
|
||||||
|
|
||||||
String title = "";
|
switch(sectionMode) {
|
||||||
String tabtext = "";
|
|
||||||
Boolean showOptions = true;
|
|
||||||
switch(sectionMode)
|
|
||||||
{
|
|
||||||
case Main:
|
case Main:
|
||||||
lstCatalogCols.remove(SColumnUtil.getColumn(ColumnName.CAT_QUANTITY));
|
lstCatalogCols.remove(SColumnUtil.getColumn(ColumnName.CAT_QUANTITY));
|
||||||
this.getCatalogManager().getTable().setAvailableColumns(lstCatalogCols);
|
this.getCatalogManager().getTable().setAvailableColumns(lstCatalogCols);
|
||||||
this.getCatalogManager().setPool(normalPool, false);
|
this.getCatalogManager().setPool(normalPool, false);
|
||||||
this.getDeckManager().setPool(this.controller.getModel().getMain());
|
this.getDeckManager().setPool(this.controller.getModel().getMain());
|
||||||
showOptions = true;
|
|
||||||
title = "Title: ";
|
|
||||||
tabtext = "Main Deck";
|
|
||||||
break;
|
break;
|
||||||
case Sideboard:
|
case Sideboard:
|
||||||
lstCatalogCols.remove(SColumnUtil.getColumn(ColumnName.CAT_QUANTITY));
|
lstCatalogCols.remove(SColumnUtil.getColumn(ColumnName.CAT_QUANTITY));
|
||||||
this.getCatalogManager().getTable().setAvailableColumns(lstCatalogCols);
|
this.getCatalogManager().getTable().setAvailableColumns(lstCatalogCols);
|
||||||
this.getCatalogManager().setPool(normalPool, false);
|
this.getCatalogManager().setPool(normalPool, false);
|
||||||
this.getDeckManager().setPool(this.controller.getModel().getOrCreate(DeckSection.Sideboard));
|
this.getDeckManager().setPool(this.controller.getModel().getOrCreate(DeckSection.Sideboard));
|
||||||
showOptions = false;
|
|
||||||
title = "Sideboard";
|
|
||||||
tabtext = "Card Catalog";
|
|
||||||
break;
|
break;
|
||||||
case Commander:
|
case Commander:
|
||||||
lstCatalogCols.remove(SColumnUtil.getColumn(ColumnName.CAT_QUANTITY));
|
lstCatalogCols.remove(SColumnUtil.getColumn(ColumnName.CAT_QUANTITY));
|
||||||
this.getCatalogManager().getTable().setAvailableColumns(lstCatalogCols);
|
this.getCatalogManager().getTable().setAvailableColumns(lstCatalogCols);
|
||||||
this.getCatalogManager().setPool(commanderPool, true);
|
this.getCatalogManager().setPool(commanderPool, true);
|
||||||
this.getDeckManager().setPool(this.controller.getModel().getOrCreate(DeckSection.Commander));
|
this.getDeckManager().setPool(this.controller.getModel().getOrCreate(DeckSection.Commander));
|
||||||
showOptions = false;
|
|
||||||
title = "Commander";
|
|
||||||
tabtext = "Card Catalog";
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
VCardCatalog.SINGLETON_INSTANCE.getTabLabel().setText(tabtext);
|
this.controller.updateCaptions();
|
||||||
VCurrentDeck.SINGLETON_INSTANCE.getBtnNew().setVisible(showOptions);
|
|
||||||
VCurrentDeck.SINGLETON_INSTANCE.getBtnOpen().setVisible(showOptions);
|
|
||||||
VCurrentDeck.SINGLETON_INSTANCE.getBtnSave().setVisible(showOptions);
|
|
||||||
VCurrentDeck.SINGLETON_INSTANCE.getBtnSaveAs().setVisible(showOptions);
|
|
||||||
VCurrentDeck.SINGLETON_INSTANCE.getBtnPrintProxies().setVisible(showOptions);
|
|
||||||
VCurrentDeck.SINGLETON_INSTANCE.getTxfTitle().setVisible(showOptions);
|
|
||||||
VCurrentDeck.SINGLETON_INSTANCE.getBtnImport().setVisible(showOptions);
|
|
||||||
VCurrentDeck.SINGLETON_INSTANCE.getLblTitle().setText(title);
|
|
||||||
|
|
||||||
this.controller.notifyModelChanged();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,8 +30,6 @@ import forge.card.CardRulesPredicates;
|
|||||||
import forge.deck.Deck;
|
import forge.deck.Deck;
|
||||||
import forge.deck.DeckSection;
|
import forge.deck.DeckSection;
|
||||||
import forge.gui.deckeditor.SEditorIO;
|
import forge.gui.deckeditor.SEditorIO;
|
||||||
import forge.gui.deckeditor.views.VCardCatalog;
|
|
||||||
import forge.gui.deckeditor.views.VCurrentDeck;
|
|
||||||
import forge.gui.framework.FScreen;
|
import forge.gui.framework.FScreen;
|
||||||
import forge.gui.toolbox.itemmanager.CardManager;
|
import forge.gui.toolbox.itemmanager.CardManager;
|
||||||
import forge.gui.toolbox.itemmanager.SItemManagerIO;
|
import forge.gui.toolbox.itemmanager.SItemManagerIO;
|
||||||
@@ -57,14 +55,8 @@ import forge.util.ItemPoolView;
|
|||||||
*/
|
*/
|
||||||
public final class CEditorConstructed extends ACEditorBase<PaperCard, Deck> {
|
public final class CEditorConstructed extends ACEditorBase<PaperCard, Deck> {
|
||||||
private final DeckController<Deck> controller;
|
private final DeckController<Deck> controller;
|
||||||
//private boolean sideboardMode = false;
|
private final List<DeckSection> allSections = new ArrayList<DeckSection>();
|
||||||
|
private final ItemPoolView<PaperCard> normalPool, avatarPool, planePool, schemePool;
|
||||||
private List<DeckSection> allSections = new ArrayList<DeckSection>();
|
|
||||||
private DeckSection sectionMode = DeckSection.Main;
|
|
||||||
|
|
||||||
private final ItemPoolView<PaperCard> avatarPool;
|
|
||||||
private final ItemPoolView<PaperCard> planePool;
|
|
||||||
private final ItemPoolView<PaperCard> schemePool;
|
|
||||||
|
|
||||||
//=========== Constructor
|
//=========== Constructor
|
||||||
/**
|
/**
|
||||||
@@ -82,6 +74,7 @@ public final class CEditorConstructed extends ACEditorBase<PaperCard, Deck> {
|
|||||||
allSections.add(DeckSection.Planes);
|
allSections.add(DeckSection.Planes);
|
||||||
//allSections.add(DeckSection.Commander);
|
//allSections.add(DeckSection.Commander);
|
||||||
|
|
||||||
|
normalPool = ItemPool.createFrom(Singletons.getMagicDb().getCommonCards().getAllCards(), PaperCard.class);
|
||||||
avatarPool = ItemPool.createFrom(Singletons.getMagicDb().getVariantCards().getAllCards(Predicates.compose(CardRulesPredicates.Presets.IS_VANGUARD, PaperCard.FN_GET_RULES)),PaperCard.class);
|
avatarPool = ItemPool.createFrom(Singletons.getMagicDb().getVariantCards().getAllCards(Predicates.compose(CardRulesPredicates.Presets.IS_VANGUARD, PaperCard.FN_GET_RULES)),PaperCard.class);
|
||||||
planePool = ItemPool.createFrom(Singletons.getMagicDb().getVariantCards().getAllCards(Predicates.compose(CardRulesPredicates.Presets.IS_PLANE_OR_PHENOMENON, PaperCard.FN_GET_RULES)),PaperCard.class);
|
planePool = ItemPool.createFrom(Singletons.getMagicDb().getVariantCards().getAllCards(Predicates.compose(CardRulesPredicates.Presets.IS_PLANE_OR_PHENOMENON, PaperCard.FN_GET_RULES)),PaperCard.class);
|
||||||
schemePool = ItemPool.createFrom(Singletons.getMagicDb().getVariantCards().getAllCards(Predicates.compose(CardRulesPredicates.Presets.IS_SCHEME, PaperCard.FN_GET_RULES)),PaperCard.class);
|
schemePool = ItemPool.createFrom(Singletons.getMagicDb().getVariantCards().getAllCards(Predicates.compose(CardRulesPredicates.Presets.IS_SCHEME, PaperCard.FN_GET_RULES)),PaperCard.class);
|
||||||
@@ -176,7 +169,8 @@ public final class CEditorConstructed extends ACEditorBase<PaperCard, Deck> {
|
|||||||
@Override
|
@Override
|
||||||
public void resetTables() {
|
public void resetTables() {
|
||||||
// Constructed mode can use all cards, no limitations.
|
// Constructed mode can use all cards, no limitations.
|
||||||
this.getCatalogManager().setPool(ItemPool.createFrom(Singletons.getMagicDb().getCommonCards().getAllCards(), PaperCard.class), true);
|
this.sectionMode = DeckSection.Main;
|
||||||
|
this.getCatalogManager().setPool(normalPool, true);
|
||||||
this.getDeckManager().setPool(this.controller.getModel().getMain());
|
this.getDeckManager().setPool(this.controller.getModel().getMain());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,26 +195,18 @@ public final class CEditorConstructed extends ACEditorBase<PaperCard, Deck> {
|
|||||||
|
|
||||||
final List<TableColumnInfo<InventoryItem>> lstCatalogCols = SColumnUtil.getCatalogDefaultColumns();
|
final List<TableColumnInfo<InventoryItem>> lstCatalogCols = SColumnUtil.getCatalogDefaultColumns();
|
||||||
|
|
||||||
String title = "";
|
|
||||||
String tabtext = "";
|
|
||||||
Boolean showOptions = true;
|
|
||||||
switch(sectionMode) {
|
switch(sectionMode) {
|
||||||
case Main:
|
case Main:
|
||||||
lstCatalogCols.remove(SColumnUtil.getColumn(ColumnName.CAT_QUANTITY));
|
lstCatalogCols.remove(SColumnUtil.getColumn(ColumnName.CAT_QUANTITY));
|
||||||
this.getCatalogManager().getTable().setAvailableColumns(lstCatalogCols);
|
this.getCatalogManager().getTable().setAvailableColumns(lstCatalogCols);
|
||||||
this.getCatalogManager().setPool(ItemPool.createFrom(Singletons.getMagicDb().getCommonCards().getAllCards(), PaperCard.class), true);
|
this.getCatalogManager().setPool(normalPool, true);
|
||||||
this.getDeckManager().setPool(this.controller.getModel().getMain());
|
this.getDeckManager().setPool(this.controller.getModel().getMain());
|
||||||
showOptions = true;
|
|
||||||
title = "Title: ";
|
|
||||||
tabtext = "Main Deck";
|
|
||||||
break;
|
break;
|
||||||
case Sideboard:
|
case Sideboard:
|
||||||
|
lstCatalogCols.remove(SColumnUtil.getColumn(ColumnName.CAT_QUANTITY));
|
||||||
this.getCatalogManager().getTable().setAvailableColumns(lstCatalogCols);
|
this.getCatalogManager().getTable().setAvailableColumns(lstCatalogCols);
|
||||||
this.getCatalogManager().setPool(this.controller.getModel().getMain());
|
this.getCatalogManager().setPool(normalPool, true);
|
||||||
this.getDeckManager().setPool(this.controller.getModel().getOrCreate(DeckSection.Sideboard));
|
this.getDeckManager().setPool(this.controller.getModel().getOrCreate(DeckSection.Sideboard));
|
||||||
showOptions = false;
|
|
||||||
title = "Sideboard";
|
|
||||||
tabtext = "Card Catalog";
|
|
||||||
break;
|
break;
|
||||||
case Avatar:
|
case Avatar:
|
||||||
lstCatalogCols.remove(SColumnUtil.getColumn(ColumnName.CAT_QUANTITY));
|
lstCatalogCols.remove(SColumnUtil.getColumn(ColumnName.CAT_QUANTITY));
|
||||||
@@ -232,9 +218,6 @@ public final class CEditorConstructed extends ACEditorBase<PaperCard, Deck> {
|
|||||||
this.getCatalogManager().getTable().setAvailableColumns(lstCatalogCols);
|
this.getCatalogManager().getTable().setAvailableColumns(lstCatalogCols);
|
||||||
this.getCatalogManager().setPool(avatarPool, true);
|
this.getCatalogManager().setPool(avatarPool, true);
|
||||||
this.getDeckManager().setPool(this.controller.getModel().getOrCreate(DeckSection.Avatar));
|
this.getDeckManager().setPool(this.controller.getModel().getOrCreate(DeckSection.Avatar));
|
||||||
showOptions = false;
|
|
||||||
title = "Vanguard";
|
|
||||||
tabtext = "Card Catalog";
|
|
||||||
break;
|
break;
|
||||||
case Planes:
|
case Planes:
|
||||||
lstCatalogCols.remove(SColumnUtil.getColumn(ColumnName.CAT_QUANTITY));
|
lstCatalogCols.remove(SColumnUtil.getColumn(ColumnName.CAT_QUANTITY));
|
||||||
@@ -246,9 +229,6 @@ public final class CEditorConstructed extends ACEditorBase<PaperCard, Deck> {
|
|||||||
this.getCatalogManager().getTable().setAvailableColumns(lstCatalogCols);
|
this.getCatalogManager().getTable().setAvailableColumns(lstCatalogCols);
|
||||||
this.getCatalogManager().setPool(planePool,true);
|
this.getCatalogManager().setPool(planePool,true);
|
||||||
this.getDeckManager().setPool(this.controller.getModel().getOrCreate(DeckSection.Planes));
|
this.getDeckManager().setPool(this.controller.getModel().getOrCreate(DeckSection.Planes));
|
||||||
showOptions = false;
|
|
||||||
title = "Planar";
|
|
||||||
tabtext = "Card Catalog";
|
|
||||||
break;
|
break;
|
||||||
case Schemes:
|
case Schemes:
|
||||||
lstCatalogCols.remove(SColumnUtil.getColumn(ColumnName.CAT_QUANTITY));
|
lstCatalogCols.remove(SColumnUtil.getColumn(ColumnName.CAT_QUANTITY));
|
||||||
@@ -260,25 +240,12 @@ public final class CEditorConstructed extends ACEditorBase<PaperCard, Deck> {
|
|||||||
this.getCatalogManager().getTable().setAvailableColumns(lstCatalogCols);
|
this.getCatalogManager().getTable().setAvailableColumns(lstCatalogCols);
|
||||||
this.getCatalogManager().setPool(schemePool,true);
|
this.getCatalogManager().setPool(schemePool,true);
|
||||||
this.getDeckManager().setPool(this.controller.getModel().getOrCreate(DeckSection.Schemes));
|
this.getDeckManager().setPool(this.controller.getModel().getOrCreate(DeckSection.Schemes));
|
||||||
showOptions = false;
|
|
||||||
title = "Scheme";
|
|
||||||
tabtext = "Card Catalog";
|
|
||||||
break;
|
break;
|
||||||
case Commander:
|
case Commander:
|
||||||
break; //do nothing for Commander here
|
break; //do nothing for Commander here
|
||||||
}
|
}
|
||||||
|
|
||||||
VCardCatalog.SINGLETON_INSTANCE.getTabLabel().setText(tabtext);
|
this.controller.updateCaptions();
|
||||||
VCurrentDeck.SINGLETON_INSTANCE.getBtnNew().setVisible(showOptions);
|
|
||||||
VCurrentDeck.SINGLETON_INSTANCE.getBtnOpen().setVisible(showOptions);
|
|
||||||
VCurrentDeck.SINGLETON_INSTANCE.getBtnSave().setVisible(showOptions);
|
|
||||||
VCurrentDeck.SINGLETON_INSTANCE.getBtnSaveAs().setVisible(showOptions);
|
|
||||||
VCurrentDeck.SINGLETON_INSTANCE.getBtnPrintProxies().setVisible(showOptions);
|
|
||||||
VCurrentDeck.SINGLETON_INSTANCE.getTxfTitle().setVisible(showOptions);
|
|
||||||
VCurrentDeck.SINGLETON_INSTANCE.getBtnImport().setVisible(showOptions);
|
|
||||||
VCurrentDeck.SINGLETON_INSTANCE.getLblTitle().setText(title);
|
|
||||||
|
|
||||||
this.controller.notifyModelChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|||||||
@@ -33,15 +33,8 @@ import forge.util.storage.IStorage;
|
|||||||
*
|
*
|
||||||
* @param <T> the generic type
|
* @param <T> the generic type
|
||||||
*/
|
*/
|
||||||
/**
|
|
||||||
* TODO: Write javadoc for this type.
|
|
||||||
*
|
|
||||||
* @param <T>
|
|
||||||
*/
|
|
||||||
public class DeckController<T extends DeckBase> {
|
public class DeckController<T extends DeckBase> {
|
||||||
|
|
||||||
private T model;
|
private T model;
|
||||||
private String modelName;
|
|
||||||
private boolean saved;
|
private boolean saved;
|
||||||
private boolean modelInStore;
|
private boolean modelInStore;
|
||||||
private final IStorage<T> folder;
|
private final IStorage<T> folder;
|
||||||
@@ -60,7 +53,6 @@ public class DeckController<T extends DeckBase> {
|
|||||||
this.folder = folder0;
|
this.folder = folder0;
|
||||||
this.view = view0;
|
this.view = view0;
|
||||||
this.model = null;
|
this.model = null;
|
||||||
this.modelName = null;
|
|
||||||
this.saved = true;
|
this.saved = true;
|
||||||
this.modelInStore = false;
|
this.modelInStore = false;
|
||||||
this.newModelCreator = newModelCreator0;
|
this.newModelCreator = newModelCreator0;
|
||||||
@@ -78,22 +70,13 @@ public class DeckController<T extends DeckBase> {
|
|||||||
/**
|
/**
|
||||||
* Sets the model.
|
* Sets the model.
|
||||||
*
|
*
|
||||||
* @param document the new model
|
|
||||||
*/
|
*/
|
||||||
public void setModel(final T document) {
|
public void setModel(final T document) {
|
||||||
this.setModel(document, false);
|
this.setModel(document, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the model.
|
|
||||||
*
|
|
||||||
* @param document the document
|
|
||||||
* @param isStored the is stored
|
|
||||||
*/
|
|
||||||
public void setModel(final T document, final boolean isStored) {
|
public void setModel(final T document, final boolean isStored) {
|
||||||
this.modelInStore = isStored;
|
this.modelInStore = isStored;
|
||||||
this.model = document;
|
this.model = document;
|
||||||
this.modelName = document.getName();
|
|
||||||
this.view.resetTables();
|
this.view.resetTables();
|
||||||
|
|
||||||
CStatistics.SINGLETON_INSTANCE.update();
|
CStatistics.SINGLETON_INSTANCE.update();
|
||||||
@@ -101,7 +84,8 @@ public class DeckController<T extends DeckBase> {
|
|||||||
|
|
||||||
if (this.isModelInSyncWithFolder()) {
|
if (this.isModelInSyncWithFolder()) {
|
||||||
_setSaved(true);
|
_setSaved(true);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
this.notifyModelChanged();
|
this.notifyModelChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,7 +100,7 @@ public class DeckController<T extends DeckBase> {
|
|||||||
if (modelStored == this.model) {
|
if (modelStored == this.model) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (null == modelStored) {
|
if (modelStored == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,11 +116,6 @@ public class DeckController<T extends DeckBase> {
|
|||||||
return this.view;
|
return this.view;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see forge.gui.deckeditor.IDeckController#notifyModelChanged()
|
|
||||||
*/
|
|
||||||
/**
|
/**
|
||||||
* Notify model changed.
|
* Notify model changed.
|
||||||
*/
|
*/
|
||||||
@@ -148,12 +127,7 @@ public class DeckController<T extends DeckBase> {
|
|||||||
saved = val;
|
saved = val;
|
||||||
updateCaptions();
|
updateCaptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see forge.gui.deckeditor.IDeckController#getSavedModelNames()
|
|
||||||
*/
|
|
||||||
/**
|
/**
|
||||||
* Gets the saved names.
|
* Gets the saved names.
|
||||||
*
|
*
|
||||||
@@ -163,11 +137,6 @@ public class DeckController<T extends DeckBase> {
|
|||||||
return new ArrayList<String>(this.folder.getItemNames());
|
return new ArrayList<String>(this.folder.getItemNames());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see forge.gui.deckeditor.IDeckController#load(java.lang.String)
|
|
||||||
*/
|
|
||||||
/**
|
/**
|
||||||
* Load.
|
* Load.
|
||||||
*
|
*
|
||||||
@@ -176,38 +145,30 @@ public class DeckController<T extends DeckBase> {
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void load(final String name) {
|
public void load(final String name) {
|
||||||
T newModel = this.folder.get(name);
|
T newModel = this.folder.get(name);
|
||||||
if (null != newModel) {
|
if (newModel != null) {
|
||||||
this.setModel((T) newModel.copyTo(name), true);
|
this.setModel((T) newModel.copyTo(name), true);
|
||||||
}
|
}
|
||||||
_setSaved(true);
|
else {
|
||||||
|
_setSaved(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see forge.gui.deckeditor.IDeckController#save()
|
|
||||||
*/
|
|
||||||
/**
|
/**
|
||||||
* Save.
|
* Save.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void save() {
|
public void save() {
|
||||||
if (null == model) {
|
if (model == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.folder.add(this.model);
|
this.folder.add(this.model);
|
||||||
// copy to new instance which will be edited and left if unsaved
|
// copy to new instance which will be edited and left if unsaved
|
||||||
this.setModel((T) this.model.copyTo(this.model.getName()), true);
|
this.model = (T)this.model.copyTo(this.model.getName());
|
||||||
this.modelInStore = true;
|
this.modelInStore = true;
|
||||||
_setSaved(true);
|
_setSaved(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see forge.gui.deckeditor.IDeckController#rename(java.lang.String)
|
|
||||||
*/
|
|
||||||
/**
|
/**
|
||||||
* Save as.
|
* Save as.
|
||||||
*
|
*
|
||||||
@@ -215,16 +176,11 @@ public class DeckController<T extends DeckBase> {
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void saveAs(final String name0) {
|
public void saveAs(final String name0) {
|
||||||
this.setModel((T) this.model.copyTo(name0), false);
|
this.model = (T)this.model.copyTo(name0);
|
||||||
|
this.modelInStore = false;
|
||||||
this.save();
|
this.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see forge.gui.deckeditor.IDeckController#isSaved()
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if is saved.
|
* Checks if is saved.
|
||||||
*
|
*
|
||||||
@@ -234,12 +190,6 @@ public class DeckController<T extends DeckBase> {
|
|||||||
return this.saved;
|
return this.saved;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see forge.gui.deckeditor.IDeckController#delete()
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete.
|
* Delete.
|
||||||
*/
|
*/
|
||||||
@@ -251,12 +201,6 @@ public class DeckController<T extends DeckBase> {
|
|||||||
this.newModel();
|
this.newModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see forge.gui.deckeditor.IDeckController#isGoodName(java.lang.String)
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* File exists.
|
* File exists.
|
||||||
*
|
*
|
||||||
@@ -267,12 +211,6 @@ public class DeckController<T extends DeckBase> {
|
|||||||
return this.folder.contains(deckName);
|
return this.folder.contains(deckName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see forge.gui.deckeditor.IDeckController#importDeck(forge.deck.Deck)
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Import deck.
|
* Import deck.
|
||||||
*
|
*
|
||||||
@@ -282,12 +220,6 @@ public class DeckController<T extends DeckBase> {
|
|||||||
this.setModel(newDeck);
|
this.setModel(newDeck);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see forge.gui.deckeditor.IDeckController#isModelInStore()
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if is model in store.
|
* Checks if is model in store.
|
||||||
*
|
*
|
||||||
@@ -319,17 +251,20 @@ public class DeckController<T extends DeckBase> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getModelName() {
|
public String getModelName() {
|
||||||
return modelName;
|
return this.model != null ? this.model.getName() : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateCaptions() {
|
public void updateCaptions() {
|
||||||
String tabCaption = "Current Deck";
|
String tabCaption = "Current Deck";
|
||||||
String title = this.model.getName();
|
String title = this.model.getName();
|
||||||
String itemManagerCaption = title.isEmpty() ? "[Untitled]" : title;
|
String itemManagerCaption = title.isEmpty() ? "[Untitled]" : title;
|
||||||
|
|
||||||
if (!saved) {
|
if (!saved) {
|
||||||
tabCaption = "*" + tabCaption;
|
tabCaption = "*" + tabCaption;
|
||||||
itemManagerCaption = "*" + itemManagerCaption;
|
itemManagerCaption = "*" + itemManagerCaption;
|
||||||
}
|
}
|
||||||
|
itemManagerCaption += " - " + this.view.getSectionMode().name();
|
||||||
|
|
||||||
VCurrentDeck.SINGLETON_INSTANCE.getTabLabel().setText(tabCaption);
|
VCurrentDeck.SINGLETON_INSTANCE.getTabLabel().setText(tabCaption);
|
||||||
VCurrentDeck.SINGLETON_INSTANCE.getTxfTitle().setText(title);
|
VCurrentDeck.SINGLETON_INSTANCE.getTxfTitle().setText(title);
|
||||||
VCurrentDeck.SINGLETON_INSTANCE.getItemManager().setCaption(itemManagerCaption);
|
VCurrentDeck.SINGLETON_INSTANCE.getItemManager().setCaption(itemManagerCaption);
|
||||||
|
|||||||
Reference in New Issue
Block a user