kerry
5 years ago
10 changed files with 226 additions and 30 deletions
@ -0,0 +1,20 @@ |
|||||||
|
package com.fr.design.mainframe; |
||||||
|
|
||||||
|
import com.fr.stable.fun.mark.API; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by kerry on 2019-10-14 |
||||||
|
*/ |
||||||
|
@API(level = NewTemplateFileProvider.CURRENT_LEVEL) |
||||||
|
public abstract class AbstractNewTemplateFileProvider implements NewTemplateFileProvider { |
||||||
|
|
||||||
|
@Override |
||||||
|
public int currentAPILevel() { |
||||||
|
return CURRENT_LEVEL; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String mark4Provider() { |
||||||
|
return getClass().getName(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,46 @@ |
|||||||
|
package com.fr.design.mainframe; |
||||||
|
|
||||||
|
import com.fr.file.FILEChooserPane; |
||||||
|
import com.fr.file.filetree.FileNode; |
||||||
|
import com.fr.stable.fun.mark.Mutable; |
||||||
|
|
||||||
|
import javax.swing.Icon; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by kerry on 2019-10-11 |
||||||
|
*/ |
||||||
|
public interface NewTemplateFileProvider extends Mutable { |
||||||
|
|
||||||
|
int CURRENT_LEVEL = 1; |
||||||
|
|
||||||
|
String XML_TAG = "NewFileTypeProvider"; |
||||||
|
|
||||||
|
/** |
||||||
|
* 向文件选择器中添加指定文件类型过滤器 |
||||||
|
* @param fileChooser 文件选择器 |
||||||
|
* @param suffix 文件后缀 |
||||||
|
*/ |
||||||
|
void addChooseFileFilter(FILEChooserPane fileChooser, String suffix); |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取本地目录文件关联的icon |
||||||
|
* @param path 文件路径 |
||||||
|
* @return 对应的图标 |
||||||
|
*/ |
||||||
|
Icon getLocalFileIcon(String path); |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取远程目录文件关联的icon |
||||||
|
* @param node 文件节点 |
||||||
|
* @param isShowLock 是否显示被锁住 |
||||||
|
* @return 对应的图标 |
||||||
|
*/ |
||||||
|
Icon getRemoteFileIcon(FileNode node, boolean isShowLock); |
||||||
|
|
||||||
|
/** |
||||||
|
* 保存为新类型文件 |
||||||
|
* @param targetPath 目标路径 |
||||||
|
* @param jTemplate 模板对象 |
||||||
|
*/ |
||||||
|
boolean saveToNewFile(String targetPath, JTemplate jTemplate); |
||||||
|
} |
@ -0,0 +1,38 @@ |
|||||||
|
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(); |
||||||
|
String result1 = Reflect.on(chooserPane).call("calFileNameText", "WorkBook1.cpt", null).get(); |
||||||
|
Assert.assertEquals("WorkBook1.cptnull", result1); |
||||||
|
|
||||||
|
ChooseFileFilter chooseFileFilter1 = new ChooseFileFilter(FileExtension.CPT, StringUtils.EMPTY); |
||||||
|
String result2 = Reflect.on(chooserPane).call("calFileNameText", "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); |
||||||
|
|
||||||
|
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); |
||||||
|
|
||||||
|
ChooseFileFilter chooseFileFilter5 = new ChooseFileFilter(FileExtension.CPTX, StringUtils.EMPTY); |
||||||
|
String result5 = Reflect.on(chooserPane).call("calFileNameText", "WorkBook1.cptx", chooseFileFilter5).get(); |
||||||
|
Assert.assertEquals("WorkBook1.cptx", result5); |
||||||
|
} |
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue