Add "Folder" column to DeckManagers

This commit is contained in:
drdev
2014-01-25 05:50:12 +00:00
parent f8d7d060b9
commit 80aa655164
3 changed files with 21 additions and 3 deletions

View File

@@ -49,11 +49,11 @@ public class DeckProxy implements InventoryItem {
private final Function<IHasName, Deck> fnGetDeck; private final Function<IHasName, Deck> fnGetDeck;
public DeckProxy(Deck deck, GameType type, IStorage<? extends IHasName> storage) { public DeckProxy(Deck deck, GameType type, IStorage<? extends IHasName> storage) {
this(deck, type, null, storage, null); this(deck, type, "", storage, null);
} }
public DeckProxy(IHasName deck, Function<IHasName, Deck> fnGetDeck, GameType type, IStorage<? extends IHasName> storage) { public DeckProxy(IHasName deck, Function<IHasName, Deck> fnGetDeck, GameType type, IStorage<? extends IHasName> storage) {
this(deck, type, null, storage, fnGetDeck); this(deck, type, "", storage, fnGetDeck);
} }
private DeckProxy(IHasName deck, GameType type, String path, IStorage<? extends IHasName> storage, Function<IHasName, Deck> fnGetDeck) { private DeckProxy(IHasName deck, GameType type, String path, IStorage<? extends IHasName> storage, Function<IHasName, Deck> fnGetDeck) {

View File

@@ -57,6 +57,7 @@ public final class DeckManager extends ItemManager<DeckProxy> {
private Command cmdDelete, cmdSelect; private Command cmdDelete, cmdSelect;
private final Map<ColumnDef, ItemColumn> columns = SColumnUtil.getColumns( private final Map<ColumnDef, ItemColumn> columns = SColumnUtil.getColumns(
ColumnDef.DECK_ACTIONS, ColumnDef.DECK_ACTIONS,
ColumnDef.DECK_FOLDER,
ColumnDef.NAME, ColumnDef.NAME,
ColumnDef.DECK_COLOR, ColumnDef.DECK_COLOR,
ColumnDef.DECK_FORMAT, ColumnDef.DECK_FORMAT,
@@ -74,7 +75,8 @@ public final class DeckManager extends ItemManager<DeckProxy> {
this.gametype = gt; this.gametype = gt;
columns.get(ColumnDef.DECK_ACTIONS).setCellRenderer(new DeckActionsRenderer()); columns.get(ColumnDef.DECK_ACTIONS).setCellRenderer(new DeckActionsRenderer());
columns.get(ColumnDef.NAME).setSortPriority(1); columns.get(ColumnDef.DECK_FOLDER).setSortPriority(1);
columns.get(ColumnDef.NAME).setSortPriority(2);
this.addSelectionListener(new ListSelectionListener() { this.addSelectionListener(new ListSelectionListener() {
@Override @Override

View File

@@ -396,6 +396,19 @@ public class ItemColumn extends TableColumn {
return toDeck(from.getKey()); return toDeck(from.getKey());
} }
}), }),
DECK_FOLDER("Folder", "Folder", 80, -1, -1, SortState.ASC, new ItemCellRenderer(),
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
@Override
public Comparable<?> apply(final Entry<InventoryItem, Integer> from) {
return toDeckFolder(from.getKey());
}
},
new Function<Entry<? extends InventoryItem, Integer>, Object>() {
@Override
public Object apply(final Entry<? extends InventoryItem, Integer> from) {
return toDeckFolder(from.getKey());
}
}),
DECK_COLOR("Color", "Color", 70, 70, 70, SortState.ASC, new ColorSetRenderer(), DECK_COLOR("Color", "Color", 70, 70, 70, SortState.ASC, new ColorSetRenderer(),
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() { new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
@Override @Override
@@ -546,5 +559,8 @@ public class ItemColumn extends TableColumn {
private static ColorSet toDeckColor(final InventoryItem i) { private static ColorSet toDeckColor(final InventoryItem i) {
return i instanceof DeckProxy ? ((DeckProxy) i).getColor() : null; return i instanceof DeckProxy ? ((DeckProxy) i).getColor() : null;
} }
private static String toDeckFolder(final InventoryItem i) {
return i instanceof DeckProxy ? ((DeckProxy) i).getPath() + "/" : null;
}
} }
} }