forked from fanruan/design
kerry
6 years ago
3 changed files with 79 additions and 1 deletions
@ -0,0 +1,27 @@ |
|||||||
|
package com.fr.design.gui.itree.filetree; |
||||||
|
|
||||||
|
import com.fr.base.FRContext; |
||||||
|
import com.fr.design.ExtraDesignClassManager; |
||||||
|
import com.fr.design.mainframe.App; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.Arrays; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Set; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by alex sung on 2019/7/23. |
||||||
|
*/ |
||||||
|
public class FileNodeConstants { |
||||||
|
public static String[] SUPPORT_FILE_TYPES; |
||||||
|
|
||||||
|
static { |
||||||
|
List<String> supportFileType = new ArrayList<>(Arrays.asList(FRContext.getFileNodes().getSupportedTypes())); |
||||||
|
//通过插件扩展的
|
||||||
|
Set<App> apps = ExtraDesignClassManager.getInstance().getArray(App.MARK_STRING); |
||||||
|
for(App app: apps){ |
||||||
|
supportFileType.addAll(Arrays.asList(app.defaultExtensions())); |
||||||
|
} |
||||||
|
SUPPORT_FILE_TYPES = supportFileType.toArray(new String[0]); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,51 @@ |
|||||||
|
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.stable.fun.mark.Mutable; |
||||||
|
import org.easymock.EasyMock; |
||||||
|
import org.junit.Assert; |
||||||
|
import org.junit.Test; |
||||||
|
|
||||||
|
import java.util.HashSet; |
||||||
|
import java.util.Set; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by alex sung on 2019/7/25. |
||||||
|
*/ |
||||||
|
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); |
||||||
|
|
||||||
|
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]); |
||||||
|
} |
||||||
|
|
||||||
|
private class MockCptxApp extends AbstractAppProvider{ |
||||||
|
@Override |
||||||
|
public String[] defaultExtensions() { |
||||||
|
return new String[] {FileExtension.CPTX.getExtension()}; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public JTemplate openTemplate(FILE tplFile) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public BaseBook asIOFile(FILE tplFile) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue