|
|
@ -86,12 +86,14 @@ public class DownloadOnlineSourcesHelper implements DownloadSourcesEvent { |
|
|
|
initDialog(); |
|
|
|
initDialog(); |
|
|
|
|
|
|
|
|
|
|
|
dialog.addWindowListener(new WindowAdapter() { |
|
|
|
dialog.addWindowListener(new WindowAdapter() { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void windowClosing(WindowEvent e) { |
|
|
|
public void windowClosing(WindowEvent e) { |
|
|
|
//取消下载
|
|
|
|
//取消下载
|
|
|
|
result = false; |
|
|
|
result = false; |
|
|
|
exitDialog(); |
|
|
|
exitDialog(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void windowOpened(WindowEvent e) { |
|
|
|
public void windowOpened(WindowEvent e) { |
|
|
|
downloadAndInstallPluginDependenceFile(); |
|
|
|
downloadAndInstallPluginDependenceFile(); |
|
|
|
exitDialog(); |
|
|
|
exitDialog(); |
|
|
@ -119,11 +121,11 @@ public class DownloadOnlineSourcesHelper implements DownloadSourcesEvent { |
|
|
|
|
|
|
|
|
|
|
|
httpClient = new HttpClient(CloudCenter.getInstance().acquireUrlByKind(siteInfo.siteKind)); |
|
|
|
httpClient = new HttpClient(CloudCenter.getInstance().acquireUrlByKind(siteInfo.siteKind)); |
|
|
|
if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) { |
|
|
|
if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) { |
|
|
|
InputStream reader = httpClient.getResponseStream(); |
|
|
|
|
|
|
|
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); |
|
|
|
FileOutputStream writer = new FileOutputStream(temp); |
|
|
|
try (InputStream reader = httpClient.getResponseStream(); |
|
|
|
|
|
|
|
FileOutputStream writer = new FileOutputStream(temp)) { |
|
|
|
byte[] buffer = new byte[PluginConstants.BYTES_NUM]; |
|
|
|
byte[] buffer = new byte[PluginConstants.BYTES_NUM]; |
|
|
|
int bytesRead; |
|
|
|
int bytesRead; |
|
|
|
while ((bytesRead = reader.read(buffer)) > 0 && result) { |
|
|
|
while ((bytesRead = reader.read(buffer)) > 0 && result) { |
|
|
@ -133,11 +135,8 @@ public class DownloadOnlineSourcesHelper implements DownloadSourcesEvent { |
|
|
|
currentBytesRead += bytesRead; |
|
|
|
currentBytesRead += bytesRead; |
|
|
|
setProgress(currentBytesRead); |
|
|
|
setProgress(currentBytesRead); |
|
|
|
} |
|
|
|
} |
|
|
|
reader.close(); |
|
|
|
|
|
|
|
writer.flush(); |
|
|
|
writer.flush(); |
|
|
|
writer.close(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (result) { |
|
|
|
if (result) { |
|
|
|
//安装文件
|
|
|
|
//安装文件
|
|
|
|
IOUtils.unZipFilesGBK(temp, StableUtils.pathJoin(WorkContext.getCurrent().getPath(), siteInfo.localDir)); |
|
|
|
IOUtils.unZipFilesGBK(temp, StableUtils.pathJoin(WorkContext.getCurrent().getPath(), siteInfo.localDir)); |
|
|
|