Browse Source

REPORT-132414 & REPORT-132506 优化菜单入口修复弹窗等

fbp/merge
vito 4 months ago
parent
commit
3ff87754b5
  1. 59
      designer-base/src/main/java/com/fr/design/data/tabledata/datacenter/DCTableDataPane.java
  2. 46
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/TableDataPaneHelper.java
  3. 14
      designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/TableDataFactory.java
  4. 17
      designer-base/src/main/java/com/fr/design/gui/controlpane/JControlUpdatePane.java
  5. 44
      designer-base/src/main/java/com/fr/design/jxbrowser/JxUIPane.java
  6. 29
      designer-base/src/test/java/com/fr/design/ui/report/ReportServerParamDemo.java

59
designer-base/src/main/java/com/fr/design/data/tabledata/datacenter/DCTableDataPane.java

@ -6,8 +6,6 @@ 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;
import com.fr.design.i18n.Toolkit;
import com.fr.design.jxbrowser.JxEngine;
import com.fr.design.jxbrowser.JxUIPane;
@ -15,15 +13,13 @@ 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;
import static com.fr.design.ui.ModernUIConstants.EMB_TAG;
import static com.fr.design.ui.ModernUIConstants.SCHEME_HEADER;
/**
* 数据中心数据集面板
@ -38,26 +34,40 @@ public class DCTableDataPane extends AbstractTableDataPane<DCTableData> {
private static final String DATA_CENTER = "dc";
private static final String DATA_CENTER_HELPER = "dcHelper";
private static final String DATA_CENTER_INJECT_URL = "fineServletURL";
private static final String DC_INDEX_HTML = "com/fr/design/data/tabledata/datacenter/web/data-choose.prod.html";
private final JxUIPane<String> dataCenterJxUIPane;
private JxTableDataNamePane namePane;
private final JxTableDataNamePane namePane = new JxTableDataNamePane(this);
// 用于复制粘贴场景
private DCTableData dcTableData;
/**
* 用于创建带有名称的面板
*
* @param name 名称
*/
public DCTableDataPane(String name) {
this();
namePane.setObjectName(name);
}
public DCTableDataPane() {
setLayout(new BorderLayout());
dataCenterJxUIPane = getJxUIPane();
add(dataCenterJxUIPane, BorderLayout.CENTER);
dataCenterJxUIPane.addXHRHeaders(ImmutableMap.of("Authorization",
WorkContext.getCurrent().getConnection().getToken()));
// 关联 bridge 和 pane
DCTableDataJSBridge.relationPanel(this);
}
private static JxUIPane<String> getJxUIPane() {
return new JxUIPane.Builder<String>()
.engine(JX_ENGINE)
.namespace(DATA_CENTER)
.bindWindow(DATA_CENTER_HELPER, DCTableDataJSBridge::getBridge)
.withEMB("com/fr/design/data/tabledata/datacenter/web/data-choose.prod.html",
ImmutableMap.of("fineServletURL", getDatacentersUrl()))
.withEMB(DC_INDEX_HTML, ImmutableMap.of(DATA_CENTER_INJECT_URL, getDatacentersUrl()))
.build();
}
@ -72,17 +82,37 @@ public class DCTableDataPane extends AbstractTableDataPane<DCTableData> {
@Override
public NamePane asNamePane() {
return namePane = new JxTableDataNamePane(this);
return namePane;
}
@Override
public void populateBean(DCTableData ob) {
DCTableDataJSBridge.relationPanel(this);
reload();
dcTableData = ob;
dataCenterJxUIPane.populate(EmbedJson.encode(ob.toBean()));
updateTableDataName(dcTableData, namePane.getObjectName());
dataCenterJxUIPane.populate(EmbedJson.encode(dcTableData.toBean()));
setDatasetNames(dcTableData);
}
private void reload() {
dataCenterJxUIPane.redirect(EMB_TAG + SCHEME_HEADER + DC_INDEX_HTML,
ImmutableMap.of(DATA_CENTER_INJECT_URL, getDatacentersUrl()));
}
private static void updateTableDataName(DCTableData dcTableData, String name) {
if (StringUtils.isNotBlank(name)) {
dcTableData.setDsName(name);
dcTableData.setName(name);
}
}
private void setDatasetNames(DCTableData ob) {
String[] allDSNames = DesignTableDataManager.getAllDSNames(DesignTableDataManager.getEditingTableDataSource());
dataCenterJxUIPane.executeJS(DATA_CENTER + DOT + "datasetNames=" + EmbedJson.encode(allDSNames));
String[] allName = Arrays.stream(allDSNames)
.filter(name -> !ob.getDsName().equals(name))
.toArray(String[]::new);
dataCenterJxUIPane.executeJS(DATA_CENTER + DOT + "datasetNames=" + EmbedJson.encode(allName));
}
@ -95,8 +125,7 @@ public class DCTableDataPane extends AbstractTableDataPane<DCTableData> {
return DCTableData.fromBean(tableDataBean);
} else {
// 复制的场景下,不打开界面需要返回数据集,需同步面板的名称
dcTableData.setDsName(namePane.getObjectName());
dcTableData.setName(namePane.getObjectName());
updateTableDataName(dcTableData, namePane.getObjectName());
return dcTableData;
}
}

46
designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/TableDataPaneHelper.java

@ -0,0 +1,46 @@
package com.fr.design.data.tabledata.tabledatapane;
import com.fr.base.AbstractTableData;
import com.fr.design.data.tabledata.datacenter.DCTableDataPane;
import com.fr.third.guava.collect.Sets;
import java.util.Set;
/**
* 数据集面板帮助类
*
* @author vito
* @since 11.0
* Created on 2024/9/10
*/
public class TableDataPaneHelper {
/**
* 标记优先使用带名称的构造方法
*/
private final static Set<Class<? extends AbstractTableDataPane<? extends AbstractTableData>>> NAMED_TABLE_DATA_PANE =
Sets.newHashSet(
MultiTDTableDataPane.class,
GlobalMultiTDTableDataPane.class,
TreeTableDataPane.class,
GlobalTreeTableDataPane.class,
DCTableDataPane.class);
/**
* 是否为带名称的数据集面板
*
* @param tableDataPaneClass 数据集面板类
* @return 是否为带名称的数据集面板
*/
public static boolean isNamedTableDataPane(Class<?> tableDataPaneClass) {
return NAMED_TABLE_DATA_PANE.contains(tableDataPaneClass);
}
/**
* 注册需要名称的数据集面板
*
* @param tableDataPaneClass 数据集面板类
*/
public static void registerNamedTableDataPane(Class<? extends AbstractTableDataPane<? extends AbstractTableData>> tableDataPaneClass) {
NAMED_TABLE_DATA_PANE.add(tableDataPaneClass);
}
}

14
designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/TableDataFactory.java

@ -16,6 +16,7 @@ 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.datapane.preview.ConnectionInfoBeanHelper;
import com.fr.design.data.datapane.preview.TableDataBeanHelper;
import com.fr.design.data.tabledata.datacenter.DCTableDataPane;
import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane;
import com.fr.design.data.tabledata.tabledatapane.ClassTableDataPane;
@ -25,13 +26,12 @@ import com.fr.design.data.tabledata.tabledatapane.EmbeddedTableDataPane;
import com.fr.design.data.tabledata.tabledatapane.FileTableDataPane;
import com.fr.design.data.tabledata.tabledatapane.MultiTDTableDataPane;
import com.fr.design.data.tabledata.tabledatapane.ProcedureDataPane;
import com.fr.design.data.tabledata.tabledatapane.TableDataPaneHelper;
import com.fr.design.data.tabledata.tabledatapane.TreeTableDataPane;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils;
import com.fr.workspace.server.repository.connection.ConnectionRepository;
import com.fr.design.data.datapane.preview.TableDataBeanHelper;
import com.fr.workspace.server.repository.tabledata.TableDataRepository;
import javax.swing.Icon;
@ -56,7 +56,7 @@ public abstract class TableDataFactory {
/**
* 有顺序的,用来排序用
*/
private static Map<String, TableDataNameObjectCreator> map = new java.util.LinkedHashMap<>();
private static Map<String, TableDataNameObjectCreator> map = new LinkedHashMap<>();
private static Map<String, TableDataNameObjectCreator> defaultMap = new LinkedHashMap<>();
@ -129,12 +129,12 @@ public abstract class TableDataFactory {
AbstractTableDataPane datapane = null;
TableDataNameObjectCreator tableDataNameObjectCreator = getTableDataNameObjectCreator(tabledata);
Class<? extends AbstractTableDataPane<?>> creatorClass = (Class<AbstractTableDataPane<?>>) tableDataNameObjectCreator.getUpdatePane();
if (tableDataNameObjectCreator != null && creatorClass != null) {
if (creatorClass != null) {
try {
if (ComparatorUtils.equals(creatorClass, MultiTDTableDataPane.class) || ComparatorUtils.equals(creatorClass, TreeTableDataPane.class)) {
Constructor constructor = creatorClass.getDeclaredConstructor(new Class[]{String.class});
if (TableDataPaneHelper.isNamedTableDataPane(creatorClass)) {
Constructor<? extends AbstractTableDataPane<?>> constructor = creatorClass.getDeclaredConstructor(String.class);
constructor.setAccessible(true);
datapane = (AbstractTableDataPane) constructor.newInstance(name);
datapane = constructor.newInstance(name);
} else {
datapane = creatorClass.newInstance();
}

17
designer-base/src/main/java/com/fr/design/gui/controlpane/JControlUpdatePane.java

@ -3,16 +3,12 @@ package com.fr.design.gui.controlpane;
import com.fr.data.impl.Connection;
import com.fr.design.DesignerEnvManager;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.data.tabledata.tabledatapane.GlobalMultiTDTableDataPane;
import com.fr.design.data.tabledata.tabledatapane.GlobalTreeTableDataPane;
import com.fr.design.data.tabledata.tabledatapane.MultiTDTableDataPane;
import com.fr.design.data.tabledata.tabledatapane.TreeTableDataPane;
import com.fr.design.data.tabledata.tabledatapane.TableDataPaneHelper;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.RemoteDesignerWorkspaceInfo;
import com.fr.design.gui.ilist.ListModelElement;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.form.event.Listener;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import javax.swing.JPanel;
@ -70,7 +66,7 @@ class JControlUpdatePane extends JPanel {
Object ob2Populate = creators[i].acceptObject2Populate(el.wrapper);
if (ob2Populate != null) {
if (updatePanes[i] == null) {
if (isMulti(creators[i].getUpdatePane()) || isTree(creators[i].getUpdatePane())) {
if (TableDataPaneHelper.isNamedTableDataPane(creators[i].getUpdatePane())) {
updatePanes[i] = listControlPane.createPaneByCreators(creators[i], el.wrapper.getName());
} else {
updatePanes[i] = listControlPane.createPaneByCreators(creators[i]);
@ -94,15 +90,6 @@ class JControlUpdatePane extends JPanel {
}
}
public boolean isMulti(Class _class) {
return ComparatorUtils.equals(_class, GlobalMultiTDTableDataPane.class) || ComparatorUtils.equals(_class, MultiTDTableDataPane.class);
}
public boolean isTree(Class _class) {
return ComparatorUtils.equals(_class, GlobalTreeTableDataPane.class) || ComparatorUtils.equals(_class, TreeTableDataPane.class);
}
public void update() {
NameableCreator[] creators = listControlPane.creators();
for (int i = 0; i < updatePanes.length; i++) {

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

@ -1,7 +1,6 @@
package com.fr.design.jxbrowser;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.design.DesignerEnvManager;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.itoolbar.UIToolbar;
@ -29,6 +28,7 @@ import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.function.Consumer;
import static com.fr.design.ui.ModernUIConstants.COMPONENT_TAG;
import static com.fr.design.ui.ModernUIConstants.DEFAULT_EXPRESSION;
@ -99,17 +99,17 @@ public class JxUIPane<T> extends BasicPane {
*/
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);
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);
}
}
@ -191,6 +191,14 @@ public class JxUIPane<T> extends BasicPane {
.ifPresent(ns -> ns.putProperty(variable, t));
return InjectJsCallback.Response.proceed();
});
if (browser.mainFrame().isPresent()) {
executeJavaScript(WINDOW + DOT + namespace,
(Consumer<JsObject>) jsObject -> {
if (Objects.nonNull(jsObject)) {
jsObject.putProperty(variable, t);
}
});
}
}
@Nullable
@ -235,6 +243,18 @@ public class JxUIPane<T> extends BasicPane {
}
}
/**
* 执行一段js
*
* @param javaScript 待执行的js脚本
* @see JxUIPane#executeJS(String)
*/
public <T> void executeJavaScript(String javaScript, Consumer<T> consumer) {
if (browser != null) {
browser.mainFrame().ifPresent(frame -> frame.executeJavaScript(javaScript, consumer));
}
}
/**
* 获取js对象
* 注意类内部使用用于简化编码提供 Optional 包装

29
designer-base/src/test/java/com/fr/design/ui/report/ReportServerParamDemo.java

@ -1,29 +0,0 @@
package com.fr.design.ui.report;
import com.fr.design.DesignerEnvManager;
import com.fr.design.ui.ModernUIPane;
import com.fr.design.ui.ModernUIPaneTest;
import javax.swing.*;
import java.awt.*;
/**
* Created by windy on 2019/3/25.
* 报表服务器参数demo
*/
public class ReportServerParamDemo {
public static void main(String... args) {
final JFrame frame = new JFrame();
frame.setSize(660, 600);
JPanel contentPane = (JPanel) frame.getContentPane();
// 是否需要开启调试窗口
DesignerEnvManager.getEnvManager().setOpenDebug(true);
final ModernUIPane<ModernUIPaneTest.Model> pane = new ModernUIPane.Builder<ModernUIPaneTest.Model>()
.withComponent(ReportServerParamComponent.KEY).build();
contentPane.add(pane, BorderLayout.CENTER);
frame.setVisible(true);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
}
Loading…
Cancel
Save