mirror of
https://github.com/magefree/mage.git
synced 2025-12-30 07:22:03 -08:00
Remember Type 2 selection when changing source on images download dialog
This commit is contained in:
parent
a399537772
commit
134dcb6946
1 changed files with 32 additions and 18 deletions
|
|
@ -187,10 +187,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
||||||
cardImageSource = GrabbagImageSource.getInstance();
|
cardImageSource = GrabbagImageSource.getInstance();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
int count = DownloadPictures.this.cards.size();
|
updateCardsToDownload();
|
||||||
float mb = (count * cardImageSource.getAverageSize()) / 1024;
|
|
||||||
bar.setString(String.format(cardIndex == count ? "%d of %d cards finished! Please close!"
|
|
||||||
: "%d of %d cards finished! Please wait! [%.1f Mb]", 0, count, mb));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
p0.add(jComboBox1);
|
p0.add(jComboBox1);
|
||||||
|
|
@ -227,20 +224,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
||||||
checkBox.addActionListener(new ActionListener() {
|
checkBox.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
ArrayList<CardDownloadData> cardsToDownload = DownloadPictures.this.cards;
|
updateCardsToDownload();
|
||||||
if (checkBox.isSelected()) {
|
|
||||||
DownloadPictures.this.type2cards = new ArrayList<>();
|
|
||||||
for (CardDownloadData data : DownloadPictures.this.cards) {
|
|
||||||
if (data.isType2() || data.isToken()) {
|
|
||||||
DownloadPictures.this.type2cards.add(data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cardsToDownload = DownloadPictures.this.type2cards;
|
|
||||||
}
|
|
||||||
int count = cardsToDownload.size();
|
|
||||||
float mb = (count * cardImageSource.getAverageSize()) / 1024;
|
|
||||||
bar.setString(String.format(cardIndex == count ? "%d of %d cards finished! Please close!"
|
|
||||||
: "%d of %d cards finished! Please wait! [%.1f Mb]", 0, count, mb));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -264,6 +248,36 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateCardsToDownload() {
|
||||||
|
ArrayList<CardDownloadData> cardsToDownload = cards;
|
||||||
|
if (type2cardsOnly()) {
|
||||||
|
selectType2andTokenCardsIfNotYetDone();
|
||||||
|
cardsToDownload = type2cards;
|
||||||
|
}
|
||||||
|
updateProgressText(cardsToDownload.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean type2cardsOnly() {
|
||||||
|
return checkBox.isSelected();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void selectType2andTokenCardsIfNotYetDone() {
|
||||||
|
if (type2cards == null) {
|
||||||
|
type2cards = new ArrayList<>();
|
||||||
|
for (CardDownloadData data : cards) {
|
||||||
|
if (data.isType2() || data.isToken()) {
|
||||||
|
type2cards.add(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateProgressText(int cardCount) {
|
||||||
|
float mb = (cardCount * cardImageSource.getAverageSize()) / 1024;
|
||||||
|
bar.setString(String.format(cardIndex == cardCount ? "%d of %d cards finished! Please close!"
|
||||||
|
: "%d of %d cards finished! Please wait! [%.1f Mb]", 0, cardCount, mb));
|
||||||
|
}
|
||||||
|
|
||||||
private static String createDownloadName(CardInfo card) {
|
private static String createDownloadName(CardInfo card) {
|
||||||
String className = card.getClassName();
|
String className = card.getClassName();
|
||||||
return className.substring(className.lastIndexOf('.') + 1);
|
return className.substring(className.lastIndexOf('.') + 1);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue