Browse Source

REPORT-93559 api优化

newui
vito 2 years ago
parent
commit
86d5d100d9
  1. 3
      designer-base/src/main/java/com/fr/design/actions/help/FineUIAction.java
  2. 2
      designer-base/src/main/java/com/fr/design/dcm/UniversalDatabasePane.java
  3. 15
      designer-base/src/main/java/com/fr/design/jxbrowser/JxEngine.java
  4. 62
      designer-base/src/main/java/com/fr/design/jxbrowser/JxUIPane.java
  5. 2
      designer-base/src/main/java/com/fr/design/login/DesignerLoginPane.java
  6. 2
      designer-base/src/main/java/com/fr/design/login/guide/DesignerGuidePane.java
  7. 2
      designer-base/src/main/java/com/fr/design/upm/UpmShowPane.java
  8. 2
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/mini/MiniComponentShopPane.java

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

@ -29,8 +29,7 @@ public class FineUIAction extends UpdateAction {
@Override
public void actionPerformed(final ActionEvent e) {
JxUIPane<?> pane = new JxUIPane.Builder<>()
.variable("i18n")
.property(new I18n())
.bindNamespace("i18n", new I18n())
.withComponent(new AssembleComponent() {
@Override

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

@ -21,7 +21,7 @@ public class UniversalDatabasePane extends BasicPane {
setLayout(new BorderLayout());
JxUIPane<Object> modernUIPane = new JxUIPane.Builder<>()
.withComponent(UniversalDatabaseComponent.KEY)
.buildProperty("DcmHelper", UniversalDcmBridge::getBridge)
.bindWindow("DcmHelper", UniversalDcmBridge::getBridge)
.build();
add(modernUIPane, BorderLayout.CENTER);
}

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

@ -65,6 +65,9 @@ public class JxEngine {
this.parameterMap = parameterMap;
}
/**
* 清理map
*/
public void clearMap() {
this.parameterMap = Collections.emptyMap();
}
@ -77,6 +80,9 @@ public class JxEngine {
this.component = component;
}
/**
* 清理component
*/
public void clearComponent() {
this.component = null;
}
@ -92,11 +98,20 @@ public class JxEngine {
return INSTANCE;
}
/**
* 获取公共引擎公共引擎使用后不用关闭引擎但需要自己管理 browser
* 应用系统管理引擎生命周期
*
* @return 引擎
*/
@NotNull
public Engine getEngine() {
return ENGINE.getValue();
}
/**
* 关闭引擎
*/
public void close() {
ENGINE.getValue().close();
ENGINE.drop();

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

@ -225,6 +225,7 @@ public class JxUIPane<T> extends ModernUIPane<T> {
private String variable;
private String expression;
private InjectJsCallback callback;
private final Map<String, Object> namespacePropertyMap;
private final Map<String, Object> propertyMap;
private final Map<String, PropertyBuild> buildPropertyMap;
private Object variableProperty;
@ -238,6 +239,7 @@ public class JxUIPane<T> extends ModernUIPane<T> {
this.variable = DEFAULT_VARIABLE;
this.expression = DEFAULT_EXPRESSION;
this.callback = null;
this.namespacePropertyMap = new HashMap<>();
this.propertyMap = new HashMap<>();
this.buildPropertyMap = new HashMap<>();
this.variableProperty = null;
@ -334,6 +336,12 @@ public class JxUIPane<T> extends ModernUIPane<T> {
/**
* 设置该前端页面做数据交换所使用的对象
* 相当于
* const namespace = "Pool";
* 调用
* window[namespace];
* 默认下结构如
* window.Pool
*
* @param namespace 对象名
*/
@ -345,6 +353,12 @@ public class JxUIPane<T> extends ModernUIPane<T> {
/**
* java端往js端传数据时使用的变量名字
* 默认值为 data
* 相当于
* const variable = "data";
* 调用
* window[namespace][variable];
* 默认下结构如
* window.Pool.data
*
* @param name 变量的名字
*/
@ -364,16 +378,19 @@ public class JxUIPane<T> extends ModernUIPane<T> {
}
/**
* 注入一个java对象到js中,绑定在全局变量 window的
* property指定的变量这个方法仅在在加载的网页上执
* JavaScript 之前注入
* 注入一个java对象到js中绑定在全局变量window的指定变量variable
* variable 可由 {@link #namespace(String)} 设置默认值为 data
* 这个方法仅在在加载的网页上执行 JavaScript 之前注入
* 相当于
* window[namespace][property] = javaObject
* 默认下
* window.Pool[property] = javaObject
*
* @param property 属性
* @param obj java对象
* @return 链式对象
*/
public JxUIPane.Builder<T> property(String property, @Nullable Object obj) {
this.propertyMap.put(property, obj);
public JxUIPane.Builder<T> bindNamespace(String property, @Nullable Object obj) {
this.namespacePropertyMap.put(property, obj);
return this;
}
@ -381,25 +398,49 @@ public class JxUIPane<T> extends ModernUIPane<T> {
* 注入一个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> property(@NotNull Object obj) {
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> buildProperty(String property, PropertyBuild obj) {
public JxUIPane.Builder<T> bindWindow(String property, PropertyBuild obj) {
buildPropertyMap.put(property, obj);
return this;
}
@ -442,6 +483,11 @@ public class JxUIPane<T> extends ModernUIPane<T> {
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));

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

@ -30,7 +30,7 @@ public class DesignerLoginPane extends BasicPane {
params.put("lastLoginAccount", DesignerEnvManager.getEnvManager().getLastLoginAccount());
setLayout(new BorderLayout());
JxUIPane<Object> modernUIPane = new JxUIPane.Builder<>()
.buildProperty(DESIGNER_LOGIN_HELPER, window -> DesignerLoginBridge.getBridge(window, params))
.bindWindow(DESIGNER_LOGIN_HELPER, window -> DesignerLoginBridge.getBridge(window, params))
.withEMB(DesignerLoginHelper.getMainResourcePath(), DesignerLoginUtils.renderMap())
.build();
add(modernUIPane, BorderLayout.CENTER);

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

@ -25,7 +25,7 @@ public class DesignerGuidePane extends BasicPane {
public DesignerGuidePane() {
setLayout(new BorderLayout());
JxUIPane<Object> modernUIPane = new JxUIPane.Builder<>()
.buildProperty(DESIGNER_GUIDE_HELPER, w -> DesignerGuideBridge.getBridge())
.bindWindow(DESIGNER_GUIDE_HELPER, w -> DesignerGuideBridge.getBridge())
.withEMB(DesignerGuideHelper.getMainResourcePath(), DesignerGuideUtils.renderMap())
.build();
add(modernUIPane, BorderLayout.CENTER);

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

@ -29,7 +29,7 @@ public class UpmShowPane extends BasicPane {
UpmShowPane() {
setLayout(new BorderLayout());
jxUIPane = new JxUIPane.Builder<>()
.buildProperty(PLUGIN_HELPER, UpmBridgeV7::getBridge)
.bindWindow(PLUGIN_HELPER, UpmBridgeV7::getBridge)
.withURL(UpmFinder.getMainResourcePath(), UpmUtils.renderMap())
.build();
EventDispatcher.listen(DownloadEvent.UPDATE, new Listener<String>() {

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

@ -26,7 +26,7 @@ public class MiniComponentShopPane extends JPanel {
setLayout(new BorderLayout());
modernUIPane = new JxUIPane.Builder<>()
.withURL(OnlineShopUtils.getWebMiniShopPath())
.buildProperty(SHOP_HELPER, ComposedNativeBridges::new)
.bindWindow(SHOP_HELPER, ComposedNativeBridges::new)
.build();
add(modernUIPane, BorderLayout.CENTER);

Loading…
Cancel
Save