Get compile working

This commit is contained in:
drdev
2013-08-09 01:54:30 +00:00
parent 07c38892f9
commit c77f70b371
9 changed files with 195 additions and 27 deletions

1
.gitattributes vendored
View File

@@ -14794,6 +14794,7 @@ src/main/java/forge/gui/MultiLineLabelUI.java svneol=native#text/plain
src/main/java/forge/gui/SOverlayUtils.java -text
src/main/java/forge/gui/UnsortedListModel.java -text
src/main/java/forge/gui/WrapLayout.java -text
src/main/java/forge/gui/cardlistview/ACEditorBase.java -text
src/main/java/forge/gui/cardlistview/AlwaysShowToolTip.java -text
src/main/java/forge/gui/cardlistview/EditorTableModel.java -text
src/main/java/forge/gui/cardlistview/EditorTableView.java -text

View File

@@ -0,0 +1,168 @@
/*
* Forge: Play Magic: the Gathering.
* Copyright (C) 2011 Forge Team
*
* This program is free software: you can redistribute it and/or modify
* 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.cardlistview;
import javax.swing.SwingUtilities;
import forge.deck.DeckBase;
import forge.gui.deckeditor.tables.DeckController;
import forge.gui.cardlistview.EditorTableView;
import forge.gui.framework.DragCell;
import forge.gui.framework.ICDoc;
import forge.gui.framework.IVDoc;
import forge.gui.framework.SRearrangingUtil;
import forge.item.InventoryItem;
import forge.view.FView;
/**
* Maintains a generically typed architecture for various editing
* environments. A basic editor instance requires a card catalog, the
* current deck being edited, and optional filters on the catalog.
* <br><br>
* 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>
*
* @param <TItem> extends {@link forge.item.InventoryItem}
* @param <TModel> extends {@link forge.deck.DeckBase}
*/
public abstract class ACEditorBase<TItem extends InventoryItem, TModel extends DeckBase> {
public interface ContextMenuBuilder {
/**
* Adds move-related items to the context menu
*
* @param verb Examples: "Sell", "Add"
* @param nounSingular Examples: "item", "card"
* @param nounPlural Examples: "items", "cards"
* @param destination Examples: null, "to deck", "to sideboard"
*/
public void addMoveItems (String verb, String nounSingular, String nounPlural, String destination);
public void addMoveAlternateItems (String verb, String nounSingular, String nounPlural, String destination);
public void addTextFilterItem ();
}
private EditorTableView<TItem> tblCatalog;
private EditorTableView<TItem> tblDeck;
/**
* Operation to add one of selected card to current deck.
*/
public abstract void addCard(InventoryItem item, boolean toAlternate, int qty);
/**
* Operation to remove one of selected card from current deck.
*/
public abstract void removeCard(InventoryItem item, boolean toAlternate, int qty);
public abstract void buildAddContextMenu(ContextMenuBuilder cmb);
public abstract void buildRemoveContextMenu(ContextMenuBuilder cmb);
/**
* Resets the cards in the catalog table and current deck table.
*/
public abstract void resetTables();
/**
* Gets controller responsible for the current deck being edited.
*
* @return {@link forge.gui.deckeditor.tables.DeckController}
*/
public abstract DeckController<TModel> getDeckController();
/**
* Called when an editor wants to exit. Should confirm save options,
* update next UI screen, etc.
*
* @return boolean &emsp; true if safe to exit
*/
public abstract boolean exit();
/**
* Resets and initializes the current editor.
*/
public abstract void init();
/**
* Gets the EditorTableView holding the cards in the current deck.
*
* @return {@link forge.gui.cardlistview.EditorTableView}
*/
public EditorTableView<TItem> getTableDeck() {
return this.tblDeck;
}
/**
* Sets the EditorTableView holding the cards in the current deck.
*
* @param table0 &emsp; {@link forge.gui.cardlistview.EditorTableView}
*/
public void setTableDeck(final EditorTableView<TItem> table0) {
this.tblDeck = table0;
}
/**
* Gets the EditorTableView holding the cards in the current catalog.
*
* @return {@link forge.gui.cardlistview.EditorTableView}
*/
public EditorTableView<TItem> getTableCatalog() {
return this.tblCatalog;
}
/**
* Sets the EditorTableView holding the cards in the current catalog.
*
* @param table0 &emsp; {@link forge.gui.cardlistview.EditorTableView}
*/
public void setTableCatalog(final EditorTableView<TItem> table0) {
this.tblCatalog = table0;
}
/**
* Removes the specified tab and returns its parent for later re-adding
*/
protected DragCell removeTab (IVDoc<? extends ICDoc> tab) {
final DragCell parent;
if (tab.getParentCell() == null) {
parent = null;
} else {
parent = tab.getParentCell();
parent.removeDoc(tab);
tab.setParentCell(null);
if (parent.getDocs().size() > 0) {
// if specified tab was first child of its parent, the new first tab needs re-selecting.
parent.setSelected(parent.getDocs().get(0));
} else {
// if the parent is now childless, fill in the resultant gap
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
SRearrangingUtil.fillGap(parent);
FView.SINGLETON_INSTANCE.removeDragCell(parent);
}
});
}
}
return parent;
}
}

View File

@@ -1,8 +1,6 @@
/*
* Forge: Play Magic: the Gathering.
* Copyright (C) 2011
import forge.gui.deckeditor.views.VDeckEditorUI;
Forge Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -45,8 +45,8 @@ import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.collect.Iterables;
import forge.gui.deckeditor.SEditorUtil;
import forge.gui.deckeditor.views.ITableContainer;
import forge.gui.cardlistview.SCardListViewUtil;
import forge.gui.cardlistview.ITableContainer;
import forge.gui.toolbox.FSkin;
import forge.item.InventoryItem;
import forge.item.ItemPool;
@@ -230,7 +230,7 @@ public final class EditorTableView<T extends InventoryItem> {
/**
* Applies a EditorTableModel and a model listener to this instance's JTable.
*
* @param view0 &emsp; the {@link javax.gui.deckeditor.views.ITableCOntainer}
* @param view0 &emsp; the {@link forge.gui.cardlistview.ITableCOntainer}
* @param cols0 &emsp; List<TableColumnInfo<InventoryItem>> of additional columns for this
*/
public void setup(final ITableContainer view0, final List<TableColumnInfo<InventoryItem>> cols0) {
@@ -255,7 +255,7 @@ public final class EditorTableView<T extends InventoryItem> {
this.model.addTableModelListener(new TableModelListener() {
@Override
public void tableChanged(final TableModelEvent ev) {
SEditorUtil.setStats(EditorTableView.this.model.getCards(), view0);
SCardListViewUtil.setStats(EditorTableView.this.model.getCards(), view0);
}
});
}

View File

@@ -2,7 +2,7 @@ package forge.gui.cardlistview;
import javax.swing.JTable;
import forge.gui.deckeditor.SEditorUtil;
import forge.gui.cardlistview.SCardListViewUtil;
import forge.gui.toolbox.FLabel;
/**
@@ -17,7 +17,7 @@ public interface ITableContainer {
* Sets the table used for displaying cards in this
* deck editor container.
*
* @param tbl0 &emsp; {@link forge.gui.deckeditor.tables.EditorTableView}
* @param tbl0 &emsp; {@link forge.gui.cardlistview.EditorTableView}
*/
void setTableView(JTable tbl0);

View File

@@ -19,6 +19,7 @@ import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
import forge.gui.cardlistview.SColumnUtil.ColumnName;
import forge.gui.cardlistview.SColumnUtil.SortState;
import forge.item.InventoryItem;
import forge.properties.NewConstants;
@@ -58,7 +59,7 @@ public class SCardListViewIO {
/**
* Retrieve a preference from the editor preference map.
*
* @param name0 &emsp; {@link forge.gui.deckeditor.SCardListViewUtil.EditorPreference}
* @param name0 &emsp; {@link forge.gui.cardlistview.SCardListViewUtil.EditorPreference}
* @return TableColumnInfo<InventoryItem>
*/
public static boolean getPref(final EditorPreference name0) {
@@ -68,7 +69,7 @@ public class SCardListViewIO {
/**
* Set a preference in the editor preference map.
*
* @param name0 &emsp; {@link forge.gui.deckeditor.SCardListViewUtil.EditorPreference}
* @param name0 &emsp; {@link forge.gui.cardlistview.SCardListViewUtil.EditorPreference}
* @param val0 &emsp; boolean
*/
public static void setPref(final EditorPreference name0, final boolean val0) {
@@ -78,7 +79,7 @@ public class SCardListViewIO {
/**
* Retrieve a custom column.
*
* @param name0 &emsp; {@link forge.gui.deckeditor.SCardListViewUtil.CatalogColumnName}
* @param name0 &emsp; {@link forge.gui.cardlistview.SCardListViewUtil.CatalogColumnName}
* @return TableColumnInfo<InventoryItem>
*/
public static TableColumnInfo<InventoryItem> getColumn(final ColumnName name0) {

View File

@@ -85,7 +85,7 @@ public final class SCardListViewUtil {
*
* @param <T> &emsp; the generic type
* @param items &emsp; ItemPoolView<InventoryITem>
* @param view &emsp; {@link forge.gui.deckeditor.views.ITableContainer}
* @param view &emsp; {@link forge.gui.cardlistview.ITableContainer}
*/
public static <T extends InventoryItem> void setStats(final ItemPoolView<T> items, final ITableContainer view) {
for (StatTypes s : StatTypes.values()) {

View File

@@ -39,7 +39,7 @@ import forge.card.mana.ManaCost;
import forge.deck.DeckBase;
import forge.game.limited.DraftRankCache;
import forge.gui.deckeditor.CDeckEditorUI;
import forge.gui.deckeditor.controllers.ACEditorBase;
import forge.gui.cardlistview.ACEditorBase;
import forge.item.PaperCard;
import forge.item.IPaperCard;
import forge.item.InventoryItem;
@@ -217,7 +217,7 @@ public final class SColumnUtil {
public static <TItem extends InventoryItem, TModel extends DeckBase>
void toggleColumn(final TableColumnInfo<InventoryItem> col0) {
final ACEditorBase<TItem, TModel> ed = (ACEditorBase<TItem, TModel>)
/*final ACEditorBase<TItem, TModel> ed = (ACEditorBase<TItem, TModel>)
CDeckEditorUI.SINGLETON_INSTANCE.getCurrentEditorController();
final JTable tbl = (col0.getEnumValue().substring(0, 4).equals("DECK"))
@@ -247,13 +247,13 @@ public final class SColumnUtil {
else {
col0.setModelIndex(colmodel.getColumnCount());
}
}
}*/
}
/**
* Retrieve a custom column (uses identical method in SEditorIO).
*
* @param id0 &emsp; {@link forge.gui.deckeditor.SCardListViewUtil.CatalogColumnName}
* @param id0 &emsp; {@link forge.gui.cardlistview.SCardListViewUtil.CatalogColumnName}
* @return TableColumnInfo<InventoryItem>
*/
public static TableColumnInfo<InventoryItem> getColumn(final ColumnName id0) {
@@ -264,7 +264,7 @@ public final class SColumnUtil {
* Convenience method to get a column's index in the view (that is,
* in the TableColumnModel).
*
* @param id0 &emsp; {@link forge.gui.deckeditor.SCardListViewUtil.CatalogColumnName}
* @param id0 &emsp; {@link forge.gui.cardlistview.SCardListViewUtil.CatalogColumnName}
* @return int
* @param <TItem> extends InventoryItem
* @param <TModel> extends InventoryItem
@@ -273,7 +273,7 @@ public final class SColumnUtil {
public static <TItem extends InventoryItem, TModel extends DeckBase>
int getColumnViewIndex(final ColumnName id0) {
final ACEditorBase<TItem, TModel> ed = (ACEditorBase<TItem, TModel>)
/*final ACEditorBase<TItem, TModel> ed = (ACEditorBase<TItem, TModel>)
CDeckEditorUI.SINGLETON_INSTANCE.getCurrentEditorController();
final JTable tbl = (id0.toString().substring(0, 4).equals("DECK"))
@@ -287,14 +287,14 @@ public final class SColumnUtil {
}
catch (final Exception e) { }
return index;
return index;*/return -1;
}
/**
* Convenience method to get a column's index in the model (that is,
* in the EditorTableModel, NOT the TableColumnModel).
*
* @param id0 &emsp; {@link forge.gui.deckeditor.SCardListViewUtil.CatalogColumnName}
* @param id0 &emsp; {@link forge.gui.cardlistview.SCardListViewUtil.CatalogColumnName}
* @return int
* @param <TItem> extends InventoryItem
* @param <TModel> extends InventoryItem
@@ -303,14 +303,14 @@ public final class SColumnUtil {
public static <TItem extends InventoryItem, TModel extends DeckBase>
int getColumnModelIndex(final ColumnName id0) {
final ACEditorBase<TItem, TModel> ed = (ACEditorBase<TItem, TModel>)
CDeckEditorUI.SINGLETON_INSTANCE.getCurrentEditorController();
/*final ACEditorBase<TItem, TModel> ed = (ACEditorBase<TItem, TModel>)
CDeckEditorUI.SINGLETON_INSTANCE.getCurrentEditorController();*/
final JTable tbl = (id0.toString().substring(0, 4).equals("DECK"))
/*final JTable tbl = (id0.toString().substring(0, 4).equals("DECK"))
? ed.getTableDeck().getTable()
: ed.getTableCatalog().getTable();
return tbl.getColumn(SColumnUtil.getColumn(id0).getIdentifier()).getModelIndex();
return tbl.getColumn(SColumnUtil.getColumn(id0).getIdentifier()).getModelIndex();*/return -1;
}
//========== Display functions

View File

@@ -23,7 +23,7 @@ import javax.swing.table.TableColumn;
import com.google.common.base.Function;
import forge.gui.deckeditor.tables.SColumnUtil.SortState;
import forge.gui.cardlistview.SColumnUtil.SortState;
/**
* A column object in a EditorTableModel in the card editor.
@@ -84,12 +84,12 @@ public class TableColumnInfo<T> extends TableColumn {
this.sortPriority = position0;
}
/** @return {@link forge.gui.deckeditor.tables.EditorTableModel.SortState} */
/** @return {@link forge.gui.cardlistview.EditorTableModel.SortState} */
public SortState getSortState() {
return this.sortstate;
}
/** @param state0 &emsp; {@link forge.gui.deckeditor.tables.TableColumnInfo.SortState} */
/** @param state0 &emsp; {@link forge.gui.cardlistview.TableColumnInfo.SortState} */
public void setSortState(final SortState state0) {
this.sortstate = state0;
}