Browse Source

Merge pull request #1229 in DESIGN/design from ~KERRY/design_10.0:release/10.0 to release/10.0

* commit '51d57103fe25bb97fb448518bd4e7d9c21c494b9':
  REPORT-23022 调整下接口
feature/big-screen
kerry 5 years ago
parent
commit
72b946afd9
  1. 8
      designer-base/src/main/java/com/fr/design/fun/ReportSupportedFileUIProvider.java
  2. 7
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractReportSupportedFileUIProvider.java
  3. 8
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java
  4. 6
      designer-base/src/main/java/com/fr/file/FILEChooserPane.java
  5. 28
      designer-base/src/test/java/com/fr/design/gui/itree/filetree/FileNodeConstantsTest.java

8
designer-base/src/main/java/com/fr/design/fun/ReportSupportedFileUIProvider.java

@ -1,6 +1,5 @@
package com.fr.design.fun;
import com.fr.base.extension.FileExtension;
import com.fr.design.mainframe.JTemplate;
import com.fr.file.FILEChooserPane;
import com.fr.stable.fun.mark.Mutable;
@ -24,13 +23,6 @@ public interface ReportSupportedFileUIProvider extends Mutable {
void addChooseFileFilter(FILEChooserPane fileChooser, String suffix);
/**
* 获取可支持的文件类型
* @return 文件扩展
*/
FileExtension[] getFileExtensions();
/**
* 获取文件关联的icon
* @param path 文件路径

7
designer-base/src/main/java/com/fr/design/fun/impl/AbstractReportSupportedFileUIProvider.java

@ -1,6 +1,5 @@
package com.fr.design.fun.impl;
import com.fr.base.extension.FileExtension;
import com.fr.design.fun.ReportSupportedFileUIProvider;
import com.fr.design.mainframe.JTemplate;
import com.fr.file.FILEChooserPane;
@ -19,12 +18,6 @@ public abstract class AbstractReportSupportedFileUIProvider extends AbstractProv
}
@Override
public FileExtension[] getFileExtensions() {
return new FileExtension[0];
}
@Override
public Icon getFileIcon(String path, boolean isShowLock) {
return null;

8
designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java

@ -2,14 +2,14 @@ package com.fr.design.gui.itree.filetree;
import com.fr.base.FRContext;
import com.fr.base.extension.FileExtension;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.fun.ReportSupportedFileUIProvider;
import com.fr.general.GeneralContext;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.injectable.PluginModule;
import com.fr.plugin.manage.PluginFilter;
import com.fr.plugin.observer.PluginEvent;
import com.fr.plugin.observer.PluginEventListener;
import com.fr.report.ExtraReportClassManager;
import com.fr.report.fun.ReportSupportedFileProvider;
import java.util.ArrayList;
import java.util.Arrays;
@ -58,8 +58,8 @@ public class FileNodeConstants {
rwl.writeLock().lock();
supportFileType = new ArrayList<String>();
//通过插件扩展的
Set<ReportSupportedFileUIProvider> providers = ExtraDesignClassManager.getInstance().getArray(ReportSupportedFileUIProvider.XML_TAG);
for (ReportSupportedFileUIProvider provider : providers) {
Set<ReportSupportedFileProvider> providers = ExtraReportClassManager.getInstance().getArray(ReportSupportedFileProvider.XML_TAG);
for (ReportSupportedFileProvider provider : providers) {
addAppExtensions(provider.getFileExtensions());
}
supportFileType.addAll(Arrays.asList(FRContext.getFileNodes().getSupportedTypes()));

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

@ -33,6 +33,8 @@ import com.fr.file.filter.FILEFilter;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext;
import com.fr.log.FineLoggerFactory;
import com.fr.report.ExtraReportClassManager;
import com.fr.report.fun.ReportSupportedFileProvider;
import com.fr.stable.CoreConstants;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
@ -742,8 +744,8 @@ public class FILEChooserPane extends BasicPane {
if (type == JFileChooser.OPEN_DIALOG) {
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) {
Set<ReportSupportedFileProvider> providers = ExtraReportClassManager.getInstance().getArray(ReportSupportedFileProvider.XML_TAG);
for (ReportSupportedFileProvider provider : providers) {
for (FileExtension fileExtension : provider.getFileExtensions()){
supportedTypes.addExtension(fileExtension.getExtension());
}

28
designer-base/src/test/java/com/fr/design/gui/itree/filetree/FileNodeConstantsTest.java

@ -1,9 +1,9 @@
package com.fr.design.gui.itree.filetree;
import com.fr.base.extension.FileExtension;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.fun.ReportSupportedFileUIProvider;
import com.fr.design.fun.impl.AbstractReportSupportedFileUIProvider;
import com.fr.report.ExtraReportClassManager;
import com.fr.report.fun.ReportSupportedFileProvider;
import com.fr.report.fun.impl.AbstractReportSupportedFileProvider;
import com.fr.stable.fun.mark.Mutable;
import org.easymock.EasyMock;
import org.junit.Assert;
@ -19,38 +19,38 @@ import java.util.Set;
* Created by alex sung on 2019/7/25.
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest(ExtraDesignClassManager.class)
@PrepareForTest(ExtraReportClassManager.class)
public class FileNodeConstantsTest {
@Test
public void supportFileTypesTest() {
ExtraDesignClassManager extra = mockExtraDesignClassManager();
Assert.assertEquals(1, extra.getArray(ReportSupportedFileUIProvider.XML_TAG).size());
ReportSupportedFileUIProvider option = (ReportSupportedFileUIProvider) extra.getArray(ReportSupportedFileUIProvider.XML_TAG).iterator().next();
ExtraReportClassManager extra = mockExtraReportClassManager();
Assert.assertEquals(1, extra.getArray(ReportSupportedFileProvider.XML_TAG).size());
ReportSupportedFileProvider option = (ReportSupportedFileProvider) extra.getArray(ReportSupportedFileProvider.XML_TAG).iterator().next();
Assert.assertEquals(FileExtension.CPTX, option.getFileExtensions()[0]);
}
@Test
public void testSupportFileTypesOrder() {
ExtraDesignClassManager extra = mockExtraDesignClassManager();
PowerMock.mockStatic(ExtraDesignClassManager.class);
EasyMock.expect(ExtraDesignClassManager.getInstance()).andReturn(extra).once();
ExtraReportClassManager extra = mockExtraReportClassManager();
PowerMock.mockStatic(ExtraReportClassManager.class);
EasyMock.expect(ExtraReportClassManager.getInstance()).andReturn(extra).once();
PowerMock.replayAll();
String[] fileTypes = FileNodeConstants.getSupportFileTypes();
Assert.assertEquals("cptx", fileTypes[0]);
Assert.assertEquals("cpt", fileTypes[1]);
}
private ExtraDesignClassManager mockExtraDesignClassManager() {
ExtraDesignClassManager extra = EasyMock.mock(ExtraDesignClassManager.class);
private ExtraReportClassManager mockExtraReportClassManager() {
ExtraReportClassManager extra = EasyMock.mock(ExtraReportClassManager.class);
Set<Mutable> options = new HashSet<Mutable>() {{
add(new MockNewTemplateFileOption());
}};
EasyMock.expect(extra.getArray(ReportSupportedFileUIProvider.XML_TAG)).andReturn(options).anyTimes();
EasyMock.expect(extra.getArray(ReportSupportedFileProvider.XML_TAG)).andReturn(options).anyTimes();
EasyMock.replay(extra);
return extra;
}
private class MockNewTemplateFileOption extends AbstractReportSupportedFileUIProvider {
private class MockNewTemplateFileOption extends AbstractReportSupportedFileProvider {
@Override
public FileExtension[] getFileExtensions() {

Loading…
Cancel
Save