Browse Source
# Conflicts: # designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/GisMapPlotPane.javaresearch/11.0
jinbokai
5 years ago
155 changed files with 2242 additions and 961 deletions
@ -0,0 +1,40 @@
|
||||
package com.fr.design.fun; |
||||
|
||||
import com.fr.design.mainframe.JTemplate; |
||||
import com.fr.file.FILEChooserPane; |
||||
import com.fr.stable.fun.mark.Mutable; |
||||
|
||||
import javax.swing.Icon; |
||||
|
||||
/** |
||||
* Created by kerry on 2019-10-11 |
||||
*/ |
||||
public interface ReportSupportedFileUIProvider extends Mutable { |
||||
|
||||
int CURRENT_LEVEL = 1; |
||||
|
||||
String XML_TAG = "ReportSupportedFileUIProvider"; |
||||
|
||||
/** |
||||
* 向文件选择器中添加指定文件类型过滤器 |
||||
* @param fileChooser 文件选择器 |
||||
* @param suffix 文件后缀 |
||||
*/ |
||||
void addChooseFileFilter(FILEChooserPane fileChooser, String suffix); |
||||
|
||||
|
||||
/** |
||||
* 获取文件关联的icon |
||||
* @param path 文件路径 |
||||
* @param isShowLock 是否显示被锁住 |
||||
* @return 对应的图标 |
||||
*/ |
||||
Icon getFileIcon(String path,boolean isShowLock); |
||||
|
||||
/** |
||||
* 保存为新类型文件 |
||||
* @param targetPath 目标路径 |
||||
* @param jTemplate 模板对象 |
||||
*/ |
||||
boolean saveToNewFile(String targetPath, JTemplate jTemplate); |
||||
} |
@ -0,0 +1,40 @@
|
||||
package com.fr.design.fun.impl; |
||||
|
||||
import com.fr.design.fun.ReportSupportedFileUIProvider; |
||||
import com.fr.design.mainframe.JTemplate; |
||||
import com.fr.file.FILEChooserPane; |
||||
import com.fr.stable.fun.impl.AbstractProvider; |
||||
import com.fr.stable.fun.mark.API; |
||||
|
||||
import javax.swing.Icon; |
||||
|
||||
/** |
||||
* Created by kerry on 2019-10-14 |
||||
*/ |
||||
@API(level = ReportSupportedFileUIProvider.CURRENT_LEVEL) |
||||
public abstract class AbstractReportSupportedFileUIProvider extends AbstractProvider implements ReportSupportedFileUIProvider { |
||||
@Override |
||||
public void addChooseFileFilter(FILEChooserPane fileChooser, String suffix) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public Icon getFileIcon(String path, boolean isShowLock) { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public boolean saveToNewFile(String targetPath, JTemplate jTemplate) { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public int currentAPILevel() { |
||||
return CURRENT_LEVEL; |
||||
} |
||||
|
||||
@Override |
||||
public String mark4Provider() { |
||||
return getClass().getName(); |
||||
} |
||||
} |
@ -1,51 +1,63 @@
|
||||
package com.fr.design.gui.itree.filetree; |
||||
|
||||
import com.fr.base.extension.FileExtension; |
||||
import com.fr.base.io.BaseBook; |
||||
import com.fr.design.ExtraDesignClassManager; |
||||
import com.fr.design.mainframe.AbstractAppProvider; |
||||
import com.fr.design.mainframe.App; |
||||
import com.fr.design.mainframe.JTemplate; |
||||
import com.fr.file.FILE; |
||||
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; |
||||
import org.junit.Test; |
||||
|
||||
import org.junit.runner.RunWith; |
||||
import org.powermock.api.easymock.PowerMock; |
||||
import org.powermock.core.classloader.annotations.PrepareForTest; |
||||
import org.powermock.modules.junit4.PowerMockRunner; |
||||
import java.util.HashSet; |
||||
import java.util.Set; |
||||
|
||||
/** |
||||
* Created by alex sung on 2019/7/25. |
||||
*/ |
||||
@RunWith(PowerMockRunner.class) |
||||
@PrepareForTest(ExtraReportClassManager.class) |
||||
public class FileNodeConstantsTest { |
||||
@Test |
||||
public void supportFileTypesTest(){ |
||||
ExtraDesignClassManager extra = EasyMock.mock(ExtraDesignClassManager.class); |
||||
Set<Mutable> apps = new HashSet<Mutable>(){{add(new MockCptxApp());}}; |
||||
EasyMock.expect(extra.getArray(App.MARK_STRING)).andReturn(apps).anyTimes(); |
||||
EasyMock.replay(extra); |
||||
public void supportFileTypesTest() { |
||||
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]); |
||||
} |
||||
|
||||
Assert.assertEquals(1, extra.getArray(App.MARK_STRING).size()); |
||||
App app = (App) extra.getArray(App.MARK_STRING).iterator().next(); |
||||
Assert.assertEquals("cptx", app.defaultExtensions()[0]); |
||||
@Test |
||||
public void testSupportFileTypesOrder() { |
||||
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 class MockCptxApp extends AbstractAppProvider{ |
||||
@Override |
||||
public String[] defaultExtensions() { |
||||
return new String[] {FileExtension.CPTX.getExtension()}; |
||||
} |
||||
private ExtraReportClassManager mockExtraReportClassManager() { |
||||
ExtraReportClassManager extra = EasyMock.mock(ExtraReportClassManager.class); |
||||
Set<Mutable> options = new HashSet<Mutable>() {{ |
||||
add(new MockNewTemplateFileOption()); |
||||
}}; |
||||
EasyMock.expect(extra.getArray(ReportSupportedFileProvider.XML_TAG)).andReturn(options).anyTimes(); |
||||
EasyMock.replay(extra); |
||||
return extra; |
||||
} |
||||
|
||||
@Override |
||||
public JTemplate openTemplate(FILE tplFile) { |
||||
return null; |
||||
} |
||||
private class MockNewTemplateFileOption extends AbstractReportSupportedFileProvider { |
||||
|
||||
@Override |
||||
public BaseBook asIOFile(FILE tplFile) { |
||||
return null; |
||||
public FileExtension[] getFileExtensions() { |
||||
return new FileExtension[]{FileExtension.CPTX |
||||
}; |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
|
@ -0,0 +1,39 @@
|
||||
package com.fr.file; |
||||
|
||||
import com.fr.base.extension.FileExtension; |
||||
import com.fr.file.filter.ChooseFileFilter; |
||||
import com.fr.invoke.Reflect; |
||||
import com.fr.stable.StringUtils; |
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
|
||||
/** |
||||
* Created by kerry on 2019-10-15 |
||||
*/ |
||||
|
||||
public class FILEChooserPaneTest { |
||||
@Test |
||||
public void testAddChooseFileFilter() { |
||||
FILEChooserPane chooserPane = Reflect.on(FILEChooserPane.class).field("INSTANCE").get(); |
||||
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("calProperFileName", "WorkBook1.cpt", chooseFileFilter1).get(); |
||||
Assert.assertEquals("WorkBook1.cpt", result2); |
||||
|
||||
ChooseFileFilter chooseFileFilter2 = new ChooseFileFilter(FileExtension.CPTX, StringUtils.EMPTY); |
||||
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("calProperFileName", "WorkBook1.cptx", chooseFileFilter3).get(); |
||||
Assert.assertEquals("WorkBook1.cpt", result4); |
||||
|
||||
ChooseFileFilter chooseFileFilter5 = new ChooseFileFilter(FileExtension.CPTX, StringUtils.EMPTY); |
||||
String result5 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.cptx", chooseFileFilter5).get(); |
||||
Assert.assertEquals("WorkBook1.cptx", result5); |
||||
} |
||||
|
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue