mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
UI: added new download images dialog:
* new option to download all modern cards; * new option with language selection; * new button for sets fast search; * new language support: Chinese Traditional; * all sets are sorted by date and have released date; * fixed selection reset on source changes;
This commit is contained in:
parent
79370108eb
commit
617f4d4b4b
5 changed files with 1151 additions and 269 deletions
|
@ -47,7 +47,7 @@ import net.java.truevfs.access.TConfig;
|
|||
import net.java.truevfs.kernel.spec.FsAccessOption;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.mage.card.arcane.ManaSymbols;
|
||||
import org.mage.plugins.card.images.DownloadPictures;
|
||||
import org.mage.plugins.card.images.DownloadPicturesService;
|
||||
import org.mage.plugins.card.info.CardInfoPaneImpl;
|
||||
import org.mage.plugins.card.utils.impl.ImageManagerImpl;
|
||||
|
||||
|
@ -1010,7 +1010,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
}//GEN-LAST:event_btnImagesActionPerformed
|
||||
|
||||
public void downloadImages() {
|
||||
DownloadPictures.startDownload();
|
||||
DownloadPicturesService.startDownload();
|
||||
}
|
||||
|
||||
public void exitApp() {
|
||||
|
@ -1380,7 +1380,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
Plugins.instance.downloadSymbols();
|
||||
break;
|
||||
case CLIENT_DOWNLOAD_CARD_IMAGES:
|
||||
DownloadPictures.startDownload();
|
||||
DownloadPicturesService.startDownload();
|
||||
break;
|
||||
case CLIENT_DISCONNECT:
|
||||
if (SessionHandler.isConnected()) {
|
||||
|
|
|
@ -41,7 +41,7 @@ import mage.view.PlaneView;
|
|||
import org.apache.log4j.Logger;
|
||||
import org.mage.card.arcane.ManaSymbols;
|
||||
import org.mage.plugins.card.images.CardDownloadData;
|
||||
import static org.mage.plugins.card.images.DownloadPictures.getTokenCardUrls;
|
||||
import static org.mage.plugins.card.images.DownloadPicturesService.getTokenCardUrls;
|
||||
|
||||
/**
|
||||
* Mage book with cards and page flipping.
|
||||
|
|
|
@ -0,0 +1,514 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.8" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
|
||||
<Properties>
|
||||
<Property name="title" type="java.lang.String" value="Downloading images"/>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[600, 400]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,73,0,0,2,65"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JPanel" name="panelGlobal">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="North"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout">
|
||||
<Property name="axis" type="int" value="1"/>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.Box$Filler" name="fillerGlobal1">
|
||||
<Properties>
|
||||
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[32767, 5]"/>
|
||||
</Property>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[0, 5]"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[0, 5]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="classDetails" type="java.lang.String" value="Box.Filler.VerticalStrut"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="labelGlobal">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Initializing image download..."/>
|
||||
<Property name="alignmentX" type="float" value="0.5"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.Box$Filler" name="fillerglobal2">
|
||||
<Properties>
|
||||
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[32767, 5]"/>
|
||||
</Property>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[0, 5]"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[0, 5]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="classDetails" type="java.lang.String" value="Box.Filler.VerticalStrut"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JTabbedPane" name="tabsList">
|
||||
<Properties>
|
||||
<Property name="tabLayoutPolicy" type="int" value="1"/>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="Center"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JPanel" name="tabMain">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
|
||||
<JTabbedPaneConstraints tabName="Standard download">
|
||||
<Property name="tabTitle" type="java.lang.String" value="Standard download"/>
|
||||
<Property name="tabIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/buttons/card_panel.png"/>
|
||||
</Property>
|
||||
</JTabbedPaneConstraints>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout">
|
||||
<Property name="axis" type="int" value="1"/>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JPanel" name="panelInfo">
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout">
|
||||
<Property name="axis" type="int" value="1"/>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.Box$Filler" name="fillerInfo1">
|
||||
<Properties>
|
||||
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[32767, 5]"/>
|
||||
</Property>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[0, 5]"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[0, 5]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="classDetails" type="java.lang.String" value="Box.Filler.VerticalStrut"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="labelInfo">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Missing: 12345 card images / 789 token images"/>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
|
||||
<EmptyBorder bottom="0" left="7" right="0" top="0"/>
|
||||
</Border>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.Box$Filler" name="fillerInfo2">
|
||||
<Properties>
|
||||
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[32767, 5]"/>
|
||||
</Property>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[0, 5]"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[0, 5]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="classDetails" type="java.lang.String" value="Box.Filler.VerticalStrut"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="panelSource">
|
||||
<Properties>
|
||||
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[65536, 55]"/>
|
||||
</Property>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[352, 55]"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[593, 55]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout">
|
||||
<Property name="axis" type="int" value="0"/>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JPanel" name="panelSourceLeft">
|
||||
<Properties>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[430, 30]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout">
|
||||
<Property name="alignment" type="int" value="3"/>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="labelSource">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Images source to download:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JComboBox" name="comboSource">
|
||||
<Properties>
|
||||
<Property name="maximumRowCount" type="int" value="10"/>
|
||||
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
|
||||
<StringArray count="4">
|
||||
<StringItem index="0" value="Item 1"/>
|
||||
<StringItem index="1" value="Item 2"/>
|
||||
<StringItem index="2" value="Item 3"/>
|
||||
<StringItem index="3" value="Item 4"/>
|
||||
</StringArray>
|
||||
</Property>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[300, 20]"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[400, 25]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="panelSourceRight">
|
||||
<Properties>
|
||||
<Property name="alignmentX" type="float" value="0.0"/>
|
||||
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[130, 32767]"/>
|
||||
</Property>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[130, 30]"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[130, 100]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout">
|
||||
<Property name="alignment" type="int" value="3"/>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="labelLanguage">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Language:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JComboBox" name="comboLanguage">
|
||||
<Properties>
|
||||
<Property name="maximumRowCount" type="int" value="20"/>
|
||||
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
|
||||
<StringArray count="4">
|
||||
<StringItem index="0" value="Item 1"/>
|
||||
<StringItem index="1" value="Item 2"/>
|
||||
<StringItem index="2" value="Item 3"/>
|
||||
<StringItem index="3" value="Item 4"/>
|
||||
</StringArray>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[90, 25]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="panelMode">
|
||||
<Properties>
|
||||
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[32869, 55]"/>
|
||||
</Property>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[322, 55]"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[100, 55]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JPanel" name="panelModeInner">
|
||||
<Properties>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[430, 43]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout">
|
||||
<Property name="alignment" type="int" value="0"/>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="labelMode">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Sets to download:"/>
|
||||
<Property name="alignmentY" type="float" value="0.0"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Container class="javax.swing.JPanel" name="panelModeSelect">
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout">
|
||||
<Property name="axis" type="int" value="0"/>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JComboBox" name="comboSets">
|
||||
<Properties>
|
||||
<Property name="maximumRowCount" type="int" value="20"/>
|
||||
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
|
||||
<StringArray count="4">
|
||||
<StringItem index="0" value="Item 1"/>
|
||||
<StringItem index="1" value="Item 2"/>
|
||||
<StringItem index="2" value="Item 3"/>
|
||||
<StringItem index="3" value="Item 4"/>
|
||||
</StringArray>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[373, 25]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.Box$Filler" name="fillerMode1">
|
||||
<Properties>
|
||||
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[5, 32767]"/>
|
||||
</Property>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[5, 0]"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[5, 0]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="classDetails" type="java.lang.String" value="Box.Filler.HorizontalStrut"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="buttonSearchSet">
|
||||
<Properties>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/buttons/search_24.png"/>
|
||||
</Property>
|
||||
<Property name="toolTipText" type="java.lang.String" value="Fast search your flag"/>
|
||||
<Property name="alignmentX" type="float" value="1.0"/>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[25, 25]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonSearchSetActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="javax.swing.Box$Filler" name="fillerMode">
|
||||
<Properties>
|
||||
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[130, 32767]"/>
|
||||
</Property>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[130, 0]"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[130, 0]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="classDetails" type="java.lang.String" value="Box.Filler.HorizontalStrut"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="javax.swing.Box$Filler" name="fillerMain1">
|
||||
<Properties>
|
||||
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[32767, 10]"/>
|
||||
</Property>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[0, 10]"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[0, 10]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="classDetails" type="java.lang.String" value="Box.Filler.VerticalStrut"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Container class="javax.swing.JPanel" name="panelProgress">
|
||||
<Properties>
|
||||
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[32777, 30]"/>
|
||||
</Property>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[20, 30]"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[564, 30]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout">
|
||||
<Property name="axis" type="int" value="0"/>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.Box$Filler" name="fillerProgress1">
|
||||
<Properties>
|
||||
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[5, 32767]"/>
|
||||
</Property>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[5, 0]"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[5, 0]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="classDetails" type="java.lang.String" value="Box.Filler.HorizontalStrut"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JProgressBar" name="progress">
|
||||
<Properties>
|
||||
<Property name="value" type="int" value="75"/>
|
||||
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[32767, 25]"/>
|
||||
</Property>
|
||||
<Property name="string" type="java.lang.String" value="123 of 12313 (120 cards/546 tokens) image downloads finished! Please wait! [123 Mb]"/>
|
||||
<Property name="stringPainted" type="boolean" value="true"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.Box$Filler" name="fillerProgress2">
|
||||
<Properties>
|
||||
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[5, 32767]"/>
|
||||
</Property>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[5, 0]"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[5, 0]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="classDetails" type="java.lang.String" value="Box.Filler.HorizontalStrut"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="javax.swing.Box$Filler" name="fillerMain2">
|
||||
<Properties>
|
||||
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[32767, 32767]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="classDetails" type="java.lang.String" value="Box.Filler.Glue"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="tabCustom">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
|
||||
<JTabbedPaneConstraints tabName="Custom download">
|
||||
<Property name="tabTitle" type="java.lang.String" value="Custom download"/>
|
||||
<Property name="tabIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/buttons/list_panel.png"/>
|
||||
</Property>
|
||||
</JTabbedPaneConstraints>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout">
|
||||
<Property name="axis" type="int" value="1"/>
|
||||
</Layout>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="panelCommands">
|
||||
<Properties>
|
||||
<Property name="alignmentX" type="float" value="0.0"/>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="South"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout">
|
||||
<Property name="alignment" type="int" value="4"/>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JButton" name="buttonOK">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Start download"/>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[120, 30]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_AddingCodePost" type="java.lang.String" value="getRootPane().setDefaultButton(buttonOK);"/>
|
||||
<AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="DownloadImagesDialog_buttonOK"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="buttonCancel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Cancel"/>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[80, 30]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
|
@ -0,0 +1,401 @@
|
|||
package mage.client.dialog;
|
||||
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.util.gui.FastSearchUtil;
|
||||
import mage.client.util.gui.MageDialogState;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
/**
|
||||
* @author JayDi85
|
||||
*/
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* Creates new form DownloadImagesDialog
|
||||
*/
|
||||
public DownloadImagesDialog() {
|
||||
initComponents();
|
||||
this.setModal(true);
|
||||
|
||||
// save default sizes
|
||||
//
|
||||
this.sizeModeMessageAndControls = new Dimension(580, 330); // dialog -> properties -> designer size
|
||||
//
|
||||
this.sizeModeMessageOnly = new Dimension(this.sizeModeMessageAndControls.getSize());
|
||||
sizeModeMessageOnly.height = 25 * 3;
|
||||
sizeModeMessageOnly.width = sizeModeMessageOnly.width / 2;
|
||||
|
||||
// Close the dialog when Esc is pressed
|
||||
String cancelName = "cancel";
|
||||
InputMap inputMap = getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
|
||||
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), cancelName);
|
||||
ActionMap actionMap = getRootPane().getActionMap();
|
||||
actionMap.put(cancelName, new AbstractAction() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
doClose(RET_CANCEL);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setWindowSize(int width, int heigth) {
|
||||
this.setSize(new Dimension(width, heigth));
|
||||
}
|
||||
|
||||
public void showDialog() {
|
||||
showDialog(null);
|
||||
}
|
||||
|
||||
public void showDialog(MageDialogState mageDialogState) {
|
||||
showDownloadControls(false); // call to change window size
|
||||
|
||||
// window settings
|
||||
if (this.isModal()) {
|
||||
MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER);
|
||||
} else {
|
||||
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
|
||||
}
|
||||
if (mageDialogState != null) {
|
||||
mageDialogState.setStateToDialog(this);
|
||||
} else {
|
||||
this.makeWindowCentered();
|
||||
}
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
public void setGlobalInfo(String info) {
|
||||
this.labelGlobal.setText(info);
|
||||
}
|
||||
|
||||
public void setCurrentInfo(String info) {
|
||||
this.labelInfo.setText(info);
|
||||
}
|
||||
|
||||
public JComboBox getSourcesCombo() {
|
||||
return this.comboSource;
|
||||
}
|
||||
|
||||
public JComboBox getLaunguagesCombo() {
|
||||
return this.comboLanguage;
|
||||
}
|
||||
|
||||
public JComboBox getSetsCombo() {
|
||||
return this.comboSets;
|
||||
}
|
||||
|
||||
public JButton getStartButton() {
|
||||
return this.buttonOK;
|
||||
}
|
||||
|
||||
public JButton getCancelButton() {
|
||||
return this.buttonCancel;
|
||||
}
|
||||
|
||||
public JProgressBar getProgressBar() {
|
||||
return this.progress;
|
||||
}
|
||||
|
||||
public void showLanguagesSupport(boolean haveSupport) {
|
||||
labelLanguage.setEnabled(haveSupport);
|
||||
comboLanguage.setEnabled(haveSupport);
|
||||
}
|
||||
|
||||
private void setTabTitle(int tabIndex, String title, String iconResourceName) {
|
||||
// tab caption with left sided icon
|
||||
// https://stackoverflow.com/questions/1782224/jtabbedpane-icon-on-left-side-of-tabs
|
||||
JLabel lbl = new JLabel(title);
|
||||
Icon icon = new ImageIcon(getClass().getResource(iconResourceName));
|
||||
lbl.setIcon(icon);
|
||||
lbl.setIconTextGap(5);
|
||||
lbl.setHorizontalTextPosition(SwingConstants.RIGHT);
|
||||
tabsList.setTabComponentAt(tabIndex, lbl);
|
||||
}
|
||||
|
||||
public void showDownloadControls(boolean needToShow) {
|
||||
// 2 modes:
|
||||
// - only message;
|
||||
// - message + download controls and buttons
|
||||
this.panelGlobal.setVisible(true);
|
||||
this.tabsList.setVisible(needToShow);
|
||||
this.panelCommands.setVisible(needToShow);
|
||||
|
||||
// auto-size form
|
||||
if (needToShow) {
|
||||
this.setWindowSize(this.sizeModeMessageAndControls.width, this.sizeModeMessageAndControls.height);
|
||||
} else {
|
||||
this.setWindowSize(this.sizeModeMessageOnly.width, this.sizeModeMessageOnly.height);
|
||||
}
|
||||
//this.setLocationRelativeTo(null); // center screen //FIX
|
||||
|
||||
// icons on tabs left side
|
||||
setTabTitle(0, "Standard download", "/buttons/card_panel.png");
|
||||
setTabTitle(1, "Custom download", "/buttons/list_panel.png");
|
||||
|
||||
// TODO: add manual mode as tab
|
||||
this.tabsList.getTabComponentAt(1).setEnabled(false);
|
||||
this.tabsList.setEnabledAt(1, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the return status of this dialog - one of RET_OK or RET_CANCEL
|
||||
*/
|
||||
public int getReturnStatus() {
|
||||
return returnStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
panelGlobal = new javax.swing.JPanel();
|
||||
fillerGlobal1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 5), new java.awt.Dimension(0, 5), new java.awt.Dimension(32767, 5));
|
||||
labelGlobal = new javax.swing.JLabel();
|
||||
fillerglobal2 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 5), new java.awt.Dimension(0, 5), new java.awt.Dimension(32767, 5));
|
||||
tabsList = new javax.swing.JTabbedPane();
|
||||
tabMain = new javax.swing.JPanel();
|
||||
panelInfo = new javax.swing.JPanel();
|
||||
fillerInfo1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 5), new java.awt.Dimension(0, 5), new java.awt.Dimension(32767, 5));
|
||||
labelInfo = new javax.swing.JLabel();
|
||||
fillerInfo2 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 5), new java.awt.Dimension(0, 5), new java.awt.Dimension(32767, 5));
|
||||
panelSource = new javax.swing.JPanel();
|
||||
panelSourceLeft = new javax.swing.JPanel();
|
||||
labelSource = new javax.swing.JLabel();
|
||||
comboSource = new javax.swing.JComboBox<>();
|
||||
panelSourceRight = new javax.swing.JPanel();
|
||||
labelLanguage = new javax.swing.JLabel();
|
||||
comboLanguage = new javax.swing.JComboBox<>();
|
||||
panelMode = new javax.swing.JPanel();
|
||||
panelModeInner = new javax.swing.JPanel();
|
||||
labelMode = new javax.swing.JLabel();
|
||||
panelModeSelect = new javax.swing.JPanel();
|
||||
comboSets = new javax.swing.JComboBox<>();
|
||||
fillerMode1 = new javax.swing.Box.Filler(new java.awt.Dimension(5, 0), new java.awt.Dimension(5, 0), new java.awt.Dimension(5, 32767));
|
||||
buttonSearchSet = new javax.swing.JButton();
|
||||
fillerMode = new javax.swing.Box.Filler(new java.awt.Dimension(130, 0), new java.awt.Dimension(130, 0), new java.awt.Dimension(130, 32767));
|
||||
fillerMain1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 10), new java.awt.Dimension(0, 10), new java.awt.Dimension(32767, 10));
|
||||
panelProgress = new javax.swing.JPanel();
|
||||
fillerProgress1 = new javax.swing.Box.Filler(new java.awt.Dimension(5, 0), new java.awt.Dimension(5, 0), new java.awt.Dimension(5, 32767));
|
||||
progress = new javax.swing.JProgressBar();
|
||||
fillerProgress2 = new javax.swing.Box.Filler(new java.awt.Dimension(5, 0), new java.awt.Dimension(5, 0), new java.awt.Dimension(5, 32767));
|
||||
fillerMain2 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(32767, 32767));
|
||||
tabCustom = new javax.swing.JPanel();
|
||||
panelCommands = new javax.swing.JPanel();
|
||||
buttonOK = new javax.swing.JButton();
|
||||
buttonCancel = new javax.swing.JButton();
|
||||
|
||||
setTitle("Downloading images");
|
||||
setPreferredSize(new java.awt.Dimension(600, 400));
|
||||
getContentPane().setLayout(new java.awt.BorderLayout());
|
||||
|
||||
panelGlobal.setLayout(new javax.swing.BoxLayout(panelGlobal, javax.swing.BoxLayout.Y_AXIS));
|
||||
panelGlobal.add(fillerGlobal1);
|
||||
|
||||
labelGlobal.setText("Initializing image download...");
|
||||
labelGlobal.setAlignmentX(0.5F);
|
||||
panelGlobal.add(labelGlobal);
|
||||
panelGlobal.add(fillerglobal2);
|
||||
|
||||
getContentPane().add(panelGlobal, java.awt.BorderLayout.NORTH);
|
||||
|
||||
tabsList.setTabLayoutPolicy(javax.swing.JTabbedPane.SCROLL_TAB_LAYOUT);
|
||||
|
||||
tabMain.setLayout(new javax.swing.BoxLayout(tabMain, javax.swing.BoxLayout.Y_AXIS));
|
||||
|
||||
panelInfo.setLayout(new javax.swing.BoxLayout(panelInfo, javax.swing.BoxLayout.Y_AXIS));
|
||||
panelInfo.add(fillerInfo1);
|
||||
|
||||
labelInfo.setText("Missing: 12345 card images / 789 token images");
|
||||
labelInfo.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 7, 0, 0));
|
||||
panelInfo.add(labelInfo);
|
||||
panelInfo.add(fillerInfo2);
|
||||
|
||||
tabMain.add(panelInfo);
|
||||
|
||||
panelSource.setMaximumSize(new java.awt.Dimension(65536, 55));
|
||||
panelSource.setMinimumSize(new java.awt.Dimension(352, 55));
|
||||
panelSource.setPreferredSize(new java.awt.Dimension(593, 55));
|
||||
panelSource.setLayout(new javax.swing.BoxLayout(panelSource, javax.swing.BoxLayout.X_AXIS));
|
||||
|
||||
panelSourceLeft.setMinimumSize(new java.awt.Dimension(430, 30));
|
||||
panelSourceLeft.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEADING));
|
||||
|
||||
labelSource.setText("Images source to download:");
|
||||
panelSourceLeft.add(labelSource);
|
||||
|
||||
comboSource.setMaximumRowCount(10);
|
||||
comboSource.setModel(new javax.swing.DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
|
||||
comboSource.setMinimumSize(new java.awt.Dimension(300, 20));
|
||||
comboSource.setPreferredSize(new java.awt.Dimension(400, 25));
|
||||
panelSourceLeft.add(comboSource);
|
||||
|
||||
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));
|
||||
|
||||
labelLanguage.setText("Language:");
|
||||
panelSourceRight.add(labelLanguage);
|
||||
|
||||
comboLanguage.setMaximumRowCount(20);
|
||||
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);
|
||||
|
||||
panelSource.add(panelSourceRight);
|
||||
|
||||
tabMain.add(panelSource);
|
||||
|
||||
panelMode.setMaximumSize(new java.awt.Dimension(32869, 55));
|
||||
panelMode.setMinimumSize(new java.awt.Dimension(322, 55));
|
||||
panelMode.setPreferredSize(new java.awt.Dimension(100, 55));
|
||||
panelMode.setLayout(new javax.swing.BoxLayout(panelMode, javax.swing.BoxLayout.LINE_AXIS));
|
||||
|
||||
panelModeInner.setMinimumSize(new java.awt.Dimension(430, 43));
|
||||
panelModeInner.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
|
||||
|
||||
labelMode.setText("Sets to download:");
|
||||
labelMode.setAlignmentY(0.0F);
|
||||
panelModeInner.add(labelMode);
|
||||
|
||||
panelModeSelect.setLayout(new javax.swing.BoxLayout(panelModeSelect, javax.swing.BoxLayout.X_AXIS));
|
||||
|
||||
comboSets.setMaximumRowCount(20);
|
||||
comboSets.setModel(new javax.swing.DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
|
||||
comboSets.setPreferredSize(new java.awt.Dimension(373, 25));
|
||||
panelModeSelect.add(comboSets);
|
||||
panelModeSelect.add(fillerMode1);
|
||||
|
||||
buttonSearchSet.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/search_24.png"))); // NOI18N
|
||||
buttonSearchSet.setToolTipText("Fast search your flag");
|
||||
buttonSearchSet.setAlignmentX(1.0F);
|
||||
buttonSearchSet.setPreferredSize(new java.awt.Dimension(25, 25));
|
||||
buttonSearchSet.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
buttonSearchSetActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
panelModeSelect.add(buttonSearchSet);
|
||||
|
||||
panelModeInner.add(panelModeSelect);
|
||||
|
||||
panelMode.add(panelModeInner);
|
||||
panelMode.add(fillerMode);
|
||||
|
||||
tabMain.add(panelMode);
|
||||
tabMain.add(fillerMain1);
|
||||
|
||||
panelProgress.setMaximumSize(new java.awt.Dimension(32777, 30));
|
||||
panelProgress.setMinimumSize(new java.awt.Dimension(20, 30));
|
||||
panelProgress.setPreferredSize(new java.awt.Dimension(564, 30));
|
||||
panelProgress.setLayout(new javax.swing.BoxLayout(panelProgress, javax.swing.BoxLayout.X_AXIS));
|
||||
panelProgress.add(fillerProgress1);
|
||||
|
||||
progress.setValue(75);
|
||||
progress.setMaximumSize(new java.awt.Dimension(32767, 25));
|
||||
progress.setString("123 of 12313 (120 cards/546 tokens) image downloads finished! Please wait! [123 Mb]");
|
||||
progress.setStringPainted(true);
|
||||
panelProgress.add(progress);
|
||||
panelProgress.add(fillerProgress2);
|
||||
|
||||
tabMain.add(panelProgress);
|
||||
tabMain.add(fillerMain2);
|
||||
|
||||
tabsList.addTab("Standard download", new javax.swing.ImageIcon(getClass().getResource("/buttons/card_panel.png")), tabMain); // NOI18N
|
||||
|
||||
tabCustom.setLayout(new javax.swing.BoxLayout(tabCustom, javax.swing.BoxLayout.Y_AXIS));
|
||||
tabsList.addTab("Custom download", new javax.swing.ImageIcon(getClass().getResource("/buttons/list_panel.png")), tabCustom); // NOI18N
|
||||
|
||||
getContentPane().add(tabsList, java.awt.BorderLayout.CENTER);
|
||||
|
||||
panelCommands.setAlignmentX(0.0F);
|
||||
panelCommands.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.TRAILING));
|
||||
|
||||
buttonOK.setText("Start download");
|
||||
buttonOK.setPreferredSize(new java.awt.Dimension(120, 30));
|
||||
panelCommands.add(buttonOK);
|
||||
getRootPane().setDefaultButton(buttonOK);
|
||||
|
||||
buttonCancel.setText("Cancel");
|
||||
buttonCancel.setPreferredSize(new java.awt.Dimension(80, 30));
|
||||
panelCommands.add(buttonCancel);
|
||||
|
||||
getContentPane().add(panelCommands, java.awt.BorderLayout.SOUTH);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
/**
|
||||
* Closes the dialog
|
||||
*/
|
||||
private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
|
||||
doClose(RET_CANCEL);
|
||||
}//GEN-LAST:event_closeDialog
|
||||
|
||||
private void buttonSearchSetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSearchSetActionPerformed
|
||||
FastSearchUtil.showFastSearchForStringComboBox(comboSets, FastSearchUtil.DEFAULT_EXPANSION_SEARCH_MESSAGE);
|
||||
}//GEN-LAST:event_buttonSearchSetActionPerformed
|
||||
|
||||
private void doClose(int retStatus) {
|
||||
returnStatus = retStatus;
|
||||
setVisible(false);
|
||||
dispose();
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton buttonCancel;
|
||||
private javax.swing.JButton buttonOK;
|
||||
private javax.swing.JButton buttonSearchSet;
|
||||
private javax.swing.JComboBox<String> comboLanguage;
|
||||
private javax.swing.JComboBox<String> comboSets;
|
||||
private javax.swing.JComboBox<String> comboSource;
|
||||
private javax.swing.Box.Filler fillerGlobal1;
|
||||
private javax.swing.Box.Filler fillerInfo1;
|
||||
private javax.swing.Box.Filler fillerInfo2;
|
||||
private javax.swing.Box.Filler fillerMain1;
|
||||
private javax.swing.Box.Filler fillerMain2;
|
||||
private javax.swing.Box.Filler fillerMode;
|
||||
private javax.swing.Box.Filler fillerMode1;
|
||||
private javax.swing.Box.Filler fillerProgress1;
|
||||
private javax.swing.Box.Filler fillerProgress2;
|
||||
private javax.swing.Box.Filler fillerglobal2;
|
||||
private javax.swing.JLabel labelGlobal;
|
||||
private javax.swing.JLabel labelInfo;
|
||||
private javax.swing.JLabel labelLanguage;
|
||||
private javax.swing.JLabel labelMode;
|
||||
private javax.swing.JLabel labelSource;
|
||||
private javax.swing.JPanel panelCommands;
|
||||
private javax.swing.JPanel panelGlobal;
|
||||
private javax.swing.JPanel panelInfo;
|
||||
private javax.swing.JPanel panelMode;
|
||||
private javax.swing.JPanel panelModeInner;
|
||||
private javax.swing.JPanel panelModeSelect;
|
||||
private javax.swing.JPanel panelProgress;
|
||||
private javax.swing.JPanel panelSource;
|
||||
private javax.swing.JPanel panelSourceLeft;
|
||||
private javax.swing.JPanel panelSourceRight;
|
||||
private javax.swing.JProgressBar progress;
|
||||
private javax.swing.JPanel tabCustom;
|
||||
private javax.swing.JPanel tabMain;
|
||||
private javax.swing.JTabbedPane tabsList;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
private int returnStatus = RET_CANCEL;
|
||||
}
|
|
@ -1,28 +1,14 @@
|
|||
package org.mage.plugins.card.images;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.nio.file.AccessDeniedException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import javax.swing.*;
|
||||
|
||||
import mage.cards.ExpansionSet;
|
||||
import mage.cards.Sets;
|
||||
import mage.cards.repository.CardCriteria;
|
||||
import mage.cards.repository.CardInfo;
|
||||
import mage.cards.repository.CardRepository;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.dialog.DownloadImagesDialog;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
import mage.client.util.CardLanguage;
|
||||
import mage.client.util.sets.ConstructedFormats;
|
||||
import mage.remote.Connection;
|
||||
import mage.util.StreamUtils;
|
||||
|
@ -35,46 +21,43 @@ import org.mage.plugins.card.dl.sources.*;
|
|||
import org.mage.plugins.card.properties.SettingsManager;
|
||||
import org.mage.plugins.card.utils.CardImageUtils;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.nio.file.AccessDeniedException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.mage.plugins.card.utils.CardImageUtils.getImagesDir;
|
||||
|
||||
public class DownloadPictures extends DefaultBoundedRangeModel implements Runnable {
|
||||
public class DownloadPicturesService extends DefaultBoundedRangeModel implements Runnable {
|
||||
|
||||
// don't forget to remove new sets from ignore.urls to download (propeties file in resources)
|
||||
private static DownloadPictures instance;
|
||||
// don't forget to remove new sets from ignore.urls to download (properties file in resources)
|
||||
private static DownloadPicturesService instance;
|
||||
private static final Logger logger = Logger.getLogger(DownloadPicturesService.class);
|
||||
|
||||
private static final Logger logger = Logger.getLogger(DownloadPictures.class);
|
||||
public static final String ALL_IMAGES = "- ALL images from selected source (can be slow)";
|
||||
public static final String ALL_MODERN_IMAGES = "- MODERN images (can be slow)";
|
||||
public static final String ALL_STANDARD_IMAGES = "- STANDARD images";
|
||||
public static final String ALL_TOKENS = "- TOKEN images";
|
||||
|
||||
public static final String ALL_IMAGES = "- ALL images from selected source (CAN BE VERY SLOW)";
|
||||
public static final String ALL_STANDARD_IMAGES = "- Only images from STANDARD sets";
|
||||
public static final String ALL_TOKENS = "- Only token images from selected source";
|
||||
|
||||
private JDialog dialog;
|
||||
private final JProgressBar bar;
|
||||
private final JOptionPane dlg;
|
||||
private boolean cancel;
|
||||
private final JButton closeButton;
|
||||
private final JButton startDownloadButton;
|
||||
private DownloadImagesDialog uiDialog;
|
||||
private boolean needCancel;
|
||||
private int cardIndex;
|
||||
private List<CardDownloadData> allCardsMissingImage;
|
||||
|
||||
private List<CardDownloadData> cardsMissing;
|
||||
private List<CardDownloadData> cardsToDownload;
|
||||
private int missingCardsCount = 0;
|
||||
private int missingTokensCount = 0;
|
||||
|
||||
private int missingCards = 0;
|
||||
private int missingTokens = 0;
|
||||
|
||||
List<String> selectedSetCodes = new ArrayList<>();
|
||||
|
||||
private final JComboBox jComboBoxServer;
|
||||
private final JLabel jLabelMessage;
|
||||
private final JLabel jLabelAllMissing;
|
||||
private final JLabel jLabelServer;
|
||||
|
||||
private final JComboBox jComboBoxSet;
|
||||
private final JLabel jLabelSet;
|
||||
List<String> selectedSets = new ArrayList<>();
|
||||
private static CardImageSource selectedSource;
|
||||
|
||||
private final Object sync = new Object();
|
||||
|
||||
private static CardImageSource cardImageSource;
|
||||
|
||||
private Proxy p = Proxy.NO_PROXY;
|
||||
|
||||
enum DownloadSources {
|
||||
|
@ -87,7 +70,6 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
ALTERNATIVE("7. alternative.mtg.onl", AltMtgOnlTokensImageSource.instance),
|
||||
COPYPASTE("8. Copy and Paste Image URLs", CopyPasteImageSource.instance);
|
||||
// MTG_ONL("mtg.onl", MtgOnlTokensImageSource.instance), Not working correctly yet
|
||||
// MAGICCARDS("magiccards.info", MagicCardsImageSource.instance)
|
||||
|
||||
private final String text;
|
||||
private final CardImageSource source;
|
||||
|
@ -108,7 +90,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
|
||||
}
|
||||
|
||||
public static DownloadPictures getInstance() {
|
||||
public static DownloadPicturesService getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
@ -117,243 +99,225 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
}
|
||||
|
||||
public static void startDownload() {
|
||||
// load images info in background task
|
||||
instance = new DownloadPicturesService(MageFrame.getInstance());
|
||||
new Thread(new LoadMissingCardDataNew(instance)).start();
|
||||
|
||||
/*
|
||||
* if (cards == null || cards.isEmpty()) {
|
||||
* JOptionPane.showMessageDialog(null,
|
||||
* "All card pictures have been downloaded."); return; }
|
||||
*/
|
||||
instance = new DownloadPictures(MageFrame.getInstance());
|
||||
Thread t1 = new Thread(new LoadMissingCardData(instance));
|
||||
t1.start();
|
||||
instance.getDlg().setVisible(true);
|
||||
instance.getDlg().dispose();
|
||||
instance.cancel = true;
|
||||
// show dialog
|
||||
instance.setNeedCancel(false);
|
||||
instance.uiDialog.showDialog();
|
||||
instance.uiDialog.dispose();
|
||||
instance.setNeedCancel(true);
|
||||
}
|
||||
|
||||
public JDialog getDlg() {
|
||||
return dialog;
|
||||
public boolean getNeedCancel() {
|
||||
return this.needCancel;
|
||||
}
|
||||
|
||||
public void setCancel(boolean cancel) {
|
||||
this.cancel = cancel;
|
||||
public void setNeedCancel(boolean needCancel) {
|
||||
this.needCancel = needCancel;
|
||||
}
|
||||
|
||||
static int WIDTH = 400;
|
||||
|
||||
public DownloadPictures(JFrame frame) {
|
||||
|
||||
public DownloadPicturesService(JFrame frame) {
|
||||
// init service and dialog
|
||||
cardsToDownload = new ArrayList<>();
|
||||
uiDialog = new DownloadImagesDialog();
|
||||
|
||||
JPanel p0 = new JPanel();
|
||||
p0.setLayout(new BoxLayout(p0, BoxLayout.Y_AXIS));
|
||||
// MESSAGE
|
||||
uiDialog.setGlobalInfo("Initializing image download...");
|
||||
|
||||
p0.add(Box.createVerticalStrut(5));
|
||||
|
||||
jLabelMessage = new JLabel();
|
||||
jLabelMessage.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||
jLabelMessage.setText("Initializing image download...");
|
||||
p0.add(jLabelMessage);
|
||||
p0.add(Box.createVerticalStrut(5));
|
||||
|
||||
jLabelAllMissing = new JLabel();
|
||||
|
||||
jLabelAllMissing.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
// jLabelAllMissing.setText("Computing number of missing images...");
|
||||
p0.add(jLabelAllMissing);
|
||||
p0.add(Box.createVerticalStrut(5));
|
||||
|
||||
jLabelServer = new JLabel();
|
||||
jLabelServer.setText("Please select image source:");
|
||||
jLabelServer.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
jLabelServer.setVisible(false);
|
||||
p0.add(jLabelServer);
|
||||
|
||||
p0.add(Box.createVerticalStrut(5));
|
||||
|
||||
jComboBoxServer = new JComboBox();
|
||||
jComboBoxServer.setModel(new DefaultComboBoxModel(DownloadSources.values()));
|
||||
jComboBoxServer.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
jComboBoxServer.setAlignmentY(Component.LEFT_ALIGNMENT);
|
||||
jComboBoxServer.addItemListener((ItemEvent event) -> {
|
||||
// SOURCES - scryfall is default source
|
||||
uiDialog.getSourcesCombo().setModel(new DefaultComboBoxModel(DownloadSources.values()));
|
||||
uiDialog.getSourcesCombo().setSelectedItem(DownloadSources.SCRYFALL);
|
||||
selectedSource = ScryfallImageSource.instance;
|
||||
uiDialog.getSourcesCombo().addItemListener((ItemEvent event) -> {
|
||||
if (event.getStateChange() == ItemEvent.SELECTED) {
|
||||
comboBoxServerItemSelected(event);
|
||||
}
|
||||
});
|
||||
Dimension d = jComboBoxServer.getPreferredSize();
|
||||
d.width = WIDTH;
|
||||
jComboBoxServer.setPreferredSize(d);
|
||||
p0.add(jComboBoxServer);
|
||||
jComboBoxServer.setVisible(false);
|
||||
|
||||
// set the first source as default
|
||||
cardImageSource = WizardCardsImageSource.instance;
|
||||
|
||||
p0.add(Box.createVerticalStrut(5));
|
||||
|
||||
// Set selection ---------------------------------
|
||||
jLabelSet = new JLabel();
|
||||
jLabelSet.setText("Please select sets to download the images for:");
|
||||
jLabelSet.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
jLabelSet.setVisible(false);
|
||||
p0.add(jLabelSet);
|
||||
|
||||
jComboBoxSet = new JComboBox();
|
||||
// jComboBoxSet.setModel(new DefaultComboBoxModel<>(getSetsForCurrentImageSource()));
|
||||
jComboBoxSet.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
jComboBoxSet.addItemListener((ItemEvent event) -> {
|
||||
if (event.getStateChange() == ItemEvent.SELECTED) {
|
||||
comboBoxSetItemSelected(event);
|
||||
comboboxSourceSelected(event);
|
||||
}
|
||||
});
|
||||
|
||||
p0.add(jComboBoxSet);
|
||||
jComboBoxSet.setVisible(false);
|
||||
// TODO: LANGUAGES
|
||||
uiDialog.getLaunguagesCombo().setModel(new DefaultComboBoxModel(CardLanguage.values()));
|
||||
uiDialog.getLaunguagesCombo().setSelectedItem(PreferencesDialog.getPrefImagesLanguage());
|
||||
reloadLanguagesForSelectedSource();
|
||||
|
||||
p0.add(Box.createVerticalStrut(5));
|
||||
|
||||
// Start
|
||||
startDownloadButton = new JButton("Start download");
|
||||
startDownloadButton.addActionListener(e -> {
|
||||
new Thread(DownloadPictures.this).start();
|
||||
startDownloadButton.setEnabled(false);
|
||||
// SETS (fills after source and language select)
|
||||
//uiDialog.getSetsCombo().setModel(new DefaultComboBoxModel(DownloadSources.values()));
|
||||
uiDialog.getSetsCombo().addItemListener((ItemEvent event) -> {
|
||||
if (event.getStateChange() == ItemEvent.SELECTED) {
|
||||
comboboxSetSelected(event);
|
||||
}
|
||||
});
|
||||
p0.add(Box.createVerticalStrut(5));
|
||||
|
||||
// Progress
|
||||
bar = new JProgressBar(this);
|
||||
p0.add(bar);
|
||||
bar.setStringPainted(true);
|
||||
// BUTTON START
|
||||
uiDialog.getStartButton().addActionListener(e -> {
|
||||
// selected language setup
|
||||
if (selectedSource != null) {
|
||||
if (selectedSource.isLanguagesSupport()) {
|
||||
selectedSource.setCurrentLanguage((CardLanguage) uiDialog.getLaunguagesCombo().getSelectedItem());
|
||||
}
|
||||
}
|
||||
|
||||
d = bar.getPreferredSize();
|
||||
d.width = WIDTH;
|
||||
bar.setPreferredSize(d);
|
||||
bar.setVisible(false);
|
||||
// run
|
||||
new Thread(DownloadPicturesService.this).start();
|
||||
uiDialog.getStartButton().setEnabled(false);
|
||||
});
|
||||
|
||||
// JOptionPane
|
||||
Object[] options = {startDownloadButton, closeButton = new JButton("Cancel")};
|
||||
startDownloadButton.setVisible(false);
|
||||
closeButton.addActionListener(e -> dialog.setVisible(false));
|
||||
closeButton.setVisible(false);
|
||||
// BUTTON CANCEL
|
||||
uiDialog.getCancelButton().addActionListener(e -> uiDialog.setVisible(false));
|
||||
|
||||
dlg = new JOptionPane(p0, JOptionPane.PLAIN_MESSAGE, JOptionPane.DEFAULT_OPTION, null, options, options[1]);
|
||||
dialog = this.dlg.createDialog(frame, "Downloading images");
|
||||
// PROGRESS BAR
|
||||
uiDialog.getProgressBar().setValue(0);
|
||||
|
||||
uiDialog.showDownloadControls(false);
|
||||
}
|
||||
|
||||
public void setAllMissingCards() {
|
||||
updateAndViewMessage("Get all available cards from the repository...");
|
||||
updateAndViewMessage("Loading cards list...");
|
||||
List<CardInfo> cards = CardRepository.instance.findCards(new CardCriteria());
|
||||
updateAndViewMessage("Check which images are missing ...");
|
||||
this.allCardsMissingImage = getNeededCards(cards);
|
||||
updateAndViewMessage("Check which images the current source is providing ...");
|
||||
jComboBoxSet.setModel(new DefaultComboBoxModel<>(getSetsForCurrentImageSource()));
|
||||
|
||||
updateCardsToDownload(jComboBoxSet.getSelectedItem().toString());
|
||||
updateAndViewMessage("Find missing images...");
|
||||
this.cardsMissing = getNeededCards(cards);
|
||||
|
||||
jComboBoxServer.setVisible(true);
|
||||
jLabelServer.setVisible(true);
|
||||
jComboBoxSet.setVisible(true);
|
||||
jLabelSet.setVisible(true);
|
||||
bar.setVisible(true);
|
||||
startDownloadButton.setVisible(true);
|
||||
closeButton.setVisible(true);
|
||||
updateAndViewMessage("Find available sets from selected source...");
|
||||
this.uiDialog.getSetsCombo().setModel(new DefaultComboBoxModel<>(getSetsForCurrentImageSource()));
|
||||
reloadCardsToDownload(this.uiDialog.getSetsCombo().getSelectedItem().toString());
|
||||
|
||||
this.uiDialog.showDownloadControls(true);
|
||||
updateAndViewMessage("");
|
||||
}
|
||||
|
||||
private void comboBoxServerItemSelected(ItemEvent evt) {
|
||||
if (jComboBoxServer.isEnabled()) {
|
||||
cardImageSource = ((DownloadSources) evt.getItem()).getSource();
|
||||
// update the available sets / token comboBox
|
||||
jComboBoxSet.setModel(new DefaultComboBoxModel<>(getSetsForCurrentImageSource()));
|
||||
updateCardsToDownload(jComboBoxSet.getSelectedItem().toString());
|
||||
private void reloadLanguagesForSelectedSource() {
|
||||
this.uiDialog.showLanguagesSupport(selectedSource != null && selectedSource.isLanguagesSupport());
|
||||
}
|
||||
|
||||
private void reloadSetsForSelectedSource() {
|
||||
// update the available sets / token combobox
|
||||
Object oldSelection = this.uiDialog.getSetsCombo().getSelectedItem();
|
||||
this.uiDialog.getSetsCombo().setModel(new DefaultComboBoxModel<>(getSetsForCurrentImageSource()));
|
||||
if (oldSelection != null) {
|
||||
this.uiDialog.getSetsCombo().setSelectedItem(oldSelection);
|
||||
}
|
||||
reloadCardsToDownload(this.uiDialog.getSetsCombo().getSelectedItem().toString());
|
||||
}
|
||||
|
||||
private void comboboxSourceSelected(ItemEvent evt) {
|
||||
if (this.uiDialog.getSourcesCombo().isEnabled()) {
|
||||
selectedSource = ((DownloadSources) evt.getItem()).getSource();
|
||||
reloadSetsForSelectedSource();
|
||||
reloadLanguagesForSelectedSource();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateAndViewMessage(String text) {
|
||||
jLabelMessage.setText(text);
|
||||
if (dialog != null) {
|
||||
dialog.pack();
|
||||
dialog.validate();
|
||||
dialog.repaint();
|
||||
this.uiDialog.setGlobalInfo(text);
|
||||
|
||||
// auto-size on empty message (on complete)
|
||||
if (text.isEmpty()) {
|
||||
this.uiDialog.showDownloadControls(true);
|
||||
}
|
||||
}
|
||||
|
||||
private String getSetNameWithYear(ExpansionSet exp) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(exp.getReleaseDate());
|
||||
String year = String.valueOf(cal.get(Calendar.YEAR));
|
||||
|
||||
if (!exp.getName().contains(year)) {
|
||||
return exp.getName() + " (" + year + ")";
|
||||
} else {
|
||||
return exp.getName();
|
||||
}
|
||||
}
|
||||
|
||||
private ExpansionSet findSetByNameWithYear(String name) {
|
||||
return Sets.getInstance().values().stream()
|
||||
.filter(exp -> getSetNameWithYear(exp).equals(name))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
private Object[] getSetsForCurrentImageSource() {
|
||||
// Set the available sets to the combo box
|
||||
ArrayList<String> supportedSets = cardImageSource.getSupportedSets();
|
||||
ArrayList<String> supportedSets = selectedSource.getSupportedSets();
|
||||
List<String> setNames = new ArrayList<>();
|
||||
if (supportedSets != null) {
|
||||
setNames.add(ALL_IMAGES);
|
||||
setNames.add(ALL_STANDARD_IMAGES);
|
||||
}
|
||||
if (cardImageSource.isTokenSource()) {
|
||||
|
||||
// multiple sets selection
|
||||
setNames.add(ALL_IMAGES);
|
||||
setNames.add(ALL_MODERN_IMAGES);
|
||||
setNames.add(ALL_STANDARD_IMAGES);
|
||||
if (selectedSource.isTokenSource()) {
|
||||
setNames.add(ALL_TOKENS);
|
||||
}
|
||||
if (supportedSets != null) {
|
||||
for (String setCode : supportedSets) {
|
||||
ExpansionSet expansionSet = Sets.findSet(setCode);
|
||||
if (expansionSet != null) {
|
||||
setNames.add(expansionSet.getName());
|
||||
} else {
|
||||
logger.warn("Source: " + cardImageSource.getSourceName() + ": Expansion set for code " + setCode + " not found in xmage sets!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// single set selection
|
||||
Collection<ExpansionSet> dbSets = Sets.getInstance().values();
|
||||
Collection<String> comboSets = dbSets.stream()
|
||||
.filter(exp -> supportedSets.contains(exp.getCode()))
|
||||
.sorted(Comparator.comparing(ExpansionSet::getReleaseDate).reversed())
|
||||
.map(this::getSetNameWithYear)
|
||||
.collect(Collectors.toList());
|
||||
setNames.addAll(comboSets);
|
||||
|
||||
if (setNames.isEmpty()) {
|
||||
logger.error("Source " + cardImageSource.getSourceName() + " creates no selectable items.");
|
||||
setNames.add("not avalable");
|
||||
logger.error("Source " + selectedSource.getSourceName() + " creates no selectable items.");
|
||||
setNames.add("not available");
|
||||
}
|
||||
return setNames.toArray(new String[0]);
|
||||
}
|
||||
|
||||
private void updateCardsToDownload(String itemText) {
|
||||
selectedSetCodes.clear();
|
||||
switch (itemText) {
|
||||
private void reloadCardsToDownload(String selectedItem) {
|
||||
// find selected sets
|
||||
selectedSets.clear();
|
||||
List<String> formatSets;
|
||||
List<String> sourceSets = selectedSource.getSupportedSets();
|
||||
switch (selectedItem) {
|
||||
|
||||
case ALL_IMAGES:
|
||||
if (cardImageSource.getSupportedSets() == null) {
|
||||
selectedSetCodes = cardImageSource.getSupportedSets();
|
||||
} else {
|
||||
selectedSetCodes.addAll(cardImageSource.getSupportedSets());
|
||||
}
|
||||
selectedSets.addAll(selectedSource.getSupportedSets());
|
||||
break;
|
||||
|
||||
case ALL_STANDARD_IMAGES:
|
||||
List<String> standardSets = ConstructedFormats.getSetsByFormat(ConstructedFormats.STANDARD);
|
||||
for (String setCode : cardImageSource.getSupportedSets()) {
|
||||
if (standardSets.contains(setCode)) {
|
||||
selectedSetCodes.add(setCode);
|
||||
} else {
|
||||
logger.debug("Set code " + setCode + " from download source " + cardImageSource.getSourceName());
|
||||
}
|
||||
}
|
||||
formatSets = ConstructedFormats.getSetsByFormat(ConstructedFormats.STANDARD);
|
||||
formatSets.stream()
|
||||
.filter(sourceSets::contains)
|
||||
.forEachOrdered(selectedSets::add);
|
||||
break;
|
||||
|
||||
case ALL_MODERN_IMAGES:
|
||||
formatSets = ConstructedFormats.getSetsByFormat(ConstructedFormats.MODERN);
|
||||
formatSets.stream()
|
||||
.filter(sourceSets::contains)
|
||||
.forEachOrdered(selectedSets::add);
|
||||
break;
|
||||
|
||||
case ALL_TOKENS:
|
||||
break;
|
||||
|
||||
default:
|
||||
int nonSetEntries = 0;
|
||||
if (cardImageSource.getSupportedSets() != null) {
|
||||
nonSetEntries = 2;
|
||||
// selects one set
|
||||
ExpansionSet selectedExp = findSetByNameWithYear(selectedItem);
|
||||
if (selectedExp != null) {
|
||||
selectedSets.add(selectedExp.getCode());
|
||||
}
|
||||
if (cardImageSource.isTokenSource()) {
|
||||
nonSetEntries++;
|
||||
}
|
||||
selectedSetCodes.add(cardImageSource.getSupportedSets().get(jComboBoxSet.getSelectedIndex() - nonSetEntries));
|
||||
break;
|
||||
}
|
||||
|
||||
// find missing cards to download
|
||||
cardsToDownload.clear();
|
||||
int numberTokenImagesAvailable = 0;
|
||||
int numberCardImagesAvailable = 0;
|
||||
for (CardDownloadData data : allCardsMissingImage) {
|
||||
for (CardDownloadData data : cardsMissing) {
|
||||
if (data.isToken()) {
|
||||
if (cardImageSource.isTokenSource() && cardImageSource.isImageProvided(data.getSet(), data.getName())) {
|
||||
if (selectedSource.isTokenSource() && selectedSource.isImageProvided(data.getSet(), data.getName())) {
|
||||
numberTokenImagesAvailable++;
|
||||
cardsToDownload.add(data);
|
||||
} else {
|
||||
//logger.warn("Source do not support token (set " + data.getSet() + ", token " + data.getName() + ")");
|
||||
}
|
||||
} else {
|
||||
if (selectedSetCodes != null && selectedSetCodes.contains(data.getSet())) {
|
||||
if (cardImageSource.isSetSupportedComplete(data.getSet()) || cardImageSource.isImageProvided(data.getSet(), data.getName())) {
|
||||
if (selectedSets != null && selectedSets.contains(data.getSet())) {
|
||||
if (selectedSource.isSetSupportedComplete(data.getSet()) || selectedSource.isImageProvided(data.getSet(), data.getName())) {
|
||||
numberCardImagesAvailable++;
|
||||
cardsToDownload.add(data);
|
||||
}
|
||||
|
@ -363,24 +327,28 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
updateProgressText(numberCardImagesAvailable, numberTokenImagesAvailable);
|
||||
}
|
||||
|
||||
private void comboBoxSetItemSelected(ItemEvent event) {
|
||||
private void comboboxSetSelected(ItemEvent event) {
|
||||
// Update the cards to download related to the selected set
|
||||
updateCardsToDownload(event.getItem().toString());
|
||||
reloadCardsToDownload(event.getItem().toString());
|
||||
}
|
||||
|
||||
private void updateProgressText(int cardCount, int tokenCount) {
|
||||
missingTokens = 0;
|
||||
for (CardDownloadData card : allCardsMissingImage) {
|
||||
missingTokensCount = 0;
|
||||
for (CardDownloadData card : cardsMissing) {
|
||||
if (card.isToken()) {
|
||||
missingTokens++;
|
||||
missingTokensCount++;
|
||||
}
|
||||
}
|
||||
missingCards = allCardsMissingImage.size() - missingTokens;
|
||||
jLabelAllMissing.setText("Missing: " + missingCards + " card images / " + missingTokens + " token images");
|
||||
missingCardsCount = cardsMissing.size() - missingTokensCount;
|
||||
uiDialog.setCurrentInfo("Missing: " + missingCardsCount + " card images / " + missingTokensCount + " token images");
|
||||
int imageSum = cardCount + tokenCount;
|
||||
float mb = (imageSum * cardImageSource.getAverageSize()) / 1024;
|
||||
bar.setString(String.format(cardIndex == imageSum ? "%d of %d (%d cards/%d tokens) image downloads finished! Please close!"
|
||||
: "%d of %d (%d cards/%d tokens) image downloads finished! Please wait! [%.1f Mb]", 0, imageSum, cardCount, tokenCount, mb));
|
||||
float mb = (imageSum * selectedSource.getAverageSize()) / 1024;
|
||||
uiDialog.getProgressBar().setString(String.format(
|
||||
cardIndex == imageSum
|
||||
? "%d of %d (%d cards/%d tokens) image downloads finished! Please close!"
|
||||
: "%d of %d (%d cards/%d tokens) image downloads finished! Please wait! [%.1f Mb]",
|
||||
0, imageSum, cardCount, tokenCount, mb
|
||||
));
|
||||
}
|
||||
|
||||
private static String createDownloadName(CardInfo card) {
|
||||
|
@ -479,8 +447,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
|
||||
public static ArrayList<CardDownloadData> getTokenCardUrls() throws RuntimeException {
|
||||
ArrayList<CardDownloadData> list = new ArrayList<>();
|
||||
InputStream in = DownloadPictures.class
|
||||
.getClassLoader().getResourceAsStream("card-pictures-tok.txt");
|
||||
InputStream in = DownloadPicturesService.class.getClassLoader().getResourceAsStream("card-pictures-tok.txt");
|
||||
|
||||
if (in == null) {
|
||||
logger.error("resources input stream is null");
|
||||
|
@ -545,7 +512,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
|
||||
} catch (Exception ex) {
|
||||
logger.error(ex);
|
||||
throw new RuntimeException("DownloadPictures : readFile() error");
|
||||
throw new RuntimeException("DownloadPicturesService : readFile() error");
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
@ -581,7 +548,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
Integer port = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_PROXY_PORT, "80"));
|
||||
p = new Proxy(type, new InetSocketAddress(address, port));
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException("Gui_DownloadPictures : error 1 - " + ex);
|
||||
throw new RuntimeException("Gui_DownloadPicturesService : error 1 - " + ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -589,11 +556,13 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
HashSet<String> ignoreUrls = SettingsManager.getIntance().getIgnoreUrls();
|
||||
|
||||
update(0, cardsToDownload.size());
|
||||
logger.info("Started download of " + cardsToDownload.size() + " images from source: " + cardImageSource.getSourceName());
|
||||
logger.info("Started download of " + cardsToDownload.size()
|
||||
+ " images from source: " + selectedSource.getSourceName()
|
||||
+ ", language: " + selectedSource.getCurrentLanguage().getCode());
|
||||
|
||||
int numberOfThreads = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_THREADS, "10"));
|
||||
ExecutorService executor = Executors.newFixedThreadPool(numberOfThreads);
|
||||
for (int i = 0; i < cardsToDownload.size() && !cancel; i++) {
|
||||
for (int i = 0; i < cardsToDownload.size() && !this.getNeedCancel(); i++) {
|
||||
try {
|
||||
|
||||
CardDownloadData card = cardsToDownload.get(i);
|
||||
|
@ -606,24 +575,24 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
if (!"0".equals(card.getCollectorId())) {
|
||||
continue;
|
||||
}
|
||||
urls = cardImageSource.generateTokenUrl(card);
|
||||
urls = selectedSource.generateTokenUrl(card);
|
||||
} else {
|
||||
urls = cardImageSource.generateURL(card);
|
||||
urls = selectedSource.generateURL(card);
|
||||
}
|
||||
|
||||
if (urls == null) {
|
||||
String imageRef = cardImageSource.getNextHttpImageUrl();
|
||||
String fileName = cardImageSource.getFileForHttpImage(imageRef);
|
||||
String imageRef = selectedSource.getNextHttpImageUrl();
|
||||
String fileName = selectedSource.getFileForHttpImage(imageRef);
|
||||
if (imageRef != null && fileName != null) {
|
||||
imageRef = cardImageSource.getSourceName() + imageRef;
|
||||
imageRef = selectedSource.getSourceName() + imageRef;
|
||||
try {
|
||||
card.setToken(cardImageSource.isTokenSource());
|
||||
Runnable task = new DownloadTask(card, imageRef, fileName, cardImageSource.getTotalImages());
|
||||
card.setToken(selectedSource.isTokenSource());
|
||||
Runnable task = new DownloadTask(card, imageRef, fileName, selectedSource.getTotalImages());
|
||||
executor.execute(task);
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
} else if (cardImageSource.getTotalImages() == -1) {
|
||||
logger.info("Image not available on " + cardImageSource.getSourceName() + ": " + card.getName() + " (" + card.getSet() + ')');
|
||||
} else if (selectedSource.getTotalImages() == -1) {
|
||||
logger.info("Image not available on " + selectedSource.getSourceName() + ": " + card.getName() + " (" + card.getSet() + ')');
|
||||
synchronized (sync) {
|
||||
update(cardIndex + 1, cardsToDownload.size());
|
||||
}
|
||||
|
@ -653,11 +622,10 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
} finally {
|
||||
//
|
||||
}
|
||||
closeButton.setText("Close");
|
||||
updateCardsToDownload(jComboBoxSet.getSelectedItem().toString());
|
||||
reloadCardsToDownload(uiDialog.getSetsCombo().getSelectedItem().toString());
|
||||
}
|
||||
|
||||
static String convertStreamToString(java.io.InputStream is) {
|
||||
static String convertStreamToString(InputStream is) {
|
||||
java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A");
|
||||
return s.hasNext() ? s.next() : "";
|
||||
}
|
||||
|
@ -692,7 +660,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
if (cancel) {
|
||||
if (DownloadPicturesService.getInstance().getNeedCancel()) {
|
||||
synchronized (sync) {
|
||||
update(cardIndex + 1, count);
|
||||
}
|
||||
|
@ -773,12 +741,12 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
URL url = new URL(currentUrl);
|
||||
|
||||
// on download cancel need to stop
|
||||
if (cancel) {
|
||||
if (DownloadPicturesService.getInstance().getNeedCancel()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// download
|
||||
cardImageSource.doPause(url.getPath());
|
||||
selectedSource.doPause(url.getPath());
|
||||
httpConn = url.openConnection(p);
|
||||
httpConn.setRequestProperty("User-Agent", "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9.2.2) Gecko/20100316 Firefox/3.6.2");
|
||||
httpConn.connect();
|
||||
|
@ -819,7 +787,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
int len;
|
||||
while ((len = in.read(buf)) != -1) {
|
||||
// user cancelled
|
||||
if (cancel) {
|
||||
if (DownloadPicturesService.getInstance().getNeedCancel()) {
|
||||
// stop download, save current state and exit
|
||||
TFile archive = destFile.getTopLevelArchive();
|
||||
///* not need to unmout/close - it's auto action
|
||||
|
@ -885,12 +853,12 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
this.cardIndex = card;
|
||||
|
||||
if (cardIndex < count) {
|
||||
float mb = ((count - card) * cardImageSource.getAverageSize()) / 1024;
|
||||
bar.setString(String.format("%d of %d image downloads finished! Please wait! [%.1f Mb]",
|
||||
float mb = ((count - card) * selectedSource.getAverageSize()) / 1024;
|
||||
uiDialog.getProgressBar().setString(String.format("%d of %d image downloads finished! Please wait! [%.1f Mb]",
|
||||
card, count, mb));
|
||||
} else {
|
||||
List<CardDownloadData> remainingCards = Collections.synchronizedList(new ArrayList<>());
|
||||
DownloadPictures.this.allCardsMissingImage.parallelStream().forEach(cardDownloadData -> {
|
||||
DownloadPicturesService.this.cardsMissing.parallelStream().forEach(cardDownloadData -> {
|
||||
TFile file = new TFile(CardImageUtils.buildImagePathToCard(cardDownloadData));
|
||||
if (!file.exists()) {
|
||||
remainingCards.add(cardDownloadData);
|
||||
|
@ -898,16 +866,16 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
});
|
||||
|
||||
// remove the cards not downloaded to get the siccessfull downloaded cards
|
||||
DownloadPictures.this.cardsToDownload.removeAll(remainingCards);
|
||||
DownloadPictures.this.allCardsMissingImage.removeAll(DownloadPictures.this.cardsToDownload);
|
||||
DownloadPicturesService.this.cardsToDownload.removeAll(remainingCards);
|
||||
DownloadPicturesService.this.cardsMissing.removeAll(DownloadPicturesService.this.cardsToDownload);
|
||||
|
||||
count = remainingCards.size();
|
||||
|
||||
if (count == 0) {
|
||||
bar.setString("0 images remaining! Please close!");
|
||||
uiDialog.getProgressBar().setString("0 images remaining! Please close!");
|
||||
} else {
|
||||
// bar.setString(String.format("%d cards remaining! Please choose another source!", count));
|
||||
startDownloadButton.setEnabled(true);
|
||||
//bar.setString(String.format("%d cards remaining! Please choose another source!", count));
|
||||
uiDialog.getStartButton().setEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -916,22 +884,21 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
|
||||
}
|
||||
|
||||
class LoadMissingCardData implements Runnable {
|
||||
class LoadMissingCardDataNew implements Runnable {
|
||||
|
||||
private static DownloadPictures downloadPictures;
|
||||
private static DownloadPicturesService downloadPicturesService;
|
||||
|
||||
public LoadMissingCardData(DownloadPictures downloadPictures) {
|
||||
LoadMissingCardData.downloadPictures = downloadPictures;
|
||||
public LoadMissingCardDataNew(DownloadPicturesService downloadPicturesService) {
|
||||
this.downloadPicturesService = downloadPicturesService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
downloadPictures.setAllMissingCards();
|
||||
downloadPicturesService.setAllMissingCards();
|
||||
}
|
||||
|
||||
public static void main() {
|
||||
|
||||
(new Thread(new LoadMissingCardData(downloadPictures))).start();
|
||||
(new Thread(new LoadMissingCardDataNew(downloadPicturesService))).start();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue