diff --git a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java index dcc588fa35..7370d4d55d 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -14,6 +14,7 @@ import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.env.LocalDesignerWorkspaceInfo; import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.locale.impl.ProductImproveMark; import com.fr.design.mainframe.vcs.VcsConfigManager; import com.fr.design.update.push.DesignerPushUpdateConfigManager; import com.fr.design.style.color.ColorSelectConfigManager; @@ -23,6 +24,8 @@ import com.fr.general.ComparatorUtils; import com.fr.general.FRLogFormatter; import com.fr.general.GeneralContext; import com.fr.general.IOUtils; +import com.fr.general.locale.LocaleCenter; +import com.fr.general.locale.LocaleMark; import com.fr.general.xml.GeneralXMLTools; import com.fr.log.FineLoggerFactory; import com.fr.stable.CommonUtils; @@ -688,7 +691,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { * @return 是否加入产品改良 */ public boolean isJoinProductImprove() { - return joinProductImprove; + LocaleMark localeMark = LocaleCenter.getMark(ProductImproveMark.class); + return localeMark.getValue() && this.joinProductImprove; } /** diff --git a/designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java b/designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java index 4fabbd6da6..f3cb21bc70 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java @@ -1,16 +1,16 @@ package com.fr.design.actions.community; -import com.fr.base.BaseUtils; import com.fr.design.actions.UpdateAction; +import com.fr.design.locale.impl.VideoMark; import com.fr.design.menu.MenuKeySet; import com.fr.design.utils.BrowseUtils; -import com.fr.general.CloudCenter; -import com.fr.general.GeneralContext; import com.fr.general.IOUtils; +import com.fr.general.locale.LocaleCenter; +import com.fr.general.locale.LocaleMark; import javax.swing.*; import java.awt.event.ActionEvent; -import java.util.Locale; + public class VideoAction extends UpdateAction { @@ -27,14 +27,8 @@ public class VideoAction extends UpdateAction @Override public void actionPerformed(ActionEvent arg0) { - String url; - if (GeneralContext.getLocale().equals(Locale.US)) { - url = CloudCenter.getInstance().acquireUrlByKind("bbs.video.en"); - } else { - url = CloudCenter.getInstance().acquireUrlByKind("bbs.video"); - } - BrowseUtils.browser(url); - + LocaleMark localeMark = LocaleCenter.getMark(VideoMark.class); + BrowseUtils.browser(localeMark.getValue()); } public static final MenuKeySet VIDEO = new MenuKeySet() { @Override diff --git a/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java b/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java index 9c892de011..44de37ea82 100644 --- a/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java +++ b/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java @@ -41,7 +41,7 @@ import javax.swing.event.ChangeListener; import java.io.ByteArrayOutputStream; import java.text.Collator; import java.util.ArrayList; -import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; @@ -123,6 +123,7 @@ public abstract class DesignTableDataManager { * @param dsNameChangedMap 改变名字的数据集 */ public static void fireDSChanged(Map dsNameChangedMap) { + clearGlobalDs(); if (!dsNameChangedMap.isEmpty()) { setDsNameChangedMap(dsNameChangedMap); } @@ -334,15 +335,9 @@ public abstract class DesignTableDataManager { private static void addStoreProcedureData(java.util.Map resMap) { ProcedureConfig procedureConfig = ProcedureConfig.getInstance(); - String[] namearray = new String[0]; - @SuppressWarnings("unchecked") - java.util.Iterator nameIt = procedureConfig.getProcedures().keySet().iterator(); - while (nameIt.hasNext()) { - namearray = (String[]) ArrayUtils.add(namearray, nameIt.next()); - } - Arrays.sort(namearray, Collator.getInstance(java.util.Locale.CHINA)); - - for (String name : namearray) { + List names = new ArrayList<>(procedureConfig.getProcedures().keySet()); + Collections.sort(names, Collator.getInstance(java.util.Locale.CHINA)); + for (String name : names) { StoreProcedure storeProcedure = procedureConfig.getProcedure(name); if (globalDsCache.containsKey(name)) { resMap.put(name, globalDsCache.get(name)); diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginUtils.java b/designer-base/src/main/java/com/fr/design/extra/PluginUtils.java index 92a8388647..98e6a75311 100644 --- a/designer-base/src/main/java/com/fr/design/extra/PluginUtils.java +++ b/designer-base/src/main/java/com/fr/design/extra/PluginUtils.java @@ -233,6 +233,8 @@ public class PluginUtils { jo.put("onTrial", pluginContext.isOnTrial()); jo.put("deadline", getDeadline(pluginContext)); jo.put("registerFailed", pluginContext.isRegisterFailed()); + jo.put("selfState", pluginContext.getSelfState()); + jo.put("switchedReason", pluginContext.getSwitchedReason()); ja.put(jo); } }catch (Exception e){ diff --git a/designer-base/src/main/java/com/fr/design/locale/impl/ProductImproveMark.java b/designer-base/src/main/java/com/fr/design/locale/impl/ProductImproveMark.java new file mode 100644 index 0000000000..b7a05975cb --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/locale/impl/ProductImproveMark.java @@ -0,0 +1,31 @@ +package com.fr.design.locale.impl; + +import com.fr.general.GeneralContext; +import com.fr.general.locale.LocaleMark; + +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + +/** + * @author Hades + * @date 2019/6/24 + */ +public class ProductImproveMark implements LocaleMark { + + private Map map = new HashMap<>(); + + public ProductImproveMark() { + map.put(Locale.CHINA, true); + map.put(Locale.TAIWAN, false); + map.put(Locale.US, false); + map.put(Locale.KOREA, false); + map.put(Locale.JAPAN, false); + } + + @Override + public Boolean getValue() { + Boolean result = map.get(GeneralContext.getLocale()); + return result == null ? false : result; + } +} diff --git a/designer-base/src/main/java/com/fr/design/locale/impl/SplashMark.java b/designer-base/src/main/java/com/fr/design/locale/impl/SplashMark.java new file mode 100644 index 0000000000..790108978f --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/locale/impl/SplashMark.java @@ -0,0 +1,35 @@ +package com.fr.design.locale.impl; + +import com.fr.design.DesignerEnvManager; +import com.fr.general.GeneralContext; +import com.fr.general.locale.LocaleMark; + +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + +/** + * @author Hades + * @date 2019/6/24 + */ +public class SplashMark implements LocaleMark { + + private Map map = new HashMap(); + private static final String SPLASH_PATH = "/com/fr/design/images/splash_10.gif"; + private static final String SPLASH_EN_PATH = "/com/fr/design/images/splash_10_en.gif"; + private static final String SPLASH_JP_PATH = "/com/fr/design/images/splash_10_jp.gif"; + + public SplashMark() { + map.put(Locale.CHINA, SPLASH_PATH); + map.put(Locale.KOREA, SPLASH_EN_PATH); + map.put(Locale.JAPAN, SPLASH_JP_PATH); + map.put(Locale.US, SPLASH_EN_PATH); + map.put(Locale.TAIWAN, SPLASH_EN_PATH); + } + + @Override + public String getValue() { + String result = map.get(DesignerEnvManager.getEnvManager().getLanguage()); + return result == null ? SPLASH_EN_PATH : result; + } +} diff --git a/designer-base/src/main/java/com/fr/design/locale/impl/SupportLocaleImpl.java b/designer-base/src/main/java/com/fr/design/locale/impl/SupportLocaleImpl.java new file mode 100644 index 0000000000..61de25937c --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/locale/impl/SupportLocaleImpl.java @@ -0,0 +1,44 @@ +package com.fr.design.locale.impl; + +import com.fr.general.locale.SupportLocale; + +import java.util.HashSet; +import java.util.Locale; +import java.util.Set; + +/** + * 某些国际化环境支持的操作 + * 需要增加/删除支持的语言 统一在这里修改 无须改动业务代码 + * 后续有新的不同语言下的差异操作 添加新的枚举 + * @author Hades + * @date 2019/6/24 + */ +public enum SupportLocaleImpl implements SupportLocale { + + /** + * 社区菜单支持的国际化环境 + */ + COMMUNITY { + @Override + public Set support() { + Set set = new HashSet(); + set.add(Locale.CHINA); + set.add(Locale.TAIWAN); + return set; + } + }, + + /** + * Facebook支持的国际化环境 + */ + FACEBOOK { + @Override + public Set support() { + Set set = new HashSet(); + set.add(Locale.TAIWAN); + return set; + } + } + + +} diff --git a/designer-base/src/main/java/com/fr/design/locale/impl/UserInfoMark.java b/designer-base/src/main/java/com/fr/design/locale/impl/UserInfoMark.java new file mode 100644 index 0000000000..3739c49f6a --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/locale/impl/UserInfoMark.java @@ -0,0 +1,36 @@ +package com.fr.design.locale.impl; + +import com.fr.general.CloudCenter; +import com.fr.general.GeneralContext; +import com.fr.general.locale.LocaleMark; + +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + +/** + * @author Hades + * @date 2019/6/24 + */ +public class UserInfoMark implements LocaleMark { + + private Map map = new HashMap<>(); + private static final String CN_LOGIN_HTML = CloudCenter.getInstance().acquireUrlByKind("frlogin.cn"); + private static final String EN_LOGIN_HTML = CloudCenter.getInstance().acquireUrlByKind("frlogin.en"); + private static final String TW_LOGIN_HTML = CloudCenter.getInstance().acquireUrlByKind("frlogin.tw"); + private static final String JP_LOGIN_HTML = CloudCenter.getInstance().acquireUrlByKind("frlogin.jp"); + + public UserInfoMark() { + map.put(Locale.CHINA, CN_LOGIN_HTML); + map.put(Locale.KOREA, EN_LOGIN_HTML); + map.put(Locale.JAPAN, JP_LOGIN_HTML); + map.put(Locale.US, EN_LOGIN_HTML); + map.put(Locale.TAIWAN, TW_LOGIN_HTML); + } + + @Override + public String getValue() { + String result = map.get(GeneralContext.getLocale()); + return result == null ? EN_LOGIN_HTML : result; + } +} diff --git a/designer-base/src/main/java/com/fr/design/locale/impl/VideoMark.java b/designer-base/src/main/java/com/fr/design/locale/impl/VideoMark.java new file mode 100644 index 0000000000..2071faba3f --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/locale/impl/VideoMark.java @@ -0,0 +1,35 @@ +package com.fr.design.locale.impl; + +import com.fr.general.CloudCenter; +import com.fr.general.GeneralContext; +import com.fr.general.locale.LocaleMark; + +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + +/** + * @author Hades + * @date 2019/6/24 + */ +public class VideoMark implements LocaleMark { + + private Map map = new HashMap<>(); + private static final String VIDEO_EN = CloudCenter.getInstance().acquireUrlByKind("bbs.video.en"); + private static final String VIDEO_CN = CloudCenter.getInstance().acquireUrlByKind("bbs.video"); + private static final String VIDEO_TW = CloudCenter.getInstance().acquireUrlByKind("bbs.video.tw"); + + public VideoMark() { + map.put(Locale.CHINA, VIDEO_CN); + map.put(Locale.KOREA, VIDEO_EN); + map.put(Locale.JAPAN, VIDEO_EN); + map.put(Locale.US, VIDEO_EN); + map.put(Locale.TAIWAN, VIDEO_TW); + } + + @Override + public String getValue() { + String result = map.get(GeneralContext.getLocale()); + return result == null ? VIDEO_EN : result; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java b/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java index 330b9304a8..9a13ed9d79 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java @@ -36,6 +36,7 @@ public class TemplateInfoCollector implements XMLReadable, XMLWriter { private static final String XML_TEMPLATE_INFO_LIST = "TemplateInfoList"; private static final String XML_FILE_NAME = "tpl.info"; private static TemplateInfoCollector instance; + private static final int MAX_SIZE = 512 * 1024 * 1024; private Map templateInfoMap; private DesignerOpenHistory designerOpenHistory; @@ -167,7 +168,7 @@ public class TemplateInfoCollector implements XMLReadable, XMLWriter { } private boolean shouldCollectInfo() { - return DesignerEnvManager.getEnvManager().isJoinProductImprove() && FRContext.isChineseEnv(); + return FileUtils.sizeOf(getInfoFile()) <= MAX_SIZE && DesignerEnvManager.getEnvManager().isJoinProductImprove() && FRContext.isChineseEnv(); } /** diff --git a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index 7e0d6b3597..8a739f54f1 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -58,6 +58,9 @@ import com.fr.design.remote.action.RemoteDesignAuthManagerAction; import com.fr.design.utils.ThemeUtils; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; +import com.fr.general.locale.LocaleAction; +import com.fr.general.locale.LocaleCenter; +import com.fr.design.locale.impl.SupportLocaleImpl; import com.fr.log.FineLoggerFactory; import com.fr.plugin.context.PluginContext; import com.fr.plugin.context.PluginRuntime; @@ -240,7 +243,7 @@ public abstract class ToolBarMenuDock { public MenuDef[] menus(final ToolBarMenuDockPlus plus) { //删除之前创建的插件菜单监听 clearPluginListeners(); - java.util.List menuList = new java.util.ArrayList(); + final java.util.List menuList = new java.util.ArrayList(); // 添加文件菜单 menuList.add(createFileMenuDef(plus)); @@ -258,10 +261,13 @@ public abstract class ToolBarMenuDock { // 添加帮助菜单 menuList.add(createHelpMenuDef()); - if (GeneralContext.getLocale().equals(Locale.CHINA) || GeneralContext.getLocale().equals(Locale.TAIWAN)) { - // 添加社区菜单 - addCommunityMenuDef(menuList); - } + LocaleCenter.buildAction(new LocaleAction() { + @Override + public void execute() { + addCommunityMenuDef(menuList); + } + }, SupportLocaleImpl.COMMUNITY); + // 添加全部UpdateAction到actionmanager中 addAllUpdateActionsToList(menuList); @@ -532,7 +538,7 @@ public abstract class ToolBarMenuDock { * @return 社区菜单的子菜单 */ public ShortCut[] createCommunityShortCuts() { - java.util.List shortCuts = new ArrayList(); + final java.util.List shortCuts = new ArrayList(); shortCuts.add(new BBSAction()); shortCuts.add(new VideoAction()); shortCuts.add(new TutorialAction()); @@ -543,9 +549,12 @@ public abstract class ToolBarMenuDock { shortCuts.add(new CusDemandAction()); shortCuts.add(new CenterAction()); shortCuts.add(new SignAction()); - if (Locale.TAIWAN.equals(GeneralContext.getLocale())) { - shortCuts.add(new FacebookFansAction()); - } + LocaleCenter.buildAction(new LocaleAction() { + @Override + public void execute() { + shortCuts.add(new FacebookFansAction()); + } + }, SupportLocaleImpl.FACEBOOK); return shortCuts.toArray(new ShortCut[shortCuts.size()]); } diff --git a/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java b/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java index 2e36ea5d8a..6692155dce 100644 --- a/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java +++ b/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java @@ -279,7 +279,12 @@ public class DBManipulationPane extends BasicBeanPane { addSubmitConditionButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - final DSColumnLiteConditionPane conditionPane = new DSColumnLiteConditionPane(); + final DSColumnLiteConditionPane conditionPane = new DSColumnLiteConditionPane() { + @Override + protected boolean isNeedDoWithCondition(Condition liteCondition) { + return liteCondition != null; + } + }; String[] columns = chooseTable.currentColumnNames(); if (columns != null && columns.length > 0) { conditionPane.populateColumns(chooseTable.currentColumnNames()); diff --git a/designer-base/src/main/java/com/fr/file/StashedFILE.java b/designer-base/src/main/java/com/fr/file/StashedFILE.java index 181af28601..454433874e 100644 --- a/designer-base/src/main/java/com/fr/file/StashedFILE.java +++ b/designer-base/src/main/java/com/fr/file/StashedFILE.java @@ -71,4 +71,9 @@ public class StashedFILE extends AbstractFILE { public boolean isEnvFile() { return false; } + + @Override + public String toString() { + return FILEFactory.MEM_PREFIX + getName(); + } } diff --git a/designer-base/src/test/java/com/fr/design/data/DesignTableDataManagerTest.java b/designer-base/src/test/java/com/fr/design/data/DesignTableDataManagerTest.java new file mode 100644 index 0000000000..8d2f522c06 --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/data/DesignTableDataManagerTest.java @@ -0,0 +1,102 @@ +package com.fr.design.data; + +import com.fr.base.TableData; +import com.fr.data.impl.storeproc.StoreProcedure; +import com.fr.design.data.tabledata.wrapper.TableDataFactory; +import com.fr.design.data.tabledata.wrapper.TableDataWrapper; +import com.fr.file.ProcedureConfig; +import com.fr.file.TableDataConfig; +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.core.classloader.annotations.SuppressStaticInitializationFor; +import org.powermock.modules.junit4.PowerMockRunner; + +import java.util.HashMap; +import java.util.Map; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({TableDataFactory.class, StoreProcedure.class, TableDataConfig.class, ProcedureConfig.class}) +@SuppressStaticInitializationFor({"com.fr.design.data.tabledata.wrapper.TableDataFactory"}) +public class DesignTableDataManagerTest { + + @Test + public void testFireDataChange() { + + DesignTableDataManager.envChange(); + + + PowerMock.mockStatic(TableDataConfig.class); + + TableDataConfig config = EasyMock.mock(TableDataConfig.class); + TableDataConfig config2 = EasyMock.mock(TableDataConfig.class); + + TableData td1 = EasyMock.mock(TableData.class); + TableData td2 = EasyMock.mock(TableData.class); + TableData td3 = EasyMock.mock(TableData.class); + TableData td4 = EasyMock.mock(TableData.class); + EasyMock.expect(config.getTableData("firstData")).andReturn(td1).once(); + EasyMock.expect(config.getTableData("secondData")).andReturn(td2).once(); + EasyMock.expect(config2.getTableData("firstData")).andReturn(td3).once(); + EasyMock.expect(config2.getTableData("secondData")).andReturn(td4).once(); + + EasyMock.expect(TableDataConfig.getInstance()).andReturn(config).once().andReturn(config2).once(); + + PowerMock.mockStatic(TableDataFactory.class); + EasyMock.expect(TableDataFactory.getSortOfChineseNameOfServerData(config)) + .andReturn(new String[]{"firstData", "secondData"}).once(); + EasyMock.expect(TableDataFactory.getSortOfChineseNameOfServerData(config2)) + .andReturn(new String[]{"firstData", "secondData"}).once(); + + + ProcedureConfig proConfig = EasyMock.mock(ProcedureConfig.class); + StoreProcedure pc1 = PowerMock.createMock(StoreProcedure.class); + StoreProcedure pc2 = PowerMock.createMock(StoreProcedure.class); + ProcedureConfig proConfig2 = EasyMock.mock(ProcedureConfig.class); + StoreProcedure pc3 = PowerMock.createMock(StoreProcedure.class); + StoreProcedure pc4 = PowerMock.createMock(StoreProcedure.class); + + Map procedureMap = new HashMap<>(); + procedureMap.put("firstPRO", pc1); + procedureMap.put("secondPRO", pc2); + EasyMock.expect(proConfig.getProcedure("firstPRO")).andReturn(pc1).once(); + EasyMock.expect(proConfig.getProcedure("secondPRO")).andReturn(pc2).once(); + + Map procedureMap2 = new HashMap<>(); + procedureMap2.put("firstPRO", pc3); + procedureMap2.put("secondPRO", pc4); + EasyMock.expect(proConfig2.getProcedure("firstPRO")).andReturn(pc3).once(); + EasyMock.expect(proConfig2.getProcedure("secondPRO")).andReturn(pc4).once(); + + EasyMock.expect(proConfig.getProcedures()).andReturn(procedureMap).once(); + EasyMock.expect(proConfig2.getProcedures()).andReturn(procedureMap2).once(); + + PowerMock.mockStatic(ProcedureConfig.class); + EasyMock.expect(ProcedureConfig.getInstance()).andReturn(proConfig).once().andReturn(proConfig2).once(); + + EasyMock.replay(proConfig, config, config2, proConfig2); + PowerMock.replay(TableDataFactory.class, TableDataConfig.class, ProcedureConfig.class); + + + Map map = DesignTableDataManager.getAllEditingDataSet(null); + Assert.assertEquals(4, map.size()); + Assert.assertSame(pc1, map.get("firstPRO").getTableData()); + Assert.assertSame(pc2, map.get("secondPRO").getTableData()); + Assert.assertSame(td1, map.get("firstData").getTableData()); + Assert.assertSame(td2, map.get("secondData").getTableData()); + + DesignTableDataManager.fireDSChanged(new HashMap()); + + Map map2 = DesignTableDataManager.getAllEditingDataSet(null); + Assert.assertEquals(4, map2.size()); + Assert.assertSame(pc3, map2.get("firstPRO").getTableData()); + Assert.assertSame(pc4, map2.get("secondPRO").getTableData()); + Assert.assertSame(td3, map2.get("firstData").getTableData()); + Assert.assertSame(td4, map2.get("secondData").getTableData()); + + + } +} diff --git a/designer-base/src/test/java/com/fr/file/StashedFILETest.java b/designer-base/src/test/java/com/fr/file/StashedFILETest.java new file mode 100644 index 0000000000..f3c358574b --- /dev/null +++ b/designer-base/src/test/java/com/fr/file/StashedFILETest.java @@ -0,0 +1,23 @@ +package com.fr.file; + +import org.easymock.EasyMock; +import org.junit.Assert; +import org.junit.Test; + +public class StashedFILETest { + + /** + * 用于测试暂存文件未保存时的提示 + */ + @Test + public void testToString() { + FILE file = EasyMock.mock(FILE.class); + String name = "getA.cpt"; + EasyMock.expect(file.getName()).andReturn(name).once(); + EasyMock.replay(file); + FILE stashedFILE = new StashedFILE(file, new byte[0]); + String expectString = FILEFactory.MEM_PREFIX + name; + Assert.assertEquals(expectString, stashedFILE + ""); + EasyMock.verify(file); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/MapDataTree.java b/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/MapDataTree.java index 642630f149..825634547f 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/MapDataTree.java +++ b/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/MapDataTree.java @@ -6,7 +6,6 @@ import com.fr.general.ComparatorUtils; import com.fr.plugin.chart.map.designer.type.GEOJSONTreeHelper; import com.fr.plugin.chart.map.server.ChartGEOJSONHelper; import com.fr.plugin.chart.map.server.CompatibleGEOJSONHelper; -import com.fr.geojson.helper.GEOJSONHelper; import com.fr.stable.StringUtils; import javax.swing.JTree; @@ -98,7 +97,8 @@ public class MapDataTree extends JTree { } String dirPath = el.getUserObject().toString(); String url = CompatibleGEOJSONHelper.getJsonUrlByPathIncludeParam(dirPath); - if (GEOJSONHelper.getInstance().isValidDirPath(dirPath) && ComparatorUtils.equals(jsonUrl, url)){ + //先equals再valid原因:valid 远程下实时去服务器看有没有json文件 + if (ComparatorUtils.equals(jsonUrl, url) && GEOJSONTreeHelper.isValidDirPath(dirPath)) { selectTreeNode(el, m_model); return el; } @@ -151,7 +151,7 @@ public class MapDataTree extends JTree { DefaultMutableTreeNode el = els.nextElement(); String path = el.getUserObject().toString(); String fileName = ChartGEOJSONHelper.getPresentNameWithPath(path); - if (GEOJSONHelper.getInstance().isValidDirPath(path) && StringUtils.contains(fileName, text)) { + if (StringUtils.contains(fileName, text) && GEOJSONTreeHelper.isValidDirPath(path)) { selectTreeNode(el, m_model); return; } diff --git a/designer-realize/src/main/java/com/fr/design/actions/insert/flot/ImageFloatAction.java b/designer-realize/src/main/java/com/fr/design/actions/insert/flot/ImageFloatAction.java index 9ba3ee9961..d7f98a2122 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/insert/flot/ImageFloatAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/insert/flot/ImageFloatAction.java @@ -87,7 +87,7 @@ public class ImageFloatAction extends ElementCaseAction { if (selectedFile != null && selectedFile.isFile()) { CellImage cellImage = selectImagePane.update(); - Image image = cellImage.getImage(); + Image image = cellImage.getBufferImage(); JTemplate currentEditingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); currentEditingTemplate.setPictureElem(floatElement, cellImage); diff --git a/designer-realize/src/main/java/com/fr/design/headerfooter/ImagePane.java b/designer-realize/src/main/java/com/fr/design/headerfooter/ImagePane.java index 1011f8036c..02d46c82aa 100644 --- a/designer-realize/src/main/java/com/fr/design/headerfooter/ImagePane.java +++ b/designer-realize/src/main/java/com/fr/design/headerfooter/ImagePane.java @@ -78,7 +78,7 @@ public class ImagePane extends BasicPane { } public Image update() { - return this.imagePreviewPane.getImage(); + return this.imagePreviewPane.getImageWithSuffix(); } /** diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java index 6e72e98fef..07136bc1ef 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java @@ -68,7 +68,6 @@ import com.fr.file.FILE; import com.fr.file.FileNodeFILE; import com.fr.file.filetree.FileNode; import com.fr.general.ComparatorUtils; -import com.fr.general.ImageWithSuffix; import com.fr.general.ModuleContext; import com.fr.grid.Grid; import com.fr.grid.GridUtils; @@ -90,7 +89,6 @@ import com.fr.report.elementcase.TemplateElementCase; import com.fr.report.poly.PolyWorkSheet; import com.fr.report.worksheet.WorkSheet; import com.fr.stable.ArrayUtils; -import com.fr.stable.CoreGraphHelper; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.module.Module; @@ -623,7 +621,7 @@ public class JWorkBook extends JTemplate { if (workBook instanceof WorkBookAdapter) { elem.setValue(new CellImagePainter(cellImage)); } else { - elem.setValue(ImageWithSuffix.build(cellImage.getImage(),cellImage.getSuffix())); + elem.setValue(cellImage.getImage()); } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/entity/FileEntityBuilder.java b/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/entity/FileEntityBuilder.java index c8ac3b32c0..4497a0b28f 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/entity/FileEntityBuilder.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/entity/FileEntityBuilder.java @@ -2,12 +2,9 @@ package com.fr.design.mainframe.messagecollect.entity; import com.fr.config.MarketConfig; import com.fr.design.DesignerEnvManager; -import com.fr.general.CloudCenter; import com.fr.general.CloudClient; import com.fr.general.IOUtils; -import com.fr.general.http.HttpToolbox; import com.fr.json.JSONArray; -import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; import com.fr.stable.CommonUtils; import com.fr.stable.CoreConstants; @@ -22,7 +19,6 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.URLEncoder; -import java.util.HashMap; import java.util.UUID; /** @@ -32,11 +28,7 @@ import java.util.UUID; public class FileEntityBuilder { private static final String FOCUS_POINT_FILE_ROOT_PATH = "FocusPoint"; - private static final String FOCUS_POINT_FILE_UPLOAD_TOPIC = "__fine_intelli_file_upload__"; private static final String FILE_FROM = "design"; - private static final String FOCUS_POINT_FILE_UPLOAD_TYPE = "FocusPoint"; - private static final String FOCUS_POINT_FILE_UPLOAD_URL = CloudCenter.getInstance().acquireUrlByKind("design.feedback"); - private static final String FOCUS_POINT_URL_KEY = "focuspoint"; /** * 文件夹路径 @@ -109,29 +101,8 @@ public class FileEntityBuilder { String filePath = FOCUS_POINT_FILE_ROOT_PATH + CoreConstants.SEPARATOR + today + CoreConstants.SEPARATOR + keyFileName; String bbsUserName = MarketConfig.getInstance().getBbsUsername(); String uuid = DesignerEnvManager.getEnvManager().getUUID(); - String name = bbsUserName == null ? uuid : bbsUserName; + String name = StringUtils.isEmpty(bbsUserName) ? uuid : bbsUserName; - client.uploadFile(file, filePath, name, FILE_FROM); - addMessageQueue(filePath, bbsUserName, uuid); - } - - private static void addMessageQueue(String filePath, String userName, String uuid) { - JSONObject uploadInfo = new JSONObject(FOCUS_POINT_FILE_UPLOAD_URL); - String focusPointUrl = uploadInfo.optString(FOCUS_POINT_URL_KEY); - try { - HashMap params = new HashMap<>(); - params.put("topic", FOCUS_POINT_FILE_UPLOAD_TOPIC); - params.put("username", URLEncoder.encode(userName, EncodeConstants.ENCODING_UTF_8)); - params.put("uuid", uuid); - params.put("filepath", filePath); - params.put("timestamp", String.valueOf(System.currentTimeMillis())); - params.put("signature", String.valueOf(CommonUtils.signature())); - params.put("type", FOCUS_POINT_FILE_UPLOAD_TYPE); - if(StringUtils.isNotEmpty(focusPointUrl)){ - HttpToolbox.post(focusPointUrl, params); - } - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } + client.uploadFile(file, filePath, URLEncoder.encode(name, EncodeConstants.ENCODING_UTF_8), FILE_FROM); } } diff --git a/designer-realize/src/main/java/com/fr/design/report/SelectImagePane.java b/designer-realize/src/main/java/com/fr/design/report/SelectImagePane.java index ba57676ecd..bcad15c76c 100644 --- a/designer-realize/src/main/java/com/fr/design/report/SelectImagePane.java +++ b/designer-realize/src/main/java/com/fr/design/report/SelectImagePane.java @@ -1,21 +1,18 @@ package com.fr.design.report; -import com.fr.base.BaseUtils; import com.fr.base.Style; import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.frpane.ImgChooseWrapper; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIRadioButton; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.style.background.image.ImageFileChooser; import com.fr.design.style.background.image.ImagePreviewPane; -import com.fr.design.utils.ImageUtils; import com.fr.design.utils.gui.GUICoreUtils; -import com.fr.general.ImageWithSuffix; import com.fr.report.cell.Elem; import com.fr.report.cell.cellattr.CellImage; import com.fr.report.cell.painter.CellImagePainter; import com.fr.stable.Constants; -import com.fr.stable.CoreGraphHelper; import javax.swing.BorderFactory; import javax.swing.ButtonGroup; @@ -27,7 +24,6 @@ import java.awt.GridLayout; import java.awt.Image; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.awt.image.BufferedImage; import java.io.File; /** @@ -44,8 +40,6 @@ public class SelectImagePane extends BasicPane { private Style imageStyle = null; - private Image previewImage = null; - private File imageFile; public SelectImagePane() { @@ -119,21 +113,8 @@ public class SelectImagePane extends BasicPane { .showOpenDialog(SelectImagePane.this); if (returnVal != JFileChooser.CANCEL_OPTION) { File selectedFile = imageFileChooser.getSelectedFile(); - - if (selectedFile != null && selectedFile.isFile()) { - String filePath = selectedFile.getPath(); - BufferedImage image = BaseUtils.readImage(filePath); - CoreGraphHelper.waitForImage(image); - - imageFile = selectedFile; - setImageStyle(); - previewPane.setImageWithSuffix(ImageWithSuffix.build(image, ImageUtils.getImageType(selectedFile))); - previewPane.setImageStyle(imageStyle); - previewImage = image; - } else { - previewPane.setImage(null); - } - previewPane.repaint(); + imageFile = selectedFile; + ImgChooseWrapper.getInstance(previewPane, imageFileChooser, imageStyle, null).dealWithImageFile(returnVal); } } }; @@ -202,7 +183,6 @@ public class SelectImagePane extends BasicPane { public void setImage(Image image) { previewPane.setImage(image); - this.previewImage = image; } public CellImage update() { diff --git a/designer-realize/src/main/java/com/fr/design/webattr/ViewToolBarPane.java b/designer-realize/src/main/java/com/fr/design/webattr/ViewToolBarPane.java index 8f7e4b8475..c396538dd4 100644 --- a/designer-realize/src/main/java/com/fr/design/webattr/ViewToolBarPane.java +++ b/designer-realize/src/main/java/com/fr/design/webattr/ViewToolBarPane.java @@ -52,9 +52,10 @@ public class ViewToolBarPane extends AbstractEditToolBarPane { editToolBarButton.setEnabled(isUseToolBarCheckBox.isSelected()); } }); - sortCheckBox.setSelected(true); - conditonFilterBox.setSelected(true); - listFilterBox.setSelected(true); + // 切换BI工程目录 webView未设置 默认false + sortCheckBox.setSelected(false); + conditonFilterBox.setSelected(false); + listFilterBox.setSelected(false); northPane.add(GUICoreUtils.createFlowPane(new Component[]{sortCheckBox, conditonFilterBox, listFilterBox}, FlowLayout.LEFT, 6)); northPane.add(GUICoreUtils.createFlowPane(new Component[] {isUseToolBarCheckBox, editToolBarButton}, FlowLayout.LEFT)); northPane.add(GUICoreUtils.createFlowPane(showListenersLabel, FlowLayout.LEFT)); diff --git a/designer-realize/src/main/java/com/fr/grid/Grid.java b/designer-realize/src/main/java/com/fr/grid/Grid.java index 16b8924731..19e68a9139 100644 --- a/designer-realize/src/main/java/com/fr/grid/Grid.java +++ b/designer-realize/src/main/java/com/fr/grid/Grid.java @@ -961,7 +961,6 @@ public class Grid extends BaseGridComponent { if (!ComparatorUtils.equals_exactly(oldValue, newValue)) { if (newValue instanceof CellImage) { CellImage cellImage = (CellImage) newValue; - newValue = cellImage.getImage(); JTemplate currentEditingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); currentEditingTemplate.setPictureElem(selectedFloatElement, cellImage); diff --git a/designer-realize/src/main/java/com/fr/start/CollectUserInformationDialog.java b/designer-realize/src/main/java/com/fr/start/CollectUserInformationDialog.java index c32c2307d2..139030642c 100644 --- a/designer-realize/src/main/java/com/fr/start/CollectUserInformationDialog.java +++ b/designer-realize/src/main/java/com/fr/start/CollectUserInformationDialog.java @@ -8,11 +8,14 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextarea.DescriptionTextArea; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.locale.impl.UserInfoMark; import com.fr.design.mainframe.ActiveKeyGenerator; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.CloudCenter; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; +import com.fr.general.locale.LocaleCenter; +import com.fr.general.locale.LocaleMark; import javax.swing.*; import javax.swing.border.TitledBorder; @@ -31,11 +34,6 @@ public class CollectUserInformationDialog extends UIDialog { private static final int ONLINE_VERIFY_TIMEOUT = 30 * 1000; - private static final String CN_LOGIN_HTML = CloudCenter.getInstance().acquireUrlByKind("frlogin.cn"); - private static final String EN_LOGIN_HTML = CloudCenter.getInstance().acquireUrlByKind("frlogin.en"); - private static final String TW_LOGIN_HTML = CloudCenter.getInstance().acquireUrlByKind("frlogin.tw"); - private static final String JP_LOGIN_HTML = CloudCenter.getInstance().acquireUrlByKind("frlogin.jp"); - private UITextField keyTextField; private ActionListener actionListener = new ActionListener() { @@ -129,19 +127,9 @@ public class CollectUserInformationDialog extends UIDialog { private void getKeyAction() { - Locale locale = GeneralContext.getLocale(); - String url = EN_LOGIN_HTML; - if (ComparatorUtils.equals(locale, Locale.TAIWAN)) { - url = TW_LOGIN_HTML; - } - if (ComparatorUtils.equals(locale, Locale.CHINA)) { - url = CN_LOGIN_HTML; - } - if (ComparatorUtils.equals(locale, Locale.JAPAN)) { - url = JP_LOGIN_HTML; - } + LocaleMark localeMark = LocaleCenter.getMark(UserInfoMark.class); try { - Desktop.getDesktop().browse(new URI(url)); + Desktop.getDesktop().browse(new URI(localeMark.getValue())); } catch (Exception ignored) { } diff --git a/designer-realize/src/main/java/com/fr/start/SplashContext.java b/designer-realize/src/main/java/com/fr/start/SplashContext.java index 87a4237e0d..ab358e8d71 100644 --- a/designer-realize/src/main/java/com/fr/start/SplashContext.java +++ b/designer-realize/src/main/java/com/fr/start/SplashContext.java @@ -1,12 +1,14 @@ package com.fr.start; -import com.fr.design.DesignerEnvManager; import com.fr.design.i18n.Toolkit; +import com.fr.design.locale.impl.SplashMark; import com.fr.design.mainframe.bbs.BBSConstants; import com.fr.event.Event; import com.fr.event.EventDispatcher; import com.fr.event.Listener; import com.fr.general.GeneralContext; +import com.fr.general.locale.LocaleCenter; +import com.fr.general.locale.LocaleMark; import com.fr.module.ModuleEvent; import com.fr.stable.StringUtils; @@ -168,13 +170,7 @@ public class SplashContext { } private static String getSplashPath() { - Locale locale = DesignerEnvManager.getEnvManager().getLanguage(); - if (Locale.US.equals(locale) || Locale.KOREA.equals(locale) || Locale.TAIWAN.equals(locale)) { - return "/com/fr/design/images/splash_10_en.gif"; - } else if (Locale.JAPAN.equals(locale)) { - return "/com/fr/design/images/splash_10_jp.gif"; - } else { - return "/com/fr/design/images/splash_10.gif"; - } + LocaleMark localeMark = LocaleCenter.getMark(SplashMark.class); + return localeMark.getValue(); } } \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java index 87e8142f28..93e4874e81 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java @@ -3,8 +3,12 @@ package com.fr.start.module; import com.fr.base.BaseFormula; import com.fr.base.Formula; import com.fr.base.MultiFieldParameter; +import com.fr.base.passport.FinePassportListenerAdapter; +import com.fr.base.passport.FinePassportManager; import com.fr.base.process.ProcessOperator; import com.fr.chart.chartattr.ChartCollection; +import com.fr.config.MarketConfig; +import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.NewFormAction; import com.fr.design.actions.core.ActionFactory; @@ -113,9 +117,9 @@ import java.util.concurrent.Executors; * 之后慢慢将DesignerModule拆成Activator */ public class DesignerActivator extends Activator { - + private LogHandler logHandler = null; - + @Override public void start() { List markers = rightCollectMutable(InterMutableKey.Path); @@ -129,12 +133,13 @@ public class DesignerActivator extends Activator { loadLogAppender(); DesignerSocketIO.update(); UserInfoPane.getInstance().updateBBSUserInfo(); + storePassport(); } - + private void loadLogAppender() { logHandler = new LogHandler() { final DesignerLogAppender logAppender = new DesignerLogAppender(); - + @Override public DesignerLogAppender getHandler() { return logAppender; @@ -142,32 +147,32 @@ public class DesignerActivator extends Activator { }; FineLoggerFactory.getLogger().addLogAppender(logHandler); } - + private void unloadLogAppender() { if (logHandler != null) { FineLoggerFactory.getLogger().removeLogAppender(logHandler); } } - + private void designerModuleStart() { - + StableFactory.registerMarkedClass(ExtraDesignClassManagerProvider.XML_TAG, ExtraDesignClassManager.class); ActionFactory.registerCellInsertActionClass(actionsForInsertCellElement()); ActionFactory.registerFloatInsertActionClass(actionsForInsertFloatElement()); DesignModuleFactory.registerCreators4Hyperlink(hyperlinkTypes()); - + justStartModules4Designer(); - + CalculatorProviderContext.setValueConverter(valueConverter()); GeneralXMLTools.Object_Tokenizer = startXMLReadObjectTokenizer(); GeneralXMLTools.Object_XML_Writer_Finder = startObjectXMLWriterFinder(); addAdapterForPlate(); - + designerRegister(); - + InformationCollector.getInstance().collectStartTime(); } - + private static void preLoadPane() { ExecutorService service = Executors.newCachedThreadPool(); service.submit(new Runnable() { @@ -176,7 +181,7 @@ public class DesignerActivator extends Activator { LogMessageBar.getInstance(); } }); - + service.submit(new Runnable() { @Override public void run() { @@ -201,7 +206,7 @@ public class DesignerActivator extends Activator { DesignerFrameFileDealerPane.getInstance();//这边会涉及到TemplateTreePane } }); - + service.submit(new Runnable() { @Override public void run() { @@ -210,26 +215,26 @@ public class DesignerActivator extends Activator { }); service.shutdown(); } - + private static Class[] actionsForInsertCellElement() { List> classes = new ArrayList<>(); Set providers = ExtraDesignClassManager.getInstance().getArray(ElementUIProvider.MARK_STRING); for (ElementUIProvider provider : providers) { classes.add(provider.actionForInsertCellElement()); } - + return ArrayUtils.addAll(new Class[]{ - DSColumnCellAction.class, - GeneralCellAction.class, - RichTextCellAction.class, - FormulaCellAction.class, - ChartCellAction.class, - ImageCellAction.class, - BiasCellAction.class, - SubReportCellAction.class + DSColumnCellAction.class, + GeneralCellAction.class, + RichTextCellAction.class, + FormulaCellAction.class, + ChartCellAction.class, + ImageCellAction.class, + BiasCellAction.class, + SubReportCellAction.class }, classes.toArray(new Class[classes.size()])); } - + private static Class[] actionsForInsertFloatElement() { List> classes = new ArrayList<>(); Set providers = ExtraDesignClassManager.getInstance().getArray(ElementUIProvider.MARK_STRING); @@ -237,28 +242,28 @@ public class DesignerActivator extends Activator { classes.add(provider.actionForInsertFloatElement()); } return ArrayUtils.addAll(new Class[]{ - TextBoxFloatAction.class, - FormulaFloatAction.class, - ChartFloatAction.class, - ImageFloatAction.class + TextBoxFloatAction.class, + FormulaFloatAction.class, + ChartFloatAction.class, + ImageFloatAction.class }, classes.toArray(new Class[classes.size()])); } - + private static NameableCreator[] hyperlinkTypes() { return new NameableCreator[]{ - new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Reportlet"), ReportletHyperlink.class, ReportletHyperlinkPane.ChartNoRename.class), - new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Email"), EmailJavaScript.class, EmailPane.class), - new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Web_Link"), WebHyperlink.class, WebHyperlinkPane.ChartNoRename.class), - new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_JavaScript_Dynamic_Parameters"), ParameterJavaScript.class, ParameterJavaScriptPane.ChartNoRename.class), - new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_JavaScript"), JavaScriptImpl.class, JavaScriptImplPane.ChartNoRename.class) + new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Reportlet"), ReportletHyperlink.class, ReportletHyperlinkPane.ChartNoRename.class), + new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Email"), EmailJavaScript.class, EmailPane.class), + new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Web_Link"), WebHyperlink.class, WebHyperlinkPane.ChartNoRename.class), + new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_JavaScript_Dynamic_Parameters"), ParameterJavaScript.class, ParameterJavaScriptPane.ChartNoRename.class), + new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_JavaScript"), JavaScriptImpl.class, JavaScriptImplPane.ChartNoRename.class) }; } - - + + private static void justStartModules4Designer() { formDesignerRegister(); } - + /** * CellElementValueConverter用来处理设计器格子里的值,将公式/数组/其他元素转换成对应的值。 * @@ -267,7 +272,7 @@ public class DesignerActivator extends Activator { private static ValueConverter valueConverter() { return new CellElementValueConverter(); } - + /* * 针对不同的对象,在读取Object对象的xml的时候需要使用不同的对象生成器 * @return 返回对象生成器 @@ -275,7 +280,7 @@ public class DesignerActivator extends Activator { private static ObjectTokenizer startXMLReadObjectTokenizer() { return new ReportXMLUtils.ReportObjectTokenizer(); } - + /** * 针对不同的对象,在写对象的XML时需要使用不同的XML生成器 * @@ -284,51 +289,51 @@ public class DesignerActivator extends Activator { private static ObjectXMLWriterFinder startObjectXMLWriterFinder() { return new ReportXMLUtils.ReportObjectXMLWriterFinder(); } - - + + //wei:fs的模块中可能有需要设计器界面做设置的地方,在这边添加 private static void addAdapterForPlate() { - + ProcessTransitionAdapter.setProcessTransitionAdapter(new ProcessTransitionAdapter() { - + @Override protected String[] getTransitionNamesByBook(String book) { return StableFactory.getMarkedObject(ProcessOperator.MARK_STRING, ProcessOperator.class, ProcessOperator.EMPTY).getTransitionNamesByBook(book); } - + @Override protected String[] getParaNames(String book) { return StableFactory.getMarkedObject(ProcessOperator.MARK_STRING, ProcessOperator.class, ProcessOperator.EMPTY).getParaNames(book); } - + @Override protected ParameterProvider[] getParas(String book) { return StableFactory.getMarkedObject(ProcessOperator.MARK_STRING, ProcessOperator.class, ProcessOperator.EMPTY).getParas(book); } - + @Override protected MultiFieldParameter[] getAllMultiFieldParas(String book) { return StableFactory.getMarkedObject(ProcessOperator.MARK_STRING, ProcessOperator.class, ProcessOperator.EMPTY).getAllMultiFieldParas(book); } }); } - + private static void designerRegister() { registerCellEditor(); registerFloatEditor(); registerData4Form(); registerOtherPane(); } - + private static void registerOtherPane() { StableFactory.registerMarkedClass(BBSGuestPaneProvider.XML_TAG, BBSGuestPane.class); } - + /** * kunsnat:注册单元格选中Editor */ private static void registerCellEditor() { - + ActionFactory.registerCellEditor(String.class, new CellStringQuickEditor()); ActionFactory.registerCellEditor(Number.class, new CellStringQuickEditor()); ActionFactory.registerCellEditor(BaseFormula.class, new CellFormulaQuickEditor()); @@ -341,7 +346,7 @@ public class DesignerActivator extends Activator { ActionFactory.registerCellEditor(CellImagePainter.class, new CellImageQuickEditor()); //todo 图表编辑器populate没能实现刷新面板显示 ActionFactory.registerCellEditorClass(ChartCollection.class, BasicChartQuickEditor.class); - + Set providers = ExtraDesignClassManager.getInstance().getArray(ElementUIProvider.MARK_STRING); for (ElementUIProvider provider : providers) { try { @@ -351,13 +356,13 @@ public class DesignerActivator extends Activator { } } } - - + + /** * kunnat: 注册悬浮选中Editor */ private static void registerFloatEditor() { - + ActionFactory.registerFloatEditor(String.class, new FloatStringQuickEditor()); ActionFactory.registerFloatEditor(Formula.class, new FloatStringQuickEditor()); ActionFactory.registerFloatEditor(Image.class, new FloatImageQuickEditor()); @@ -366,19 +371,19 @@ public class DesignerActivator extends Activator { //todo 图表编辑器populate没能实现刷新面板显示 ActionFactory.registerFloatEditorClass(ChartCollection.class, FloatChartQuickEditor.class); } - - + + private static void registerData4Form() { StableFactory.registerMarkedClass(FormECDesignerProvider.XML_TAG, FormElementCaseDesigner.class); StableFactory.registerMarkedClass(FormECCompositeProvider.XML_TAG, FormReportComponentComposite.class); DesignModuleFactory.registerParameterReader(new WorkBookParameterReader()); } - - + + private static void formDesignerRegister() { - + StableFactory.registerMarkedObject(DesignToolbarProvider.STRING_MARKED, WidgetToolBarPane.getInstance()); - + DesignModuleFactory.registerNewFormActionClass(NewFormAction.class); DesignModuleFactory.registerFormParaDesignerClass(FormParaDesigner.class); DesignModuleFactory.registerParaPropertyPaneClass(ParameterPropertyPane.class); @@ -386,15 +391,26 @@ public class DesignerActivator extends Activator { DesignModuleFactory.registerWidgetPropertyPaneClass(WidgetPropertyPane.class); DesignModuleFactory.registerButtonDetailPaneClass(FormSubmitButtonDetailPane.class); DesignModuleFactory.registerParameterReader(new FormParameterReader()); - + StableFactory.registerMarkedClass(BaseJForm.XML_TAG, JForm.class); - + StableFactory.registerMarkedObject(ElementCaseThumbnailProcessor.MARK_STRING, new ElementCaseThumbnail()); } - + + private static void storePassport() { + FinePassportManager.getInstance().storePassport(MarketConfig.getInstance().getBbsUsername(), DesignerEnvManager.getEnvManager().getActivationKey()); + FinePassportManager.getInstance().addPassportListener(new FinePassportListenerAdapter() { + @Override + public void onLoginSuccess() { + FinePassportManager.getInstance().storePassport(MarketConfig.getInstance().getBbsUsername(), DesignerEnvManager.getEnvManager().getActivationKey()); + } + }); + } + @Override public void stop() { unloadLogAppender(); DesignerSocketIO.close(); } } + diff --git a/designer-realize/src/test/java/com.fr/design/mainframe/JFileTest.java b/designer-realize/src/test/java/com.fr/design/mainframe/JFileTest.java new file mode 100644 index 0000000000..3b5bd1a14e --- /dev/null +++ b/designer-realize/src/test/java/com.fr/design/mainframe/JFileTest.java @@ -0,0 +1,69 @@ +package com.fr.design.mainframe; + +import com.fr.config.dao.DaoContext; +import com.fr.config.dao.impl.LocalClassHelperDao; +import com.fr.config.dao.impl.LocalEntityDao; +import com.fr.config.dao.impl.LocalXmlEntityDao; +import com.fr.form.main.Form; +import com.fr.form.ui.ElementCaseEditor; +import com.fr.general.ImageWithSuffix; +import com.fr.general.ModuleContext; +import com.fr.main.impl.WorkBook; +import com.fr.report.cell.DefaultTemplateCellElement; +import com.fr.report.cell.TemplateCellElement; +import com.fr.report.cell.cellattr.CellImage; +import com.fr.report.restriction.CellCountRestriction; +import com.fr.report.restriction.ReportRestrictionScene; +import com.fr.report.worksheet.FormElementCase; +import com.fr.report.worksheet.WorkSheet; +import com.fr.restriction.Restrictions; +import com.fr.stable.module.Module; +import com.fr.start.Designer; +import junit.framework.TestCase; +import org.junit.Assert; + +import java.awt.image.BufferedImage; + +public class JFileTest extends TestCase { + @Override + protected void setUp() throws Exception { + DaoContext.setEntityDao(new LocalEntityDao()); + DaoContext.setClassHelperDao(new LocalClassHelperDao()); + DaoContext.setXmlEntityDao(new LocalXmlEntityDao()); + Restrictions.register(ReportRestrictionScene.CELL_COUNT, new CellCountRestriction()); + ModuleContext.startModule(Module.PAGE_MODULE); + ModuleContext.startModule(Module.VIEW_MODULE); + Designer designer = new Designer(new String[0]); + } + + public void testJWorkBookSetPicture() { + WorkBook workBook = new WorkBook(); + WorkSheet workSheet = new WorkSheet(); + workBook.addReport("sheet1", workSheet); + TemplateCellElement cellElement = new DefaultTemplateCellElement(); + workSheet.addCellElement(cellElement); + ImageWithSuffix imageWithSuffix = ImageWithSuffix.build(new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB), "jpg"); + CellImage cellImage = new CellImage(); + cellImage.setImage(imageWithSuffix); + JWorkBook jWorkBook = new JWorkBook(workBook, "text"); + jWorkBook.setPictureElem(cellElement, cellImage); + Assert.assertEquals(imageWithSuffix, cellElement.getValue()); + } + + public void testJFormSetPicture() { + Form form = new Form(); + ElementCaseEditor editor = new ElementCaseEditor(); + FormElementCase elementCase = new FormElementCase(); + TemplateCellElement cellElement = new DefaultTemplateCellElement(); + elementCase.addCellElement(cellElement); + editor.setElementCase(elementCase); + form.getContainer().addWidget(editor); + ImageWithSuffix imageWithSuffix = ImageWithSuffix.build(new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB), "jpg"); + CellImage cellImage = new CellImage(); + cellImage.setImage(imageWithSuffix); + JForm jForm = new JForm(); + jForm.setTarget(form); + jForm.setPictureElem(cellElement, cellImage); + Assert.assertEquals(imageWithSuffix, cellElement.getValue()); + } +} \ No newline at end of file