From 62f74da6f1c31b65ea8cac9cccb8cd6b2bfad449 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Thu, 7 Nov 2024 10:46:05 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-138249=20cpt=E6=94=AF=E6=8C=81=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=9B=86=E6=9B=BF=E6=8D=A2=20=E6=8F=90=E5=87=BA?= =?UTF-8?q?=E9=A2=84=E8=A7=88=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/data/BasicTableDataTreePane.java | 113 ++++++++++-------- .../data/datapane/TableDataTreePane.java | 2 +- 2 files changed, 62 insertions(+), 53 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/data/BasicTableDataTreePane.java b/designer-base/src/main/java/com/fr/design/data/BasicTableDataTreePane.java index af9850172b..4fe69e08eb 100644 --- a/designer-base/src/main/java/com/fr/design/data/BasicTableDataTreePane.java +++ b/designer-base/src/main/java/com/fr/design/data/BasicTableDataTreePane.java @@ -442,64 +442,73 @@ public abstract class BasicTableDataTreePane extends DockingView implements Resp if (selectedNO != null) { data = selectedNO.getObject(); } - try { - if (((TableDataWrapper) Objects.requireNonNull(data)).getTableData() instanceof MultiResultTableData) { - ((MultiResultTableData) (((TableDataWrapper) data).getTableData())).resetDataModelList(); - if (data instanceof MultiResultTableDataWrapper) { - MultiResultTableDataWrapper oldSdw = ((MultiResultTableDataWrapper) data); - MultiResultTableDataWrapper newSdw = new MultiResultTableDataWrapper((MultiResultTableData) oldSdw.getTableData(), oldSdw.getMultiResultTableDataName(), oldSdw.getTableDataName()); - newSdw.previewData(MultiResultTableDataWrapper.PREVIEW_ONE); - } else { - MultiResultTableData tableData = (MultiResultTableData) ((TableDataWrapper) data).getTableData(); - MultiResultTableDataWrapper storeProcedureDataWrapper = new MultiResultTableDataWrapper(tableData, StringUtils.EMPTY, StringUtils.EMPTY); - storeProcedureDataWrapper.previewData(MultiResultTableDataWrapper.PREVIEW_ALL); - } - } else { - TableDataWrapper wrapper = ((TableDataWrapper) data); - if (TableDataAuthHelper.needCheckAuthWhenEdit(wrapper.getTableData())) { - // 先打开一个Loading面板 - TableDataLoadingPane loadingPane = new TableDataLoadingPane(); - BasicDialog loadingDialog = loadingPane.showLargeWindow(SwingUtilities.getWindowAncestor(BasicTableDataTreePane.this), null); - // 查询权限 - new SwingWorker() { - @Override - protected Boolean doInBackground() throws Exception { - // 获取无权限连接名称集合 - Collection noAuthConnections = TableDataAuthHelper.getNoAuthConnections(); - // 获取当前数据集对应的数据连接名称 - String connectionName = TableDataAuthHelper.getConnectionNameByDBTableData((DBTableData) wrapper.getTableData()); - return !noAuthConnections.contains(connectionName); - } + preview((TableDataWrapper) data, BasicTableDataTreePane.this); + } + } - @Override - protected void done() { - try { - Boolean hasAuth = get(); - if (hasAuth) { - // 有权限时,关闭Loading面板,打开编辑面板 - loadingDialog.setVisible(false); - wrapper.previewData(); - } else { - // 无权限时,给出无权限提示 - loadingPane.switchTo(TableDataLoadingPane.NO_AUTH_PANE_NAME); - } - } catch (Exception e) { - FineLoggerFactory.getLogger().error("loading connection error in remote design", e.getMessage()); - // 查询权限失败时,给出报错提示 - loadingPane.switchTo(TableDataLoadingPane.ERROR_NAME); + /** + * 预览数据集 + * + * @param data TableDataWrapper + * @param c 底层面板 + */ + public static void preview(TableDataWrapper data, Component c) { + try { + if (((TableDataWrapper) Objects.requireNonNull(data)).getTableData() instanceof MultiResultTableData) { + ((MultiResultTableData) (((TableDataWrapper) data).getTableData())).resetDataModelList(); + if (data instanceof MultiResultTableDataWrapper) { + MultiResultTableDataWrapper oldSdw = ((MultiResultTableDataWrapper) data); + MultiResultTableDataWrapper newSdw = new MultiResultTableDataWrapper((MultiResultTableData) oldSdw.getTableData(), oldSdw.getMultiResultTableDataName(), oldSdw.getTableDataName()); + newSdw.previewData(MultiResultTableDataWrapper.PREVIEW_ONE); + } else { + MultiResultTableData tableData = (MultiResultTableData) ((TableDataWrapper) data).getTableData(); + MultiResultTableDataWrapper storeProcedureDataWrapper = new MultiResultTableDataWrapper(tableData, StringUtils.EMPTY, StringUtils.EMPTY); + storeProcedureDataWrapper.previewData(MultiResultTableDataWrapper.PREVIEW_ALL); + } + } else { + TableDataWrapper wrapper = ((TableDataWrapper) data); + if (TableDataAuthHelper.needCheckAuthWhenEdit(wrapper.getTableData())) { + // 先打开一个Loading面板 + TableDataLoadingPane loadingPane = new TableDataLoadingPane(); + BasicDialog loadingDialog = loadingPane.showLargeWindow(SwingUtilities.getWindowAncestor(c), null); + // 查询权限 + new SwingWorker() { + @Override + protected Boolean doInBackground() throws Exception { + // 获取无权限连接名称集合 + Collection noAuthConnections = TableDataAuthHelper.getNoAuthConnections(); + // 获取当前数据集对应的数据连接名称 + String connectionName = TableDataAuthHelper.getConnectionNameByDBTableData((DBTableData) wrapper.getTableData()); + return !noAuthConnections.contains(connectionName); + } + + @Override + protected void done() { + try { + Boolean hasAuth = get(); + if (hasAuth) { + // 有权限时,关闭Loading面板,打开编辑面板 + loadingDialog.setVisible(false); + wrapper.previewData(); + } else { + // 无权限时,给出无权限提示 + loadingPane.switchTo(TableDataLoadingPane.NO_AUTH_PANE_NAME); } + } catch (Exception e) { + FineLoggerFactory.getLogger().error("loading connection error in remote design", e.getMessage()); + // 查询权限失败时,给出报错提示 + loadingPane.switchTo(TableDataLoadingPane.ERROR_NAME); } - }.execute(); - loadingDialog.setVisible(true); - } else { - wrapper.previewData(); - } + } + }.execute(); + loadingDialog.setVisible(true); + } else { + wrapper.previewData(); } - - } catch (Exception ex) { - FineLoggerFactory.getLogger().error(ex.getMessage(), ex); } + } catch (Exception ex) { + FineLoggerFactory.getLogger().error(ex.getMessage(), ex); } } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java index c55524f247..4bf7cb6fdb 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java @@ -100,6 +100,7 @@ import java.util.Set; import java.util.concurrent.ExecutionException; public class TableDataTreePane extends BasicTableDataTreePane { + private static Set extraActions = new HashSet<>(); private static final TableDataTreePane singleton = new TableDataTreePane(); public static final int PLUGIN_LISTENER_PRIORITY = 1; @@ -147,7 +148,6 @@ public class TableDataTreePane extends BasicTableDataTreePane { private EsdOffAction esdOffAction; private SwitchAction switchAction; private PreviewTableDataAction previewTableDataAction; - private static Set extraActions = new HashSet<>(); private JPanel serverDatasetAuthTipJPanel = new JPanel(); private TableDataSearchRemindPane remindPane;