Browse Source

Pull request #7930: 无JIRA任务 解决冲突release11.0 -> feature/x

Merge in DESIGN/design from ~FANGLEI/design:feature/x to feature/x

* commit 'd95cf6ec3f6ef396335e77719bd15454662cd58c':
  REPORT-64011 优化大文本 - 先回退,等新前端适配完了再发布
  REPORT-66465 【组件商城风格优化】设计器商城,概率打开空白
  REPORT-65772 模板权限编辑状态切换问题-打开一张cpt,进入模板权限编辑后,再打开一张frm时,frm也有模板权限编辑框了
  REPORT-66306 组件包下载面板无遮罩阴影
  CHART-22876&CHART-22873&CHART-22861&CHART-22863&CHART-22797&CHART-22768 若干bug一起改
feature/x
ju|剧浩宇 2 years ago
parent
commit
931755b70f
  1. 2
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/report/CategoryPlotMoreCateReportDataContentPane.java
  2. 5
      designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java
  3. 40
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineDownloadPackagePane.java
  4. 23
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/mini/MiniComponentShopPane.java
  5. 19
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/mini/bridge/ComposedNativeBridges.java
  6. 3
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/mini/bridge/NativeAuthBridge.java
  7. 13
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/mini/bridge/NativeBrowserBridge.java
  8. 86
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/mini/bridge/NativeProductBridge.java
  9. 21
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/mini/bridge/NativeTaskBridge.java
  10. 29
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/mini/bridge/SafeJSFunctionInvoker.java
  11. 171
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java

2
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/report/CategoryPlotMoreCateReportDataContentPane.java

@ -192,8 +192,8 @@ public class CategoryPlotMoreCateReportDataContentPane extends CategoryPlotRepor
NormalReportDataDefinition reportDefinition = (NormalReportDataDefinition) definition;
reportDefinition.clearMoreCate();
updateMoreCate(reportDefinition, plot);
collection.updateAxisCategoryStyles();
}
collection.updateAxisCategoryStyles();
}
protected void updateMoreCate(NormalReportDataDefinition reportDefinition, Plot plot) {

5
designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java

@ -1520,7 +1520,10 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
private DesignerBaseOperate getLayoutBaseOperate(){
FormSelection selection = this.getSelectionModel().getSelection();
XCreator creator = selection.getSelectedCreator();
XLayoutContainer container = (XLayoutContainer) creator.getParent();
XLayoutContainer container = null;
if (creator != null) {
container = (XLayoutContainer) creator.getParent();
}
if (container == null) {
return new DefaultDesignerBaseOperate();
}

40
designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineDownloadPackagePane.java

@ -72,22 +72,6 @@ public class OnlineDownloadPackagePane extends OnlineWidgetSelectPane {
return false;
}
protected JPanel createWidgetPane() {
return new JPanel() {
@Override
public void paint(Graphics g) {
super.paint(g);
Graphics2D g2d = (Graphics2D) g;
Composite oldComposite = g2d.getComposite();
AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.65f);
g2d.setComposite(composite);
g2d.setColor(Color.DARK_GRAY);
g2d.fillRect(0, 0, getWidth(), getHeight());
g2d.setComposite(oldComposite);
}
};
}
protected JPanel createContentPane(JPanel widgetPane) {
JPanel panel = new JPanel() {
@Override
@ -114,7 +98,20 @@ public class OnlineDownloadPackagePane extends OnlineWidgetSelectPane {
parentPane.resetWidgetDetailPane(packageId, getSharableWidgetProviders());
}
}
});
}) {
@Override
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
Composite oldComposite = g2d.getComposite();
AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.65f);
g2d.setComposite(composite);
g2d.setColor(Color.DARK_GRAY);
g2d.fillRect(0, 0, getWidth(), getHeight());
g2d.setComposite(oldComposite);
super.paint(g);
}
};
panel.add(downloadProgressPane);
panel.add(widgetPane, BorderLayout.CENTER);
return panel;
@ -125,10 +122,16 @@ public class OnlineDownloadPackagePane extends OnlineWidgetSelectPane {
final com.fr.design.extra.Process<Double> downloadProcess = aDouble -> {
OnlineDownloadPackagePane.this.process = 0.8 * aDouble;
downloadProgressPane.updateProgress(process);
if (downloadProgressPane != null) {
downloadProgressPane.repaint();
}
};
final com.fr.design.extra.Process<Double> installProcess = aDouble -> {
OnlineDownloadPackagePane.this.process = 0.8 + 0.2 * aDouble;
downloadProgressPane.updateProgress(process);
if (downloadProgressPane != null) {
downloadProgressPane.repaint();
}
};
downloadProcess.process(0.0D);
@ -220,6 +223,9 @@ public class OnlineDownloadPackagePane extends OnlineWidgetSelectPane {
File file = new File(filePath);
installProcess.process(0.0D);
downloadProgressPane.changeState();
if (downloadProgressPane != null) {
downloadProgressPane.repaint();
}
InstallUtils.InstallResult result = null;
try {
if (file.exists()) {

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

@ -3,15 +3,18 @@ package com.fr.design.mainframe.share.ui.online.mini;
import com.fr.design.mainframe.share.ui.online.mini.bridge.ComposedNativeBridges;
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.event.Event;
import com.fr.event.EventDispatcher;
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.JOptionPane;
import javax.swing.JPanel;
import java.awt.BorderLayout;
@ -27,14 +30,26 @@ public class MiniComponentShopPane extends JPanel {
public MiniComponentShopPane() {
setLayout(new BorderLayout());
modernUIPane = new ModernUIPane.Builder<>()
modernUIPane = ModernUIPaneFactory.modernUIPaneBuilder()
.withURL(OnlineShopUtils.getWebMiniShopPath())
.prepare(new ScriptContextAdapter() {
.prepareForV6(new ScriptContextAdapter() {
@Override
public void onScriptContextCreated(ScriptContextEvent event) {
super.onScriptContextCreated(event);
JSObject window = event.getBrowser().executeJavaScriptAndReturnValue("window").asObject();
window.asObject().setProperty("ShopHelper", new ComposedNativeBridges(window, JOptionPane.getFrameForComponent(MiniComponentShopPane.this)));
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();

19
designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/mini/bridge/ComposedNativeBridges.java

@ -1,9 +1,7 @@
package com.fr.design.mainframe.share.ui.online.mini.bridge;
import com.teamdev.jxbrowser.chromium.JSAccessible;
import com.teamdev.jxbrowser.chromium.JSObject;
import java.awt.Window;
import com.teamdev.jxbrowser.js.JsAccessible;
/**
* @author Starryi
@ -12,14 +10,19 @@ import java.awt.Window;
*/
public class ComposedNativeBridges {
@JSAccessible
public final NativeBrowserBridge Browser;
@JsAccessible
public final Object Browser;
@JSAccessible
public final NativeAuthBridge Auth;
@JsAccessible
public final Object Auth;
@JSAccessible
public final NativeProductBridge Product;
@JsAccessible
public final Object Product;
public ComposedNativeBridges(JSObject window, Window nativeWindow) {
this.Browser = new NativeBrowserBridge(nativeWindow);
public ComposedNativeBridges(Object window) {
this.Browser = new NativeBrowserBridge();
this.Auth = new NativeAuthBridge();
this.Product = new NativeProductBridge(window);
}

3
designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/mini/bridge/NativeAuthBridge.java

@ -6,6 +6,7 @@ import com.fr.design.login.DesignerLoginHelper;
import com.fr.design.login.DesignerLoginSource;
import com.fr.design.mainframe.share.ui.online.mini.MiniComponentShopDialog;
import com.teamdev.jxbrowser.chromium.JSAccessible;
import com.teamdev.jxbrowser.js.JsAccessible;
import java.awt.Window;
import java.util.HashMap;
@ -17,12 +18,14 @@ import java.util.HashMap;
*/
public class NativeAuthBridge {
@JSAccessible
@JsAccessible
@JSBridge
public String getLoginUsername() {
return DesignerEnvManager.getEnvManager().getDesignerLoginUsername();
}
@JSAccessible
@JsAccessible
@JSBridge
public void goLogin() {
Window parentWindow = MiniComponentShopDialog.getInstance().getWindow();

13
designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/mini/bridge/NativeBrowserBridge.java

@ -1,7 +1,9 @@
package com.fr.design.mainframe.share.ui.online.mini.bridge;
import com.fr.design.bridge.exec.JSBridge;
import com.fr.design.mainframe.share.ui.online.mini.MiniComponentShopDialog;
import com.teamdev.jxbrowser.chromium.JSAccessible;
import com.teamdev.jxbrowser.js.JsAccessible;
import java.awt.Window;
@ -11,15 +13,14 @@ import java.awt.Window;
* Created by Starryi on 2021/12/20
*/
public class NativeBrowserBridge {
private final Window nativeWindow;
public NativeBrowserBridge(Window nativeWindow) {
this.nativeWindow = nativeWindow;
}
@JSAccessible
@JsAccessible
@JSBridge
public void dispose() {
this.nativeWindow.dispose();
Window nativeWindow = MiniComponentShopDialog.getInstance().getWindow();
if (nativeWindow != null) {
nativeWindow.dispose();
}
}
}

86
designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/mini/bridge/NativeProductBridge.java

@ -21,8 +21,7 @@ import com.fr.form.share.group.DefaultShareGroupManager;
import com.fr.json.JSONObject;
import com.fr.stable.StringUtils;
import com.teamdev.jxbrowser.chromium.JSAccessible;
import com.teamdev.jxbrowser.chromium.JSFunction;
import com.teamdev.jxbrowser.chromium.JSObject;
import com.teamdev.jxbrowser.js.JsAccessible;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
@ -38,20 +37,21 @@ import java.util.Set;
* Created by Starryi on 2021/12/20
*/
public class NativeProductBridge {
private final JSObject window;
private final Object window;
private static final Map<String, ComponentInstallationTask> executingComponentInstallationTasks = new HashMap<>();
private static final Map<String, ComponentsPackageInstallationTask> executingComponentsPackageInstallationTasks = new HashMap<>();
private static final Map<String, TemplateThemeInstallationTask> executingTemplateThemeInstallationTasks = new HashMap<>();
private final Map<String, Set<JSFunction>> componentDownloadTaskStartListeners = new HashMap<>();
private final Map<String, Set<JSFunction>> componentsPackageDownloadTaskStartListeners = new HashMap<>();
private final Map<String, Set<JSFunction>> themeDownloadTaskStartListeners = new HashMap<>();
private final Map<String, Set<Object>> componentDownloadTaskStartListeners = new HashMap<>();
private final Map<String, Set<Object>> componentsPackageDownloadTaskStartListeners = new HashMap<>();
private final Map<String, Set<Object>> themeDownloadTaskStartListeners = new HashMap<>();
public NativeProductBridge(JSObject window) {
public NativeProductBridge(Object window) {
this.window = window;
}
@JSAccessible
@JsAccessible
@JSBridge
public boolean isProductDownloaded(String uuid) {
for (Group group : DefaultShareGroupManager.getInstance().getAllGroup()) {
@ -66,16 +66,17 @@ public class NativeProductBridge {
}
@JSAccessible
@JsAccessible
@JSBridge
public void addProductDownloadTaskStartListener(String json, JSFunction function) {
public void addProductDownloadTaskStartListener(String json, Object function) {
JSONObject object = new JSONObject(json);
OnlineShareWidget widget = OnlineShareWidget.parseFromJSONObject(object);
String uuid = widget.getUuid();
boolean isPackage = widget.isWidgetPackage();
Map<String, Set<JSFunction>> downloadTaskGetters =
Map<String, Set<Object>> downloadTaskGetters =
isPackage ? componentsPackageDownloadTaskStartListeners : componentDownloadTaskStartListeners;
Set<JSFunction> startListeners = downloadTaskGetters.get(widget.getUuid());
Set<Object> startListeners = downloadTaskGetters.get(widget.getUuid());
if (startListeners == null) {
startListeners = new HashSet<>();
}
@ -86,16 +87,17 @@ public class NativeProductBridge {
}
@JSAccessible
@JsAccessible
@JSBridge
public void removeProductDownloadTaskStartListener(String json, JSFunction function) {
public void removeProductDownloadTaskStartListener(String json, Object function) {
JSONObject object = new JSONObject(json);
OnlineShareWidget widget = OnlineShareWidget.parseFromJSONObject(object);
String uuid = widget.getUuid();
boolean isPackage = widget.isWidgetPackage();
Map<String, Set<JSFunction>> downloadTaskGetters = isPackage ? componentsPackageDownloadTaskStartListeners : componentDownloadTaskStartListeners;
Map<String, Set<Object>> downloadTaskGetters = isPackage ? componentsPackageDownloadTaskStartListeners : componentDownloadTaskStartListeners;
Set<JSFunction> startListeners = downloadTaskGetters.get(uuid);
Set<Object> startListeners = downloadTaskGetters.get(uuid);
if (startListeners == null) {
startListeners = new HashSet<>();
}
@ -104,6 +106,7 @@ public class NativeProductBridge {
}
@JSAccessible
@JsAccessible
@JSBridge
public Object getExecutingProductDownloadTask(String json) {
JSONObject object = new JSONObject(json);
@ -121,22 +124,24 @@ public class NativeProductBridge {
}
@JSAccessible
@JsAccessible
@JSBridge
public Object createProductDownloadTask(String json) {
JSONObject object = new JSONObject(json);
OnlineShareWidget widget = OnlineShareWidget.parseFromJSONObject(object);
int childrenCount = object.optInt("pkgsize", 0);
if (childrenCount > 0) {
return new ComponentsPackageInstallationTask(window, widget, childrenCount);
return new ComponentsPackageInstallationTask(this, window, widget, childrenCount);
} else {
return new ComponentInstallationTask(window, widget);
return new ComponentInstallationTask(this, window, widget);
}
}
@JSAccessible
@JsAccessible
@JSBridge
public void addThemeDownloadTaskStartListener(String themePath, JSFunction function) {
Set<JSFunction> startListeners = themeDownloadTaskStartListeners.get(themePath);
public void addThemeDownloadTaskStartListener(String themePath, Object function) {
Set<Object> startListeners = themeDownloadTaskStartListeners.get(themePath);
if (startListeners == null) {
startListeners = new HashSet<>();
}
@ -145,9 +150,10 @@ public class NativeProductBridge {
}
@JSAccessible
@JsAccessible
@JSBridge
public void removeThemeDownloadTaskStartListener(String themePath, JSFunction function) {
Set<JSFunction> startListeners = themeDownloadTaskStartListeners.get(themePath);
public void removeThemeDownloadTaskStartListener(String themePath, Object function) {
Set<Object> startListeners = themeDownloadTaskStartListeners.get(themePath);
if (startListeners == null) {
startListeners = new HashSet<>();
}
@ -156,9 +162,10 @@ public class NativeProductBridge {
}
@JSAccessible
@JsAccessible
@JSBridge
public Object getExecutingThemeDownloadTask(String themePath) {
NativeTaskBridge task = executingTemplateThemeInstallationTasks.get(themePath);
NativeTaskBridge task = (NativeTaskBridge) executingTemplateThemeInstallationTasks.get(themePath);
if (task != null) {
task.checkJSEnvChange(this.window);
}
@ -166,17 +173,20 @@ public class NativeProductBridge {
}
@JSAccessible
@JsAccessible
@JSBridge
public Object createTemplateThemeDownloadTask(String themePath) {
return new TemplateThemeInstallationTask(window, themePath);
return new TemplateThemeInstallationTask(this, window, themePath);
}
public class ComponentInstallationTask extends NativeTaskBridge {
public static class ComponentInstallationTask extends NativeTaskBridge {
private final NativeProductBridge env;
private final OnlineShareWidget widget;
private final ComponentInstallation action;
public ComponentInstallationTask(JSObject window, OnlineShareWidget widget) {
public ComponentInstallationTask(NativeProductBridge env, Object window, OnlineShareWidget widget) {
super(window);
this.env = env;
this.widget = widget;
action = new ComponentInstallation(widget);
action.setActionListener(new AsyncInstallation.AsyncActionListener() {
@ -203,6 +213,7 @@ public class NativeProductBridge {
}
@JSAccessible
@JsAccessible
@JSBridge
@Override
public void execute() {
@ -231,6 +242,7 @@ public class NativeProductBridge {
}
@JSAccessible
@JsAccessible
@JSBridge
@Override
public void cancel() {
@ -246,8 +258,8 @@ public class NativeProductBridge {
@Override
protected void fireStartEvent(String event) {
executingComponentInstallationTasks.put(widget.getUuid(), this);
Set<JSFunction> startListeners = componentDownloadTaskStartListeners.get(widget.getUuid());
SafeJSFunctionInvoker.invoke(startListeners, window);
Set<Object> startListeners = env.componentDownloadTaskStartListeners.get(widget.getUuid());
SafeJSFunctionInvoker.invoke(startListeners, env.window);
super.fireStartEvent(event);
}
@ -264,14 +276,16 @@ public class NativeProductBridge {
}
}
public class ComponentsPackageInstallationTask extends NativeTaskBridge {
public static class ComponentsPackageInstallationTask extends NativeTaskBridge {
private final NativeProductBridge env;
private final ComponentsPackageInstallation action;
private final OnlineShareWidget widget;
private final int childrenCount;
public ComponentsPackageInstallationTask(JSObject window, OnlineShareWidget widget, int childrenCount) {
public ComponentsPackageInstallationTask(NativeProductBridge env, Object window, OnlineShareWidget widget, int childrenCount) {
super(window);
this.env = env;
this.widget = widget;
this.childrenCount = childrenCount;
action = new ComponentsPackageInstallation(widget, childrenCount);
@ -299,6 +313,7 @@ public class NativeProductBridge {
}
@JSAccessible
@JsAccessible
@JSBridge
@Override
public void execute() {
@ -343,6 +358,7 @@ public class NativeProductBridge {
}
@JSAccessible
@JsAccessible
@JSBridge
@Override
public void cancel() {
@ -360,8 +376,8 @@ public class NativeProductBridge {
executingComponentsPackageInstallationTasks.put(widget.getUuid(), this);
super.fireStartEvent(event);
Set<JSFunction> startListeners = componentsPackageDownloadTaskStartListeners.get(widget.getUuid());
SafeJSFunctionInvoker.invoke(startListeners, window);
Set<Object> startListeners = env.componentsPackageDownloadTaskStartListeners.get(widget.getUuid());
SafeJSFunctionInvoker.invoke(startListeners, env.window);
}
@Override
@ -377,11 +393,13 @@ public class NativeProductBridge {
}
}
public class TemplateThemeInstallationTask extends NativeTaskBridge {
public static class TemplateThemeInstallationTask extends NativeTaskBridge {
private final NativeProductBridge env;
private final String themePath;
private final TemplateThemeInstallation action;
public TemplateThemeInstallationTask(JSObject window, String themePath) {
public TemplateThemeInstallationTask(NativeProductBridge env, Object window, String themePath) {
super(window);
this.env = env;
this.themePath = themePath;
Window miniShopWindow = MiniComponentShopDialog.getInstance().getWindow();
action = new TemplateThemeInstallation(miniShopWindow, themePath);
@ -404,6 +422,7 @@ public class NativeProductBridge {
}
@JSAccessible
@JsAccessible
@JSBridge
@Override
public void execute() {
@ -418,6 +437,7 @@ public class NativeProductBridge {
}
@JSAccessible
@JsAccessible
@JSBridge
@Override
public void cancel() {
@ -433,8 +453,8 @@ public class NativeProductBridge {
@Override
protected void fireStartEvent(String event) {
executingTemplateThemeInstallationTasks.put(themePath, this);
Set<JSFunction> startListeners = themeDownloadTaskStartListeners.get(themePath);
SafeJSFunctionInvoker.invoke(startListeners, window);
Set<Object> startListeners = env.themeDownloadTaskStartListeners.get(themePath);
SafeJSFunctionInvoker.invoke(startListeners, env.window);
super.fireStartEvent(event);
}

21
designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/mini/bridge/NativeTaskBridge.java

@ -4,12 +4,9 @@ import com.fr.design.bridge.exec.JSBridge;
import com.fr.design.mainframe.share.mini.MiniShopNativeTask;
import com.fr.design.mainframe.share.mini.MiniShopNativeTaskManager;
import com.teamdev.jxbrowser.chromium.JSAccessible;
import com.teamdev.jxbrowser.chromium.JSFunction;
import com.teamdev.jxbrowser.chromium.JSObject;
import com.teamdev.jxbrowser.js.JsAccessible;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/**
@ -19,14 +16,14 @@ import java.util.Set;
*/
public class NativeTaskBridge implements MiniShopNativeTask {
private JSObject window;
protected final Set<JSFunction> statusCbs = new HashSet<>();
private Object window;
protected final Set<Object> statusCbs = new HashSet<>();
public NativeTaskBridge(JSObject window) {
public NativeTaskBridge(Object window) {
this.window = window;
}
public void checkJSEnvChange(JSObject window) {
public void checkJSEnvChange(Object window) {
if (this.window != window) {
this.window = window;
this.statusCbs.clear();
@ -35,24 +32,28 @@ public class NativeTaskBridge implements MiniShopNativeTask {
@JSBridge
@JSAccessible
public void addStatusCallback(JSFunction cb) {
@JsAccessible
public void addStatusCallback(Object cb) {
this.statusCbs.add(cb);
}
@JSBridge
@JSAccessible
public void removeStatusCallback(JSFunction cb) {
@JsAccessible
public void removeStatusCallback(Object cb) {
this.statusCbs.remove(cb);
}
@JSBridge
@JSAccessible
@JsAccessible
@Override
public void execute() {
}
@JSBridge
@JSAccessible
@JsAccessible
@Override
public void cancel() {
MiniShopNativeTaskManager.getInstance().removeCompletedTask(this);

29
designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/mini/bridge/SafeJSFunctionInvoker.java

@ -2,6 +2,8 @@ package com.fr.design.mainframe.share.ui.online.mini.bridge;
import com.teamdev.jxbrowser.chromium.JSFunction;
import com.teamdev.jxbrowser.chromium.JSObject;
import com.teamdev.jxbrowser.js.JsFunction;
import com.teamdev.jxbrowser.js.JsObject;
import java.util.Collection;
@ -12,18 +14,31 @@ import java.util.Collection;
*/
public class SafeJSFunctionInvoker {
public static void invoke(Collection<JSFunction> functions, JSObject instance, Object... args) {
public static void invoke(Collection<Object> functions, Object instance, Object... args) {
if (functions != null) {
for (JSFunction function: functions) {
if (function != null && !function.getContext().isDisposed()) {
function.invoke(instance, args);
}
for (Object function: functions) {
invoke(function, instance, args);
}
}
}
public static void invoke(JSFunction function, JSObject instance, Object... args) {
if (function != null && !function.getContext().isDisposed()) {
public static void invoke(Object function, Object instance, Object... args) {
if (function != null) {
if (function instanceof JSFunction && instance instanceof JSObject) {
invokeV6((JSFunction) function, (JSObject) instance, args);
} else if (function instanceof JsFunction && instance instanceof JsObject) {
invokeV7((JsFunction) function, (JsObject) instance, args);
}
}
}
private static void invokeV6(JSFunction function, JSObject instance, Object... args) {
if (!function.getContext().isDisposed()) {
function.invoke(instance, args);
}
}
private static void invokeV7(JsFunction function, JsObject instance, Object... args) {
function.invoke(instance, args);
}
}

171
designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java

@ -12,10 +12,8 @@ import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.layout.VerticalFlowLayout;
@ -60,8 +58,6 @@ public class CellOtherSetPane extends AbstractCellAttrPane {
private static final int HEAD_HEIGTH = 24;
private static final int COMBO_WIDTH = 154;
private static final int BUTTON_GROUP_WIDTH = 140;
private static final double f = TableLayout.FILL;
private static final double p = TableLayout.PREFERRED;
// normal
private UIButtonGroup autoshrik;
@ -71,20 +67,8 @@ public class CellOtherSetPane extends AbstractCellAttrPane {
private UIComboBox showContent;
//内容提示
private UIButtonGroup tooltipButtonGroup;
private CardLayout tooltipLayout;
private JPanel tooltipPane;
private UITextField tooltipTextField;
//文本超出时隐藏
private UICheckBox textOverflowCheckBox;
private UIComboBox showPartComboBox;
private CardLayout showPartLayout;
private JPanel showPartPane;
private UISpinner showCharNums;
private UIComboBox textOverflowTypeComboBox;
private UITextField fileNameTextField;
// 分页
@ -230,16 +214,17 @@ public class CellOtherSetPane extends AbstractCellAttrPane {
private JPanel seniorUpPane() {
JPanel pane = new JPanel(new BorderLayout());
// TODO: 方法之间的耦合还比较严重。现在必须先执行 createShowContentPane,再执行 createSeniorCheckPane。否则出现 npe。
pane.add(createTextOverflowPane(), BorderLayout.SOUTH);
pane.add(createShowContentPane(), BorderLayout.CENTER);
pane.add(createSeniorCheckPane(), BorderLayout.NORTH);
return pane;
}
private JPanel createShowContentPane() {
double[] rowSize = {p, p, p, p};
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
double[] rowSize = {p, p, p};
double[] colSize = {f, COMBO_WIDTH};
int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}};
int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}};
JPanel fileNamePane = createNormal();
fileNamePane.setBorder(BorderFactory.createEmptyBorder(0,12,0,0));
@ -248,96 +233,21 @@ public class CellOtherSetPane extends AbstractCellAttrPane {
UIComponentUtils.setLineWrap(showContentLabel);
UILabel toolTipLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_CellWrite_ToolTip"));
tooltipLayout = new CardLayout();
tooltipPane = new JPanel(tooltipLayout);
tooltipPane.add(new JPanel(), "none");
tooltipPane.add(tooltipTextField, "content");
tooltipPane.setPreferredSize(new Dimension(0, 0));
tooltipButtonGroup = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Report_CellWrite_ToolTip_Custom"), Toolkit.i18nText("Fine-Design_Report_CellWrite_ToolTip_CellValue")});
tooltipButtonGroup.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (tooltipButtonGroup.getSelectedIndex() == 0) {
tooltipPane.setPreferredSize(new Dimension(154, 20));
tooltipLayout.show(tooltipPane, "content");
} else {
tooltipLayout.show(tooltipPane, "none");
tooltipPane.setPreferredSize(new Dimension(0, 0));
}
}
});
JPanel toolTipTextFieldWrapper = new JPanel(new BorderLayout());
toolTipTextFieldWrapper.add(tooltipTextField, BorderLayout.NORTH);
Component[][] components = new Component[][]{
new Component[]{showContentLabel, UIComponentUtils.wrapWithBorderLayoutPane(showContent)},
new Component[]{fileNamePane, null}, // 选择"用下载连接显示二进制内容"时,会显示这一行的面板
new Component[]{toolTipLabel, tooltipButtonGroup}, // “自定义”or"单元格值"
new Component[]{null, tooltipPane} // 选择“自定义”时显示这一行
new Component[]{toolTipLabel, toolTipTextFieldWrapper}
};
JPanel showContentPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, colSize, rowCount, LayoutConstants.VGAP_LARGE, LayoutConstants.VGAP_MEDIUM);
showContentPane.setBorder(BorderFactory.createEmptyBorder(6, 0, 6, 0));
showContentPane.setBorder(BorderFactory.createEmptyBorder(6, 0, 12, 0));
return showContentPane;
}
private JPanel createTextOverflowPane() {
showPartLayout = new CardLayout();
showPartPane = new JPanel(showPartLayout);
showCharNums = new UISpinner(0, Integer.MAX_VALUE, 1, 10);
JPanel showPartNumPane = new JPanel(new BorderLayout(4, 0));
showPartNumPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_Nums")), BorderLayout.WEST);
showPartNumPane.add(showCharNums, BorderLayout.CENTER);
showPartPane.add(new JPanel(), "none");
showPartPane.add(showPartNumPane, "content");
showPartComboBox = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_CharNum"), Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_CellWidth")});
showPartComboBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (showPartComboBox.getSelectedIndex() == 0) {
showPartPane.setPreferredSize(new Dimension(70, 20));
showPartLayout.show(showPartPane, "content");
} else {
showPartLayout.show(showPartPane, "none");
showPartPane.setPreferredSize(new Dimension(0, 0));
}
}
});
textOverflowTypeComboBox = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_Ellipsis"), Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_NoneSymbol")});
UILabel showPartLabel = new UILabel(Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_ShowPart") + ":");
UILabel hideTypeLabel = new UILabel(Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_HideType") + ":");
Component[][] textOverflowComponents = new Component[][]{
new Component[]{showPartLabel, showPartComboBox, showPartPane},
new Component[]{hideTypeLabel, textOverflowTypeComboBox, null}
};
JPanel textOverflowComPane = TableLayoutHelper.createTableLayoutPane(textOverflowComponents, new double[]{p, p}, new double[]{p, f, p});
textOverflowComPane.setVisible(false);
textOverflowCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_HideWhenOverflow"));
textOverflowCheckBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
textOverflowComPane.setVisible(e.getStateChange() == ItemEvent.SELECTED);
if (e.getStateChange() == ItemEvent.SELECTED) {
if (showPartComboBox.getSelectedIndex() == 0) {
showPartPane.setPreferredSize(new Dimension(70, 20));
showPartLayout.show(showPartPane, "content");
} else {
showPartLayout.show(showPartPane, "none");
showPartPane.setPreferredSize(new Dimension(0, 0));
}
noAutoRadioButton.setSelected(true);
}
}
});
JPanel dynamicPaneWrapper = FRGUIPaneFactory.createBorderLayout_S_Pane();
dynamicPaneWrapper.add(textOverflowComPane);
JPanel textOverflowPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
textOverflowPane.add(textOverflowCheckBox, BorderLayout.NORTH);
textOverflowPane.add(dynamicPaneWrapper, BorderLayout.CENTER);
textOverflowPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
return textOverflowPane;
}
private JPanel createSeniorCheckPane() {
previewCellContent.setBorder(UIConstants.CELL_ATTR_ZEROBORDER);
printAndExportContent.setBorder(UIConstants.CELL_ATTR_ZEROBORDER);
@ -461,11 +371,6 @@ public class CellOtherSetPane extends AbstractCellAttrPane {
insertRowPolicyButtonGroup.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_CellWrite_InsertRow_Policy"));
valueEditor.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_CellWrite_InsertRow_Policy"));
pageFixedRowDataCheckBox.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_CellWrite_Page_Fixed_Row_Cell"));
tooltipButtonGroup.setGlobalName(Toolkit.i18nText("Fine-Design_Report_CellWrite_ToolTip_Button_Group"));
textOverflowCheckBox.setGlobalName(Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_HideWhenOverflow"));
showPartComboBox.setGlobalName(Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_ShowPart"));
showCharNums.setGlobalName(Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_Nums"));
textOverflowTypeComboBox.setGlobalName(Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_HideType"));
}
@ -524,40 +429,7 @@ public class CellOtherSetPane extends AbstractCellAttrPane {
} else {
showContent.setSelectedItem(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Default"));
}
if (cellGUIAttr.isCustomTooltip()) {
tooltipButtonGroup.setSelectedIndex(0);
tooltipTextField.setText(cellGUIAttr.getTooltipText());
} else {
tooltipButtonGroup.setSelectedIndex(1);
}
if (tooltipButtonGroup.getSelectedIndex() == 0) {
tooltipPane.setPreferredSize(new Dimension(100, 20));
tooltipLayout.show(tooltipPane, "content");
} else {
tooltipLayout.show(tooltipPane, "none");
tooltipPane.setPreferredSize(new Dimension(0, 0));
}
tooltipPane.setVisible(true);
if (cellGUIAttr.isHideTextWhenOverflow()) {
textOverflowCheckBox.setSelected(true);
if (cellGUIAttr.isShowCharNum()) {
showPartComboBox.setSelectedIndex(0);
showCharNums.setValue(cellGUIAttr.getShowCharNums());
} else {
showPartComboBox.setSelectedIndex(1);
}
showPartPane.setVisible(true);
if (cellGUIAttr.isTextOverflowEllipsis()) {
textOverflowTypeComboBox.setSelectedItem(Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_Ellipsis"));
} else {
textOverflowTypeComboBox.setSelectedItem(Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_NoneSymbol"));
}
} else {
showPartComboBox.setSelectedIndex(0);
showCharNums.setValue(cellGUIAttr.getShowCharNums());
textOverflowTypeComboBox.setSelectedIndex(0);
textOverflowCheckBox.setSelected(false);
}
tooltipTextField.setText(cellGUIAttr.getTooltipText());
CellPageAttr cellPageAttr = cellElement.getCellPageAttr(); // 分页
if (cellPageAttr == null) {
cellPageAttr = new CellPageAttr();
@ -649,18 +521,7 @@ public class CellOtherSetPane extends AbstractCellAttrPane {
cellGUIAttr.setFileName(fileNameTextField.getText());
}
}
if (ComparatorUtils.equals(getGlobalName(), Toolkit.i18nText("Fine-Design_Report_CellWrite_ToolTip_Button_Group"))) {
cellGUIAttr.setCustomTooltip(tooltipButtonGroup.getSelectedIndex() == 0);
if (tooltipButtonGroup.getSelectedIndex() == 0) {
if (tooltipTextField.getText() == null || tooltipTextField.getText().trim().length() <= 0) {
cellGUIAttr.setTooltipText(fieldName);
} else {
cellGUIAttr.setTooltipText(tooltipTextField.getText());
}
} else if (tooltipButtonGroup.getSelectedIndex() == 1) {
cellGUIAttr.setTooltipText("=$$$");
}
}
if (ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_CellWrite_ToolTip"))) {
if (tooltipTextField.getText() == null || tooltipTextField.getText().trim().length() <= 0) {
cellGUIAttr.setTooltipText(fieldName);
@ -668,18 +529,6 @@ public class CellOtherSetPane extends AbstractCellAttrPane {
cellGUIAttr.setTooltipText(tooltipTextField.getText());
}
}
if (ComparatorUtils.equals(getGlobalName(), Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_HideWhenOverflow"))) {
cellGUIAttr.setHideTextWhenOverflow(textOverflowCheckBox.isSelected());
}
if (ComparatorUtils.equals(getGlobalName(), Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_ShowPart"))) {
cellGUIAttr.setShowCharNum(showPartComboBox.getSelectedIndex() == 0);
}
if (ComparatorUtils.equals(getGlobalName(), Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_Nums"))) {
cellGUIAttr.setShowCharNums((int) showCharNums.getValue());
}
if (ComparatorUtils.equals(getGlobalName(), Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_HideType"))) {
cellGUIAttr.setTextOverflowEllipsis(textOverflowTypeComboBox.getSelectedIndex() == 0);
}
// 如果与默认的CellGUIAttr相同,就不用保存这个属性了
if (ComparatorUtils.equals(cellGUIAttr, CellGUIAttr.DEFAULT_CELLGUIATTR)) {
cellElement.setCellGUIAttr(cellNullGUIAttr);

Loading…
Cancel
Save