Browse Source

Merge pull request #12263 in DESIGN/design from release/11.0 to bugfix/11.0

* commit '0e41cdda2f873dd7cd26f5e7e7dbae75b6e677e4':
  fix: fvs适配jxbrowser7.26兼容问题 #REPORT-98648
  REPORT-98450 批量修改单元格格式会影响单元格样式 【问题原因】实际修改时,未考虑到style是包含字体、背景等其他样式,代码中将整个style样式替换为了左上角单元格的样式 【改动思路】批量操作时,仅修改格式样式
  REPORT-97334 单测修复 com.fr.design.*  【问题原因】见 https://kms.fineres.com/pages/viewpage.action?pageId=743611693  【改动思路】同上
  REPORT-94637 单元测试修复 【问题原因】com.fr.design部分单测修复 【改动思路】详见https://kms.fineres.com/pages/viewpage.action?pageId=742496063 【review建议】
  无jira任务 代码规范
  REPORT-93559 补充兼容插件接口
  REPORT-94637 单测修复
  REPORT-94637 单测修复
  REPORT-93559 提升jxbrowser 7.26
  无jira任务 代码质量注释
  REPORT-93559 api优化
  REPORT-93559 JxUIPane升级支持Jxbrowser7替换ModernUIPane
  Revert "fix: fvs图表配置不保存不生效 #REPORT-94359"
  fix: fvs图表配置不保存不生效 #REPORT-94359
bugfix/11.0
superman 1 year ago
parent
commit
6c48ccba4b
  1. 10
      build.gradle
  2. 16
      designer-base/src/main/java/com/fr/design/actions/help/FineUIAction.java
  3. 19
      designer-base/src/main/java/com/fr/design/dcm/UniversalDatabasePane.java
  4. 22
      designer-base/src/main/java/com/fr/design/dcm/UniversalDcmBridge.java
  5. 2
      designer-base/src/main/java/com/fr/design/fun/DefaultValueAdjustProvider.java
  6. 6
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractDefaultValueAdjustProvider.java
  7. 40
      designer-base/src/main/java/com/fr/design/jxbrowser/BrowserExecutor.java
  8. 140
      designer-base/src/main/java/com/fr/design/jxbrowser/JxEngine.java
  9. 536
      designer-base/src/main/java/com/fr/design/jxbrowser/JxUIPane.java
  10. 113
      designer-base/src/main/java/com/fr/design/jxbrowser/MimeType.java
  11. 171
      designer-base/src/main/java/com/fr/design/jxbrowser/NxInterceptRequestCallback.java
  12. 20
      designer-base/src/main/java/com/fr/design/jxbrowser/PropertyBuild.java
  13. 54
      designer-base/src/main/java/com/fr/design/login/DesignerLoginBridge.java
  14. 20
      designer-base/src/main/java/com/fr/design/login/DesignerLoginPane.java
  15. 34
      designer-base/src/main/java/com/fr/design/login/guide/DesignerGuideBridge.java
  16. 3
      designer-base/src/main/java/com/fr/design/login/guide/DesignerGuideHelper.java
  17. 20
      designer-base/src/main/java/com/fr/design/login/guide/DesignerGuidePane.java
  18. 16
      designer-base/src/main/java/com/fr/design/ui/ModernUIConstants.java
  19. 24
      designer-base/src/main/java/com/fr/design/ui/ModernUIPane.java
  20. 33
      designer-base/src/main/java/com/fr/design/ui/compatible/BuilderDiff.java
  21. 35
      designer-base/src/main/java/com/fr/design/ui/compatible/ModernUIPaneFactory.java
  22. 362
      designer-base/src/main/java/com/fr/design/ui/compatible/NewModernUIPane.java
  23. 86
      designer-base/src/main/java/com/fr/design/ui/compatible/NxComplexInterceptRequestCallback.java
  24. 148
      designer-base/src/main/java/com/fr/design/ui/compatible/NxInterceptRequestCallback.java
  25. 36
      designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateDialog.java
  26. 10
      designer-base/src/main/java/com/fr/design/update/push/DesignerUpdateInfo.java
  27. 8
      designer-base/src/main/java/com/fr/design/upm/UpmBridge.java
  28. 9
      designer-base/src/main/java/com/fr/design/upm/UpmBridgeV7.java
  29. 4
      designer-base/src/main/java/com/fr/design/upm/UpmFinder.java
  30. 30
      designer-base/src/main/java/com/fr/design/upm/UpmShowPane.java
  31. 20
      designer-base/src/test/java/com/fr/design/actions/help/TutorialActionTest.java
  32. 10
      designer-base/src/test/java/com/fr/design/base/clipboard/DesignerClipboardTest.java
  33. 17
      designer-base/src/test/java/com/fr/design/data/DesignTableDataManagerTest.java
  34. 18
      designer-base/src/test/java/com/fr/design/data/datapane/TableDataPaneListPaneTest.java
  35. 4
      designer-base/src/test/java/com/fr/design/data/tabledata/paste/TableDataFollowingPasteUtilsTest.java
  36. 4
      designer-base/src/test/java/com/fr/design/formula/FormulaPaneTest.java
  37. 12
      designer-base/src/test/java/com/fr/design/formula/FunctionConstantsTest.java
  38. 17
      designer-base/src/test/java/com/fr/design/gui/icombocheckbox/UICheckListPopupTest.java
  39. 72
      designer-base/src/test/java/com/fr/design/jxbrowser/JxUIPaneTest.java
  40. 21
      designer-base/src/test/java/com/fr/design/jxbrowser/MimeTypeTest.java
  41. 128
      designer-base/src/test/java/com/fr/design/mainfarme/toolbar/ToolBarMenuDockTest.java
  42. 3
      designer-base/src/test/java/com/fr/design/ui/FineUIDemo.java
  43. 10
      designer-base/src/test/java/com/fr/design/ui/report/TemplateWebSettingDemo.java
  44. 4
      designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxRichTextDetailedFieldListPane.java
  45. 4
      designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxRichTextResultFieldListPane.java
  46. 6
      designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxTooltipContentPane.java
  47. 6
      designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java
  48. 6
      designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldListPane.java
  49. 2
      designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichEditorModel.java
  50. 103
      designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichEditorPane.java
  51. 6
      designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichTextPane.java
  52. 6
      designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/TooltipContentPaneWithOutSeries.java
  53. 4
      designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/VanChartFieldListPaneWithOutSeries.java
  54. 6
      designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelLabelContentPane.java
  55. 4
      designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelRichTextFieldListPane.java
  56. 6
      designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelTooltipContentPane.java
  57. 4
      designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/tooltip/VanChartGanttRichTextFieldListPane.java
  58. 6
      designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/tooltip/VanChartGanttTooltipContentPane.java
  59. 4
      designer-chart/src/main/java/com/fr/van/chart/map/designer/style/VanChartMapRichTextFieldListPane.java
  60. 6
      designer-chart/src/main/java/com/fr/van/chart/map/designer/style/label/VanChartMapLabelContentPane.java
  61. 6
      designer-chart/src/main/java/com/fr/van/chart/map/designer/style/tooltip/VanChartMapTooltipContentPane.java
  62. 4
      designer-chart/src/main/java/com/fr/van/chart/map/line/VanChartLineMapRichTextFieldListPane.java
  63. 6
      designer-chart/src/main/java/com/fr/van/chart/map/line/VanChartLineMapTooltipContentPane.java
  64. 6
      designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieLabelContentPane.java
  65. 4
      designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieRichTextFieldListPane.java
  66. 6
      designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieTooltipContentPane.java
  67. 6
      designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieCategoryLabelContentPane.java
  68. 4
      designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieCategoryRichTextFieldListPane.java
  69. 6
      designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieValueLabelContentPane.java
  70. 4
      designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieValueRichTextFieldListPane.java
  71. 4
      designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterRichTextFieldListPane.java
  72. 6
      designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterTooltipContentPane.java
  73. 4
      designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureRichTextFieldListPane.java
  74. 6
      designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureTooltipContentPane.java
  75. 4
      designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudRichTextFieldListPane.java
  76. 6
      designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudTooltipContentPane.java
  77. 4
      designer-chart/src/main/resources/com/fr/design/editor/rich_editor.html
  78. 35
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/mini/MiniComponentShopPane.java
  79. 6
      designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java
  80. 18
      designer-realize/src/test/java/com.fr/design/mainframe/alphafine/cell/model/ModelTest.java
  81. 17
      designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/FileSearchManagerTest.java
  82. 2
      designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManagerTest.java
  83. 18
      designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/SearchManegerTest.java

10
build.gradle

@ -14,6 +14,7 @@ ext {
outputPath = "build" outputPath = "build"
ignoreTestFailureSetting = true ignoreTestFailureSetting = true
languageLevelSetting = 1.8 languageLevelSetting = 1.8
jxBrowserVersion = '7.26'
} }
applyGlobalConfigPathIfExist() applyGlobalConfigPathIfExist()
@ -66,8 +67,8 @@ allprojects {
implementation 'com.fr.cbb:fine-universal-skeleton:' + cbbVersion implementation 'com.fr.cbb:fine-universal-skeleton:' + cbbVersion
implementation 'com.install4j:install4j-runtime:8.0.4' implementation 'com.install4j:install4j-runtime:8.0.4'
implementation 'com.fr.third:jxbrowser:6.23' implementation 'com.fr.third:jxbrowser:6.23'
implementation 'com.fr.third:jxbrowser-v7:7.22' implementation "com.fr.third:jxbrowser-v7:${jxBrowserVersion}"
implementation 'com.fr.third:jxbrowser-swing-v7:7.22' implementation "com.fr.third:jxbrowser-swing-v7:${jxBrowserVersion}"
implementation 'com.fr.third.server:servlet-api:3.0' implementation 'com.fr.third.server:servlet-api:3.0'
implementation 'org.swingexplorer:swexpl:2.0.1' implementation 'org.swingexplorer:swexpl:2.0.1'
implementation 'org.swingexplorer:swag:1.0' implementation 'org.swingexplorer:swag:1.0'
@ -89,18 +90,19 @@ allprojects {
testImplementation 'org.easymock:easymock:3.5.1' testImplementation 'org.easymock:easymock:3.5.1'
testImplementation 'org.powermock:powermock-module-junit4:1.7.1' testImplementation 'org.powermock:powermock-module-junit4:1.7.1'
testImplementation 'org.powermock:powermock-api-easymock:1.7.1' testImplementation 'org.powermock:powermock-api-easymock:1.7.1'
testImplementation 'org.powermock:powermock-api-mockito2:1.7.4'
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
} }
if (OperatingSystem.current().isMacOsX()) { if (OperatingSystem.current().isMacOsX()) {
dependencies { dependencies {
implementation 'com.fr.third:jxbrowser-mac:6.23' implementation 'com.fr.third:jxbrowser-mac:6.23'
implementation 'com.fr.third:jxbrowser-mac-v7:7.22' implementation "com.fr.third:jxbrowser-mac-v7:${jxBrowserVersion}"
} }
} else if (OperatingSystem.current().isWindows()) { } else if (OperatingSystem.current().isWindows()) {
dependencies { dependencies {
implementation 'com.fr.third:jxbrowser-win64:6.23' implementation 'com.fr.third:jxbrowser-win64:6.23'
implementation 'com.fr.third:jxbrowser-win64-v7:7.22' implementation "com.fr.third:jxbrowser-win64-v7:${jxBrowserVersion}"
} }
} }
} }

16
designer-base/src/main/java/com/fr/design/actions/help/FineUIAction.java

@ -3,14 +3,15 @@ package com.fr.design.actions.help;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.jxbrowser.JxUIPane;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.ui.ModernUIPane;
import com.fr.locale.InterProviderFactory; import com.fr.locale.InterProviderFactory;
import com.fr.web.struct.AssembleComponent; import com.fr.web.struct.AssembleComponent;
import com.fr.web.struct.Atom; import com.fr.web.struct.Atom;
import com.fr.web.struct.browser.RequestClient; import com.fr.web.struct.browser.RequestClient;
import com.fr.web.struct.category.ScriptPath; import com.fr.web.struct.category.ScriptPath;
import com.fr.web.struct.impl.FineUI; import com.fr.web.struct.impl.FineUI;
import com.teamdev.jxbrowser.js.JsAccessible;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
@ -27,14 +28,8 @@ public class FineUIAction extends UpdateAction {
@Override @Override
public void actionPerformed(final ActionEvent e) { public void actionPerformed(final ActionEvent e) {
ModernUIPane<?> pane = new ModernUIPane.Builder<>() JxUIPane<?> pane = new JxUIPane.Builder<>()
// .prepare(new ScriptContextAdapter() { .bindNamespace("i18n", new I18n())
// @Override
// public void onScriptContextCreated(ScriptContextEvent event) {
// JSValue pool = event.getBrowser().executeJavaScriptAndReturnValue("window.Pool");
// pool.asObject().setProperty("i18n", new I18n());
// }
// })
.withComponent(new AssembleComponent() { .withComponent(new AssembleComponent() {
@Override @Override
@ -44,7 +39,7 @@ public class FineUIAction extends UpdateAction {
@Override @Override
public Atom[] refer() { public Atom[] refer() {
return new Atom[] {FineUI.KEY}; return new Atom[]{FineUI.KEY};
} }
}) })
.build(); .build();
@ -58,6 +53,7 @@ public class FineUIAction extends UpdateAction {
} }
@JsAccessible
public static class I18n { public static class I18n {
public String i18nText(String key) { public String i18nText(String key) {

19
designer-base/src/main/java/com/fr/design/dcm/UniversalDatabasePane.java

@ -1,12 +1,9 @@
package com.fr.design.dcm; package com.fr.design.dcm;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.ui.ModernUIPane; import com.fr.design.jxbrowser.JxUIPane;
import com.teamdev.jxbrowser.chromium.JSValue;
import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter;
import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent;
import java.awt.*; import java.awt.BorderLayout;
/** /**
* @author richie * @author richie
@ -15,8 +12,6 @@ import java.awt.*;
*/ */
public class UniversalDatabasePane extends BasicPane { public class UniversalDatabasePane extends BasicPane {
private ModernUIPane<Object> modernUIPane;
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return "Database"; return "Database";
@ -24,15 +19,9 @@ public class UniversalDatabasePane extends BasicPane {
public UniversalDatabasePane() { public UniversalDatabasePane() {
setLayout(new BorderLayout()); setLayout(new BorderLayout());
modernUIPane = new ModernUIPane.Builder<>() JxUIPane<Object> modernUIPane = new JxUIPane.Builder<>()
.withComponent(UniversalDatabaseComponent.KEY) .withComponent(UniversalDatabaseComponent.KEY)
.prepare(new ScriptContextAdapter() { .bindWindow("DcmHelper", UniversalDcmBridge::getBridge)
@Override
public void onScriptContextCreated(ScriptContextEvent event) {
JSValue window = event.getBrowser().executeJavaScriptAndReturnValue("window");
window.asObject().setProperty("DcmHelper", UniversalDcmBridge.getBridge(event.getBrowser()));
}
})
.build(); .build();
add(modernUIPane, BorderLayout.CENTER); add(modernUIPane, BorderLayout.CENTER);
} }

22
designer-base/src/main/java/com/fr/design/dcm/UniversalDcmBridge.java

@ -2,8 +2,8 @@ package com.fr.design.dcm;
import com.fr.decision.webservice.bean.BaseBean; import com.fr.decision.webservice.bean.BaseBean;
import com.fr.design.bridge.exec.JSBridge; import com.fr.design.bridge.exec.JSBridge;
import com.teamdev.jxbrowser.chromium.Browser; import com.teamdev.jxbrowser.js.JsAccessible;
import com.teamdev.jxbrowser.chromium.JSObject; import com.teamdev.jxbrowser.js.JsObject;
/** /**
* @author richie * @author richie
@ -11,20 +11,28 @@ import com.teamdev.jxbrowser.chromium.JSObject;
* Created by richie on 2019-05-17 * Created by richie on 2019-05-17
* 桥接Java和JavaScript的类 * 桥接Java和JavaScript的类
*/ */
@JsAccessible
public class UniversalDcmBridge { public class UniversalDcmBridge {
public static UniversalDcmBridge getBridge(Browser browser) { /**
return new UniversalDcmBridge(browser); * 获取 js-java bridge
*
* @param window 全局环境
* @return bridge
*/
public static UniversalDcmBridge getBridge(JsObject window) {
return new UniversalDcmBridge(window);
} }
private JSObject window; private JsObject window;
private UniversalDcmBridge(Browser browser) { private UniversalDcmBridge(JsObject window) {
this.window = browser.executeJavaScriptAndReturnValue("window").asObject(); this.window = window;
} }
/** /**
* 获取所有的数据连接 * 获取所有的数据连接
*
* @return 数据连接集合 * @return 数据连接集合
*/ */
@JSBridge @JSBridge

2
designer-base/src/main/java/com/fr/design/fun/DefaultValueAdjustProvider.java

@ -14,7 +14,7 @@ import java.awt.Font;
*/ */
public interface DefaultValueAdjustProvider extends Selectable { public interface DefaultValueAdjustProvider extends Selectable {
String MARK_STRING = "DefaultValueAdjustProvider"; String MARK_STRING = "DefaultValueAdjustProvider";
int CURRENT_LEVEL = 1; int CURRENT_LEVEL = 2;
/** /**
* 调整单元格对象默认值 * 调整单元格对象默认值

6
designer-base/src/main/java/com/fr/design/fun/impl/AbstractDefaultValueAdjustProvider.java

@ -9,9 +9,13 @@ import com.fr.stable.fun.mark.API;
@API(level = DefaultValueAdjustProvider.CURRENT_LEVEL) @API(level = DefaultValueAdjustProvider.CURRENT_LEVEL)
public abstract class AbstractDefaultValueAdjustProvider extends AbstractProvider implements DefaultValueAdjustProvider { public abstract class AbstractDefaultValueAdjustProvider extends AbstractProvider implements DefaultValueAdjustProvider {
//1.16及之前发布版本插件里面没有实现currentAPILevel方法,运行时候会走到主jar,拿到-2。
//1.16.1及之后发布版本插件实现currentAPILevel方法,编译插件的时候,会把DefaultValueAdjustProvider.CURRENT_LEVEL的值编译给插件,比如1.16.1会拿到2。
private static final int OLD_CURRENT_LEVEL = -2;
@Override @Override
public int currentAPILevel() { public int currentAPILevel() {
return CURRENT_LEVEL; return OLD_CURRENT_LEVEL;
} }
public String mark4Provider() { public String mark4Provider() {

40
designer-base/src/main/java/com/fr/design/jxbrowser/BrowserExecutor.java

@ -0,0 +1,40 @@
package com.fr.design.jxbrowser;
import com.fr.design.bridge.exec.JSExecutor;
import com.teamdev.jxbrowser.js.JsFunction;
import com.teamdev.jxbrowser.js.JsObject;
/**
* 用于 jxbrowser 执行后的回调执行器
* 适配7.15之后
*
* @author vito
* @since 11.0
* Created on 2023/6/8
*/
public class BrowserExecutor implements JSExecutor {
/**
* 创建一个回调执行器
*
* @param window js环境的window对象
* @param callback 回调
* @return 执行器
*/
public static BrowserExecutor create(JsObject window, JsFunction callback) {
return new BrowserExecutor(window, callback);
}
private final JsObject window;
private final JsFunction callback;
private BrowserExecutor(JsObject window, JsFunction callback) {
this.window = window;
this.callback = callback;
}
@Override
public void executor(String newValue) {
callback.invoke(window, newValue);
}
}

140
designer-base/src/main/java/com/fr/design/jxbrowser/JxEngine.java

@ -0,0 +1,140 @@
package com.fr.design.jxbrowser;
import com.fr.design.DesignerEnvManager;
import com.fr.design.ui.ModernUIConstants;
import com.fr.log.FineLoggerFactory;
import com.fr.value.ClearableLazyValue;
import com.fr.web.struct.AssembleComponent;
import com.teamdev.jxbrowser.engine.Engine;
import com.teamdev.jxbrowser.engine.EngineOptions;
import com.teamdev.jxbrowser.engine.RenderingMode;
import com.teamdev.jxbrowser.engine.event.EngineCrashed;
import com.teamdev.jxbrowser.net.Network;
import com.teamdev.jxbrowser.net.Scheme;
import com.teamdev.jxbrowser.net.callback.VerifyCertificateCallback;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.Map;
/**
* 可重复启动的 Jxbrowser 引擎
* 手动创建的引擎应当自己负责管理声明周期 {@link #newInstance()}
* 单例的引擎由系统管理生命周期使用后仅需清理browser和map等数据
* {@link #getEngine()} {@link #getPublicEngineInstance()}
*
* @author vito
* @since 11.0
* Created on 2023/6/8
*/
public class JxEngine {
private static final JxEngine INSTANCE = new JxEngine();
private AssembleComponent component;
private Map<String, String> parameterMap = Collections.emptyMap();
private final ClearableLazyValue<Engine> ENGINE = ClearableLazyValue.create(() -> {
EngineOptions.Builder builder = EngineOptions
.newBuilder(RenderingMode.HARDWARE_ACCELERATED)
.addSwitch("--disable-google-traffic")
.addScheme(Scheme.of(ModernUIConstants.EMB_TAG),
new NxInterceptRequestCallback(this::getComponent, this::getParameterMap));
Engine engine = Engine.newInstance(builder.build());
engine.on(EngineCrashed.class, (event) -> {
FineLoggerFactory.getLogger().error("jxBrowser engine crashed with exitCode: {}", event.exitCode());
event.engine().close();
});
if (DesignerEnvManager.getEnvManager().isOpenDebug()) {
// 调试模式下,禁止HTTPS证书验证,使得可以正常访问商城测试服务器等
Network network = engine.network();
network.set(VerifyCertificateCallback.class, params -> VerifyCertificateCallback.Response.valid());
}
return engine;
});
public Map<String, String> getParameterMap() {
return Collections.unmodifiableMap(parameterMap);
}
public void setMap(Map<String, String> parameterMap) {
if (parameterMap == null) {
return;
}
this.parameterMap = parameterMap;
}
/**
* 清理map
*/
public void clearMap() {
this.parameterMap = Collections.emptyMap();
}
public AssembleComponent getComponent() {
return component;
}
public void setComponent(AssembleComponent component) {
this.component = component;
}
/**
* 清理component
*/
public void clearComponent() {
this.component = null;
}
/**
* 获取单例引擎包装能够更新渲染
* 从单例获取的引擎不用负责关闭
* 应用系统管理声明周期
*
* @return jxbrowser 引擎包装类
*/
public static JxEngine getInstance() {
return INSTANCE;
}
/**
* 获取公共引擎公共引擎使用后不用关闭引擎但需要自己管理 browser
* 应用系统管理引擎生命周期
*
* @return 引擎
*/
@NotNull
public Engine getEngine() {
return ENGINE.getValue();
}
/**
* 关闭引擎
*/
public void close() {
ENGINE.getValue().close();
ENGINE.drop();
}
/**
* 获取公共引擎公共引擎使用后不用关闭引擎但需要自己管理 browser
* 应用系统管理引擎生命周期
*
* @return 引擎
*/
public static Engine getPublicEngineInstance() {
return getInstance().ENGINE.getValue();
}
/**
* 创建一个新的引擎创建引擎使用后需负责关闭引擎
* 但可以独立使用 map component
*
* @return 引擎
*/
public static JxEngine newInstance() {
return new JxEngine();
}
}

536
designer-base/src/main/java/com/fr/design/jxbrowser/JxUIPane.java

@ -0,0 +1,536 @@
package com.fr.design.jxbrowser;
import com.fr.design.DesignerEnvManager;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.i18n.Toolkit;
import com.fr.design.ui.ModernUIConstants;
import com.fr.design.ui.ModernUIPane;
import com.fr.stable.StringUtils;
import com.fr.stable.collections.combination.Pair;
import com.fr.web.struct.AssembleComponent;
import com.teamdev.jxbrowser.browser.Browser;
import com.teamdev.jxbrowser.browser.callback.InjectJsCallback;
import com.teamdev.jxbrowser.chromium.events.LoadListener;
import com.teamdev.jxbrowser.chromium.events.ScriptContextListener;
import com.teamdev.jxbrowser.event.Observer;
import com.teamdev.jxbrowser.frame.Frame;
import com.teamdev.jxbrowser.js.JsObject;
import com.teamdev.jxbrowser.view.swing.BrowserView;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.SwingUtilities;
import java.awt.BorderLayout;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import static com.fr.design.ui.ModernUIConstants.COMPONENT_TAG;
import static com.fr.design.ui.ModernUIConstants.DEFAULT_EXPRESSION;
import static com.fr.design.ui.ModernUIConstants.DEFAULT_NAMESPACE;
import static com.fr.design.ui.ModernUIConstants.DEFAULT_VARIABLE;
import static com.fr.design.ui.ModernUIConstants.DOT;
import static com.fr.design.ui.ModernUIConstants.EMB_TAG;
import static com.fr.design.ui.ModernUIConstants.SCHEME_HEADER;
import static com.fr.design.ui.ModernUIConstants.WINDOW;
/**
* 基于v7 jxbrowser 实现
* 用于加载 html5 的Swing容器可以在设计选项设置中打开调试窗口
* 示例可查看com.fr.design.ui.JxUIPaneTest
*
* @author vito
* @since 11.0
* Created on 2023-06-12
*/
public class JxUIPane<T> extends ModernUIPane<T> {
private Browser browser;
private String namespace = "Pool";
private String variable = "data";
private String expression = "update()";
private JxUIPane() {
super();
}
private void initialize() {
setLayout(new BorderLayout());
if (browser != null) {
return;
}
initDebugIfNeeded();
// 使用公共引擎创建浏览器
browser = JxEngine.getPublicEngineInstance().newBrowser();
add(BrowserView.newInstance(browser), BorderLayout.CENTER);
}
/**
* 按需初始化debug界面UI
*/
private void initDebugIfNeeded() {
if (DesignerEnvManager.getEnvManager().isOpenDebug()) {
UIToolbar toolbar = new UIToolbar();
add(toolbar, BorderLayout.NORTH);
UIButton openDebugButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Open_Debug_Window"));
openDebugButton.addActionListener(e -> browser.devTools().show());
toolbar.add(openDebugButton);
UIButton reloadButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Reload"));
reloadButton.addActionListener(e -> browser.navigation().reloadIgnoringCache());
toolbar.add(reloadButton);
UIButton closeButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Close_Window"));
closeButton.addActionListener(e -> SwingUtilities.getWindowAncestor(JxUIPane.this).setVisible(false));
toolbar.add(closeButton);
}
}
/**
* 在初始化时进行注入JS的方法只被build调用
*
* @param injectJsCallback 回调
*/
private void initInjectJs(InjectJsCallback injectJsCallback) {
browser.set(InjectJsCallback.class, params -> {
// 初始化的时候,就把命名空间对象初始化好,确保window.a.b.c("a.b.c"为命名空间)对象都是初始化过的
params.frame().executeJavaScript(String.format(ModernUIConstants.SCRIPT_INIT_NAME_SPACE, namespace));
return injectJsCallback.on(params);
});
}
/**
* 设置 InjectJsCallback
* 这个方法解决重复InjectJsCallback被覆盖的问题
* 用于本类内部方法使用{@link #populate(Object)}
*
* @param injectJsCallback 回调
*/
private void setInjectJsCallback(InjectJsCallback injectJsCallback) {
Optional<InjectJsCallback> callback = browser.get(InjectJsCallback.class);
if (callback.isPresent()) {
browser.set(InjectJsCallback.class, params -> {
callback.get().on(params);
return injectJsCallback.on(params);
});
} else {
browser.set(InjectJsCallback.class, injectJsCallback);
}
}
/**
* 转向一个新的地址相当于重新加载
*
* @param url 新的地址
*/
@Override
public void redirect(String url) {
browser.navigation().loadUrl(url);
}
/**
* 转向一个新的地址相当于重新加载
*
* @param url 新的地址
* @param map 初始化参数
*/
@Override
public void redirect(String url, Map<String, String> map) {
setMap(map);
browser.navigation().loadUrl(url);
}
private void setMap(Map<String, String> map) {
JxEngine.getInstance().setMap(map);
}
private void setComponent(AssembleComponent component) {
JxEngine.getInstance().setComponent(component);
}
@Override
protected String title4PopupWindow() {
return "ModernUI7";
}
@Override
public void populate(final T t) {
setInjectJsCallback(params -> {
executeJsObject(params.frame(), WINDOW + DOT + namespace)
.ifPresent(ns -> ns.putProperty(variable, t));
return InjectJsCallback.Response.proceed();
});
}
@Override
@Nullable
public T update() {
if (browser.mainFrame().isPresent()) {
return browser.mainFrame().get().executeJavaScript("window." + namespace + "." + expression);
}
return null;
}
/**
* 关闭浏览器
*/
public void disposeBrowser() {
if (browser != null) {
browser.close();
browser = null;
JxEngine.getInstance().clearMap();
JxEngine.getInstance().clearComponent();
}
}
/**
* 清理浏览器缓存
*/
public void clearCache() {
if (browser != null) {
browser.engine().httpCache().clear();
}
}
/**
* 执行一段js
*
* @param javaScript 待执行的js脚本
*/
public void executeJavaScript(String javaScript) {
if (browser != null) {
browser.mainFrame().ifPresent(frame -> {
frame.executeJavaScript(javaScript);
});
}
}
/**
* 获取js对象
* 注意类内部使用用于简化编码提供 Optional 包装
*
* @param frame 页面frame对象
* @param name 变量命名
* @return js对象
*/
private static Optional<JsObject> executeJsObject(Frame frame, String name) {
return Optional.ofNullable(frame.executeJavaScript(name));
}
/**
* JxUIPane 的建造者
*
* @param <T> 参数
*/
public static class Builder<T> extends ModernUIPane.Builder<T> {
private String namespace;
private String variable;
private String expression;
private InjectJsCallback callback;
private Pair<Class, Observer> listenerPair;
private final Map<String, Object> namespacePropertyMap;
private final Map<String, Object> propertyMap;
private final Map<String, PropertyBuild> buildPropertyMap;
private Object variableProperty;
private Map<String, String> parameterMap;
private AssembleComponent component;
private String url;
private String html;
public Builder() {
this.namespace = DEFAULT_NAMESPACE;
this.variable = DEFAULT_VARIABLE;
this.expression = DEFAULT_EXPRESSION;
this.callback = null;
this.listenerPair = null;
this.namespacePropertyMap = new HashMap<>();
this.propertyMap = new HashMap<>();
this.buildPropertyMap = new HashMap<>();
this.variableProperty = null;
this.parameterMap = null;
this.component = null;
this.url = StringUtils.EMPTY;
this.html = StringUtils.EMPTY;
}
/**
* 注入一个回调回调的js会在初始化进行执行
*
* @param callback 回调
* @return builder
*/
public Builder<T> prepare(InjectJsCallback callback) {
this.callback = callback;
return this;
}
@Override
public Builder<T> prepareForV6(ScriptContextListener contextListener) {
return this;
}
@Override
public Builder<T> prepareForV6(LoadListener loadListener) {
return this;
}
@Override
public JxUIPane.Builder<T> prepareForV7(InjectJsCallback callback) {
prepare(callback);
return this;
}
@Override
public JxUIPane.Builder<T> prepareForV7(Class event, Observer listener) {
listenerPair = new Pair<>(event, listener);
return this;
}
/**
* 加载jar包中的资源
*
* @param path 资源路径
*/
public JxUIPane.Builder<T> withEMB(final String path) {
this.url = EMB_TAG + SCHEME_HEADER + path;
return this;
}
/**
* 加载jar包中的资源
*
* @param path 资源路径
*/
public JxUIPane.Builder<T> withEMB(final String path, Map<String, String> map) {
this.parameterMap = map;
this.url = EMB_TAG + SCHEME_HEADER + path;
return this;
}
/**
* 加载url指向的资源
*
* @param url 文件的地址
*/
public JxUIPane.Builder<T> withURL(final String url) {
this.url = url;
return this;
}
/**
* 加载url指向的资源
*
* @param url 文件的地址
*/
public JxUIPane.Builder<T> withURL(final String url, Map<String, String> map) {
this.parameterMap = map;
this.url = url;
return this;
}
/**
* 加载Atom组件
*
* @param component Atom组件
*/
public JxUIPane.Builder<T> withComponent(AssembleComponent component) {
return withComponent(component, null);
}
/**
* 加载Atom组件
*
* @param component Atom组件
*/
public JxUIPane.Builder<T> withComponent(AssembleComponent component, Map<String, String> map) {
this.parameterMap = map;
this.component = component;
this.url = COMPONENT_TAG;
return this;
}
/**
* 加载html文本内容
*
* @param html 要加载html文本内容
*/
public JxUIPane.Builder<T> withHTML(String html) {
this.html = html;
return this;
}
/**
* 设置该前端页面做数据交换所使用的对象
* 相当于
* const namespace = "Pool";
* 调用
* window[namespace];
* 默认下结构如
* window.Pool
*
* @param namespace 对象名
*/
public JxUIPane.Builder<T> namespace(String namespace) {
this.namespace = namespace;
return this;
}
/**
* java端往js端传数据时使用的变量名字
* 默认值为 data
* 相当于
* const variable = "data";
* 调用
* window[namespace][variable];
* 默认下结构如
* window.Pool.data
*
* @param name 变量的名字
*/
public JxUIPane.Builder<T> variable(String name) {
this.variable = name;
return this;
}
/**
* js端往java端传数据时执行的函数表达式
*
* @param expression 函数表达式
*/
public JxUIPane.Builder<T> expression(String expression) {
this.expression = expression;
return this;
}
/**
* 注入一个java对象到js中绑定在全局变量window的指定变量variable
* variable 可由 {@link #namespace(String)} 设置默认值为 data
* 这个方法仅在在加载的网页上执行 JavaScript 之前注入
* 相当于
* window[namespace][property] = javaObject
* 默认下
* window.Pool[property] = javaObject
*
* @param obj java对象
* @return 链式对象
*/
public JxUIPane.Builder<T> bindNamespace(String property, @Nullable Object obj) {
this.namespacePropertyMap.put(property, obj);
return this;
}
/**
* 注入一个java对象到js中绑定在全局变量window的指定变量variable
* variable 可由 {@link #variable(String)} 设置默认值为 data
* 这个方法仅在在加载的网页上执行 JavaScript 之前注入
* 相当于
* window[namespace][variable] = javaObject
* 默认下
* window.Pool.data = javaObject
*
* @param obj java对象
* @return 链式对象
*/
public JxUIPane.Builder<T> bindVariable(@NotNull Object obj) {
this.variableProperty = obj;
return this;
}
/**
* 注入一个java对象到js中,绑定在全局变量 window的
* property指定的变量这个方法仅在在加载的网页上执
* JavaScript 之前注入
* 相当于
* window[property] = javaObject
*
* @param property 属性
* @param obj java对象
* @return 链式对象
* @see #bindWindow(String, PropertyBuild)
*/
public JxUIPane.Builder<T> bindWindow(String property, @Nullable Object obj) {
this.propertyMap.put(property, obj);
return this;
}
/**
* 注入一个java对象到js中绑定在全局变量 window的property指定的变量
* PropertyBuild用于动态生成绑定属性个方法仅在在加载的网页上执行
* JavaScript 之前注入
* 相当于
* window[property] = javaObject
*
* @param property 属性构建器
* @param obj java对象
* @return 链式对象
* @see #bindWindow(String, Object)
*/
public JxUIPane.Builder<T> bindWindow(String property, PropertyBuild obj) {
buildPropertyMap.put(property, obj);
return this;
}
/**
* 构建
*/
public JxUIPane<T> build() {
JxUIPane<T> pane = new JxUIPane<>();
pane.namespace = namespace;
pane.variable = variable;
pane.expression = expression;
pane.setMap(parameterMap);
pane.setComponent(component);
pane.initialize();
injectJs(pane);
if (!Objects.isNull(listenerPair)) {
pane.browser.navigation().on(listenerPair.getFirst(), listenerPair.getSecond());
}
if (StringUtils.isNotEmpty(this.url)) {
pane.browser.navigation().loadUrl(this.url);
} else if (StringUtils.isNotEmpty(this.html)) {
pane.browser.mainFrame().ifPresent(f -> f.loadHtml(html));
}
return pane;
}
/**
* 由于 InjectJsCallback 的回调机制在初始化期间只有
* InjectJsCallback putProperty 才能生效
* 因此嵌套回调分别做默认初始化putProperty外置初始化
*/
private void injectJs(JxUIPane<T> pane) {
pane.initInjectJs(params -> {
Frame frame = params.frame();
if (!propertyMap.isEmpty()) {
propertyMap.forEach((key, value) ->
executeJsObject(frame, WINDOW)
.ifPresent(window -> window.putProperty(key, value)));
}
if (!buildPropertyMap.isEmpty()) {
buildPropertyMap.forEach((key, value) ->
executeJsObject(frame, WINDOW)
.ifPresent(window -> window.putProperty(key, value.build(window))));
}
if (!namespacePropertyMap.isEmpty()) {
namespacePropertyMap.forEach((key, value) ->
executeJsObject(frame, WINDOW + DOT + namespace)
.ifPresent(pool -> pool.putProperty(key, value)));
}
if (variableProperty != null) {
executeJsObject(frame, WINDOW + DOT + namespace)
.ifPresent(pool -> pool.putProperty(variable, variableProperty));
}
if (callback != null) {
return callback.on(params);
}
return InjectJsCallback.Response.proceed();
});
}
}
}

113
designer-base/src/main/java/com/fr/design/jxbrowser/MimeType.java

@ -0,0 +1,113 @@
package com.fr.design.jxbrowser;
import com.fr.stable.StringUtils;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Optional;
/**
* jxbrowser 使用的一些媒体类型
*
* @author vito
* @since 11.0
* Created on 2023/6/13
*/
public enum MimeType {
/**
* html 格式
*/
HTML(".html", "text/html"),
/**
* CSS 格式
*/
CSS(".css", "text/css"),
/**
* js 格式
*/
JS(".js", "text/css"),
/**
* svg 格式
*/
SVG(".svg", "text/javascript"),
/**
* png 格式
*/
PNG(".png", "image/png"),
/**
* jpg 格式
*/
JPG(".jpg", "image/jpeg"),
/**
* jpeg 格式
*/
JPEG(".jpeg", "image/jpeg"),
/**
* gif 格式
*/
GIF(".gif", "image/gif"),
/**
* woff 字体格式
*/
WOFF(".woff", "font/woff"),
/**
* ttf 字体格式
*/
TTF(".ttf", "truetype"),
/**
* MS 嵌入式开放字体
*/
EOT(".eot", "embedded-opentype");
private final String suffix;
private final String mimeType;
MimeType(String suffix, String mimeType) {
this.suffix = suffix;
this.mimeType = mimeType;
}
public String getMimeType() {
return mimeType;
}
/**
* 获取指定路径对应的 mimetype优先匹配常量中的类型
* 如果没有尝试使用 Files.probeContentType 检测
* 如果没有默认返回 text/html
*
* @param url url路径
* @return MimeType
*/
public static String parseMimeType(String url) {
if (StringUtils.isBlank(url)) {
return HTML.mimeType;
}
String finalPath = url.split("\\?")[0];
Optional<MimeType> mimeType = Arrays.stream(values())
.filter(type -> finalPath.endsWith(type.suffix))
.findFirst();
if (mimeType.isPresent()) {
return mimeType.get().mimeType;
} else {
return getFileMimeType(finalPath);
}
}
private static String getFileMimeType(String finalPath) {
Path file = new File(finalPath).toPath();
try {
String s = Files.probeContentType(file);
return StringUtils.isEmpty(s) ? HTML.mimeType : s;
} catch (IOException e) {
return HTML.mimeType;
}
}
}

171
designer-base/src/main/java/com/fr/design/jxbrowser/NxInterceptRequestCallback.java

@ -0,0 +1,171 @@
package com.fr.design.jxbrowser;
import com.fr.base.TemplateUtils;
import com.fr.design.ui.ModernRequestClient;
import com.fr.design.ui.ModernUIConstants;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.EncodeConstants;
import com.fr.stable.StringUtils;
import com.fr.web.struct.AssembleComponent;
import com.fr.web.struct.AtomBuilder;
import com.fr.web.struct.PathGroup;
import com.fr.web.struct.category.ScriptPath;
import com.fr.web.struct.category.StylePath;
import com.teamdev.jxbrowser.net.HttpHeader;
import com.teamdev.jxbrowser.net.HttpStatus;
import com.teamdev.jxbrowser.net.UrlRequest;
import com.teamdev.jxbrowser.net.UrlRequestJob;
import com.teamdev.jxbrowser.net.callback.InterceptUrlRequestCallback;
import org.jetbrains.annotations.NotNull;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.Optional;
import java.util.function.Supplier;
import static com.fr.design.ui.ModernUIConstants.COMPONENT_TAG;
/**
* jxbrowser7 自定义 scheme 处理回调
*
* @author vito
* @since 11.0
* Created on 2023/6/8
*/
public class NxInterceptRequestCallback implements InterceptUrlRequestCallback {
private Supplier<AssembleComponent> component;
private Supplier<Map<String, String>> renderParameterBuild;
public NxInterceptRequestCallback(Supplier<Map<String, String>> renderParameterBuild) {
this.renderParameterBuild = renderParameterBuild;
}
public NxInterceptRequestCallback(Supplier<AssembleComponent> component,
Supplier<Map<String, String>> renderParameterBuild) {
this.component = component;
this.renderParameterBuild = renderParameterBuild;
}
/**
* 主要包括 atom emb协议的文件链接处理
* 去掉file文件协议的支持因此jxbrowser 7之后不支持覆盖内置协议详细见
* {@link com.teamdev.jxbrowser.net.internal.NonInterceptableScheme}
*
* @param params 参数
* @return 响应
*/
@Override
public Response on(Params params) {
UrlRequest urlRequest = params.urlRequest();
String path = urlRequest.url();
Optional<UrlRequestJob> urlRequestJobOptional;
if (path.startsWith(COMPONENT_TAG)) {
String text = htmlText(renderParameterBuild.get());
urlRequestJobOptional = generateBasicUrlRequestJob(params,
"text/html", text.getBytes(StandardCharsets.UTF_8));
} else {
urlRequestJobOptional = generateFileProtocolUrlRequestJob(params, path);
}
return urlRequestJobOptional
.map(Response::intercept)
.orElseGet(Response::proceed);
}
protected Optional<UrlRequestJob> generateFileProtocolUrlRequestJob(Params params, String path) {
try {
InputStream inputStream = getResourceStream(path);
String mimeType = MimeType.parseMimeType(path);
byte[] bytes;
if (isHtml(mimeType)) {
String text = IOUtils.inputStream2String(inputStream, EncodeConstants.ENCODING_UTF_8);
text = TemplateUtils.renderParameter4Tpl(text, renderParameterBuild.get());
bytes = text.getBytes(StandardCharsets.UTF_8);
} else {
bytes = IOUtils.inputStream2Bytes(inputStream);
}
return generateBasicUrlRequestJob(params, mimeType, bytes);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return Optional.empty();
}
/**
* 获取资源文件流
*
* @param path 文件路径
* @return 输入流
* @throws Exception IO异常
*/
private InputStream getResourceStream(String path) throws Exception {
int index = path.indexOf("=");
if (index > 0) {
path = path.substring(index + 1);
} else {
// jxbrowser 7之后,协议会自动补齐双斜杠//
path = path.split(":/")[1];
}
return IOUtils.readResource(path);
}
private boolean isHtml(String mimeType) {
return MimeType.HTML.getMimeType().equals(mimeType);
}
private Optional<UrlRequestJob> generateBasicUrlRequestJob(Params params, String mimeType, byte[] bytes) {
if (StringUtils.isEmpty(mimeType)) {
return Optional.empty();
}
UrlRequestJob.Options options = UrlRequestJob.Options
.newBuilder(HttpStatus.OK)
.addHttpHeader(HttpHeader.of("Content-Type", mimeType))
.build();
UrlRequestJob urlRequestJob = params.newUrlRequestJob(options);
urlRequestJob.write(bytes);
urlRequestJob.complete();
return Optional.of(urlRequestJob);
}
private String htmlText(Map<String, String> map) {
return component.get() == null ?
StringUtils.EMPTY :
parseComponent(component.get(), map);
}
@NotNull
private static String parseComponent(AssembleComponent component, Map<String, String> map) {
PathGroup pathGroup = AtomBuilder.create().buildAssembleFilePath(ModernRequestClient.KEY, component);
StylePath[] stylePaths = pathGroup.toStylePathGroup();
StringBuilder styleText = new StringBuilder();
for (StylePath path : stylePaths) {
if (StringUtils.isNotBlank(path.toFilePath())) {
styleText.append("<link rel=\"stylesheet\" href=\"emb://");
styleText.append(path.toFilePath());
styleText.append("\"/>");
}
}
String result = ModernUIConstants.HTML_TPL.replaceAll("##style##", styleText.toString());
ScriptPath[] scriptPaths = pathGroup.toScriptPathGroup();
StringBuilder scriptText = new StringBuilder();
for (ScriptPath path : scriptPaths) {
if (StringUtils.isNotBlank(path.toFilePath())) {
scriptText.append("<script src=\"emb://");
scriptText.append(path.toFilePath());
scriptText.append("\"></script>");
}
}
result = result.replaceAll("##script##", scriptText.toString());
if (map != null) {
for (Map.Entry<String, String> entry : map.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
result = result.replaceAll("\\$\\{" + key + "}", value);
}
}
return result;
}
}

20
designer-base/src/main/java/com/fr/design/jxbrowser/PropertyBuild.java

@ -0,0 +1,20 @@
package com.fr.design.jxbrowser;
import com.teamdev.jxbrowser.js.JsObject;
/**
* 属性构建器
*
* @author vito
* @since 11.0
* Created on 2023/6/8
*/
public interface PropertyBuild {
/**
* 构建属性
*
* @param window js环境的window对象
* @return 待注入java对象
*/
Object build(JsObject window);
}

54
designer-base/src/main/java/com/fr/design/login/DesignerLoginBridge.java

@ -7,9 +7,9 @@ import com.fr.design.gui.ilable.ActionLabel;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.LocaleLinkProvider; import com.fr.design.i18n.LocaleLinkProvider;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.jxbrowser.BrowserExecutor;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.locale.impl.BbsResetMark; import com.fr.design.locale.impl.BbsResetMark;
import com.fr.design.login.executor.DesignerLoginBrowserExecutor;
import com.fr.design.login.executor.DesignerLoginExecutor; import com.fr.design.login.executor.DesignerLoginExecutor;
import com.fr.design.login.executor.DesignerSendCaptchaExecutor; import com.fr.design.login.executor.DesignerSendCaptchaExecutor;
import com.fr.design.login.executor.DesignerSmsLoginExecutor; import com.fr.design.login.executor.DesignerSmsLoginExecutor;
@ -21,25 +21,26 @@ import com.fr.general.CloudCenter;
import com.fr.general.locale.LocaleCenter; import com.fr.general.locale.LocaleCenter;
import com.fr.general.locale.LocaleMark; import com.fr.general.locale.LocaleMark;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.teamdev.jxbrowser.chromium.Browser; import com.teamdev.jxbrowser.js.JsAccessible;
import com.teamdev.jxbrowser.chromium.JSFunction; import com.teamdev.jxbrowser.js.JsFunction;
import com.teamdev.jxbrowser.chromium.JSObject; import com.teamdev.jxbrowser.js.JsObject;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import java.awt.Desktop; import java.awt.Desktop;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.URI; import java.net.URI;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
/** /**
* 设计器登录通行证js-java桥
*
* @author Lanlan * @author Lanlan
* @version 10.0 * @version 10.0
* Created by Lanlan on 2021/5/21 * Created by Lanlan on 2021/5/21
*/ */
@JsAccessible
public class DesignerLoginBridge { public class DesignerLoginBridge {
/** /**
@ -52,20 +53,26 @@ public class DesignerLoginBridge {
*/ */
private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Market_Template_Default"; private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Market_Template_Default";
private Map<String, String> params; private final Map<String, String> params;
public static DesignerLoginBridge getBridge(Browser browser, Map<String, String> params) { /**
return new DesignerLoginBridge(browser, params); * 获取 js-java bridge
*
* @param window 全局环境
* @return bridge
*/
public static DesignerLoginBridge getBridge(JsObject window, Map<String, String> params) {
return new DesignerLoginBridge(window, params);
} }
private JSObject window; private final JsObject window;
private DesignerLoginBridge(Browser browser, Map<String, String> params) { private DesignerLoginBridge(JsObject window, Map<String, String> params) {
this.params = params; this.params = params;
this.window = browser.executeJavaScriptAndReturnValue("window").asObject(); this.window = window;
Set<Map.Entry<String, String>> entries = params.entrySet(); Set<Map.Entry<String, String>> entries = params.entrySet();
for (Map.Entry<String, String> entry : entries) { for (Map.Entry<String, String> entry : entries) {
this.window.setProperty(entry.getKey(), entry.getValue()); this.window.putProperty(entry.getKey(), entry.getValue());
} }
} }
@ -183,9 +190,9 @@ public class DesignerLoginBridge {
* @param callback 回调函数 * @param callback 回调函数
*/ */
@JSBridge @JSBridge
public void normalLogin(String username, String password, final JSFunction callback) { public void normalLogin(String username, String password, final JsFunction callback) {
DesignerLoginTaskWorker<Void> worker = new DesignerLoginTaskWorker<>( DesignerLoginTaskWorker<Void> worker = new DesignerLoginTaskWorker<>(
new JSCallback(DesignerLoginBrowserExecutor.create(window, callback)), new JSCallback(BrowserExecutor.create(window, callback)),
new DesignerLoginExecutor(username, password)); new DesignerLoginExecutor(username, password));
worker.execute(); worker.execute();
} }
@ -198,9 +205,9 @@ public class DesignerLoginBridge {
* @param callback 回调函数 * @param callback 回调函数
*/ */
@JSBridge @JSBridge
public void sendCaptcha(String regionCode, String phone, final JSFunction callback) { public void sendCaptcha(String regionCode, String phone, final JsFunction callback) {
DesignerLoginTaskWorker<Void> worker = new DesignerLoginTaskWorker<>( DesignerLoginTaskWorker<Void> worker = new DesignerLoginTaskWorker<>(
new JSCallback(DesignerLoginBrowserExecutor.create(window, callback)), new JSCallback(BrowserExecutor.create(window, callback)),
new DesignerSendCaptchaExecutor(regionCode, phone)); new DesignerSendCaptchaExecutor(regionCode, phone));
worker.execute(); worker.execute();
} }
@ -214,9 +221,9 @@ public class DesignerLoginBridge {
* @param callback 回调函数 * @param callback 回调函数
*/ */
@JSBridge @JSBridge
public void smsLogin(String regionCode, String phone, String code, final JSFunction callback) { public void smsLogin(String regionCode, String phone, String code, final JsFunction callback) {
DesignerLoginTaskWorker<Void> worker = new DesignerLoginTaskWorker<>( DesignerLoginTaskWorker<Void> worker = new DesignerLoginTaskWorker<>(
new JSCallback(DesignerLoginBrowserExecutor.create(window, callback)), new JSCallback(BrowserExecutor.create(window, callback)),
new DesignerSmsLoginExecutor(regionCode, phone, code)); new DesignerSmsLoginExecutor(regionCode, phone, code));
worker.execute(); worker.execute();
} }
@ -231,9 +238,9 @@ public class DesignerLoginBridge {
* @param callback 回调函数 * @param callback 回调函数
*/ */
@JSBridge @JSBridge
public void smsRegister(String regionCode, String phone, String password, String regToken, final JSFunction callback) { public void smsRegister(String regionCode, String phone, String password, String regToken, final JsFunction callback) {
DesignerLoginTaskWorker<Void> worker = new DesignerLoginTaskWorker<>( DesignerLoginTaskWorker<Void> worker = new DesignerLoginTaskWorker<>(
new JSCallback(DesignerLoginBrowserExecutor.create(window, callback)), new JSCallback(BrowserExecutor.create(window, callback)),
new DesignerSmsRegisterExecutor(regionCode, phone, password, regToken)); new DesignerSmsRegisterExecutor(regionCode, phone, password, regToken));
worker.execute(); worker.execute();
} }
@ -275,14 +282,11 @@ public class DesignerLoginBridge {
private JPanel getHyperlinkPane(String title, String hyperlinkText, String hyperlink) { private JPanel getHyperlinkPane(String title, String hyperlinkText, String hyperlink) {
ActionLabel actionLabel = new ActionLabel(hyperlinkText); ActionLabel actionLabel = new ActionLabel(hyperlinkText);
actionLabel.addActionListener(new ActionListener() { actionLabel.addActionListener(e -> {
@Override
public void actionPerformed(ActionEvent e) {
try { try {
Desktop.getDesktop().browse(new URI(hyperlink)); Desktop.getDesktop().browse(new URI(hyperlink));
} catch (Exception ignore) { } catch (Exception ignore) {
} }
}
}); });
JPanel panel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); JPanel panel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
panel.add(new UILabel(title)); panel.add(new UILabel(title));

20
designer-base/src/main/java/com/fr/design/login/DesignerLoginPane.java

@ -2,21 +2,23 @@ package com.fr.design.login;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.jxbrowser.JxUIPane;
import com.fr.design.login.utils.DesignerLoginUtils; import com.fr.design.login.utils.DesignerLoginUtils;
import com.fr.design.ui.ModernUIPane;
import com.teamdev.jxbrowser.chromium.JSValue;
import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter;
import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.util.Map; import java.util.Map;
/** /**
* 设计器登录通行证面板
*
* @author Lanlan * @author Lanlan
* @version 10.0 * @version 10.0
* Created by Lanlan on 2021/5/21 * Created by Lanlan on 2021/5/21
*/ */
public class DesignerLoginPane extends BasicPane { public class DesignerLoginPane extends BasicPane {
private static final String DESIGNER_LOGIN_HELPER = "DesignerLoginHelper";
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return "DESIGNER_LOGIN"; return "DESIGNER_LOGIN";
@ -27,14 +29,8 @@ public class DesignerLoginPane extends BasicPane {
params.put("lastLoginType", String.valueOf(DesignerEnvManager.getEnvManager().getLastLoginType().getType())); params.put("lastLoginType", String.valueOf(DesignerEnvManager.getEnvManager().getLastLoginType().getType()));
params.put("lastLoginAccount", DesignerEnvManager.getEnvManager().getLastLoginAccount()); params.put("lastLoginAccount", DesignerEnvManager.getEnvManager().getLastLoginAccount());
setLayout(new BorderLayout()); setLayout(new BorderLayout());
ModernUIPane<Object> modernUIPane = new ModernUIPane.Builder<>() JxUIPane<Object> modernUIPane = new JxUIPane.Builder<>()
.prepare(new ScriptContextAdapter() { .bindWindow(DESIGNER_LOGIN_HELPER, window -> DesignerLoginBridge.getBridge(window, params))
@Override
public void onScriptContextCreated(ScriptContextEvent event) {
JSValue window = event.getBrowser().executeJavaScriptAndReturnValue("window");
window.asObject().setProperty("DesignerLoginHelper", DesignerLoginBridge.getBridge(event.getBrowser(), params));
}
})
.withEMB(DesignerLoginHelper.getMainResourcePath(), DesignerLoginUtils.renderMap()) .withEMB(DesignerLoginHelper.getMainResourcePath(), DesignerLoginUtils.renderMap())
.build(); .build();
add(modernUIPane, BorderLayout.CENTER); add(modernUIPane, BorderLayout.CENTER);

34
designer-base/src/main/java/com/fr/design/login/guide/DesignerGuideBridge.java

@ -6,26 +6,31 @@ import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.login.DesignerLoginHelper; import com.fr.design.login.DesignerLoginHelper;
import com.fr.design.login.DesignerLoginSource; import com.fr.design.login.DesignerLoginSource;
import com.teamdev.jxbrowser.chromium.Browser; import com.teamdev.jxbrowser.js.JsAccessible;
import com.teamdev.jxbrowser.chromium.JSObject;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
/** /**
* 设计器登录指南面板的js-java桥
*
* @author Lanlan * @author Lanlan
* @version 10.0 * @version 10.0
* Created by Lanlan on 2021/5/21 * Created by Lanlan on 2021/5/21
*/ */
@JsAccessible
public class DesignerGuideBridge { public class DesignerGuideBridge {
public static DesignerGuideBridge getBridge(Browser browser) { /**
return new DesignerGuideBridge(browser); * 获取 js-java bridge
*
* @return bridge
*/
public static DesignerGuideBridge getBridge() {
return new DesignerGuideBridge();
} }
private JSObject window; private DesignerGuideBridge() {
private DesignerGuideBridge(Browser browser) {
this.window = browser.executeJavaScriptAndReturnValue("window").asObject();
} }
@JSBridge @JSBridge
@ -40,17 +45,15 @@ public class DesignerGuideBridge {
DesignerLoginHelper.showLoginDialog(DesignerLoginSource.GUIDE); DesignerLoginHelper.showLoginDialog(DesignerLoginSource.GUIDE);
checkDoNotRemind(doNotRemind); checkDoNotRemind(doNotRemind);
} else { } else {
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(() -> {
@Override
public void run() {
String[] options = new String[]{ String[] options = new String[]{
com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Login_Quit"), Toolkit.i18nText("Fine-Designer_Login_Quit"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Login_Return_Login") Toolkit.i18nText("Fine-Designer_Login_Return_Login")
}; };
int rv = FineJOptionPane.showConfirmDialog( int rv = FineJOptionPane.showConfirmDialog(
DesignerGuideHelper.getDialog(), DesignerGuideHelper.getDialog(),
com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Login_Quit_Tip"), Toolkit.i18nText("Fine-Designer_Login_Quit_Tip"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
JOptionPane.YES_NO_OPTION, JOptionPane.YES_NO_OPTION,
JOptionPane.WARNING_MESSAGE, JOptionPane.WARNING_MESSAGE,
null, null,
@ -65,7 +68,6 @@ public class DesignerGuideBridge {
DesignerGuideHelper.closeWindow(); DesignerGuideHelper.closeWindow();
checkDoNotRemind(doNotRemind); checkDoNotRemind(doNotRemind);
} }
}
}); });
} }
} }

3
designer-base/src/main/java/com/fr/design/login/guide/DesignerGuideHelper.java

@ -10,9 +10,12 @@ import com.fr.design.os.impl.SupportOSImpl;
import com.fr.design.update.push.DesignerPushUpdateManager; import com.fr.design.update.push.DesignerPushUpdateManager;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.WindowConstants; import javax.swing.WindowConstants;
/** /**
* 设计器登录指南帮助类
*
* @author Lanlan * @author Lanlan
* @version 10.0 * @version 10.0
* Created by Lanlan on 2021/5/21 * Created by Lanlan on 2021/5/21

20
designer-base/src/main/java/com/fr/design/login/guide/DesignerGuidePane.java

@ -1,20 +1,22 @@
package com.fr.design.login.guide; package com.fr.design.login.guide;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.jxbrowser.JxUIPane;
import com.fr.design.login.guide.utils.DesignerGuideUtils; import com.fr.design.login.guide.utils.DesignerGuideUtils;
import com.fr.design.ui.ModernUIPane;
import com.teamdev.jxbrowser.chromium.JSValue;
import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter;
import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent;
import java.awt.BorderLayout; import java.awt.BorderLayout;
/** /**
* 设计器登录帆软通行证的指南面板
*
* @author Lanlan * @author Lanlan
* @version 10.0 * @version 10.0
* Created by Lanlan on 2021/5/21 * Created by Lanlan on 2021/5/21
*/ */
public class DesignerGuidePane extends BasicPane { public class DesignerGuidePane extends BasicPane {
private static final String DESIGNER_GUIDE_HELPER = "DesignerGuideHelper";
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return "DESIGNER_GUIDE"; return "DESIGNER_GUIDE";
@ -22,14 +24,8 @@ public class DesignerGuidePane extends BasicPane {
public DesignerGuidePane() { public DesignerGuidePane() {
setLayout(new BorderLayout()); setLayout(new BorderLayout());
ModernUIPane<Object> modernUIPane = new ModernUIPane.Builder<>() JxUIPane<Object> modernUIPane = new JxUIPane.Builder<>()
.prepare(new ScriptContextAdapter() { .bindWindow(DESIGNER_GUIDE_HELPER, w -> DesignerGuideBridge.getBridge())
@Override
public void onScriptContextCreated(ScriptContextEvent event) {
JSValue window = event.getBrowser().executeJavaScriptAndReturnValue("window");
window.asObject().setProperty("DesignerGuideHelper", DesignerGuideBridge.getBridge(event.getBrowser()));
}
})
.withEMB(DesignerGuideHelper.getMainResourcePath(), DesignerGuideUtils.renderMap()) .withEMB(DesignerGuideHelper.getMainResourcePath(), DesignerGuideUtils.renderMap())
.build(); .build();
add(modernUIPane, BorderLayout.CENTER); add(modernUIPane, BorderLayout.CENTER);

16
designer-base/src/main/java/com/fr/design/ui/ModernUIConstants.java

@ -3,12 +3,28 @@ package com.fr.design.ui;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
/** /**
* 新式面板常量
*
* @author richie * @author richie
* @version 10.0 * @version 10.0
* Created by richie on 2019-03-05 * Created by richie on 2019-03-05
*/ */
public class ModernUIConstants { public class ModernUIConstants {
public static final String WINDOW = "window";
public static final String DOT = ".";
public static final String EMB_TAG = "emb";
/**
* 从emb:dynamic 改为 emb://dynamic
* 7之后协议会自动在":"后加上斜杠导致识别错误
*/
public static final String COMPONENT_TAG = "emb://dynamic";
public static final String SCHEME_HEADER = "://";
public static final String DEFAULT_NAMESPACE = "Pool";
public static final String DEFAULT_VARIABLE = "data";
public static final String DEFAULT_EXPRESSION = "update()";
public static final String SCRIPT_INIT_NAME_SPACE = IOUtils.readResourceAsString("/com/fr/design/ui/InitNameSpace.js"); public static final String SCRIPT_INIT_NAME_SPACE = IOUtils.readResourceAsString("/com/fr/design/ui/InitNameSpace.js");
public static final String HTML_TPL = IOUtils.readResourceAsString("/com/fr/design/ui/tpl.html"); public static final String HTML_TPL = IOUtils.readResourceAsString("/com/fr/design/ui/tpl.html");

24
designer-base/src/main/java/com/fr/design/ui/ModernUIPane.java

@ -34,7 +34,10 @@ import java.util.Map;
* @version 10.0 * @version 10.0
* Created by richie on 2019-03-04 * Created by richie on 2019-03-04
* 用于加载html5的Swing容器可以在设计选项设置中打开调试窗口示例可查看com.fr.design.ui.ModernUIPaneTest * 用于加载html5的Swing容器可以在设计选项设置中打开调试窗口示例可查看com.fr.design.ui.ModernUIPaneTest
* @see {@link com.fr.design.jxbrowser.JxUIPane}
* @deprecated 主要用于jxbrowser6将在下个版本删除
*/ */
@Deprecated
public class ModernUIPane<T> extends BasicPane { public class ModernUIPane<T> extends BasicPane {
private Browser browser; private Browser browser;
@ -119,6 +122,7 @@ public class ModernUIPane<T> extends BasicPane {
/** /**
* 转向一个新的地址相当于重新加载 * 转向一个新的地址相当于重新加载
*
* @param url 新的地址 * @param url 新的地址
*/ */
public void redirect(String url) { public void redirect(String url) {
@ -127,6 +131,7 @@ public class ModernUIPane<T> extends BasicPane {
/** /**
* 转向一个新的地址相当于重新加载 * 转向一个新的地址相当于重新加载
*
* @param url 新的地址 * @param url 新的地址
* @param map 初始化参数 * @param map 初始化参数
*/ */
@ -161,7 +166,7 @@ public class ModernUIPane<T> extends BasicPane {
public void disposeBrowser() { public void disposeBrowser() {
if(browser != null) { if (browser != null) {
browser.dispose(); browser.dispose();
browser = null; browser = null;
} }
@ -191,6 +196,12 @@ public class ModernUIPane<T> extends BasicPane {
return null; return null;
} }
/**
* ModernUIPane 建造者
*
* @param <T>
*/
public static class Builder<T> implements BuilderDiff<T> { public static class Builder<T> implements BuilderDiff<T> {
private ModernUIPane<T> pane; private ModernUIPane<T> pane;
@ -219,6 +230,7 @@ public class ModernUIPane<T> extends BasicPane {
/** /**
* 加载jar包中的资源 * 加载jar包中的资源
*
* @param path 资源路径 * @param path 资源路径
*/ */
public Builder<T> withEMB(final String path) { public Builder<T> withEMB(final String path) {
@ -229,6 +241,7 @@ public class ModernUIPane<T> extends BasicPane {
/** /**
* 加载jar包中的资源 * 加载jar包中的资源
*
* @param path 资源路径 * @param path 资源路径
*/ */
public Builder<T> withEMB(final String path, Map<String, String> map) { public Builder<T> withEMB(final String path, Map<String, String> map) {
@ -239,6 +252,7 @@ public class ModernUIPane<T> extends BasicPane {
/** /**
* 加载url指向的资源 * 加载url指向的资源
*
* @param url 文件的地址 * @param url 文件的地址
*/ */
public Builder<T> withURL(final String url) { public Builder<T> withURL(final String url) {
@ -249,6 +263,7 @@ public class ModernUIPane<T> extends BasicPane {
/** /**
* 加载url指向的资源 * 加载url指向的资源
*
* @param url 文件的地址 * @param url 文件的地址
*/ */
public Builder<T> withURL(final String url, Map<String, String> map) { public Builder<T> withURL(final String url, Map<String, String> map) {
@ -259,6 +274,7 @@ public class ModernUIPane<T> extends BasicPane {
/** /**
* 加载Atom组件 * 加载Atom组件
*
* @param component Atom组件 * @param component Atom组件
*/ */
public Builder<T> withComponent(AssembleComponent component) { public Builder<T> withComponent(AssembleComponent component) {
@ -269,6 +285,7 @@ public class ModernUIPane<T> extends BasicPane {
/** /**
* 加载Atom组件 * 加载Atom组件
*
* @param component Atom组件 * @param component Atom组件
*/ */
public Builder<T> withComponent(AssembleComponent component, Map<String, String> map) { public Builder<T> withComponent(AssembleComponent component, Map<String, String> map) {
@ -277,9 +294,9 @@ public class ModernUIPane<T> extends BasicPane {
return this; return this;
} }
/** /**
* 加载html文本内容 * 加载html文本内容
*
* @param html 要加载html文本内容 * @param html 要加载html文本内容
*/ */
public Builder<T> withHTML(String html) { public Builder<T> withHTML(String html) {
@ -290,6 +307,7 @@ public class ModernUIPane<T> extends BasicPane {
/** /**
* 设置该前端页面做数据交换所使用的对象 * 设置该前端页面做数据交换所使用的对象
*
* @param namespace 对象名 * @param namespace 对象名
*/ */
public Builder<T> namespace(String namespace) { public Builder<T> namespace(String namespace) {
@ -299,6 +317,7 @@ public class ModernUIPane<T> extends BasicPane {
/** /**
* java端往js端传数据时使用的变量名字 * java端往js端传数据时使用的变量名字
*
* @param name 变量的名字 * @param name 变量的名字
*/ */
public Builder<T> variable(String name) { public Builder<T> variable(String name) {
@ -308,6 +327,7 @@ public class ModernUIPane<T> extends BasicPane {
/** /**
* js端往java端传数据时执行的函数表达式 * js端往java端传数据时执行的函数表达式
*
* @param expression 函数表达式 * @param expression 函数表达式
*/ */
public Builder<T> expression(String expression) { public Builder<T> expression(String expression) {

33
designer-base/src/main/java/com/fr/design/ui/compatible/BuilderDiff.java

@ -1,5 +1,6 @@
package com.fr.design.ui.compatible; package com.fr.design.ui.compatible;
import com.fr.design.jxbrowser.JxUIPane;
import com.fr.design.ui.ModernUIPane; import com.fr.design.ui.ModernUIPane;
import com.teamdev.jxbrowser.browser.callback.InjectJsCallback; import com.teamdev.jxbrowser.browser.callback.InjectJsCallback;
import com.teamdev.jxbrowser.chromium.events.LoadListener; import com.teamdev.jxbrowser.chromium.events.LoadListener;
@ -10,17 +11,45 @@ import com.teamdev.jxbrowser.event.Observer;
* 封装jxbrwoser v6/v7的构建方式的差异 * 封装jxbrwoser v6/v7的构建方式的差异
* *
* @author hades * @author hades
* @version 10.0 * @see {@link JxUIPane}
* Created by hades on 2021/6/13 * @since 10.0
* Created on 2021/6/13
* @deprecated 6在下个版本弃用
*/ */
@Deprecated
public interface BuilderDiff<T> { public interface BuilderDiff<T> {
/**
* v6准备工作
*
* @param contextListener 上下文监听器
* @return 构造器
*/
ModernUIPane.Builder<T> prepareForV6(ScriptContextListener contextListener); ModernUIPane.Builder<T> prepareForV6(ScriptContextListener contextListener);
/**
* v6准备工作
*
* @param loadListener 加载监听器
* @return 构造器
*/
ModernUIPane.Builder<T> prepareForV6(LoadListener loadListener); ModernUIPane.Builder<T> prepareForV6(LoadListener loadListener);
/**
* v7准备工作
*
* @param callback 注入js回调器
* @return 构造器
*/
ModernUIPane.Builder<T> prepareForV7(InjectJsCallback callback); ModernUIPane.Builder<T> prepareForV7(InjectJsCallback callback);
/**
* v7准备工作
*
* @param event 事件
* @param listener 监听器
* @return 构造器
*/
ModernUIPane.Builder<T> prepareForV7(Class event, Observer listener); ModernUIPane.Builder<T> prepareForV7(Class event, Observer listener);
} }

35
designer-base/src/main/java/com/fr/design/ui/compatible/ModernUIPaneFactory.java

@ -1,36 +1,45 @@
package com.fr.design.ui.compatible; package com.fr.design.ui.compatible;
import com.fr.design.jxbrowser.JxUIPane;
import com.fr.design.ui.ModernUIPane; import com.fr.design.ui.ModernUIPane;
import com.fr.stable.os.OperatingSystem;
/** /**
* 根据版本选择构造器
*
* @author hades * @author hades
* @version 10.0 * @see {@link JxUIPane}
* Created by hades on 2021/6/13 * @since 10.0
* Created on 2021/6/13
* @deprecated 6在下个版本弃用
*/ */
public class ModernUIPaneFactory { public class ModernUIPaneFactory {
/**
* 获取一个 JxBrowser pane 的构造器
*
* @param <T> 参数
* @return 构造器
*/
public static <T> ModernUIPane.Builder<T> modernUIPaneBuilder() { public static <T> ModernUIPane.Builder<T> modernUIPaneBuilder() {
if (isV7()) { if (isV7()) {
return new NewModernUIPane.Builder<>(); return new JxUIPane.Builder<>();
} else { } else {
return new ModernUIPane.Builder<>(); return new ModernUIPane.Builder<>();
} }
} }
/**
* 判断 JxBrowser 版本是否在7或之上
*
* @return 是否7或之上
*/
public static boolean isV7() { public static boolean isV7() {
boolean jxBrowserV7 = true;
// 7.15的class不存在时 走老版本
boolean hasJxBrowserV7_15 = true;
try { try {
Class.forName("com.teamdev.jxbrowser.net.Scheme"); Class.forName("com.teamdev.jxbrowser.net.Scheme");
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
hasJxBrowserV7_15 = false; jxBrowserV7 = false;
} }
return jxBrowserV7;
return OperatingSystem.isWindows() && hasJxBrowserV7_15;
} }
} }

362
designer-base/src/main/java/com/fr/design/ui/compatible/NewModernUIPane.java

@ -1,362 +0,0 @@
package com.fr.design.ui.compatible;
import com.fr.design.DesignerEnvManager;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.i18n.Toolkit;
import com.fr.design.ui.ModernUIConstants;
import com.fr.design.ui.ModernUIPane;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.web.struct.AssembleComponent;
import com.teamdev.jxbrowser.browser.Browser;
import com.teamdev.jxbrowser.browser.callback.InjectJsCallback;
import com.teamdev.jxbrowser.chromium.events.LoadListener;
import com.teamdev.jxbrowser.chromium.events.ScriptContextListener;
import com.teamdev.jxbrowser.engine.Engine;
import com.teamdev.jxbrowser.engine.EngineOptions;
import com.teamdev.jxbrowser.engine.RenderingMode;
import com.teamdev.jxbrowser.event.Observer;
import com.teamdev.jxbrowser.js.JsObject;
import com.teamdev.jxbrowser.net.Network;
import com.teamdev.jxbrowser.net.Scheme;
import com.teamdev.jxbrowser.net.callback.VerifyCertificateCallback;
import com.teamdev.jxbrowser.view.swing.BrowserView;
import org.jetbrains.annotations.Nullable;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.util.Map;
import javax.swing.JDialog;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;
/**
* 基于v7 jxbrowser实现
*
* @author richie
* @version 10.0
* Created by richie on 2019-03-04
* 用于加载html5的Swing容器可以在设计选项设置中打开调试窗口示例可查看com.fr.design.ui.ModernUIPaneTest
*/
public class NewModernUIPane<T> extends ModernUIPane<T> {
private Browser browser;
private String namespace = "Pool";
private String variable = "data";
private String expression = "update()";
private Scheme scheme;
private NxInterceptRequestCallback requestCallback;
private NewModernUIPane() {
super();
initialize();
}
private void initialize() {
setLayout(new BorderLayout());
if (browser == null) {
if (DesignerEnvManager.getEnvManager().isOpenDebug()) {
UIToolbar toolbar = new UIToolbar();
add(toolbar, BorderLayout.NORTH);
UIButton openDebugButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Open_Debug_Window"));
toolbar.add(openDebugButton);
UIButton reloadButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Reload"));
toolbar.add(reloadButton);
UIButton closeButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Close_Window"));
toolbar.add(closeButton);
openDebugButton.addActionListener(e -> showDebuggerDialog());
reloadButton.addActionListener(e -> browser.navigation().reloadIgnoringCache());
closeButton.addActionListener(e -> SwingUtilities.getWindowAncestor(
NewModernUIPane.this).setVisible(false));
initializeBrowser();
add(BrowserView.newInstance(browser), BorderLayout.CENTER);
} else {
initializeBrowser();
add(BrowserView.newInstance(browser), BorderLayout.CENTER);
}
}
}
private void showDebuggerDialog() {
JDialog dialog = new JDialog(SwingUtilities.getWindowAncestor(this));
Browser debugger = browser.engine().newBrowser();
BrowserView debuggerView = BrowserView.newInstance(debugger);
dialog.add(debuggerView, BorderLayout.CENTER);
dialog.setSize(new Dimension(800, 400));
GUICoreUtils.centerWindow(dialog);
dialog.setVisible(true);
dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
browser.devTools().remoteDebuggingUrl().ifPresent(url -> {
debugger.navigation().loadUrl(url);
});
}
private void initializeBrowser() {
EngineOptions.Builder builder;
if (scheme != null && requestCallback != null) {
builder = EngineOptions.newBuilder(RenderingMode.HARDWARE_ACCELERATED).addSwitch("--disable-google-traffic").addScheme(scheme, requestCallback);
} else {
builder = EngineOptions.newBuilder(RenderingMode.HARDWARE_ACCELERATED).addSwitch("--disable-google-traffic");
}
if (DesignerEnvManager.getEnvManager().isOpenDebug()) {
builder.remoteDebuggingPort(9222);
}
Engine engine = Engine.newInstance(builder.build());
if (DesignerEnvManager.getEnvManager().isOpenDebug()) {
// 调试模式下,禁止HTTPS证书验证,使得可以正常访问商城测试服务器等
Network network = engine.network();
network.set(VerifyCertificateCallback.class, new VerifyCertificateCallback() {
@Nullable
@Override
public Response on(Params params) {
return VerifyCertificateCallback.Response.valid();
}
});
}
browser = engine.newBrowser();
// 初始化的时候,就把命名空间对象初始化好,确保window.a.b.c("a.b.c"为命名空间)对象都是初始化过的
browser.set(InjectJsCallback.class, params -> {
params.frame().executeJavaScript(String.format(ModernUIConstants.SCRIPT_INIT_NAME_SPACE, namespace));
return InjectJsCallback.Response.proceed();
});
}
/**
* 转向一个新的地址相当于重新加载
*
* @param url 新的地址
*/
@Override
public void redirect(String url) {
browser.navigation().loadUrl(url);
}
/**
* 转向一个新的地址相当于重新加载
*
* @param url 新的地址
* @param map 初始化参数
*/
@Override
public void redirect(String url, Map<String, String> map) {
if (requestCallback != null) {
requestCallback.setMap(map);
}
browser.navigation().loadUrl(url);
}
@Override
protected String title4PopupWindow() {
return "Modern";
}
@Override
public void populate(final T t) {
browser.set(InjectJsCallback.class, params -> {
JsObject ns = params.frame().executeJavaScript("window." + namespace);
if (ns != null) {
ns.putProperty(variable, t);
}
return InjectJsCallback.Response.proceed();
});
}
@Override
public T update() {
if (browser.mainFrame().isPresent()) {
return browser.mainFrame().get().executeJavaScript("window." + namespace + "." + expression);
}
return null;
}
public void disposeBrowser() {
if (browser != null) {
browser.engine().close();
browser = null;
}
}
public void clearCache() {
if (browser != null) {
browser.engine().httpCache().clear();
}
}
public void executeJavaScript(String javaScript) {
if (browser != null) {
browser.mainFrame().ifPresent(frame -> {
frame.executeJavaScript(javaScript);
});
}
}
public static class Builder<T> extends ModernUIPane.Builder<T> {
private NewModernUIPane<T> pane = new NewModernUIPane<>();
public Builder() {
super((ModernUIPane<T>)null);
}
public NewModernUIPane.Builder<T> prepare(InjectJsCallback callback) {
pane.browser.set(InjectJsCallback.class, callback);
return this;
}
/**
* 加载jar包中的资源
*
* @param path 资源路径
*/
@Override
public NewModernUIPane.Builder<T> withEMB(final String path) {
pane.scheme = Scheme.of("emb");
pane.requestCallback = new NxComplexInterceptRequestCallback(null);
pane.browser.navigation().loadUrl("emb:" + path);
return this;
}
/**
* 加载url指向的资源
*
* @param url 文件的地址
*/
@Override
public NewModernUIPane.Builder<T> withURL(final String url) {
pane.scheme = Scheme.of("file");
pane.requestCallback = new NxComplexInterceptRequestCallback(null);
pane.browser.navigation().loadUrl(url);
return this;
}
/**
* 加载url指向的资源
*
* @param url 文件的地址
*/
@Override
public NewModernUIPane.Builder<T> withURL(final String url, Map<String, String> map) {
pane.scheme = Scheme.of("file");
pane.requestCallback = new NxInterceptRequestCallback(map);
pane.browser.navigation().loadUrl(url);
return this;
}
/**
* 加载Atom组件
*
* @param component Atom组件
*/
@Override
public NewModernUIPane.Builder<T> withComponent(AssembleComponent component) {
pane.scheme = Scheme.of("emb");
pane.requestCallback = new NxComplexInterceptRequestCallback(component);
pane.browser.navigation().loadUrl("emb:dynamic");
return this;
}
/**
* 加载Atom组件
*
* @param component Atom组件
*/
@Override
public NewModernUIPane.Builder<T> withComponent(AssembleComponent component, Map<String, String> map) {
pane.scheme = Scheme.of("emb");
pane.requestCallback = new NxComplexInterceptRequestCallback(component, map);
pane.browser.navigation().loadUrl("emb:dynamic");
return this;
}
/**
* 加载html文本内容
*
* @param html 要加载html文本内容
*/
@Override
public NewModernUIPane.Builder<T> withHTML(String html) {
pane.scheme = Scheme.of("html");
pane.requestCallback = new NxInterceptRequestCallback();
pane.browser.mainFrame().ifPresent(frame -> {
frame.loadHtml(html);
});
return this;
}
/**
* 设置该前端页面做数据交换所使用的对象
*
* @param namespace 对象名
*/
@Override
public NewModernUIPane.Builder<T> namespace(String namespace) {
pane.namespace = namespace;
return this;
}
/**
* java端往js端传数据时使用的变量名字
*
* @param name 变量的名字
*/
@Override
public NewModernUIPane.Builder<T> variable(String name) {
pane.variable = name;
return this;
}
/**
* js端往java端传数据时执行的函数表达式
*
* @param expression 函数表达式
*/
@Override
public NewModernUIPane.Builder<T> expression(String expression) {
pane.expression = expression;
return this;
}
@Override
public NewModernUIPane.Builder<T> prepareForV6(ScriptContextListener contextListener) {
// do nothing
return this;
}
@Override
public NewModernUIPane.Builder<T> prepareForV6(LoadListener loadListener) {
// do nothing
return this;
}
@Override
public NewModernUIPane.Builder<T> prepareForV7(InjectJsCallback callback) {
return prepare(callback);
}
@Override
public ModernUIPane.Builder<T> prepareForV7(Class event, Observer listener) {
pane.browser.navigation().on(event, listener);
return this;
}
@Override
public NewModernUIPane<T> build() {
return pane;
}
}
}

86
designer-base/src/main/java/com/fr/design/ui/compatible/NxComplexInterceptRequestCallback.java

@ -1,86 +0,0 @@
package com.fr.design.ui.compatible;
import com.fr.design.ui.ModernRequestClient;
import com.fr.design.ui.ModernUIConstants;
import com.fr.general.IOUtils;
import com.fr.stable.StringUtils;
import com.fr.web.struct.AssembleComponent;
import com.fr.web.struct.AtomBuilder;
import com.fr.web.struct.PathGroup;
import com.fr.web.struct.category.ScriptPath;
import com.fr.web.struct.category.StylePath;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Map;
/**
* @author richie
* @version 10.0
* Created by richie on 2020/3/25
*/
public class NxComplexInterceptRequestCallback extends NxInterceptRequestCallback {
private AssembleComponent component;
public NxComplexInterceptRequestCallback(AssembleComponent component) {
this.component = component;
}
public NxComplexInterceptRequestCallback(AssembleComponent component, Map<String, String> map) {
super(map);
this.component = component;
}
@Override
protected Response next(Params params, String path) {
if (path.startsWith("emb:dynamic")) {
String text = htmlText(map);
return Response.intercept(generateBasicUrlRequestJob(params, "text/html", text.getBytes(StandardCharsets.UTF_8)));
} else {
int index = path.indexOf("=");
if (index > 0) {
path = path.substring(index + 1);
} else {
path = path.substring(4);
}
InputStream inputStream = IOUtils.readResource(path);
if (inputStream == null) {
return Response.proceed();
}
return Response.intercept(generateBasicUrlRequestJob(params, getMimeType(path), IOUtils.inputStream2Bytes(inputStream)));
}
}
private String htmlText(Map<String, String> map) {
PathGroup pathGroup = AtomBuilder.create().buildAssembleFilePath(ModernRequestClient.KEY, component);
StylePath[] stylePaths = pathGroup.toStylePathGroup();
StringBuilder styleText = new StringBuilder();
for (StylePath path : stylePaths) {
if (StringUtils.isNotBlank(path.toFilePath())) {
styleText.append("<link rel=\"stylesheet\" href=\"emb:");
styleText.append(path.toFilePath());
styleText.append("\"/>");
}
}
String result = ModernUIConstants.HTML_TPL.replaceAll("##style##", styleText.toString());
ScriptPath[] scriptPaths = pathGroup.toScriptPathGroup();
StringBuilder scriptText = new StringBuilder();
for (ScriptPath path : scriptPaths) {
if (StringUtils.isNotBlank(path.toFilePath())) {
scriptText.append("<script src=\"emb:");
scriptText.append(path.toFilePath());
scriptText.append("\"></script>");
}
}
result = result.replaceAll("##script##", scriptText.toString());
if (map != null) {
for (Map.Entry<String, String> entry : map.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
result = result.replaceAll("\\$\\{" + key + "}", value);
}
}
return result;
}
}

148
designer-base/src/main/java/com/fr/design/ui/compatible/NxInterceptRequestCallback.java

@ -1,148 +0,0 @@
package com.fr.design.ui.compatible;
import com.fr.base.TemplateUtils;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils;
import com.fr.stable.EncodeConstants;
import com.fr.stable.StringUtils;
import com.fr.third.org.apache.commons.codec.net.URLCodec;
import com.teamdev.jxbrowser.net.HttpHeader;
import com.teamdev.jxbrowser.net.HttpStatus;
import com.teamdev.jxbrowser.net.UrlRequest;
import com.teamdev.jxbrowser.net.UrlRequestJob;
import com.teamdev.jxbrowser.net.callback.InterceptUrlRequestCallback;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Map;
import java.util.Optional;
/**
* @author richie
* @version 10.0
* Created by richie on 2020/3/25
*/
public class NxInterceptRequestCallback implements InterceptUrlRequestCallback {
Map<String, String> map;
public NxInterceptRequestCallback() {
}
public NxInterceptRequestCallback(Map<String, String> map) {
this.map = map;
}
@Override
public Response on(Params params) {
UrlRequest urlRequest = params.urlRequest();
String path = urlRequest.url();
if (path.startsWith("file:")) {
Optional<UrlRequestJob> optional = generateFileProtocolUrlRequestJob(params, path);
if (optional.isPresent()) {
return Response.intercept(optional.get());
}
} else {
return next(params, path);
}
return Response.proceed();
}
Response next(Params params, String path) {
return Response.proceed();
}
private Optional<UrlRequestJob> generateFileProtocolUrlRequestJob(Params params, String path) {
try {
String url = new URLCodec().decode(path);
String filePath = TemplateUtils.renderParameter4Tpl(url, map);
File file = new File(URI.create(filePath).getPath());
InputStream inputStream = IOUtils.readResource(file.getAbsolutePath());
String mimeType = getMimeType(path);
byte[] bytes;
if (isPlainText(mimeType)) {
String text = IOUtils.inputStream2String(inputStream, EncodeConstants.ENCODING_UTF_8);
text = TemplateUtils.renderParameter4Tpl(text, map);
bytes = text.getBytes(StandardCharsets.UTF_8);
} else {
bytes = IOUtils.inputStream2Bytes(inputStream);
}
return Optional.of(generateBasicUrlRequestJob(params, mimeType, bytes));
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return Optional.empty();
}
private boolean isPlainText(String mimeType) {
return ArrayUtils.contains(new String[]{"text/html", "text/javascript", "text/css"}, mimeType);
}
UrlRequestJob generateBasicUrlRequestJob(Params params, String mimeType, byte[] bytes) {
UrlRequestJob.Options options = UrlRequestJob.Options
.newBuilder(HttpStatus.OK)
.addHttpHeader(HttpHeader.of("Content-Type", mimeType))
.build();
UrlRequestJob urlRequestJob = params.newUrlRequestJob(options);
urlRequestJob.write(bytes);
urlRequestJob.complete();
return urlRequestJob;
}
String getMimeType(String path) {
// 去除 xxx?xxx 后面部分
int index = path.indexOf("?");
if (index != -1) {
path = path.substring(0, path.indexOf("?"));
}
if (StringUtils.isBlank(path)) {
return "text/html";
}
if (path.endsWith(".html")) {
return "text/html";
}
if (path.endsWith(".css")) {
return "text/css";
}
if (path.endsWith(".js")) {
return "text/javascript";
}
if (path.endsWith(".svg")) {
return "image/svg+xml";
}
if (path.endsWith(".png")) {
return "image/png";
}
if (path.endsWith(".jpeg")) {
return "image/jpeg";
}
if (path.endsWith(".gif")) {
return "image/gif";
}
if (path.endsWith(".woff")) {
return "font/woff";
}
if (path.endsWith(".ttf")) {
return "truetype";
}
if (path.endsWith(".eot")) {
return "embedded-opentype";
}
Path file = new File(path).toPath();
try {
return Files.probeContentType(file);
} catch (IOException e) {
return "text/html";
}
}
public void setMap(Map<String, String> map) {
this.map = map;
}
}

36
designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateDialog.java

@ -1,7 +1,7 @@
package com.fr.design.update.push; package com.fr.design.update.push;
import com.fr.design.dialog.UIDialog; import com.fr.design.dialog.UIDialog;
import com.fr.design.ui.ModernUIPane; import com.fr.design.jxbrowser.JxUIPane;
import com.fr.design.utils.BrowseUtils; import com.fr.design.utils.BrowseUtils;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.intelli.record.FocusPoint; import com.fr.intelli.record.FocusPoint;
@ -14,20 +14,24 @@ import com.fr.web.struct.browser.RequestClient;
import com.fr.web.struct.category.ScriptPath; import com.fr.web.struct.category.ScriptPath;
import com.fr.web.struct.category.StylePath; import com.fr.web.struct.category.StylePath;
import com.fr.web.struct.impl.FineUI; import com.fr.web.struct.impl.FineUI;
import com.teamdev.jxbrowser.js.JsAccessible;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Frame; import java.awt.Frame;
/** /**
* Created by plough on 2019/4/10. * 设计器推送更新对话框
*
* @author plough
* @since 10.0
* Created on 2019/4/10.
*/ */
class DesignerPushUpdateDialog extends UIDialog { public class DesignerPushUpdateDialog extends UIDialog {
public static final Dimension DEFAULT = new Dimension(640, 360); public static final Dimension DEFAULT = new Dimension(640, 360);
private ModernUIPane<Model> jsPane; private JxUIPane<Model> jsPane;
private DesignerPushUpdateDialog(Frame parent) { private DesignerPushUpdateDialog(Frame parent) {
super(parent); super(parent);
@ -35,23 +39,23 @@ class DesignerPushUpdateDialog extends UIDialog {
initComponents(); initComponents();
} }
static void createAndShow(final Frame parent, final DesignerUpdateInfo updateInfo) { /**
SwingUtilities.invokeLater(new Runnable() { * 创建并展示窗口
@Override *
public void run() { * @param parent 父窗体
* @param updateInfo 要展示的更新数据
*/
public static void createAndShow(final Frame parent, final DesignerUpdateInfo updateInfo) {
DesignerPushUpdateDialog dialog = new DesignerPushUpdateDialog(parent); DesignerPushUpdateDialog dialog = new DesignerPushUpdateDialog(parent);
dialog.populate(updateInfo); dialog.populate(updateInfo);
dialog.showDialog(); dialog.showDialog();
} }
});
}
private void initComponents() { private void initComponents() {
JPanel contentPane = (JPanel) getContentPane(); JPanel contentPane = (JPanel) getContentPane();
contentPane.setLayout(new BorderLayout()); contentPane.setLayout(new BorderLayout());
jsPane = new ModernUIPane.Builder<Model>() jsPane = new JxUIPane.Builder<Model>()
.withComponent(new AssembleComponent() { .withComponent(new AssembleComponent() {
@Override @Override
public ScriptPath script(RequestClient req) { public ScriptPath script(RequestClient req) {
@ -67,7 +71,7 @@ class DesignerPushUpdateDialog extends UIDialog {
public Atom[] refer() { public Atom[] refer() {
return new Atom[]{FineUI.KEY}; return new Atom[]{FineUI.KEY};
} }
}).namespace("Pool").build(); }).build();
contentPane.add(jsPane); contentPane.add(jsPane);
} }
@ -101,6 +105,7 @@ class DesignerPushUpdateDialog extends UIDialog {
setVisible(true); setVisible(true);
} }
@JsAccessible
public class Model { public class Model {
private String version; private String version;
private String content; private String content;
@ -163,6 +168,7 @@ class DesignerPushUpdateDialog extends UIDialog {
exit(); exit();
} }
@JsAccessible
public String i18nText(String key) { public String i18nText(String key) {
return com.fr.design.i18n.Toolkit.i18nText(key); return com.fr.design.i18n.Toolkit.i18nText(key);
} }
@ -180,9 +186,11 @@ class DesignerPushUpdateDialog extends UIDialog {
private enum OperateType { private enum OperateType {
CLOSE_WINDOW(0), UPDATE(1), REMIND_NEXT_TIME(2), SKIP(3); CLOSE_WINDOW(0), UPDATE(1), REMIND_NEXT_TIME(2), SKIP(3);
private int index; private int index;
OperateType(int index) { OperateType(int index) {
this.index = index; this.index = index;
} }
private String toText() { private String toText() {
return String.valueOf(this.index); return String.valueOf(this.index);
} }

10
designer-base/src/main/java/com/fr/design/update/push/DesignerUpdateInfo.java

@ -12,9 +12,13 @@ import com.fr.stable.StringUtils;
import java.security.InvalidParameterException; import java.security.InvalidParameterException;
/** /**
* Created by plough on 2019/4/8. * 设计器更新信息bean
*
* @author plough
* @since 10.0
* Created on 2019/4/8.
*/ */
class DesignerUpdateInfo { public class DesignerUpdateInfo {
private static final String KEY_VERSION = "version"; private static final String KEY_VERSION = "version";
private static final String KEY_CONTENT = "content"; private static final String KEY_CONTENT = "content";
private static final String KEY_BACKGROUND_URL = "background"; private static final String KEY_BACKGROUND_URL = "background";
@ -32,7 +36,7 @@ class DesignerUpdateInfo {
private final String backgroundUrl; // 推送背景图片 url private final String backgroundUrl; // 推送背景图片 url
private final String moreInfoUrl; // 更多新特性 private final String moreInfoUrl; // 更多新特性
DesignerUpdateInfo(String currentVersion, String latestVersion, String lastIgnoredVersion, JSONObject pushData) { public DesignerUpdateInfo(String currentVersion, String latestVersion, String lastIgnoredVersion, JSONObject pushData) {
this.currentVersion = currentVersion; this.currentVersion = currentVersion;
this.latestVersion = latestVersion; this.latestVersion = latestVersion;
this.latestFullVersion = initLatestFullVersion(); this.latestFullVersion = initLatestFullVersion();

8
designer-base/src/main/java/com/fr/design/upm/UpmBridge.java

@ -42,11 +42,11 @@ import com.teamdev.jxbrowser.chromium.JSFunction;
import com.teamdev.jxbrowser.chromium.JSObject; import com.teamdev.jxbrowser.chromium.JSObject;
import com.teamdev.jxbrowser.chromium.JSValue; import com.teamdev.jxbrowser.chromium.JSValue;
import java.awt.Desktop;
import javax.swing.JFileChooser; import javax.swing.JFileChooser;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.SwingWorker; import javax.swing.SwingWorker;
import javax.swing.filechooser.FileNameExtensionFilter; import javax.swing.filechooser.FileNameExtensionFilter;
import java.awt.Desktop;
import java.io.File; import java.io.File;
import java.net.URI; import java.net.URI;
import java.util.ArrayList; import java.util.ArrayList;
@ -60,7 +60,9 @@ import java.util.concurrent.RunnableFuture;
* @version 10.0 * @version 10.0
* Created by richie on 2019-04-12 * Created by richie on 2019-04-12
* 桥接Java和JavaScript的类 * 桥接Java和JavaScript的类
* @deprecated 用于jxbrowser6下版本删除
*/ */
@Deprecated
public class UpmBridge { public class UpmBridge {
public static UpmBridge getBridge(Browser browser) { public static UpmBridge getBridge(Browser browser) {
@ -79,6 +81,7 @@ public class UpmBridge {
/** /**
* 更新插件管理中心资源文件这个方法仅仅是为了语义上的作用更新 * 更新插件管理中心资源文件这个方法仅仅是为了语义上的作用更新
*
* @param callback 安装完成后的回调函数 * @param callback 安装完成后的回调函数
*/ */
@JSBridge @JSBridge
@ -97,6 +100,7 @@ public class UpmBridge {
/** /**
* 下载并安装插件管理中心的资源文件 * 下载并安装插件管理中心的资源文件
*
* @param callback 安装完成后的回调函数 * @param callback 安装完成后的回调函数
*/ */
@JSBridge @JSBridge
@ -127,6 +131,7 @@ public class UpmBridge {
/** /**
* 获取upm的版本信息 * 获取upm的版本信息
*
* @return 版本信息 * @return 版本信息
*/ */
@JSBridge @JSBridge
@ -481,6 +486,7 @@ public class UpmBridge {
/** /**
* 使用系统浏览器打开网页 * 使用系统浏览器打开网页
*
* @param url 要打开的网页 * @param url 要打开的网页
*/ */
@JSBridge @JSBridge

9
designer-base/src/main/java/com/fr/design/upm/NewUpmBridge.java → designer-base/src/main/java/com/fr/design/upm/UpmBridgeV7.java

@ -45,15 +45,16 @@ import java.util.concurrent.RunnableFuture;
* Created by richie on 2019-04-12 * Created by richie on 2019-04-12
* 桥接Java和JavaScript的类 * 桥接Java和JavaScript的类
*/ */
public class NewUpmBridge extends UpmBridge { @JsAccessible
public class UpmBridgeV7 extends UpmBridge {
public static NewUpmBridge getBridge(JsObject jsObject) { public static UpmBridgeV7 getBridge(JsObject jsObject) {
return new NewUpmBridge(jsObject); return new UpmBridgeV7(jsObject);
} }
private JsObject jsObject; private JsObject jsObject;
private NewUpmBridge(JsObject jsObject) { private UpmBridgeV7(JsObject jsObject) {
this.jsObject = jsObject; this.jsObject = jsObject;
} }

4
designer-base/src/main/java/com/fr/design/upm/UpmFinder.java

@ -8,6 +8,7 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.login.utils.DesignerLoginUtils; import com.fr.design.login.utils.DesignerLoginUtils;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.plugin.DesignerPluginContext; import com.fr.design.plugin.DesignerPluginContext;
import com.fr.design.ui.ModernUIConstants;
import com.fr.design.update.ui.dialog.UpdateMainDialog; import com.fr.design.update.ui.dialog.UpdateMainDialog;
import com.fr.event.Event; import com.fr.event.Event;
import com.fr.event.EventDispatcher; import com.fr.event.EventDispatcher;
@ -57,7 +58,8 @@ public class UpmFinder {
} }
public static String getMainResourcePath() { public static String getMainResourcePath() {
return "file:///" + StableUtils.pathJoin(installHome, MAIN_RESOURCE_PATH); return ModernUIConstants.EMB_TAG + ModernUIConstants.SCHEME_HEADER
+ StableUtils.pathJoin(installHome, MAIN_RESOURCE_PATH);
} }
public static UIDialog getDialog() { public static UIDialog getDialog() {

30
designer-base/src/main/java/com/fr/design/upm/UpmShowPane.java

@ -1,19 +1,13 @@
package com.fr.design.upm; package com.fr.design.upm;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.ui.ModernUIPane; import com.fr.design.jxbrowser.JxUIPane;
import com.fr.design.ui.compatible.ModernUIPaneFactory;
import com.fr.design.upm.event.DownloadEvent; import com.fr.design.upm.event.DownloadEvent;
import com.fr.event.Event; import com.fr.event.Event;
import com.fr.event.EventDispatcher; import com.fr.event.EventDispatcher;
import com.fr.event.Listener; import com.fr.event.Listener;
import com.teamdev.jxbrowser.browser.callback.InjectJsCallback;
import com.teamdev.jxbrowser.chromium.JSValue;
import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter;
import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent;
import com.teamdev.jxbrowser.js.JsObject; import java.awt.BorderLayout;
import java.awt.*;
/** /**
* @author richie * @author richie
@ -23,7 +17,9 @@ import java.awt.*;
*/ */
public class UpmShowPane extends BasicPane { public class UpmShowPane extends BasicPane {
private ModernUIPane<Object> modernUIPane; public static final String PLUGIN_HELPER = "PluginHelper";
private final JxUIPane<Object> jxUIPane;
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
@ -32,28 +28,22 @@ public class UpmShowPane extends BasicPane {
UpmShowPane() { UpmShowPane() {
setLayout(new BorderLayout()); setLayout(new BorderLayout());
modernUIPane = new ModernUIPane.Builder<>() jxUIPane = new JxUIPane.Builder<>()
.prepare(new ScriptContextAdapter() { .bindWindow(PLUGIN_HELPER, UpmBridgeV7::getBridge)
@Override
public void onScriptContextCreated(ScriptContextEvent event) {
JSValue window = event.getBrowser().executeJavaScriptAndReturnValue("window");
window.asObject().setProperty("PluginHelper", UpmBridge.getBridge(event.getBrowser()));
}
})
.withURL(UpmFinder.getMainResourcePath(), UpmUtils.renderMap()) .withURL(UpmFinder.getMainResourcePath(), UpmUtils.renderMap())
.build(); .build();
EventDispatcher.listen(DownloadEvent.UPDATE, new Listener<String>() { EventDispatcher.listen(DownloadEvent.UPDATE, new Listener<String>() {
@Override @Override
public void on(Event event, String param) { public void on(Event event, String param) {
modernUIPane.redirect(UpmFinder.getMainResourcePath(), UpmUtils.renderMap()); jxUIPane.redirect(UpmFinder.getMainResourcePath(), UpmUtils.renderMap());
} }
}); });
EventDispatcher.listen(DownloadEvent.UPDATE, new Listener<String>() { EventDispatcher.listen(DownloadEvent.UPDATE, new Listener<String>() {
@Override @Override
public void on(Event event, String param) { public void on(Event event, String param) {
modernUIPane.redirect(UpmFinder.getMainResourcePath(), UpmUtils.renderMap()); jxUIPane.redirect(UpmFinder.getMainResourcePath(), UpmUtils.renderMap());
} }
}); });
add(modernUIPane, BorderLayout.CENTER); add(jxUIPane, BorderLayout.CENTER);
} }
} }

20
designer-base/src/test/java/com/fr/design/actions/help/TutorialActionTest.java

@ -1,14 +1,34 @@
package com.fr.design.actions.help; package com.fr.design.actions.help;
import com.fr.base.svg.SystemScaleUtils;
import com.fr.design.i18n.Toolkit;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.easymock.EasyMock;
import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import java.util.Locale; import java.util.Locale;
import java.util.UUID; import java.util.UUID;
@RunWith(PowerMockRunner.class)
@PowerMockIgnore({"javax.management.*","javax.net.ssl.*"})
@PrepareForTest({Toolkit.class, SystemScaleUtils.class})
public class TutorialActionTest extends TestCase { public class TutorialActionTest extends TestCase {
public void setUp() {
PowerMock.mockStatic(Toolkit.class);
EasyMock.expect(Toolkit.i18nText(EasyMock.anyString())).andReturn("test").anyTimes();
PowerMock.mockStatic(SystemScaleUtils.class);
EasyMock.expect(SystemScaleUtils.sysScale()).andReturn(1F).anyTimes();
EasyMock.expect(SystemScaleUtils.isJreHiDPIEnabled()).andReturn(false).anyTimes();
PowerMock.replayAll();
}
public void testCreateKey() { public void testCreateKey() {
TutorialAction action = new TutorialAction(); TutorialAction action = new TutorialAction();
GeneralContext.setLocale(Locale.US); GeneralContext.setLocale(Locale.US);

10
designer-base/src/test/java/com/fr/design/base/clipboard/DesignerClipboardTest.java

@ -1,5 +1,6 @@
package com.fr.design.base.clipboard; package com.fr.design.base.clipboard;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.fun.ClipboardHandlerProvider; import com.fr.design.fun.ClipboardHandlerProvider;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.dnd.ArrayListTransferable; import com.fr.design.mainframe.dnd.ArrayListTransferable;
@ -42,10 +43,19 @@ public class DesignerClipboardTest {
.anyTimes(); .anyTimes();
EasyMock.replay(formClassManager); EasyMock.replay(formClassManager);
ExtraDesignClassManager designClassManager = EasyMock.mock(ExtraDesignClassManager.class);
EasyMock.expect(designClassManager.getArray(ClipboardHandlerProvider.XML_TAG))
.andReturn(providers)
.anyTimes();
EasyMock.replay(designClassManager);
PowerMock.mockStatic(PluginModule.class); PowerMock.mockStatic(PluginModule.class);
EasyMock.expect(PluginModule.getAgent(PluginModule.ExtraForm)) EasyMock.expect(PluginModule.getAgent(PluginModule.ExtraForm))
.andReturn(formClassManager) .andReturn(formClassManager)
.anyTimes(); .anyTimes();
EasyMock.expect(PluginModule.getAgent(PluginModule.ExtraDesign))
.andReturn(designClassManager)
.anyTimes();
PowerMock.replayAll(); PowerMock.replayAll();
} }

17
designer-base/src/test/java/com/fr/design/data/DesignTableDataManagerTest.java

@ -141,18 +141,15 @@ public class DesignTableDataManagerTest {
} }
@Test @Test
public void testAddDsColumnNames() { public void testOperateDsColumnNames() {
DesignTableDataManager.addDsColumnNames("ds1", new String[]{"a", "b", "c"});
Map<TableDataSource, Map<String, String[]>> map = Reflect.on(DesignTableDataManager.class).field(
"columnCache").get();
Assert.assertEquals(new String[]{"a", "b", "c"}, map.get(null).get("ds1"));
}
@Test
public void testGetDsColumnNames() {
Assert.assertTrue(ArrayUtils.isEmpty(DesignTableDataManager.getDsColumnNames("ds1")));
String[] columnNames = new String[]{"a", "b", "c"}; String[] columnNames = new String[]{"a", "b", "c"};
Assert.assertTrue(ArrayUtils.isEmpty(DesignTableDataManager.getDsColumnNames("ds1")));
// 测试Add
DesignTableDataManager.addDsColumnNames("ds1", new String[]{"a", "b", "c"}); DesignTableDataManager.addDsColumnNames("ds1", new String[]{"a", "b", "c"});
// 测试Get
Assert.assertEquals(columnNames, DesignTableDataManager.getDsColumnNames("ds1")); Assert.assertEquals(columnNames, DesignTableDataManager.getDsColumnNames("ds1"));
// 测试Remove
DesignTableDataManager.removeSelectedColumnNames("ds1");
Assert.assertTrue(ArrayUtils.isEmpty(DesignTableDataManager.getDsColumnNames("ds1")));
} }
} }

18
designer-base/src/test/java/com/fr/design/data/datapane/TableDataPaneListPaneTest.java

@ -1,6 +1,14 @@
package com.fr.design.data.datapane; package com.fr.design.data.datapane;
import com.fr.design.i18n.Toolkit;
import org.easymock.EasyMock;
import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import java.util.Map; import java.util.Map;
@ -11,8 +19,18 @@ import static org.junit.Assert.*;
* @version 10.0 * @version 10.0
* Created by Yyming on 2020/9/29 * Created by Yyming on 2020/9/29
*/ */
@RunWith(PowerMockRunner.class)
@PowerMockIgnore({"javax.management.*", "javax.swing.*"})
@PrepareForTest(Toolkit.class)
public class TableDataPaneListPaneTest { public class TableDataPaneListPaneTest {
@Before
public void setUp() {
PowerMock.mockStatic(Toolkit.class);
EasyMock.expect(Toolkit.i18nText(EasyMock.anyString())).andReturn("test").anyTimes();
PowerMock.replayAll();
}
@Test @Test
public void rename() { public void rename() {
TableDataPaneListPane listPane = new TableDataPaneListPane(); TableDataPaneListPane listPane = new TableDataPaneListPane();

4
designer-base/src/test/java/com/fr/design/data/tabledata/paste/TableDataFollowingPasteUtilsTest.java

@ -62,6 +62,7 @@ public class TableDataFollowingPasteUtilsTest extends TestCase {
PowerMock.mockStatic(DesignTableDataManager.class); PowerMock.mockStatic(DesignTableDataManager.class);
EasyMock.expect(DesignTableDataManager.getEditingTableDataSource()).andReturn(tableDataSource).anyTimes(); EasyMock.expect(DesignTableDataManager.getEditingTableDataSource()).andReturn(tableDataSource).anyTimes();
EasyMock.expect(DesignTableDataManager.getEditingDataSet(tableDataSource)).andReturn(list).anyTimes(); EasyMock.expect(DesignTableDataManager.getEditingDataSet(tableDataSource)).andReturn(list).anyTimes();
EasyMock.expect(DesignTableDataManager.getAllDataSetIncludingProcedure(templateDataMap)).andReturn(templateDataMap).anyTimes();
PowerMock.replayAll(); PowerMock.replayAll();
} }
@ -107,6 +108,7 @@ public class TableDataFollowingPasteUtilsTest extends TestCase {
set.add("ds3"); set.add("ds3");
MockWidget widget1 = EasyMock.mock(MockWidget.class); MockWidget widget1 = EasyMock.mock(MockWidget.class);
EasyMock.expect(widget1.getUsedTableDataSets()).andReturn(set).anyTimes(); EasyMock.expect(widget1.getUsedTableDataSets()).andReturn(set).anyTimes();
EasyMock.expect(widget1.getChartCollections()).andReturn(new ArrayList<>()).anyTimes();
EasyMock.replay(widget1); EasyMock.replay(widget1);
DataBinding dataBinding = new DataBinding("ds4", ""); DataBinding dataBinding = new DataBinding("ds4", "");
@ -114,6 +116,7 @@ public class TableDataFollowingPasteUtilsTest extends TestCase {
widgetValue2.setValue(dataBinding); widgetValue2.setValue(dataBinding);
AbstractDataControl widget2 = EasyMock.mock(AbstractDataControl.class); AbstractDataControl widget2 = EasyMock.mock(AbstractDataControl.class);
EasyMock.expect(widget2.getWidgetValue()).andReturn(widgetValue2).anyTimes(); EasyMock.expect(widget2.getWidgetValue()).andReturn(widgetValue2).anyTimes();
EasyMock.expect(widget2.getChartCollections()).andReturn(new ArrayList<>()).anyTimes();
EasyMock.replay(widget2); EasyMock.replay(widget2);
DataTableConfig dataTableConfig = EasyMock.mock(DataTableConfig.class); DataTableConfig dataTableConfig = EasyMock.mock(DataTableConfig.class);
@ -122,6 +125,7 @@ public class TableDataFollowingPasteUtilsTest extends TestCase {
widgetValue3.setValue(dataTableConfig); widgetValue3.setValue(dataTableConfig);
AbstractDataControl widget3 = EasyMock.mock(AbstractDataControl.class); AbstractDataControl widget3 = EasyMock.mock(AbstractDataControl.class);
EasyMock.expect(widget3.getWidgetValue()).andReturn(widgetValue3).anyTimes(); EasyMock.expect(widget3.getWidgetValue()).andReturn(widgetValue3).anyTimes();
EasyMock.expect(widget3.getChartCollections()).andReturn(new ArrayList<>()).anyTimes();
EasyMock.replay(dataTableConfig, widget3); EasyMock.replay(dataTableConfig, widget3);
Widget[] widgets = new Widget[3]; Widget[] widgets = new Widget[3];

4
designer-base/src/test/java/com/fr/design/formula/FormulaPaneTest.java

@ -16,8 +16,8 @@ public class FormulaPaneTest extends TestCase {
@Test @Test
public void testSimilarComparator() { public void testSimilarComparator() {
String[] strs = new String[] {"ScriptEval", "SPLIT", "SUMPRECISE"}; String[] strs = new String[]{"ScriptEval", "SPLIT", "SUMPRECISE"};
String[] result = new String[] {"SPLIT", "ScriptEval", "SUMPRECISE"}; String[] result = new String[]{"SPLIT", "SUMPRECISE", "ScriptEval"};
Arrays.sort(strs, new FormulaPane.SimilarComparator("sp")); Arrays.sort(strs, new FormulaPane.SimilarComparator("sp"));
Assert.assertArrayEquals(result, strs); Assert.assertArrayEquals(result, strs);
} }

12
designer-base/src/test/java/com/fr/design/formula/FunctionConstantsTest.java

@ -1,12 +1,16 @@
package com.fr.design.formula; package com.fr.design.formula;
import com.fr.design.i18n.Toolkit;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
import com.fr.invoke.Reflect; import com.fr.invoke.Reflect;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import org.easymock.EasyMock; import org.easymock.EasyMock;
import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.powermock.api.easymock.PowerMock; import org.powermock.api.easymock.PowerMock;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
@ -19,9 +23,15 @@ import static org.junit.Assert.fail;
* Created by plough on 2018/12/7. * Created by plough on 2018/12/7.
*/ */
@RunWith(PowerMockRunner.class) @RunWith(PowerMockRunner.class)
@PrepareForTest(GeneralUtils.class) @PrepareForTest({GeneralUtils.class, Toolkit.class})
public class FunctionConstantsTest { public class FunctionConstantsTest {
@Before
public void setUp() {
PowerMockito.mockStatic(Toolkit.class);
PowerMockito.when(Toolkit.i18nText(Mockito.anyString())).thenReturn("test");
}
@Test @Test
public void testNewInstanceFail() throws Exception { public void testNewInstanceFail() throws Exception {
try { try {

17
designer-base/src/test/java/com/fr/design/gui/icombocheckbox/UICheckListPopupTest.java

@ -1,8 +1,16 @@
package com.fr.design.gui.icombocheckbox; package com.fr.design.gui.icombocheckbox;
import com.fr.design.i18n.Toolkit;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -14,8 +22,17 @@ import java.util.TreeMap;
* @version 10.0 * @version 10.0
* Created by hades on 2020/4/3 * Created by hades on 2020/4/3
*/ */
@RunWith(PowerMockRunner.class)
@PrepareForTest(Toolkit.class)
@PowerMockIgnore("javax.swing.*")
public class UICheckListPopupTest extends TestCase { public class UICheckListPopupTest extends TestCase {
@Before
public void setUp() {
PowerMockito.mockStatic(Toolkit.class);
PowerMockito.when(Toolkit.i18nText(Mockito.anyString())).thenReturn("test");
}
@Test @Test
public void testGetSelectedValues() { public void testGetSelectedValues() {
Object[] values = new Object[]{"a", "b", "c"}; Object[] values = new Object[]{"a", "b", "c"};

72
designer-base/src/test/java/com/fr/design/jxbrowser/JxUIPaneTest.java

@ -0,0 +1,72 @@
package com.fr.design.jxbrowser;
import com.fr.design.DesignerEnvManager;
import com.teamdev.jxbrowser.js.JsAccessible;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.WindowConstants;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
public class JxUIPaneTest {
public static void main(String... args) {
final JFrame frame = new JFrame();
frame.setSize(1200, 800);
JPanel contentPane = (JPanel) frame.getContentPane();
// 是否需要开启调试窗口
DesignerEnvManager.getEnvManager().setOpenDebug(true);
final JxUIPane<Model> pane = new JxUIPane.Builder<Model>()
.withEMB("/com/fr/design/ui/demo.html").namespace("Pool").build();
contentPane.add(pane, BorderLayout.CENTER);
Model model = new Model();
model.setAge(20);
model.setName("Pick");
pane.populate(model);
JPanel panel = new JPanel(new FlowLayout());
contentPane.add(panel, BorderLayout.SOUTH);
JButton button = new JButton("点击我可以看到Swing的弹框,输出填写的信息");
panel.add(button);
button.addActionListener(e -> {
Model returnValue = pane.update();
if (returnValue != null) {
JOptionPane.showMessageDialog(frame, String.format("姓名为:%s,年龄为:%d", returnValue.getName(), returnValue.getAge()));
}
});
frame.setVisible(true);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
@JsAccessible
public static class Model {
private String name;
private int age;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public void print(String message) {
System.out.println(message);
}
}
}

21
designer-base/src/test/java/com/fr/design/jxbrowser/MimeTypeTest.java

@ -0,0 +1,21 @@
package com.fr.design.jxbrowser;
import org.junit.Assert;
import org.junit.Test;
/**
* @author vito
* @since 11.0
* Created on 2023/6/13
*/
public class MimeTypeTest {
@Test
public void getMimeType() {
Assert.assertEquals("text/html", MimeType.parseMimeType("http://a.html"));
Assert.assertEquals("text/html", MimeType.parseMimeType("http://a.html?a=ji"));
Assert.assertEquals("text/html", MimeType.parseMimeType("http://a.xml?a=ji"));
Assert.assertEquals("image/jpeg", MimeType.parseMimeType("http://a.jpg?a=ji"));
Assert.assertEquals("image/jpeg", MimeType.parseMimeType("http://a.jpeg?a=ji"));
}
}

128
designer-base/src/test/java/com/fr/design/mainfarme/toolbar/ToolBarMenuDockTest.java

@ -1,30 +1,35 @@
package com.fr.design.mainfarme.toolbar; package com.fr.design.mainfarme.toolbar;
import java.util.HashMap;
import java.util.Locale; import java.util.Locale;
import com.fr.base.svg.SystemScaleUtils;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.community.TechSupportAction;
import com.fr.design.actions.community.VideoAction; import com.fr.design.actions.community.VideoAction;
import com.fr.design.actions.help.AboutAction; import com.fr.design.actions.help.AboutAction;
import com.fr.design.actions.help.FineUIAction;
import com.fr.design.actions.help.TutorialAction; import com.fr.design.actions.help.TutorialAction;
import com.fr.design.actions.help.WebDemoAction; import com.fr.design.actions.help.WebDemoAction;
import com.fr.design.actions.help.alphafine.AlphaFineAction; import com.fr.design.actions.help.alphafine.AlphaFineAction;
import com.fr.design.actions.help.alphafine.AlphaFineConfigManager; import com.fr.design.actions.help.alphafine.AlphaFineConfigManager;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.platform.ServicePlatformAction;
import com.fr.design.mainframe.toolbar.ToolBarMenuDock; import com.fr.design.mainframe.toolbar.ToolBarMenuDock;
import com.fr.design.menu.SeparatorDef; import com.fr.design.menu.SeparatorDef;
import com.fr.design.menu.ShortCut; import com.fr.design.menu.ShortCut;
import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.os.impl.SupportOSImpl;
import com.fr.design.update.actions.SoftwareUpdateAction; import com.fr.design.update.actions.SoftwareUpdateAction;
import com.fr.env.detect.ui.EnvDetectorAction;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace; import com.fr.workspace.Workspace;
import org.easymock.EasyMock; import org.easymock.EasyMock;
import org.easymock.Mock;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock; import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.reflect.Whitebox; import org.powermock.reflect.Whitebox;
@ -42,66 +47,99 @@ import org.powermock.reflect.Whitebox;
Locale.class, Locale.class,
WorkContext.class, WorkContext.class,
DesignerEnvManager.class, DesignerEnvManager.class,
Toolkit.class,
SystemScaleUtils.class,
AlphaFineConfigManager.class}) AlphaFineConfigManager.class})
@PowerMockIgnore({"javax.management.*"})
public class ToolBarMenuDockTest { public class ToolBarMenuDockTest {
@Mock
VideoAction videoAction;
@Mock
TutorialAction tutorialAction;
@Mock
WebDemoAction webDemoAction;
@Mock
SoftwareUpdateAction softwareUpdateAction;
@Mock
AlphaFineAction alphaFineAction;
@Mock
FineUIAction fineUIAction;
@Mock
AboutAction aboutAction;
@Before @Before
public void testCreateHelpShortCutsBefore() { public void testCreateHelpShortCutsBefore() {
try { PowerMock.mockStatic(Toolkit.class);
PowerMock.expectNew(VideoAction.class).andReturn(videoAction).anyTimes(); EasyMock.expect(Toolkit.i18nText(EasyMock.anyString())).andReturn("test").anyTimes();
PowerMock.expectNew(TutorialAction.class).andReturn(tutorialAction).anyTimes(); PowerMock.mockStatic(SystemScaleUtils.class);
PowerMock.expectNew(WebDemoAction.class).andReturn(webDemoAction).anyTimes(); EasyMock.expect(SystemScaleUtils.sysScale()).andReturn(1F).anyTimes();
PowerMock.expectNew(SoftwareUpdateAction.class).andReturn(softwareUpdateAction).anyTimes(); EasyMock.expect(SystemScaleUtils.isJreHiDPIEnabled()).andReturn(false).anyTimes();
PowerMock.expectNew(AlphaFineAction.class).andReturn(alphaFineAction).anyTimes(); PowerMock.replay();
PowerMock.expectNew(FineUIAction.class).andReturn(fineUIAction).anyTimes();
PowerMock.expectNew(AboutAction.class).andReturn(aboutAction).anyTimes();
} catch (Exception e) {
Assert.fail(e.getMessage());
}
} }
@Test @Test
public void testCreateHelpShortCuts() { public void testCreateHelpShortCutsWithLocaleChina() {
// 处理判断条件 // 处理判断条件
GeneralContext context = EasyMock.createMock(GeneralContext.class); GeneralContext context = EasyMock.createMock(GeneralContext.class);
PowerMock.mockStatic(GeneralContext.class); PowerMock.mockStatic(GeneralContext.class);
EasyMock.expect(GeneralContext.getLocale()).andReturn(Locale.CHINA).once(); EasyMock.expect(GeneralContext.getLocale()).andReturn(Locale.CHINA).anyTimes();
EasyMock.expect(GeneralContext.getLocale()).andReturn(Locale.US).once();
Workspace workspace = EasyMock.createMock(Workspace.class); Workspace workspace = EasyMock.createMock(Workspace.class);
PowerMock.mockStatic(WorkContext.class); PowerMock.mockStatic(WorkContext.class);
EasyMock.expect(WorkContext.getCurrent()).andReturn(workspace).anyTimes(); EasyMock.expect(WorkContext.getCurrent()).andReturn(workspace).anyTimes();
EasyMock.expect(workspace.isLocal()).andReturn(true).anyTimes();
EasyMock.expect(workspace.isLocal()).andReturn(false).once();
EasyMock.expect(workspace.isLocal()).andReturn(true).once();
DesignerEnvManager envManager = EasyMock.createMock(DesignerEnvManager.class); DesignerEnvManager envManager = EasyMock.createMock(DesignerEnvManager.class);
PowerMock.mockStatic(DesignerEnvManager.class); PowerMock.mockStatic(DesignerEnvManager.class);
EasyMock.expect(DesignerEnvManager.getEnvManager()).andReturn(envManager).anyTimes(); EasyMock.expect(DesignerEnvManager.getEnvManager()).andReturn(envManager).anyTimes();
EasyMock.expect(envManager.isOpenDebug()).andReturn(true).anyTimes();
AlphaFineConfigManager configManager = EasyMock.createMock(AlphaFineConfigManager.class);
PowerMock.mockStatic(AlphaFineConfigManager.class);
EasyMock.expect(AlphaFineConfigManager.getInstance()).andReturn(configManager).anyTimes();
EasyMock.expect(configManager.isALPHALicAvailable()).andReturn(true).anyTimes();
EasyMock.expect(configManager.getActionSearchTextCache()).andReturn(new HashMap<>()).anyTimes();
EasyMock.expect(configManager.getCacheBuildNO()).andReturn("").anyTimes();
SupportOSImpl osImpl = EasyMock.createMock(SupportOSImpl.class);
Whitebox.setInternalState(SupportOSImpl.class, "FINEUI", osImpl);
EasyMock.expect(osImpl.support()).andReturn(false).anyTimes();
EasyMock.expect(envManager.isOpenDebug()).andReturn(false).once(); EasyMock.replay(context, workspace, envManager, configManager, osImpl);
EasyMock.expect(envManager.isOpenDebug()).andReturn(true).once(); PowerMock.replayAll();
ToolBarMenuDock menuDock = new ToolBarMenuDock() {
@Override
public ShortCut[] createNewFileShortCuts() {
return new ShortCut[0];
}
};
ShortCut[] shortCuts = new ShortCut[] {
new WebDemoAction(),
new SoftwareUpdateAction(),
new AlphaFineAction(),
new EnvDetectorAction(),
new ServicePlatformAction(),
SeparatorDef.DEFAULT,
new AboutAction()};
Assert.assertEquals(menuDock.createHelpShortCuts(), shortCuts);
}
@Test
public void testCreateHelpShortCutsWithLocaleUS() {
// 处理判断条件
GeneralContext context = EasyMock.createMock(GeneralContext.class);
PowerMock.mockStatic(GeneralContext.class);
EasyMock.expect(GeneralContext.getLocale()).andReturn(Locale.US).anyTimes();
Workspace workspace = EasyMock.createMock(Workspace.class);
PowerMock.mockStatic(WorkContext.class);
EasyMock.expect(WorkContext.getCurrent()).andReturn(workspace).anyTimes();
EasyMock.expect(workspace.isLocal()).andReturn(false).anyTimes();
DesignerEnvManager envManager = EasyMock.createMock(DesignerEnvManager.class);
PowerMock.mockStatic(DesignerEnvManager.class);
EasyMock.expect(DesignerEnvManager.getEnvManager()).andReturn(envManager).anyTimes();
EasyMock.expect(envManager.isOpenDebug()).andReturn(false).anyTimes();
AlphaFineConfigManager configManager = EasyMock.createMock(AlphaFineConfigManager.class); AlphaFineConfigManager configManager = EasyMock.createMock(AlphaFineConfigManager.class);
PowerMock.mockStatic(AlphaFineConfigManager.class); PowerMock.mockStatic(AlphaFineConfigManager.class);
EasyMock.expect(AlphaFineConfigManager.isALPHALicAvailable()).andReturn(false).once(); EasyMock.expect(configManager.isALPHALicAvailable()).andReturn(false).anyTimes();
EasyMock.expect(AlphaFineConfigManager.isALPHALicAvailable()).andReturn(true).once(); EasyMock.expect(configManager.getActionSearchTextCache()).andReturn(new HashMap<>()).anyTimes();
EasyMock.expect(configManager.getCacheBuildNO()).andReturn("").anyTimes();
EasyMock.expect(AlphaFineConfigManager.getInstance()).andReturn(configManager).anyTimes();
SupportOSImpl osImpl = EasyMock.createMock(SupportOSImpl.class); SupportOSImpl osImpl = EasyMock.createMock(SupportOSImpl.class);
Whitebox.setInternalState(SupportOSImpl.class, "FINEUI", osImpl); Whitebox.setInternalState(SupportOSImpl.class, "FINEUI", osImpl);
@ -118,12 +156,14 @@ public class ToolBarMenuDockTest {
} }
}; };
ShortCut[] shortCuts1 = new ShortCut[] {SeparatorDef.DEFAULT, aboutAction}; ShortCut[] shortCuts = new ShortCut[] {
ShortCut[] shortCuts2 = new ShortCut[] {videoAction, tutorialAction, webDemoAction, new VideoAction(),
softwareUpdateAction, alphaFineAction, SeparatorDef.DEFAULT, aboutAction}; new TutorialAction(),
new TechSupportAction(),
Assert.assertEquals(menuDock.createHelpShortCuts(), shortCuts1); new EnvDetectorAction(),
Assert.assertEquals(menuDock.createHelpShortCuts(), shortCuts2); SeparatorDef.DEFAULT,
new AboutAction()};
Assert.assertEquals(menuDock.createHelpShortCuts(), shortCuts);
} }
} }

3
designer-base/src/test/java/com/fr/design/ui/FineUIDemo.java

@ -1,6 +1,7 @@
package com.fr.design.ui; package com.fr.design.ui;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.jxbrowser.JxUIPane;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
@ -19,7 +20,7 @@ public class FineUIDemo {
// 是否需要开启调试窗口 // 是否需要开启调试窗口
DesignerEnvManager.getEnvManager().setOpenDebug(true); DesignerEnvManager.getEnvManager().setOpenDebug(true);
final ModernUIPane<ModernUIPaneTest.Model> pane = new ModernUIPane.Builder<ModernUIPaneTest.Model>() final JxUIPane<ModernUIPaneTest.Model> pane = new JxUIPane.Builder<ModernUIPaneTest.Model>()
.withComponent(StartComponent.KEY).build(); .withComponent(StartComponent.KEY).build();
contentPane.add(pane, BorderLayout.CENTER); contentPane.add(pane, BorderLayout.CENTER);
frame.setVisible(true); frame.setVisible(true);

10
designer-base/src/test/java/com/fr/design/ui/report/TemplateWebSettingDemo.java

@ -1,11 +1,13 @@
package com.fr.design.ui.report; package com.fr.design.ui.report;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.ui.ModernUIPane; import com.fr.design.jxbrowser.JxUIPane;
import com.fr.design.ui.ModernUIPaneTest; import com.fr.design.ui.ModernUIPaneTest;
import javax.swing.*; import javax.swing.JFrame;
import java.awt.*; import javax.swing.JPanel;
import javax.swing.WindowConstants;
import java.awt.BorderLayout;
/** /**
* Created by windy on 2019/3/26. * Created by windy on 2019/3/26.
@ -19,7 +21,7 @@ public class TemplateWebSettingDemo {
// 是否需要开启调试窗口 // 是否需要开启调试窗口
DesignerEnvManager.getEnvManager().setOpenDebug(true); DesignerEnvManager.getEnvManager().setOpenDebug(true);
final ModernUIPane<ModernUIPaneTest.Model> pane = new ModernUIPane.Builder<ModernUIPaneTest.Model>() final JxUIPane<ModernUIPaneTest.Model> pane = new JxUIPane.Builder<ModernUIPaneTest.Model>()
.withComponent(TemplateWebSettingComponent.KEY).build(); .withComponent(TemplateWebSettingComponent.KEY).build();
contentPane.add(pane, BorderLayout.CENTER); contentPane.add(pane, BorderLayout.CENTER);
frame.setVisible(true); frame.setVisible(true);

4
designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxRichTextDetailedFieldListPane.java

@ -1,7 +1,7 @@
package com.fr.van.chart.box; package com.fr.van.chart.box;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.ui.ModernUIPane; import com.fr.design.jxbrowser.JxUIPane;
import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.AttrTooltipContent;
import com.fr.plugin.chart.base.format.AttrTooltipCategoryFormat; import com.fr.plugin.chart.base.format.AttrTooltipCategoryFormat;
import com.fr.plugin.chart.base.format.AttrTooltipDataMaxFormat; import com.fr.plugin.chart.base.format.AttrTooltipDataMaxFormat;
@ -33,7 +33,7 @@ public class VanChartBoxRichTextDetailedFieldListPane extends VanChartFieldListP
private VanChartFieldButton richTextMin; private VanChartFieldButton richTextMin;
private VanChartFieldButton richTextOutlier; private VanChartFieldButton richTextOutlier;
public VanChartBoxRichTextDetailedFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditorPane) { public VanChartBoxRichTextDetailedFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane<VanChartRichEditorModel> richEditorPane) {
super(fieldAttrPane, richEditorPane); super(fieldAttrPane, richEditorPane);
} }

4
designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxRichTextResultFieldListPane.java

@ -1,6 +1,6 @@
package com.fr.van.chart.box; package com.fr.van.chart.box;
import com.fr.design.ui.ModernUIPane; import com.fr.design.jxbrowser.JxUIPane;
import com.fr.van.chart.designer.component.richText.VanChartFieldAttrPane; import com.fr.van.chart.designer.component.richText.VanChartFieldAttrPane;
import com.fr.van.chart.designer.component.richText.VanChartFieldButton; import com.fr.van.chart.designer.component.richText.VanChartFieldButton;
import com.fr.van.chart.designer.component.richText.VanChartRichEditorModel; import com.fr.van.chart.designer.component.richText.VanChartRichEditorModel;
@ -11,7 +11,7 @@ import java.util.List;
public class VanChartBoxRichTextResultFieldListPane extends VanChartBoxRichTextDetailedFieldListPane { public class VanChartBoxRichTextResultFieldListPane extends VanChartBoxRichTextDetailedFieldListPane {
public VanChartBoxRichTextResultFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditorPane) { public VanChartBoxRichTextResultFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane<VanChartRichEditorModel> richEditorPane) {
super(fieldAttrPane, richEditorPane); super(fieldAttrPane, richEditorPane);
} }

6
designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxTooltipContentPane.java

@ -2,9 +2,9 @@ package com.fr.van.chart.box;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.jxbrowser.JxUIPane;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.ui.ModernUIPane;
import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.AttrTooltipContent;
import com.fr.plugin.chart.base.format.AttrTooltipCategoryFormat; import com.fr.plugin.chart.base.format.AttrTooltipCategoryFormat;
import com.fr.plugin.chart.base.format.AttrTooltipDataMaxFormat; import com.fr.plugin.chart.base.format.AttrTooltipDataMaxFormat;
@ -103,11 +103,11 @@ public class VanChartBoxTooltipContentPane extends VanChartTooltipContentPane {
return commonPanel; return commonPanel;
} }
protected VanChartRichTextPane createRichTextPane(ModernUIPane<VanChartRichEditorModel> richEditorPane) { protected VanChartRichTextPane createRichTextPane(JxUIPane<VanChartRichEditorModel> richEditorPane) {
return new VanChartRichTextPane(richEditorPane) { return new VanChartRichTextPane(richEditorPane) {
protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditor) { protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane<VanChartRichEditorModel> richEditor) {
if (detailed) { if (detailed) {
return new VanChartBoxRichTextDetailedFieldListPane(fieldAttrPane, richEditor); return new VanChartBoxRichTextDetailedFieldListPane(fieldAttrPane, richEditor);
} }

6
designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java

@ -7,11 +7,11 @@ import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.jxbrowser.JxUIPane;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane;
import com.fr.design.ui.ModernUIPane;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.AttrTooltipContent;
import com.fr.plugin.chart.base.AttrTooltipRichText; import com.fr.plugin.chart.base.AttrTooltipRichText;
@ -390,7 +390,7 @@ public class VanChartTooltipContentPane extends BasicBeanPane<AttrTooltipContent
private void fireRichEditor() { private void fireRichEditor() {
AttrTooltipRichText richText = this.richTextTooltipContent.getRichTextAttr(); AttrTooltipRichText richText = this.richTextTooltipContent.getRichTextAttr();
refreshTableFieldParams(richText.getParams()); refreshTableFieldParams(richText.getParams());
ModernUIPane<VanChartRichEditorModel> richEditorPane = VanChartRichEditorPane.createRichEditorPane(richText); JxUIPane<VanChartRichEditorModel> richEditorPane = VanChartRichEditorPane.createRichEditorPane(richText);
VanChartRichTextPane richTextPane = this.createRichTextPane(richEditorPane); VanChartRichTextPane richTextPane = this.createRichTextPane(richEditorPane);
BasicDialog richTextDialog = new VanChartRichTextDialog(DesignerContext.getDesignerFrame(), richTextPane); BasicDialog richTextDialog = new VanChartRichTextDialog(DesignerContext.getDesignerFrame(), richTextPane);
@ -431,7 +431,7 @@ public class VanChartTooltipContentPane extends BasicBeanPane<AttrTooltipContent
} }
} }
protected VanChartRichTextPane createRichTextPane(ModernUIPane<VanChartRichEditorModel> richEditorPane) { protected VanChartRichTextPane createRichTextPane(JxUIPane<VanChartRichEditorModel> richEditorPane) {
return new VanChartRichTextPane(richEditorPane); return new VanChartRichTextPane(richEditorPane);
} }

6
designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldListPane.java

@ -4,7 +4,7 @@ import com.fr.data.util.function.AbstractDataFunction;
import com.fr.data.util.function.DataFunction; import com.fr.data.util.function.DataFunction;
import com.fr.design.event.UIObserverListener; import com.fr.design.event.UIObserverListener;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.ui.ModernUIPane; import com.fr.design.jxbrowser.JxUIPane;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.AttrTooltipContent;
@ -43,14 +43,14 @@ public class VanChartFieldListPane extends JPanel {
private VanChartFieldButton percentButton; private VanChartFieldButton percentButton;
private VanChartFieldAttrPane fieldAttrPane; private VanChartFieldAttrPane fieldAttrPane;
private ModernUIPane<VanChartRichEditorModel> richEditorPane; private JxUIPane<VanChartRichEditorModel> richEditorPane;
private List<String> tableFieldNameList; private List<String> tableFieldNameList;
private List<VanChartFieldButton> tableFieldButtonList = new ArrayList<>(); private List<VanChartFieldButton> tableFieldButtonList = new ArrayList<>();
private TableFieldCollection tableFieldCollection = new TableFieldCollection(); private TableFieldCollection tableFieldCollection = new TableFieldCollection();
private VanChartFieldListener fieldListener; private VanChartFieldListener fieldListener;
public VanChartFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditorPane) { public VanChartFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane<VanChartRichEditorModel> richEditorPane) {
List<String> richEditorFieldNames = VanChartRichEditorPane.getFieldNames(); List<String> richEditorFieldNames = VanChartRichEditorPane.getFieldNames();

2
designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichEditorModel.java

@ -2,7 +2,9 @@ package com.fr.van.chart.designer.component.richText;
import com.fr.plugin.chart.type.TextAlign; import com.fr.plugin.chart.type.TextAlign;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.teamdev.jxbrowser.js.JsAccessible;
@JsAccessible
public class VanChartRichEditorModel { public class VanChartRichEditorModel {
private String content = StringUtils.EMPTY; private String content = StringUtils.EMPTY;

103
designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichEditorPane.java

@ -11,7 +11,7 @@ import com.fr.data.impl.NameTableData;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.ui.ModernUIPane; import com.fr.design.jxbrowser.JxUIPane;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.plugin.chart.base.AttrTooltipRichText; import com.fr.plugin.chart.base.AttrTooltipRichText;
@ -21,11 +21,9 @@ import com.fr.plugin.chart.type.TextAlign;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.third.org.apache.commons.lang3.SystemUtils; import com.fr.third.org.apache.commons.lang3.SystemUtils;
import com.fr.van.chart.designer.PlotFactory; import com.fr.van.chart.designer.PlotFactory;
import com.teamdev.jxbrowser.chromium.Browser; import com.teamdev.jxbrowser.browser.callback.InjectJsCallback;
import com.teamdev.jxbrowser.chromium.BrowserType; import com.teamdev.jxbrowser.frame.Frame;
import com.teamdev.jxbrowser.chromium.JSValue; import com.teamdev.jxbrowser.js.JsObject;
import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter;
import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -45,8 +43,8 @@ public class VanChartRichEditorPane {
private static final String REFRESH = "refresh()"; private static final String REFRESH = "refresh()";
private static final String ADD_FIELD = "addField()"; private static final String ADD_FIELD = "addField()";
private static ModernUIPane<VanChartRichEditorModel> richEditorPane; private static JxUIPane<VanChartRichEditorModel> richEditorPane;
private static Browser browser; private static Frame frame;
private static List<String> fieldNames; private static List<String> fieldNames;
private static final boolean USE_LIGHT_WEIGHT = SystemUtils.IS_OS_WINDOWS_10; private static final boolean USE_LIGHT_WEIGHT = SystemUtils.IS_OS_WINDOWS_10;
@ -123,12 +121,24 @@ public class VanChartRichEditorPane {
fieldNames.addAll(Arrays.asList(columnNames)); fieldNames.addAll(Arrays.asList(columnNames));
} }
public static ModernUIPane<VanChartRichEditorModel> createRichEditorPane(AttrTooltipRichText richEditor) { /**
* 创建富文本编辑器
*
* @param richEditor 属性
* @return 富文本编辑器
*/
public static JxUIPane<VanChartRichEditorModel> createRichEditorPane(AttrTooltipRichText richEditor) {
VanChartRichEditorModel model = getRichEditorModel(richEditor); VanChartRichEditorModel model = getRichEditorModel(richEditor);
return createRichEditorPane(model); return createRichEditorPane(model);
} }
public static ModernUIPane<VanChartRichEditorModel> createRichEditorPane(VanChartRichEditorModel model) { /**
* 创建富文本编辑器
*
* @param model 模型
* @return 富文本编辑器
*/
public static JxUIPane<VanChartRichEditorModel> createRichEditorPane(VanChartRichEditorModel model) {
if (richEditorPane == null) { if (richEditorPane == null) {
richEditorPane = initPane(model); richEditorPane = initPane(model);
} else { } else {
@ -139,50 +149,57 @@ public class VanChartRichEditorPane {
} }
public static void richEditorRefresh(VanChartRichEditorModel model) { public static void richEditorRefresh(VanChartRichEditorModel model) {
if (richEditorPane != null && browser != null) { if (richEditorPane != null && frame != null) {
refresh(browser, model); refresh(frame, model);
} }
} }
public static void richEditorAddField(VanChartRichEditorModel model) { public static void richEditorAddField(VanChartRichEditorModel model) {
if (richEditorPane != null && browser != null) { if (richEditorPane != null && frame != null) {
addField(browser, model); addField(frame, model);
} }
} }
public static ModernUIPane<VanChartRichEditorModel> initPane(VanChartRichEditorModel model) { /**
BrowserType type = USE_LIGHT_WEIGHT ? BrowserType.LIGHTWEIGHT : BrowserType.HEAVYWEIGHT; * 初始化富文本编辑器
return new ModernUIPane.Builder<VanChartRichEditorModel>(type) *
.prepare(new ScriptContextAdapter() { * @param model 模型
public void onScriptContextCreated(ScriptContextEvent event) { * @return pane
browser = event.getBrowser(); */
browser.getCacheStorage().clearCache(); public static JxUIPane<VanChartRichEditorModel> initPane(VanChartRichEditorModel model) {
return new JxUIPane.Builder<VanChartRichEditorModel>()
browser.executeJavaScript(IOUtils.readResourceAsString("/com/fr/web/ui/fineui.min.js")); .prepare(params -> {
browser.executeJavaScript(IOUtils.readResourceAsString("/com/fr/design/editor/script/i18n.js")); frame = params.frame();
browser.executeJavaScript(generateTransformI18nJS()); frame.browser().engine().httpCache().clear();
browser.executeJavaScript(IOUtils.readResourceAsString("/com/fr/web/ui/materials.min.js")); frame.executeJavaScript(IOUtils.readResourceAsString("/com/fr/web/ui/fineui.min.js"));
frame.executeJavaScript(IOUtils.readResourceAsString("/com/fr/design/editor/script/i18n.js"));
JSValue ns = browser.executeJavaScriptAndReturnValue("window." + NAME_SPACE); frame.executeJavaScript(generateTransformI18nJS());
ns.asObject().setProperty(VARIABLE, model); frame.executeJavaScript(IOUtils.readResourceAsString("/com/fr/web/ui/materials.min.js"));
}
JsObject ns = frame.executeJavaScript("window." + NAME_SPACE);
if (ns != null) {
ns.putProperty(VARIABLE, model);
}
return InjectJsCallback.Response.proceed();
}) })
.withEMB(RICH_EDITOR_HTML) .withEMB(RICH_EDITOR_HTML)
.namespace(NAME_SPACE).build(); .namespace(NAME_SPACE).build();
} }
public static void refresh(Browser browser, VanChartRichEditorModel model) { private static void refresh(Frame frame, VanChartRichEditorModel model) {
stateChange(browser, model, REFRESH); stateChange(frame, model, REFRESH);
} }
public static void addField(Browser browser, VanChartRichEditorModel model) { private static void addField(Frame frame, VanChartRichEditorModel model) {
stateChange(browser, model, ADD_FIELD); stateChange(frame, model, ADD_FIELD);
} }
public static void stateChange(Browser browser, VanChartRichEditorModel model, String trigger) { private static void stateChange(Frame frame, VanChartRichEditorModel model, String trigger) {
JSValue ns = browser.executeJavaScriptAndReturnValue("window." + NAME_SPACE); JsObject ns = frame.executeJavaScript("window." + NAME_SPACE);
ns.asObject().setProperty(VARIABLE, model); if (ns != null) {
browser.executeJavaScript("window." + NAME_SPACE + "." + trigger); ns.putProperty(VARIABLE, model);
frame.executeJavaScript("window." + NAME_SPACE + "." + trigger);
}
} }
public static VanChartRichEditorModel getRichEditorModel(AttrTooltipRichText richText) { public static VanChartRichEditorModel getRichEditorModel(AttrTooltipRichText richText) {
@ -231,9 +248,7 @@ public class VanChartRichEditorPane {
} }
public static void checkDispose() { public static void checkDispose() {
if (USE_LIGHT_WEIGHT) { frame.browser().close();
browser.dispose();
richEditorPane = null; richEditorPane = null;
} }
}
} }

6
designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichTextPane.java

@ -2,8 +2,8 @@ package com.fr.van.chart.designer.component.richText;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.jxbrowser.JxUIPane;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.ui.ModernUIPane;
import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.AttrTooltipContent;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -25,7 +25,7 @@ public class VanChartRichTextPane extends BasicBeanPane<AttrTooltipContent> {
private VanChartFieldListPane fieldListPane; private VanChartFieldListPane fieldListPane;
private VanChartFieldAttrPane fieldAttrPane; private VanChartFieldAttrPane fieldAttrPane;
public VanChartRichTextPane(ModernUIPane<VanChartRichEditorModel> richEditor) { public VanChartRichTextPane(JxUIPane<VanChartRichEditorModel> richEditor) {
fieldAttrPane = new VanChartFieldAttrPane(); fieldAttrPane = new VanChartFieldAttrPane();
fieldListPane = createFieldListPane(fieldAttrPane, richEditor); fieldListPane = createFieldListPane(fieldAttrPane, richEditor);
@ -63,7 +63,7 @@ public class VanChartRichTextPane extends BasicBeanPane<AttrTooltipContent> {
return fieldPane; return fieldPane;
} }
protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditor) { protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane<VanChartRichEditorModel> richEditor) {
return new VanChartFieldListPane(fieldAttrPane, richEditor); return new VanChartFieldListPane(fieldAttrPane, richEditor);
} }

6
designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/TooltipContentPaneWithOutSeries.java

@ -1,7 +1,7 @@
package com.fr.van.chart.designer.component.tooltip; package com.fr.van.chart.designer.component.tooltip;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.ui.ModernUIPane; import com.fr.design.jxbrowser.JxUIPane;
import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.AttrTooltipContent;
import com.fr.plugin.chart.base.format.AttrTooltipCategoryFormat; import com.fr.plugin.chart.base.format.AttrTooltipCategoryFormat;
import com.fr.plugin.chart.base.format.AttrTooltipFormat; import com.fr.plugin.chart.base.format.AttrTooltipFormat;
@ -63,11 +63,11 @@ public class TooltipContentPaneWithOutSeries extends VanChartTooltipContentPane
}; };
} }
protected VanChartRichTextPane createRichTextPane(ModernUIPane<VanChartRichEditorModel> richEditorPane) { protected VanChartRichTextPane createRichTextPane(JxUIPane<VanChartRichEditorModel> richEditorPane) {
return new VanChartRichTextPane(richEditorPane) { return new VanChartRichTextPane(richEditorPane) {
protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditor) { protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane<VanChartRichEditorModel> richEditor) {
return new VanChartFieldListPaneWithOutSeries(fieldAttrPane, richEditor); return new VanChartFieldListPaneWithOutSeries(fieldAttrPane, richEditor);
} }

4
designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/VanChartFieldListPaneWithOutSeries.java

@ -1,7 +1,7 @@
package com.fr.van.chart.designer.component.tooltip; package com.fr.van.chart.designer.component.tooltip;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.ui.ModernUIPane; import com.fr.design.jxbrowser.JxUIPane;
import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.AttrTooltipContent;
import com.fr.plugin.chart.base.format.AttrTooltipTargetValueFormat; import com.fr.plugin.chart.base.format.AttrTooltipTargetValueFormat;
import com.fr.plugin.chart.base.format.AttrTooltipValueFormat; import com.fr.plugin.chart.base.format.AttrTooltipValueFormat;
@ -20,7 +20,7 @@ public class VanChartFieldListPaneWithOutSeries extends VanChartFieldListPane {
private VanChartFieldButton targetValueButton; private VanChartFieldButton targetValueButton;
public VanChartFieldListPaneWithOutSeries(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditorPane) { public VanChartFieldListPaneWithOutSeries(VanChartFieldAttrPane fieldAttrPane, JxUIPane<VanChartRichEditorModel> richEditorPane) {
super(fieldAttrPane, richEditorPane); super(fieldAttrPane, richEditorPane);
} }

6
designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelLabelContentPane.java

@ -1,7 +1,7 @@
package com.fr.van.chart.funnel.designer.style; package com.fr.van.chart.funnel.designer.style;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.ui.ModernUIPane; import com.fr.design.jxbrowser.JxUIPane;
import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.AttrTooltipContent;
import com.fr.plugin.chart.base.format.AttrTooltipFormat; import com.fr.plugin.chart.base.format.AttrTooltipFormat;
import com.fr.plugin.chart.base.format.AttrTooltipNameFormat; import com.fr.plugin.chart.base.format.AttrTooltipNameFormat;
@ -49,11 +49,11 @@ public class VanChartFunnelLabelContentPane extends VanChartLabelContentPane {
setPercentFormatPane(new FunnelPercentFormatPaneWithCheckBox(parent, showOnPane)); setPercentFormatPane(new FunnelPercentFormatPaneWithCheckBox(parent, showOnPane));
} }
protected VanChartRichTextPane createRichTextPane(ModernUIPane<VanChartRichEditorModel> richEditorPane) { protected VanChartRichTextPane createRichTextPane(JxUIPane<VanChartRichEditorModel> richEditorPane) {
return new VanChartRichTextPane(richEditorPane) { return new VanChartRichTextPane(richEditorPane) {
protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditor) { protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane<VanChartRichEditorModel> richEditor) {
return new VanChartFunnelRichTextFieldListPane(fieldAttrPane, richEditor); return new VanChartFunnelRichTextFieldListPane(fieldAttrPane, richEditor);
} }

4
designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelRichTextFieldListPane.java

@ -1,7 +1,7 @@
package com.fr.van.chart.funnel.designer.style; package com.fr.van.chart.funnel.designer.style;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.ui.ModernUIPane; import com.fr.design.jxbrowser.JxUIPane;
import com.fr.plugin.chart.base.format.AttrTooltipCategoryFormat; import com.fr.plugin.chart.base.format.AttrTooltipCategoryFormat;
import com.fr.plugin.chart.base.format.AttrTooltipNameFormat; import com.fr.plugin.chart.base.format.AttrTooltipNameFormat;
import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat; import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat;
@ -18,7 +18,7 @@ import java.util.List;
public class VanChartFunnelRichTextFieldListPane extends VanChartFieldListPane { public class VanChartFunnelRichTextFieldListPane extends VanChartFieldListPane {
public VanChartFunnelRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditorPane) { public VanChartFunnelRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane<VanChartRichEditorModel> richEditorPane) {
super(fieldAttrPane, richEditorPane); super(fieldAttrPane, richEditorPane);
} }

6
designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelTooltipContentPane.java

@ -1,7 +1,7 @@
package com.fr.van.chart.funnel.designer.style; package com.fr.van.chart.funnel.designer.style;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.ui.ModernUIPane; import com.fr.design.jxbrowser.JxUIPane;
import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.AttrTooltipContent;
import com.fr.plugin.chart.base.format.AttrTooltipFormat; import com.fr.plugin.chart.base.format.AttrTooltipFormat;
import com.fr.plugin.chart.base.format.AttrTooltipNameFormat; import com.fr.plugin.chart.base.format.AttrTooltipNameFormat;
@ -48,11 +48,11 @@ public class VanChartFunnelTooltipContentPane extends VanChartTooltipContentPane
setPercentFormatPane(new FunnelPercentFormatPaneWithCheckBox(parent, showOnPane)); setPercentFormatPane(new FunnelPercentFormatPaneWithCheckBox(parent, showOnPane));
} }
protected VanChartRichTextPane createRichTextPane(ModernUIPane<VanChartRichEditorModel> richEditorPane) { protected VanChartRichTextPane createRichTextPane(JxUIPane<VanChartRichEditorModel> richEditorPane) {
return new VanChartRichTextPane(richEditorPane) { return new VanChartRichTextPane(richEditorPane) {
protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditor) { protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane<VanChartRichEditorModel> richEditor) {
return new VanChartFunnelRichTextFieldListPane(fieldAttrPane, richEditor); return new VanChartFunnelRichTextFieldListPane(fieldAttrPane, richEditor);
} }

4
designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/tooltip/VanChartGanttRichTextFieldListPane.java

@ -1,7 +1,7 @@
package com.fr.van.chart.gantt.designer.style.tooltip; package com.fr.van.chart.gantt.designer.style.tooltip;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.ui.ModernUIPane; import com.fr.design.jxbrowser.JxUIPane;
import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.AttrTooltipContent;
import com.fr.plugin.chart.base.format.AttrTooltipDurationFormat; import com.fr.plugin.chart.base.format.AttrTooltipDurationFormat;
import com.fr.plugin.chart.base.format.AttrTooltipEndTimeFormat; import com.fr.plugin.chart.base.format.AttrTooltipEndTimeFormat;
@ -28,7 +28,7 @@ public class VanChartGanttRichTextFieldListPane extends VanChartFieldListPane {
private VanChartFieldButton richTextDurationFormatPane; private VanChartFieldButton richTextDurationFormatPane;
private VanChartFieldButton richTextProgressFormatPane; private VanChartFieldButton richTextProgressFormatPane;
public VanChartGanttRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditorPane) { public VanChartGanttRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane<VanChartRichEditorModel> richEditorPane) {
super(fieldAttrPane, richEditorPane); super(fieldAttrPane, richEditorPane);
} }

6
designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/tooltip/VanChartGanttTooltipContentPane.java

@ -1,7 +1,7 @@
package com.fr.van.chart.gantt.designer.style.tooltip; package com.fr.van.chart.gantt.designer.style.tooltip;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.ui.ModernUIPane; import com.fr.design.jxbrowser.JxUIPane;
import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.AttrTooltipContent;
import com.fr.plugin.chart.base.format.AttrTooltipDurationFormat; import com.fr.plugin.chart.base.format.AttrTooltipDurationFormat;
import com.fr.plugin.chart.base.format.AttrTooltipEndTimeFormat; import com.fr.plugin.chart.base.format.AttrTooltipEndTimeFormat;
@ -66,11 +66,11 @@ public class VanChartGanttTooltipContentPane extends VanChartTooltipContentPane
}; };
} }
protected VanChartRichTextPane createRichTextPane(ModernUIPane<VanChartRichEditorModel> richEditorPane) { protected VanChartRichTextPane createRichTextPane(JxUIPane<VanChartRichEditorModel> richEditorPane) {
return new VanChartRichTextPane(richEditorPane) { return new VanChartRichTextPane(richEditorPane) {
protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditor) { protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane<VanChartRichEditorModel> richEditor) {
return new VanChartGanttRichTextFieldListPane(fieldAttrPane, richEditor); return new VanChartGanttRichTextFieldListPane(fieldAttrPane, richEditor);
} }

4
designer-chart/src/main/java/com/fr/van/chart/map/designer/style/VanChartMapRichTextFieldListPane.java

@ -1,7 +1,7 @@
package com.fr.van.chart.map.designer.style; package com.fr.van.chart.map.designer.style;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.ui.ModernUIPane; import com.fr.design.jxbrowser.JxUIPane;
import com.fr.plugin.chart.base.format.AttrTooltipAreaNameFormat; import com.fr.plugin.chart.base.format.AttrTooltipAreaNameFormat;
import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat; import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat;
import com.fr.plugin.chart.base.format.AttrTooltipSeriesFormat; import com.fr.plugin.chart.base.format.AttrTooltipSeriesFormat;
@ -14,7 +14,7 @@ import com.fr.van.chart.designer.component.richText.VanChartRichEditorModel;
public class VanChartMapRichTextFieldListPane extends VanChartFieldListPane { public class VanChartMapRichTextFieldListPane extends VanChartFieldListPane {
public VanChartMapRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditorPane) { public VanChartMapRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane<VanChartRichEditorModel> richEditorPane) {
super(fieldAttrPane, richEditorPane); super(fieldAttrPane, richEditorPane);
} }

6
designer-chart/src/main/java/com/fr/van/chart/map/designer/style/label/VanChartMapLabelContentPane.java

@ -3,8 +3,8 @@ package com.fr.van.chart.map.designer.style.label;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.jxbrowser.JxUIPane;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.ui.ModernUIPane;
import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.AttrTooltipContent;
import com.fr.plugin.chart.base.format.AttrTooltipAreaNameFormat; import com.fr.plugin.chart.base.format.AttrTooltipAreaNameFormat;
import com.fr.plugin.chart.base.format.AttrTooltipFormat; import com.fr.plugin.chart.base.format.AttrTooltipFormat;
@ -50,11 +50,11 @@ public class VanChartMapLabelContentPane extends VanChartLabelContentPane {
setPercentFormatPane(new PercentFormatPaneWithCheckBox(parent, showOnPane)); setPercentFormatPane(new PercentFormatPaneWithCheckBox(parent, showOnPane));
} }
protected VanChartRichTextPane createRichTextPane(ModernUIPane<VanChartRichEditorModel> richEditorPane) { protected VanChartRichTextPane createRichTextPane(JxUIPane<VanChartRichEditorModel> richEditorPane) {
return new VanChartRichTextPane(richEditorPane) { return new VanChartRichTextPane(richEditorPane) {
protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditor) { protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane<VanChartRichEditorModel> richEditor) {
return new VanChartMapRichTextFieldListPane(fieldAttrPane, richEditor); return new VanChartMapRichTextFieldListPane(fieldAttrPane, richEditor);
} }

6
designer-chart/src/main/java/com/fr/van/chart/map/designer/style/tooltip/VanChartMapTooltipContentPane.java

@ -1,7 +1,7 @@
package com.fr.van.chart.map.designer.style.tooltip; package com.fr.van.chart.map.designer.style.tooltip;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.ui.ModernUIPane; import com.fr.design.jxbrowser.JxUIPane;
import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.AttrTooltipContent;
import com.fr.plugin.chart.base.format.AttrTooltipAreaNameFormat; import com.fr.plugin.chart.base.format.AttrTooltipAreaNameFormat;
import com.fr.plugin.chart.base.format.AttrTooltipFormat; import com.fr.plugin.chart.base.format.AttrTooltipFormat;
@ -39,11 +39,11 @@ public class VanChartMapTooltipContentPane extends VanChartTooltipContentPane {
setPercentFormatPane(new PercentFormatPaneWithCheckBox(parent, showOnPane)); setPercentFormatPane(new PercentFormatPaneWithCheckBox(parent, showOnPane));
} }
protected VanChartRichTextPane createRichTextPane(ModernUIPane<VanChartRichEditorModel> richEditorPane) { protected VanChartRichTextPane createRichTextPane(JxUIPane<VanChartRichEditorModel> richEditorPane) {
return new VanChartRichTextPane(richEditorPane) { return new VanChartRichTextPane(richEditorPane) {
protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditor) { protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane<VanChartRichEditorModel> richEditor) {
return new VanChartMapRichTextFieldListPane(fieldAttrPane, richEditor); return new VanChartMapRichTextFieldListPane(fieldAttrPane, richEditor);
} }

4
designer-chart/src/main/java/com/fr/van/chart/map/line/VanChartLineMapRichTextFieldListPane.java

@ -1,7 +1,7 @@
package com.fr.van.chart.map.line; package com.fr.van.chart.map.line;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.ui.ModernUIPane; import com.fr.design.jxbrowser.JxUIPane;
import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat; import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat;
import com.fr.plugin.chart.base.format.AttrTooltipSeriesFormat; import com.fr.plugin.chart.base.format.AttrTooltipSeriesFormat;
import com.fr.plugin.chart.base.format.AttrTooltipStartAndEndNameFormat; import com.fr.plugin.chart.base.format.AttrTooltipStartAndEndNameFormat;
@ -14,7 +14,7 @@ import com.fr.van.chart.designer.component.richText.VanChartRichEditorModel;
public class VanChartLineMapRichTextFieldListPane extends VanChartFieldListPane { public class VanChartLineMapRichTextFieldListPane extends VanChartFieldListPane {
public VanChartLineMapRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditorPane) { public VanChartLineMapRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane<VanChartRichEditorModel> richEditorPane) {
super(fieldAttrPane, richEditorPane); super(fieldAttrPane, richEditorPane);
} }

6
designer-chart/src/main/java/com/fr/van/chart/map/line/VanChartLineMapTooltipContentPane.java

@ -1,7 +1,7 @@
package com.fr.van.chart.map.line; package com.fr.van.chart.map.line;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.ui.ModernUIPane; import com.fr.design.jxbrowser.JxUIPane;
import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.AttrTooltipContent;
import com.fr.plugin.chart.base.format.AttrTooltipFormat; import com.fr.plugin.chart.base.format.AttrTooltipFormat;
import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat; import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat;
@ -36,11 +36,11 @@ public class VanChartLineMapTooltipContentPane extends VanChartTooltipContentPan
setPercentFormatPane(new PercentFormatPaneWithCheckBox(parent, showOnPane)); setPercentFormatPane(new PercentFormatPaneWithCheckBox(parent, showOnPane));
} }
protected VanChartRichTextPane createRichTextPane(ModernUIPane<VanChartRichEditorModel> richEditorPane) { protected VanChartRichTextPane createRichTextPane(JxUIPane<VanChartRichEditorModel> richEditorPane) {
return new VanChartRichTextPane(richEditorPane) { return new VanChartRichTextPane(richEditorPane) {
protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditor) { protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane<VanChartRichEditorModel> richEditor) {
return new VanChartLineMapRichTextFieldListPane(fieldAttrPane, richEditor); return new VanChartLineMapRichTextFieldListPane(fieldAttrPane, richEditor);
} }

6
designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieLabelContentPane.java

@ -1,7 +1,7 @@
package com.fr.van.chart.multilayer.style; package com.fr.van.chart.multilayer.style;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.ui.ModernUIPane; import com.fr.design.jxbrowser.JxUIPane;
import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.AttrTooltipContent;
import com.fr.plugin.chart.base.format.AttrTooltipFormat; import com.fr.plugin.chart.base.format.AttrTooltipFormat;
import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat; import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat;
@ -36,10 +36,10 @@ public class VanChartMultiPieLabelContentPane extends VanChartLabelContentPane {
setPercentFormatPane(new PercentFormatPaneWithCheckBox(parent, showOnPane)); setPercentFormatPane(new PercentFormatPaneWithCheckBox(parent, showOnPane));
} }
protected VanChartRichTextPane createRichTextPane(ModernUIPane<VanChartRichEditorModel> richEditorPane) { protected VanChartRichTextPane createRichTextPane(JxUIPane<VanChartRichEditorModel> richEditorPane) {
return new VanChartRichTextPane(richEditorPane) { return new VanChartRichTextPane(richEditorPane) {
protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditor) { protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane<VanChartRichEditorModel> richEditor) {
return new VanChartMultiPieRichTextFieldListPane(fieldAttrPane, richEditor); return new VanChartMultiPieRichTextFieldListPane(fieldAttrPane, richEditor);
} }

4
designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieRichTextFieldListPane.java

@ -1,7 +1,7 @@
package com.fr.van.chart.multilayer.style; package com.fr.van.chart.multilayer.style;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.ui.ModernUIPane; import com.fr.design.jxbrowser.JxUIPane;
import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat; import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat;
import com.fr.plugin.chart.base.format.AttrTooltipSeriesFormat; import com.fr.plugin.chart.base.format.AttrTooltipSeriesFormat;
import com.fr.plugin.chart.base.format.AttrTooltipValueFormat; import com.fr.plugin.chart.base.format.AttrTooltipValueFormat;
@ -14,7 +14,7 @@ import com.fr.van.chart.designer.component.richText.VanChartRichEditorModel;
public class VanChartMultiPieRichTextFieldListPane extends VanChartFieldListPane { public class VanChartMultiPieRichTextFieldListPane extends VanChartFieldListPane {
public VanChartMultiPieRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditorPane) { public VanChartMultiPieRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane<VanChartRichEditorModel> richEditorPane) {
super(fieldAttrPane, richEditorPane); super(fieldAttrPane, richEditorPane);
} }

6
designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieTooltipContentPane.java

@ -1,7 +1,7 @@
package com.fr.van.chart.multilayer.style; package com.fr.van.chart.multilayer.style;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.ui.ModernUIPane; import com.fr.design.jxbrowser.JxUIPane;
import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.AttrTooltipContent;
import com.fr.plugin.chart.base.format.AttrTooltipFormat; import com.fr.plugin.chart.base.format.AttrTooltipFormat;
import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat; import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat;
@ -35,10 +35,10 @@ public class VanChartMultiPieTooltipContentPane extends VanChartTooltipContentPa
setPercentFormatPane(new PercentFormatPaneWithCheckBox(parent, showOnPane)); setPercentFormatPane(new PercentFormatPaneWithCheckBox(parent, showOnPane));
} }
protected VanChartRichTextPane createRichTextPane(ModernUIPane<VanChartRichEditorModel> richEditorPane) { protected VanChartRichTextPane createRichTextPane(JxUIPane<VanChartRichEditorModel> richEditorPane) {
return new VanChartRichTextPane(richEditorPane) { return new VanChartRichTextPane(richEditorPane) {
protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditor) { protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane<VanChartRichEditorModel> richEditor) {
return new VanChartMultiPieRichTextFieldListPane(fieldAttrPane, richEditor); return new VanChartMultiPieRichTextFieldListPane(fieldAttrPane, richEditor);
} }

6
designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieCategoryLabelContentPane.java

@ -1,8 +1,8 @@
package com.fr.van.chart.pie.style; package com.fr.van.chart.pie.style;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.jxbrowser.JxUIPane;
import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPaneWithAuto; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPaneWithAuto;
import com.fr.design.ui.ModernUIPane;
import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.AttrTooltipContent;
import com.fr.plugin.chart.base.format.AttrTooltipCategoryFormat; import com.fr.plugin.chart.base.format.AttrTooltipCategoryFormat;
import com.fr.plugin.chart.base.format.AttrTooltipFormat; import com.fr.plugin.chart.base.format.AttrTooltipFormat;
@ -45,11 +45,11 @@ public class VanChartPieCategoryLabelContentPane extends VanChartLabelContentPan
summaryValueFormatPane = new SummaryValueFormatPaneWithCheckBox(parent, showOnPane); summaryValueFormatPane = new SummaryValueFormatPaneWithCheckBox(parent, showOnPane);
} }
protected VanChartRichTextPane createRichTextPane(ModernUIPane<VanChartRichEditorModel> richEditorPane) { protected VanChartRichTextPane createRichTextPane(JxUIPane<VanChartRichEditorModel> richEditorPane) {
return new VanChartRichTextPane(richEditorPane) { return new VanChartRichTextPane(richEditorPane) {
protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditor) { protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane<VanChartRichEditorModel> richEditor) {
return new VanChartPieCategoryRichTextFieldListPane(fieldAttrPane, richEditor); return new VanChartPieCategoryRichTextFieldListPane(fieldAttrPane, richEditor);
} }

4
designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieCategoryRichTextFieldListPane.java

@ -1,7 +1,7 @@
package com.fr.van.chart.pie.style; package com.fr.van.chart.pie.style;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.ui.ModernUIPane; import com.fr.design.jxbrowser.JxUIPane;
import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.AttrTooltipContent;
import com.fr.plugin.chart.base.format.AttrTooltipSummaryValueFormat; import com.fr.plugin.chart.base.format.AttrTooltipSummaryValueFormat;
import com.fr.plugin.chart.pie.attr.PieCategoryLabelContent; import com.fr.plugin.chart.pie.attr.PieCategoryLabelContent;
@ -19,7 +19,7 @@ public class VanChartPieCategoryRichTextFieldListPane extends VanChartFieldListP
private VanChartFieldButton summaryValueButton; private VanChartFieldButton summaryValueButton;
public VanChartPieCategoryRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditorPane) { public VanChartPieCategoryRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane<VanChartRichEditorModel> richEditorPane) {
super(fieldAttrPane, richEditorPane); super(fieldAttrPane, richEditorPane);
} }

6
designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieValueLabelContentPane.java

@ -1,7 +1,7 @@
package com.fr.van.chart.pie.style; package com.fr.van.chart.pie.style;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.ui.ModernUIPane; import com.fr.design.jxbrowser.JxUIPane;
import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.AttrTooltipContent;
import com.fr.plugin.chart.base.format.AttrTooltipFormat; import com.fr.plugin.chart.base.format.AttrTooltipFormat;
import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat; import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat;
@ -43,11 +43,11 @@ public class VanChartPieValueLabelContentPane extends VanChartLabelContentPane {
setPercentFormatPane(new PercentFormatPaneWithCheckBox(parent, showOnPane)); setPercentFormatPane(new PercentFormatPaneWithCheckBox(parent, showOnPane));
} }
protected VanChartRichTextPane createRichTextPane(ModernUIPane<VanChartRichEditorModel> richEditorPane) { protected VanChartRichTextPane createRichTextPane(JxUIPane<VanChartRichEditorModel> richEditorPane) {
return new VanChartRichTextPane(richEditorPane) { return new VanChartRichTextPane(richEditorPane) {
protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditor) { protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane<VanChartRichEditorModel> richEditor) {
return new VanChartPieValueRichTextFieldListPane(fieldAttrPane, richEditor); return new VanChartPieValueRichTextFieldListPane(fieldAttrPane, richEditor);
} }

4
designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieValueRichTextFieldListPane.java

@ -1,6 +1,6 @@
package com.fr.van.chart.pie.style; package com.fr.van.chart.pie.style;
import com.fr.design.ui.ModernUIPane; import com.fr.design.jxbrowser.JxUIPane;
import com.fr.van.chart.designer.component.richText.VanChartFieldAttrPane; import com.fr.van.chart.designer.component.richText.VanChartFieldAttrPane;
import com.fr.van.chart.designer.component.richText.VanChartFieldButton; import com.fr.van.chart.designer.component.richText.VanChartFieldButton;
import com.fr.van.chart.designer.component.richText.VanChartFieldListPane; import com.fr.van.chart.designer.component.richText.VanChartFieldListPane;
@ -12,7 +12,7 @@ import java.util.List;
public class VanChartPieValueRichTextFieldListPane extends VanChartFieldListPane { public class VanChartPieValueRichTextFieldListPane extends VanChartFieldListPane {
public VanChartPieValueRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditorPane) { public VanChartPieValueRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane<VanChartRichEditorModel> richEditorPane) {
super(fieldAttrPane, richEditorPane); super(fieldAttrPane, richEditorPane);
} }

4
designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterRichTextFieldListPane.java

@ -1,7 +1,7 @@
package com.fr.van.chart.scatter; package com.fr.van.chart.scatter;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.ui.ModernUIPane; import com.fr.design.jxbrowser.JxUIPane;
import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.AttrTooltipContent;
import com.fr.plugin.chart.base.format.AttrTooltipSizeFormat; import com.fr.plugin.chart.base.format.AttrTooltipSizeFormat;
import com.fr.plugin.chart.base.format.AttrTooltipXFormat; import com.fr.plugin.chart.base.format.AttrTooltipXFormat;
@ -23,7 +23,7 @@ public class VanChartScatterRichTextFieldListPane extends VanChartFieldListPane
private VanChartFieldButton richTextYFormatPane; private VanChartFieldButton richTextYFormatPane;
private VanChartFieldButton richTextSizeFormatPane; private VanChartFieldButton richTextSizeFormatPane;
public VanChartScatterRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditorPane) { public VanChartScatterRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane<VanChartRichEditorModel> richEditorPane) {
super(fieldAttrPane, richEditorPane); super(fieldAttrPane, richEditorPane);
} }

6
designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterTooltipContentPane.java

@ -1,7 +1,7 @@
package com.fr.van.chart.scatter; package com.fr.van.chart.scatter;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.ui.ModernUIPane; import com.fr.design.jxbrowser.JxUIPane;
import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.AttrTooltipContent;
import com.fr.plugin.chart.base.format.AttrTooltipFormat; import com.fr.plugin.chart.base.format.AttrTooltipFormat;
import com.fr.plugin.chart.base.format.AttrTooltipSeriesFormat; import com.fr.plugin.chart.base.format.AttrTooltipSeriesFormat;
@ -60,11 +60,11 @@ public class VanChartScatterTooltipContentPane extends VanChartTooltipContentPa
sizeFormatPane = new ValueFormatPaneWithCheckBox(parent, showOnPane); sizeFormatPane = new ValueFormatPaneWithCheckBox(parent, showOnPane);
} }
protected VanChartRichTextPane createRichTextPane(ModernUIPane<VanChartRichEditorModel> richEditorPane) { protected VanChartRichTextPane createRichTextPane(JxUIPane<VanChartRichEditorModel> richEditorPane) {
return new VanChartRichTextPane(richEditorPane) { return new VanChartRichTextPane(richEditorPane) {
protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditor) { protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane<VanChartRichEditorModel> richEditor) {
return new VanChartScatterRichTextFieldListPane(fieldAttrPane, richEditor); return new VanChartScatterRichTextFieldListPane(fieldAttrPane, richEditor);
} }

4
designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureRichTextFieldListPane.java

@ -1,7 +1,7 @@
package com.fr.van.chart.structure.desinger.style; package com.fr.van.chart.structure.desinger.style;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.ui.ModernUIPane; import com.fr.design.jxbrowser.JxUIPane;
import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat; import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat;
import com.fr.plugin.chart.base.format.AttrTooltipSeriesFormat; import com.fr.plugin.chart.base.format.AttrTooltipSeriesFormat;
import com.fr.plugin.chart.base.format.AttrTooltipValueFormat; import com.fr.plugin.chart.base.format.AttrTooltipValueFormat;
@ -18,7 +18,7 @@ import java.util.List;
public class VanChartStructureRichTextFieldListPane extends VanChartFieldListPane { public class VanChartStructureRichTextFieldListPane extends VanChartFieldListPane {
public VanChartStructureRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditorPane) { public VanChartStructureRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane<VanChartRichEditorModel> richEditorPane) {
super(fieldAttrPane, richEditorPane); super(fieldAttrPane, richEditorPane);
} }

6
designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureTooltipContentPane.java

@ -2,7 +2,7 @@ package com.fr.van.chart.structure.desinger.style;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.ui.ModernUIPane; import com.fr.design.jxbrowser.JxUIPane;
import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.AttrTooltipContent;
import com.fr.plugin.chart.base.format.AttrTooltipFormat; import com.fr.plugin.chart.base.format.AttrTooltipFormat;
import com.fr.plugin.chart.base.format.AttrTooltipSeriesFormat; import com.fr.plugin.chart.base.format.AttrTooltipSeriesFormat;
@ -62,11 +62,11 @@ public class VanChartStructureTooltipContentPane extends VanChartTooltipContentP
setPercentFormatPane(percentFormatPane); setPercentFormatPane(percentFormatPane);
} }
protected VanChartRichTextPane createRichTextPane(ModernUIPane<VanChartRichEditorModel> richEditorPane) { protected VanChartRichTextPane createRichTextPane(JxUIPane<VanChartRichEditorModel> richEditorPane) {
return new VanChartRichTextPane(richEditorPane) { return new VanChartRichTextPane(richEditorPane) {
protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditor) { protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane<VanChartRichEditorModel> richEditor) {
return new VanChartStructureRichTextFieldListPane(fieldAttrPane, richEditor); return new VanChartStructureRichTextFieldListPane(fieldAttrPane, richEditor);
} }

4
designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudRichTextFieldListPane.java

@ -1,7 +1,7 @@
package com.fr.van.chart.wordcloud.designer.style; package com.fr.van.chart.wordcloud.designer.style;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.ui.ModernUIPane; import com.fr.design.jxbrowser.JxUIPane;
import com.fr.plugin.chart.base.format.AttrTooltipCategoryFormat; import com.fr.plugin.chart.base.format.AttrTooltipCategoryFormat;
import com.fr.plugin.chart.base.format.AttrTooltipNameFormat; import com.fr.plugin.chart.base.format.AttrTooltipNameFormat;
import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat; import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat;
@ -14,7 +14,7 @@ import com.fr.van.chart.designer.component.richText.VanChartRichEditorModel;
public class VanChartWordCloudRichTextFieldListPane extends VanChartFieldListPane { public class VanChartWordCloudRichTextFieldListPane extends VanChartFieldListPane {
public VanChartWordCloudRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditorPane) { public VanChartWordCloudRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane<VanChartRichEditorModel> richEditorPane) {
super(fieldAttrPane, richEditorPane); super(fieldAttrPane, richEditorPane);
} }

6
designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudTooltipContentPane.java

@ -2,7 +2,7 @@ package com.fr.van.chart.wordcloud.designer.style;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.ui.ModernUIPane; import com.fr.design.jxbrowser.JxUIPane;
import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.AttrTooltipContent;
import com.fr.plugin.chart.base.format.AttrTooltipCategoryFormat; import com.fr.plugin.chart.base.format.AttrTooltipCategoryFormat;
import com.fr.plugin.chart.base.format.AttrTooltipFormat; import com.fr.plugin.chart.base.format.AttrTooltipFormat;
@ -58,10 +58,10 @@ public class VanChartWordCloudTooltipContentPane extends VanChartTooltipContentP
setPercentFormatPane(percentFormatPane); setPercentFormatPane(percentFormatPane);
} }
protected VanChartRichTextPane createRichTextPane(ModernUIPane<VanChartRichEditorModel> richEditorPane) { protected VanChartRichTextPane createRichTextPane(JxUIPane<VanChartRichEditorModel> richEditorPane) {
return new VanChartRichTextPane(richEditorPane) { return new VanChartRichTextPane(richEditorPane) {
protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditor) { protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, JxUIPane<VanChartRichEditorModel> richEditor) {
return new VanChartWordCloudRichTextFieldListPane(fieldAttrPane, richEditor); return new VanChartWordCloudRichTextFieldListPane(fieldAttrPane, richEditor);
} }

4
designer-chart/src/main/resources/com/fr/design/editor/rich_editor.html

@ -3,8 +3,8 @@
<head> <head>
<meta charset="utf-8"/> <meta charset="utf-8"/>
<title></title> <title></title>
<link rel="stylesheet" type="text/css" href="emb:/com/fr/web/ui/fineui.min.css"/> <link rel="stylesheet" type="text/css" href="emb://com/fr/web/ui/fineui.min.css"/>
<link rel="stylesheet" type="text/css" href="emb:/com/fr/web/ui/materials.min.css"/> <link rel="stylesheet" type="text/css" href="emb://com/fr/web/ui/materials.min.css"/>
</head> </head>
<body> <body>
<script src="script/enums.js"></script> <script src="script/enums.js"></script>

35
designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/mini/MiniComponentShopPane.java

@ -1,19 +1,12 @@
package com.fr.design.mainframe.share.ui.online.mini; package com.fr.design.mainframe.share.ui.online.mini;
import com.fr.design.jxbrowser.JxUIPane;
import com.fr.design.mainframe.share.ui.online.mini.bridge.ComposedNativeBridges; import com.fr.design.mainframe.share.ui.online.mini.bridge.ComposedNativeBridges;
import com.fr.design.mainframe.share.util.OnlineShopUtils; import com.fr.design.mainframe.share.util.OnlineShopUtils;
import com.fr.design.ui.ModernUIPane;
import com.fr.design.ui.compatible.ModernUIPaneFactory;
import com.fr.design.upm.event.CertificateEvent; import com.fr.design.upm.event.CertificateEvent;
import com.fr.event.Event; import com.fr.event.Event;
import com.fr.event.EventDispatcher; import com.fr.event.EventDispatcher;
import com.fr.event.Listener; import com.fr.event.Listener;
import com.teamdev.jxbrowser.browser.callback.InjectJsCallback;
import com.teamdev.jxbrowser.chromium.JSObject;
import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter;
import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent;
import com.teamdev.jxbrowser.js.JsObject;
import org.jetbrains.annotations.Nullable;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.BorderLayout; import java.awt.BorderLayout;
@ -24,34 +17,16 @@ import java.awt.BorderLayout;
* Created by Starryi on 2021/12/20 * Created by Starryi on 2021/12/20
*/ */
public class MiniComponentShopPane extends JPanel { public class MiniComponentShopPane extends JPanel {
private final ModernUIPane<Object> modernUIPane; private static final String SHOP_HELPER = "ShopHelper";
private final JxUIPane<Object> modernUIPane;
private final Listener<String> loginListener; private final Listener<String> loginListener;
private final Listener<String> logoutListener; private final Listener<String> logoutListener;
public MiniComponentShopPane() { public MiniComponentShopPane() {
setLayout(new BorderLayout()); setLayout(new BorderLayout());
modernUIPane = ModernUIPaneFactory.modernUIPaneBuilder() modernUIPane = new JxUIPane.Builder<>()
.withURL(OnlineShopUtils.getWebMiniShopPath()) .withURL(OnlineShopUtils.getWebMiniShopPath())
.prepareForV6(new ScriptContextAdapter() { .bindWindow(SHOP_HELPER, ComposedNativeBridges::new)
@Override
public void onScriptContextCreated(ScriptContextEvent event) {
super.onScriptContextCreated(event);
JSObject window = event.getBrowser().executeJavaScriptAndReturnValue("window").asObject();
window.setProperty("ShopHelper", new ComposedNativeBridges(window));
}
})
.prepareForV7(new InjectJsCallback() {
@Nullable
@Override
public Response on(Params params) {
// 7.x
JsObject window = params.frame().executeJavaScript("window");
if (window != null) {
window.putProperty("ShopHelper", new ComposedNativeBridges(window));
}
return InjectJsCallback.Response.proceed();
}
})
.build(); .build();
add(modernUIPane, BorderLayout.CENTER); add(modernUIPane, BorderLayout.CENTER);

6
designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java

@ -446,12 +446,14 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
Style oldStyle = cellElement == null ? Style.DEFAULT_STYLE : cellElement.getStyle(); Style oldStyle = cellElement == null ? Style.DEFAULT_STYLE : cellElement.getStyle();
Style style = formatPane.update(oldStyle); Style style = formatPane.update(oldStyle);
for (TemplateCellElement cellElement : allCellElements) { for (TemplateCellElement cellElement : allCellElements) {
Format elementFormat = cellElement.getStyle().getFormat(); Style cellElementStyle = cellElement.getStyle();
Format elementFormat = cellElementStyle.getFormat();
Format paneFormat = style.getFormat(); Format paneFormat = style.getFormat();
if (!Objects.equals(paneFormat, elementFormat)) { if (!Objects.equals(paneFormat, elementFormat)) {
// 点击单元格,但未设置格式时,不将单元格设置为编辑状态,防止将所选的每个单元格都设置为编辑状态 // 点击单元格,但未设置格式时,不将单元格设置为编辑状态,防止将所选的每个单元格都设置为编辑状态
editingElementCase.addCellElement(cellElement); editingElementCase.addCellElement(cellElement);
cellElement.setStyle(style); Style newStyle = cellElementStyle.deriveFormat(paneFormat);
cellElement.setStyle(newStyle);
updateStyle = true; updateStyle = true;
} }
} }

18
designer-realize/src/test/java/com.fr/design/mainframe/alphafine/cell/model/ModelTest.java

@ -1,13 +1,31 @@
package com.fr.design.mainframe.alphafine.cell.model; package com.fr.design.mainframe.alphafine.cell.model;
import com.fr.design.actions.help.alphafine.AlphaFineCloudConstants; import com.fr.design.actions.help.alphafine.AlphaFineCloudConstants;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.alphafine.CellType; import com.fr.design.mainframe.alphafine.CellType;
import com.fr.json.JSONException; import com.fr.json.JSONException;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
@PrepareForTest(Toolkit.class)
@PowerMockIgnore("javax.swing.*")
public class ModelTest { public class ModelTest {
@Before
public void setUp() {
PowerMockito.mockStatic(Toolkit.class);
PowerMockito.when(Toolkit.i18nText(Mockito.anyString())).thenReturn("test");
}
@Test @Test
public void documentModelTest() { public void documentModelTest() {
DocumentModel documentModel = new DocumentModel("name", "content", 1); DocumentModel documentModel = new DocumentModel("name", "content", 1);

17
designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/FileSearchManagerTest.java

@ -1,7 +1,5 @@
package com.fr.design.mainframe.alphafine.search.manager.impl; package com.fr.design.mainframe.alphafine.search.manager.impl;
import com.fr.base.FRContext;
import com.fr.base.extension.FileExtension;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.help.alphafine.AlphaFineConfigManager; import com.fr.design.actions.help.alphafine.AlphaFineConfigManager;
import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.AlphaFineHelper;
@ -9,9 +7,6 @@ import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
import com.fr.design.mainframe.alphafine.model.SearchResult; import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.file.filetree.FileNode; import com.fr.file.filetree.FileNode;
import com.fr.invoke.Reflect; import com.fr.invoke.Reflect;
import com.fr.stable.project.ProjectConstants;
import com.fr.web.core.SessionPoolManager;
import com.fr.web.utils.WebUtils;
import org.easymock.EasyMock; import org.easymock.EasyMock;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -23,7 +18,7 @@ import org.powermock.modules.junit4.PowerMockRunner;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import static org.junit.Assert.*; import static org.junit.Assert.assertEquals;
/** /**
* @author Yyming * @author Yyming
@ -43,8 +38,8 @@ public class FileSearchManagerTest {
FileNode fileNode2 = EasyMock.createMock(FileNode.class); FileNode fileNode2 = EasyMock.createMock(FileNode.class);
EasyMock.expect(fileNode1.getName()).andReturn("workbook").anyTimes(); EasyMock.expect(fileNode1.getName()).andReturn("workbook").anyTimes();
EasyMock.expect(fileNode2.getName()).andReturn("work book").anyTimes(); EasyMock.expect(fileNode2.getName()).andReturn("work book").anyTimes();
EasyMock.expect(fileNode1.getEnvPath()).andReturn("").anyTimes(); EasyMock.expect(fileNode1.getEnvPath()).andReturn("t1").anyTimes();
EasyMock.expect(fileNode2.getEnvPath()).andReturn("").anyTimes(); EasyMock.expect(fileNode2.getEnvPath()).andReturn("t2").anyTimes();
EasyMock.replay(fileNode1,fileNode2); EasyMock.replay(fileNode1,fileNode2);
FileNode[] fileNodes = { fileNode1, fileNode2 }; FileNode[] fileNodes = { fileNode1, fileNode2 };
Reflect.on(instance).set("fileNodes",fileNodes); Reflect.on(instance).set("fileNodes",fileNodes);
@ -65,8 +60,10 @@ public class FileSearchManagerTest {
PowerMock.mockStatic(AlphaFineHelper.class); PowerMock.mockStatic(AlphaFineHelper.class);
AlphaFineHelper.getFilterResult(); AlphaFineHelper.getFilterResult();
PowerMock.expectLastCall().andReturn(list).anyTimes(); PowerMock.expectLastCall().andReturn(list).anyTimes();
AlphaFineHelper.findFolderName(""); AlphaFineHelper.findFolderName("t1");
PowerMock.expectLastCall().andReturn("").anyTimes(); PowerMock.expectLastCall().andReturn("t1").anyTimes();
AlphaFineHelper.findFolderName("t2");
PowerMock.expectLastCall().andReturn("t2").anyTimes();
AlphaFineHelper.checkCancel(); AlphaFineHelper.checkCancel();
PowerMock.expectLastCall().andVoid().anyTimes(); PowerMock.expectLastCall().andVoid().anyTimes();
PowerMock.replay(AlphaFineHelper.class); PowerMock.replay(AlphaFineHelper.class);

2
designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManagerTest.java

@ -19,7 +19,7 @@ public class PluginSearchManagerTest {
Assert.assertTrue(Reflect.on(PluginSearchManager.class).call("isCompatibleCurrentEnv", "9.0").get()); Assert.assertTrue(Reflect.on(PluginSearchManager.class).call("isCompatibleCurrentEnv", "9.0").get());
Assert.assertTrue(Reflect.on(PluginSearchManager.class).call("isCompatibleCurrentEnv", "9~").get()); Assert.assertTrue(Reflect.on(PluginSearchManager.class).call("isCompatibleCurrentEnv", "9~").get());
Assert.assertTrue(Reflect.on(PluginSearchManager.class).call("isCompatibleCurrentEnv", "10").get()); Assert.assertTrue(Reflect.on(PluginSearchManager.class).call("isCompatibleCurrentEnv", "10").get());
Assert.assertFalse(Reflect.on(PluginSearchManager.class).call("isCompatibleCurrentEnv", "11").get()); Assert.assertTrue(Reflect.on(PluginSearchManager.class).call("isCompatibleCurrentEnv", "11").get());
} }
} }

18
designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/SearchManegerTest.java

@ -1,13 +1,26 @@
package com.fr.design.mainframe.alphafine.search.manager.impl; package com.fr.design.mainframe.alphafine.search.manager.impl;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.CellType; import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.model.SearchResult; import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.design.mainframe.toolbar.UpdateActionManager;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import java.util.ArrayList;
@RunWith(PowerMockRunner.class)
@PrepareForTest(Toolkit.class)
@PowerMockIgnore("javax.swing.*")
public class SearchManegerTest { public class SearchManegerTest {
SimilarSearchManager similarSearchManager; SimilarSearchManager similarSearchManager;
ComplementAdviceManager complementAdviceManager; ComplementAdviceManager complementAdviceManager;
@ -21,6 +34,11 @@ public class SearchManegerTest {
@Before @Before
public void setUp() { public void setUp() {
UpdateActionManager.getUpdateActionManager().setUpdateActions(new ArrayList<>());
PowerMockito.mockStatic(Toolkit.class);
PowerMockito.when(Toolkit.i18nText(Mockito.anyString())).thenReturn("test");
recentSearchManager = RecentSearchManager.getInstance(); recentSearchManager = RecentSearchManager.getInstance();
recommendSearchManager = RecommendSearchManager.getInstance(); recommendSearchManager = RecommendSearchManager.getInstance();
similarSearchManager = SimilarSearchManager.getInstance(); similarSearchManager = SimilarSearchManager.getInstance();

Loading…
Cancel
Save