|
|
@ -5,9 +5,12 @@ import com.fr.design.RestartHelper; |
|
|
|
import com.fr.design.dialog.FineJOptionPane; |
|
|
|
import com.fr.design.dialog.FineJOptionPane; |
|
|
|
import com.fr.design.extra.PluginConstants; |
|
|
|
import com.fr.design.extra.PluginConstants; |
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
|
|
|
|
import com.fr.design.i18n.Toolkit; |
|
|
|
|
|
|
|
import com.fr.design.utils.DesignUtils; |
|
|
|
import com.fr.design.utils.gui.GUICoreUtils; |
|
|
|
import com.fr.design.utils.gui.GUICoreUtils; |
|
|
|
import com.fr.general.CloudCenter; |
|
|
|
import com.fr.general.CloudCenter; |
|
|
|
import com.fr.general.IOUtils; |
|
|
|
import com.fr.general.IOUtils; |
|
|
|
|
|
|
|
import com.fr.general.SiteBlockedException; |
|
|
|
import com.fr.general.http.HttpClient; |
|
|
|
import com.fr.general.http.HttpClient; |
|
|
|
import com.fr.plugin.chart.DownloadSourcesEvent; |
|
|
|
import com.fr.plugin.chart.DownloadSourcesEvent; |
|
|
|
import com.fr.stable.CommonUtils; |
|
|
|
import com.fr.stable.CommonUtils; |
|
|
@ -20,6 +23,8 @@ import javax.swing.JFrame; |
|
|
|
import javax.swing.JOptionPane; |
|
|
|
import javax.swing.JOptionPane; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.JProgressBar; |
|
|
|
import javax.swing.JProgressBar; |
|
|
|
|
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
|
|
|
|
import java.awt.event.ActionListener; |
|
|
|
import java.io.File; |
|
|
|
import java.io.File; |
|
|
|
import java.io.FileOutputStream; |
|
|
|
import java.io.FileOutputStream; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.io.InputStream; |
|
|
@ -33,6 +38,8 @@ import java.awt.event.WindowAdapter; |
|
|
|
import java.awt.event.WindowEvent; |
|
|
|
import java.awt.event.WindowEvent; |
|
|
|
import java.awt.image.BufferedImage; |
|
|
|
import java.awt.image.BufferedImage; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static com.fr.design.dialog.FineJOptionPane.OPTION_OK_CANCEL; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Created by shine on 2017/8/21. |
|
|
|
* Created by shine on 2017/8/21. |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -69,7 +76,23 @@ public class DownloadOnlineSourcesHelper implements DownloadSourcesEvent { |
|
|
|
//本地有这个资源,不下载
|
|
|
|
//本地有这个资源,不下载
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
httpClient = new HttpClient(CloudCenter.getInstance().acquireUrlByKind(siteKind)); |
|
|
|
try { |
|
|
|
|
|
|
|
httpClient = new HttpClient(CloudCenter.getInstance().acquireUrlByKind(siteKind)); |
|
|
|
|
|
|
|
} catch (SiteBlockedException e) { |
|
|
|
|
|
|
|
FineJOptionPane.showConfirmDialogWithOkListener(null, |
|
|
|
|
|
|
|
e.getMessage(), |
|
|
|
|
|
|
|
Toolkit.i18nText("Fine-Design_Basic_Alert"), null, null, |
|
|
|
|
|
|
|
new ActionListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
|
|
|
|
DesignUtils.visitEnvServerByParameters( |
|
|
|
|
|
|
|
"#management/system/normal", |
|
|
|
|
|
|
|
null, |
|
|
|
|
|
|
|
null); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
if (httpClient.getResponseCode() != HttpURLConnection.HTTP_OK) { |
|
|
|
if (httpClient.getResponseCode() != HttpURLConnection.HTTP_OK) { |
|
|
|
//服务器连不上,不下载
|
|
|
|
//服务器连不上,不下载
|
|
|
|
return; |
|
|
|
return; |
|
|
@ -116,12 +139,22 @@ public class DownloadOnlineSourcesHelper implements DownloadSourcesEvent { |
|
|
|
private void downloadAndInstallPluginDependenceFile() { |
|
|
|
private void downloadAndInstallPluginDependenceFile() { |
|
|
|
try { |
|
|
|
try { |
|
|
|
double currentBytesRead = 0; |
|
|
|
double currentBytesRead = 0; |
|
|
|
|
|
|
|
result = false; |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < list.size(); i++) { |
|
|
|
for (int i = 0; i < list.size(); i++) { |
|
|
|
SiteInfo siteInfo = list.get(i); |
|
|
|
SiteInfo siteInfo = list.get(i); |
|
|
|
|
|
|
|
try { |
|
|
|
httpClient = new HttpClient(CloudCenter.getInstance().acquireUrlByKind(siteInfo.siteKind)); |
|
|
|
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) { |
|
|
|
if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) { |
|
|
|
|
|
|
|
result = true; |
|
|
|
String temp = StableUtils.pathJoin(PluginConstants.DOWNLOAD_PATH, PluginConstants.TEMP_FILE); |
|
|
|
String temp = StableUtils.pathJoin(PluginConstants.DOWNLOAD_PATH, PluginConstants.TEMP_FILE); |
|
|
|
File file = new File(temp); |
|
|
|
File file = new File(temp); |
|
|
|
StableUtils.makesureFileExist(file); |
|
|
|
StableUtils.makesureFileExist(file); |
|
|
|