From 641290016ab2fbb27de6fbdbe72e99934c76f48e Mon Sep 17 00:00:00 2001 From: zack Date: Tue, 24 May 2022 16:40:36 +0800 Subject: [PATCH] =?UTF-8?q?INO-12903=20=E5=A4=96=E7=BD=91=E6=9D=83?= =?UTF-8?q?=E9=99=90=E7=BB=86=E7=B2=92=E5=BA=A6=E6=8E=A7=E5=88=B6-?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=8D=87=E7=BA=A7+=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E7=AE=A1=E7=90=86+=E5=9B=BE=E8=A1=A8=E8=B5=84=E6=BA=90=20?= =?UTF-8?q?=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../extra/exe/ReadUpdateOnlineExecutor.java | 11 ++++++++ .../update/ui/dialog/UpdateMainDialog.java | 13 ++++++++- .../chart/DownloadOnlineSourcesHelper.java | 28 +++++++++++++++++-- 3 files changed, 48 insertions(+), 4 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/ReadUpdateOnlineExecutor.java b/designer-base/src/main/java/com/fr/design/extra/exe/ReadUpdateOnlineExecutor.java index 739b84666d..f9e790103d 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/ReadUpdateOnlineExecutor.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/ReadUpdateOnlineExecutor.java @@ -1,15 +1,21 @@ package com.fr.design.extra.exe; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.extra.PluginsReaderFromStore; import com.fr.design.extra.Process; +import com.fr.design.i18n.Toolkit; +import com.fr.general.SiteBlockedException; import com.fr.json.JSONArray; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; import com.fr.plugin.view.PluginView; import com.fr.stable.StringUtils; +import javax.swing.JOptionPane; import java.util.List; +import static com.fr.design.dialog.FineJOptionPane.OPTION_OK_CANCEL; + /** * Created by vito on 16/4/19. */ @@ -41,6 +47,11 @@ public class ReadUpdateOnlineExecutor implements Executor { jsonArray.put(jsonObject); } result = jsonArray.toString(); + } catch (SiteBlockedException e1) { + FineJOptionPane.showConfirmDialog(null, + e1.getMessage(), + Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.DEFAULT_OPTION, + FineJOptionPane.WARNING_MESSAGE, null, OPTION_OK_CANCEL, null); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } diff --git a/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java b/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java index 9a849ad4e9..b770290d3c 100644 --- a/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java +++ b/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java @@ -56,6 +56,7 @@ import java.util.*; import java.util.List; import java.util.concurrent.ExecutionException; +import static com.fr.design.dialog.FineJOptionPane.OPTION_OK_CANCEL; import static java.nio.charset.StandardCharsets.*; import static javax.swing.JOptionPane.QUESTION_MESSAGE; @@ -350,7 +351,17 @@ public class UpdateMainDialog extends UIDialog { new SwingWorker() { @Override protected JSONObject doInBackground() throws Exception { - return new JSONObject(HttpToolbox.get(CloudCenter.getInstance().acquireUrlByKind("jar11.update"))); + try { + String url = CloudCenter.getInstance().acquireUrlByKind("jar11.update"); + return new JSONObject(HttpToolbox.get(url)); + } catch (SiteBlockedException e) { + stopLoading(); + FineJOptionPane.showConfirmDialog(null, + e.getMessage(), + Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.DEFAULT_OPTION, + FineJOptionPane.WARNING_MESSAGE, null, OPTION_OK_CANCEL, null); + } + return null; } @Override diff --git a/designer-chart/src/main/java/com/fr/van/chart/DownloadOnlineSourcesHelper.java b/designer-chart/src/main/java/com/fr/van/chart/DownloadOnlineSourcesHelper.java index 33dba72f9b..7fc8e7e5ad 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/DownloadOnlineSourcesHelper.java +++ b/designer-chart/src/main/java/com/fr/van/chart/DownloadOnlineSourcesHelper.java @@ -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);