Browse Source

冲突

research/10.0
zack 5 years ago
parent
commit
70a4c79a8f
  1. 9
      designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java
  2. 4
      designer-base/src/main/java/com/fr/design/utils/DesignUtils.java
  3. 11
      designer-chart/src/main/java/com/fr/van/chart/DownloadOnlineSourcesHelper.java
  4. 15
      designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java

9
designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java

@ -35,6 +35,7 @@ import com.fr.json.JSONArray;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.EncodeConstants;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -513,16 +514,15 @@ public class UpdateMainDialog extends UIDialog {
if (endTime.equals(lastUpdateCacheTime) || jsonArray.length() == 0 || ComparatorUtils.compare(endTime, lastUpdateCacheTime) <= 0) { if (endTime.equals(lastUpdateCacheTime) || jsonArray.length() == 0 || ComparatorUtils.compare(endTime, lastUpdateCacheTime) <= 0) {
return; return;
} }
OutputStreamWriter writerStream = new OutputStreamWriter(new FileOutputStream(cacheFile), "UTF-8"); try (OutputStreamWriter writerStream = new OutputStreamWriter(new FileOutputStream(cacheFile), EncodeConstants.ENCODING_UTF_8);
BufferedWriter bufferWriter = new BufferedWriter(writerStream); BufferedWriter bufferWriter = new BufferedWriter(writerStream)) {
for (int i = 0; i < jsonArray.length(); i++) { for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jo = (JSONObject) jsonArray.get(i); JSONObject jo = (JSONObject) jsonArray.get(i);
bufferWriter.write((String) jo.get("update") + '\t' + jo.get("title")); bufferWriter.write((String) jo.get("update") + '\t' + jo.get("title"));
bufferWriter.newLine(); bufferWriter.newLine();
bufferWriter.flush(); bufferWriter.flush();
} }
bufferWriter.close(); }
writerStream.close();
lastUpdateCacheState = UPDATE_CACHE_STATE_SUCCESS; lastUpdateCacheState = UPDATE_CACHE_STATE_SUCCESS;
lastUpdateCacheTime = endTime; lastUpdateCacheTime = endTime;
cacheProperty.updateProperty("updateTime", lastUpdateCacheTime); cacheProperty.updateProperty("updateTime", lastUpdateCacheTime);
@ -634,6 +634,7 @@ public class UpdateMainDialog extends UIDialog {
/** /**
* 获取当前jar的md5 * 获取当前jar的md5
*
* @param currentJAR * @param currentJAR
* @return * @return
*/ */

4
designer-base/src/main/java/com/fr/design/utils/DesignUtils.java

@ -67,8 +67,7 @@ public class DesignUtils {
* @return 启动了返回true * @return 启动了返回true
*/ */
public static boolean isStarted() { public static boolean isStarted() {
try { try (Socket socket = new Socket("localhost", port)) {
new Socket("localhost", port);
return true; return true;
} catch (Exception ignored) { } catch (Exception ignored) {
} }
@ -116,6 +115,7 @@ public class DesignUtils {
* @param startPort 端口 * @param startPort 端口
* @param suffixs 文件后缀 * @param suffixs 文件后缀
*/ */
@SuppressWarnings("squid:S2095")
public static void createListeningServer(final int startPort, final String[] suffixs) { public static void createListeningServer(final int startPort, final String[] suffixs) {
ExecutorService service = Executors.newSingleThreadExecutor(new NamedThreadFactory("DesignClientListener")); ExecutorService service = Executors.newSingleThreadExecutor(new NamedThreadFactory("DesignClientListener"));
service.execute(new Runnable() { service.execute(new Runnable() {

11
designer-chart/src/main/java/com/fr/van/chart/DownloadOnlineSourcesHelper.java

@ -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));

15
designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java

@ -54,7 +54,6 @@ import java.util.concurrent.TimeUnit;
/** /**
* @author neil * @author neil
*
* @date: 2015-4-8-下午5:11:46 * @date: 2015-4-8-下午5:11:46
*/ */
public class InformationCollector implements XMLReadable, XMLWriter { public class InformationCollector implements XMLReadable, XMLWriter {
@ -253,24 +252,14 @@ public class InformationCollector implements XMLReadable, XMLWriter {
* 将文件内容写到输出流中 * 将文件内容写到输出流中
*/ */
private static void writeEncodeContentToFile(String fileContent, File file) { private static void writeEncodeContentToFile(String fileContent, File file) {
BufferedWriter bw = null; try (FileOutputStream fos = new FileOutputStream(file);
try {
FileOutputStream fos = new FileOutputStream(file);
OutputStreamWriter osw = new OutputStreamWriter(fos, EncodeConstants.ENCODING_UTF_8); OutputStreamWriter osw = new OutputStreamWriter(fos, EncodeConstants.ENCODING_UTF_8);
bw = new BufferedWriter(osw); BufferedWriter bw = new BufferedWriter(osw)) {
bw.write(fileContent); bw.write(fileContent);
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} finally {
if(bw != null){
try {
bw.close();
} catch (IOException e) {
} }
} }
}
}
@Override @Override
public void writeXML(XMLPrintWriter writer) { public void writeXML(XMLPrintWriter writer) {

Loading…
Cancel
Save