Browse Source

无jira sonar修复

research/10.0
Hades 5 years ago
parent
commit
3b54e72008
  1. 15
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java
  2. 25
      designer-base/src/main/java/com/fr/design/update/actions/FileDownloader.java
  3. 15
      designer-base/src/main/java/com/fr/design/update/factory/DirectoryOperationFactory.java
  4. 31
      designer-base/src/main/java/com/fr/design/update/ui/dialog/EncodingDetect.java
  5. 38
      designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java
  6. 19
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java
  7. 20
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java
  8. 18
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SegmentationManager.java
  9. 20
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManager.java

15
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 instacne;
return Holder.INSTANCE;
}
private static class Holder {
private static final HistoryTemplateListCache INSTANCE = new HistoryTemplateListCache();
}
private HistoryTemplateListCache() {

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

@ -80,22 +80,21 @@ 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);
byte[] buffer = new byte[UpdateConstants.BYTE];
int bytesRead = 0;
int totalBytesRead = 0;
while ((bytesRead = reader.read(buffer)) != -1) {
writer.write(buffer, 0, bytesRead);
buffer = new byte[UpdateConstants.BYTE];
totalBytesRead += bytesRead;
item.setDownloadLength(totalBytesRead);
publish(item);
try ( InputStream reader = connection.getInputStream();
FileOutputStream writer = new FileOutputStream(tempFile)) {
byte[] buffer = new byte[UpdateConstants.BYTE];
int bytesRead = 0;
int totalBytesRead = 0;
while ((bytesRead = reader.read(buffer)) != -1) {
writer.write(buffer, 0, bytesRead);
buffer = new byte[UpdateConstants.BYTE];
totalBytesRead += bytesRead;
item.setDownloadLength(totalBytesRead);
publish(item);
}
}
reader.close();
writer.close();
}
/**

15
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)));
byte[] date = new byte[in.available()];
in.read(date);
out.write(date);
in.close();
out.close();
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);
}
}
/**

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

@ -11,12 +11,12 @@ import java.io.FileInputStream;
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* EncodingDetect.java<br>
* 自动获取文件的编码
* @author Mata
* @since Create on 2018-08-23
* @version 1.0
* @version 1.0
*/
public class EncodingDetect {
/**
@ -25,11 +25,11 @@ public class EncodingDetect {
* @return 文件的编码
*/
public static String getJavaEncode(File file){
BytesEncodingDetect s = new BytesEncodingDetect();
BytesEncodingDetect s = new BytesEncodingDetect();
String fileCode = BytesEncodingDetect.javaname[s.detectEncoding(file)];
return fileCode;
}
}
@ -75,17 +75,14 @@ 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);
chinesefile.read(rawtext);
chinesefile.close();
} catch (Exception e) {
System.err.println("Error: " + e);
}
return detectEncoding(rawtext);
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);
}
return detectEncoding(rawtext);
}
/**
@ -647,7 +644,7 @@ class BytesEncodingDetect extends Encoding {
* (byte)0xDF) == rawtext[i]) { // Two bytes if (i+1 < rawtextlen && (rawtext[i+1] & (byte)0xBF) == rawtext[i+1]) {
* goodbytes += 2; i++; } } else if ((rawtext[i] & (byte)0xEF) == rawtext[i]) { // Three bytes if (i+2 < rawtextlen &&
* (rawtext[i+1] & (byte)0xBF) == rawtext[i+1] && (rawtext[i+2] & (byte)0xBF) == rawtext[i+2]) { goodbytes += 3; i+=2; } } }
*
*
* score = (int)(100 * ((float)goodbytes/(float)rawtext.length)); // An all ASCII file is also a good UTF8 file, but I'd
* rather it // get identified as ASCII. Can delete following 3 lines otherwise if (goodbytes == asciibytes) { score = 0; } //
* If not above 90, reduce to zero to prevent coincidental matches if (score > 90) { return score; } else { return 0; }
@ -4551,5 +4548,5 @@ class BytesEncodingDetect extends Encoding {
nicename[ASCII] = "ASCII";
nicename[OTHER] = "OTHER";
}
}

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

@ -468,30 +468,28 @@ public class UpdateMainDialog extends UIDialog {
return;
}
if (cacheFile.exists()) {
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) {
updateTimeStr = updateInfo[0];
Date updateTime = CHANGELOG_FORMAT.parse(updateTimeStr);
//形如 Build#release-2018.07.31.03.03.52.80
String currentNO = GeneralUtils.readBuildNO();
Date curJarDate = UPDATE_INFO_TABLE_FORMAT.parse(currentNO, new ParsePosition(currentNO.indexOf("-") + 1));
if (!ComparatorUtils.equals(keyword, StringUtils.EMPTY)) {
if (!containsKeyword(UPDATE_INFO_TABLE_FORMAT.format(updateTime), keyword) && !containsKeyword(updateInfo[1], keyword)) {
continue;
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) {
updateTimeStr = updateInfo[0];
Date updateTime = CHANGELOG_FORMAT.parse(updateTimeStr);
//形如 Build#release-2018.07.31.03.03.52.80
String currentNO = GeneralUtils.readBuildNO();
Date curJarDate = UPDATE_INFO_TABLE_FORMAT.parse(currentNO, new ParsePosition(currentNO.indexOf("-") + 1));
if (!ComparatorUtils.equals(keyword, StringUtils.EMPTY)) {
if (!containsKeyword(UPDATE_INFO_TABLE_FORMAT.format(updateTime), keyword) && !containsKeyword(updateInfo[1], keyword)) {
continue;
}
}
if (isValidLogInfo(updateInfo[1])) {
updateInfoList.add(new Object[]{UPDATE_INFO_TABLE_FORMAT.format(updateTime), updateInfo[1], updateTime.after(curJarDate)});
}
}
if (isValidLogInfo(updateInfo[1])) {
updateInfoList.add(new Object[]{UPDATE_INFO_TABLE_FORMAT.format(updateTime), updateInfo[1], updateTime.after(curJarDate)});
}
}
}
br.close();
streamReader.close();
}
}

19
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();
}
}
}
return instance;
return Holder.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;
}

20
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();
private RecommendSearchManager() {
}
public static RecommendSearchManager getInstance() {
if (instance == null) {
synchronized (RecentSearchManager.class) {
if (instance == null) {
instance = new RecommendSearchManager();
}
}
}
return instance;
return Holder.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;
}

18
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;
private SegmentationManager() {
}
public static SegmentationManager getInstance() {
if (segmentationManager == null) {
synchronized (SegmentationManager.class) {
if (segmentationManager == null) {
segmentationManager = new SegmentationManager();
}
}
}
return segmentationManager;
return Holder.INSTANCE;
}
private static class Holder {
private static final SegmentationManager INSTANCE = new SegmentationManager();
}
/**

20
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();
private SimilarSearchManager() {
}
public static SimilarSearchManager getInstance() {
if (instance == null) {
synchronized (SimilarSearchManager.class) {
if (instance == null) {
instance = new SimilarSearchManager();
}
}
}
return instance;
return Holder.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