From d963ee47e3a51e35bc55d5cc25d8b1503beb9807 Mon Sep 17 00:00:00 2001 From: vito Date: Mon, 26 Aug 2024 18:17:28 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-131584=20=E5=88=A4=E9=87=8D=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=9B=86=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datapane/TableDataCreatorProducer.java | 4 +- ...JSBridge.java => DCTableDataJSBridge.java} | 17 ++++---- ...acentersPane.java => DCTableDataPane.java} | 40 ++++++------------- .../tabledata/wrapper/TableDataFactory.java | 4 +- 4 files changed, 26 insertions(+), 39 deletions(-) rename designer-base/src/main/java/com/fr/design/data/tabledata/datacenter/{DatacentersJSBridge.java => DCTableDataJSBridge.java} (91%) rename designer-base/src/main/java/com/fr/design/data/tabledata/datacenter/{DatacentersPane.java => DCTableDataPane.java} (79%) diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataCreatorProducer.java b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataCreatorProducer.java index c1adf134a4..2dcaea1aaa 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataCreatorProducer.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataCreatorProducer.java @@ -14,7 +14,7 @@ import com.fine.theme.icon.LazyIcon; import com.fr.data.impl.storeproc.StoreProcedure; import com.fr.datacenters.tabledata.DCTableData; import com.fr.design.ExtraDesignClassManager; -import com.fr.design.data.tabledata.datacenter.DatacentersPane; +import com.fr.design.data.tabledata.datacenter.DCTableDataPane; import com.fr.design.data.tabledata.tabledatapane.ClassTableDataPane; import com.fr.design.data.tabledata.tabledatapane.DBTableDataPane; import com.fr.design.data.tabledata.tabledatapane.EmbeddedTableDataPane; @@ -95,7 +95,7 @@ public class TableDataCreatorProducer { return new TableDataNameObjectCreator[]{ new TableDataNameObjectCreator(i18nText("Fine-Design_Basic_DS_Datacenters"), new LazyIcon("datacenter"), - DCTableData.class, DatacentersPane.class) { + DCTableData.class, DCTableDataPane.class) { @Override public boolean shouldInsertSeparator() { return true; diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/datacenter/DatacentersJSBridge.java b/designer-base/src/main/java/com/fr/design/data/tabledata/datacenter/DCTableDataJSBridge.java similarity index 91% rename from designer-base/src/main/java/com/fr/design/data/tabledata/datacenter/DatacentersJSBridge.java rename to designer-base/src/main/java/com/fr/design/data/tabledata/datacenter/DCTableDataJSBridge.java index f8e164dccf..c5f25d68aa 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/datacenter/DatacentersJSBridge.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/datacenter/DCTableDataJSBridge.java @@ -4,6 +4,7 @@ import com.fr.base.BaseFormula; import com.fr.datacenters.tabledata.bean.DCFilterQueryBean; import com.fr.datacenters.tabledata.bean.DCTableDataBean; import com.fr.datacenters.tabledata.filter.DCFilter; +import com.fr.datacenters.tabledata.parameter.DCParameter; import com.fr.design.bridge.exec.JSBridge; import com.fr.design.dialog.DialogActionListener; import com.fr.design.dialog.UIDialog; @@ -37,7 +38,7 @@ import java.util.stream.Collectors; * Created on 2024/6/17 */ @JsAccessible -public class DatacentersJSBridge { +public class DCTableDataJSBridge { private static final String EVENT_FORMULA_UPDATE = "OK"; private static final String EVENT_FORMULA_CANCEL = "CANCEL"; @@ -47,25 +48,25 @@ public class DatacentersJSBridge { * @param window js环境的window对象 * @return 桥接实例 */ - public static DatacentersJSBridge getBridge(JsObject window) { - return new DatacentersJSBridge(window); + public static DCTableDataJSBridge getBridge(JsObject window) { + return new DCTableDataJSBridge(window); } private final JsObject window; - private DatacentersJSBridge(JsObject window) { + private DCTableDataJSBridge(JsObject window) { this.window = window; } - private static DatacentersPane relationPanel; + private static DCTableDataPane relationPanel; /** * 设置窗口,用于打开对话框的层级 * * @param panel 面板 */ - public static void relationPanel(DatacentersPane panel) { + public static void relationPanel(DCTableDataPane panel) { relationPanel = panel; } @@ -161,7 +162,9 @@ public class DatacentersJSBridge { JxUIPane.DEFAULT_EXECUTOR.submit(() -> { try { DCTableDataBean decoded = EmbedJson.decodeValue(tableData, DCTableDataBean.class); - DCFilter dcFilter = decoded.getFilter().evalValue(decoded.getParameters(), Calculator.createCalculator()); + DCParameter[] dcParameters = Arrays.stream(decoded.getParameters()) + .map(DCParameter::fromBean).toArray(DCParameter[]::new); + DCFilter dcFilter = decoded.getFilter().evalValue(dcParameters, Calculator.createCalculator()); DCFilterQueryBean queryBean = dcFilter.toQueryBean(); String encode = EmbedJson.encode(queryBean); callback.invoke(window, encode); diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/datacenter/DatacentersPane.java b/designer-base/src/main/java/com/fr/design/data/tabledata/datacenter/DCTableDataPane.java similarity index 79% rename from designer-base/src/main/java/com/fr/design/data/tabledata/datacenter/DatacentersPane.java rename to designer-base/src/main/java/com/fr/design/data/tabledata/datacenter/DCTableDataPane.java index 62679018d4..766e57ec20 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/datacenter/DatacentersPane.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/datacenter/DCTableDataPane.java @@ -4,6 +4,7 @@ import com.fanruan.workplace.http.ServiceType; import com.fr.datacenters.tabledata.DCTableData; import com.fr.datacenters.tabledata.bean.DCNameBean; import com.fr.datacenters.tabledata.bean.DCTableDataBean; +import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane; import com.fr.design.dialog.DialogActionListener; import com.fr.design.dialog.UIDialog; @@ -14,10 +15,15 @@ import com.fr.json.revise.EmbedJson; import com.fr.stable.StringUtils; import com.fr.third.guava.collect.ImmutableMap; import com.fr.workspace.WorkContext; +import com.teamdev.jxbrowser.browser.callback.InjectJsCallback; import javax.swing.SwingUtilities; import java.awt.BorderLayout; import java.awt.Window; +import java.util.Arrays; + +import static com.fr.design.ui.ModernUIConstants.DOT; +import static com.fr.design.ui.ModernUIConstants.WINDOW; /** * 数据中心数据集面板 @@ -26,7 +32,7 @@ import java.awt.Window; * @since 11.0 * Created on 2024/6/17 */ -public class DatacentersPane extends AbstractTableDataPane { +public class DCTableDataPane extends AbstractTableDataPane { private static final JxEngine JX_ENGINE = JxEngine.newInstance(false); @@ -37,31 +43,7 @@ public class DatacentersPane extends AbstractTableDataPane { // 用于复制粘贴场景 private DCTableData dcTableData; - /** - * 借用,只运行一次 - */ - private void addDialogActionListener() { - - // 保证在窗口加载完成后执行 - SwingUtilities.invokeLater(() -> { - Window ancestor = SwingUtilities.getWindowAncestor(DatacentersPane.this); - if (ancestor instanceof UIDialog) { - ((UIDialog) ancestor).addDialogActionListener(new DialogActionListener() { - @Override - public void doOk() { - dataCenterJxUIPane.disposeBrowser(); - } - - @Override - public void doCancel() { - dataCenterJxUIPane.disposeBrowser(); - } - }); - } - }); - } - - public DatacentersPane() { + public DCTableDataPane() { setLayout(new BorderLayout()); dataCenterJxUIPane = getJxUIPane(); add(dataCenterJxUIPane, BorderLayout.CENTER); @@ -73,7 +55,7 @@ public class DatacentersPane extends AbstractTableDataPane { return new JxUIPane.Builder() .engine(JX_ENGINE) .namespace(DATA_CENTER) - .bindWindow(DATA_CENTER_HELPER, DatacentersJSBridge::getBridge) + .bindWindow(DATA_CENTER_HELPER, DCTableDataJSBridge::getBridge) .withEMB("com/fr/design/data/tabledata/datacenter/web/data-choose.prod.html", ImmutableMap.of("fineServletURL", getDatacentersUrl())) .build(); @@ -96,9 +78,11 @@ public class DatacentersPane extends AbstractTableDataPane { @Override public void populateBean(DCTableData ob) { - DatacentersJSBridge.relationPanel(this); + DCTableDataJSBridge.relationPanel(this); dcTableData = ob; dataCenterJxUIPane.populate(EmbedJson.encode(ob.toBean())); + String[] allDSNames = DesignTableDataManager.getAllDSNames(DesignTableDataManager.getEditingTableDataSource()); + dataCenterJxUIPane.executeJS(DATA_CENTER + DOT + "datasetNames=" + EmbedJson.encode(allDSNames)); } diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/TableDataFactory.java b/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/TableDataFactory.java index 096fcc420d..6d87a2c1bc 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/TableDataFactory.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/TableDataFactory.java @@ -15,7 +15,7 @@ import com.fr.data.impl.storeproc.StoreProcedure; import com.fr.datacenters.tabledata.DCTableData; import com.fr.decision.webservice.bean.dataset.ServerDataSetBean; import com.fr.design.data.datapane.TableDataNameObjectCreator; -import com.fr.design.data.tabledata.datacenter.DatacentersPane; +import com.fr.design.data.tabledata.datacenter.DCTableDataPane; import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane; import com.fr.design.data.tabledata.tabledatapane.ClassTableDataPane; import com.fr.design.data.tabledata.tabledatapane.DBTableDataPane; @@ -79,7 +79,7 @@ public abstract class TableDataFactory { i18nText("Fine-Design_Basic_DS_Datacenters"), new LazyIcon("datacenter"), DCTableData.class, - DatacentersPane.class)); + DCTableDataPane.class)); map.putAll(defaultMap); }