Browse Source

Merge pull request #1010 in DESIGN/design from ~HADES/design:feature/10.0 to feature/10.0

* commit 'c9958151e0b8426bcec1ec0e2e93c7c35ad0e54e':
  update
  无jira sonar修复
research/10.0
Hades 5 years ago
parent
commit
ec34d44831
  1. 13
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java
  2. 7
      designer-base/src/main/java/com/fr/design/update/actions/FileDownloader.java
  3. 9
      designer-base/src/main/java/com/fr/design/update/factory/DirectoryOperationFactory.java
  4. 11
      designer-base/src/main/java/com/fr/design/update/ui/dialog/EncodingDetect.java
  5. 8
      designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java
  6. 17
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java
  7. 18
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java
  8. 16
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SegmentationManager.java
  9. 18
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManager.java

13
designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java

@ -41,17 +41,12 @@ public class HistoryTemplateListCache implements CallbackEvent {
private List<JTemplate<?, ?>> historyList;
private JTemplate<?, ?> editingTemplate;
private static volatile HistoryTemplateListCache instacne;
public static HistoryTemplateListCache getInstance() {
if (instacne == null) {
synchronized (HistoryTemplateListCache.class) {
if (instacne == null) {
instacne = new HistoryTemplateListCache();
}
return Holder.INSTANCE;
}
}
return instacne;
private static class Holder {
private static final HistoryTemplateListCache INSTANCE = new HistoryTemplateListCache();
}
private HistoryTemplateListCache() {

7
designer-base/src/main/java/com/fr/design/update/actions/FileDownloader.java

@ -80,10 +80,10 @@ public abstract class FileDownloader extends SwingWorker<Boolean, DownloadItem>
URLConnection connection = url.openConnection();
int total = connection.getContentLength();
item.setTotalLength(total);
InputStream reader = connection.getInputStream();
File tempFile = new File(StableUtils.pathJoin(saveDir, item.getName()));
StableUtils.makesureFileExist(tempFile);
FileOutputStream writer = new FileOutputStream(tempFile);
try ( InputStream reader = connection.getInputStream();
FileOutputStream writer = new FileOutputStream(tempFile)) {
byte[] buffer = new byte[UpdateConstants.BYTE];
int bytesRead = 0;
int totalBytesRead = 0;
@ -94,8 +94,7 @@ public abstract class FileDownloader extends SwingWorker<Boolean, DownloadItem>
item.setDownloadLength(totalBytesRead);
publish(item);
}
reader.close();
writer.close();
}
}
/**

9
designer-base/src/main/java/com/fr/design/update/factory/DirectoryOperationFactory.java

@ -82,15 +82,12 @@ public class DirectoryOperationFactory {
}
private static void copy(String path1, String path2) throws IOException {
DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(path1)));
DataOutputStream out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(path2)));
try (DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(path1)));
DataOutputStream out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(path2)))) {
byte[] date = new byte[in.available()];
in.read(date);
out.write(date);
in.close();
out.close();
}
}
/**

11
designer-base/src/main/java/com/fr/design/update/ui/dialog/EncodingDetect.java

@ -1,5 +1,6 @@
package com.fr.design.update.ui.dialog;
import com.fr.log.FineLoggerFactory;
import java.io.File;
import java.io.FileInputStream;
@ -75,15 +76,11 @@ class BytesEncodingDetect extends Encoding {
* type. The encoding type with the highest probability is returned.
*/
public int detectEncoding(File testfile) {
FileInputStream chinesefile;
byte[] rawtext;
rawtext = new byte[(int) testfile.length()];
try {
chinesefile = new FileInputStream(testfile);
byte[] rawtext = new byte[(int) testfile.length()];
try (FileInputStream chinesefile = new FileInputStream(testfile)) {
chinesefile.read(rawtext);
chinesefile.close();
} catch (Exception e) {
System.err.println("Error: " + e);
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return detectEncoding(rawtext);
}

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

@ -468,10 +468,9 @@ public class UpdateMainDialog extends UIDialog {
return;
}
if (cacheFile.exists()) {
InputStreamReader streamReader = new InputStreamReader(new FileInputStream(cacheFile), "UTF-8");
BufferedReader br = new BufferedReader(streamReader);
try (InputStreamReader streamReader = new InputStreamReader(new FileInputStream(cacheFile), "UTF-8");
BufferedReader br = new BufferedReader(streamReader)) {
String readStr, updateTimeStr;
while ((readStr = br.readLine()) != null) {
String[] updateInfo = readStr.split("\\t");
if (updateInfo.length == 2) {
@ -490,8 +489,7 @@ public class UpdateMainDialog extends UIDialog {
}
}
}
br.close();
streamReader.close();
}
}
}

17
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java

@ -27,21 +27,20 @@ import java.net.URLEncoder;
* Created by XiaXiang on 2017/3/27.
*/
public class PluginSearchManager implements AlphaFineSearchProvider {
private static volatile PluginSearchManager instance;
private SearchResult lessModelList;
private SearchResult moreModelList;
private PluginSearchManager() {
public static PluginSearchManager getInstance() {
if (instance == null) {
synchronized (PluginSearchManager.class) {
if (instance == null) {
instance = new PluginSearchManager();
}
}
public static PluginSearchManager getInstance() {
return Holder.INSTANCE;
}
return instance;
private static class Holder {
private static final PluginSearchManager INSTANCE = new PluginSearchManager();
}
private static boolean isCompatibleCurrentEnv(String envVersion) {
@ -105,7 +104,7 @@ public class PluginSearchManager implements AlphaFineSearchProvider {
lessModelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Plugin_Addon")));
return lessModelList;
}
SearchResult noConnectList = AlphaFineHelper.getNoConnectList(instance);
SearchResult noConnectList = AlphaFineHelper.getNoConnectList(Holder.INSTANCE);
if(noConnectList != null){
return noConnectList;
}

18
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java

@ -25,22 +25,22 @@ import java.util.List;
* Created by XiaXiang on 2017/3/31.
*/
public class RecommendSearchManager implements AlphaFineSearchProvider {
private static volatile RecommendSearchManager instance;
private SearchResult modelList = new SearchResult();
private SearchResult recommendModelList = new SearchResult();
private SearchResult complementAdviceModelList;
private SearchResult moreModelList = new SearchResult();
public static RecommendSearchManager getInstance() {
if (instance == null) {
synchronized (RecentSearchManager.class) {
if (instance == null) {
instance = new RecommendSearchManager();
}
private RecommendSearchManager() {
}
public static RecommendSearchManager getInstance() {
return Holder.INSTANCE;
}
return instance;
private static class Holder {
private static final RecommendSearchManager INSTANCE = new RecommendSearchManager();
}
@Override
@ -51,7 +51,7 @@ public class RecommendSearchManager implements AlphaFineSearchProvider {
if (ArrayUtils.isEmpty(searchText)) {
return new SearchResult();
}
SearchResult noConnectList = AlphaFineHelper.getNoConnectList(instance);
SearchResult noConnectList = AlphaFineHelper.getNoConnectList(Holder.INSTANCE);
if (noConnectList != null) {
return noConnectList;
}

16
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SegmentationManager.java

@ -13,18 +13,18 @@ import java.util.regex.Pattern;
* Created by alex.sung on 2018/8/3.
*/
public class SegmentationManager {
private static volatile SegmentationManager segmentationManager = null;
private static final int MAX_CHINESE_CHARACTERS_NUM = 4;
public static SegmentationManager getInstance() {
if (segmentationManager == null) {
synchronized (SegmentationManager.class) {
if (segmentationManager == null) {
segmentationManager = new SegmentationManager();
}
private SegmentationManager() {
}
public static SegmentationManager getInstance() {
return Holder.INSTANCE;
}
return segmentationManager;
private static class Holder {
private static final SegmentationManager INSTANCE = new SegmentationManager();
}
/**

18
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManager.java

@ -18,19 +18,19 @@ import com.fr.third.org.apache.commons.codec.digest.DigestUtils;
* Created by alex.sung on 2018/8/3.
*/
public class SimilarSearchManager implements AlphaFineSearchProvider {
private static volatile SimilarSearchManager instance;
private SearchResult lessModelList;
private SearchResult moreModelList = new SearchResult();
public static SimilarSearchManager getInstance() {
if (instance == null) {
synchronized (SimilarSearchManager.class) {
if (instance == null) {
instance = new SimilarSearchManager();
}
private SimilarSearchManager() {
}
public static SimilarSearchManager getInstance() {
return Holder.INSTANCE;
}
return instance;
private static class Holder {
private static final SimilarSearchManager INSTANCE = new SimilarSearchManager();
}
@Override
@ -40,7 +40,7 @@ public class SimilarSearchManager implements AlphaFineSearchProvider {
if (ArrayUtils.isEmpty(searchText)) {
return new SearchResult();
}
SearchResult noConnectList = AlphaFineHelper.getNoConnectList(instance);
SearchResult noConnectList = AlphaFineHelper.getNoConnectList(Holder.INSTANCE);
if (noConnectList != null) {
return noConnectList;
}

Loading…
Cancel
Save