diff --git a/Mage.Client/src/main/java/mage/client/dialog/DownloadImagesDialog.form b/Mage.Client/src/main/java/mage/client/dialog/DownloadImagesDialog.form
index 2ab6699220..420011de61 100644
--- a/Mage.Client/src/main/java/mage/client/dialog/DownloadImagesDialog.form
+++ b/Mage.Client/src/main/java/mage/client/dialog/DownloadImagesDialog.form
@@ -20,7 +20,7 @@
-
+
@@ -223,14 +223,14 @@
-
+
-
+
@@ -258,7 +258,47 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -368,10 +408,10 @@
-
+
-
+
@@ -379,7 +419,7 @@
-
+
diff --git a/Mage.Client/src/main/java/mage/client/dialog/DownloadImagesDialog.java b/Mage.Client/src/main/java/mage/client/dialog/DownloadImagesDialog.java
index f6877c8eff..cbf581d0c0 100644
--- a/Mage.Client/src/main/java/mage/client/dialog/DownloadImagesDialog.java
+++ b/Mage.Client/src/main/java/mage/client/dialog/DownloadImagesDialog.java
@@ -19,9 +19,9 @@ public class DownloadImagesDialog extends MageDialog {
public static final int RET_CANCEL = 0;
public static final int RET_OK = 1;
- private Dimension sizeModeMessageOnly;
- private Dimension sizeModeMessageAndControls;
- private Map actionsControlStates = new HashMap<>();
+ private final Dimension sizeModeMessageOnly;
+ private final Dimension sizeModeMessageAndControls;
+ private final Map actionsControlStates = new HashMap<>();
/**
@@ -34,9 +34,9 @@ public class DownloadImagesDialog extends MageDialog {
// fix for panelInfo (it's resets aligmentX after netbeans designer opened)
panelInfo.setAlignmentX(CENTER_ALIGNMENT);
- // save default sizes
+ // save default sizes (WARNING, you must sync it manually with designer sizes)
//
- this.sizeModeMessageAndControls = new Dimension(580, 330); // dialog -> properties -> designer size
+ this.sizeModeMessageAndControls = new Dimension(716, 329); // dialog -> properties -> code tab -> designer size
//
this.sizeModeMessageOnly = new Dimension(this.sizeModeMessageAndControls.getSize());
sizeModeMessageOnly.height = 25 * 4;
@@ -95,6 +95,10 @@ public class DownloadImagesDialog extends MageDialog {
return this.comboLanguage;
}
+ public JComboBox getDownloadThreadsCombo() {
+ return this.comboDownloadThreads;
+ }
+
public JComboBox getSetsCombo() {
return this.comboSets;
}
@@ -142,6 +146,7 @@ public class DownloadImagesDialog extends MageDialog {
enableActionControl(enable, comboSets);
enableActionControl(enable, buttonSearchSet);
enableActionControl(enable, comboLanguage);
+ enableActionControl(enable, comboDownloadThreads);
enableActionControl(enable, checkboxRedownload);
}
@@ -214,9 +219,12 @@ public class DownloadImagesDialog extends MageDialog {
panelSourceLeft = new javax.swing.JPanel();
labelSource = new javax.swing.JLabel();
comboSource = new javax.swing.JComboBox<>();
- panelSourceRight = new javax.swing.JPanel();
+ panelSourceCenter = new javax.swing.JPanel();
labelLanguage = new javax.swing.JLabel();
comboLanguage = new javax.swing.JComboBox<>();
+ panelSourceRight = new javax.swing.JPanel();
+ labelDownloadThreads = new javax.swing.JLabel();
+ comboDownloadThreads = new javax.swing.JComboBox<>();
panelMode = new javax.swing.JPanel();
panelModeInner = new javax.swing.JPanel();
labelMode = new javax.swing.JLabel();
@@ -295,19 +303,33 @@ public class DownloadImagesDialog extends MageDialog {
panelSource.add(panelSourceLeft);
- panelSourceRight.setAlignmentX(0.0F);
- panelSourceRight.setMaximumSize(new java.awt.Dimension(130, 32767));
- panelSourceRight.setMinimumSize(new java.awt.Dimension(130, 30));
- panelSourceRight.setPreferredSize(new java.awt.Dimension(130, 100));
- panelSourceRight.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEADING));
+ panelSourceCenter.setAlignmentX(0.0F);
+ panelSourceCenter.setMaximumSize(new java.awt.Dimension(130, 32767));
+ panelSourceCenter.setMinimumSize(new java.awt.Dimension(130, 10));
+ panelSourceCenter.setPreferredSize(new java.awt.Dimension(130, 100));
+ panelSourceCenter.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEADING));
labelLanguage.setText("Language:");
- panelSourceRight.add(labelLanguage);
+ panelSourceCenter.add(labelLanguage);
comboLanguage.setMaximumRowCount(15);
comboLanguage.setModel(new javax.swing.DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
- comboLanguage.setPreferredSize(new java.awt.Dimension(90, 25));
- panelSourceRight.add(comboLanguage);
+ comboLanguage.setPreferredSize(new java.awt.Dimension(110, 25));
+ panelSourceCenter.add(comboLanguage);
+
+ panelSource.add(panelSourceCenter);
+
+ panelSourceRight.setMinimumSize(new java.awt.Dimension(150, 30));
+ panelSourceRight.setPreferredSize(new java.awt.Dimension(150, 35));
+ panelSourceRight.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEADING));
+
+ labelDownloadThreads.setText("Download threads:");
+ panelSourceRight.add(labelDownloadThreads);
+
+ comboDownloadThreads.setMaximumRowCount(15);
+ comboDownloadThreads.setModel(new javax.swing.DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
+ comboDownloadThreads.setPreferredSize(new java.awt.Dimension(110, 25));
+ panelSourceRight.add(comboDownloadThreads);
panelSource.add(panelSourceRight);
@@ -350,11 +372,11 @@ public class DownloadImagesDialog extends MageDialog {
panelRedownload.setAlignmentX(0.0F);
panelRedownload.setMaximumSize(new java.awt.Dimension(130, 32767));
- panelRedownload.setMinimumSize(new java.awt.Dimension(130, 30));
- panelRedownload.setPreferredSize(new java.awt.Dimension(130, 100));
+ panelRedownload.setMinimumSize(new java.awt.Dimension(280, 30));
+ panelRedownload.setPreferredSize(new java.awt.Dimension(280, 100));
panelRedownload.setLayout(new java.awt.BorderLayout());
- checkboxRedownload.setText("Re-download selected images");
+ checkboxRedownload.setText("Re-download all images");
checkboxRedownload.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
panelRedownload.add(checkboxRedownload, java.awt.BorderLayout.CENTER);
panelRedownload.add(filler1, java.awt.BorderLayout.PAGE_END);
@@ -431,6 +453,7 @@ public class DownloadImagesDialog extends MageDialog {
private javax.swing.JButton buttonSearchSet;
private javax.swing.JButton buttonStop;
private javax.swing.JCheckBox checkboxRedownload;
+ private javax.swing.JComboBox comboDownloadThreads;
private javax.swing.JComboBox comboLanguage;
private javax.swing.JComboBox comboSets;
private javax.swing.JComboBox comboSource;
@@ -444,6 +467,7 @@ public class DownloadImagesDialog extends MageDialog {
private javax.swing.Box.Filler fillerProgress1;
private javax.swing.Box.Filler fillerProgress2;
private javax.swing.Box.Filler fillerglobal2;
+ private javax.swing.JLabel labelDownloadThreads;
private javax.swing.JLabel labelGlobal;
private javax.swing.JLabel labelInfo;
private javax.swing.JLabel labelLanguage;
@@ -458,6 +482,7 @@ public class DownloadImagesDialog extends MageDialog {
private javax.swing.JPanel panelProgress;
private javax.swing.JPanel panelRedownload;
private javax.swing.JPanel panelSource;
+ private javax.swing.JPanel panelSourceCenter;
private javax.swing.JPanel panelSourceLeft;
private javax.swing.JPanel panelSourceRight;
private javax.swing.JProgressBar progress;
diff --git a/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.form b/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.form
index 1e52f05391..b1a497484e 100644
--- a/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.form
+++ b/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.form
@@ -4425,7 +4425,7 @@
-
+
diff --git a/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.java b/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.java
index 6f69eeed8f..07f5b02ae0 100644
--- a/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.java
+++ b/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.java
@@ -344,6 +344,10 @@ public class PreferencesDialog extends javax.swing.JDialog {
return CardLanguage.valueByCode(getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_PREF_LANGUAGE, CardLanguage.ENGLISH.getCode()));
}
+ public static Integer getPrefDownloadThreads() {
+ return Integer.parseInt(getCachedValue(KEY_CARD_IMAGES_THREADS, KEY_CARD_IMAGES_THREADS_DEFAULT));
+ }
+
private static class ImageFileFilter extends FileFilter {
@Override
@@ -487,7 +491,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
txtImageFolderPath = new javax.swing.JTextField();
btnBrowseImageLocation = new javax.swing.JButton();
cbSaveToZipFiles = new javax.swing.JCheckBox();
- cbPreferedImageLanguage = new javax.swing.JComboBox();
+ cbPreferedImageLanguage = new javax.swing.JComboBox<>();
labelPreferedImageLanguage = new javax.swing.JLabel();
labelNumberOfDownloadThreads = new javax.swing.JLabel();
cbNumberOfDownloadThreads = new javax.swing.JComboBox();
@@ -548,7 +552,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
txtURLServerList = new javax.swing.JTextField();
jLabel17 = new javax.swing.JLabel();
lblProxyType = new javax.swing.JLabel();
- cbProxyType = new javax.swing.JComboBox();
+ cbProxyType = new javax.swing.JComboBox<>();
pnlProxySettings = new javax.swing.JPanel();
pnlProxy = new javax.swing.JPanel();
lblProxyServer = new javax.swing.JLabel();
@@ -589,7 +593,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
tabThemes = new javax.swing.JPanel();
themesCategory = new javax.swing.JPanel();
lbSelectLabel = new javax.swing.JLabel();
- cbTheme = new javax.swing.JComboBox();
+ cbTheme = new javax.swing.JComboBox<>();
lbThemeHint = new javax.swing.JLabel();
saveButton = new javax.swing.JButton();
exitButton = new javax.swing.JButton();
@@ -1557,12 +1561,12 @@ public class PreferencesDialog extends javax.swing.JDialog {
});
cbPreferedImageLanguage.setMaximumRowCount(20);
- cbPreferedImageLanguage.setModel(new javax.swing.DefaultComboBoxModel(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
+ cbPreferedImageLanguage.setModel(new javax.swing.DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
labelPreferedImageLanguage.setText("Default images language:");
labelPreferedImageLanguage.setFocusable(false);
- labelNumberOfDownloadThreads.setText("Number of download threads:");
+ labelNumberOfDownloadThreads.setText("Default download threads:");
cbNumberOfDownloadThreads.setMaximumRowCount(20);
cbNumberOfDownloadThreads.setModel(new javax.swing.DefaultComboBoxModel(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/images/DownloadPicturesService.java b/Mage.Client/src/main/java/org/mage/plugins/card/images/DownloadPicturesService.java
index 9211ba721a..92b84cf1fa 100644
--- a/Mage.Client/src/main/java/org/mage/plugins/card/images/DownloadPicturesService.java
+++ b/Mage.Client/src/main/java/org/mage/plugins/card/images/DownloadPicturesService.java
@@ -164,11 +164,14 @@ public class DownloadPicturesService extends DefaultBoundedRangeModel implements
uiDialog.getLaunguagesCombo().setSelectedItem(PreferencesDialog.getPrefImagesLanguage());
reloadLanguagesForSelectedSource();
+ // DOWNLOAD THREADS
+ uiDialog.getDownloadThreadsCombo().setModel(new DefaultComboBoxModel<>(new String[]{"10", "9", "8", "7", "6", "5", "4", "3", "2", "1"}));
+ uiDialog.getDownloadThreadsCombo().setSelectedItem(PreferencesDialog.getPrefDownloadThreads().toString());
+
// REDOWNLOAD
uiDialog.getRedownloadCheckbox().setSelected(false);
uiDialog.getRedownloadCheckbox().addItemListener(this::checkboxRedowloadChanged);
-
// SETS (fills after source and language select)
//uiDialog.getSetsCombo().setModel(new DefaultComboBoxModel(DownloadSources.values()));
uiDialog.getSetsCombo().addItemListener((ItemEvent event) -> {
@@ -585,7 +588,6 @@ public class DownloadPicturesService extends DefaultBoundedRangeModel implements
}
Connection.ProxyType configProxyType = Connection.ProxyType.valueByText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_PROXY_TYPE, "None"));
-
Proxy.Type type = Proxy.Type.DIRECT;
switch (configProxyType) {
case HTTP:
@@ -610,15 +612,17 @@ public class DownloadPicturesService extends DefaultBoundedRangeModel implements
}
}
+ int downloadThreadsAmount = Integer.parseInt((String) uiDialog.getDownloadThreadsCombo().getSelectedItem());
+
if (proxy != null) {
logger.info("Started download of " + cardsDownloadQueue.size() + " images"
+ " from source: " + selectedSource.getSourceName()
- + ", language: " + selectedSource.getCurrentLanguage().getCode());
+ + ", language: " + selectedSource.getCurrentLanguage().getCode()
+ + ", threads: " + downloadThreadsAmount);
uiDialog.getProgressBar().setString("Preparing download list...");
if (selectedSource.prepareDownloadList(this, cardsDownloadQueue)) {
update(0, cardsDownloadQueue.size());
- int numberOfThreads = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_THREADS, PreferencesDialog.KEY_CARD_IMAGES_THREADS_DEFAULT));
- ExecutorService executor = Executors.newFixedThreadPool(numberOfThreads);
+ ExecutorService executor = Executors.newFixedThreadPool(downloadThreadsAmount);
for (int i = 0; i < cardsDownloadQueue.size() && !this.isNeedCancel(); i++) {
try {
CardDownloadData card = cardsDownloadQueue.get(i);