rewrote gettypetext, added removeIf to TableModel

This commit is contained in:
igoudt 2017-04-26 10:12:55 +02:00
parent 27aea04820
commit 5b21f34941
2 changed files with 19 additions and 35 deletions

View file

@ -181,12 +181,7 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
}
}
} else {
for (CardView cv : view) {
if (cv.getId().equals(entry.getKey())) {
view.remove(cv);
break;
}
}
view.removeIf(cardView -> cardView.getId().equals(entry.getKey()));
}
}
}
@ -296,12 +291,7 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
public void removeCard(UUID cardId) {
cards.remove(cardId);
for (CardView cv : view) {
if (cv.getId().equals(cardId)) {
view.remove(cv);
break;
}
}
view.removeIf(cardView -> cardView.getId().equals(cardId));
}
@Override

View file

@ -28,6 +28,7 @@
package mage.view;
import java.util.*;
import java.util.stream.Collectors;
import com.sun.xml.internal.ws.util.StringUtils;
import mage.MageObject;
@ -970,24 +971,17 @@ public class CardView extends SimpleCardView {
public String getTypeText() {
StringBuilder type = new StringBuilder();
for (SuperType superType : getSuperTypes()) {
type.append(superType.toString());
type.append(' ');
if (!getSuperTypes().isEmpty()) {
type.append(String.join(" ", getSuperTypes().stream().map(SuperType::toString).collect(Collectors.toList())));
type.append(" ");
}
for (CardType cardType : getCardTypes()) {
type.append(cardType.toString());
type.append(' ');
if (!getCardTypes().isEmpty()) {
type.append(String.join(" ", getCardTypes().stream().map(CardType::toString).collect(Collectors.toList())));
type.append(" ");
}
if (!getSubTypes().isEmpty()) {
type.append(" - ");
for (String subType : getSubTypes()) {
type.append(subType);
type.append(' ');
}
}
if (type.length() > 0) {
// remove trailing space
type.deleteCharAt(type.length() - 1);
type.append(String.join(" ", getSubTypes()));
}
return type.toString();
}