Browse Source

REPORT-23053【10.0.4回归】远程设计输出Excel、内置数据集模版,文件后缀重复

feature/big-screen
kerry 5 years ago
parent
commit
3fd4e107a3
  1. 15
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  2. 5
      designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java
  3. 48
      designer-base/src/main/java/com/fr/file/FILEChooserPane.java
  4. 17
      designer-base/src/test/java/com/fr/file/FILEChooserPaneTest.java
  5. 7
      designer-form/src/main/java/com/fr/design/mainframe/JForm.java
  6. 10
      designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java

15
designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java

@ -628,22 +628,11 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
}
}
private void addChooseFILEFilter(FILEChooserPane fileChooser){
String appName = ProductConstants.APP_NAME;
if (FileExtension.CPT.matchExtension(this.suffix())){
fileChooser.addChooseFILEFilter(new ChooseFileFilter(FileExtension.CPT, appName + Toolkit.i18nText("Fine-Design_Report_Template_File")));
}
if (FileExtension.FRM.matchExtension(this.suffix())) {
// richer:form文件 daniel 改成三个字
fileChooser.addChooseFILEFilter(new ChooseFileFilter(FileExtension.FRM, appName + Toolkit.i18nText("Fine-Design_Report_Template_File")));
}
addExtraChooseFILEFilter(fileChooser);
}
protected void addExtraChooseFILEFilter(FILEChooserPane fileChooser){
protected void addChooseFILEFilter(FILEChooserPane fileChooser){
}
// 保存新模板时会进入此方法(新建模板直接保存,或者另存为)
protected boolean saveNewFile(FILE editingFILE, String oldName) {
String originID = StringUtils.EMPTY;

5
designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java

@ -15,6 +15,7 @@ import com.fr.design.parameter.ParameterDesignerProvider;
import com.fr.design.parameter.ParameterReader;
import com.fr.form.ui.Widget;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.solution.sandbox.collection.PluginSandboxCollections;
import com.fr.stable.StableUtils;
import org.jetbrains.annotations.NotNull;
@ -235,7 +236,7 @@ public class DesignModuleFactory {
public static void registerParameterReader(ParameterReader reader) {
if (instance.parameterReaderList == null) {
instance.parameterReaderList = new ArrayList<ParameterReader>();
instance.parameterReaderList = PluginSandboxCollections.newSandboxList();
}
instance.parameterReaderList.add(reader);
}
@ -246,4 +247,4 @@ public class DesignModuleFactory {
}
return instance.parameterReaderList.toArray(new ParameterReader[instance.parameterReaderList.size()]);
}
}
}

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

@ -4,12 +4,14 @@ import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.base.extension.FileExtension;
import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.UpdateAction;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.UIDialog;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.DesignerWorkspaceType;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.fun.ReportSupportedFileUIProvider;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIButtonUI;
import com.fr.design.gui.icombobox.UIComboBox;
@ -90,6 +92,7 @@ import java.util.ArrayList;
import java.util.EnumSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -475,8 +478,9 @@ public class FILEChooserPane extends BasicPane {
@Override
public void itemStateChanged(ItemEvent e) {
Object ss = postfixComboBox.getSelectedItem();
if (ss instanceof FILEFilter) {
setFILEFilter((FILEFilter) ss);
if (ss instanceof ChooseFileFilter) {
setFILEFilter((ChooseFileFilter) ss);
fileNameTextField.setText(calProperFileName(fileNameTextField.getText(), (ChooseFileFilter) ss));
} else {
setFILEFilter(null);
}
@ -484,6 +488,21 @@ public class FILEChooserPane extends BasicPane {
});
}
private String calProperFileName(String fileName, ChooseFileFilter fileFilter) {
if(fileFilter == null){
return fileName;
}
String filterExtension = fileFilter.getExtensionString();
int lastDotIndex = fileName.lastIndexOf(".") != -1 ? fileName.lastIndexOf(".") : fileName.length();
String fileNameWithOutExtension = fileName.substring(0, lastDotIndex);
String fileNameExtension = fileName.substring(lastDotIndex);
FileExtension fileExtension = FileExtension.parse(fileNameExtension);
if (StringUtils.isEmpty(fileName) || StringUtils.isEmpty(filterExtension) || fileFilter.containsExtension(fileExtension.getExtension())) {
return fileName;
}
return fileNameWithOutExtension + filterExtension;
}
private void doCancel() {
this.locationBtnPane.setPopDir(null);
dialogExit();
@ -720,7 +739,14 @@ public class FILEChooserPane extends BasicPane {
if (editing == null || !editing.isChartBook()) {
if (type == JFileChooser.OPEN_DIALOG) {
this.addChooseFILEFilter(new ChooseFileFilter(FRContext.getFileNodes().getSupportedTypes(), appName + Toolkit.i18nText("Fine-Design_Report_Template_File")));
ChooseFileFilter supportedTypes = new ChooseFileFilter(FRContext.getFileNodes().getSupportedTypes(), appName + Toolkit.i18nText("Fine-Design_Report_Template_File"));
Set<ReportSupportedFileUIProvider> providers = ExtraDesignClassManager.getInstance().getArray(ReportSupportedFileUIProvider.XML_TAG);
for (ReportSupportedFileUIProvider provider : providers) {
for (FileExtension fileExtension : provider.getFileExtensions()){
supportedTypes.addExtension(fileExtension.getExtension());
}
}
this.addChooseFILEFilter(supportedTypes);
}
// ben:filefilter设置初值为cpt过滤
@ -728,6 +754,11 @@ public class FILEChooserPane extends BasicPane {
// richer:form文件 daniel 改成三个字
this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.FRM, appName + Toolkit.i18nText("Fine-Design_Report_Template_File")));
Set<ReportSupportedFileUIProvider> providers = ExtraDesignClassManager.getInstance().getArray(ReportSupportedFileUIProvider.XML_TAG);
for (ReportSupportedFileUIProvider provider : providers) {
provider.addChooseFileFilter(this, StringUtils.EMPTY);
}
} else {
if (type == JFileChooser.OPEN_DIALOG) {
this.addChooseFILEFilter(new ChooseFileFilter(EnumSet.of(FileExtension.XLS, FileExtension.XLSX), Toolkit.i18nText("Fine-Design_Basic_Import_Excel_Source")));
@ -834,7 +865,8 @@ public class FILEChooserPane extends BasicPane {
private void saveDialog() {
String filename = fileNameTextField.getText();
fileNameTextField.setText(calFileNameText(filename, (ChooseFileFilter) (postfixComboBox.getSelectedItem())));
filename = calProperFileName(filename, (ChooseFileFilter) (postfixComboBox.getSelectedItem()));
fileNameTextField.setText(filename);
option = OK_OPTION;
FILE selectedFile = this.getSelectedFILE();
@ -860,14 +892,6 @@ public class FILEChooserPane extends BasicPane {
}
}
private String calFileNameText(String currentValue, ChooseFileFilter selectFileFilter) {
if (selectFileFilter == null || StringUtils.isEmpty(selectFileFilter.getExtensionString())) {
return currentValue + this.suffix;
} else if (!currentValue.endsWith(selectFileFilter.getExtensionString())) {
return currentValue + selectFileFilter.getExtensionString();
}
return currentValue;
}
private boolean access(FILE selectedFile) {
boolean access = false;

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

@ -15,23 +15,24 @@ public class FILEChooserPaneTest {
@Test
public void testAddChooseFileFilter() {
FILEChooserPane chooserPane = Reflect.on(FILEChooserPane.class).field("INSTANCE").get();
String result1 = Reflect.on(chooserPane).call("calFileNameText", "WorkBook1.cpt", null).get();
Assert.assertEquals("WorkBook1.cptnull", result1);
Reflect.on(chooserPane).set("suffix", ".cpt");
String result1 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.cpt", null).get();
Assert.assertEquals("WorkBook1.cpt", result1);
ChooseFileFilter chooseFileFilter1 = new ChooseFileFilter(FileExtension.CPT, StringUtils.EMPTY);
String result2 = Reflect.on(chooserPane).call("calFileNameText", "WorkBook1.cpt", chooseFileFilter1).get();
String result2 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.cpt", chooseFileFilter1).get();
Assert.assertEquals("WorkBook1.cpt", result2);
ChooseFileFilter chooseFileFilter2 = new ChooseFileFilter(FileExtension.CPTX, StringUtils.EMPTY);
String result3 = Reflect.on(chooserPane).call("calFileNameText", "WorkBook1.cpt", chooseFileFilter2).get();
Assert.assertEquals("WorkBook1.cpt.cptx", result3);
String result3 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.cpt", chooseFileFilter2).get();
Assert.assertEquals("WorkBook1.cptx", result3);
ChooseFileFilter chooseFileFilter3 = new ChooseFileFilter(FileExtension.CPT, StringUtils.EMPTY);
String result4 = Reflect.on(chooserPane).call("calFileNameText", "WorkBook1.cptx", chooseFileFilter3).get();
Assert.assertEquals("WorkBook1.cptx.cpt", result4);
String result4 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.cptx", chooseFileFilter3).get();
Assert.assertEquals("WorkBook1.cpt", result4);
ChooseFileFilter chooseFileFilter5 = new ChooseFileFilter(FileExtension.CPTX, StringUtils.EMPTY);
String result5 = Reflect.on(chooserPane).call("calFileNameText", "WorkBook1.cptx", chooseFileFilter5).get();
String result5 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.cptx", chooseFileFilter5).get();
Assert.assertEquals("WorkBook1.cptx", result5);
}

7
designer-form/src/main/java/com/fr/design/mainframe/JForm.java

@ -957,10 +957,7 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
protected void addChooseFILEFilter(FILEChooserPane fileChooser){
String appName = ProductConstants.APP_NAME;
if (FileExtension.FRM.matchExtension(this.suffix())) {
// richer:form文件 daniel 改成三个字
fileChooser.addChooseFILEFilter(new ChooseFileFilter(FileExtension.FRM, appName + Toolkit.i18nText("Fine-Design_Report_Template_File")));
}
// richer:form文件 daniel 改成三个字
fileChooser.addChooseFILEFilter(new ChooseFileFilter(FileExtension.FRM, appName + Toolkit.i18nText("Fine-Design_Report_Template_File")));
}
}

10
designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java

@ -4,6 +4,7 @@ import com.fr.base.BaseUtils;
import com.fr.base.DynamicUnitList;
import com.fr.base.Parameter;
import com.fr.base.ScreenResolution;
import com.fr.base.extension.FileExtension;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignModelAdapter;
import com.fr.design.ExtraDesignClassManager;
@ -41,6 +42,7 @@ import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icontainer.UIModeControlContainer;
import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.cell.QuickEditorRegion;
import com.fr.design.mainframe.template.info.JWorkBookProcessInfo;
import com.fr.design.mainframe.template.info.TemplateProcessInfo;
@ -69,6 +71,7 @@ import com.fr.file.FILE;
import com.fr.file.FILEChooserPane;
import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode;
import com.fr.file.filter.ChooseFileFilter;
import com.fr.general.ComparatorUtils;
import com.fr.general.ModuleContext;
import com.fr.grid.Grid;
@ -92,6 +95,7 @@ import com.fr.report.poly.PolyWorkSheet;
import com.fr.report.worksheet.WorkSheet;
import com.fr.stable.ArrayUtils;
import com.fr.stable.AssistUtils;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.module.Module;
@ -1171,6 +1175,12 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
return ViewRequestConstants.REPORT_VIEW_PATH;
}
protected void addChooseFILEFilter(FILEChooserPane fileChooser) {
String appName = ProductConstants.APP_NAME;
fileChooser.addChooseFILEFilter(new ChooseFileFilter(FileExtension.CPT, appName + Toolkit.i18nText("Fine-Design_Report_Template_File")));
addExtraChooseFILEFilter(fileChooser);
}
protected void addExtraChooseFILEFilter(FILEChooserPane fileChooser){
Set<ReportSupportedFileUIProvider> providers = ExtraDesignClassManager.getInstance().getArray(ReportSupportedFileUIProvider.XML_TAG);
for (ReportSupportedFileUIProvider provider : providers) {

Loading…
Cancel
Save