|
|
|
@ -5,9 +5,11 @@ import com.fr.design.RestartHelper;
|
|
|
|
|
import com.fr.design.dialog.FineJOptionPane; |
|
|
|
|
import com.fr.design.extra.PluginConstants; |
|
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
|
import com.fr.design.i18n.Toolkit; |
|
|
|
|
import com.fr.design.utils.gui.GUICoreUtils; |
|
|
|
|
import com.fr.general.CloudCenter; |
|
|
|
|
import com.fr.general.IOUtils; |
|
|
|
|
import com.fr.general.SiteBlockedException; |
|
|
|
|
import com.fr.general.http.HttpClient; |
|
|
|
|
import com.fr.plugin.chart.DownloadSourcesEvent; |
|
|
|
|
import com.fr.stable.CommonUtils; |
|
|
|
@ -33,6 +35,8 @@ import java.awt.event.WindowAdapter;
|
|
|
|
|
import java.awt.event.WindowEvent; |
|
|
|
|
import java.awt.image.BufferedImage; |
|
|
|
|
|
|
|
|
|
import static com.fr.design.dialog.FineJOptionPane.OPTION_OK_CANCEL; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Created by shine on 2017/8/21. |
|
|
|
|
*/ |
|
|
|
@ -69,7 +73,15 @@ public class DownloadOnlineSourcesHelper implements DownloadSourcesEvent {
|
|
|
|
|
//本地有这个资源,不下载
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
httpClient = new HttpClient(CloudCenter.getInstance().acquireUrlByKind(siteKind)); |
|
|
|
|
try { |
|
|
|
|
httpClient = new HttpClient(CloudCenter.getInstance().acquireUrlByKind(siteKind)); |
|
|
|
|
} catch (SiteBlockedException e) { |
|
|
|
|
FineJOptionPane.showConfirmDialog(null, |
|
|
|
|
e.getMessage(), |
|
|
|
|
Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.DEFAULT_OPTION, |
|
|
|
|
FineJOptionPane.WARNING_MESSAGE, null, OPTION_OK_CANCEL, null); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (httpClient.getResponseCode() != HttpURLConnection.HTTP_OK) { |
|
|
|
|
//服务器连不上,不下载
|
|
|
|
|
return; |
|
|
|
@ -116,12 +128,22 @@ public class DownloadOnlineSourcesHelper implements DownloadSourcesEvent {
|
|
|
|
|
private void downloadAndInstallPluginDependenceFile() { |
|
|
|
|
try { |
|
|
|
|
double currentBytesRead = 0; |
|
|
|
|
result = false; |
|
|
|
|
|
|
|
|
|
for (int i = 0; i < list.size(); i++) { |
|
|
|
|
SiteInfo siteInfo = list.get(i); |
|
|
|
|
|
|
|
|
|
httpClient = new HttpClient(CloudCenter.getInstance().acquireUrlByKind(siteInfo.siteKind)); |
|
|
|
|
try { |
|
|
|
|
httpClient = new HttpClient(CloudCenter.getInstance().acquireUrlByKind(siteInfo.siteKind)); |
|
|
|
|
} catch (SiteBlockedException e) { |
|
|
|
|
FineJOptionPane.showConfirmDialog(null, |
|
|
|
|
e.getMessage(), |
|
|
|
|
Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.DEFAULT_OPTION, |
|
|
|
|
FineJOptionPane.WARNING_MESSAGE, null, OPTION_OK_CANCEL, null); |
|
|
|
|
result = false; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) { |
|
|
|
|
result = true; |
|
|
|
|
String temp = StableUtils.pathJoin(PluginConstants.DOWNLOAD_PATH, PluginConstants.TEMP_FILE); |
|
|
|
|
File file = new File(temp); |
|
|
|
|
StableUtils.makesureFileExist(file); |
|
|
|
|