Browse Source

REPORT-27732

feature/big-screen
hades 5 years ago
parent
commit
a3b428bbf6
  1. 9
      designer-base/src/main/java/com/fr/file/FILEChooserPane.java
  2. 6
      designer-base/src/test/java/com/fr/file/FILEChooserPaneTest.java

9
designer-base/src/main/java/com/fr/file/FILEChooserPane.java

@ -502,13 +502,12 @@ public class FILEChooserPane extends BasicPane {
String fileNameWithOutExtension = fileName.substring(0, lastDotIndex); String fileNameWithOutExtension = fileName.substring(0, lastDotIndex);
String fileNameExtension = fileName.substring(lastDotIndex); String fileNameExtension = fileName.substring(lastDotIndex);
FileExtension fileExtension = FileExtension.parse(fileNameExtension); FileExtension fileExtension = FileExtension.parse(fileNameExtension);
boolean accept = StringUtils.isEmpty(fileName) if (StringUtils.isEmpty(fileName) || StringUtils.isEmpty(filterExtension) || fileFilter.containsExtension(fileExtension.getExtension())) {
|| StringUtils.isEmpty(filterExtension)
|| fileFilter.containsExtension(fileExtension.getExtension())
|| !ComparatorUtils.equals(fileNameExtension, filterExtension);
if (accept) {
return fileName; return fileName;
} }
if (!ComparatorUtils.equals(fileNameExtension, filterExtension)) {
return fileName + filterExtension;
}
return fileNameWithOutExtension + filterExtension; return fileNameWithOutExtension + filterExtension;
} }

6
designer-base/src/test/java/com/fr/file/FILEChooserPaneTest.java

@ -25,11 +25,11 @@ public class FILEChooserPaneTest {
ChooseFileFilter chooseFileFilter2 = new ChooseFileFilter(FileExtension.CPTX, StringUtils.EMPTY); ChooseFileFilter chooseFileFilter2 = new ChooseFileFilter(FileExtension.CPTX, StringUtils.EMPTY);
String result3 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.cpt", chooseFileFilter2).get(); String result3 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.cpt", chooseFileFilter2).get();
Assert.assertEquals("WorkBook1.cpt", result3); Assert.assertEquals("WorkBook1.cpt.cptx", result3);
ChooseFileFilter chooseFileFilter3 = new ChooseFileFilter(FileExtension.CPT, StringUtils.EMPTY); ChooseFileFilter chooseFileFilter3 = new ChooseFileFilter(FileExtension.CPT, StringUtils.EMPTY);
String result4 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.cptx", chooseFileFilter3).get(); String result4 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.cptx", chooseFileFilter3).get();
Assert.assertEquals("WorkBook1.cptx", result4); Assert.assertEquals("WorkBook1.cptx.cpt", result4);
ChooseFileFilter chooseFileFilter5 = new ChooseFileFilter(FileExtension.CPTX, StringUtils.EMPTY); ChooseFileFilter chooseFileFilter5 = new ChooseFileFilter(FileExtension.CPTX, StringUtils.EMPTY);
String result5 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.cptx", chooseFileFilter5).get(); String result5 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.cptx", chooseFileFilter5).get();
@ -37,7 +37,7 @@ public class FILEChooserPaneTest {
ChooseFileFilter chooseFileFilter6 = new ChooseFileFilter(FileExtension.CPT, StringUtils.EMPTY); ChooseFileFilter chooseFileFilter6 = new ChooseFileFilter(FileExtension.CPT, StringUtils.EMPTY);
String result6 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.xls", chooseFileFilter6).get(); String result6 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.xls", chooseFileFilter6).get();
Assert.assertEquals("WorkBook1.xls", result6); Assert.assertEquals("WorkBook1.xls.cpt", result6);
} }

Loading…
Cancel
Save