From 51d57103fe25bb97fb448518bd4e7d9c21c494b9 Mon Sep 17 00:00:00 2001 From: kerry Date: Fri, 25 Oct 2019 16:35:03 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-23022=20=E8=B0=83=E6=95=B4=E4=B8=8B?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fun/ReportSupportedFileUIProvider.java | 8 ------ ...AbstractReportSupportedFileUIProvider.java | 7 ----- .../gui/itree/filetree/FileNodeConstants.java | 8 +++--- .../java/com/fr/file/FILEChooserPane.java | 6 ++-- .../itree/filetree/FileNodeConstantsTest.java | 28 +++++++++---------- 5 files changed, 22 insertions(+), 35 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/fun/ReportSupportedFileUIProvider.java b/designer-base/src/main/java/com/fr/design/fun/ReportSupportedFileUIProvider.java index 2ccfd9363e..4f4ea45c3c 100644 --- a/designer-base/src/main/java/com/fr/design/fun/ReportSupportedFileUIProvider.java +++ b/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 文件路径 diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractReportSupportedFileUIProvider.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractReportSupportedFileUIProvider.java index 3e8046e6f7..e8d1dfcc19 100644 --- a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractReportSupportedFileUIProvider.java +++ b/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; diff --git a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java index 617051dc63..f5da5302c4 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java +++ b/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(); //通过插件扩展的 - Set providers = ExtraDesignClassManager.getInstance().getArray(ReportSupportedFileUIProvider.XML_TAG); - for (ReportSupportedFileUIProvider provider : providers) { + Set providers = ExtraReportClassManager.getInstance().getArray(ReportSupportedFileProvider.XML_TAG); + for (ReportSupportedFileProvider provider : providers) { addAppExtensions(provider.getFileExtensions()); } supportFileType.addAll(Arrays.asList(FRContext.getFileNodes().getSupportedTypes())); diff --git a/designer-base/src/main/java/com/fr/file/FILEChooserPane.java b/designer-base/src/main/java/com/fr/file/FILEChooserPane.java index 08c16fd178..52e63c9bfa 100644 --- a/designer-base/src/main/java/com/fr/file/FILEChooserPane.java +++ b/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 providers = ExtraDesignClassManager.getInstance().getArray(ReportSupportedFileUIProvider.XML_TAG); - for (ReportSupportedFileUIProvider provider : providers) { + Set providers = ExtraReportClassManager.getInstance().getArray(ReportSupportedFileProvider.XML_TAG); + for (ReportSupportedFileProvider provider : providers) { for (FileExtension fileExtension : provider.getFileExtensions()){ supportedTypes.addExtension(fileExtension.getExtension()); } diff --git a/designer-base/src/test/java/com/fr/design/gui/itree/filetree/FileNodeConstantsTest.java b/designer-base/src/test/java/com/fr/design/gui/itree/filetree/FileNodeConstantsTest.java index e62091048f..3358ac8be9 100644 --- a/designer-base/src/test/java/com/fr/design/gui/itree/filetree/FileNodeConstantsTest.java +++ b/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 options = new HashSet() {{ 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() {