use of org.magic.api.beans.MagicEdition in project MtgDesktopCompanion by nicho92.
the class CardStockTableModel method updateEdition.
private void updateEdition(MagicCardStock magicCardStock, MagicEdition aValue) {
MagicEdition ed = aValue;
magicCardStock.getMagicCard().getEditions().remove(ed);
magicCardStock.getMagicCard().getEditions().add(0, (MagicEdition) aValue);
}
use of org.magic.api.beans.MagicEdition in project MtgDesktopCompanion by nicho92.
the class ManualImportDialog method getAsDeck.
public MagicDeck getAsDeck() {
if (editorPane.getText().length() == 0)
return deck;
String[] line = editorPane.getText().split("\n");
for (String l : line) {
int nb = Integer.parseInt(l.substring(0, l.indexOf(' ')));
String name = l.substring(l.indexOf(' '), l.length());
try {
MagicCard mc;
if (name.trim().equalsIgnoreCase("Plains") || name.trim().equalsIgnoreCase("Island") || name.trim().equalsIgnoreCase("Swamp") || name.trim().equalsIgnoreCase("Mountain") || name.trim().equalsIgnoreCase("Forest")) {
MagicEdition ed = new MagicEdition();
ed.setId(MTGControler.getInstance().get("default-land-deck"));
mc = MTGControler.getInstance().getEnabledProviders().searchCardByCriteria("name", name.trim(), ed, true).get(0);
} else {
mc = MTGControler.getInstance().getEnabledProviders().searchCardByCriteria("name", name.trim(), null, true).get(0);
}
if (mc != null) {
deck.getMap().put(mc, nb);
}
} catch (Exception e) {
logger.error(e);
}
}
return deck;
}
use of org.magic.api.beans.MagicEdition in project MtgDesktopCompanion by nicho92.
the class MagicEditionsTableModel method calculate.
public void calculate() throws SQLException {
MagicCollection mc = new MagicCollection(MTGControler.getInstance().get("default-library"));
Map<String, Integer> temp = MTGControler.getInstance().getEnabledDAO().getCardsCountGlobal(mc);
countDefaultLibrary = 0;
countTotal = 0;
for (MagicEdition me : list) {
mapCount.put(me, (temp.get(me.getId()) == null) ? 0 : temp.get(me.getId()));
countDefaultLibrary += mapCount.get(me);
}
for (MagicEdition me : list) countTotal += me.getCardCount();
}
use of org.magic.api.beans.MagicEdition in project MtgDesktopCompanion by nicho92.
the class SealedPackTableModel method setValueAt.
@Override
public void setValueAt(Object aValue, int row, int column) {
MagicEdition ed = pack.listEditions().get(row);
if (column == 0)
pack.set((MagicEdition) aValue, 0);
else if (column == 1)
if (Integer.parseInt(aValue.toString()) > 0) {
pack.set(ed, Integer.parseInt(aValue.toString()));
} else {
pack.remove(ed);
}
fireTableDataChanged();
}
use of org.magic.api.beans.MagicEdition in project MtgDesktopCompanion by nicho92.
the class EditionCellRenderer method getTableCellRendererComponent.
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
pane.removeAll();
pane.setBackground(super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column).getBackground());
for (MagicEdition ed : (List<MagicEdition>) value) {
JLabel l = new JLabel(IconSetProvider.getInstance().get16(ed.getId()));
l.setToolTipText(ed.getSet());
l.setOpaque(false);
pane.add(l);
}
return pane;
}
Aggregations