|
|
@ -1,6 +1,8 @@ |
|
|
|
package com.fr.design.mainframe; |
|
|
|
package com.fr.design.mainframe; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.fr.base.theme.FormTheme; |
|
|
|
import com.fr.base.theme.FormThemeConfig; |
|
|
|
import com.fr.base.theme.FormThemeConfig; |
|
|
|
|
|
|
|
import com.fr.base.theme.ReportThemeConfig; |
|
|
|
import com.fr.base.theme.TemplateTheme; |
|
|
|
import com.fr.base.theme.TemplateTheme; |
|
|
|
import com.fr.base.theme.TemplateThemeConfig; |
|
|
|
import com.fr.base.theme.TemplateThemeConfig; |
|
|
|
import com.fr.config.dao.DaoContext; |
|
|
|
import com.fr.config.dao.DaoContext; |
|
|
@ -10,8 +12,11 @@ import com.fr.config.dao.impl.LocalXmlEntityDao; |
|
|
|
import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase; |
|
|
|
import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase; |
|
|
|
import com.fr.form.main.Form; |
|
|
|
import com.fr.form.main.Form; |
|
|
|
import com.fr.form.ui.ElementCaseEditor; |
|
|
|
import com.fr.form.ui.ElementCaseEditor; |
|
|
|
|
|
|
|
import com.fr.form.ui.container.OccupiedLayout; |
|
|
|
|
|
|
|
import com.fr.form.ui.container.WFitLayout; |
|
|
|
import com.fr.general.ImageWithSuffix; |
|
|
|
import com.fr.general.ImageWithSuffix; |
|
|
|
import com.fr.general.ModuleContext; |
|
|
|
import com.fr.general.ModuleContext; |
|
|
|
|
|
|
|
import com.fr.invoke.Reflect; |
|
|
|
import com.fr.main.impl.WorkBook; |
|
|
|
import com.fr.main.impl.WorkBook; |
|
|
|
import com.fr.report.cell.TemplateCellElement; |
|
|
|
import com.fr.report.cell.TemplateCellElement; |
|
|
|
import com.fr.report.cell.cellattr.CellImage; |
|
|
|
import com.fr.report.cell.cellattr.CellImage; |
|
|
@ -23,14 +28,20 @@ import com.fr.restriction.Restrictions; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import com.fr.stable.module.Module; |
|
|
|
import com.fr.stable.module.Module; |
|
|
|
import com.fr.start.MainDesigner; |
|
|
|
import com.fr.start.MainDesigner; |
|
|
|
|
|
|
|
import com.fr.third.guava.collect.Lists; |
|
|
|
|
|
|
|
import com.fr.transaction.WorkerCallBack; |
|
|
|
import junit.framework.TestCase; |
|
|
|
import junit.framework.TestCase; |
|
|
|
import org.easymock.EasyMock; |
|
|
|
import org.easymock.EasyMock; |
|
|
|
import org.junit.Assert; |
|
|
|
import org.junit.Assert; |
|
|
|
import org.junit.runner.RunWith; |
|
|
|
import org.junit.runner.RunWith; |
|
|
|
|
|
|
|
import org.mockito.Mockito; |
|
|
|
|
|
|
|
import org.powermock.api.easymock.PowerMock; |
|
|
|
import org.powermock.core.classloader.annotations.PowerMockIgnore; |
|
|
|
import org.powermock.core.classloader.annotations.PowerMockIgnore; |
|
|
|
import org.powermock.modules.junit4.PowerMockRunner; |
|
|
|
import org.powermock.modules.junit4.PowerMockRunner; |
|
|
|
|
|
|
|
|
|
|
|
import java.awt.image.BufferedImage; |
|
|
|
import java.awt.image.BufferedImage; |
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
@RunWith(PowerMockRunner.class) |
|
|
|
@RunWith(PowerMockRunner.class) |
|
|
|
@PowerMockIgnore("javax.swing.*") |
|
|
|
@PowerMockIgnore("javax.swing.*") |
|
|
@ -55,6 +66,7 @@ public class JFileTest extends TestCase { |
|
|
|
ImageWithSuffix imageWithSuffix = ImageWithSuffix.build(new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB), "jpg"); |
|
|
|
ImageWithSuffix imageWithSuffix = ImageWithSuffix.build(new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB), "jpg"); |
|
|
|
CellImage cellImage = new CellImage(); |
|
|
|
CellImage cellImage = new CellImage(); |
|
|
|
cellImage.setImage(imageWithSuffix); |
|
|
|
cellImage.setImage(imageWithSuffix); |
|
|
|
|
|
|
|
mockJCreateConfigEnv(ReportThemeConfig.getInstance()); |
|
|
|
JWorkBook jWorkBook = new JWorkBook(workBook, "text"); |
|
|
|
JWorkBook jWorkBook = new JWorkBook(workBook, "text"); |
|
|
|
jWorkBook.setPictureElem(cellElement, cellImage); |
|
|
|
jWorkBook.setPictureElem(cellElement, cellImage); |
|
|
|
Assert.assertEquals(imageWithSuffix, cellElement.getValue()); |
|
|
|
Assert.assertEquals(imageWithSuffix, cellElement.getValue()); |
|
|
@ -71,9 +83,24 @@ public class JFileTest extends TestCase { |
|
|
|
ImageWithSuffix imageWithSuffix = ImageWithSuffix.build(new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB), "jpg"); |
|
|
|
ImageWithSuffix imageWithSuffix = ImageWithSuffix.build(new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB), "jpg"); |
|
|
|
CellImage cellImage = new CellImage(); |
|
|
|
CellImage cellImage = new CellImage(); |
|
|
|
cellImage.setImage(imageWithSuffix); |
|
|
|
cellImage.setImage(imageWithSuffix); |
|
|
|
JForm jForm = new JForm(); |
|
|
|
mockJCreateConfigEnv(FormThemeConfig.getInstance()); |
|
|
|
|
|
|
|
form.setContainer(new WFitLayout()); |
|
|
|
|
|
|
|
JForm jForm = new JForm(form); |
|
|
|
jForm.setTarget(form); |
|
|
|
jForm.setTarget(form); |
|
|
|
jForm.setPictureElem(cellElement, cellImage); |
|
|
|
jForm.setPictureElem(cellElement, cellImage); |
|
|
|
Assert.assertEquals(imageWithSuffix, cellElement.getValue()); |
|
|
|
Assert.assertEquals(imageWithSuffix, cellElement.getValue()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void mockJCreateConfigEnv(TemplateThemeConfig instance) { |
|
|
|
|
|
|
|
Reflect.on(instance).field("themeName4NewTemplate").call("set", "test"); |
|
|
|
|
|
|
|
TemplateThemeConfig.OrderedNameList list = new TemplateThemeConfig.OrderedNameList(); |
|
|
|
|
|
|
|
list.setThemeNames(Lists.newArrayList("test")); |
|
|
|
|
|
|
|
Reflect.on(instance).field("themeNameList").call("set", list); |
|
|
|
|
|
|
|
TemplateTheme testTheme = new FormTheme(); |
|
|
|
|
|
|
|
testTheme.setDark(false); |
|
|
|
|
|
|
|
testTheme.setName("test"); |
|
|
|
|
|
|
|
Map<String, TemplateTheme> testMap = new HashMap<>(); |
|
|
|
|
|
|
|
testMap.put("test", testTheme); |
|
|
|
|
|
|
|
Reflect.on(instance).call("put", "test", testTheme, true); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |