From b8c2d337a87429c9ac0c91ceeabcaa271a80a17c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvan-=E6=AC=A7=E9=98=B3=E5=B8=86?= Date: Tue, 11 Oct 2022 22:05:59 +0800 Subject: [PATCH 01/63] =?UTF-8?q?REPORT-75091=20-=20=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=84=B1=E6=95=8F=EF=BC=88=E6=8A=A5=E8=A1=A8=EF=BC=89=20?= =?UTF-8?q?=E3=80=90=E9=97=AE=E9=A2=98=E5=8E=9F=E5=9B=A0=E3=80=91rt=20?= =?UTF-8?q?=E3=80=90=E6=94=B9=E5=8A=A8=E6=80=9D=E8=B7=AF=E3=80=91=E8=AF=A6?= =?UTF-8?q?=E8=A7=81=E5=BC=80=E5=8F=91=E6=96=87=E6=A1=A3=EF=BC=9Ahttps://k?= =?UTF-8?q?ms.fineres.com/pages/viewpage.action=3FpageId=3D504469104=20?= =?UTF-8?q?=E3=80=90review=E5=BB=BA=E8=AE=AE=E3=80=91=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E6=99=9A=E6=98=AF=E5=9B=A0=E4=B8=BA=E8=99=BD=E7=84=B6=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E6=98=AF=E4=B8=80=E6=9C=9F=EF=BC=8C=E4=BD=86=E6=98=AF?= =?UTF-8?q?=E6=94=BE=E5=88=B0=E4=BA=8C=E6=9C=9F=E5=8F=91=E5=B8=83=EF=BC=8C?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E5=9C=A8=E5=90=88=E5=B9=B6release/11.0?= =?UTF-8?q?=E5=90=8E=E6=89=8D=E6=8F=90=E4=BA=A4feature?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/actions/UpdateAction.java | 14 +- .../com/fr/design/constants/UIConstants.java | 1 + .../datapane/preview/PreviewTableModel.java | 2 + .../datapane/preview/PreviewTablePane.java | 421 ++++++++++++---- .../TableDataPreviewDesensitizeManager.java | 178 +++++++ .../model/DesensitizedPreviewTableModel.java | 113 +++++ .../rule/DesensitizationRuleChoosePane.java | 308 ++++++++++++ .../rule/DesensitizationRuleDebugPane.java | 127 +++++ .../rule/DesensitizationRuleEditPane.java | 296 +++++++++++ .../view/rule/DesensitizationRulePane.java | 80 +++ .../DesensitizationRuleSourceChoosePane.java | 48 ++ .../TableDataDesensitizationSettingPane.java | 110 +++++ .../TableDataDesensitizationTableModel.java | 459 ++++++++++++++++++ .../TableDataDesensitizationTablePane.java | 64 +++ .../design/images/control/refresh_normal.svg | 7 + .../design/standard/add/add_black_normal.svg | 3 + .../design/standard/debug/debug_disabled.svg | 6 + .../fr/design/standard/debug/debug_normal.svg | 4 + .../fr/design/standard/edit/edit_disabled.svg | 5 + .../fr/design/standard/edit/edit_normal.svg | 3 + .../standard/remove/remove_red_normal.svg | 7 + 21 files changed, 2167 insertions(+), 89 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/TableDataPreviewDesensitizeManager.java create mode 100644 designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/model/DesensitizedPreviewTableModel.java create mode 100644 designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleChoosePane.java create mode 100644 designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleDebugPane.java create mode 100644 designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleEditPane.java create mode 100644 designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRulePane.java create mode 100644 designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleSourceChoosePane.java create mode 100644 designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationSettingPane.java create mode 100644 designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTableModel.java create mode 100644 designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTablePane.java create mode 100644 designer-base/src/main/resources/com/fr/design/images/control/refresh_normal.svg create mode 100644 designer-base/src/main/resources/com/fr/design/standard/add/add_black_normal.svg create mode 100644 designer-base/src/main/resources/com/fr/design/standard/debug/debug_disabled.svg create mode 100644 designer-base/src/main/resources/com/fr/design/standard/debug/debug_normal.svg create mode 100644 designer-base/src/main/resources/com/fr/design/standard/edit/edit_disabled.svg create mode 100644 designer-base/src/main/resources/com/fr/design/standard/edit/edit_normal.svg create mode 100644 designer-base/src/main/resources/com/fr/design/standard/remove/remove_red_normal.svg diff --git a/designer-base/src/main/java/com/fr/design/actions/UpdateAction.java b/designer-base/src/main/java/com/fr/design/actions/UpdateAction.java index 048f233373..d33c04eb15 100644 --- a/designer-base/src/main/java/com/fr/design/actions/UpdateAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/UpdateAction.java @@ -185,12 +185,24 @@ public abstract class UpdateAction extends ShortCut implements Action { * @param resource 图标资源路径 */ public void setSmallIcon(String resource) { + setSmallIcon(resource, true); + } + + /** + * 使用传入资源url的方式设置Icon,会自动设置_normal.svg,然后通过needDisable参数判断是否需要自动设置_disable.svg + * 因为有些地方是不需要设置灰化图标的,所以不存在灰化图标资源,这边如果一并设置,就会报错文件找不到 + * @param resource + * @param needDisable + */ + public void setSmallIcon(String resource, boolean needDisable) { if (StringUtils.equals(resource, StringUtils.EMPTY)) { this.putValue(Action.SMALL_ICON, null); return; } this.putValue(Action.SMALL_ICON, IconUtils.readIcon(resource)); - this.putValue(UpdateAction.DISABLED_ICON, IconUtils.readSVGIcon(resource, IconUtils.ICON_TYPE_DISABLED)); + if (needDisable) { + this.putValue(UpdateAction.DISABLED_ICON, IconUtils.readSVGIcon(resource, IconUtils.ICON_TYPE_DISABLED)); + } } public void setSmallIcon(Icon[] smallIcon, boolean white) { diff --git a/designer-base/src/main/java/com/fr/design/constants/UIConstants.java b/designer-base/src/main/java/com/fr/design/constants/UIConstants.java index b10d3f9e52..850a6b5aac 100644 --- a/designer-base/src/main/java/com/fr/design/constants/UIConstants.java +++ b/designer-base/src/main/java/com/fr/design/constants/UIConstants.java @@ -150,6 +150,7 @@ public interface UIConstants { public static final Color LIST_ITEM_SPLIT_LINE = new Color(0xf0f0f3); public static final Color DESIGNER_LOGIN_BACKGROUND = new Color(0xf1ad14); public static final Color DESIGNER_LOGIN_BACKGROUND_ONCLICK = new Color(0xd89600); + public static final Color CHECK_BOX_TIP_FONT_COLOR = new Color(51, 51, 52, (int)Math.round(0.5 * 255)); public static final BufferedImage DRAG_BAR = IOUtils.readImage("com/fr/design/images/control/bar.png"); public static final BufferedImage DRAG_BAR_LIGHT = IOUtils.readImage("com/fr/design/images/control/bar-light.png"); diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTableModel.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTableModel.java index abbe3a7e08..91c8506b79 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTableModel.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTableModel.java @@ -26,6 +26,8 @@ public class PreviewTableModel extends AbstractTableModel { public IntList dateIndexs = new IntList(4); + public PreviewTableModel() {} + public PreviewTableModel(int maxRowCount) { // peter:默认必须显示错误的数据源. this(new ErrorResultSet(), maxRowCount); diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java index 5926dcb2df..6665c6f772 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java @@ -3,28 +3,39 @@ */ package com.fr.design.data.datapane.preview; -import com.fr.base.BaseUtils; import com.fr.base.TableData; +import com.fr.base.svg.IconUtils; import com.fr.data.TableDataSource; +import com.fr.data.desensitize.base.AbstractDesensitizationTableData; import com.fr.data.impl.DBTableData; import com.fr.data.impl.EmbeddedTableData; import com.fr.data.impl.NameDataModel; import com.fr.data.operator.DataOperator; import com.fr.design.DesignerEnvManager; +import com.fr.design.constants.UIConstants; import com.fr.design.data.DesignTableDataManager; +import com.fr.design.data.datapane.preview.desensitization.TableDataPreviewDesensitizeManager; +import com.fr.design.data.datapane.preview.desensitization.model.DesensitizedPreviewTableModel; +import com.fr.design.data.datapane.preview.desensitization.view.setting.TableDataDesensitizationSettingPane; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicPane; +import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.gui.frpane.UITabbedPane; +import com.fr.design.gui.ibutton.UIToggleButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.iprogressbar.AutoProgressBar; import com.fr.design.gui.itable.SortableJTable; import com.fr.design.gui.itable.TableSorter; import com.fr.design.gui.itextfield.UINumberField; +import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.JTemplate; +import com.fr.design.menu.SeparatorDef; +import com.fr.design.menu.ToolBarDef; import com.fr.design.ui.util.UIUtil; import com.fr.function.TIME; import com.fr.general.FRFont; @@ -39,6 +50,7 @@ import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; +import javax.swing.SwingUtilities; import javax.swing.SwingWorker; import javax.swing.UIManager; import javax.swing.table.DefaultTableCellRenderer; @@ -57,12 +69,19 @@ import java.sql.Timestamp; import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.Objects; import java.util.concurrent.CancellationException; /** * august: PreviewTablePane一共提供5个共有的静态方法,用来预览。 */ public class PreviewTablePane extends BasicPane { + + private static final String DATA_DESENSITIZATION_CONFIG = Toolkit.i18nText("Fine-Design_Report_Desensitization_Config"); + private static final String LEFT_BRACKET = "("; + private static final String RIGHT_BRACKET = ")"; + private static final String COUNT = Toolkit.i18nText("Fine-Design_Report_Desensitization_Count"); + private TableData tableData; private DataModel dataModel; private UINumberField maxPreviewNumberField; @@ -78,6 +97,54 @@ public class PreviewTablePane extends BasicPane { private static PreviewTablePane THIS; private EmbeddedTableData previewTableData; + private UILabel desensitizationLabel; + + /** + * 用于refreshLabel的鼠标监听 + */ + private final MouseAdapter refreshLabelMouseAdapter = new MouseAdapter() { + boolean mouseEntered = false; + boolean buttonPressed = false; + + @Override + public void mouseEntered(MouseEvent e) { // 当鼠标进入时候调用. + mouseEntered = true; + if (!buttonPressed) { + refreshLabel.setBackground(java.awt.Color.WHITE); + refreshLabel.setOpaque(true); + refreshLabel.setBorder(BorderFactory.createLineBorder(java.awt.Color.GRAY)); + } + } + + @Override + public void mouseExited(MouseEvent e) { + mouseEntered = false; + refreshLabel.setOpaque(false); + refreshLabel.setBorder(BorderFactory.createEmptyBorder()); + } + + @Override + public void mousePressed(MouseEvent e) { + buttonPressed = true; + refreshLabel.setBackground(java.awt.Color.lightGray); + } + + @Override + public void mouseReleased(MouseEvent e) { + buttonPressed = false; + if (mouseEntered) { + refreshLabel.setBackground(java.awt.Color.WHITE); + try { + populate(tableData); + if (dataModel != null) { + setRowsLimitTableModel(); + } + } catch (Exception ignore) { + } + } + } + }; + public static final PreviewTablePane getInstance() { if (THIS == null) { THIS = new PreviewTablePane(); @@ -87,91 +154,175 @@ public class PreviewTablePane extends BasicPane { private PreviewTablePane() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); + // northPane + this.add(initNorthPane(), BorderLayout.NORTH); + // centerPane + this.add(initCenterPane(), BorderLayout.CENTER); + // dialog + initDialog(); + // progressBar + initProgressBar(); + } - // elalke:预览行数 - JPanel previewNumberPanel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); - this.add(previewNumberPanel, BorderLayout.NORTH); + /** + * 初始化northPane + * + * @return + */ + private JComponent initNorthPane() { + JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + // 预览行数面板 + northPane.add(initPreviewNumberPane(), BorderLayout.CENTER); + // 脱敏预览设置面板 + northPane.add(initDesensitizationPane(), BorderLayout.EAST); + return northPane; + } + /** + * 初始化预览行数面板 + * + * @return + */ + private JComponent initPreviewNumberPane() { + JPanel previewNumberPanel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + // 当前行数 JPanel currentPreviewPanel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); - previewNumberPanel.add(currentPreviewPanel); currentPreviewPanel.add(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Current_Preview_Rows") + ":")); - currentRowsField = new UINumberField(); currentPreviewPanel.add(currentRowsField); currentRowsField.setEditable(false); currentRowsField.setColumns(4); currentRowsField.setInteger(true); - + // 最大行数 JPanel maxPanel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); - previewNumberPanel.add(maxPanel); maxPanel.add(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Datasource_Maximum_Number_of_Preview_Rows") + ":")); - maxPreviewNumberField = new UINumberField(); maxPanel.add(maxPreviewNumberField); maxPreviewNumberField.setColumns(4); maxPreviewNumberField.setInteger(true); - - DesignerEnvManager designerEnvManager = DesignerEnvManager.getEnvManager(); - maxPreviewNumberField.setValue(designerEnvManager.getMaxNumberOrPreviewRow()); - + maxPreviewNumberField.setValue(DesignerEnvManager.getEnvManager().getMaxNumberOrPreviewRow()); maxPreviewNumberField.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent evt) { DesignerEnvManager designerEnvManager = DesignerEnvManager.getEnvManager(); designerEnvManager.setMaxNumberOrPreviewRow((int) ((UINumberField) evt.getSource()).getValue()); } }); + // 刷新按钮 + initRefreshLabel(); - Icon refreshImage = BaseUtils.readIcon("/com/fr/design/images/control/refresh.png"); - refreshLabel = new UILabel(refreshImage); + previewNumberPanel.add(currentPreviewPanel); + previewNumberPanel.add(maxPanel); previewNumberPanel.add(refreshLabel); - refreshLabel.addMouseListener(new MouseAdapter() { - boolean mouseEntered = false; - boolean buttonPressed = false; - - public void mouseEntered(MouseEvent e) { // 当鼠标进入时候调用. - mouseEntered = true; - if (!buttonPressed) { - refreshLabel.setBackground(java.awt.Color.WHITE); - refreshLabel.setOpaque(true); - refreshLabel.setBorder(BorderFactory.createLineBorder(java.awt.Color.GRAY)); - } - } - - public void mouseExited(MouseEvent e) { - mouseEntered = false; - refreshLabel.setOpaque(false); - refreshLabel.setBorder(BorderFactory.createEmptyBorder()); - } + return previewNumberPanel; + } - public void mousePressed(MouseEvent e) { - buttonPressed = true; - refreshLabel.setBackground(java.awt.Color.lightGray); - } + private void initRefreshLabel() { + Icon refreshImage = IconUtils.readIcon("/com/fr/design/images/control/refresh"); + refreshLabel = new UILabel(refreshImage); + refreshLabel.addMouseListener(refreshLabelMouseAdapter); + } - public void mouseReleased(MouseEvent e) { - buttonPressed = false; - if (mouseEntered) { - refreshLabel.setBackground(java.awt.Color.WHITE); - try { - populate(tableData); - if (dataModel != null) { - setRowsLimitTableModel(); + /** + * 初始化脱敏设置面板 + * + * @return + */ + private JComponent initDesensitizationPane() { + JPanel desensitizationPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + // 初始化Label + desensitizationLabel = new UILabel(DATA_DESENSITIZATION_CONFIG); + desensitizationLabel.setForeground(UIConstants.NORMAL_BLUE); + desensitizationLabel.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + TableDataDesensitizationSettingPane settingPane = new TableDataDesensitizationSettingPane((AbstractDesensitizationTableData) tableData); + settingPane.populateBean((AbstractDesensitizationTableData) tableData); + BasicDialog dialog = settingPane.showWindowWithCustomSize(SwingUtilities.getWindowAncestor(PreviewTablePane.this), new DialogActionAdapter() { + @Override + public void doOk() { + // 保存脱敏规则配置 + settingPane.updateBean(); + // 改变模板保存状态 + JTemplate editingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (Objects.nonNull(editingTemplate)) { + editingTemplate.fireTargetModified(true); } - } catch (Exception e1) { + // 刷新预览页面 + refreshTable(); } - } + + @Override + public void doCancel() { + + } + }, BasicDialog.DEFAULT); + dialog.setVisible(true); } }); + // 初始化分隔符 + ToolBarDef toolbarDef = new ToolBarDef(); + toolbarDef.addShortCut(SeparatorDef.DEFAULT); + UIToolbar toolBar = ToolBarDef.createJToolBar(); + toolBar.setBorderPainted(false); + toolbarDef.updateToolBar(toolBar); + + // 初始化预览按钮 + UIToggleButton previewToggle = new UIToggleButton(new Icon[]{IconUtils.readIcon("/com/fr/design/images/m_file/preview"), IconUtils.readIcon("/com/fr/design/images/m_file/preview")}, true); + previewToggle.setToolTipText(Toolkit.i18nText("Fine-Design_Report_Desensitization_Preview")); + previewToggle.setSelected(false); + previewToggle.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // 切换TableModel的脱敏状态 + togglePreviewTableModelDesensitizeStatus(); + // 刷新页面,展示 + refreshTable(); + } + }); + + desensitizationPane.add(desensitizationLabel); + desensitizationPane.add(toolBar); + desensitizationPane.add(previewToggle); + return desensitizationPane; + } + + /** + * 设置脱敏设置的个数 + * + * @param model + */ + private void setDesensitizationCount(TableModel model) { + if (isDesensitizeOpened()) { + int count = model instanceof DesensitizedPreviewTableModel ? ((DesensitizedPreviewTableModel) model).getDesensitizeColumnsCount() : 0; + desensitizationLabel.setText(DATA_DESENSITIZATION_CONFIG + LEFT_BRACKET + count + RIGHT_BRACKET + COUNT); + } else { + desensitizationLabel.setText(DATA_DESENSITIZATION_CONFIG); + } + } + + /** + * 初始化centerPane + * + * @return + */ + private JComponent initCenterPane() { preveiwTable = new CopyableJTable(new TableSorter()); preveiwTable.setRowSelectionAllowed(false); preveiwTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + return new JScrollPane(preveiwTable); + } - this.add(new JScrollPane(preveiwTable), BorderLayout.CENTER); + private void initDialog() { if (this.dialog == null) { this.dialog = this.showWindow(new JFrame()); } + } + + private void initProgressBar() { progressBar = new AutoProgressBar(this, Toolkit.i18nText("Fine-Design_Basic_Loading_Data"), "", 0, 100) { + @Override public void doMonitorCanceled() { if (getWorker() != null) { getWorker().cancel(true); @@ -182,7 +333,7 @@ public class PreviewTablePane extends BasicPane { } public AutoProgressBar getProgressBar() { - return this.progressBar; + return PreviewTablePane.progressBar; } @Override @@ -222,13 +373,19 @@ public class PreviewTablePane extends BasicPane { return this.worker; } - // elake:为预览表的columnIndex列着c色. + /** + * 为预览表的columnIndex列着色. + * + * @param columnIndex 列索引值 + * @param c 颜色 + */ private void setPreviewTableColumnColor(final int columnIndex, final Color c) { addLoadedListener(new LoadedEventListener() { @Override public void fireLoaded() { TableColumn column = preveiwTable.getColumnModel().getColumn(columnIndex); DefaultTableCellRenderer cellRenderer = new DefaultTableCellRenderer() { + @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JComponent comp = (JComponent) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); comp.setBackground(c); @@ -249,7 +406,7 @@ public class PreviewTablePane extends BasicPane { getInstance().preveiwTable = new SortableJTable(new TableSorter()); getInstance().preveiwTable.setRowSelectionAllowed(false); getInstance().preveiwTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); - getInstance().progressBar.close(); + PreviewTablePane.progressBar.close(); getInstance().repaint(); } @@ -331,6 +488,7 @@ public class PreviewTablePane extends BasicPane { private void previewTableDataSQL() throws Exception { connectionBar = new AutoProgressBar(this, Toolkit.i18nText("Fine-Design_Basic_Utils_Now_Create_Connection"), "", 0, 100) { + @Override public void doMonitorCanceled() { getWorker().cancel(true); getDialog().setVisible(false); @@ -345,42 +503,49 @@ public class PreviewTablePane extends BasicPane { private void setPreviewTableColumnValue(final Graphics g) { for (int i = 0; i < preveiwTable.getColumnModel().getColumnCount(); i++) { TableColumn column = preveiwTable.getColumnModel().getColumn(i); - DefaultTableCellRenderer cellRenderer = new DefaultTableCellRenderer() { - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { - JComponent comp = (JComponent) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); - Font f = table.getFont(); - - //默认在系统不支持 无法显示时 如自造的字 ,字体设置为空. - Font defaultShowFont = FRFont.getInstance("", f.getStyle(), f.getSize()); - if (value instanceof String) { - String str = (String) value; - for (int j = 0; j < str.length(); j++) { - char c = str.charAt(j); - if (!f.canDisplay(c)) { - table.setFont(defaultShowFont); - } + DefaultTableCellRenderer cellRenderer = getDefaultTableCellRenderer(); + column.setCellRenderer(cellRenderer); + } + } + + /** + * 默认表格格子渲染器 + * + * @return + */ + private DefaultTableCellRenderer getDefaultTableCellRenderer() { + return new DefaultTableCellRenderer() { + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + JComponent comp = (JComponent) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + Font f = table.getFont(); + + //默认在系统不支持 无法显示时 如自造的字 ,字体设置为空. + Font defaultShowFont = FRFont.getInstance("", f.getStyle(), f.getSize()); + if (value instanceof String) { + String str = (String) value; + for (int j = 0; j < str.length(); j++) { + char c = str.charAt(j); + if (!f.canDisplay(c)) { + table.setFont(defaultShowFont); } } - return comp; } - }; - column.setCellRenderer(cellRenderer); - } + return comp; + } + }; } private void setWorker() { - worker = new SwingWorker() { - protected PreviewTableModel doInBackground() throws Exception { + worker = new SwingWorker() { + + @Override + protected TableModel doInBackground() throws Exception { connectionBar.start(); try { - if (tableData instanceof DBTableData) { - boolean status = DataOperator.getInstance().testConnection(((DBTableData) tableData).getDatabase()); - if (!status) { - throw new Exception(Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed")); - } - } + testDBTableDataConnection(tableData); } finally { // 将close操作放到EDT线程中 UIUtil.invokeLaterIfNeeded(() -> connectionBar.close()); @@ -390,22 +555,20 @@ public class PreviewTablePane extends BasicPane { // parameterInputDialog // update之后的parameters,转成一个parameterMap,用于预览TableData PreviewTableModel previewModel = new PreviewTableModel(previewTableData.createDataModel(null), (int) maxPreviewNumberField.getValue()); - for (int i = 0; i < previewTableData.getColumnCount(); i++) { - Class cls = previewTableData.getColumnClass(i); - if (cls == Date.class || cls == TIME.class || cls == Timestamp.class) { - previewModel.dateIndexs.add(i); - } + if (TableDataPreviewDesensitizeManager.getInstance().needDesensitize(tableData)) { + // 数据集预览脱敏 + previewModel = TableDataPreviewDesensitizeManager.getInstance().desensitizeTableModel(tableData, previewModel); } + dealWithPreviewTableModelColumnClass(previewModel, previewTableData); return previewModel; } + @Override public void done() { try { - PreviewTableModel model = get(); - setModel(model); - setCurrentRows(model.getRowCount()); + TableModel model = get(); + setPreviewTableModel(model); setPreviewTableColumnValue(getParent().getGraphics()); - fireLoadedListener(); } catch (Exception e) { if (!(e instanceof CancellationException)) { FineLoggerFactory.getLogger().error(e.getMessage(), e); @@ -420,6 +583,36 @@ public class PreviewTablePane extends BasicPane { }; } + /** + * 检查DBTableData连接 + * + * @param tableData + * @throws Exception + */ + private void testDBTableDataConnection(TableData tableData) throws Exception { + if (tableData instanceof DBTableData) { + boolean status = DataOperator.getInstance().testConnection(((DBTableData) tableData).getDatabase()); + if (!status) { + throw new Exception(Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed")); + } + } + } + + /** + * 处理预览Model的列类型 + * + * @param previewModel + * @param previewTableData + */ + private void dealWithPreviewTableModelColumnClass(PreviewTableModel previewModel, EmbeddedTableData previewTableData) { + for (int i = 0; i < previewTableData.getColumnCount(); i++) { + Class cls = previewTableData.getColumnClass(i); + if (cls == Date.class || cls == TIME.class || cls == Timestamp.class) { + previewModel.dateIndexs.add(i); + } + } + } + /** * 直接预览存储过程的一个返回数据集,没有实际值和显示值 * @@ -528,9 +721,61 @@ public class PreviewTablePane extends BasicPane { } catch (Exception e) { previewModel = new PreviewTableModel((int) maxPreviewNumberField.getValue()); } - setModel(previewModel); - setCurrentRows(previewModel.getRowCount()); + setPreviewTableModel(previewModel); + + } + + /** + * 切换TableModel的展示状态 + */ + private void togglePreviewTableModelDesensitizeStatus() { + if (!isDesensitizeOpened()) { + // 未启用数据脱敏时,不需要切换 + return; + } + TableSorter tableSorter = (TableSorter) preveiwTable.getModel(); + TableModel originTableModel = tableSorter.getTableModel(); + if (originTableModel instanceof DesensitizedPreviewTableModel) { + ((DesensitizedPreviewTableModel) originTableModel).toggleNeedDesensite(); + } + } + + /** + * 刷新一下预览页面,用于切换脱敏和非脱敏时的显示 + */ + private void refreshTable() { + TableModel originTableModel = getCurrentTableModel(); + setPreviewTableModel(originTableModel); + } + + /** + * 获取当前的TableModel,已经除掉了TableSorter的包装 + * + * @return + */ + private TableModel getCurrentTableModel() { + TableSorter tableSorter = (TableSorter) preveiwTable.getModel(); + return tableSorter.getTableModel(); + } + + /** + * 设置预览TableModel + * + * @param previewTableModel + */ + private void setPreviewTableModel(TableModel previewTableModel) { + setDesensitizationCount(previewTableModel); + setModel(previewTableModel); + setCurrentRows(previewTableModel.getRowCount()); fireLoadedListener(); + } + /** + * 数据脱敏是否启用 + * @return + */ + private boolean isDesensitizeOpened() { + return tableData instanceof AbstractDesensitizationTableData && + ((AbstractDesensitizationTableData) tableData).getDesensitizeOpen(); } } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/TableDataPreviewDesensitizeManager.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/TableDataPreviewDesensitizeManager.java new file mode 100644 index 0000000000..c8cdae8e72 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/TableDataPreviewDesensitizeManager.java @@ -0,0 +1,178 @@ +package com.fr.design.data.datapane.preview.desensitization; + + +import com.fr.base.TableData; +import com.fr.data.desensitize.base.AbstractDesensitizationTableData; +import com.fr.data.desensitize.base.TableDataDesensitizationBean; +import com.fr.data.desensitize.manage.DesensitizationManager; +import com.fr.data.desensitize.util.DesentizationUtils; +import com.fr.decision.webservice.bean.user.DepartmentPostBean; +import com.fr.decision.webservice.bean.user.RoleBean; +import com.fr.decision.webservice.utils.DecisionServiceConstants; +import com.fr.decision.webservice.v10.user.CustomRoleService; +import com.fr.decision.webservice.v10.user.PositionService; +import com.fr.design.data.DesignTableDataManager; +import com.fr.design.data.datapane.preview.PreviewTableModel; +import com.fr.design.data.datapane.preview.desensitization.model.DesensitizedPreviewTableModel; +import com.fr.design.data.tabledata.wrapper.TableDataWrapper; +import com.fr.general.ComparatorUtils; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.StringUtils; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Comparator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + + +/** + * 管理所有数据集预览过程中的脱敏计算 + * @author Yvan + * @version 11.0 + * Created by Yvan on 2022/9/14 + */ +public class TableDataPreviewDesensitizeManager implements DesensitizationManager { + + private static final String CONNECTOR = "_"; + + private TableDataPreviewDesensitizeManager() { + } + + private static class Holder { + private static final TableDataPreviewDesensitizeManager INSTANCE = new TableDataPreviewDesensitizeManager(); + } + + public static TableDataPreviewDesensitizeManager getInstance() { + return TableDataPreviewDesensitizeManager.Holder.INSTANCE; + } + + /** + * 判断数据集预览时是否需要脱敏,这里不需要判断roleIds,因为默认有权限编辑的人一定有权限看脱敏前后字段值 + * + * @param tableData + * @return + */ + public boolean needDesensitize(TableData tableData) { + return tableData instanceof AbstractDesensitizationTableData && + DesentizationUtils.isCollectionNotEmpty(((AbstractDesensitizationTableData) tableData).getDesensitizationBeans()) && + ((AbstractDesensitizationTableData) tableData).getDesensitizationBeans().stream().noneMatch(TableDataDesensitizationBean::invalid); + } + + /** + * 数据集预览脱敏,使用DesensitizedPreviewTableModel对当前的预览TableModel做包装 + * + * @param model + * @return + */ + public PreviewTableModel desensitizeTableModel(TableData tableData, PreviewTableModel model) { + if (needDesensitize(tableData)) { + Map desensitizationBeanMap = new LinkedHashMap<>(); + // 获取此数据集的所有脱敏信息 + Collection desensitizationBeans = ((AbstractDesensitizationTableData) tableData).getDesensitizationBeans(); + // 排个序 + List sortedBeans = desensitizationBeans.stream().sorted(Comparator.comparingInt(TableDataDesensitizationBean::getColumnIndex)).collect(Collectors.toList()); + int columnIndex = 0; + for (TableDataDesensitizationBean sortedBean : sortedBeans) { + // 当map中已包含列序号时,代表对这一列设置了不同的脱敏规则,将key + 1 + if (desensitizationBeanMap.containsKey(columnIndex)) { + columnIndex++; + } + desensitizationBeanMap.put(columnIndex, sortedBean); + } + // 包装TableModel + return new DesensitizedPreviewTableModel(model, desensitizationBeanMap); + } + return model; + } + + /** + * 通过TableData获取其列名 + * 实现逻辑有点绕,TableData本身并不能返回列名集合,只能先去获取当前模板所有数据集,然后匹配名称拿到TableDataWrapper再获取列名 + * @param tableData + * @return + */ + public List getColumnNamesByTableData(TableData tableData) { + List> editingDataSet = DesignTableDataManager.getEditingDataSet(DesignTableDataManager.getEditingTableDataSource()); + // 当前所有模板数据集Wrapper,不包括存储过程 + Map templeteDataMap = editingDataSet.get(0); + // 当前所有模板数据集Wrapper,包括存储过程 + Map dataWrapperMap = DesignTableDataManager.getAllDataSetIncludingProcedure(templeteDataMap); + // 找到匹配当前数据集名称的Wrapper + TableDataWrapper tableDataWrapper = dataWrapperMap.get(tableData.getName()); + return tableDataWrapper == null ? + new ArrayList<>() : + tableDataWrapper.calculateColumnNameList(); + } + + /** + * 这个api会返回 部门职位 + 自定义角色 的Map + * 其中 key为 "pid" + "_" + "id",value为 "ptext" + "text" + * @return + */ + public Map getAllRoles() { + Map rolesMap = new LinkedHashMap<>(); + // 处理部门职位相关的用户组 + addDepartmentAndPositionRoles2Map(rolesMap); + // 处理自定义角色相关的用户组 + addCustomRoles2Map(rolesMap); + return rolesMap; + } + + /** + * 获取所有的部门职位,按照 key为 "pid" + "_" + "id",value为 "ptext" + "text"的格式添加到参数Map中 + * @param rolesMap + */ + private void addDepartmentAndPositionRoles2Map(Map rolesMap) { + try { + List postBeans = PositionService.getInstance().getDepartmentPostNameList(); + for (DepartmentPostBean postBean : postBeans) { + String department = postBean.getpText(); + String position = postBean.getText(); + String departmentId = postBean.getpId(); + String positionId = postBean.getId(); + if (!ComparatorUtils.equals(DecisionServiceConstants.DECISION_DEP_ROOT, postBean.getId()) && StringUtils.isNotEmpty(position)) { + // 只添加部门和职位同时存在的 + rolesMap.put(mergeRoleId(departmentId, positionId), mergeRoleText(department, position)); + } + } + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e, "[Desensitization] failed to add department and position roles to map for {}", e.getMessage()); + } + } + + /** + * 获取所有的自定义角色,按照 id - name添加到参数map里 + * @param rolesMap + */ + private void addCustomRoles2Map(Map rolesMap) { + try { + List allCustomRole = CustomRoleService.getInstance().getAllCustomRoleNameList(null); + allCustomRole.forEach(roleBean -> rolesMap.put(roleBean.getId(), roleBean.getText())); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e, "[Desensitization] failed to add custom role to map for {}", e.getMessage()); + } + } + + /** + * 合并部门 + 职位的名称 + * @param departmentName + * @param positionName + * @return + */ + public String mergeRoleText(String departmentName, String positionName) { + return departmentName + positionName; + } + + /** + * 合并部门 + 职位的id + * @param departmentId + * @param positionId + * @return + */ + public String mergeRoleId(String departmentId, String positionId) { + return departmentId + CONNECTOR + positionId; + } +} diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/model/DesensitizedPreviewTableModel.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/model/DesensitizedPreviewTableModel.java new file mode 100644 index 0000000000..066f11374b --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/model/DesensitizedPreviewTableModel.java @@ -0,0 +1,113 @@ +package com.fr.design.data.datapane.preview.desensitization.model; + + +import com.fr.data.desensitize.base.TableDataDesensitizationBean; +import com.fr.data.desensitize.calculate.DesensitizationCalculator; +import com.fr.data.desensitize.rule.base.DesensitizationRule; +import com.fr.design.data.datapane.preview.PreviewTableModel; + +import java.util.Map; +import java.util.Objects; + +/** + * 数据集预览TableModel的脱敏实现 + * + * @author Yvan + * @version 11.0 + * Created by Yvan on 2022/9/14 + */ +public class DesensitizedPreviewTableModel extends PreviewTableModel { + + /** + * 原始数据Model + */ + private PreviewTableModel previewTableModel; + + /** + * 脱敏后新组装的TableModel中,列序号 - 脱敏信息 对应的Map + */ + private Map desensitizationBeanMap; + + private boolean needDesensitize = false; + + public DesensitizedPreviewTableModel(PreviewTableModel previewTableModel, Map desensitizationBeanMap) { + this.previewTableModel = previewTableModel; + this.desensitizationBeanMap = desensitizationBeanMap; + } + + @Override + public String getColumnName(int column) { + int originIndex = needDesensitize && Objects.nonNull(desensitizationBeanMap.get(column)) ? + desensitizationBeanMap.get(column).getColumnIndex() : column; + return previewTableModel.getColumnName(originIndex); + } + + @Override + public int getRowCount() { + return previewTableModel.getRowCount(); + } + + @Override + public int getColumnCount() { + return needDesensitize ? + getDesensitizeColumnsCount() : + previewTableModel.getColumnCount(); + } + + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + return needDesensitize && Objects.nonNull(desensitizationBeanMap.get(columnIndex)) ? + getDesensitizedValue(rowIndex, columnIndex) : + previewTableModel.getValueAt(rowIndex, columnIndex); + } + + /** + * 返回脱敏后的数据值 + * + * @param rowIndex + * @param columnIndex + * @return + */ + private Object getDesensitizedValue(int rowIndex, int columnIndex) { + // 先通过columnIndex找到对应原TableModel的列序号 + int originColumnIndex = desensitizationBeanMap.get(columnIndex).getColumnIndex(); + // 获取原值 + Object value = previewTableModel.getValueAt(rowIndex, originColumnIndex); + // 判空 + if (Objects.isNull(value)) { + return value; + } + // 脱敏 + String strValue = String.valueOf(value); + value = desensitizeValue(strValue, columnIndex); + return value; + } + + /** + * 计算脱敏后的value,此时columnIndex对应的脱敏信息一定不为空 + * + * @param strValue + * @param columnIndex + * @return + */ + private String desensitizeValue(String strValue, int columnIndex) { + TableDataDesensitizationBean desensitizationBean = desensitizationBeanMap.get(columnIndex); + DesensitizationRule desensitizationRule = desensitizationBean.getDesensitizationRule(); + return DesensitizationCalculator.getInstance().desensitize(strValue, desensitizationRule); + } + + /** + * 获取当前有效的脱敏字段个数 + * @return + */ + public int getDesensitizeColumnsCount() { + return desensitizationBeanMap.size(); + } + + /** + * 切换脱敏状态 + */ + public void toggleNeedDesensite() { + this.needDesensitize = !needDesensitize; + } +} diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleChoosePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleChoosePane.java new file mode 100644 index 0000000000..35901ff4b8 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleChoosePane.java @@ -0,0 +1,308 @@ +package com.fr.design.data.datapane.preview.desensitization.view.rule; + +import com.fr.base.svg.IconUtils; +import com.fr.data.desensitize.rule.DesensitizationRuleManager; +import com.fr.data.desensitize.rule.base.DesensitizationRule; +import com.fr.data.desensitize.rule.base.DesensitizationRuleSource; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.gui.ibutton.UIRadioButton; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itableeditorpane.UITableEditAction; +import com.fr.design.gui.itableeditorpane.UITableEditorPane; +import com.fr.design.gui.itableeditorpane.UITableModelAdapter; +import com.fr.design.i18n.Toolkit; +import com.fr.stable.StringUtils; +import com.fr.stable.collections.CollectionUtils; + +import javax.swing.AbstractCellEditor; +import javax.swing.JPanel; +import javax.swing.JTable; +import javax.swing.SwingUtilities; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import java.awt.CardLayout; +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * 脱敏规则选择页面 + * + * @author Yvan + * @version 11.0 + * Created by Yvan on 2022/9/26 + */ +public class DesensitizationRuleChoosePane extends JPanel { + + private CardLayout cardLayout; + + private UITableEditorPane serverRuleEditPane; + + private UITableEditorPane customRuleEditPane; + + private DesensitizationRuleSource currentRuleSource; + + public DesensitizationRuleChoosePane() { + this.cardLayout = new CardLayout(); + this.setLayout(cardLayout); + serverRuleEditPane = new UITableEditorPane<>(new DesensitizationRuleChooseTableModel(this, true)); + customRuleEditPane = new UITableEditorPane<>(new DesensitizationRuleChooseTableModel(this, false)); + serverRuleEditPane.setHeaderResizing(false); + customRuleEditPane.setHeaderResizing(false); + populateDesensitizationRules(); + this.add(serverRuleEditPane, DesensitizationRuleSource.SERVER.name()); + this.add(customRuleEditPane, DesensitizationRuleSource.CUSTOM.name()); + // 默认显示平台规则 + switchPaneByRuleSource(DesensitizationRuleSource.SERVER); + } + + public void switchPaneByRuleSource(DesensitizationRuleSource ruleSource) { + this.currentRuleSource = ruleSource; + this.cardLayout.show(this, ruleSource.name()); + } + + /** + * 展示当前规则 + */ + private void populateDesensitizationRules() { + serverRuleEditPane.populate(DesensitizationRuleManager.getInstance().getRules(DesensitizationRuleSource.SERVER)); + customRuleEditPane.populate(DesensitizationRuleManager.getInstance().getRules(DesensitizationRuleSource.CUSTOM)); + } + + /** + * 获取当前选中的规则 + * + * @return + */ + public DesensitizationRule getSelectedDesensitizationRule() { + switch (currentRuleSource) { + case SERVER: + return serverRuleEditPane.getTableModel().getSelectedValue(); + case CUSTOM: + return customRuleEditPane.getTableModel().getSelectedValue(); + default: + return null; + } + } + + /** + * 规则选择Table的TableModel + */ + private class DesensitizationRuleChooseTableModel extends UITableModelAdapter { + + private Component parent; + + private boolean debugActionOnly; + + protected DesensitizationRuleChooseTableModel(Component parent, boolean debugActionOnly) { + super(new String[]{ + StringUtils.EMPTY, + Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule_Name"), + Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule_Description") + }); + this.parent = parent; + this.debugActionOnly = debugActionOnly; + this.setColumnClass(new Class[]{ + RuleChoosePane.class, + UILabel.class, + UILabel.class + }); + this.setDefaultEditor(RuleChoosePane.class, new RuleChoosePane()); + this.setDefaultRenderer(RuleChoosePane.class, new RuleChoosePane()); + this.createTable().getColumnModel().getColumn(0).setMaxWidth(20); + } + + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + DesensitizationRule rule = getList().get(rowIndex); + switch (columnIndex) { + case 0: + return rule.equals(getSelectedValue()); + case 1: + return rule.getRuleName(); + case 2: + return DesensitizationRule.getDescription(rule); + default: + return StringUtils.EMPTY; + } + } + + @Override + public boolean isCellEditable(int row, int col) { + return true; + } + + @Override + public UITableEditAction[] createAction() { + return debugActionOnly ? + new UITableEditAction[]{new DebugRuleAction(parent)} : + new UITableEditAction[]{new AddRuleAction(), new EditRuleAction(), new DeleteRuleAction(parent), new DebugRuleAction(parent)}; + } + + private Set getCurrentExistRuleNames(String excludeName) { + List rules = getList(); + return CollectionUtils.isEmpty(rules) ? + new LinkedHashSet<>() : + rules.stream() + .map(DesensitizationRule::getRuleName) + .filter(name -> !StringUtils.equals(name, excludeName)) + .collect(Collectors.toSet()); + } + + private class RuleChoosePane extends AbstractCellEditor implements TableCellEditor, TableCellRenderer { + + private UIRadioButton selectedButton; + + public RuleChoosePane() { + this.selectedButton = new UIRadioButton(); + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + selectedButton.setSelected(isSelected); + return selectedButton; + } + + @Override + public Object getCellEditorValue() { + return selectedButton.isSelected(); + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + selectedButton.setSelected(isSelected); + return selectedButton; + } + } + + /** + * 添加规则 + */ + private class AddRuleAction extends AddTableRowAction { + + public AddRuleAction() { + this.setName(Toolkit.i18nText("Fine-Design_Report_Desensitization_Add")); + this.setSmallIcon("/com/fr/design/standard/add/add_black", false); + } + + @Override + public void actionPerformed(ActionEvent e) { + // 新增一条规则 + DesensitizationRuleEditPane editPane = new DesensitizationRuleEditPane(getCurrentExistRuleNames(StringUtils.EMPTY)); + BasicDialog basicDialog = editPane.showWindowWithCustomSize(SwingUtilities.getWindowAncestor(parent), new DialogActionAdapter() { + @Override + public void doOk() { + DesensitizationRule rule = editPane.updateBean(); + // 添加到Rule Manager中 + if (DesensitizationRule.valid(rule)) { + DesensitizationRuleManager.getInstance().addRule(rule); + } + // 添加到Table中 + addRow(rule); + fireTableDataChanged(); + } + + @Override + public void doCancel() { + super.doCancel(); + } + }, BasicDialog.DEFAULT); + basicDialog.setVisible(true); + } + } + + private class EditRuleAction extends UITableEditAction { + + public EditRuleAction() { + this.setName(Toolkit.i18nText("Fine-Design_Basic_Edit")); + this.setSmallIcon(IconUtils.readIcon("/com/fr/design/standard/edit/edit")); + } + + @Override + public void checkEnabled() { + setEnabled(table.getSelectedRow() != -1); + } + + @Override + public void actionPerformed(ActionEvent e) { + // 获取当前选中规则 + DesensitizationRule selectedValue = getSelectedValue(); + DesensitizationRuleEditPane editPane = new DesensitizationRuleEditPane(getCurrentExistRuleNames(selectedValue.getRuleName())); + editPane.populateBean(selectedValue); + BasicDialog basicDialog = editPane.showWindowWithCustomSize(SwingUtilities.getWindowAncestor(parent), new DialogActionAdapter() { + @Override + public void doOk() { + DesensitizationRule rule = editPane.updateBean(); + // 修改同步到RuleManager中 + if (DesensitizationRule.valid(rule)) { + DesensitizationRuleManager.getInstance().updateRule(rule); + } + fireTableDataChanged(); + } + + @Override + public void doCancel() { + super.doCancel(); + } + }, BasicDialog.DEFAULT); + basicDialog.setVisible(true); + } + } + + private class DeleteRuleAction extends DeleteAction { + + public DeleteRuleAction(Component parent) { + super(parent); + this.setName(Toolkit.i18nText("Fine-Design_Basic_Base_Remove")); + this.setSmallIcon("/com/fr/design/images/control/remove"); + } + + @Override + public void checkEnabled() { + setEnabled(table.getSelectedRow() != -1); + } + + @Override + public void actionPerformed(ActionEvent e) { + // 获取当前选中规则 + DesensitizationRule selectedRule = getSelectedValue(); + // 删除同步到RuleManager中 + if (DesensitizationRule.valid(selectedRule)) { + DesensitizationRuleManager.getInstance().removeRule(selectedRule); + } + super.actionPerformed(e); + } + } + + private class DebugRuleAction extends UITableEditAction { + + private Component parent; + + public DebugRuleAction(Component parent) { + this.parent = parent; + this.setName(Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule_Debug")); + this.setSmallIcon("/com/fr/design/standard/debug/debug"); + } + + @Override + public void checkEnabled() { + setEnabled(table.getSelectedRow() != -1); + } + + @Override + public void actionPerformed(ActionEvent e) { + // 获取当前选中规则 + DesensitizationRule selectedRule = getSelectedValue(); + DesensitizationRuleDebugPane ruleDebugPane = new DesensitizationRuleDebugPane(selectedRule); + BasicDialog ruleDebugDialog = ruleDebugPane.showWindowWithCustomSize(SwingUtilities.getWindowAncestor(parent), null, BasicDialog.DEFAULT); + ruleDebugDialog.setVisible(true); + } + } + } + + +} diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleDebugPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleDebugPane.java new file mode 100644 index 0000000000..71998b7bee --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleDebugPane.java @@ -0,0 +1,127 @@ +package com.fr.design.data.datapane.preview.desensitization.view.rule; + +import com.fr.data.desensitize.calculate.DesensitizationCalculator; +import com.fr.data.desensitize.rule.base.DesensitizationRule; +import com.fr.design.dialog.BasicPane; +import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ilable.UILabel; +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.stable.StringUtils; + +import javax.swing.BorderFactory; +import javax.swing.JComponent; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; + +/** + * 脱敏规则调试页 + * @author Yvan + * @version 11.0 + * Created by Yvan on 2022/9/8 + */ +public class DesensitizationRuleDebugPane extends BasicPane { + + /** + * 脱敏规则 + */ + private DesensitizationRule rule; + + public DesensitizationRuleDebugPane(DesensitizationRule rule) { + this.rule = rule; + initComponent(); + } + + private void initComponent() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.add(initNorthPane(), BorderLayout.NORTH); + this.add(initCenterPane(), BorderLayout.CENTER); + } + + private JPanel initNorthPane() { + JPanel northPane = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule_Description")); + JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + panel.setBorder(BorderFactory.createEmptyBorder(20, 10, 0, 0)); + UILabel desensitizationRule = new UILabel(Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule_Algorithm")); + UILabel characterReplace = new UILabel(rule.getRuleType().getTypeName()); + UILabel description = new UILabel(DesensitizationRule.getDescription(rule)); + JComponent[][] components = new JComponent[][] { + {desensitizationRule, characterReplace}, + {new UILabel(), description} + }; + panel.add( + TableLayoutHelper.createCommonTableLayoutPane( + components, + new double[]{TableLayout.PREFERRED, TableLayout.PREFERRED}, + new double[]{TableLayout.PREFERRED, TableLayout.PREFERRED}, + 20), + BorderLayout.CENTER); + northPane.add(panel); + return northPane; + } + + private JPanel initCenterPane() { + JPanel centerPane = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule_Debug")); + JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + panel.setBorder(BorderFactory.createEmptyBorder(20, 10, 0, 0)); + + UILabel beforeDesensitize = new UILabel(Toolkit.i18nText("Fine-Design_Report_Desensitization_Before")); + UITextField beforeDesensitizeText = new UITextField(20); + beforeDesensitizeText.setPlaceholder(Toolkit.i18nText("Fine-Design_Report_Desensitization_Enter_Content")); + UILabel afterDesensitize = new UILabel(Toolkit.i18nText("Fine-Design_Report_Desensitization_After")); + UITextField afterDesensitizeText = new UITextField(20); + afterDesensitizeText.setEditable(false); + UIButton desensitizeButton = new UIButton(Toolkit.i18nText("Fine-Design_Report_Desensitization_Debug")); + beforeDesensitizeText.addFocusListener(new FocusListener() { + @Override + public void focusGained(FocusEvent e) { + afterDesensitizeText.setText(StringUtils.EMPTY); + } + + @Override + public void focusLost(FocusEvent e) { + + } + }); + desensitizeButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + String text = beforeDesensitizeText.getText(); + if (StringUtils.isEmpty(text)) { + FineJOptionPane.showMessageDialog(DesensitizationRuleDebugPane.this, + Toolkit.i18nText("Fine-Design_Report_Desensitization_Please_Enter_Valid_Content")); + } + String desensitizedText = DesensitizationCalculator.getInstance().desensitize(text, rule); + afterDesensitizeText.setText(desensitizedText); + } + }); + + JComponent[][] components = new JComponent[][] { + {beforeDesensitize, beforeDesensitizeText, desensitizeButton}, + {afterDesensitize, afterDesensitizeText, new UILabel()} + }; + panel.add( + TableLayoutHelper.createCommonTableLayoutPane( + components, + new double[]{TableLayout.PREFERRED, TableLayout.PREFERRED}, + new double[]{TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED}, + 20), + BorderLayout.CENTER); + + centerPane.add(panel); + return centerPane; + } + + @Override + protected String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule_Debug"); + } +} diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleEditPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleEditPane.java new file mode 100644 index 0000000000..9c2c467fe3 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleEditPane.java @@ -0,0 +1,296 @@ +package com.fr.design.data.datapane.preview.desensitization.view.rule; + +import com.fr.data.desensitize.rule.base.DesensitizationCondition; +import com.fr.data.desensitize.rule.base.DesensitizationRule; +import com.fr.data.desensitize.rule.base.DesensitizationRuleType; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.constants.UIConstants; +import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itextfield.UINumberField; +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.stable.StringUtils; + +import javax.swing.BorderFactory; +import javax.swing.JComponent; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Insets; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.util.Arrays; +import java.util.Set; + +/** + * 脱敏规则编辑页 + * + * @author Yvan + * @version 11.0 + * Created by Yvan on 2022/9/8 + */ +public class DesensitizationRuleEditPane extends BasicBeanPane { + /** + * 已经存在的规则名称,用于检测重名 + */ + private Set existRuleNames; + + private UITextField ruleNameTextField; + private UIComboBox ruleTypeComboBox; + private UINumberField retainFrontTextField; + private UINumberField retainBackTextField; + private UITextField firstSymbolTextField; + private UITextField secondSymbolTextField; + private CardLayout cardLayout; + private JPanel ruleConditionPane; + + + private DesensitizationRule rule = DesensitizationRule.createDefaultEmptyRule(); + + private final FocusListener retainFrontListener = new FocusListener() { + @Override + public void focusGained(FocusEvent e) { + } + + @Override + public void focusLost(FocusEvent e) { + rule.getCondition().setRetainFront((int) retainFrontTextField.getValue()); + } + }; + + private final FocusListener retainBackListener = new FocusListener() { + @Override + public void focusGained(FocusEvent e) { + } + + @Override + public void focusLost(FocusEvent e) { + rule.getCondition().setRetainBack((int) retainBackTextField.getValue()); + } + }; + + private final FocusListener firstSymbolListener = new FocusListener() { + @Override + public void focusGained(FocusEvent e) { + } + + @Override + public void focusLost(FocusEvent e) { + rule.getCondition().setSymbol(firstSymbolTextField.getText()); + } + }; + + private final FocusListener secondSymbolListener = new FocusListener() { + @Override + public void focusGained(FocusEvent e) { + } + + @Override + public void focusLost(FocusEvent e) { + rule.getCondition().setRetainFront(0); + rule.getCondition().setRetainBack(0); + rule.getCondition().setSymbol(secondSymbolTextField.getText()); + } + }; + + public DesensitizationRuleEditPane(Set existRuleNames) { + this.existRuleNames = existRuleNames; + initComponent(); + } + + /** + * 初始化面板 + */ + private void initComponent() { + this.setLayout(FRGUIPaneFactory.createLeftZeroVgapNormalHgapLayout()); + JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + panel.setBorder(BorderFactory.createEmptyBorder(20, 10, 0, 0)); + UILabel ruleNameLabel = new UILabel(Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule_Name")); + // 规则名称输入框 + initRuleNameTextField(); + UILabel ruleTypeLabel = new UILabel(Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule_Algorithm")); + // 脱敏算法Type设置 + JPanel ruleTypePane = initRuleTypePane(); + // 脱敏算法Condition设置 + JPanel ruleConditionPane = initRuleConditionPane(); + JComponent[][] components = { + {ruleNameLabel, ruleNameTextField}, + {ruleTypeLabel, ruleTypePane}, + {new UILabel(), ruleConditionPane} + }; + panel.add( + TableLayoutHelper.createGapTableLayoutPane( + components, + new double[]{TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.FILL}, + new double[]{TableLayout.FILL, TableLayout.PREFERRED}, + 20, + 20), + BorderLayout.CENTER); + this.add(panel); + } + + /** + * 初始化规则类型面板 + * @return + */ + private JPanel initRuleTypePane() { + JPanel ruleTypePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + // 脱敏算法类型下拉框 + initRuleTypeComboBox(); + ruleTypePane.add(ruleTypeComboBox, BorderLayout.CENTER); + return ruleTypePane; + } + + /** + * 初始化规则条件面板 + * @return + */ + private JPanel initRuleConditionPane() { + JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + cardLayout = new CardLayout(); + ruleConditionPane = new JPanel(cardLayout); + // 字符替换 + JPanel characterReplacePane = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); + UILabel retainFrontLabel = new UILabel(Toolkit.i18nText("Fine-Design_Report_Desensitization_Retain_Front") + StringUtils.BLANK); + retainFrontTextField = new UINumberField(5); + retainFrontTextField.addFocusListener(retainFrontListener); + + UILabel retainBackLabel = new UILabel(StringUtils.BLANK + Toolkit.i18nText("Fine-Design_Report_Desensitization_Count_And_Back") + StringUtils.BLANK); + retainBackTextField = new UINumberField(5); + retainBackTextField.addFocusListener(retainBackListener); + + UILabel replaceLabel = new UILabel(StringUtils.BLANK + Toolkit.i18nText("Fine-Design_Report_Desensitization_Count_And_Other_Character_Replace_By") + StringUtils.BLANK); + firstSymbolTextField = new UITextField(10); + firstSymbolTextField.addFocusListener(firstSymbolListener); + + characterReplacePane.add(retainFrontLabel); + characterReplacePane.add(retainFrontTextField); + characterReplacePane.add(retainBackLabel); + characterReplacePane.add(retainBackTextField); + characterReplacePane.add(replaceLabel); + characterReplacePane.add(firstSymbolTextField); + // 整体替换 + JPanel characterAllReplacePane = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); + UILabel allReplaceLabel = new UILabel(Toolkit.i18nText("Fine-Design_Report_Desensitization_All_Character_Replace_By") + StringUtils.BLANK); + secondSymbolTextField = new UITextField(10); + secondSymbolTextField.addFocusListener(secondSymbolListener); + + characterAllReplacePane.add(allReplaceLabel); + characterAllReplacePane.add(secondSymbolTextField); + + ruleConditionPane.add(characterReplacePane, DesensitizationRuleType.CHARACTER_REPLACE.getTypeName()); + ruleConditionPane.add(characterAllReplacePane, DesensitizationRuleType.ALL_CHARACTERS_REPLACE.getTypeName()); + // 初始化状态为字符替换 + switchRuleConditionPane(DesensitizationRuleType.CHARACTER_REPLACE); + + panel.add(ruleConditionPane, BorderLayout.CENTER); + return panel; + } + + /** + * 切换规则类型面板 + * @param ruleType + */ + private void switchRuleConditionPane(DesensitizationRuleType ruleType) { + this.cardLayout.show(ruleConditionPane, ruleType.getTypeName()); + } + + /** + * 初始化规则类型下拉框 + */ + private void initRuleTypeComboBox() { + ruleTypeComboBox = new UIComboBox(Arrays.stream(DesensitizationRuleType.values()).map(DesensitizationRuleType::getTypeName).toArray()); + ruleTypeComboBox.setSelectedIndex(0); + ruleTypeComboBox.registerChangeListener(new UIObserverListener() { + @Override + public void doChange() { + DesensitizationRuleType ruleType = DesensitizationRuleType.matchByTypeName((String) ruleTypeComboBox.getSelectedItem()); + rule.setRuleType(ruleType); + // 修改底下的conditionPane + switchRuleConditionPane(ruleType); + } + }); + } + + /** + * 初始化规则名称输入框 + */ + private void initRuleNameTextField() { + ruleNameTextField = new UITextField(20) { + @Override + public Insets getInsets() { + return new Insets(2, 4, 0, 4); + } + }; + ruleNameTextField.setPlaceholder(Toolkit.i18nText("Fine-Design_Report_Desensitization_Please_Enter_Rule_Name")); + ruleNameTextField.setBorderPainted(true); + ruleNameTextField.addFocusListener(new FocusListener() { + @Override + public void focusGained(FocusEvent e) { + ruleNameTextField.setBorder(BorderFactory.createLineBorder(UIConstants.NORMAL_BLUE)); + ruleNameTextField.repaint(); + } + + @Override + public void focusLost(FocusEvent e) { + ruleNameTextField.setBorder(BorderFactory.createLineBorder(UIConstants.TOOLBAR_BORDER_COLOR)); + rule.setRuleName(ruleNameTextField.getText()); + ruleNameTextField.repaint(); + } + }); + } + + + @Override + public void populateBean(DesensitizationRule ob) { + this.rule = ob; + this.ruleNameTextField.setText(rule.getRuleName()); + String typeName = rule.getRuleType().getTypeName(); + this.ruleTypeComboBox.setSelectedItem(typeName); + switch (DesensitizationRuleType.matchByTypeName(typeName)) { + case CHARACTER_REPLACE: + this.retainFrontTextField.setValue(rule.getCondition().getRetainFront()); + this.retainBackTextField.setValue(rule.getCondition().getRetainBack()); + this.firstSymbolTextField.setText(rule.getCondition().getSymbol()); + break; + case ALL_CHARACTERS_REPLACE: + this.secondSymbolTextField.setText(rule.getCondition().getSymbol()); + break; + default: + } + + } + + @Override + public DesensitizationRule updateBean() { + rule.setEnable(true); + return rule; + } + + @Override + protected String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Report_Desensitization_Custom_Config_Rules"); + } + + @Override + public void checkValid() throws Exception { + // 保存rule前检查下 + String checkMessage = StringUtils.EMPTY; + if (StringUtils.isEmpty(rule.getRuleName())) { + checkMessage = Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule_Name_Cannot_Be_Empty"); + } else if (existRuleNames.contains(rule.getRuleName())) { + checkMessage = Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule_Name_Cannot_Repeat"); + } else if (DesensitizationCondition.invalid(rule.getCondition())) { + checkMessage = Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule_Wrong_Condition"); + } + if (StringUtils.isNotEmpty(checkMessage)) { + throw new Exception(checkMessage); + } + } + +} diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRulePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRulePane.java new file mode 100644 index 0000000000..4fd8f5fef4 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRulePane.java @@ -0,0 +1,80 @@ +package com.fr.design.data.datapane.preview.desensitization.view.rule; + +import com.fr.data.desensitize.rule.base.DesensitizationRule; +import com.fr.data.desensitize.rule.base.DesensitizationRuleSource; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.border.UITitledBorder; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; + +import javax.swing.JPanel; +import java.awt.BorderLayout; + +/** + * 脱敏规则展示页 + * @author Yvan + * @version 11.0 + * Created by Yvan on 2022/9/8 + */ +public class DesensitizationRulePane extends BasicBeanPane { + + /** + * 规则来源选择面板 + */ + private DesensitizationRuleSourceChoosePane ruleSourceChoosePane; + + /** + * 规则选择面板 + */ + private DesensitizationRuleChoosePane ruleChoosePane; + + /** + * 内容面板 + */ + private JPanel contentPane; + + public DesensitizationRulePane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + initPane(); + } + + private void initPane() { + // 内容面板 + contentPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + contentPane.setBorder(UITitledBorder.createBorderWithTitle(Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule_Choose"))); + this.add(contentPane, BorderLayout.CENTER); + // 规则来源选择Pane + ruleSourceChoosePane = new DesensitizationRuleSourceChoosePane(this); + // 规则选择Pane + ruleChoosePane = new DesensitizationRuleChoosePane(); + contentPane.add(ruleSourceChoosePane, BorderLayout.NORTH); + contentPane.add(ruleChoosePane, BorderLayout.CENTER); + } + + /** + * 处理规则来源选择面板中改动来源的事件 + * @param newRuleSource + */ + public void dealWithRuleSourceChanged(DesensitizationRuleSource newRuleSource) { + ruleChoosePane.switchPaneByRuleSource(newRuleSource); + } + + + @Override + public void populateBean(DesensitizationRule ob) { + // 这边展示当前所有规则时,不依靠外界传值,初始化的时候,从规则管理中心去获取 + } + + @Override + public DesensitizationRule updateBean() { + DesensitizationRule desensitizationRule = ruleChoosePane.getSelectedDesensitizationRule(); + return DesensitizationRule.valid(desensitizationRule) ? + desensitizationRule : + DesensitizationRule.createDefaultEmptyRule(); + } + + @Override + protected String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule"); + } +} diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleSourceChoosePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleSourceChoosePane.java new file mode 100644 index 0000000000..f67512164e --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleSourceChoosePane.java @@ -0,0 +1,48 @@ +package com.fr.design.data.datapane.preview.desensitization.view.rule; + +import com.fr.data.desensitize.rule.base.DesensitizationRuleSource; +import com.fr.design.gui.ibutton.UIRadioButton; +import com.fr.design.i18n.Toolkit; + +import javax.swing.BorderFactory; +import javax.swing.ButtonGroup; +import javax.swing.JPanel; +import java.awt.FlowLayout; + +/** + * 脱敏规则来源选择页面 + * @author Yvan + * @version 11.0 + * Created by Yvan on 2022/9/26 + */ +public class DesensitizationRuleSourceChoosePane extends JPanel { + + /** + * 来源平台的按钮 + */ + private UIRadioButton serverSource; + + /** + * 来源本地的按钮 + */ + private UIRadioButton customSource; + + public DesensitizationRuleSourceChoosePane(DesensitizationRulePane desensitizationRulePane) { + this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); + this.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); + + serverSource = new UIRadioButton(Toolkit.i18nText("Fine-Design_Report_Desensitization_Server_Config_Rules")); + customSource = new UIRadioButton(Toolkit.i18nText("Fine-Design_Report_Desensitization_Custom_Config_Rules")); + + ButtonGroup buttonGroup = new ButtonGroup(); + buttonGroup.add(serverSource); + buttonGroup.add(customSource); + serverSource.setSelected(true); + + serverSource.registerChangeListener(() -> desensitizationRulePane.dealWithRuleSourceChanged(DesensitizationRuleSource.SERVER)); + customSource.registerChangeListener(() -> desensitizationRulePane.dealWithRuleSourceChanged(DesensitizationRuleSource.CUSTOM)); + + this.add(serverSource); + this.add(customSource); + } +} diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationSettingPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationSettingPane.java new file mode 100644 index 0000000000..f63bcdacc3 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationSettingPane.java @@ -0,0 +1,110 @@ +package com.fr.design.data.datapane.preview.desensitization.view.setting; + +import com.fr.data.desensitize.base.AbstractDesensitizationTableData; +import com.fr.data.desensitize.base.TableDataDesensitizationBean; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.constants.UIConstants; +import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; + +import javax.swing.JComponent; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.util.List; + +/** + * 数据集脱敏字段设置页面 + * @author Yvan + * @version 11.0 + * Created by Yvan on 2022/9/8 + */ +public class TableDataDesensitizationSettingPane extends BasicBeanPane { + + /** + * 设置针对的数据集 + */ + private AbstractDesensitizationTableData tableData; + + private UICheckBox desensitizeOpen; + + private TableDataDesensitizationTablePane tableDataDesensitizationTablePane; + + + public TableDataDesensitizationSettingPane(AbstractDesensitizationTableData tableData) { + this.tableData = tableData; + initComponents(); + } + + private void initComponents() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.add(initNorthPane(), BorderLayout.NORTH); + this.add(initCenterPane(), BorderLayout.CENTER); + } + + /** + * 初始化启用数据脱敏面板 + * @return + */ + private JComponent initNorthPane() { + JPanel northPane = FRGUIPaneFactory.createTopVerticalTitledBorderPane(Toolkit.i18nText("Fine-Design_Report_Desensitization_Config")); + this.desensitizeOpen = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_Desensitization_Opened")); + northPane.add(desensitizeOpen); + UILabel tipLabel = new UILabel(Toolkit.i18nText("Fine-Design_Report_Desensitization_Opened_Tooltips")); + tipLabel.setForeground(UIConstants.CHECK_BOX_TIP_FONT_COLOR); + northPane.add(tipLabel); + return northPane; + } + + /** + * 初始化数据脱敏规则表面板 + * @return + */ + private JComponent initCenterPane() { + this.tableDataDesensitizationTablePane = new TableDataDesensitizationTablePane(tableData, this); + return tableDataDesensitizationTablePane; + } + + /** + * 是否启用脱敏 + * @return + */ + public boolean isDesensitizeOpened() { + return desensitizeOpen.isSelected(); + } + + @Override + protected String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Report_Desensitization_Config"); + } + + @Override + public void populateBean(AbstractDesensitizationTableData tableData) { + this.tableData = tableData; + this.desensitizeOpen.setSelected(tableData.getDesensitizeOpen()); + tableDataDesensitizationTablePane.populateDesensitizationSetting(tableData); + } + + @Override + public AbstractDesensitizationTableData updateBean() { + saveDesensitizeOpened(); + saveDesensitizationBeans(tableDataDesensitizationTablePane.updateDesensitizationSetting()); + return tableData; + } + + /** + * 保存脱敏启用状态 + */ + public void saveDesensitizeOpened() { + tableData.setDesensitizeOpen(desensitizeOpen.isSelected()); + } + + /** + * 保存脱敏规则配置信息 + * @param tableDataDesensitizationBeans + */ + public void saveDesensitizationBeans(List tableDataDesensitizationBeans) { + tableData.setDesensitizationBeans(tableDataDesensitizationBeans); + } +} diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTableModel.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTableModel.java new file mode 100644 index 0000000000..36322c3980 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTableModel.java @@ -0,0 +1,459 @@ +package com.fr.design.data.datapane.preview.desensitization.view.setting; + +import com.fr.data.desensitize.base.AbstractDesensitizationTableData; +import com.fr.data.desensitize.base.TableDataDesensitizationBean; +import com.fr.data.desensitize.rule.base.DesensitizationRule; +import com.fr.design.data.datapane.preview.desensitization.TableDataPreviewDesensitizeManager; +import com.fr.design.data.datapane.preview.desensitization.view.rule.DesensitizationRulePane; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.icombocheckbox.UIComboCheckBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itableeditorpane.UITableEditAction; +import com.fr.design.gui.itableeditorpane.UITableModelAdapter; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.stable.StringUtils; +import com.fr.stable.collections.CollectionUtils; +import org.jetbrains.annotations.Nullable; + +import javax.swing.AbstractCellEditor; +import javax.swing.JPanel; +import javax.swing.JTable; +import javax.swing.SwingUtilities; +import javax.swing.event.CellEditorListener; +import javax.swing.event.ChangeEvent; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; + +/** + * 处理TableDataDesensitizationTablePane中TableEditPane的Model + * + * @author Yvan + * @version 11.0 + * Created by Yvan on 2022/9/23 + */ +public class TableDataDesensitizationTableModel extends UITableModelAdapter { + + private static final String APOSTROPHE = "..."; + + private AbstractDesensitizationTableData tableData; + + /** + * 当前数据集的所有列名 + */ + private List columnNames; + + /** + * key为用户组唯一标识(id拼接),value为用户组名称 + */ + private Map roleMap; + + private Component parent; + + private DesensitizationRuleChooser ruleChooser; + + private DesensitizationRuleDescriptionPane descriptionPane; + + public TableDataDesensitizationTableModel(AbstractDesensitizationTableData tableData, Component parent) { + // table相关 + super(new String[]{ + Toolkit.i18nText("Fine-Design_Report_Desensitization_Column"), + Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule"), + StringUtils.EMPTY, + Toolkit.i18nText("Fine-Design_Report_Desensitization_Effected_Roles") + }); + // 一些数据相关 + this.tableData = tableData; + // 获取当前数据集的所有列名 + this.columnNames = TableDataPreviewDesensitizeManager.getInstance().getColumnNamesByTableData(tableData); + // 获取当前所有用户组 + this.roleMap = TableDataPreviewDesensitizeManager.getInstance().getAllRoles(); + this.parent = parent; + this.setColumnClass(new Class[]{ + // 列名选择 + ColumnNamesComboBox.class, + // 规则选择 + DesensitizationRuleChooser.class, + // 规则详情展示 + DesensitizationRuleDescriptionPane.class, + // 生效用户组选择 + EffectedRolesChooser.class + }); + this.setDefaultEditor(ColumnNamesComboBox.class, new ColumnNamesComboBox()); + this.ruleChooser = new DesensitizationRuleChooser(); + this.setDefaultEditor(DesensitizationRuleChooser.class, ruleChooser); + this.setDefaultRenderer(DesensitizationRuleChooser.class, ruleChooser); + this.descriptionPane = new DesensitizationRuleDescriptionPane(); + this.setDefaultEditor(DesensitizationRuleDescriptionPane.class, new DesensitizationRuleDescriptionPane()); + this.setDefaultEditor(EffectedRolesChooser.class, new EffectedRolesChooser()); + } + + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + TableDataDesensitizationBean desensitizationBean = this.getList().get(rowIndex); + switch (columnIndex) { + case 0: + return getColumnNameValue(desensitizationBean); + case 1: + return desensitizationBean.getDesensitizationRule().getRuleName(); + case 2: + return DesensitizationRule.getDescription(desensitizationBean.getDesensitizationRule()); + case 3: + return matchRoleNamesByIds(desensitizationBean.getRoleIds()); + default: + return StringUtils.EMPTY; + } + } + + /** + * 根据当前选中的Bean,获取其对应的列名字段 + * @param desensitizationBean + * @return + */ + private Object getColumnNameValue(TableDataDesensitizationBean desensitizationBean) { + // 内部列名list为空时直接返回空字符串 + if (CollectionUtils.isEmpty(columnNames)) { + return StringUtils.EMPTY; + } + // bean的列字段index不对劲时,返回空字符串 + return validColumnIndex(desensitizationBean.getColumnIndex()) ? + columnNames.get(desensitizationBean.getColumnIndex()) : + StringUtils.EMPTY; + } + + /** + * 判断字段索引是否越界 + * @param columnIndex + * @return + */ + private boolean validColumnIndex(int columnIndex) { + return columnIndex >= 0 && columnIndex < columnNames.size(); + } + + /** + * 通过id匹配此用户组对应的部门职位名称(或者说自定义角色名称) + * + * @param roleIds + * @return + */ + private List matchRoleNamesByIds(Set roleIds) { + List result = new ArrayList<>(); + for (String roleId : roleIds) { + if (roleMap != null && roleMap.containsKey(roleId)) { + result.add(roleMap.get(roleId)); + } + } + return result; + } + + @Override + public boolean isCellEditable(int row, int col) { + return true; + } + + @Override + public UITableEditAction[] createAction() { + return new UITableEditAction[]{new AddDesensitizationAction(), new RemoveDesensitizationAction(parent)}; + } + + /** + * 获取当前选中的item,可能为null + * + * @return + */ + @Nullable + private TableDataDesensitizationBean getCurrentSelectBean() { + return table.getSelectedRow() == -1 ? + null : + getList().get(table.getSelectedRow()); + } + + /** + * 列名选择下拉框 + */ + private class ColumnNamesComboBox extends AbstractCellEditor implements TableCellEditor, TableCellRenderer { + + private UIComboBox columnNameComboBox; + + ColumnNamesComboBox() { + columnNameComboBox = new UIComboBox(columnNames.toArray(new String[0])); + this.addCellEditorListener(new CellEditorListener() { + @Override + public void editingStopped(ChangeEvent e) { + + TableDataDesensitizationBean desensitizationBean = getCurrentSelectBean(); + if (Objects.nonNull(desensitizationBean)) { + desensitizationBean.setColumnIndex(columnNameComboBox.getSelectedIndex()); + fireTableDataChanged(); + } + } + + @Override + public void editingCanceled(ChangeEvent e) { + + } + }); + } + + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + columnNameComboBox.setSelectedIndex(getList().get(row).getColumnIndex()); + return columnNameComboBox; + } + + @Override + public Object getCellEditorValue() { + Object selectedItem = columnNameComboBox.getSelectedItem(); + return Objects.isNull(selectedItem) ? StringUtils.EMPTY : selectedItem.toString(); + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + columnNameComboBox.setSelectedIndex(getList().get(row).getColumnIndex()); + return columnNameComboBox; + } + } + + private class DesensitizationRuleChooser extends AbstractCellEditor implements TableCellEditor, TableCellRenderer { + /** + * 规则选择页面 + */ + private JPanel choosePane; + /** + * 规则名称 + */ + private UITextField ruleNameTextField; + /** + * 规则选择按钮 + */ + private UIButton chooseButton; + /** + * 规则 + */ + private DesensitizationRule rule; + + private ActionListener chooseRuleListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + DesensitizationRulePane rulePane = new DesensitizationRulePane(); + BasicDialog ruleDialog = rulePane.showWindowWithCustomSize(SwingUtilities.getWindowAncestor(parent), new DialogActionAdapter() { + @Override + public void doOk() { + rule = rulePane.updateBean(); + TableDataDesensitizationBean desensitizationBean = getCurrentSelectBean(); + if (Objects.nonNull(desensitizationBean) && Objects.nonNull(rule)) { + desensitizationBean.setDesensitizationRule(rule); + fireTableDataChanged(); + } + rule = null; + } + }, BasicDialog.DEFAULT); + ruleDialog.setVisible(true); + } + }; + + DesensitizationRuleChooser() { + // 规则名称展示 + ruleNameTextField = new UITextField(); + ruleNameTextField.setEnabled(false); + // 规则选择按钮 + chooseButton = new UIButton(APOSTROPHE); + chooseButton.addActionListener(chooseRuleListener); + // 规则选择页面 + Component[][] templateChooserComponent = {{ruleNameTextField, chooseButton}}; + double[] rowSize = {TableLayout.PREFERRED}; + double[] columnSize = {TableLayout.FILL, 22}; + choosePane = TableLayoutHelper.createCommonTableLayoutPane(templateChooserComponent, rowSize, columnSize, 0); + this.addCellEditorListener(new CellEditorListener() { + + @Override + public void editingCanceled(ChangeEvent e) { + + } + + @Override + public void editingStopped(ChangeEvent e) { + TableDataDesensitizationBean desensitizationBean = getCurrentSelectBean(); + if (Objects.nonNull(desensitizationBean) && Objects.nonNull(rule)) { + desensitizationBean.setDesensitizationRule(rule); + fireTableDataChanged(); + } + } + }); + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + ruleNameTextField.setText(getList().get(row).getDesensitizationRule().getRuleName()); + return choosePane; + } + + @Override + public Object getCellEditorValue() { + return ruleNameTextField.getText(); + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + ruleNameTextField.setText((String) value); + return choosePane; + } + } + + private class DesensitizationRuleDescriptionPane extends AbstractCellEditor implements TableCellEditor { + + private UILabel descriptionLabel; + + DesensitizationRuleDescriptionPane() { + // 规则描述 + this.descriptionLabel = new UILabel(); + } + + /** + * 根据脱敏规则信息,刷新下规则描述文字,主要用于与规则选择器的联动 + * + * @param desensitizationRule + */ + public void refreshDescription(DesensitizationRule desensitizationRule) { + this.descriptionLabel.setText(DesensitizationRule.getDescription(desensitizationRule)); + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + refreshDescription(getList().get(row).getDesensitizationRule()); + return descriptionLabel; + } + + @Override + public Object getCellEditorValue() { + return this.descriptionLabel.getText(); + } + } + + private class EffectedRolesChooser extends AbstractCellEditor implements TableCellEditor, TableCellRenderer { + + private UIComboCheckBox rolesCheckBox; + + EffectedRolesChooser() { + this.rolesCheckBox = new UIComboCheckBox(roleMap.values().toArray(), true); + this.addCellEditorListener(new CellEditorListener() { + @Override + public void editingStopped(ChangeEvent e) { + TableDataDesensitizationBean desensitizationBean = getCurrentSelectBean(); + if (Objects.nonNull(desensitizationBean)) { + desensitizationBean.setRoleIds(generateRolesIdsBySelectedValues()); + fireTableDataChanged(); + } + } + + @Override + public void editingCanceled(ChangeEvent e) { + + } + }); + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + rolesCheckBox.setSelectedValues(generateRolesCheckBoxSelectedValues(getList().get(row))); + return rolesCheckBox; + } + + /** + * 根据当前的规则配置信息,生成选中的rolesMap用来展示 + * @param desensitizationBean + * @return + */ + private Map generateRolesCheckBoxSelectedValues(TableDataDesensitizationBean desensitizationBean) { + Map result = new HashMap<>(roleMap.size()); + for (Map.Entry roleEntry : roleMap.entrySet()) { + String roleId = roleEntry.getKey(); + String roleName = roleEntry.getValue(); + if (desensitizationBean.getRoleIds().contains(roleId)) { + result.put(roleName, true); + } else { + result.put(roleName, false); + } + } + return result; + } + + /** + * 根据当前的RoleName选择项,生成其对应的RoleId的set存入规则配置信息 + * @return + */ + private Set generateRolesIdsBySelectedValues() { + Set result = new LinkedHashSet<>(); + Object[] selectedValues = rolesCheckBox.getSelectedValues(); + for (Object selectedValue : selectedValues) { + String selectedRoleName = (String) selectedValue; + if (roleMap.containsValue(selectedRoleName)) { + Optional> matchedEntry = roleMap.entrySet().stream().filter(entry -> StringUtils.equals(entry.getValue(), selectedRoleName)).findFirst(); + matchedEntry.ifPresent(stringStringEntry -> result.add(stringStringEntry.getKey())); + } + } + return result; + } + + @Override + public Object getCellEditorValue() { + return rolesCheckBox.getSelectedValues(); + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + rolesCheckBox.setSelectedValues(generateRolesCheckBoxSelectedValues(getList().get(row))); + return rolesCheckBox; + } + } + + + private class AddDesensitizationAction extends AddTableRowAction { + + public AddDesensitizationAction() { + this.setName(Toolkit.i18nText("Fine-Design_Report_Desensitization_Add")); + this.setSmallIcon("/com/fr/design/standard/add/add_black", false); + } + + @Override + public void actionPerformed(ActionEvent e) { + super.actionPerformed(e); + // 添加一条空白数据 + addRow(TableDataDesensitizationBean.createEmyptBean()); + fireTableDataChanged(); + table.getSelectionModel().setSelectionInterval(table.getRowCount() - 1, table.getRowCount() - 1); + } + } + + private class RemoveDesensitizationAction extends DeleteAction { + + public RemoveDesensitizationAction(Component component) { + super(component); + this.setName(Toolkit.i18nText("Fine-Design_Basic_Base_Remove")); + this.setSmallIcon("/com/fr/design/standard/remove/remove_red", false); + } + + @Override + public void actionPerformed(ActionEvent e) { + super.actionPerformed(e); + } + } + +} diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTablePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTablePane.java new file mode 100644 index 0000000000..77546b9ef1 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTablePane.java @@ -0,0 +1,64 @@ +package com.fr.design.data.datapane.preview.desensitization.view.setting; + +import com.fr.data.desensitize.base.AbstractDesensitizationTableData; +import com.fr.data.desensitize.base.TableDataDesensitizationBean; +import com.fr.design.gui.itableeditorpane.UITableEditorPane; +import com.fr.design.layout.FRGUIPaneFactory; + +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; +import java.util.List; + +/** + * 脱敏字段设置页面中的Table + * @author Yvan + * @version 11.0 + * Created by Yvan on 2022/9/14 + */ +public class TableDataDesensitizationTablePane extends JPanel { + + /** + * 脱敏数据集 + */ + private AbstractDesensitizationTableData tableData; + + /** + * 父页面 + */ + private Component parent; + + /** + * 脱敏信息Table + */ + private UITableEditorPane editorPane; + + public TableDataDesensitizationTablePane(AbstractDesensitizationTableData tableData, Component parent) { + this.tableData = tableData; + this.parent = parent; + initComponent(); + } + + private void initComponent() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.editorPane = new UITableEditorPane<>(new TableDataDesensitizationTableModel(tableData, parent)); + this.editorPane.setHeaderResizing(false); + this.add(editorPane, BorderLayout.CENTER); + } + + /** + * 展示此TableData中已配置的脱敏规则信息 + * @param tableData + */ + public void populateDesensitizationSetting(AbstractDesensitizationTableData tableData) { + this.tableData = tableData; + editorPane.populate(tableData.getDesensitizationBeans().toArray(new TableDataDesensitizationBean[0])); + } + + /** + * 获取当前对TableData的配置脱敏规则信息 + */ + public List updateDesensitizationSetting() { + return editorPane.update(); + } +} diff --git a/designer-base/src/main/resources/com/fr/design/images/control/refresh_normal.svg b/designer-base/src/main/resources/com/fr/design/images/control/refresh_normal.svg new file mode 100644 index 0000000000..e83a52740e --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/images/control/refresh_normal.svg @@ -0,0 +1,7 @@ + + + icon_刷新_normal + + + + diff --git a/designer-base/src/main/resources/com/fr/design/standard/add/add_black_normal.svg b/designer-base/src/main/resources/com/fr/design/standard/add/add_black_normal.svg new file mode 100644 index 0000000000..2c63e640bc --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/standard/add/add_black_normal.svg @@ -0,0 +1,3 @@ + + + diff --git a/designer-base/src/main/resources/com/fr/design/standard/debug/debug_disabled.svg b/designer-base/src/main/resources/com/fr/design/standard/debug/debug_disabled.svg new file mode 100644 index 0000000000..520d126a0f --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/standard/debug/debug_disabled.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/designer-base/src/main/resources/com/fr/design/standard/debug/debug_normal.svg b/designer-base/src/main/resources/com/fr/design/standard/debug/debug_normal.svg new file mode 100644 index 0000000000..80abccaba9 --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/standard/debug/debug_normal.svg @@ -0,0 +1,4 @@ + + + + diff --git a/designer-base/src/main/resources/com/fr/design/standard/edit/edit_disabled.svg b/designer-base/src/main/resources/com/fr/design/standard/edit/edit_disabled.svg new file mode 100644 index 0000000000..6ac7d0b932 --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/standard/edit/edit_disabled.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/designer-base/src/main/resources/com/fr/design/standard/edit/edit_normal.svg b/designer-base/src/main/resources/com/fr/design/standard/edit/edit_normal.svg new file mode 100644 index 0000000000..3ab4c0b297 --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/standard/edit/edit_normal.svg @@ -0,0 +1,3 @@ + + + diff --git a/designer-base/src/main/resources/com/fr/design/standard/remove/remove_red_normal.svg b/designer-base/src/main/resources/com/fr/design/standard/remove/remove_red_normal.svg new file mode 100644 index 0000000000..74ff5ab385 --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/standard/remove/remove_red_normal.svg @@ -0,0 +1,7 @@ + + + icon_关闭_red + + + + From 10bcd9acdece78afedb635299765b7a4c2bd02b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvan-=E6=AC=A7=E9=98=B3=E5=B8=86?= Date: Tue, 11 Oct 2022 22:37:08 +0800 Subject: [PATCH 02/63] =?UTF-8?q?REPORT-75091=20-=20=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=84=B1=E6=95=8F=EF=BC=88=E6=8A=A5=E8=A1=A8=EF=BC=89=20?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=B4=A8=E9=87=8F=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../desensitization/TableDataPreviewDesensitizeManager.java | 4 ++++ .../view/rule/DesensitizationRuleChoosePane.java | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/TableDataPreviewDesensitizeManager.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/TableDataPreviewDesensitizeManager.java index c8cdae8e72..e2d79fbf70 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/TableDataPreviewDesensitizeManager.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/TableDataPreviewDesensitizeManager.java @@ -45,6 +45,10 @@ public class TableDataPreviewDesensitizeManager implements DesensitizationManage private static final TableDataPreviewDesensitizeManager INSTANCE = new TableDataPreviewDesensitizeManager(); } + /** + * 获取TableDataPreviewDesensitizeManager单例 + * @return + */ public static TableDataPreviewDesensitizeManager getInstance() { return TableDataPreviewDesensitizeManager.Holder.INSTANCE; } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleChoosePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleChoosePane.java index 35901ff4b8..3f8485ffa5 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleChoosePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleChoosePane.java @@ -60,6 +60,10 @@ public class DesensitizationRuleChoosePane extends JPanel { switchPaneByRuleSource(DesensitizationRuleSource.SERVER); } + /** + * 通过脱敏规则来源,切换显示不同的脱敏规则Table面板 + * @param ruleSource + */ public void switchPaneByRuleSource(DesensitizationRuleSource ruleSource) { this.currentRuleSource = ruleSource; this.cardLayout.show(this, ruleSource.name()); From 59001462ddae74c01d8cbb7cd45b3ccb677948e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvan-=E6=AC=A7=E9=98=B3=E5=B8=86?= Date: Thu, 13 Oct 2022 11:38:47 +0800 Subject: [PATCH 03/63] =?UTF-8?q?REPORT-75091=20-=20=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=84=B1=E6=95=8F=EF=BC=88=E6=8A=A5=E8=A1=A8=EF=BC=89=20?= =?UTF-8?q?=E3=80=90=E9=97=AE=E9=A2=98=E5=8E=9F=E5=9B=A0=E3=80=91=20?= =?UTF-8?q?=E3=80=90=E6=94=B9=E5=8A=A8=E6=80=9D=E8=B7=AF=E3=80=91=E6=A0=B9?= =?UTF-8?q?=E6=8D=AE=E8=AF=84=E5=AE=A1=E6=84=8F=E8=A7=81=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=B8=8B=E4=BB=A3=E7=A0=81=EF=BC=8C=E6=B7=BB=E5=8A=A0=E6=B3=A8?= =?UTF-8?q?=E9=87=8A=E3=80=81=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F=E5=8C=96?= =?UTF-8?q?=E7=AD=89=EF=BC=9B=E5=8F=A6=E8=A1=A5=E4=BA=86=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E6=BC=8F=E5=81=9A=E7=9A=84UI=E5=9B=BE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datapane/preview/PreviewTableModel.java | 8 +- .../TableDataPreviewDesensitizeManager.java | 42 +++++---- .../model/DesensitizedPreviewTableModel.java | 1 + .../view/common/DesensitizationOpenPane.java | 94 +++++++++++++++++++ .../rule/DesensitizationRuleChoosePane.java | 4 + .../rule/DesensitizationRuleDebugPane.java | 5 +- .../rule/DesensitizationRuleEditPane.java | 3 + .../view/rule/DesensitizationRulePane.java | 2 + .../DesensitizationRuleSourceChoosePane.java | 1 + .../TableDataDesensitizationSettingPane.java | 32 ++----- .../TableDataDesensitizationTableModel.java | 8 ++ .../TableDataDesensitizationTablePane.java | 2 + .../fr/design/standard/tip/tips_normal.svg | 3 + 13 files changed, 164 insertions(+), 41 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/common/DesensitizationOpenPane.java create mode 100644 designer-base/src/main/resources/com/fr/design/standard/tip/tips_normal.svg diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTableModel.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTableModel.java index 91c8506b79..49ce4ba420 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTableModel.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTableModel.java @@ -20,13 +20,19 @@ public class PreviewTableModel extends AbstractTableModel { private static final int LEN_LIMIT = 1000; private static final String THREE_DOT = "..."; + private static final int DEFAULT_MAX_ROW_COUNT = 10000; private DataModel dataModel; private String erroMessage = null; public IntList dateIndexs = new IntList(4); - public PreviewTableModel() {} + /** + * 为了兼容子类的空参构造,一般不主动使用 + */ + public PreviewTableModel() { + this(new ErrorResultSet(), DEFAULT_MAX_ROW_COUNT); + } public PreviewTableModel(int maxRowCount) { // peter:默认必须显示错误的数据源. diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/TableDataPreviewDesensitizeManager.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/TableDataPreviewDesensitizeManager.java index e2d79fbf70..9cc82dfdda 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/TableDataPreviewDesensitizeManager.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/TableDataPreviewDesensitizeManager.java @@ -30,6 +30,7 @@ import java.util.stream.Collectors; /** * 管理所有数据集预览过程中的脱敏计算 + * * @author Yvan * @version 11.0 * Created by Yvan on 2022/9/14 @@ -47,6 +48,7 @@ public class TableDataPreviewDesensitizeManager implements DesensitizationManage /** * 获取TableDataPreviewDesensitizeManager单例 + * * @return */ public static TableDataPreviewDesensitizeManager getInstance() { @@ -72,29 +74,32 @@ public class TableDataPreviewDesensitizeManager implements DesensitizationManage * @return */ public PreviewTableModel desensitizeTableModel(TableData tableData, PreviewTableModel model) { - if (needDesensitize(tableData)) { - Map desensitizationBeanMap = new LinkedHashMap<>(); - // 获取此数据集的所有脱敏信息 - Collection desensitizationBeans = ((AbstractDesensitizationTableData) tableData).getDesensitizationBeans(); - // 排个序 - List sortedBeans = desensitizationBeans.stream().sorted(Comparator.comparingInt(TableDataDesensitizationBean::getColumnIndex)).collect(Collectors.toList()); - int columnIndex = 0; - for (TableDataDesensitizationBean sortedBean : sortedBeans) { - // 当map中已包含列序号时,代表对这一列设置了不同的脱敏规则,将key + 1 - if (desensitizationBeanMap.containsKey(columnIndex)) { - columnIndex++; - } - desensitizationBeanMap.put(columnIndex, sortedBean); + + Map desensitizationBeanMap = new LinkedHashMap<>(); + // 获取此数据集的所有脱敏信息 + Collection desensitizationBeans = ((AbstractDesensitizationTableData) tableData).getDesensitizationBeans(); + // 去除被禁用的规则 + 排序 + List sortedBeans = desensitizationBeans + .stream() + .filter(bean -> bean.getDesensitizationRule().isEnable()) + .sorted(Comparator.comparingInt(TableDataDesensitizationBean::getColumnIndex)) + .collect(Collectors.toList()); + int columnIndex = 0; + for (TableDataDesensitizationBean sortedBean : sortedBeans) { + // 当map中已包含列序号时,代表对这一列设置了不同的脱敏规则,将key + 1 + if (desensitizationBeanMap.containsKey(columnIndex)) { + columnIndex++; } - // 包装TableModel - return new DesensitizedPreviewTableModel(model, desensitizationBeanMap); + desensitizationBeanMap.put(columnIndex, sortedBean); } - return model; + // 包装TableModel + return new DesensitizedPreviewTableModel(model, desensitizationBeanMap); } /** * 通过TableData获取其列名 * 实现逻辑有点绕,TableData本身并不能返回列名集合,只能先去获取当前模板所有数据集,然后匹配名称拿到TableDataWrapper再获取列名 + * * @param tableData * @return */ @@ -114,6 +119,7 @@ public class TableDataPreviewDesensitizeManager implements DesensitizationManage /** * 这个api会返回 部门职位 + 自定义角色 的Map * 其中 key为 "pid" + "_" + "id",value为 "ptext" + "text" + * * @return */ public Map getAllRoles() { @@ -127,6 +133,7 @@ public class TableDataPreviewDesensitizeManager implements DesensitizationManage /** * 获取所有的部门职位,按照 key为 "pid" + "_" + "id",value为 "ptext" + "text"的格式添加到参数Map中 + * * @param rolesMap */ private void addDepartmentAndPositionRoles2Map(Map rolesMap) { @@ -149,6 +156,7 @@ public class TableDataPreviewDesensitizeManager implements DesensitizationManage /** * 获取所有的自定义角色,按照 id - name添加到参数map里 + * * @param rolesMap */ private void addCustomRoles2Map(Map rolesMap) { @@ -162,6 +170,7 @@ public class TableDataPreviewDesensitizeManager implements DesensitizationManage /** * 合并部门 + 职位的名称 + * * @param departmentName * @param positionName * @return @@ -172,6 +181,7 @@ public class TableDataPreviewDesensitizeManager implements DesensitizationManage /** * 合并部门 + 职位的id + * * @param departmentId * @param positionId * @return diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/model/DesensitizedPreviewTableModel.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/model/DesensitizedPreviewTableModel.java index 066f11374b..e3598e39c0 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/model/DesensitizedPreviewTableModel.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/model/DesensitizedPreviewTableModel.java @@ -98,6 +98,7 @@ public class DesensitizedPreviewTableModel extends PreviewTableModel { /** * 获取当前有效的脱敏字段个数 + * * @return */ public int getDesensitizeColumnsCount() { diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/common/DesensitizationOpenPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/common/DesensitizationOpenPane.java new file mode 100644 index 0000000000..949069aaa8 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/common/DesensitizationOpenPane.java @@ -0,0 +1,94 @@ +package com.fr.design.data.datapane.preview.desensitization.view.common; + +import com.fr.base.svg.IconUtils; +import com.fr.design.border.UITitledBorder; +import com.fr.design.constants.UIConstants; +import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.VerticalFlowLayout; +import com.fr.log.FineLoggerFactory; + +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Desktop; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.net.URL; + +/** + * 启用数据脱敏的面板 + * + * @author Yvan + * @version 11.0 + * Created by Yvan on 2022/10/12 + */ +public class DesensitizationOpenPane extends JPanel { + + /** + * 数据脱敏启用框 + */ + private UICheckBox desensitizeOpenCheckBox; + + /** + * 跳转帮助文档Label + */ + private UILabel hyperlinkLabel; + + /** + * 启用提示Label + */ + private UILabel tipsLabel; + + + public DesensitizationOpenPane() { + VerticalFlowLayout layout = new VerticalFlowLayout(VerticalFlowLayout.TOP); + layout.setAlignLeft(true); + this.setLayout(layout); + this.setBorder(UITitledBorder.createBorderWithTitle(Toolkit.i18nText("Fine-Design_Report_Desensitization_Config"))); + + JPanel panel = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); + // 启用数据脱敏的勾选框 + desensitizeOpenCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_Desensitization_Opened")); + // 跳转帮助文档Label + hyperlinkLabel = new UILabel(IconUtils.readIcon("/com/fr/design/standard/tip/tips")); + hyperlinkLabel.setToolTipText(Toolkit.i18nText("Fine-Design_Report_Desensitization_Open_Tips")); + hyperlinkLabel.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent event) { + try { + URL url = new URL(Toolkit.i18nText("Fine-Design_Report_Desensitization_Help_Document_Url")); + Desktop.getDesktop().browse(url.toURI()); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e, "open browse of table data desensitization help document failed for {}", e.getMessage()); + } + } + }); + panel.add(desensitizeOpenCheckBox); + panel.add(hyperlinkLabel); + + // 提示Label + tipsLabel = new UILabel(Toolkit.i18nText("Fine-Design_Report_Desensitization_Opened_Tooltips")); + tipsLabel.setForeground(UIConstants.CHECK_BOX_TIP_FONT_COLOR); + + this.add(panel); + this.add(tipsLabel); + } + + /** + * 数据脱敏启用状态 + * @return + */ + public boolean isDesensitizationOpened() { + return desensitizeOpenCheckBox.isSelected(); + } + + /** + * 设置数据脱敏启用状态 + * @param opened + */ + public void setDesensitizationOpened(boolean opened) { + desensitizeOpenCheckBox.setSelected(opened); + } +} diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleChoosePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleChoosePane.java index 3f8485ffa5..16900defa4 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleChoosePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleChoosePane.java @@ -62,6 +62,7 @@ public class DesensitizationRuleChoosePane extends JPanel { /** * 通过脱敏规则来源,切换显示不同的脱敏规则Table面板 + * * @param ruleSource */ public void switchPaneByRuleSource(DesensitizationRuleSource ruleSource) { @@ -125,10 +126,13 @@ public class DesensitizationRuleChoosePane extends JPanel { DesensitizationRule rule = getList().get(rowIndex); switch (columnIndex) { case 0: + // 选中状态 return rule.equals(getSelectedValue()); case 1: + // 脱敏规则名称 return rule.getRuleName(); case 2: + // 脱敏规则描述 return DesensitizationRule.getDescription(rule); default: return StringUtils.EMPTY; diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleDebugPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleDebugPane.java index 71998b7bee..5f74dee9c0 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleDebugPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleDebugPane.java @@ -24,6 +24,7 @@ import java.awt.event.FocusListener; /** * 脱敏规则调试页 + * * @author Yvan * @version 11.0 * Created by Yvan on 2022/9/8 @@ -53,7 +54,7 @@ public class DesensitizationRuleDebugPane extends BasicPane { UILabel desensitizationRule = new UILabel(Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule_Algorithm")); UILabel characterReplace = new UILabel(rule.getRuleType().getTypeName()); UILabel description = new UILabel(DesensitizationRule.getDescription(rule)); - JComponent[][] components = new JComponent[][] { + JComponent[][] components = new JComponent[][]{ {desensitizationRule, characterReplace}, {new UILabel(), description} }; @@ -104,7 +105,7 @@ public class DesensitizationRuleDebugPane extends BasicPane { } }); - JComponent[][] components = new JComponent[][] { + JComponent[][] components = new JComponent[][]{ {beforeDesensitize, beforeDesensitizeText, desensitizeButton}, {afterDesensitize, afterDesensitizeText, new UILabel()} }; diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleEditPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleEditPane.java index 9c2c467fe3..2f526f4b8f 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleEditPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleEditPane.java @@ -136,6 +136,7 @@ public class DesensitizationRuleEditPane extends BasicBeanPane /** * 处理规则来源选择面板中改动来源的事件 + * * @param newRuleSource */ public void dealWithRuleSourceChanged(DesensitizationRuleSource newRuleSource) { diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleSourceChoosePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleSourceChoosePane.java index f67512164e..05ace32bdd 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleSourceChoosePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleSourceChoosePane.java @@ -11,6 +11,7 @@ import java.awt.FlowLayout; /** * 脱敏规则来源选择页面 + * * @author Yvan * @version 11.0 * Created by Yvan on 2022/9/26 diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationSettingPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationSettingPane.java index f63bcdacc3..91119b4083 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationSettingPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationSettingPane.java @@ -3,19 +3,17 @@ package com.fr.design.data.datapane.preview.desensitization.view.setting; import com.fr.data.desensitize.base.AbstractDesensitizationTableData; import com.fr.data.desensitize.base.TableDataDesensitizationBean; import com.fr.design.beans.BasicBeanPane; -import com.fr.design.constants.UIConstants; -import com.fr.design.gui.icheckbox.UICheckBox; -import com.fr.design.gui.ilable.UILabel; +import com.fr.design.data.datapane.preview.desensitization.view.common.DesensitizationOpenPane; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import javax.swing.JComponent; -import javax.swing.JPanel; import java.awt.BorderLayout; import java.util.List; /** * 数据集脱敏字段设置页面 + * * @author Yvan * @version 11.0 * Created by Yvan on 2022/9/8 @@ -27,7 +25,7 @@ public class TableDataDesensitizationSettingPane extends BasicBeanPane tableDataDesensitizationBeans) { diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTableModel.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTableModel.java index 36322c3980..099f5d0b1b 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTableModel.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTableModel.java @@ -109,12 +109,16 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter generateRolesIdsBySelectedValues() { diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTablePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTablePane.java index 77546b9ef1..b9311f0c4b 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTablePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTablePane.java @@ -12,6 +12,7 @@ import java.util.List; /** * 脱敏字段设置页面中的Table + * * @author Yvan * @version 11.0 * Created by Yvan on 2022/9/14 @@ -48,6 +49,7 @@ public class TableDataDesensitizationTablePane extends JPanel { /** * 展示此TableData中已配置的脱敏规则信息 + * * @param tableData */ public void populateDesensitizationSetting(AbstractDesensitizationTableData tableData) { diff --git a/designer-base/src/main/resources/com/fr/design/standard/tip/tips_normal.svg b/designer-base/src/main/resources/com/fr/design/standard/tip/tips_normal.svg new file mode 100644 index 0000000000..cfc3370a66 --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/standard/tip/tips_normal.svg @@ -0,0 +1,3 @@ + + + From 6fef48938c09950fc802a268d3b819c9437747b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvan-=E6=AC=A7=E9=98=B3=E5=B8=86?= Date: Thu, 13 Oct 2022 16:32:11 +0800 Subject: [PATCH 04/63] =?UTF-8?q?REPORT-75091=20-=20=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=84=B1=E6=95=8F=EF=BC=88=E6=8A=A5=E8=A1=A8=EF=BC=89=20?= =?UTF-8?q?=E3=80=90=E9=97=AE=E9=A2=98=E5=8E=9F=E5=9B=A0=E3=80=91=E4=B9=8B?= =?UTF-8?q?=E5=89=8D=E7=94=A8AbstractDesensitizationTabledata=E6=8A=BD?= =?UTF-8?q?=E8=B1=A1=E7=B1=BB=E4=BD=9C=E4=B8=BA=E6=89=80=E6=9C=89=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=9B=86=E7=9A=84=E9=A1=B6=E5=B1=82=E6=8A=BD=E8=B1=A1?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=EF=BC=8C=E5=9C=A8=E8=AF=BB=E5=86=99=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E5=80=99=E6=9C=89=E7=82=B9=E8=86=88=E5=BA=94=EF=BC=8C?= =?UTF-8?q?=E4=B8=BB=E8=A6=81=E6=98=AF=E5=8F=AF=E8=83=BD=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E6=A0=87=E7=AD=BE=E5=86=97=E4=BD=99=EF=BC=8C=E6=88=96=E8=80=85?= =?UTF-8?q?=E7=A0=B4=E5=9D=8F=E5=8E=9F=E6=9C=89=E8=AF=BB=E5=86=99=E5=A7=94?= =?UTF-8?q?=E6=89=98=E7=9A=84=E5=B1=82=E7=BA=A7=20=E3=80=90=E6=94=B9?= =?UTF-8?q?=E5=8A=A8=E6=80=9D=E8=B7=AF=E3=80=91=E7=8E=B0=E5=9C=A8=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E4=B8=BADesensitizationTableData=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=EF=BC=8CAbstractTableData=E5=AE=9E=E7=8E=B0=E6=AD=A4=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=EF=BC=8C=E5=B9=B6=E5=9C=A8=E5=86=85=E9=83=A8=E6=8F=90?= =?UTF-8?q?=E4=BE=9B=E8=AF=BB=E5=86=99=E7=9A=84=E5=B7=A5=E5=85=B7=E6=96=B9?= =?UTF-8?q?=E6=B3=95=EF=BC=8C=E5=AD=90=E7=B1=BB=E7=BB=9F=E4=B8=80=E9=80=9A?= =?UTF-8?q?=E8=BF=87=E8=B0=83=E7=94=A8=E5=B7=A5=E5=85=B7=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E7=9A=84=E6=96=B9=E5=BC=8F=E6=9D=A5=E8=AF=BB=E5=8F=96=E8=84=B1?= =?UTF-8?q?=E6=95=8F=E8=A7=84=E5=88=99=E4=BF=A1=E6=81=AF=20=E3=80=90review?= =?UTF-8?q?=E5=BB=BA=E8=AE=AE=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datapane/preview/PreviewTablePane.java | 10 +++++----- .../TableDataPreviewDesensitizeManager.java | 10 +++++----- .../TableDataDesensitizationSettingPane.java | 14 +++++++------- .../TableDataDesensitizationTableModel.java | 6 +++--- .../setting/TableDataDesensitizationTablePane.java | 8 ++++---- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java index 6665c6f772..dc3bc6ed8d 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java @@ -6,7 +6,7 @@ package com.fr.design.data.datapane.preview; import com.fr.base.TableData; import com.fr.base.svg.IconUtils; import com.fr.data.TableDataSource; -import com.fr.data.desensitize.base.AbstractDesensitizationTableData; +import com.fr.data.desensitize.base.DesensitizationTableData; import com.fr.data.impl.DBTableData; import com.fr.data.impl.EmbeddedTableData; import com.fr.data.impl.NameDataModel; @@ -236,8 +236,8 @@ public class PreviewTablePane extends BasicPane { desensitizationLabel.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { - TableDataDesensitizationSettingPane settingPane = new TableDataDesensitizationSettingPane((AbstractDesensitizationTableData) tableData); - settingPane.populateBean((AbstractDesensitizationTableData) tableData); + TableDataDesensitizationSettingPane settingPane = new TableDataDesensitizationSettingPane((DesensitizationTableData) tableData); + settingPane.populateBean((DesensitizationTableData) tableData); BasicDialog dialog = settingPane.showWindowWithCustomSize(SwingUtilities.getWindowAncestor(PreviewTablePane.this), new DialogActionAdapter() { @Override public void doOk() { @@ -775,7 +775,7 @@ public class PreviewTablePane extends BasicPane { * @return */ private boolean isDesensitizeOpened() { - return tableData instanceof AbstractDesensitizationTableData && - ((AbstractDesensitizationTableData) tableData).getDesensitizeOpen(); + return tableData instanceof DesensitizationTableData && + ((DesensitizationTableData) tableData).isDesensitizeOpen(); } } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/TableDataPreviewDesensitizeManager.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/TableDataPreviewDesensitizeManager.java index 9cc82dfdda..0632de3e65 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/TableDataPreviewDesensitizeManager.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/TableDataPreviewDesensitizeManager.java @@ -2,7 +2,7 @@ package com.fr.design.data.datapane.preview.desensitization; import com.fr.base.TableData; -import com.fr.data.desensitize.base.AbstractDesensitizationTableData; +import com.fr.data.desensitize.base.DesensitizationTableData; import com.fr.data.desensitize.base.TableDataDesensitizationBean; import com.fr.data.desensitize.manage.DesensitizationManager; import com.fr.data.desensitize.util.DesentizationUtils; @@ -62,9 +62,9 @@ public class TableDataPreviewDesensitizeManager implements DesensitizationManage * @return */ public boolean needDesensitize(TableData tableData) { - return tableData instanceof AbstractDesensitizationTableData && - DesentizationUtils.isCollectionNotEmpty(((AbstractDesensitizationTableData) tableData).getDesensitizationBeans()) && - ((AbstractDesensitizationTableData) tableData).getDesensitizationBeans().stream().noneMatch(TableDataDesensitizationBean::invalid); + return tableData instanceof DesensitizationTableData && + DesentizationUtils.isCollectionNotEmpty(((DesensitizationTableData) tableData).getDesensitizationBeans()) && + ((DesensitizationTableData) tableData).getDesensitizationBeans().stream().noneMatch(TableDataDesensitizationBean::invalid); } /** @@ -77,7 +77,7 @@ public class TableDataPreviewDesensitizeManager implements DesensitizationManage Map desensitizationBeanMap = new LinkedHashMap<>(); // 获取此数据集的所有脱敏信息 - Collection desensitizationBeans = ((AbstractDesensitizationTableData) tableData).getDesensitizationBeans(); + Collection desensitizationBeans = ((DesensitizationTableData) tableData).getDesensitizationBeans(); // 去除被禁用的规则 + 排序 List sortedBeans = desensitizationBeans .stream() diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationSettingPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationSettingPane.java index 91119b4083..a706efb2fb 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationSettingPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationSettingPane.java @@ -1,6 +1,6 @@ package com.fr.design.data.datapane.preview.desensitization.view.setting; -import com.fr.data.desensitize.base.AbstractDesensitizationTableData; +import com.fr.data.desensitize.base.DesensitizationTableData; import com.fr.data.desensitize.base.TableDataDesensitizationBean; import com.fr.design.beans.BasicBeanPane; import com.fr.design.data.datapane.preview.desensitization.view.common.DesensitizationOpenPane; @@ -18,19 +18,19 @@ import java.util.List; * @version 11.0 * Created by Yvan on 2022/9/8 */ -public class TableDataDesensitizationSettingPane extends BasicBeanPane { +public class TableDataDesensitizationSettingPane extends BasicBeanPane { /** * 设置针对的数据集 */ - private AbstractDesensitizationTableData tableData; + private DesensitizationTableData tableData; private DesensitizationOpenPane desensitizationOpenPane; private TableDataDesensitizationTablePane tableDataDesensitizationTablePane; - public TableDataDesensitizationSettingPane(AbstractDesensitizationTableData tableData) { + public TableDataDesensitizationSettingPane(DesensitizationTableData tableData) { this.tableData = tableData; initComponents(); } @@ -67,14 +67,14 @@ public class TableDataDesensitizationSettingPane extends BasicBeanPane editorPane; - public TableDataDesensitizationTablePane(AbstractDesensitizationTableData tableData, Component parent) { + public TableDataDesensitizationTablePane(DesensitizationTableData tableData, Component parent) { this.tableData = tableData; this.parent = parent; initComponent(); @@ -52,7 +52,7 @@ public class TableDataDesensitizationTablePane extends JPanel { * * @param tableData */ - public void populateDesensitizationSetting(AbstractDesensitizationTableData tableData) { + public void populateDesensitizationSetting(DesensitizationTableData tableData) { this.tableData = tableData; editorPane.populate(tableData.getDesensitizationBeans().toArray(new TableDataDesensitizationBean[0])); } From ac1a14dbec338fafde33da86d2549a244874bcb8 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Tue, 18 Oct 2022 18:22:16 +0800 Subject: [PATCH 05/63] =?UTF-8?q?REPORT-75998=20=E4=BF=AE=E6=94=B9UI?= =?UTF-8?q?=E4=B8=8E=E9=80=82=E9=85=8D=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/images/replace/change_normal.svg | 3 + .../com/fr/design/images/replace/replace.png | Bin 418 -> 437 bytes .../design/images/replace/replace_normal.svg | 5 +- .../replace/ui/ITReplaceMainDialog.java | 8 +- .../replace/ui/ITReplaceNorthPanel.java | 152 ++++++++++-------- .../replace/ui/ITReplaceSouthPanel.java | 8 + .../replace/ui/ITReplaceWestPanel.java | 24 ++- 7 files changed, 129 insertions(+), 71 deletions(-) create mode 100644 designer-base/src/main/resources/com/fr/design/images/replace/change_normal.svg diff --git a/designer-base/src/main/resources/com/fr/design/images/replace/change_normal.svg b/designer-base/src/main/resources/com/fr/design/images/replace/change_normal.svg new file mode 100644 index 0000000000..88d9e7772b --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/images/replace/change_normal.svg @@ -0,0 +1,3 @@ + + + diff --git a/designer-base/src/main/resources/com/fr/design/images/replace/replace.png b/designer-base/src/main/resources/com/fr/design/images/replace/replace.png index e736042724c17a037500b250aaeb5802acdb5366..b9a41125c56b58c9d71f27677bf6f951f453466a 100644 GIT binary patch delta 395 zcmV;60d)SN1GNJoiBL{Q4GJ0x0000DNk~Le0000E0000E2nGNE03S##(UBoFe@aP2 zK~#7Fl~PMm!axx184_16@C3#aFd<4=uHp^2fp`Mu2I39m26}^V0<&@c*INWAsQVwQOp9 z&ER)9Z!H+35c%x7&W%l+9~t9>e_qz@-o9)xg2_We;rce8C$GD*EC2&WHAK#4({afN z5E?w%2eR_53LN7qO<2M$TdU@Zqznj({3w*DzM2yae+7AWrz_EoOxEo@@vUx#kCet*T>;my~VLX8|Pm<}R zTt`u?KJ1bq*+V1R2dZ}|wRXc&@><3{WE7uZw$~V}QN=<6mJIA*)cQ(&|7-!92!bBu p=spY(l^HBE#tyn1r)m7}{vUt!e|(l%aLoV!002ovPDHLkV1gCat@{7~ delta 376 zcmV-;0f+vz1EK>ViBL{Q4GJ0x0000DNk~Le0000G0000G2nGNE03Y-JVUZyX`) zK~#7Fty0@j0x=ZL%~AjzKnEmbmk)p34xj_D0x7`~umYt6I&k^%Lv~3z04mUbXE&a^ z=s50UP~^^JlAPq8`#M7W)2Ip5I=c40P~``b&f3lTR|M=xR6G*V9?LQ2y_kRudl6e} z4{bz3sc>vevJZ{05Q?~ZGHN`C3 z+ - + + + + diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java index 9a2f5c8de7..6ea30d9896 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java @@ -20,6 +20,7 @@ import com.fr.general.GeneralUtils; import com.fr.stable.StringUtils; +import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import java.awt.BorderLayout; @@ -55,6 +56,7 @@ public class ITReplaceMainDialog extends UIDialog { private String searchStr; private static final int FIRST_ROW = 0; public static int selectCount = 0; + public static int MAIN_PANEL_WIDTH = 929 ; public ITReplaceMainDialog() { super(DesignerContext.getDesignerFrame()); @@ -97,8 +99,8 @@ public class ITReplaceMainDialog extends UIDialog { int width = jTemplate.getWidth(); Point point = jTemplate.getLocationOnScreen(); setModal(false); - setMaximumSize(new Dimension(jTemplate.getWidth(), jTemplate.getHeight())); - setMinimumSize(new Dimension(jTemplate.getWidth(), 240)); + setMaximumSize(new Dimension(width, jTemplate.getHeight())); + setMinimumSize(new Dimension(width, 240)); setSize(width, height); setLocation(new Point(point.x, point.y + jTemplate.getHeight() / 2 + jTemplate.getHeight() / 2 - 385)); @@ -124,7 +126,7 @@ public class ITReplaceMainDialog extends UIDialog { replaceComboBox.setEnabled(false); replaceComboBox.setEditable(true); northPane.getReplaceButton().setEnabled(false); - + westPanel.getLeftPanel().setPreferredSize(new Dimension(ITReplaceWestPanel.LEFT_WIDTH,this.getHeight())); ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).setPlaceholder(Toolkit.i18nText("Fine-Design_Replace_Search_Input")); ((UITextField) (northPane.getReplaceInputCombobox().getEditor().getEditorComponent())).setPlaceholder(Toolkit.i18nText("Fine-Design_Replace_Input")); ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).addActionListener(new ActionListener() { diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java index a4fe1fef0f..909ce7112a 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java @@ -1,5 +1,6 @@ package com.fr.design.actions.replace.ui; +import com.fr.base.svg.IconUtils; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icontainer.UIScrollPane; @@ -9,7 +10,9 @@ import com.fr.design.i18n.Toolkit; import com.fr.stable.StringUtils; +import javax.swing.BorderFactory; import javax.swing.ComboBoxEditor; +import javax.swing.Icon; import javax.swing.JCheckBox; import javax.swing.JPanel; import javax.swing.ScrollPaneConstants; @@ -34,20 +37,28 @@ public class ITReplaceNorthPanel { private UIComboBox findCombobox; private UIComboBox rangeCombobox; private JCheckBox matchRadioButton; + private UILabel iconLabel; private UIComboBox findInputCombobox; private UIComboBox replaceInputCombobox; private UIScrollPane scrollPane; private UIButton replaceButton; private UIButton searchButton; + private static double rate = 1.00; //存储的5次最近输入 private int maxItemCount = 5; - private static final int LIMIT_WIDTH = 1250; + private static int limit_width = 800; private static final int HEIGHT = 161; - private static final int BUTTON_WIDTH = 60; - private static final int BUTTON_GAP = 20; + private static final int BUTTON_WIDTH = 44; + private static final int GAP = 20; + private static final int BUTTON_GAP = 10; private static final int MATCH_WIDTH = 70; + private static final int COMPONENT_HEIGHT = 25; + private static final int FIRST_Y = 15, SECOND_Y = 50, THIRD_Y = 85, FOURTH_Y = 120; + private static final int FIRST_X = 20, SECOND_X = 80; + private static final int LABEL_WIDTH = 60; + private static final Icon CHANGE_ICON = IconUtils.readIcon("/com/fr/design/images/replace/change_normal.svg"); private int findLabelX, findLabelY, findLabelWidth, findLabelHeight; @@ -60,7 +71,8 @@ public class ITReplaceNorthPanel { private int replaceInputComboBoxX, replaceInputComboBoxY, replaceInputComboBoxWidth, replaceInputComboBoxHeight; private int replaceButtonX, replaceButtonY, replaceButtonHeight; private int searchButtonX, searchButtonY, searchButtonHeight; - + private int iconX, iconY, iconWidth, iconHeight; + private int inputLength; public static ArrayList findItems = new ArrayList<>(); public static ArrayList findInputItems = new ArrayList<>(); @@ -81,6 +93,7 @@ public class ITReplaceNorthPanel { findLabel = new UILabel(Toolkit.i18nText("Fine-Design_Replace_Search_Element")); rangeLabel = new UILabel(Toolkit.i18nText("Fine-Design_Replace_Search_Range")); + iconLabel = new UILabel(CHANGE_ICON); resultLabel = new UILabel(); String[] rangeItems = new String[]{Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Current")}; @@ -109,7 +122,7 @@ public class ITReplaceNorthPanel { replaceButton = new UIButton(Toolkit.i18nText("Fine-Design_Replace_Button")); searchButton = new UIButton(Toolkit.i18nText("Fine-Design_Search_Button")); - upPanel.setPreferredSize(new Dimension(LIMIT_WIDTH, HEIGHT)); + upPanel.setPreferredSize(new Dimension(limit_width, HEIGHT)); scrollPane = new UIScrollPane(upPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); upPanel.add(findLabel); upPanel.add(rangeLabel); @@ -121,6 +134,8 @@ public class ITReplaceNorthPanel { upPanel.add(matchRadioButton); upPanel.add(replaceButton); upPanel.add(searchButton); + upPanel.add(iconLabel); + scrollPane.setBorder(BorderFactory.createEmptyBorder()); } /** @@ -129,9 +144,8 @@ public class ITReplaceNorthPanel { * @param width */ public void setLimitSize(int width) { - width = Math.max(LIMIT_WIDTH, width); - upPanel.setMaximumSize(new Dimension(width, 161)); - upPanel.setPreferredSize(new Dimension(width, 161)); + upPanel.setMaximumSize(new Dimension(limit_width, 161)); + upPanel.setPreferredSize(new Dimension(limit_width, 161)); } @@ -144,21 +158,22 @@ public class ITReplaceNorthPanel { */ public void fitScreen(int x, int y, int templateWidth) { - templateWidth = Math.max(templateWidth, LIMIT_WIDTH); - - setFindLabelBounds(x, y, templateWidth); - setRangeLabelBounds(x, y, templateWidth); - setResultLabelBounds(x, y, templateWidth); + templateWidth = Math.max(ITReplaceMainDialog.MAIN_PANEL_WIDTH, templateWidth); + templateWidth = templateWidth - ITReplaceWestPanel.LEFT_WIDTH; + inputLength = (templateWidth - GAP * 5) / 2; - setFindComboboxBounds(x, y, templateWidth); - setRangeComboboxBounds(x, y, templateWidth); - setFindInputComboboxBounds(x, y, templateWidth); - setReplaceInputComboboxBounds(x, y, templateWidth); - - setUIRadioButtonBounds(x, y, templateWidth); - setReplaceButtonBounds(x, y, templateWidth); - setSearchButtonBounds(x, y, templateWidth); + setFindLabelBounds(); + setResultLabelBounds(templateWidth); + setFindComboboxBounds(); + setFindInputComboboxBounds(); + setReplaceInputComboboxBounds(templateWidth); + setRangeLabelBounds(); + setRangeComboboxBounds(); + setUIRadioButtonBounds(); + setReplaceButtonBounds(); + setSearchButtonBounds(); + setIconLabelBounds(); } @@ -214,87 +229,94 @@ public class ITReplaceNorthPanel { this.scrollPane = scrollPane; } + private void setIconLabelBounds() { + iconX = inputLength + GAP; + iconY = SECOND_Y; + iconWidth = GAP; + iconHeight = COMPONENT_HEIGHT; + iconLabel.setBounds(iconX, iconY, iconWidth, iconHeight); + } - private void setSearchButtonBounds(int x, int y, int templateWidth) { - searchButtonHeight = 25; - searchButtonY = resultLabelY; + private void setSearchButtonBounds() { + searchButtonHeight = COMPONENT_HEIGHT; + searchButtonY = FOURTH_Y; searchButtonX = replaceInputComboBoxX + replaceInputComboBoxWidth - BUTTON_WIDTH * 2 - BUTTON_GAP; searchButton.setBounds(searchButtonX, searchButtonY, BUTTON_WIDTH, searchButtonHeight); } - private void setReplaceButtonBounds(int x, int y, int templateWidth) { - replaceButtonHeight = 25; - replaceButtonY = resultLabelY; + private void setReplaceButtonBounds() { + replaceButtonHeight = COMPONENT_HEIGHT; + replaceButtonY = FOURTH_Y; replaceButtonX = replaceInputComboBoxX + replaceInputComboBoxWidth - BUTTON_WIDTH; replaceButton.setBounds(replaceButtonX, replaceButtonY, BUTTON_WIDTH, replaceButtonHeight); } - private void setReplaceInputComboboxBounds(int x, int y, int templateWidth) { - replaceInputComboBoxX = x + templateWidth / 2 + templateWidth / 60; - replaceInputComboBoxY = y + 55; - replaceInputComboBoxWidth = templateWidth / 3 + templateWidth / 30 * 2; - replaceInputComboBoxHeight = 25; + private void setReplaceInputComboboxBounds(int templateWidth) { + replaceInputComboBoxX = templateWidth - inputLength - GAP * 2; + replaceInputComboBoxY = SECOND_Y; + replaceInputComboBoxWidth = inputLength; + replaceInputComboBoxHeight = COMPONENT_HEIGHT; replaceInputCombobox.setBounds(replaceInputComboBoxX, replaceInputComboBoxY, replaceInputComboBoxWidth, replaceInputComboBoxHeight); } - private void setFindInputComboboxBounds(int x, int y, int templateWidth) { - findInputComboBoxX = x + templateWidth / 60; - findInputComboBoxY = y + 55; - findInputComboBoxWidth = templateWidth / 3 + templateWidth / 30 * 2; - findInputComboBoxHeight = 25; + private void setFindInputComboboxBounds() { + findInputComboBoxX = FIRST_X; + findInputComboBoxY = SECOND_Y; + findInputComboBoxWidth = inputLength - GAP; + findInputComboBoxHeight = COMPONENT_HEIGHT; findInputCombobox.setBounds(findInputComboBoxX, findInputComboBoxY, findInputComboBoxWidth, findInputComboBoxHeight); } - private void setUIRadioButtonBounds(int x, int y, int templateWidth) { - matchX = x + templateWidth / 60; - matchY = y + 90; + private void setUIRadioButtonBounds() { + matchX = FIRST_X; + matchY = THIRD_Y; matchWidth = MATCH_WIDTH; - matchHeight = 25; + matchHeight = COMPONENT_HEIGHT; matchRadioButton.setBounds(matchX, matchY, matchWidth, matchHeight); } - private void setRangeComboboxBounds(int x, int y, int templateWidth) { - rangeComboBoxX = x + templateWidth / 2 + templateWidth / 15; - rangeComboBoxY = y + 20; - rangeComboBoxWidth = templateWidth / 3 + templateWidth / 60; - rangeComboBoxHeight = 25; + private void setRangeComboboxBounds() { + rangeComboBoxX = rangeLabelX + rangeLabelWidth; + rangeComboBoxY = FIRST_Y; + rangeComboBoxWidth = inputLength - 3 * GAP; + rangeComboBoxHeight = COMPONENT_HEIGHT; rangeCombobox.setBounds(rangeComboBoxX, rangeComboBoxY, rangeComboBoxWidth, rangeComboBoxHeight); } - private void setFindComboboxBounds(int x, int y, int templateWidth) { - findComboBoxX = x + templateWidth / 30 * 2; - findComboBoxY = y + 20; - findComboBoxWidth = templateWidth / 3 + templateWidth / 60; - findComboBoxHeight = 25; + private void setFindComboboxBounds() { + findComboBoxX = SECOND_X; + findComboBoxY = FIRST_Y; + findComboBoxWidth = inputLength - 4 * GAP; + findComboBoxHeight = COMPONENT_HEIGHT; findCombobox.setBounds(findComboBoxX, findComboBoxY, findComboBoxWidth, findComboBoxHeight); } - private void setResultLabelBounds(int x, int y, int templateWidth) { - resultLabelX = findLabelX; - resultLabelY = y + 125; + private void setResultLabelBounds(int templateWidth) { + resultLabelX = FIRST_X; + resultLabelY = FOURTH_Y; resultLabelWidth = templateWidth; - resultLabelHeight = 25; + resultLabelHeight = COMPONENT_HEIGHT; resultLabel.setBounds(resultLabelX, resultLabelY, resultLabelWidth, resultLabelHeight); } - private void setRangeLabelBounds(int x, int y, int templateWidth) { - rangeLabelX = x + templateWidth / 2 + templateWidth / 60; - rangeLabelY = y + 20; - rangeLabelWidth = findLabelWidth; - rangeLabelHeight = 25; + private void setRangeLabelBounds() { + rangeLabelX = replaceInputComboBoxX; + rangeLabelY = FIRST_Y; + rangeLabelWidth = LABEL_WIDTH; + rangeLabelHeight = COMPONENT_HEIGHT; rangeLabel.setBounds(rangeLabelX, rangeLabelY, rangeLabelWidth, rangeLabelHeight); } - private void setFindLabelBounds(int x, int y, int templateWidth) { - findLabelX = x + templateWidth / 60; - findLabelY = y + 20; - findLabelWidth = templateWidth / 20; - findLabelHeight = 25; + private void setFindLabelBounds() { + findLabelX = FIRST_X; + findLabelY = FIRST_Y; + findLabelWidth = LABEL_WIDTH; + findLabelHeight = COMPONENT_HEIGHT; findLabel.setBounds(findLabelX, findLabelY, findLabelWidth, findLabelHeight); } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java index a240eba967..ef27f7e47e 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java @@ -1,8 +1,12 @@ package com.fr.design.actions.replace.ui; +import javax.swing.BorderFactory; +import javax.swing.JPanel; import javax.swing.RowSorter; +import javax.swing.border.EmptyBorder; import javax.swing.table.TableRowSorter; import java.awt.Color; +import java.awt.Label; /** * 下面板 @@ -18,10 +22,13 @@ public class ITReplaceSouthPanel { public static final int CHECKBOX_INDEX = 0; //ITContent在表格的列索引 public static final int CONTENT_INDEX = 6; + public static final int TABLE_GAP = 20; public ITReplaceSouthPanel() { itTableEditor = new ITTableEditor(); tableEditorPane = new ITTableEditorPane<>(itTableEditor); + //左右两边间距20 + tableEditorPane.setBorder(BorderFactory.createEmptyBorder(0,TABLE_GAP,0,TABLE_GAP)); RowSorter sorter = new TableRowSorter(itTableEditor){ @Override public boolean isSortable(int column) { @@ -29,6 +36,7 @@ public class ITReplaceSouthPanel { } }; tableEditorPane.getEditTable().setRowSorter(sorter); + tableEditorPane.getEditTable().setBorder(BorderFactory.createEmptyBorder()); tableEditorPane.getEditTable().setSelectionBackground(new Color(217, 235, 254)); tableEditorPane.getEditTable().setRowHeight(tableEditorPane.getEditTable().getRowHeight() / 2 + tableEditorPane.getEditTable().getRowHeight()); tableEditorPane.makeFace(tableEditorPane.getEditTable()); diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java index a58091a06a..d64cd4efd4 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java @@ -7,14 +7,20 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.share.ui.base.MouseClickListener; import com.fr.design.utils.BrowseUtils; import com.fr.general.CloudCenter; +import com.fr.general.FRFont; import com.fr.stable.StringUtils; +import com.fr.third.com.lowagie.text.FontFactory; import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.JPanel; +import javax.swing.SwingConstants; import java.awt.Color; import java.awt.Cursor; +import java.awt.Font; import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.awt.event.MouseEvent; /** @@ -29,7 +35,8 @@ public class ITReplaceWestPanel { private UILabel iconLabel; private static final Icon HELP_ICON = IconUtils.readIcon("com/fr/design/images/buttonicon/replace_help.svg"); private static final String HELP_URL = CloudCenter.getInstance().acquireUrlByKind("design.replace.help", "https://help.fanruan.com/finereport/doc-view-4954.html?source=3"); - private static final int FILL_COUNT = 13; + private static final int FILL_COUNT = 12; + public static final int LEFT_WIDTH = 100; public ITReplaceWestPanel() { @@ -37,6 +44,18 @@ public class ITReplaceWestPanel { iconLabel = new UILabel("" + Toolkit.i18nText("Fine-Design_Report_Community_Help") + ""); UIToggleButton contentButton = new UIToggleButton(Toolkit.i18nText("Fine-Design_Basic_Templates_Content")); + contentButton.setText(""+Toolkit.i18nText("Fine-Design_Basic_Templates_Content")+ ""); + contentButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (!contentButton.isSelected()) { + contentButton.setText(""+Toolkit.i18nText("Fine-Design_Basic_Templates_Content")+ ""); + } else { + contentButton.setText(Toolkit.i18nText("Fine-Design_Basic_Templates_Content")); + } + } + }); + leftPanel.setBackground(Color.WHITE); contentButton.setSelected(true); contentButton.setBorderPainted(false); leftPanel.add(contentButton); @@ -47,8 +66,8 @@ public class ITReplaceWestPanel { } //添加帮助文档按钮及超链 - iconLabel.setIcon(HELP_ICON); iconLabel.setToolTipText(Toolkit.i18nText("Fine-Design_Replace_Tooltip")); + iconLabel.setHorizontalAlignment(SwingConstants.CENTER); //设置游标 iconLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); iconLabel.addMouseListener(new MouseClickListener() { @@ -58,6 +77,7 @@ public class ITReplaceWestPanel { } }); leftPanel.add(iconLabel); + leftPanel.add(new UILabel(StringUtils.EMPTY)); } public JPanel getLeftPanel() { From 8b4065e774318c10ff85c7de65a1f7fcd8ffda01 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Tue, 18 Oct 2022 18:27:31 +0800 Subject: [PATCH 06/63] =?UTF-8?q?REPORT-75998=20=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/actions/replace/ui/ITReplaceMainDialog.java | 4 ++-- .../com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java | 4 ++-- .../com/fr/design/actions/replace/ui/ITReplaceWestPanel.java | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java index 6ea30d9896..d0ae2d13cc 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java @@ -56,7 +56,7 @@ public class ITReplaceMainDialog extends UIDialog { private String searchStr; private static final int FIRST_ROW = 0; public static int selectCount = 0; - public static int MAIN_PANEL_WIDTH = 929 ; + public static int MAIN_PANEL_WIDTH = 929; public ITReplaceMainDialog() { super(DesignerContext.getDesignerFrame()); @@ -126,7 +126,7 @@ public class ITReplaceMainDialog extends UIDialog { replaceComboBox.setEnabled(false); replaceComboBox.setEditable(true); northPane.getReplaceButton().setEnabled(false); - westPanel.getLeftPanel().setPreferredSize(new Dimension(ITReplaceWestPanel.LEFT_WIDTH,this.getHeight())); + westPanel.getLeftPanel().setPreferredSize(new Dimension(ITReplaceWestPanel.LEFT_WIDTH, this.getHeight())); ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).setPlaceholder(Toolkit.i18nText("Fine-Design_Replace_Search_Input")); ((UITextField) (northPane.getReplaceInputCombobox().getEditor().getEditorComponent())).setPlaceholder(Toolkit.i18nText("Fine-Design_Replace_Input")); ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).addActionListener(new ActionListener() { diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java index ef27f7e47e..f3dc6296ec 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java @@ -28,8 +28,8 @@ public class ITReplaceSouthPanel { itTableEditor = new ITTableEditor(); tableEditorPane = new ITTableEditorPane<>(itTableEditor); //左右两边间距20 - tableEditorPane.setBorder(BorderFactory.createEmptyBorder(0,TABLE_GAP,0,TABLE_GAP)); - RowSorter sorter = new TableRowSorter(itTableEditor){ + tableEditorPane.setBorder(BorderFactory.createEmptyBorder(0, TABLE_GAP, 0, TABLE_GAP)); + RowSorter sorter = new TableRowSorter(itTableEditor) { @Override public boolean isSortable(int column) { return column != CHECKBOX_INDEX || column != CONTENT_INDEX; diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java index d64cd4efd4..344a37f9b0 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java @@ -44,12 +44,12 @@ public class ITReplaceWestPanel { iconLabel = new UILabel("" + Toolkit.i18nText("Fine-Design_Report_Community_Help") + ""); UIToggleButton contentButton = new UIToggleButton(Toolkit.i18nText("Fine-Design_Basic_Templates_Content")); - contentButton.setText(""+Toolkit.i18nText("Fine-Design_Basic_Templates_Content")+ ""); + contentButton.setText("" + Toolkit.i18nText("Fine-Design_Basic_Templates_Content") + ""); contentButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (!contentButton.isSelected()) { - contentButton.setText(""+Toolkit.i18nText("Fine-Design_Basic_Templates_Content")+ ""); + contentButton.setText("" + Toolkit.i18nText("Fine-Design_Basic_Templates_Content") + ""); } else { contentButton.setText(Toolkit.i18nText("Fine-Design_Basic_Templates_Content")); } From 8f657a3d85d13a78f2e9309979508cb2021acb89 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Tue, 18 Oct 2022 18:29:32 +0800 Subject: [PATCH 07/63] =?UTF-8?q?REPORT-75998=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/actions/replace/ui/ITReplaceWestPanel.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java index 344a37f9b0..5497169e90 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java @@ -37,6 +37,7 @@ public class ITReplaceWestPanel { private static final String HELP_URL = CloudCenter.getInstance().acquireUrlByKind("design.replace.help", "https://help.fanruan.com/finereport/doc-view-4954.html?source=3"); private static final int FILL_COUNT = 12; public static final int LEFT_WIDTH = 100; + public static final String CONTENT_TEXT = "" + Toolkit.i18nText("Fine-Design_Basic_Templates_Content") + ""; public ITReplaceWestPanel() { @@ -44,12 +45,12 @@ public class ITReplaceWestPanel { iconLabel = new UILabel("" + Toolkit.i18nText("Fine-Design_Report_Community_Help") + ""); UIToggleButton contentButton = new UIToggleButton(Toolkit.i18nText("Fine-Design_Basic_Templates_Content")); - contentButton.setText("" + Toolkit.i18nText("Fine-Design_Basic_Templates_Content") + ""); + contentButton.setText(CONTENT_TEXT); contentButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (!contentButton.isSelected()) { - contentButton.setText("" + Toolkit.i18nText("Fine-Design_Basic_Templates_Content") + ""); + contentButton.setText(CONTENT_TEXT); } else { contentButton.setText(Toolkit.i18nText("Fine-Design_Basic_Templates_Content")); } From 79cfbaee26ac9b29a61b8a621e9b2d3d4f661520 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Wed, 19 Oct 2022 09:14:02 +0800 Subject: [PATCH 08/63] =?UTF-8?q?REPORT-75998=20=E5=8E=BB=E9=99=A4?= =?UTF-8?q?=E5=A4=9A=E4=BD=99=E7=9A=84=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/actions/replace/ui/ITReplaceMainDialog.java | 1 - .../com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java | 3 --- .../com/fr/design/actions/replace/ui/ITReplaceWestPanel.java | 3 --- 3 files changed, 7 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java index d0ae2d13cc..4e31314e4e 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java @@ -20,7 +20,6 @@ import com.fr.general.GeneralUtils; import com.fr.stable.StringUtils; -import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import java.awt.BorderLayout; diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java index f3dc6296ec..997013592d 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java @@ -1,12 +1,9 @@ package com.fr.design.actions.replace.ui; import javax.swing.BorderFactory; -import javax.swing.JPanel; import javax.swing.RowSorter; -import javax.swing.border.EmptyBorder; import javax.swing.table.TableRowSorter; import java.awt.Color; -import java.awt.Label; /** * 下面板 diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java index 5497169e90..0804efa23b 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java @@ -7,9 +7,7 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.share.ui.base.MouseClickListener; import com.fr.design.utils.BrowseUtils; import com.fr.general.CloudCenter; -import com.fr.general.FRFont; import com.fr.stable.StringUtils; -import com.fr.third.com.lowagie.text.FontFactory; import javax.swing.BorderFactory; import javax.swing.Icon; @@ -17,7 +15,6 @@ import javax.swing.JPanel; import javax.swing.SwingConstants; import java.awt.Color; import java.awt.Cursor; -import java.awt.Font; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; From bbd4658c0a6e6403c26c122d2e277505e701c2a3 Mon Sep 17 00:00:00 2001 From: Carlson Date: Thu, 20 Oct 2022 20:09:21 +0800 Subject: [PATCH 09/63] =?UTF-8?q?REPORT-79287=20fix:=E5=9B=BE=E8=A1=A8?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E7=BC=96=E8=BE=91=E7=95=8C=E9=9D=A2=E6=9B=B4?= =?UTF-8?q?=E6=8D=A2=E6=95=B0=E6=8D=AE=E9=9B=86=E5=90=8E=E4=B9=8B=E5=89=8D?= =?UTF-8?q?=E7=9A=84=E5=8C=B9=E9=85=8D=E6=B8=85=E7=A9=BA=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E6=B8=85=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/mainframe/chart/gui/data/TableDataPane.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/TableDataPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/TableDataPane.java index 8863977740..55745cd1d2 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/TableDataPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/TableDataPane.java @@ -15,10 +15,10 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; import com.fr.design.utils.gui.UIComponentUtils; +import com.fr.stable.StringUtils; -import javax.swing.BorderFactory; -import java.awt.BorderLayout; -import java.awt.Dimension; +import javax.swing.*; +import java.awt.*; public class TableDataPane extends FurtherBasicBeanPane{ private static final long serialVersionUID = 4740461028440155147L; @@ -74,6 +74,10 @@ public class TableDataPane extends FurtherBasicBeanPane{ return; } if(dataContentPane != null) { + // 如果属性编辑画板中选中的数据集发生改变,则清空之前的匹配项 + if (!StringUtils.equals(dataContentPane.getTableName(), dataWrap.getTableDataName())) { + dataContentPane.clearAllBoxList(); + } dataContentPane.onSelectTableData(dataWrap); dataContentPane.setTableName(dataWrap.getTableDataName()); } From 1128719f38515e29c583ce82b68b3fff81d0f49e Mon Sep 17 00:00:00 2001 From: Carlson Date: Fri, 21 Oct 2022 14:37:12 +0800 Subject: [PATCH 10/63] =?UTF-8?q?REPORT-79287=20import=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/mainframe/chart/gui/data/TableDataPane.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/TableDataPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/TableDataPane.java index 55745cd1d2..82240bc6d2 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/TableDataPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/TableDataPane.java @@ -17,8 +17,9 @@ import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane import com.fr.design.utils.gui.UIComponentUtils; import com.fr.stable.StringUtils; -import javax.swing.*; -import java.awt.*; +import javax.swing.BorderFactory; +import java.awt.BorderLayout; +import java.awt.Dimension; public class TableDataPane extends FurtherBasicBeanPane{ private static final long serialVersionUID = 4740461028440155147L; From b9e8b5227a7e96c76b9220947ab8b02c62f18ce5 Mon Sep 17 00:00:00 2001 From: levy Date: Fri, 21 Oct 2022 18:13:37 +0800 Subject: [PATCH 11/63] =?UTF-8?q?REPORT-82110=20=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E5=8F=96=E8=89=B2bug=20=E3=80=90=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E5=8E=9F=E5=9B=A0=E3=80=91=E5=8F=96=E8=89=B2=E5=99=A8ColorPick?= =?UTF-8?q?er=E5=8F=96=E8=89=B2=E6=98=AF=E5=9F=BA=E4=BA=8E=E6=88=AA?= =?UTF-8?q?=E5=B1=8F=E5=90=8E=E8=AF=BB=E5=8F=96=E9=A2=9C=E8=89=B2=E7=9A=84?= =?UTF-8?q?=EF=BC=8C=E5=9B=A0=E6=AD=A4=E9=9C=80=E7=A1=AE=E4=BF=9D=E5=BC=B9?= =?UTF-8?q?=E5=87=BA=E6=A1=86=E5=85=A8=E9=83=A8=E5=85=B3=E9=97=AD=E5=90=8E?= =?UTF-8?q?=E6=88=AA=E5=B1=8F=E3=80=82=20=E3=80=90=E6=94=B9=E5=8A=A8?= =?UTF-8?q?=E6=80=9D=E8=B7=AF=E3=80=911=E3=80=81=E5=8F=96=E8=89=B2?= =?UTF-8?q?=E5=89=8D=E6=B7=BB=E5=8A=A0hidePopupMenu=E7=9A=84=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=202=E3=80=81=E4=BD=BF=E7=94=A8invokeLater=E7=A1=AE?= =?UTF-8?q?=E4=BF=9D=E5=BC=82=E6=AD=A5=E4=BB=BB=E5=8A=A1=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=90=8E=E6=88=AA=E5=B1=8F=203=E3=80=81?= =?UTF-8?q?=E4=B8=BA=E9=81=BF=E5=85=8DREPORT-25645=E7=9A=84macOS=E9=80=82?= =?UTF-8?q?=E9=85=8D=E9=97=AE=E9=A2=98,=E6=96=B0=E5=A2=9EhidePopupMenu4Pic?= =?UTF-8?q?kColor=E7=9A=84=E6=96=B9=E6=B3=95=20=E3=80=90Review=E5=BB=BA?= =?UTF-8?q?=E8=AE=AE=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/style/color/ColorPicker.java | 11 ++++------- .../fr/design/style/color/UIToolbarColorButton.java | 10 ++++++++++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorPicker.java b/designer-base/src/main/java/com/fr/design/style/color/ColorPicker.java index 2e5f56981d..baf7920e14 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/ColorPicker.java +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorPicker.java @@ -70,13 +70,10 @@ public class ColorPicker extends JDialog implements ActionListener { // 主要针对"图案"选项卡中的"前景"、"背景" if (this.setColorRealTime) { colorSelectable.setColor(Color.WHITE); // setColor 可以关闭弹窗 - try { - Thread.sleep(100); // 等待弹窗关闭 - } catch (InterruptedException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - Thread.currentThread().interrupt(); - } - colorPickerPanel.captureScreen(); + // REPORT-82110 确保关闭所有弹窗后截屏 + SwingUtilities.invokeLater(() -> { + colorPickerPanel.captureScreen(); + }); } } diff --git a/designer-base/src/main/java/com/fr/design/style/color/UIToolbarColorButton.java b/designer-base/src/main/java/com/fr/design/style/color/UIToolbarColorButton.java index 9a8640f627..11fe154469 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/UIToolbarColorButton.java +++ b/designer-base/src/main/java/com/fr/design/style/color/UIToolbarColorButton.java @@ -153,12 +153,22 @@ public class UIToolbarColorButton extends UICombinationButton implements PopupHi popupWin = null; } + // 取色器取色时,隐藏弹出框,无需经过macOS的判断 + public void hidePopupMenu4PickColor() { + if (popupWin != null) { + popupWin.setVisible(false); + } + + popupWin = null; + } + private ColorControlWindow getColorControlWindow() { //find parant. if (this.popupWin == null) { this.popupWin = new ColorControlWindow(this.isCanBeNull(), UIToolbarColorButton.this) { @Override protected void colorChanged() { + hidePopupMenu4PickColor(); UIToolbarColorButton.this.setColor(this.getColor()); } From 828671fce4d3f9d67203d6474450d0019aaf8a9f Mon Sep 17 00:00:00 2001 From: levy Date: Mon, 24 Oct 2022 18:33:07 +0800 Subject: [PATCH 12/63] =?UTF-8?q?REPORT-82110=20=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E5=8F=96=E8=89=B2bug=20=E3=80=90=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E5=8E=9F=E5=9B=A0=E3=80=91=E5=8F=96=E8=89=B2=E5=99=A8ColorPick?= =?UTF-8?q?er=E5=8F=96=E8=89=B2=E6=98=AF=E5=9F=BA=E4=BA=8E=E6=88=AA?= =?UTF-8?q?=E5=B1=8F=E5=90=8E=E8=AF=BB=E5=8F=96=E9=A2=9C=E8=89=B2=E7=9A=84?= =?UTF-8?q?=EF=BC=8C=E5=9B=A0=E6=AD=A4=E9=9C=80=E7=A1=AE=E4=BF=9D=E5=BC=B9?= =?UTF-8?q?=E5=87=BA=E6=A1=86=E5=85=A8=E9=83=A8=E5=85=B3=E9=97=AD=E5=90=8E?= =?UTF-8?q?=E6=88=AA=E5=B1=8F=E3=80=82=20=E3=80=90=E6=94=B9=E5=8A=A8?= =?UTF-8?q?=E6=80=9D=E8=B7=AF=E3=80=911=E3=80=81=E5=8F=96=E8=89=B2?= =?UTF-8?q?=E5=89=8D=E6=B7=BB=E5=8A=A0hidePopupMenu=E7=9A=84=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=202=E3=80=81=E4=BD=BF=E7=94=A8invokeLater=E7=A1=AE?= =?UTF-8?q?=E4=BF=9D=E5=BC=82=E6=AD=A5=E4=BB=BB=E5=8A=A1=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=90=8E=E6=88=AA=E5=B1=8F=203=E3=80=81?= =?UTF-8?q?=E4=B8=BA=E8=A7=84=E9=81=BFREPORT-25645=E7=9A=84macOS=E9=80=82?= =?UTF-8?q?=E9=85=8D=E9=97=AE=E9=A2=98,=E6=96=B0=E5=A2=9EhidePopupMenu4Pic?= =?UTF-8?q?kColor=E7=9A=84=E6=96=B9=E6=B3=95=20=E3=80=90Review=E5=BB=BA?= =?UTF-8?q?=E8=AE=AE=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/style/color/ColorPicker.java | 5 +---- .../java/com/fr/design/style/color/UIToolbarColorButton.java | 5 +++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorPicker.java b/designer-base/src/main/java/com/fr/design/style/color/ColorPicker.java index baf7920e14..067d82f9ce 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/ColorPicker.java +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorPicker.java @@ -67,13 +67,10 @@ public class ColorPicker extends JDialog implements ActionListener { hideCursor(); // 如果要求实时变化,确保先关闭弹窗,再截屏 - // 主要针对"图案"选项卡中的"前景"、"背景" if (this.setColorRealTime) { colorSelectable.setColor(Color.WHITE); // setColor 可以关闭弹窗 // REPORT-82110 确保关闭所有弹窗后截屏 - SwingUtilities.invokeLater(() -> { - colorPickerPanel.captureScreen(); - }); + SwingUtilities.invokeLater(colorPickerPanel :: captureScreen); } } diff --git a/designer-base/src/main/java/com/fr/design/style/color/UIToolbarColorButton.java b/designer-base/src/main/java/com/fr/design/style/color/UIToolbarColorButton.java index 11fe154469..8627f27a5f 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/UIToolbarColorButton.java +++ b/designer-base/src/main/java/com/fr/design/style/color/UIToolbarColorButton.java @@ -153,12 +153,13 @@ public class UIToolbarColorButton extends UICombinationButton implements PopupHi popupWin = null; } - // 取色器取色时,隐藏弹出框,无需经过macOS的判断 + /** + * 取色器取色时隐藏弹出框,与另一个hide的区别是无需经过macOS的判断,以规避REPORT-25645的mac适配bug + */ public void hidePopupMenu4PickColor() { if (popupWin != null) { popupWin.setVisible(false); } - popupWin = null; } From 88790a4fec33864193006bf7e2e4908804133656 Mon Sep 17 00:00:00 2001 From: levy Date: Mon, 24 Oct 2022 18:53:38 +0800 Subject: [PATCH 13/63] =?UTF-8?q?REPORT-79296=20=E6=8A=A5=E8=A1=A8?= =?UTF-8?q?=E5=BC=95=E6=93=8E=E5=B1=9E=E6=80=A7=E6=98=BE=E7=A4=BA=E4=B8=8D?= =?UTF-8?q?=E5=85=A8=20=E3=80=90=E9=97=AE=E9=A2=98=E5=8E=9F=E5=9B=A0?= =?UTF-8?q?=E3=80=91=E6=9C=AA=E8=80=83=E8=99=91i8n=E8=8B=B1=E6=96=87?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E4=B8=8B=E7=9A=84Label=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E6=8D=A2=E8=A1=8C=20=E3=80=90=E6=94=B9=E5=8A=A8=E6=80=9D?= =?UTF-8?q?=E8=B7=AF=E3=80=91=E5=B0=86=E6=B6=89=E5=8F=8A=E5=88=B0=E7=9A=84?= =?UTF-8?q?Label=E8=87=AA=E5=8A=A8=E6=8D=A2=E8=A1=8C=E5=A4=84=E7=90=86?= =?UTF-8?q?=EF=BC=8C=E7=95=A5=E4=BF=AE=E6=94=B9=E4=BA=86=E5=8E=9F=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E5=88=9B=E5=BB=BApanel=E7=9A=84=E5=B8=83=E5=B1=80?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=EF=BC=8C=E5=AE=9E=E9=99=85=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=95=88=E6=9E=9C=E6=97=A0=E5=8F=98=E5=8C=96=E3=80=82=20?= =?UTF-8?q?=E3=80=90Review=E5=BB=BA=E8=AE=AE=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/report/ReportEnginePane.java | 79 ++++++++++--------- 1 file changed, 41 insertions(+), 38 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/report/ReportEnginePane.java b/designer-realize/src/main/java/com/fr/design/report/ReportEnginePane.java index b29de8855f..15dd2a3ea3 100644 --- a/designer-realize/src/main/java/com/fr/design/report/ReportEnginePane.java +++ b/designer-realize/src/main/java/com/fr/design/report/ReportEnginePane.java @@ -12,12 +12,14 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.DesignerContext; +import com.fr.design.widget.FRWidgetFactory; import com.fr.general.SiteCenter; import com.fr.log.FineLoggerFactory; import com.fr.report.core.ReportUtils; import com.fr.report.stable.LayerReportAttr; import com.fr.report.worksheet.WorkSheet; import com.fr.stable.ProductConstants; + import javax.swing.AbstractButton; import javax.swing.BorderFactory; import javax.swing.ButtonGroup; @@ -26,13 +28,11 @@ import javax.swing.JLayeredPane; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JRadioButton; -import javax.swing.SwingConstants; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; import java.awt.Desktop; import java.awt.Dimension; -import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; @@ -86,7 +86,7 @@ public class ReportEnginePane extends BasicBeanPane { outAdvicePane.add(createAdvicePane()); } - private JPanel createReportEnginePane(){ + private JPanel createReportEnginePane() { JPanel reportEnginePane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_M_Pane(); JPanel clientPagingPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); clientPaging = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Enable_Client_Page")); @@ -102,7 +102,7 @@ public class ReportEnginePane extends BasicBeanPane { return reportEnginePane; } - private JPanel createPagingEngineSelectPane(){ + private JPanel createPagingEngineSelectPane() { engineSettingPane = new JLayeredPane(); engineSettingPane.setPreferredSize(new Dimension(570, 240)); engineSettingPane.setBounds(0, 0, 570, 240); @@ -121,8 +121,8 @@ public class ReportEnginePane extends BasicBeanPane { /** * 目前先屏蔽,后面新引擎显示页码再加上相关代码 - * */ - private void createEngineXSettingPane(){ + */ + private void createEngineXSettingPane() { outEngineXSettingPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_New_Engine")); outEngineXSettingPane.setBounds(0, 0, 570, 240); JPanel engineXSettingPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_M_Pane(); @@ -146,7 +146,7 @@ public class ReportEnginePane extends BasicBeanPane { outEngineXSettingPane.add(engineXSettingPane); } - private void createLineEngineSettingPane(){ + private void createLineEngineSettingPane() { outLineEngineSettingPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Line_Engine")); outLineEngineSettingPane.setBounds(0, 0, 570, 240); JPanel lineEngineSettingPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_M_Pane(); @@ -166,9 +166,9 @@ public class ReportEnginePane extends BasicBeanPane { outLineEngineSettingPane.add(lineEngineSettingPane); } - private JPanel createTipPane(String tipText){ + private JPanel createTipPane(String tipText) { JPanel tipPane = new JPanel(); - UILabel tip = new UILabel(tipText, SwingConstants.LEFT); + UILabel tip = FRWidgetFactory.createLineWrapLabel(tipText, 420); tip.setForeground(new Color(128, 128, 128)); tipPane.add(tip); return tipPane; @@ -184,20 +184,19 @@ public class ReportEnginePane extends BasicBeanPane { return pageQueryPane; } - private JPanel createAdvicePane(){ - JPanel advicePane = new JPanel(new BorderLayout()); - FRExplainLabel topExplainLabel = new FRExplainLabel(Toolkit.i18nText("Fine-Design_Report_Report_Engine_Warnning_Info")); - advicePane.add(topExplainLabel, BorderLayout.NORTH); + private JPanel createAdvicePane() { + JPanel advicePane = new JPanel(FRGUIPaneFactory.create1ColumnGridLayout()); + // 上侧文字 + UILabel topExplainLabel = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Report_Report_Engine_Warnning_Info"), 480); topExplainLabel.setForeground(new Color(0, 0, 0)); - FlowLayout flowLayout = new FlowLayout(FlowLayout.LEADING); - flowLayout.setHgap(0); - flowLayout.setVgap(0); - JPanel adviceDownPane = new JPanel(flowLayout); - advicePane.add(adviceDownPane, BorderLayout.CENTER); - FRExplainLabel downExplainLabel = new FRExplainLabel(Toolkit.i18nText("Fine-Design_Report_Report_Detail_Reference")); + advicePane.add(topExplainLabel); + // 下侧文字及链接 + JPanel adviceDownPane = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); + advicePane.add(adviceDownPane); + UILabel downExplainLabel = new UILabel(Toolkit.i18nText("Fine-Design_Report_Report_Detail_Reference")); adviceDownPane.add(downExplainLabel); downExplainLabel.setForeground(new Color(0, 0, 0)); - JLabel helper = new FRExplainLabel( com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Community_Help")); + JLabel helper = new FRExplainLabel(Toolkit.i18nText("Fine-Design_Report_Community_Help")); helper.setForeground(new Color(1, 159, 222)); adviceDownPane.add(helper); helper.addMouseListener(new MouseAdapter() { @@ -213,7 +212,7 @@ public class ReportEnginePane extends BasicBeanPane { return advicePane; } - private JPanel createPagingEngineRadioPanel(){ + private JPanel createPagingEngineRadioPanel() { UIRadioButton newEngine = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_New_Engine"), true); UIRadioButton lineEngine = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Line_Engine"), false); ButtonGroup buttonGroup = new ButtonGroup(); @@ -225,7 +224,7 @@ public class ReportEnginePane extends BasicBeanPane { double[] rowSize = {p}; double[] columnSize = {p, p, p, p, p}; Component[][] components = new Component[][]{ - new Component[] { + new Component[]{ newEngine, lineEngine } @@ -243,7 +242,7 @@ public class ReportEnginePane extends BasicBeanPane { @Override public void populateBean(LayerReportAttr ob) { - if (ob == null){ + if (ob == null) { setDefaultAttr(); return; } @@ -252,14 +251,14 @@ public class ReportEnginePane extends BasicBeanPane { engineSettingPane.setVisible(true); radioButtons.get(0).setSelected(ob.getEngineState() == LayerReportAttr.ENGINE_X); radioButtons.get(1).setSelected(ob.getEngineState() == LayerReportAttr.LINE_ENGINE); - if (ob.getEngineState() == LayerReportAttr.ENGINE_X){ + if (ob.getEngineState() == LayerReportAttr.ENGINE_X) { engineSettingPane.moveToFront(outEngineXSettingPane); outEngineXSettingPane.setVisible(true); outLineEngineSettingPane.setVisible(false); engineXCountPerPageEditor.setValue(new Integer(ob.getCountPerPage())); engineXPageQueryBox.setSelected(ob.isPageQuery()); engineXPageQueryPane.setVisible(ob.isPageQuery()); - }else { + } else { engineSettingPane.moveToFront(outLineEngineSettingPane); outEngineXSettingPane.setVisible(false); outLineEngineSettingPane.setVisible(true); @@ -275,16 +274,16 @@ public class ReportEnginePane extends BasicBeanPane { //这里注意一下怎么更新的,后续可能存在判断为空的调用,从而对老引擎造成影响。 LayerReportAttr attr = new LayerReportAttr(); attr.setClientPaging(clientPaging.isSelected()); - for (int i = 0; i < radioButtons.size(); i++){ - if (radioButtons.get(i).isSelected()){ + for (int i = 0; i < radioButtons.size(); i++) { + if (radioButtons.get(i).isSelected()) { attr.setEngineState(i); } } - if (attr.getEngineState() == LayerReportAttr.ENGINE_X){ + if (attr.getEngineState() == LayerReportAttr.ENGINE_X) { attr.setEnableRowCount(rowCountBox.isSelected()); attr.setCountPerPage(engineXCountPerPageEditor.getValue().intValue()); attr.setPageQuery(engineXPageQueryBox.isSelected()); - }else { + } else { attr.setPageQuery(lineEnginePageQueryBox.isSelected()); attr.setCountPerPage(lineEngineCountPerPageEditor.getValue()); } @@ -304,7 +303,8 @@ public class ReportEnginePane extends BasicBeanPane { } } } - public void setDefaultAttr(){ + + public void setDefaultAttr() { clientPaging.setSelected(false); lineEngineCountPerPageEditor.setValue(30); lineEnginePageQueryBox.setSelected(false); @@ -315,26 +315,29 @@ public class ReportEnginePane extends BasicBeanPane { private class SelectActionListener implements ActionListener { private AbstractButton source; private JPanel target; - private SelectActionListener(AbstractButton source, JPanel target){ + + private SelectActionListener(AbstractButton source, JPanel target) { this.source = source; this.target = target; } + @Override public void actionPerformed(ActionEvent e) { - if (source.isSelected()){ + if (source.isSelected()) { target.setVisible(true); - }else { + } else { target.setVisible(false); } } } - private class EngineSelectActionListener implements ActionListener{ + private class EngineSelectActionListener implements ActionListener { private AbstractButton source; private JLayeredPane target; private JPanel showTarget; private JPanel notShowTarget; - private EngineSelectActionListener(AbstractButton source, JLayeredPane target, JPanel showTarget, JPanel notShowTarget){ + + private EngineSelectActionListener(AbstractButton source, JLayeredPane target, JPanel showTarget, JPanel notShowTarget) { this.source = source; this.target = target; this.showTarget = showTarget; @@ -344,15 +347,15 @@ public class ReportEnginePane extends BasicBeanPane { /** * 由于屏蔽了新引擎设置,由于新引擎设置界面是空的,行式引擎的设置界面会显示出来,因此每次界面转换时,将不需要显示的界面屏蔽。 * 不需要屏蔽新引擎设置时,就不需要showTarget.setVisible(true);notShowTarget.setVisible(false);这两行代码了 - * **/ + **/ @Override public void actionPerformed(ActionEvent e) { - if (source.isSelected()){ + if (source.isSelected()) { target.setVisible(true); showTarget.setVisible(true); notShowTarget.setVisible(false); target.moveToFront(showTarget); - }else { + } else { target.setVisible(false); } } From 37961dbec685c18cb8d66ac8d6e9bfd2d8f8728e Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Thu, 27 Oct 2022 15:33:37 +0800 Subject: [PATCH 14/63] =?UTF-8?q?REPORT-80695=20=E3=80=90=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E5=85=A8=E5=B1=80=E7=BA=A7=E5=88=AB=E6=9F=A5=E6=89=BE?= =?UTF-8?q?=E6=9B=BF=E6=8D=A2=E4=BA=8C=E6=9C=9F=E3=80=91UI=E7=95=8C?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/gui/icheckbox/UICheckBox.java | 15 +- .../replace/ui/ITReplaceMainDialog.java | 254 +++++++++- .../replace/ui/ITReplaceNorthPanel.java | 442 ++++++++++++++++-- .../replace/ui/ITReplaceSouthPanel.java | 6 +- .../replace/ui/ITReplaceWestPanel.java | 62 ++- .../actions/replace/ui/ITTableButton.java | 7 +- .../actions/replace/ui/ITTableEditor.java | 77 ++- .../actions/replace/ui/ITTableEditorPane.java | 46 +- 8 files changed, 805 insertions(+), 104 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java b/designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java index 0ddd3e22d2..8162c7ba86 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java +++ b/designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java @@ -139,6 +139,15 @@ public class UICheckBox extends JCheckBox implements UIObserver, GlobalNameObser return true; } + /** + * 获取UICheckBox的UI层,可以用于设置UI + * + * @return UICheckBoxUI + */ + public UICheckBoxUI getUICheckBoxUI(){ + return new UICheckBoxUI(); + } + private class UICheckBoxUI extends MetalCheckBoxUI { @Override public synchronized void paint(Graphics g, JComponent c) { @@ -186,9 +195,9 @@ public class UICheckBox extends JCheckBox implements UIObserver, GlobalNameObser g2d.drawRoundRect(iconRect.x, iconRect.y, iconRect.width - 1, iconRect.height - 1, UIConstants.ARC, UIConstants.ARC); } - if (model.isSelected()) { - UIConstants.YES_ICON.paintIcon(c, g, iconRect.x + 2, iconRect.y + 2); - } + if (model.isSelected()) { + UIConstants.YES_ICON.paintIcon(c, g, iconRect.x + 2, iconRect.y + 2); + } g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); // Draw the Text diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java index 4e31314e4e..f80609e39d 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java @@ -3,6 +3,7 @@ package com.fr.design.actions.replace.ui; import com.fr.design.actions.replace.action.ShowSearchResultAction; +import com.fr.design.actions.replace.action.setting.SettingController; import com.fr.design.actions.replace.info.Info; import com.fr.design.actions.replace.utils.ShowValueUtils; @@ -42,7 +43,8 @@ import static com.fr.design.actions.replace.ui.ITTableEditorPane.getEditTable; * created by Destiny.Lin on 2022-08-10 */ public class ITReplaceMainDialog extends UIDialog { - List searchResultList = new ArrayList<>(); + private static List searchContentResultList = new ArrayList<>(); + private static List searchSettingResultList = new ArrayList<>(); private static boolean ITReplaceFlag = false; private static boolean matched = false; private static volatile ITReplaceMainDialog instance = null; @@ -53,9 +55,19 @@ public class ITReplaceMainDialog extends UIDialog { private ITReplaceWestPanel westPanel; private boolean searchFlag; private String searchStr; + private String settingInputStr; + private String settingExtraStr; private static final int FIRST_ROW = 0; + private static final int NONE = 0; public static int selectCount = 0; public static int MAIN_PANEL_WIDTH = 929; + public static int replaceContentNum = 0; + public static int replaceSettingNum = 0; + public static int contentReplaceCount = 0; + public static int contentReplaceFailedCount = 0; + public static int settingReplaceCount = 0; + public static int settingReplaceFailedCount = 0; + public ITReplaceMainDialog() { super(DesignerContext.getDesignerFrame()); @@ -131,15 +143,14 @@ public class ITReplaceMainDialog extends UIDialog { ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - search(); + search4Content(); } }); northPane.getSearchButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - search(); - + search4Content(); } }); @@ -147,11 +158,24 @@ public class ITReplaceMainDialog extends UIDialog { @Override public void actionPerformed(ActionEvent e) { if (isSearchFlag()) { - replace(); + replace4Content(); } } }); - center.add(northPane.getScrollPane(), BorderLayout.NORTH); + + northPane.getSearchSettingButton().addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + search4Setting(); + } + }); + northPane.getReplaceSettingButton().addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + replace4Setting(); + } + }); + center.add(ITReplaceNorthPanel.getCardPanel(), BorderLayout.NORTH); center.add(southPanel.getTableEditorPane(), BorderLayout.CENTER); add(westPanel.getLeftPanel(), BorderLayout.WEST); //主体部分 @@ -162,24 +186,27 @@ public class ITReplaceMainDialog extends UIDialog { /** * 替换 */ - private void replace() { + private void replace4Content() { String searchStr = ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).getText(); String replaceStr = ((UITextField) (northPane.getReplaceInputCombobox().getEditor().getEditorComponent())).getText(); - //替换内容为空需要触发搜索 - if (isITReplaceValid() && checkTemplateChanged(searchResultList)) { + clearContentCount(); + if (isITReplaceValid() && checkTemplateChanged(searchContentResultList)) { if (StringUtils.equals(getSearchStr(), searchStr) && StringUtils.isNotEmpty(replaceStr)) { HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified(true); - for (Info info : searchResultList) { - if (info.getContent().isSelected()) { + for (Info info : searchContentResultList) { + if (isAllow2Replace(info)) { info.setValue(info, searchStr, replaceStr, info.getContent().getOperatorArray()); + info.getContent().setReplaced(true); + contentReplaceCount++; } } + northPane.getResultLabel().setText(ShowValueUtils.getResultTip(searchContentResultList.size(), contentReplaceCount, contentReplaceFailedCount)); southPanel.getTableEditorPane().update(); northPane.refreshReplaceInputComboBoxItems(); ITTableEditorPane.getEditTable().repaint(); - setSearchFlag(false); + } else { + search4Content(); } - search(); } else { Object[] options = new Object[]{Toolkit.i18nText("Fine-Design_Replace_Search_Again"), Toolkit.i18nText("Fine-Design_Basic_Cancel")}; int optionSelected = FineJOptionPane.showOptionDialog( @@ -195,16 +222,25 @@ public class ITReplaceMainDialog extends UIDialog { ); //如果选择了重新查找,则再查找一遍 if (optionSelected == 0) { - search(); + search4Content(); } } + } - + /** + * 是否能够替换 + * + * @param info 存储信息的数据结构 + * @return 能则返回true + */ + private boolean isAllow2Replace(Info info) { + return info.getContent().isSelected() && !info.getContent().isReplaced(); } + private Boolean checkTemplateChanged(List searchResultList) { for (Info info : searchResultList) { - if (!info.checkValid()) { + if (!info.getContent().isReplaced() && !info.checkValid()) { return false; } } @@ -281,10 +317,11 @@ public class ITReplaceMainDialog extends UIDialog { } /** - * 搜索 + * 搜索模板内容 */ - public void search() { + public void search4Content() { ITTableEditor itTableEditor = southPanel.getItTableEditor(); + clearContentCount(); if (JTemplate.isValid(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate())) { JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); templateID = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget().getTemplateID(); @@ -299,24 +336,25 @@ public class ITReplaceMainDialog extends UIDialog { ShowSearchResultAction searchAction = ShowSearchResultAction.match(GeneralUtils.objectToString(northPane.getFindCombobox().getSelectedItem())); //搜索 if (searchAction != null) { - searchResultList = searchAction.addMatchResult(searchStr, searchAction.showSearchValue(jTemplate)); - itTableEditor.add(searchResultList); - northPane.getResultLabel().setText("" + Toolkit.i18nText("Fine-Design_Replace_Search_Finish") + "" + searchResultList.size() + "" + Toolkit.i18nText("Fine-Design_Replace_Result")); + searchContentResultList = searchAction.addMatchResult(searchStr, searchAction.showSearchValue(jTemplate)); + itTableEditor.add(searchContentResultList); + northPane.getResultLabel().setText(ShowValueUtils.getResultTip(searchContentResultList.size(), contentReplaceCount, contentReplaceFailedCount)); } + replaceContentNum = 0; ITTableEditorPane.ITHeaderRenderer renderer = (ITTableEditorPane.ITHeaderRenderer) getEditTable().getTableHeader().getDefaultRenderer(); //刷新表头,并且重新勾选中表头全选框 renderer.refreshHeader(getEditTable(), true); itTableEditor.fireTableDataChanged(); northPane.refreshFindInputComboBoxItems(); setSearchFlag(true); - selectCount = searchResultList.size(); + selectCount = searchContentResultList.size(); //如果有结果,默认选中第一行 - if (searchResultList.size() > 0) { + if (searchContentResultList.size() > 0) { getEditTable().addRowSelectionInterval(FIRST_ROW, FIRST_ROW); } //更新替换按钮可用性 - if (StringUtils.isEmpty(searchStr) || searchResultList.size() == 0) { + if (StringUtils.isEmpty(searchStr) || searchContentResultList.size() == 0) { northPane.getReplaceButton().setEnabled(false); } else { northPane.getReplaceButton().setEnabled(true); @@ -330,6 +368,126 @@ public class ITReplaceMainDialog extends UIDialog { } + /** + * 搜索设置项 + */ + public void search4Setting() { + ITTableEditor settingEditor = southPanel.getItTableEditor(); + templateID = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget().getTemplateID(); + templateName = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTemplateName(); + clearSettingCount(); + if (JTemplate.isValid(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate())) { + String firstStr = GeneralUtils.objectToString(northPane.getFindSettingComboBox().getSelectedItem()); + String secondStr = GeneralUtils.objectToString(northPane.getFindSettingInputComboBox().getSelectedItem()); + String thirdStr = GeneralUtils.objectToString(northPane.getFindExtraSettingComboBox().getSelectedItem()); + setSettingInputStr(secondStr); + setSettingExtraStr(thirdStr); + SettingController controller = SettingController.match(firstStr); + if (controller != null) { + searchSettingResultList = controller.addMatchResult(controller.showSearchValue(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()), secondStr, thirdStr); + settingEditor.clear(); + settingEditor.add(searchSettingResultList); + ITTableEditorPane.ITHeaderRenderer renderer = (ITTableEditorPane.ITHeaderRenderer) getEditTable().getTableHeader().getDefaultRenderer(); + renderer.refreshHeader(getEditTable(), true); + settingEditor.fireTableDataChanged(); + } + //如果有结果,默认选中第一行 + if (searchSettingResultList.size() > 0) { + getEditTable().addRowSelectionInterval(FIRST_ROW, FIRST_ROW); + } + northPane.getSettingResultLabel().setText(ShowValueUtils.getResultTip(searchSettingResultList.size(), settingReplaceCount, settingReplaceFailedCount)); + + } + } + + /** + * 替换设置项 + */ + public void replace4Setting() { + String firstStr = GeneralUtils.objectToString(northPane.getFindSettingComboBox().getSelectedItem()); + String inputStr = GeneralUtils.objectToString(northPane.getFindSettingInputComboBox().getSelectedItem()); + String extraStr = GeneralUtils.objectToString(northPane.getFindExtraSettingComboBox().getSelectedItem()); + clearSettingCount(); + if (isITReplaceValid() && !isSettingEverChanged(searchSettingResultList, firstStr, inputStr, extraStr)) { + if (isInputStrValid(inputStr, extraStr)) { + String secondStr = GeneralUtils.objectToString(northPane.getReplaceSettingInputComboBox().getSelectedItem()); + String thirdStr = GeneralUtils.objectToString(northPane.getReplaceExtraSettingComboBox().getSelectedItem()); + HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified(true); + for (Info info : searchSettingResultList) { + if (info.getContent().isSelected()) { + SettingController controller = SettingController.match(firstStr); + if (controller != null) { + controller.replace(info, secondStr, thirdStr); + info.getContent().setReplaced(true); + settingReplaceCount++; + } + } + } + northPane.getSettingResultLabel().setText(ShowValueUtils.getResultTip(searchSettingResultList.size(), settingReplaceCount, settingReplaceFailedCount)); + southPanel.getTableEditorPane().update(); + ITTableEditorPane.getEditTable().repaint(); + HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified(); + } else { + search4Setting(); + } + } else { + Object[] options = new Object[]{Toolkit.i18nText("Fine-Design_Replace_Search_Again"), Toolkit.i18nText("Fine-Design_Basic_Cancel")}; + int optionSelected = FineJOptionPane.showOptionDialog( + ITReplaceMainDialog.this, + Toolkit.i18nText("Fine-Design_Replace_Message"), + Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), + JOptionPane.YES_NO_CANCEL_OPTION, + JOptionPane.ERROR_MESSAGE, + null, + // 如果传null, 则按钮为 optionType 类型所表示的按钮(也就是确认对话框) + options, + options[0] + ); + //如果选择了重新查找,则再查找一遍 + if (isSelectSearch(optionSelected)) { + search4Setting(); + } + } + } + + private boolean isSelectSearch(int optionSelected) { + return optionSelected == NONE; + } + + + /** + * 用户的输入是否更改 + * + * @param inputStr 用户的一级输入框 + * @param extraStr 用户的二级输入框 + * @return 没更改过返回true + */ + public boolean isInputStrValid(String inputStr, String extraStr) { + return StringUtils.equals(inputStr, getSettingInputStr()) && StringUtils.equals(extraStr, getSettingExtraStr()); + } + + /** + * 设置项的内容是否更改过 + * + * @param searchSettingResultList 数据 + * @param controllerMatch controller的类型 + * @param inputStr 用户的一级输入框 + * @param extraStr 用户的二级输入框 + * @return 更改过返回true + */ + public boolean isSettingEverChanged(List searchSettingResultList, String controllerMatch, String inputStr, String extraStr) { + for (Info info : searchSettingResultList) { + if (info.getContent().isSelected() && !info.getContent().isReplaced()) { + SettingController controller = SettingController.match(controllerMatch); + if (controller != null && controller.isEverChanged(info, inputStr, extraStr)) { + return true; + } + } + } + return false; + } + + public ITReplaceSouthPanel getSouthPanel() { return southPanel; } @@ -346,10 +504,58 @@ public class ITReplaceMainDialog extends UIDialog { this.northPane = northPane; } + public String getSettingInputStr() { + return settingInputStr; + } + + public void setSettingInputStr(String settingInputStr) { + this.settingInputStr = settingInputStr; + } + + public String getSettingExtraStr() { + return settingExtraStr; + } + + public void setSettingExtraStr(String settingExtraStr) { + this.settingExtraStr = settingExtraStr; + } + /** * 检测结果是否合法 */ @Override public void checkValid() throws Exception { } + + public static List getSearchContentResultList() { + return searchContentResultList; + } + + public void setSearchContentResultList(List searchContentResultList) { + this.searchContentResultList = searchContentResultList; + } + + public static List getSearchSettingResultList() { + return searchSettingResultList; + } + + public void setSearchSettingResultList(List searchSettingResultList) { + this.searchSettingResultList = searchSettingResultList; + } + + /** + * 重置计数 + */ + public void clearContentCount() { + contentReplaceCount = NONE; + contentReplaceFailedCount = NONE; + } + + /** + * 重置计数 + */ + public void clearSettingCount() { + settingReplaceCount = NONE; + settingReplaceFailedCount = NONE; + } } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java index 909ce7112a..60300de2a9 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java @@ -1,12 +1,16 @@ package com.fr.design.actions.replace.ui; import com.fr.base.svg.IconUtils; +import com.fr.design.actions.replace.action.setting.SettingContent; +import com.fr.design.actions.replace.action.setting.SettingController; +import com.fr.design.data.datapane.TableDataComboBox; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.i18n.Toolkit; +import com.fr.general.GeneralUtils; import com.fr.stable.StringUtils; @@ -16,11 +20,15 @@ import javax.swing.Icon; import javax.swing.JCheckBox; import javax.swing.JPanel; import javax.swing.ScrollPaneConstants; +import java.awt.CardLayout; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; import java.util.ArrayList; import java.util.Collections; +import java.util.List; /** * 上面板 @@ -30,7 +38,12 @@ import java.util.Collections; * created by Destiny.Lin on 2022-09-01 */ public class ITReplaceNorthPanel { - private JPanel upPanel; + private JPanel upContentPanel; + private JPanel upSettingPanel; + private static JPanel cardPanel; + private static CardLayout cardLayout; + + //content private UILabel findLabel; private UILabel rangeLabel; private UILabel resultLabel; @@ -38,12 +51,28 @@ public class ITReplaceNorthPanel { private UIComboBox rangeCombobox; private JCheckBox matchRadioButton; private UILabel iconLabel; - private UIComboBox findInputCombobox; private UIComboBox replaceInputCombobox; - private UIScrollPane scrollPane; + private UIScrollPane contentScrollPane; + private UIScrollPane settingScrollPane; private UIButton replaceButton; private UIButton searchButton; + + //setting + private UILabel iconSettingLabel; + private UILabel findSettingLabel; + private UILabel rangeSettingLabel; + private UILabel settingResultLabel; + private UIComboBox rangeSettingComboBox; + private UIComboBox findSettingComboBox; + private UIComboBox findSettingInputComboBox; + private UIComboBox replaceSettingInputComboBox; + private UIComboBox findExtraSettingComboBox; + private UIComboBox replaceExtraSettingComboBox; + private TableDataComboBox tableDataComboBox; + private UIButton replaceSettingButton; + private UIButton searchSettingButton; + private static double rate = 1.00; //存储的5次最近输入 @@ -59,6 +88,10 @@ public class ITReplaceNorthPanel { private static final int FIRST_X = 20, SECOND_X = 80; private static final int LABEL_WIDTH = 60; private static final Icon CHANGE_ICON = IconUtils.readIcon("/com/fr/design/images/replace/change_normal.svg"); + private static final String[] rangeItems = new String[]{Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Current")}; + + public static final String CARD_CONTENT = "Content"; + public static final String CARD_SETTING = "setting"; private int findLabelX, findLabelY, findLabelWidth, findLabelHeight; @@ -74,9 +107,14 @@ public class ITReplaceNorthPanel { private int iconX, iconY, iconWidth, iconHeight; private int inputLength; - public static ArrayList findItems = new ArrayList<>(); - public static ArrayList findInputItems = new ArrayList<>(); - public static ArrayList replaceInputItems = new ArrayList<>(); + public static List findItems = new ArrayList<>(); + public static List findSettingItems = new ArrayList<>(); + public static List findInputItems = new ArrayList<>(); + public static List replaceInputItems = new ArrayList<>(); + public static List formatItems = new ArrayList<>(); + public static List digitItems = new ArrayList<>(); + public static List groupItems = new ArrayList<>(); + public static List dsColumnItems = new ArrayList<>(); static { findItems.add(Toolkit.i18nText("Fine-Design_Basic_Cell")); @@ -86,17 +124,66 @@ public class ITReplaceNorthPanel { findItems.add(Toolkit.i18nText("Fine-Design_Replace_Component")); findItems.add(Toolkit.i18nText("Fine-Design_Basic_Widget")); findItems.add(Toolkit.i18nText("Fine-Design_Basic_Formula")); + + + findSettingItems.add(SettingContent.CELL_FORMAT_NAME); + findSettingItems.add(SettingContent.CELL_DATA_SETTING_NAME); + findSettingItems.add(SettingContent.CELL_DS_COLUMN_NAME); + findSettingItems.add(SettingContent.DATASOURCE_CONNECTION_NAME); + findSettingItems.add(SettingContent.DATASOURCE_COLLECT_NAME); + + formatItems.add(SettingContent.FORMAT_COMMON); + formatItems.add(SettingContent.FORMAT_NUMBER); + formatItems.add(SettingContent.FORMAT_MONEY); + formatItems.add(SettingContent.FORMAT_PERCENT); + formatItems.add(SettingContent.FORMAT_PERMILLAGE); + formatItems.add(SettingContent.FORMAT_SCIENCE); + formatItems.add(SettingContent.FORMAT_DATE); + formatItems.add(SettingContent.FORMAT_TIME); + formatItems.add(SettingContent.FORMAT_TEXT); + + digitItems.add(SettingContent.DIGIT_SETTING_GROUP); + digitItems.add(SettingContent.DIGIT_SETTING_LIST); + digitItems.add(SettingContent.DIGIT_SETTING_SUM); + + groupItems.add(SettingContent.GROUP_COMMON); + groupItems.add(SettingContent.GROUP_CONTINUUM); + + dsColumnItems.add(SettingContent.CONNECTION_TEMPLATE); } public ITReplaceNorthPanel() { - upPanel = new JPanel(null); + cardLayout = new CardLayout(); + cardPanel = new JPanel(cardLayout); + upContentPanel = new JPanel(null); + upSettingPanel = new JPanel(null); + + initContentPanel(); + initSettingPanel(); + + + cardPanel.add(contentScrollPane, CARD_CONTENT); + cardPanel.add(upSettingPanel, CARD_SETTING); + } + + /** + * 限制尺寸 + * + * @param width + */ + public void setLimitSize(int width) { + upContentPanel.setMaximumSize(new Dimension(limit_width, HEIGHT)); + upContentPanel.setPreferredSize(new Dimension(limit_width, HEIGHT)); + } + /** + * 初始化模板内容查找面板 + */ + public void initContentPanel() { findLabel = new UILabel(Toolkit.i18nText("Fine-Design_Replace_Search_Element")); rangeLabel = new UILabel(Toolkit.i18nText("Fine-Design_Replace_Search_Range")); iconLabel = new UILabel(CHANGE_ICON); resultLabel = new UILabel(); - - String[] rangeItems = new String[]{Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Current")}; String[] replaceInputItems = new String[]{StringUtils.EMPTY}; findCombobox = new UIComboBox(findItems.toArray()); rangeCombobox = new UIComboBox(rangeItems); @@ -122,32 +209,198 @@ public class ITReplaceNorthPanel { replaceButton = new UIButton(Toolkit.i18nText("Fine-Design_Replace_Button")); searchButton = new UIButton(Toolkit.i18nText("Fine-Design_Search_Button")); - upPanel.setPreferredSize(new Dimension(limit_width, HEIGHT)); - scrollPane = new UIScrollPane(upPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); - upPanel.add(findLabel); - upPanel.add(rangeLabel); - upPanel.add(resultLabel); - upPanel.add(findCombobox); - upPanel.add(rangeCombobox); - upPanel.add(findInputCombobox); - upPanel.add(replaceInputCombobox); - upPanel.add(matchRadioButton); - upPanel.add(replaceButton); - upPanel.add(searchButton); - upPanel.add(iconLabel); - scrollPane.setBorder(BorderFactory.createEmptyBorder()); + upContentPanel.setPreferredSize(new Dimension(limit_width, HEIGHT)); + contentScrollPane = new UIScrollPane(upContentPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); + upContentPanel.add(findLabel); + upContentPanel.add(rangeLabel); + upContentPanel.add(resultLabel); + upContentPanel.add(findCombobox); + upContentPanel.add(rangeCombobox); + upContentPanel.add(findInputCombobox); + upContentPanel.add(replaceInputCombobox); + upContentPanel.add(matchRadioButton); + upContentPanel.add(replaceButton); + upContentPanel.add(searchButton); + upContentPanel.add(iconLabel); + contentScrollPane.setBorder(BorderFactory.createEmptyBorder()); } /** - * 限制尺寸 + * 初始化设置项查找面板 + */ + public void initSettingPanel() { + findSettingLabel = new UILabel(Toolkit.i18nText("Fine-Design_Replace_Search_Element")); + rangeSettingLabel = new UILabel(Toolkit.i18nText("Fine-Design_Replace_Search_Range")); + settingResultLabel = new UILabel(); + findSettingComboBox = new UIComboBox(findSettingItems.toArray()); + rangeSettingComboBox = new UIComboBox(rangeItems); + findSettingInputComboBox = new UIComboBox(formatItems.toArray()) { + @Override + public void setEditor(ComboBoxEditor anEditor) { + super.setEditor(new ITComboBoxEditor()); + } + }; + findSettingInputComboBox.setSelectedIndex(-1); + replaceSettingInputComboBox = new UIComboBox(formatItems.toArray()) { + @Override + public void setEditor(ComboBoxEditor anEditor) { + super.setEditor(new ITComboBoxEditor()); + } + }; + replaceSettingInputComboBox.setSelectedIndex(-1); + + + ((UITextField) (findSettingInputComboBox.getEditor().getEditorComponent())).setPlaceholder(Toolkit.i18nText("Fine-Design_Replace_Choose_Search") + SettingContent.CELL_FORMAT_NAME); + findSettingInputComboBox.setEditable(true); + ((UITextField) (findSettingInputComboBox.getEditor().getEditorComponent())).setEditable(false); + ((UITextField) (replaceSettingInputComboBox.getEditor().getEditorComponent())).setPlaceholder(Toolkit.i18nText("Fine-Design_Replace_Choose_Replace") + SettingContent.CELL_FORMAT_NAME); + replaceSettingInputComboBox.setEditable(true); + ((UITextField) (replaceSettingInputComboBox.getEditor().getEditorComponent())).setEditable(false); + + + iconSettingLabel = new UILabel(CHANGE_ICON); + findExtraSettingComboBox = new UIComboBox(groupItems.toArray()); + findExtraSettingComboBox.setVisible(false); + replaceExtraSettingComboBox = new UIComboBox(groupItems.toArray()); + replaceExtraSettingComboBox.setVisible(false); + searchSettingButton = new UIButton(Toolkit.i18nText("Fine-Design_Search_Button")); + replaceSettingButton = new UIButton(Toolkit.i18nText("Fine-Design_Replace_Button")); + + replaceSettingButton.setEnabled(false); + + upSettingPanel.add(findSettingLabel); + upSettingPanel.add(rangeSettingLabel); + upSettingPanel.add(findSettingComboBox); + upSettingPanel.add(rangeSettingComboBox); + upSettingPanel.add(findSettingInputComboBox); + upSettingPanel.add(replaceSettingInputComboBox); + upSettingPanel.add(iconSettingLabel); + upSettingPanel.add(findExtraSettingComboBox); + upSettingPanel.add(replaceExtraSettingComboBox); + upSettingPanel.add(searchSettingButton); + upSettingPanel.add(replaceSettingButton); + upSettingPanel.add(settingResultLabel); + settingScrollPane = new UIScrollPane(upSettingPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); + settingScrollPane.setBorder(BorderFactory.createEmptyBorder()); + + initListener(); + + } + + /** + * 初始化事件 + */ + private void initListener() { + findSettingComboBox.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + replaceSettingInputComboBox.clearBoxItems(); + findSettingInputComboBox.clearBoxItems(); + String str = GeneralUtils.objectToString(findSettingComboBox.getSelectedItem()); + ((UITextField) findSettingInputComboBox.getEditor().getEditorComponent()).setText(StringUtils.EMPTY); + refreshSettingComboBox(SettingController.getSettingRefreshItems(str)); + setDataSourceComboBoxStatus(isAllow2Replace()); + replaceSettingButton.setEnabled(false); + + } + }); + + findSettingInputComboBox.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + refreshExtraComboBox(findSettingInputComboBox, findExtraSettingComboBox); + + } + }); + + replaceSettingInputComboBox.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + refreshExtraComboBox(replaceSettingInputComboBox, replaceExtraSettingComboBox); + } + }); + } + + /** + * 刷新替换按钮状态 + */ + public void refreshSettingReplaceButtonStatus() { + replaceSettingButton.setEnabled(isAllChoose()); + } + + /** + * 是否各个选项都有选中内容 * - * @param width + * @return 是则返回true */ - public void setLimitSize(int width) { - upPanel.setMaximumSize(new Dimension(limit_width, 161)); - upPanel.setPreferredSize(new Dimension(limit_width, 161)); + public boolean isAllChoose() { + String str = GeneralUtils.objectToString(findSettingComboBox.getSelectedItem()); + String findInputStr = GeneralUtils.objectToString(findSettingInputComboBox.getSelectedItem()); + String replaceInputStr = GeneralUtils.objectToString(replaceSettingInputComboBox.getSelectedItem()); + String findExtraStr = GeneralUtils.objectToString(findExtraSettingComboBox.getSelectedItem()); + String replaceExtraStr = GeneralUtils.objectToString(replaceExtraSettingComboBox.getSelectedItem()); + return (!StringUtils.equals(str, SettingContent.DATASOURCE_COLLECT_NAME) && !StringUtils.equals(str, SettingContent.DATASOURCE_CONNECTION_NAME)) + && StringUtils.isNotEmpty(findInputStr) + && StringUtils.isNotEmpty(replaceInputStr) + && StringUtils.isNotEmpty(findExtraStr) + && StringUtils.isNotEmpty(replaceExtraStr); } + /** + * 是否支持替换 + * + * @return 支持返回true + */ + public boolean isAllow2Replace() { + String str = GeneralUtils.objectToString(findSettingComboBox.getSelectedItem()); + return !StringUtils.equals(str, SettingContent.DATASOURCE_CONNECTION_NAME) && !StringUtils.equals(str, SettingContent.DATASOURCE_COLLECT_NAME); + } + + /** + * 设置数据集相关情况下的替换框的状态 + * + * @param status + */ + public void setDataSourceComboBoxStatus(boolean status) { + replaceSettingButton.setEnabled(status); + replaceSettingInputComboBox.setEnabled(status); + replaceExtraSettingComboBox.setEnabled(status); + } + + /** + * 刷新延展出的下拉框(第三层) + * + * @param settingComboBox + * @param extraComboBox + */ + public void refreshExtraComboBox(UIComboBox settingComboBox, UIComboBox extraComboBox) { + String str = GeneralUtils.objectToString(findSettingComboBox.getSelectedItem()); + String parent = GeneralUtils.objectToString(settingComboBox.getSelectedItem()); + if (StringUtils.isNotEmpty(parent) && SettingController.match(str) != null && SettingController.match(str).hasExpand(str, parent)) { + extraComboBox.clearBoxItems(); + extraComboBox.setVisible(true); + extraComboBox.refreshBoxItems(SettingController.getSettingExtraRefreshItems(str, parent)); + extraComboBox.setSelectedIndex(0); + } else { + extraComboBox.setVisible(false); + } + refreshSettingReplaceButtonStatus(); + } + + /** + * 刷新用户选择的输入框(第二层) + * + * @param list + */ + public void refreshSettingComboBox(List list) { + findSettingInputComboBox.clearBoxItems(); + findSettingInputComboBox.refreshBoxItems(list); + replaceSettingInputComboBox.clearBoxItems(); + replaceSettingInputComboBox.refreshBoxItems(list); + replaceExtraSettingComboBox.setVisible(false); + findExtraSettingComboBox.setVisible(false); + + } /** * 适配屏幕 @@ -162,7 +415,50 @@ public class ITReplaceNorthPanel { templateWidth = templateWidth - ITReplaceWestPanel.LEFT_WIDTH; inputLength = (templateWidth - GAP * 5) / 2; + fitContentScreen(templateWidth); + fitSettingScreen(templateWidth); + + + } + /** + * 适配屏幕 + * + * @param templateWidth 当前设计器宽度 + */ + private void fitSettingScreen(int templateWidth) { + findSettingLabel.setBounds(FIRST_X, FIRST_Y, LABEL_WIDTH, COMPONENT_HEIGHT); + findSettingComboBox.setBounds(SECOND_X, FIRST_Y, inputLength - 4 * GAP, COMPONENT_HEIGHT); + rangeSettingLabel.setBounds(replaceInputComboBoxX, FIRST_Y, LABEL_WIDTH, COMPONENT_HEIGHT); + rangeSettingComboBox.setBounds(rangeLabelX + rangeLabelWidth, FIRST_Y, inputLength - 3 * GAP, COMPONENT_HEIGHT); + findSettingInputComboBox.setBounds(FIRST_X, SECOND_Y, inputLength - GAP, COMPONENT_HEIGHT); + replaceSettingInputComboBox.setBounds(templateWidth - inputLength - GAP * 2, SECOND_Y, inputLength, COMPONENT_HEIGHT); + iconSettingLabel.setBounds(iconX, iconY, iconWidth, iconHeight); + searchSettingButton.setBounds(searchButtonX, searchButtonY, BUTTON_WIDTH, searchButtonHeight); + replaceSettingButton.setBounds(replaceButtonX, replaceButtonY, BUTTON_WIDTH, replaceButtonHeight); + settingResultLabel.setBounds(resultLabelX, resultLabelY, resultLabelWidth, resultLabelHeight); + setExtraBounds(templateWidth); + + + } + + /** + * 设置额外的输入框 + * + * @param templateWidth 当前设计器宽度 + */ + private void setExtraBounds(int templateWidth) { + findExtraSettingComboBox.setBounds(FIRST_X, THIRD_Y, inputLength - GAP, COMPONENT_HEIGHT); + replaceExtraSettingComboBox.setBounds(templateWidth - inputLength - GAP * 2, THIRD_Y, inputLength, COMPONENT_HEIGHT); + } + + + /** + * 模板内容查找面板适配屏幕 + * + * @param templateWidth 当前设计器宽度 + */ + private void fitContentScreen(int templateWidth) { setFindLabelBounds(); setResultLabelBounds(templateWidth); setFindComboboxBounds(); @@ -174,7 +470,6 @@ public class ITReplaceNorthPanel { setReplaceButtonBounds(); setSearchButtonBounds(); setIconLabelBounds(); - } @@ -221,12 +516,12 @@ public class ITReplaceNorthPanel { } - public UIScrollPane getScrollPane() { - return scrollPane; + public UIScrollPane getContentScrollPane() { + return contentScrollPane; } - public void setScrollPane(UIScrollPane scrollPane) { - this.scrollPane = scrollPane; + public void setContentScrollPane(UIScrollPane contentScrollPane) { + this.contentScrollPane = contentScrollPane; } private void setIconLabelBounds() { @@ -320,12 +615,12 @@ public class ITReplaceNorthPanel { findLabel.setBounds(findLabelX, findLabelY, findLabelWidth, findLabelHeight); } - public JPanel getUpPanel() { - return upPanel; + public JPanel getUpContentPanel() { + return upContentPanel; } - public void setUpPanel(JPanel upPanel) { - this.upPanel = upPanel; + public void setUpContentPanel(JPanel upContentPanel) { + this.upContentPanel = upContentPanel; } public UILabel getFindLabel() { @@ -407,4 +702,77 @@ public class ITReplaceNorthPanel { public void setSearchButton(UIButton searchButton) { this.searchButton = searchButton; } + + public static CardLayout getCardLayout() { + return cardLayout; + } + + public static JPanel getCardPanel() { + return cardPanel; + } + + + public UIButton getReplaceSettingButton() { + return replaceSettingButton; + } + + public void setReplaceSettingButton(UIButton replaceSettingButton) { + this.replaceSettingButton = replaceSettingButton; + } + + public UIButton getSearchSettingButton() { + return searchSettingButton; + } + + public void setSearchSettingButton(UIButton searchSettingButton) { + this.searchSettingButton = searchSettingButton; + } + + public UIComboBox getFindSettingInputComboBox() { + return findSettingInputComboBox; + } + + public void setFindSettingInputComboBox(UIComboBox findSettingInputComboBox) { + this.findSettingInputComboBox = findSettingInputComboBox; + } + + public UIComboBox getReplaceSettingInputComboBox() { + return replaceSettingInputComboBox; + } + + public void setReplaceSettingInputComboBox(UIComboBox replaceSettingInputComboBox) { + this.replaceSettingInputComboBox = replaceSettingInputComboBox; + } + + public UIComboBox getFindExtraSettingComboBox() { + return findExtraSettingComboBox; + } + + public void setFindExtraSettingComboBox(UIComboBox findExtraSettingComboBox) { + this.findExtraSettingComboBox = findExtraSettingComboBox; + } + + public UIComboBox getReplaceExtraSettingComboBox() { + return replaceExtraSettingComboBox; + } + + public void setReplaceExtraSettingComboBox(UIComboBox replaceExtraSettingComboBox) { + this.replaceExtraSettingComboBox = replaceExtraSettingComboBox; + } + + public UIComboBox getFindSettingComboBox() { + return findSettingComboBox; + } + + public void setFindSettingComboBox(UIComboBox findSettingComboBox) { + this.findSettingComboBox = findSettingComboBox; + } + + public UILabel getSettingResultLabel() { + return settingResultLabel; + } + + public void setSettingResultLabel(UILabel settingResultLabel) { + this.settingResultLabel = settingResultLabel; + } } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java index 997013592d..24c441b9a3 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java @@ -14,11 +14,11 @@ import java.awt.Color; */ public class ITReplaceSouthPanel { ITTableEditorPane tableEditorPane; - ITTableEditor itTableEditor; + public static ITTableEditor itTableEditor; //勾选框索引 public static final int CHECKBOX_INDEX = 0; //ITContent在表格的列索引 - public static final int CONTENT_INDEX = 6; + public static final int CONTENT_INDEX = 7; public static final int TABLE_GAP = 20; public ITReplaceSouthPanel() { @@ -47,7 +47,7 @@ public class ITReplaceSouthPanel { this.tableEditorPane = tableEditorPane; } - public ITTableEditor getItTableEditor() { + public static ITTableEditor getItTableEditor() { return itTableEditor; } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java index 0804efa23b..1c9ed16523 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java @@ -1,6 +1,7 @@ package com.fr.design.actions.replace.ui; import com.fr.base.svg.IconUtils; +import com.fr.design.actions.replace.info.Info; import com.fr.design.gui.ibutton.UIToggleButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; @@ -19,6 +20,7 @@ import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; +import java.util.List; /** * 左侧面板 @@ -30,33 +32,59 @@ import java.awt.event.MouseEvent; public class ITReplaceWestPanel { private JPanel leftPanel; private UILabel iconLabel; + private UIToggleButton contentButton; + private UIToggleButton settingButton; private static final Icon HELP_ICON = IconUtils.readIcon("com/fr/design/images/buttonicon/replace_help.svg"); private static final String HELP_URL = CloudCenter.getInstance().acquireUrlByKind("design.replace.help", "https://help.fanruan.com/finereport/doc-view-4954.html?source=3"); - private static final int FILL_COUNT = 12; + private static final int FILL_COUNT = 11; public static final int LEFT_WIDTH = 100; public static final String CONTENT_TEXT = "" + Toolkit.i18nText("Fine-Design_Basic_Templates_Content") + ""; + public static final String SETTING_TEXT = "" + Toolkit.i18nText("Fine-Design_Replace_Setting") + ""; public ITReplaceWestPanel() { leftPanel = new JPanel(new GridLayout(15, 1, 0, 0)); iconLabel = new UILabel("" + Toolkit.i18nText("Fine-Design_Report_Community_Help") + ""); - UIToggleButton contentButton = new UIToggleButton(Toolkit.i18nText("Fine-Design_Basic_Templates_Content")); + contentButton = new UIToggleButton(Toolkit.i18nText("Fine-Design_Basic_Templates_Content")); + settingButton = new UIToggleButton(Toolkit.i18nText("Fine-Design_Replace_Setting")); contentButton.setText(CONTENT_TEXT); contentButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (!contentButton.isSelected()) { - contentButton.setText(CONTENT_TEXT); + showSelectPanel(ITReplaceNorthPanel.CARD_CONTENT, ITReplaceMainDialog.getSearchContentResultList()); } else { - contentButton.setText(Toolkit.i18nText("Fine-Design_Basic_Templates_Content")); + showSelectPanel(ITReplaceNorthPanel.CARD_SETTING, ITReplaceMainDialog.getSearchSettingResultList()); } + changeColor4SelectContent(); + settingButton.setSelected(contentButton.isSelected()); + + } + }); + + settingButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (!settingButton.isSelected()) { + showSelectPanel(ITReplaceNorthPanel.CARD_SETTING, ITReplaceMainDialog.getSearchSettingResultList()); + } else { + showSelectPanel(ITReplaceNorthPanel.CARD_CONTENT, ITReplaceMainDialog.getSearchContentResultList()); + } + changeColor4SelectContent(); + contentButton.setSelected(settingButton.isSelected()); + } }); leftPanel.setBackground(Color.WHITE); + //默认选中模板内容 contentButton.setSelected(true); + settingButton.setSelected(false); + //去除按钮的边框 contentButton.setBorderPainted(false); + settingButton.setBorderPainted(false); leftPanel.add(contentButton); + leftPanel.add(settingButton); leftPanel.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, new Color(218, 218, 221))); //填充一下面板 for (int i = 0; i < FILL_COUNT; i++) { @@ -85,4 +113,30 @@ public class ITReplaceWestPanel { public void setLeftPanel(JPanel leftPanel) { this.leftPanel = leftPanel; } + + /** + * 切换面板时改变颜色 + */ + public void changeColor4SelectContent() { + if (!contentButton.isSelected()) { + contentButton.setText(CONTENT_TEXT); + settingButton.setText(Toolkit.i18nText("Fine-Design_Replace_Setting")); + } else { + contentButton.setText(Toolkit.i18nText("Fine-Design_Basic_Templates_Content")); + settingButton.setText(SETTING_TEXT); + } + } + + /** + * 展示指定的面板 + * + * @param str card面板的标签 + * @param list 对应的表格数据 + */ + public void showSelectPanel(String str, List list) { + ITReplaceNorthPanel.getCardLayout().show(ITReplaceNorthPanel.getCardPanel(), str); + ITReplaceSouthPanel.getItTableEditor().clear(); + ITReplaceSouthPanel.getItTableEditor().add(list); + ITReplaceSouthPanel.getItTableEditor().fireTableDataChanged(); + } } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java index c4cf47f592..ce11d184d0 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java @@ -13,7 +13,6 @@ import com.fr.general.GeneralUtils; import com.fr.stable.StringUtils; - import javax.swing.AbstractCellEditor; import javax.swing.JTable; import javax.swing.table.TableCellEditor; @@ -42,7 +41,7 @@ public class ITTableButton extends AbstractCellEditor implements TableCellEditor paraButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - ITContent content = (ITContent) getEditTable().getValueAt(getEditTable().getEditingRow(), 6); + ITContent content = (ITContent) getEditTable().getValueAt(getEditTable().getEditingRow(), ITReplaceSouthPanel.CONTENT_INDEX); if (StringUtils.isNotEmpty(GeneralUtils.objectToString(content.getTrlString()))) { ITReplaceMainDialog.setITReplaceFlag(true); TRL trl = new TRL(GeneralUtils.objectToString(content.getTrlString())); @@ -67,7 +66,7 @@ public class ITTableButton extends AbstractCellEditor implements TableCellEditor */ @Override public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { - ITContent content = (ITContent) table.getValueAt(row, 6); + ITContent content = (ITContent) table.getValueAt(row, ITReplaceSouthPanel.CONTENT_INDEX); paraButton.setEnabled(content.isJumpAble()); return paraButton; } @@ -85,7 +84,7 @@ public class ITTableButton extends AbstractCellEditor implements TableCellEditor */ @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { - ITContent content = (ITContent) table.getValueAt(row, 6); + ITContent content = (ITContent) table.getValueAt(row, ITReplaceSouthPanel.CONTENT_INDEX); paraButton.setEnabled(content.isJumpAble()); return paraButton; } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditor.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditor.java index 0c8819abff..7f4960d21b 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditor.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditor.java @@ -3,6 +3,7 @@ package com.fr.design.actions.replace.ui; import com.fr.design.actions.replace.info.Info; import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itableeditorpane.UITableEditAction; import com.fr.design.gui.itableeditorpane.UITableModelAdapter; @@ -12,6 +13,14 @@ import com.fr.stable.StringUtils; import org.jetbrains.annotations.Nullable; +import javax.swing.BorderFactory; +import javax.swing.DefaultCellEditor; +import javax.swing.JLabel; +import javax.swing.JTable; +import javax.swing.plaf.UIResource; +import javax.swing.table.TableCellRenderer; +import java.awt.Color; +import java.awt.Component; import java.util.List; /** @@ -28,6 +37,7 @@ public class ITTableEditor extends UITableModelAdapter { super(new String[]{ StringUtils.BLANK, Toolkit.i18nText("Fine-Design_Replace_Search_Content"), + Toolkit.i18nText("Fine-Design_After_Replace"), Toolkit.i18nText("Fine-Design_Replace_Template_Name"), Toolkit.i18nText("Fine-Design_Replace_Sheet_Name"), Toolkit.i18nText("Fine-Design_Replace_Block_Name"), @@ -42,11 +52,14 @@ public class ITTableEditor extends UITableModelAdapter { UILabel.class, UILabel.class, UILabel.class, + UILabel.class, ITTableButton.class, }); this.setDefaultEditor(ITTableButton.class, new ITTableButton()); this.setDefaultRenderer(ITTableButton.class, new ITTableButton()); + this.setDefaultEditor(Boolean.class, new ITBooleanEditor()); + this.setDefaultRenderer(Boolean.class, new ITBooleanRenderer()); this.createTable().getColumnModel().getColumn(ITReplaceSouthPanel.CONTENT_INDEX).setMaxWidth(50); this.createTable().getColumnModel().getColumn(ITReplaceSouthPanel.CHECKBOX_INDEX).setMaxWidth(50); @@ -106,6 +119,9 @@ public class ITTableEditor extends UITableModelAdapter { fireTableDataChanged(); } + /** + * 选择的索引 + */ public enum ChooseIndex { /** * 第一列,返回选中情况 @@ -127,9 +143,18 @@ public class ITTableEditor extends UITableModelAdapter { } }, /** - * 第三列,展示模板名 + * 第三列,展示替换后内容 */ INDEX_2(2) { + @Override + public @Nullable Object returnContentObject(ITContent content) { + return content.getAfterReplaceStr(); + } + }, + /** + * 第四列,展示模板名 + */ + INDEX_3(3) { @Override public Object returnContentObject(ITContent content) { return " " + content.getTemplateName(); @@ -137,9 +162,9 @@ public class ITTableEditor extends UITableModelAdapter { }, /** - * 第四列,展示Sheet + * 第五列,展示Sheet */ - INDEX_3(3) { + INDEX_4(4) { @Override public Object returnContentObject(ITContent content) { return " " + content.getSheetName(); @@ -147,18 +172,18 @@ public class ITTableEditor extends UITableModelAdapter { }, /** - * 第五列,展示块名、组件名 + * 第六列,展示块名、组件名 */ - INDEX_4(4) { + INDEX_5(5) { @Override public Object returnContentObject(ITContent content) { return " " + content.getBlockName(); } }, /** - * 第六列,展示路径 + * 第七列,展示路径 */ - INDEX_5(5) { + INDEX_6(6) { @Override public Object returnContentObject(ITContent content) { return " " + content.getOtherPos(); @@ -166,9 +191,9 @@ public class ITTableEditor extends UITableModelAdapter { }, /** - * 第七列,展示定位按钮 + * 第八列,展示定位按钮 */ - INDEX_6(6) { + INDEX_7(7) { @Override public Object returnContentObject(ITContent content) { return content; @@ -209,4 +234,38 @@ public class ITTableEditor extends UITableModelAdapter { return null; } } + + /** + * 用于展示指定风格的checkbox的Editor + */ + public class ITBooleanEditor extends DefaultCellEditor { + public ITBooleanEditor() { + super(new UICheckBox()); + UICheckBox checkBox = (UICheckBox) getComponent(); + checkBox.setHorizontalAlignment(UICheckBox.CENTER); + } + } + + /** + * 用于展示指定风格的checkbox的渲染器 + */ + public class ITBooleanRenderer extends UICheckBox implements TableCellRenderer, UIResource { + public ITBooleanRenderer() { + super(); + setHorizontalAlignment(JLabel.CENTER); + setBorderPainted(true); + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + ITContent content = (ITContent) table.getValueAt(row, ITReplaceSouthPanel.CONTENT_INDEX); + setEnabled(!content.isReplaced()); + setSelected((value != null && ((Boolean) value).booleanValue())); + setUI(getUICheckBoxUI()); + setBorder(BorderFactory.createEmptyBorder()); + setBackground(Color.WHITE); + return this; + } + } } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java index 0a743d34eb..f46ea95ac4 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java @@ -5,6 +5,7 @@ import com.fr.design.border.UIRoundedBorder; import com.fr.design.constants.UIConstants; import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itableeditorpane.UITableEditAction; @@ -14,7 +15,6 @@ import com.fr.design.mainframe.share.ui.base.MouseClickListener; import com.fr.stable.StringUtils; -import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; @@ -85,27 +85,30 @@ public class ITTableEditorPane extends BasicPane { /** * 改变面板的各个状态(替换按钮、表头勾选框) + * * @param content * @param row * @param col */ public void changeComponentStatus(ITContent content, int row, int col) { - if (content.isSelected()) { - content.setSelected(false); - editTable.setValueAt(content.isSelected(), row, col); - ITReplaceMainDialog.selectCount--; - //如果没有选中,替换按钮需要置灰 - ITReplaceMainDialog.getInstance().getNorthPane().getReplaceButton().setEnabled(ITReplaceMainDialog.selectCount > 0); - } else { - content.setSelected(true); - editTable.setValueAt(content.isSelected(), row, col); - ITReplaceMainDialog.selectCount++; - ITReplaceMainDialog.getInstance().getNorthPane().getReplaceButton().setEnabled(true); - } - //更新表头的勾选框状态 - if (editTable.getTableHeader().getDefaultRenderer() instanceof ITHeaderRenderer) { - ITHeaderRenderer renderer = (ITHeaderRenderer) editTable.getTableHeader().getDefaultRenderer(); - renderer.refreshHeader(editTable, ITReplaceMainDialog.selectCount >= editTable.getRowCount()); + if (!content.isReplaced()) { + if (content.isSelected()) { + content.setSelected(false); + editTable.setValueAt(content.isSelected(), row, col); + ITReplaceMainDialog.selectCount--; + //如果没有选中,替换按钮需要置灰 + ITReplaceMainDialog.getInstance().getNorthPane().getReplaceButton().setEnabled(ITReplaceMainDialog.selectCount > 0); + } else { + content.setSelected(true); + editTable.setValueAt(content.isSelected(), row, col); + ITReplaceMainDialog.selectCount++; + ITReplaceMainDialog.getInstance().getNorthPane().getReplaceButton().setEnabled(true); + } + //更新表头的勾选框状态 + if (editTable.getTableHeader().getDefaultRenderer() instanceof ITHeaderRenderer) { + ITHeaderRenderer renderer = (ITHeaderRenderer) editTable.getTableHeader().getDefaultRenderer(); + renderer.refreshHeader(editTable, ITReplaceMainDialog.selectCount >= editTable.getRowCount()); + } } } @@ -125,11 +128,11 @@ public class ITTableEditorPane extends BasicPane { */ public static class ITHeaderRenderer implements TableCellRenderer { JTableHeader tableHeader; - final JCheckBox selectBox; + final UICheckBox selectBox; public ITHeaderRenderer(JTable table) { this.tableHeader = table.getTableHeader(); - selectBox = new JCheckBox(); + selectBox = new UICheckBox(); selectBox.setSelected(true); tableHeader.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { @@ -217,7 +220,10 @@ public class ITTableEditorPane extends BasicPane { ITReplaceMainDialog.getInstance().getNorthPane().getReplaceButton().setEnabled(value); } for (int i = 0; i < len; i++) { - ((ITContent) (getEditTable().getValueAt(i, ITReplaceSouthPanel.CONTENT_INDEX))).setSelected(value); + ITContent content = ((ITContent) (getEditTable().getValueAt(i, ITReplaceSouthPanel.CONTENT_INDEX))); + if (!content.isReplaced()) { + content.setSelected(value); + } } } From 0f010b22ca539f2fba8588b85d858d81e1c63ddb Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Thu, 27 Oct 2022 15:34:07 +0800 Subject: [PATCH 15/63] =?UTF-8?q?REPORT-80695=20=E3=80=90=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E5=85=A8=E5=B1=80=E7=BA=A7=E5=88=AB=E6=9F=A5=E6=89=BE?= =?UTF-8?q?=E6=9B=BF=E6=8D=A2=E4=BA=8C=E6=9C=9F=E3=80=91=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../actions/replace/utils/SearchJSUtils.java | 7 +- .../actions/replace/utils/ShowValueUtils.java | 86 +++++++++++++++++++ 2 files changed, 91 insertions(+), 2 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/SearchJSUtils.java b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/SearchJSUtils.java index 5bb27c6686..ef2909db6b 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/SearchJSUtils.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/SearchJSUtils.java @@ -5,6 +5,7 @@ import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartglyph.ConditionAttr; import com.fr.chart.chartglyph.ConditionCollection; import com.fr.chart.web.ChartHyperPoplink; +import com.fr.design.actions.replace.action.content.js.JSCheckTag; import com.fr.design.actions.replace.action.content.js.SearchChartJSAction; import com.fr.design.actions.replace.info.JSInfo; import com.fr.design.actions.replace.info.base.ITContent; @@ -68,7 +69,7 @@ public class SearchJSUtils { ITContent newContent = ITContent.copy(content); newContent.setReplaceObject(listener); SearchJSUtils.addJSInfos(jsInfos, new JSInfo(newContent)); - } else if (javaScript instanceof Commit2DBJavaScript){ + } else if (javaScript instanceof Commit2DBJavaScript) { dealCommit2DBJS(jsInfos, content, (Commit2DBJavaScript) javaScript); } } @@ -90,7 +91,7 @@ public class SearchJSUtils { if (javaScript instanceof JavaScriptImpl) { newContent.setReplaceObject(javaScript); jsInfos.add(new JSInfo(newContent)); - } else if (javaScript instanceof Commit2DBJavaScript){ + } else if (javaScript instanceof Commit2DBJavaScript) { dealCommit2DBJS(jsInfos, newContent, (Commit2DBJavaScript) javaScript); } } @@ -362,6 +363,8 @@ public class SearchJSUtils { newContent.addOtherPos(Toolkit.i18nText("Fine-Design_Report_Hyperlink")); newContent.setReplaceObject(nameJavaScript); newContent.addOtherPos(nameJavaScript.getName()); + newContent.setHoldObject(elem); + newContent.setTag(JSCheckTag.CELL_HYPERLINK); SearchJSUtils.addJSInfos(jsInfos, new JSInfo(newContent)); } else if (isChartHyperPopLinkValid(javaScript)) { ITContent chartContent = ITContent.copy(content); diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java index 191a08eefc..8f1174e8fc 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java @@ -1,7 +1,9 @@ package com.fr.design.actions.replace.utils; +import com.fr.design.actions.replace.info.Info; import com.fr.design.actions.replace.ui.ITReplaceMainDialog; +import com.fr.design.i18n.Toolkit; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.collections.combination.Pair; @@ -97,6 +99,22 @@ public class ShowValueUtils { } } + /** + * 获取高亮后用于展示的搜索后内容 + * + * @param str 原内容 + * @param searchStr 搜索内容 + * @param replaceStr 替换内容 + * @return 处理完的文本 + */ + public static String getReplaceString(String str, String searchStr, String replaceStr) { + if (StringUtils.isEmpty(searchStr)) { + return str; + } else { + return updateReplaceHighlight(str, searchStr, replaceStr); + } + } + /** * 替换策略 * @@ -187,6 +205,40 @@ public class ShowValueUtils { } } + /** + * 更新替换后的高亮 + * + * @param str + * @param searchStr + * @param replaceStr + * @return + */ + public static String updateReplaceHighlight(String str, String searchStr, String replaceStr) { + if (ITReplaceMainDialog.isMatched()) { + String result = str; + Pattern pattern = containPattern; + Matcher matcher = pattern.matcher(str); + int size = FONT_HEAD.length() + FONT_TAIL.length(); + int different = getDifferent(searchStr.length(), replaceStr.length()); + int index = 0; + StringBuilder builder = new StringBuilder(str); + while (matcher.find()) { + builder.replace(matcher.start() + index, matcher.end() + index, FONT_HEAD + changeHtmlStr(replaceStr) + FONT_TAIL); + index += getDifferent(size, different); + index += getIncreaseCount(replaceStr); + } + + return changeOriginHtmlStr(HEAD + builder.toString() + TAIL); + } else { + String ans = HEAD + replaceAll(str, searchStr, FONT_HEAD + changeHtmlStr(replaceStr) + FONT_TAIL) + TAIL; + return changeOriginHtmlStr(ans); + } + } + + private static int getDifferent(int searchLength, int replaceLength) { + return searchLength - replaceLength; + } + /** * 用于处理原字符串中的尖括号 */ @@ -315,4 +367,38 @@ public class ShowValueUtils { public static String joinStr4Position(String... strings) { return StableUtils.join(strings, JOIN_GAP_STRING); } + + /** + * 更新替换后内容的高亮 + * + * @param info 存储信息的数据结构 + * @param str 原内容 + * @param searchStr 搜索内容 + * @param replacedStr 替换内容 + */ + public static void updateAfterReplaceStr(Info info, String str, String searchStr, String replacedStr) { + info.getContent().setAfterReplaceStr(ShowValueUtils.getReplaceString(str, searchStr, replacedStr)); + } + + + /** + * 获取搜索或替换后的提示 + * + * @param findCount + * @param replaceCount + * @param failedCount + * @return + */ + public static String getResultTip(int findCount, int replaceCount, int failedCount) { + StringBuilder str = new StringBuilder(); + str.append("").append(Toolkit.i18nText("Fine-Design_Replace_Search_Finish")).append("").append(findCount).append("").append(Toolkit.i18nText("Fine-Design_Replace_Result")); + if (replaceCount != 0) { + str.append(Toolkit.i18nText("Fine-Design_Replace_Also_Finish")).append("").append(replaceCount).append("").append(Toolkit.i18nText("Fine-Design_Replace_Result_Count")); + if (failedCount != 0) { + str.append(Toolkit.i18nText("Fine-Design_Replace_Have")).append("").append(replaceCount).append("").append(Toolkit.i18nText("Fine-Design_Replace_Can_Not_Replace")); + } + } + + return str.toString(); + } } From 45b448ca4188d12ee426180bc0e0659068ec3671 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Thu, 27 Oct 2022 15:35:09 +0800 Subject: [PATCH 16/63] =?UTF-8?q?REPORT-80695=20=E3=80=90=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E5=85=A8=E5=B1=80=E7=BA=A7=E5=88=AB=E6=9F=A5=E6=89=BE?= =?UTF-8?q?=E6=9B=BF=E6=8D=A2=E4=BA=8C=E6=9C=9F=E3=80=91=E5=9F=BA=E7=A1=80?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=BB=93=E6=9E=84=E4=BF=AE=E6=94=B9=EF=BC=8C?= =?UTF-8?q?=E9=80=82=E9=85=8D=E5=A4=9A=E5=87=BA=E6=9D=A5=E7=9A=84=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2=E5=90=8E=E5=86=85=E5=AE=B9=E8=BF=99=E4=B8=80=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/actions/replace/info/CellInfo.java | 29 ++++++++++++----- .../actions/replace/info/ConnectionInfo.java | 28 +++++++++++++++++ .../actions/replace/info/DSColumnInfo.java | 28 +++++++++++++++++ .../actions/replace/info/FloatInfo.java | 14 ++++++--- .../fr/design/actions/replace/info/Info.java | 2 -- .../design/actions/replace/info/JSInfo.java | 1 + .../actions/replace/info/ReplaceObject.java | 31 ++++++++++++++++--- .../actions/replace/info/WidgetInfo.java | 7 +++-- .../actions/replace/info/base/ITContent.java | 31 ++++++++++++++++++- 9 files changed, 150 insertions(+), 21 deletions(-) create mode 100644 designer-realize/src/main/java/com/fr/design/actions/replace/info/ConnectionInfo.java create mode 100644 designer-realize/src/main/java/com/fr/design/actions/replace/info/DSColumnInfo.java diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/CellInfo.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/CellInfo.java index e5a6ce4fa2..9f83b99234 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/info/CellInfo.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/CellInfo.java @@ -99,10 +99,13 @@ public class CellInfo implements Info { if (title.getTextObject() instanceof Formula) { Formula formula = (Formula) title.getTextObject(); updateOldStr(formula.getContent(), findStr); + ShowValueUtils.updateAfterReplaceStr(info, formula.getContent(), findStr, replaceStr); formula.setContent(ShowValueUtils.replaceAll(formula.getContent(), findStr, replaceStr)); } else { updateOldStr(GeneralUtils.objectToString(title.getTextObject()), findStr); - title.setTextObject(ShowValueUtils.replaceAll(GeneralUtils.objectToString(title.getTextObject()), findStr, replaceStr)); + String str = GeneralUtils.objectToString(title.getTextObject()); + ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr); + title.setTextObject(ShowValueUtils.replaceAll(str, findStr, replaceStr)); } } else { CellValueType cellValueType = CellValueType.match(cellElement.getValue().getClass().getSimpleName()); @@ -110,7 +113,9 @@ public class CellInfo implements Info { cellValueType.setValue(this, cellElement.getValue(), findStr, replaceStr); } else { updateOldStr(GeneralUtils.objectToString(cellElement.getValue()), findStr); - cellElement.setValue(ShowValueUtils.replaceAll(GeneralUtils.objectToString(cellElement.getValue()), findStr, replaceStr)); + String str = GeneralUtils.objectToString(cellElement.getValue()); + ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr); + cellElement.setValue(ShowValueUtils.replaceAll(str, findStr, replaceStr)); } } @@ -205,7 +210,9 @@ public class CellInfo implements Info { @Override public void setValue(CellInfo cellInfo, Object o, String findStr, String replaceStr) { cellInfo.updateOldStr(GeneralUtils.objectToString(((DSColumn) o).getDSName()), findStr); - ((DSColumn) o).setDSName(ShowValueUtils.replaceAll(((DSColumn) o).getDSName(), findStr, replaceStr)); + String str = ((DSColumn) o).getDSName(); + ShowValueUtils.updateAfterReplaceStr(cellInfo, str, findStr, replaceStr); + ((DSColumn) o).setDSName(ShowValueUtils.replaceAll(str, findStr, replaceStr)); } @Override @@ -226,7 +233,9 @@ public class CellInfo implements Info { @Override public void setValue(CellInfo cellInfo, Object o, String findStr, String replaceStr) { cellInfo.updateOldStr(GeneralUtils.objectToString(o), findStr); - ((Formula) o).setContent(ShowValueUtils.replaceAll(((Formula) o).getContent(), findStr, replaceStr)); + String str = ((Formula) o).getContent(); + ShowValueUtils.updateAfterReplaceStr(cellInfo, str, findStr, replaceStr); + ((Formula) o).setContent(ShowValueUtils.replaceAll(str, findStr, replaceStr)); } @Override @@ -243,8 +252,10 @@ public class CellInfo implements Info { @Override public void setValue(CellInfo cellInfo, Object o, String findStr, String replaceStr) { LinkWorkBookTemplate workBookTemplate = (LinkWorkBookTemplate) ((SubReport) o).getPackee(); - cellInfo.updateOldStr(workBookTemplate.getTemplatePath(), findStr); - workBookTemplate.setTemplatePath(ShowValueUtils.replaceAll(workBookTemplate.getTemplatePath(), findStr, replaceStr)); + String str = workBookTemplate.getTemplatePath(); + cellInfo.updateOldStr(str, findStr); + ShowValueUtils.updateAfterReplaceStr(cellInfo, str, findStr, replaceStr); + workBookTemplate.setTemplatePath(ShowValueUtils.replaceAll(str, findStr, replaceStr)); } @Override @@ -267,8 +278,10 @@ public class CellInfo implements Info { BIAS_TEXT_PAINTER("BiasTextPainter") { @Override public void setValue(CellInfo cellInfo, Object o, String findStr, String replaceStr) { - cellInfo.updateOldStr(((BiasTextPainter) o).getText(), findStr); - ((BiasTextPainter) o).setText(ShowValueUtils.replaceAll(((BiasTextPainter) o).getText(), findStr, replaceStr)); + String str = ((BiasTextPainter) o).getText(); + cellInfo.updateOldStr(str, findStr); + ShowValueUtils.updateAfterReplaceStr(cellInfo, str, findStr, replaceStr); + ((BiasTextPainter) o).setText(ShowValueUtils.replaceAll(str, findStr, replaceStr)); } @Override diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/ConnectionInfo.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/ConnectionInfo.java new file mode 100644 index 0000000000..b88c8c6e07 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/ConnectionInfo.java @@ -0,0 +1,28 @@ +package com.fr.design.actions.replace.info; + +import com.fr.design.actions.replace.info.base.ITContent; + +/** + * 存储数据连接 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-10-26 + */ +public class ConnectionInfo implements Info { + private ITContent content; + + + public ConnectionInfo(ITContent content) { + this.content = content; + } + + @Override + public ITContent getContent() { + return content; + } + + public void setContent(ITContent content) { + this.content = content; + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/DSColumnInfo.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/DSColumnInfo.java new file mode 100644 index 0000000000..f51a75fe5c --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/DSColumnInfo.java @@ -0,0 +1,28 @@ +package com.fr.design.actions.replace.info; + +import com.fr.design.actions.replace.info.base.ITContent; + +/** + * 存储数据列 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-10-26 + */ +public class DSColumnInfo implements Info { + private ITContent content; + + + public DSColumnInfo(ITContent content) { + this.content = content; + } + + @Override + public ITContent getContent() { + return content; + } + + public void setContent(ITContent content) { + this.content = content; + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/FloatInfo.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/FloatInfo.java index 2bf794ab80..187b5c4f8a 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/info/FloatInfo.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/FloatInfo.java @@ -92,20 +92,26 @@ public class FloatInfo implements Info { if (title.getTextObject() instanceof Formula) { Formula formula = (Formula) title.getTextObject(); updateOldStr(formula.getContent(), findStr); + ShowValueUtils.updateAfterReplaceStr(info, formula.getContent(), findStr, replaceStr); formula.setContent(ShowValueUtils.replaceAll(formula.getContent(), findStr, replaceStr)); } else { - updateOldStr(GeneralUtils.objectToString(title.getTextObject()), findStr); - title.setTextObject(ShowValueUtils.replaceAll(GeneralUtils.objectToString(title.getTextObject()), findStr, replaceStr)); + String str = GeneralUtils.objectToString(title.getTextObject()); + ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr); + updateOldStr(str, findStr); + title.setTextObject(ShowValueUtils.replaceAll(str, findStr, replaceStr)); } } else { FloatElement floatElement = ((FloatElement) this.getContent().getReplaceObject()); if (floatElement.getValue() instanceof Formula) { Formula formula = (Formula) floatElement.getValue(); updateOldStr(formula.getContent(), findStr); + ShowValueUtils.updateAfterReplaceStr(info, formula.getContent(), findStr, replaceStr); formula.setContent(ShowValueUtils.replaceAll(formula.getContent(), findStr, replaceStr)); } else { - updateOldStr(GeneralUtils.objectToString(floatElement.getValue()), findStr); - floatElement.setValue(ShowValueUtils.replaceAll(GeneralUtils.objectToString(floatElement.getValue()), findStr, replaceStr)); + String str = GeneralUtils.objectToString(floatElement.getValue()); + ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr); + updateOldStr(str, findStr); + floatElement.setValue(ShowValueUtils.replaceAll(str, findStr, replaceStr)); } } } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/Info.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/Info.java index 3f5a30d860..6f26be2595 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/info/Info.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/Info.java @@ -40,6 +40,4 @@ public interface Info extends DealWithInfoValue { //todo 完善所有类型的校验 return true; } - - ; } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/JSInfo.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/JSInfo.java index 3f0632fe84..3718381f12 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/info/JSInfo.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/JSInfo.java @@ -1,6 +1,7 @@ package com.fr.design.actions.replace.info; +import com.fr.design.actions.replace.action.content.js.JSCheckType; import com.fr.design.actions.replace.info.base.ITContent; import com.fr.stable.AssistUtils; diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/ReplaceObject.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/ReplaceObject.java index 48a4dbf644..140245cc9b 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/info/ReplaceObject.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/ReplaceObject.java @@ -2,6 +2,7 @@ package com.fr.design.actions.replace.info; import com.fr.data.impl.DBTableData; import com.fr.design.DesignModelAdapter; +import com.fr.design.actions.replace.action.content.js.JSCheckType; import com.fr.design.actions.replace.utils.ShowValueUtils; import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.datapane.TableDataTreePane; @@ -47,10 +48,12 @@ public enum ReplaceObject implements DealWithInfoValue { if (((JSInfo) info).isContent()) { JavaScriptImpl javaScript = (JavaScriptImpl) ((NameJavaScript) (info.getContent().getReplaceObject())).getJavaScript(); info.updateOldStr(javaScript.getContent(), findStr); + ShowValueUtils.updateAfterReplaceStr(info, javaScript.getContent(), findStr, replaceStr); javaScript.setContent(ShowValueUtils.replaceAll(javaScript.getContent(), findStr, replaceStr)); } else { NameJavaScript javaScript = ((NameJavaScript) (info.getContent().getReplaceObject())); info.updateOldStr(javaScript.getName(), findStr); + ShowValueUtils.updateAfterReplaceStr(info, javaScript.getName(), findStr, replaceStr); javaScript.setName(ShowValueUtils.replaceAll(javaScript.getName(), findStr, replaceStr)); } } @@ -94,10 +97,12 @@ public enum ReplaceObject implements DealWithInfoValue { if (((JSInfo) info).isContent()) { JavaScriptImpl javaScript = (JavaScriptImpl) ((Listener) (info.getContent().getReplaceObject())).getAction(); info.updateOldStr(javaScript.getContent(), findStr); + ShowValueUtils.updateAfterReplaceStr(info, javaScript.getContent(), findStr, replaceStr); javaScript.setContent(ShowValueUtils.replaceAll(javaScript.getContent(), findStr, replaceStr)); } else { Listener listener = ((Listener) ((info.getContent().getReplaceObject()))); info.updateOldStr(listener.getName(), findStr); + ShowValueUtils.updateAfterReplaceStr(info, listener.getName(), findStr, replaceStr); listener.setName(ShowValueUtils.replaceAll(listener.getName(), findStr, replaceStr)); } } @@ -141,6 +146,7 @@ public enum ReplaceObject implements DealWithInfoValue { VanChartHtmlLabel htmlLabel = ((VanChartHtmlLabel) (info.getContent().getReplaceObject())); StringBuilder stringBuilder = new StringBuilder(htmlLabel.getCustomText()); info.updateOldStr(htmlLabel.getCustomText(), findStr); + ShowValueUtils.updateAfterReplaceStr(info, htmlLabel.getCustomText(), findStr, replaceStr); htmlLabel.setCustomText(ShowValueUtils.replaceAll(htmlLabel.getCustomText(), findStr, replaceStr)); } } @@ -175,6 +181,7 @@ public enum ReplaceObject implements DealWithInfoValue { public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { JavaScriptImpl javaScript = (JavaScriptImpl) (info.getContent().getReplaceObject()); info.updateOldStr(javaScript.getContent(), findStr); + ShowValueUtils.updateAfterReplaceStr(info, javaScript.getContent(), findStr, replaceStr); javaScript.setContent(ShowValueUtils.replaceAll(javaScript.getContent(), findStr, replaceStr)); } @@ -209,6 +216,7 @@ public enum ReplaceObject implements DealWithInfoValue { String jsName = GeneralUtils.objectToString(info.getContent().getReplaceObject()); for (int i = 0, len = jsImports.size(); i < len; i++) { if (StringUtils.equals(jsImports.get(i), jsName)) { + ShowValueUtils.updateAfterReplaceStr(info, jsName, findStr, replaceStr); jsImports.set(i, ShowValueUtils.replaceAll(jsName, findStr, replaceStr)); } } @@ -234,22 +242,23 @@ public enum ReplaceObject implements DealWithInfoValue { */ DB_TABLE_DATA("DBTableData") { @Override - boolean check (Info info){ + boolean check(Info info) { DBTableData dbTableData = (DBTableData) info.getContent().getReplaceObject(); return StringUtils.equals(dbTableData.getQuery(), info.getContent().getOldShowStr()); } @Override - public Map getValue (Object...o){ + public Map getValue(Object... o) { HashMap map = new HashMap<>(); addValue2Map(contentKey, ((DBTableData) o[0]).getQuery(), map); return map; } @Override - public void setValue (Info info, String findStr, String replaceStr, List < Pair < Integer, Integer >> operatorArray){ + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { DBTableData dbTableData = (DBTableData) info.getContent().getReplaceObject(); info.updateOldStr(dbTableData.getQuery(), findStr); + ShowValueUtils.updateAfterReplaceStr(info, dbTableData.getQuery(), findStr, replaceStr); dbTableData.setQuery(ShowValueUtils.replaceAll(dbTableData.getQuery(), findStr, replaceStr)); //清除缓存 DesignTableDataManager.removeSelectedColumnNames(dbTableData.getName()); @@ -258,7 +267,7 @@ public enum ReplaceObject implements DealWithInfoValue { } @Override - public String getInfoShowStr (Info info){ + public String getInfoShowStr(Info info) { return info.getInfoShowStr(info); } }; @@ -304,4 +313,18 @@ public enum ReplaceObject implements DealWithInfoValue { abstract boolean check(Info info); + + /** + * 修改会引入新对象的放入这里检查 + * + * @param info + * @return + */ + public boolean checkQuote(Info info) { + JSCheckType o = JSCheckType.match(info.getContent().getTag()); + if (o != null) { + return o.check(info); + } + return true; } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/WidgetInfo.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/WidgetInfo.java index 8f44967a9c..afdf098028 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/info/WidgetInfo.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/WidgetInfo.java @@ -66,10 +66,13 @@ public class WidgetInfo implements Info, DealWithInfoValue { } } else { if (isWaterMark()) { - updateOldStr(((WaterMark) widget).getWaterMark(), findStr); - ((WaterMark) widget).setWaterMark(ShowValueUtils.replaceAll(((WaterMark) widget).getWaterMark(), findStr, replaceStr)); + String str = ((WaterMark) widget).getWaterMark(); + updateOldStr(str, findStr); + ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr); + ((WaterMark) widget).setWaterMark(ShowValueUtils.replaceAll(str, findStr, replaceStr)); } else { updateOldStr(widget.getWidgetName(), findStr); + ShowValueUtils.updateAfterReplaceStr(info, widget.getWidgetName(), findStr, replaceStr); widget.setWidgetName(ShowValueUtils.replaceAll(widget.getWidgetName(), findStr, replaceStr)); } } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/ITContent.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/ITContent.java index ee83e77534..aecbe2ed10 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/ITContent.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/ITContent.java @@ -77,6 +77,16 @@ public class ITContent implements Cloneable { */ private int tag = -1; + /** + * 替换后内容 + */ + private String afterReplaceStr; + + /** + * 是否替换过 + */ + private boolean replaced = false; + public ITContent() { this.sheetID = StringUtils.EMPTY; this.sheetName = StringUtils.EMPTY; @@ -92,6 +102,7 @@ public class ITContent implements Cloneable { this.operatorArray = new ArrayList<>(); this.holdObject = new Object(); this.templatePath = StringUtils.EMPTY; + this.afterReplaceStr = StringUtils.EMPTY; } @@ -102,7 +113,7 @@ public class ITContent implements Cloneable { */ public static ITContent copy(ITContent content) { ITContent result = new ITContent(); - if (content != null){ + if (content != null) { result.setSheetID(content.getSheetID()); result.setSheetName(content.getSheetName()); result.setTemplateName(content.getTemplateName()); @@ -120,6 +131,8 @@ public class ITContent implements Cloneable { result.setHoldObject(content.getHoldObject()); result.setTag(content.getTag()); result.setTemplatePath(content.getTemplatePath()); + result.setAfterReplaceStr(content.getAfterReplaceStr()); + result.setReplaced(content.isReplaced()); } return result; } @@ -216,6 +229,22 @@ public class ITContent implements Cloneable { this.templatePath = templatePath; } + public String getAfterReplaceStr() { + return afterReplaceStr; + } + + public void setAfterReplaceStr(String afterReplaceStr) { + this.afterReplaceStr = afterReplaceStr; + } + + public boolean isReplaced() { + return replaced; + } + + public void setReplaced(boolean replaced) { + this.replaced = replaced; + } + /** * 添加位置信息 * From bdb3e25edeb355538b396dfa94744504ce9351a4 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Thu, 27 Oct 2022 15:38:25 +0800 Subject: [PATCH 17/63] =?UTF-8?q?REPORT-80695=20=E3=80=90=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E5=85=A8=E5=B1=80=E7=BA=A7=E5=88=AB=E6=9F=A5=E6=89=BE?= =?UTF-8?q?=E6=9B=BF=E6=8D=A2=E4=BA=8C=E6=9C=9F=E3=80=91=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E9=A1=B9=E4=B8=BB=E8=A6=81=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../actions/replace/action/ShowValue.java | 22 +- .../action/setting/CellFormatType.java | 257 ++++++++++++ .../replace/action/setting/CellGroupType.java | 246 ++++++++++++ .../action/setting/SettingContent.java | 72 ++++ .../action/setting/SettingController.java | 374 ++++++++++++++++++ .../action/SearchCellDSColumnAction.java | 82 ++++ .../action/SearchCellFormatAction.java | 92 +++++ .../action/SearchConnectionAction.java | 108 +++++ .../setting/action/SearchDSColumnAction.java | 87 ++++ 9 files changed, 1338 insertions(+), 2 deletions(-) create mode 100644 designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellFormatType.java create mode 100644 designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellGroupType.java create mode 100644 designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/SettingContent.java create mode 100644 designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/SettingController.java create mode 100644 designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchCellDSColumnAction.java create mode 100644 designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchCellFormatAction.java create mode 100644 designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchConnectionAction.java create mode 100644 designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchDSColumnAction.java diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/ShowValue.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/ShowValue.java index 02ded341eb..34211f1f8a 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/ShowValue.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/ShowValue.java @@ -3,6 +3,7 @@ package com.fr.design.actions.replace.action; import com.fr.design.actions.replace.info.Info; import com.fr.design.mainframe.JTemplate; +import java.util.ArrayList; import java.util.List; /** @@ -20,7 +21,9 @@ public interface ShowValue { * @param jTemplate * @return */ - List showSearchValue(JTemplate jTemplate); + default List showSearchValue(JTemplate jTemplate) { + return new ArrayList<>(); + } /** * 对搜索结果进行过滤 @@ -29,6 +32,21 @@ public interface ShowValue { * @param list * @return */ - List addMatchResult(String str, List list); + default List addMatchResult(String str, List list) { + return new ArrayList<>(); + } + + /** + * 对搜索结果进行过滤(多个过滤条件,主要针对设置项) + * + * @param list + * @param settingStr + * @param extraStr + * @return + */ + default List addMatchResult(List list, String settingStr, String extraStr) { + return new ArrayList<>(); + } + } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellFormatType.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellFormatType.java new file mode 100644 index 0000000000..9f77d7d2b4 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellFormatType.java @@ -0,0 +1,257 @@ +package com.fr.design.actions.replace.action.setting; + +import com.fr.base.CoreDecimalFormat; +import com.fr.base.NameStyle; +import com.fr.base.TextFormat; +import com.fr.data.core.FormatField; +import com.fr.design.actions.replace.info.Info; +import com.fr.general.date.FineDateFormat; +import com.fr.report.cell.CellElement; +import com.fr.stable.StringUtils; +import org.jetbrains.annotations.Nullable; + +import java.text.Format; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-10-25 + */ +public enum CellFormatType { + + /** + * 单元格-格式-数字 + */ + CELL_FORMAT_NUMBER(SettingContent.FORMAT_NUMBER) { + @Override + public boolean hasExpand(String parentStr) { + return true; + } + + @Override + public List getItems() { + return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_NUMBER))); + } + + @Override + public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) { + Format format = cellElement.getStyle().getFormat(); + return format instanceof CoreDecimalFormat && StringUtils.equals(((CoreDecimalFormat) format).toPattern(), secondStr); + } + }, + /** + * 单元格-格式-常规 + */ + CELL_FORMAT_COMMON(SettingContent.FORMAT_COMMON) { + @Override + public List getItems() { + return super.getItems(); + } + + @Override + public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) { + return cellElement.getStyle().getFormat() == null; + } + }, + /** + * 单元格-格式-货币 + */ + CELL_FORMAT_MONEY(SettingContent.FORMAT_MONEY) { + @Override + public boolean hasExpand(String parentStr) { + return true; + } + + @Override + public List getItems() { + return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_MONEY))); + } + + @Override + public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) { + Format format = cellElement.getStyle().getFormat(); + return format instanceof CoreDecimalFormat && StringUtils.equals(((CoreDecimalFormat) format).toPattern(), secondStr); + } + }, + /** + * 单元格-格式-日期 + */ + CELL_FORMAT_DATE(SettingContent.FORMAT_DATE) { + @Override + public boolean hasExpand(String parentStr) { + return true; + } + + @Override + public List getItems() { + return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_DATE))); + } + + @Override + public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) { + Format format = cellElement.getStyle().getFormat(); + return format instanceof FineDateFormat && StringUtils.equals(((FineDateFormat) format).toPattern(), secondStr); + } + }, + /** + * 单元格-格式-时间 + */ + CELL_FORMAT_TIME(SettingContent.FORMAT_TIME) { + @Override + public boolean hasExpand(String parentStr) { + return true; + } + + @Override + public List getItems() { + return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_TIME))); + } + + @Override + public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) { + Format format = cellElement.getStyle().getFormat(); + return format instanceof FineDateFormat && StringUtils.equals(((FineDateFormat) format).toPattern(), secondStr); + } + }, + /** + * 单元格-格式-科学计数 + */ + CELL_FORMAT_SCIENCE(SettingContent.FORMAT_SCIENCE) { + @Override + public boolean hasExpand(String parentStr) { + return true; + } + + @Override + public List getItems() { + return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_SCIENCE))); + } + + @Override + public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) { + Format format = cellElement.getStyle().getFormat(); + return format instanceof CoreDecimalFormat && StringUtils.equals(((CoreDecimalFormat) format).toPattern(), secondStr); + } + }, + /** + * 单元格-格式-百分比 + */ + CELL_FORMAT_PERCENT(SettingContent.FORMAT_PERCENT) { + @Override + public boolean hasExpand(String parentStr) { + return true; + } + + @Override + public List getItems() { + return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_PERCENT))); + } + + @Override + public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) { + Format format = cellElement.getStyle().getFormat(); + return format instanceof CoreDecimalFormat && StringUtils.equals(((CoreDecimalFormat) format).toPattern(), secondStr); + } + }, + /** + * 单元格-格式-千分比 + */ + CELL_FORMAT_PERMILLAGE(SettingContent.FORMAT_PERMILLAGE) { + @Override + public boolean hasExpand(String parentStr) { + return true; + } + + @Override + public List getItems() { + return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_PERMILLAGE))); + } + + @Override + public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) { + Format format = cellElement.getStyle().getFormat(); + return format instanceof CoreDecimalFormat && StringUtils.equals(((CoreDecimalFormat) format).toPattern(), secondStr); + } + }, + /** + * 单元格-格式-文本 + */ + CELL_FORMAT_TEXT(SettingContent.FORMAT_TEXT) { + @Override + public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) { + Format format = cellElement.getStyle().getFormat(); + return format instanceof TextFormat; + } + }; + + + private String name; + + CellFormatType(String name) { + this.name = name; + } + + + /** + * 匹配 + * + * @param name + * @return + */ + @Nullable + public static CellFormatType match(String name) { + CellFormatType[] values = CellFormatType.values(); + for (CellFormatType value : values) { + if (StringUtils.equals(value.name, name)) { + return value; + } + } + return null; + } + + /** + * 是否能扩展选项 + * + * @return 能扩展则返回true + */ + public boolean hasExpand(String parentStr) { + return false; + } + + /** + * 获取界面数据 + */ + public List getItems() { + return new ArrayList<>(); + } + + /** + * 是否是要查找的内容 + * + * @param cellElement + * @param firstStr + * @param secondStr + * @return + */ + public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) { + return false; + } + + /** + * 替换 + * + * @param info 存储信息的数据结构 + * @param firstStr 用户输入的第一级下拉框内容 + * @param secondStr 用户输入的第二级下拉框内容 + */ + public void replace(Info info, String firstStr, String secondStr) { + CellElement cellElement = (CellElement) info.getContent().getReplaceObject(); + cellElement.setStyle(cellElement.getStyle().deriveFormat(FormatField.getInstance().getFormat(FormatField.getInstance().getContents(firstStr), secondStr))); + if (cellElement.getStyle() instanceof NameStyle) { + ((NameStyle) cellElement.getStyle()).refreshStyle(); + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellGroupType.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellGroupType.java new file mode 100644 index 0000000000..8e769b4715 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellGroupType.java @@ -0,0 +1,246 @@ +package com.fr.design.actions.replace.action.setting; + + +import com.fr.data.util.function.AverageFunction; +import com.fr.data.util.function.CountFunction; +import com.fr.data.util.function.DataFunction; +import com.fr.data.util.function.MaxFunction; +import com.fr.data.util.function.MinFunction; +import com.fr.data.util.function.NoneFunction; +import com.fr.data.util.function.SumFunction; +import com.fr.design.actions.replace.info.Info; +import com.fr.report.cell.CellElement; +import com.fr.report.cell.cellattr.core.group.DSColumn; +import com.fr.report.cell.cellattr.core.group.FunctionGrouper; +import com.fr.report.cell.cellattr.core.group.RecordGrouper; +import com.fr.report.cell.cellattr.core.group.SummaryGrouper; +import com.fr.stable.StringUtils; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 处理单元格的格式(对于高级,由于需要自定义,不加入处理范围) + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-10-26 + */ +public enum CellGroupType { + + /** + * 分组 + */ + GROUP(SettingContent.DIGIT_SETTING_GROUP) { + @Override + public List getItems() { + List items = new ArrayList() { + { + add(SettingContent.GROUP_COMMON); + add(SettingContent.GROUP_CONTINUUM); + } + }; + return items; + } + + + @Override + public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) { + DSColumn column = (DSColumn) cellElement.getValue(); + RecordGrouper grouper = column.getGrouper(); + return grouper instanceof FunctionGrouper && grouper.getDivideMode() == getGroupType(secondStr); + } + + }, + /** + * 列表 + */ + LIST(SettingContent.DIGIT_SETTING_LIST) { + @Override + public boolean hasExpand(String parentStr) { + return false; + } + + + @Override + public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) { + DSColumn column = (DSColumn) cellElement.getValue(); + RecordGrouper grouper = column.getGrouper(); + return grouper instanceof FunctionGrouper && grouper.getDivideMode() == getGroupType(firstStr); + } + }, + /** + * 汇总 + */ + SUM(SettingContent.DIGIT_SETTING_SUM) { + @Override + public List getItems() { + List items = new ArrayList() { + { + add(SettingContent.SUMMARY_SUM); + add(SettingContent.SUMMARY_AVERAGE); + add(SettingContent.SUMMARY_MAX); + add(SettingContent.SUMMARY_MIN); + add(SettingContent.SUMMARY_COUNT); + add(SettingContent.SUMMARY_NONE); + } + }; + return items; + } + + @Override + public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) { + DSColumn column = (DSColumn) cellElement.getValue(); + RecordGrouper grouper = column.getGrouper(); + return grouper instanceof SummaryGrouper && ((SummaryGrouper) grouper).getFunction() != null && StringUtils.equals(((SummaryGrouper) grouper).getFunction().getClass().getSimpleName(), getSummaryType(secondStr)); + } + + @Override + public void replace(Info info, String firstStr, String secondStr) { + SummaryGrouper grouper = new SummaryGrouper(); + grouper.setFunction(createDataFunction(secondStr)); + CellElement cellElement = (CellElement) info.getContent().getReplaceObject(); + DSColumn column = (DSColumn) cellElement.getValue(); + column.setGrouper(grouper); + } + }; + + private String name; + + private Map groupMap = new HashMap() { + { + put(SettingContent.GROUP_COMMON, FunctionGrouper.GROUPING_MODE); + put(SettingContent.GROUP_CONTINUUM, FunctionGrouper.CONTINUUM_MODE); + put(SettingContent.DIGIT_LIST, FunctionGrouper.LIST_MODE); + } + }; + private Map summaryMap = new HashMap() { + { + put(SettingContent.SUMMARY_SUM, SUM_FUNCTION); + put(SettingContent.SUMMARY_AVERAGE, AVERAGE_FUNCTION); + put(SettingContent.SUMMARY_MAX, MAX_FUNCTION); + put(SettingContent.SUMMARY_MIN, MIN_FUNCTION); + put(SettingContent.SUMMARY_COUNT, COUNT_FUNCTION); + put(SettingContent.SUMMARY_NONE, NONE_FUNCTION); + } + }; + + public static final String SUM_FUNCTION = "SumFunction"; + public static final String AVERAGE_FUNCTION = "AverageFunction"; + public static final String MAX_FUNCTION = "MaxFunction"; + public static final String MIN_FUNCTION = "MinFunction"; + public static final String COUNT_FUNCTION = "CountFunction"; + public static final String NONE_FUNCTION = "NoneFunction"; + + + CellGroupType(String name) { + this.name = name; + } + + + /** + * 匹配 + * + * @param name + * @return + */ + @Nullable + public static CellGroupType match(String name) { + CellGroupType[] values = CellGroupType.values(); + for (CellGroupType value : values) { + if (StringUtils.equals(value.name, name)) { + return value; + } + } + return null; + } + + /** + * 是否是要查找的内容 + * + * @param cellElement + * @param firstStr + * @param secondStr + * @return + */ + public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) { + DSColumn column = (DSColumn) cellElement.getValue(); + RecordGrouper recordGrouper = column.getGrouper(); + return recordGrouper instanceof FunctionGrouper && recordGrouper.getDivideMode() == getGroupType(secondStr); + } + + /** + * 匹配分组 + * + * @param str + * @return + */ + public Integer getGroupType(String str) { + return groupMap.getOrDefault(str, -1); + } + + /** + * 匹配汇总 + */ + public String getSummaryType(String str) { + return summaryMap.getOrDefault(str, StringUtils.EMPTY); + } + + /** + * 创建对应汇总的DataFunction + * + * @param str 汇总子级下拉框的内容 + * @return 指定类型的DataFunction + */ + public DataFunction createDataFunction(String str) { + switch (getSummaryType(str)) { + case SUM_FUNCTION: + return new SumFunction(); + case AVERAGE_FUNCTION: + return new AverageFunction(); + case MAX_FUNCTION: + return new MaxFunction(); + case MIN_FUNCTION: + return new MinFunction(); + case COUNT_FUNCTION: + return new CountFunction(); + case NONE_FUNCTION: + return new NoneFunction(); + } + return new NoneFunction(); + } + + /** + * 是否能扩展选项 + * + * @return 能扩展则返回true + */ + public boolean hasExpand(String parentStr) { + return true; + } + + /** + * 获取界面数据 + */ + public List getItems() { + return new ArrayList<>(); + } + + /** + * 替换 + * + * @param info 存储信息的数据结构 + * @param firstStr 用户输入的第一级下拉框 + * @param secondStr 用户输入的第二级下拉框 + */ + public void replace(Info info, String firstStr, String secondStr) { + FunctionGrouper grouper = new FunctionGrouper(); + grouper.setDivideMode(getGroupType(secondStr)); + CellElement cellElement = (CellElement) info.getContent().getReplaceObject(); + DSColumn column = (DSColumn) cellElement.getValue(); + column.setGrouper(grouper); + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/SettingContent.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/SettingContent.java new file mode 100644 index 0000000000..67211b77e9 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/SettingContent.java @@ -0,0 +1,72 @@ +package com.fr.design.actions.replace.action.setting; + +import com.fr.design.actions.replace.utils.ShowValueUtils; +import com.fr.design.i18n.Toolkit; + +/** + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-10-24 + */ +public class SettingContent { + + public static final String CELL_FORMAT_NAME = ShowValueUtils.joinStr4Position(Toolkit.i18nText("Fine-Design_Basic_Cell"), Toolkit.i18nText("Fine-Design_Report_Base_Format")); + public static final String CELL_DATA_SETTING_NAME = ShowValueUtils.joinStr4Position(Toolkit.i18nText("Fine-Design_Basic_Cell"), Toolkit.i18nText("Fine-Design_Chart_Data_Setting")); + public static final String CELL_DS_COLUMN_NAME = ShowValueUtils.joinStr4Position(Toolkit.i18nText("Fine-Design_Basic_Cell"), Toolkit.i18nText("Fine-Design_Basic_DS_Column")); + public static final String DATASOURCE_CONNECTION_NAME = ShowValueUtils.joinStr4Position(Toolkit.i18nText("Fine-Design_Replace_Data_Source"), Toolkit.i18nText("Fine-Design_Replace_Data_Connection")); + public static final String DATASOURCE_COLLECT_NAME = ShowValueUtils.joinStr4Position(Toolkit.i18nText("Fine-Design_Replace_Data_Source"), Toolkit.i18nText("Fine-Design_Replace_Data_Collect")); + + /** + * 单元格-格式 + */ + public static final String FORMAT_COMMON = Toolkit.i18nText("Fine-Design_Replace_Common"); + public static final String FORMAT_NUMBER = Toolkit.i18nText("Fine-Design_Replace_Number"); + public static final String FORMAT_MONEY = Toolkit.i18nText("Fine-Design_Replace_Money"); + public static final String FORMAT_PERCENT = Toolkit.i18nText("Fine-Design_Replace_Percent"); + public static final String FORMAT_PERMILLAGE = Toolkit.i18nText("Fine-Design_Replace_Permillage"); + public static final String FORMAT_SCIENCE = Toolkit.i18nText("Fine-Design_Replace_Science"); + public static final String FORMAT_DATE = Toolkit.i18nText("Fine-Design_Replace_Date"); + public static final String FORMAT_TIME = Toolkit.i18nText("Fine-Design_Replace_Time"); + public static final String FORMAT_TEXT = Toolkit.i18nText("Fine-Design_Replace_Text"); + + + /** + * 单元格-数据设置 + */ + public static final String DIGIT_SETTING_GROUP = Toolkit.i18nText("Fine-Design_Replace_Group"); + public static final String DIGIT_SETTING_LIST = Toolkit.i18nText("Fine-Design_Replace_List"); + public static final String DIGIT_SETTING_SUM = Toolkit.i18nText("Fine-Design_Replace_Sum"); + + /** + * 单元格-数据设置-分组 + */ + public static final String GROUP_COMMON = Toolkit.i18nText("Fine-Design_Report_Common"); + public static final String GROUP_CONTINUUM = Toolkit.i18nText("Fine-Design_Report_Continuum"); + + /** + * 单元格-数据设置-列表 + */ + public static final String DIGIT_LIST = Toolkit.i18nText("Fine-Design_Report_Bind_Column_Select"); + + /** + * 单元格-数据设置-汇总 + */ + public static final String SUMMARY_SUM = Toolkit.i18nText("Fine-Design_DataFunction_Sum"); + public static final String SUMMARY_AVERAGE = Toolkit.i18nText("Fine-Design_DataFunction_Average"); + public static final String SUMMARY_MAX = Toolkit.i18nText("Fine-Design_DataFunction_Max"); + public static final String SUMMARY_MIN = Toolkit.i18nText("Fine-Design_DataFunction_Min"); + public static final String SUMMARY_COUNT = Toolkit.i18nText("Fine-Design_DataFunction_Count"); + public static final String SUMMARY_NONE = Toolkit.i18nText("Fine-Design_DataFunction_None"); + + /** + * 数据连接 + */ + public static final String CONNECTION_TEMPLATE = Toolkit.i18nText("Fine-Design_Basic_DS_Report_TableData"); + + /** + * 扩展出来的可能的选项 + */ + public static final String DS_COLUMN_EXPEND = "DS_COLUMN_EXPEND"; + + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/SettingController.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/SettingController.java new file mode 100644 index 0000000000..fa7fcc0b09 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/SettingController.java @@ -0,0 +1,374 @@ +package com.fr.design.actions.replace.action.setting; + + +import com.fr.data.TableDataSource; +import com.fr.design.actions.replace.action.ShowValue; +import com.fr.design.actions.replace.action.setting.action.SearchCellDSColumnAction; +import com.fr.design.actions.replace.action.setting.action.SearchCellFormatAction; +import com.fr.design.actions.replace.action.setting.action.SearchConnectionAction; +import com.fr.design.actions.replace.action.setting.action.SearchDSColumnAction; +import com.fr.design.actions.replace.info.CellInfo; +import com.fr.design.actions.replace.info.ConnectionInfo; +import com.fr.design.actions.replace.info.Info; +import com.fr.design.actions.replace.ui.ITReplaceNorthPanel; +import com.fr.design.data.DesignTableDataManager; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.mainframe.JTemplate; +import com.fr.file.ConnectionConfig; +import com.fr.general.data.TableDataColumn; +import com.fr.report.cell.CellElement; +import com.fr.report.cell.cellattr.core.group.DSColumn; +import com.fr.stable.StringUtils; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; + +/** + * 设置项的查找内容 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-10-24 + */ +public enum SettingController implements ShowValue { + + /** + * 单元格-格式 + */ + CELL_FORMAT(SettingContent.CELL_FORMAT_NAME) { + @Override + public List getItems() { + return ITReplaceNorthPanel.formatItems; + } + + @Override + public List showSearchValue(JTemplate jTemplate) { + SearchCellFormatAction.getInstance().search4Infos(jTemplate); + return SearchCellFormatAction.getInstance().getCellInfos(); + } + + @Override + public List addMatchResult(List list, String settingStr, String extraStr) { + List cellInfos = new ArrayList<>(); + for (Info info : list) { + CellElement cellElement = (CellElement) info.getContent().getReplaceObject(); + CellFormatType type = CellFormatType.match(settingStr); + if (type != null && type.isNeed(cellElement, settingStr, extraStr)) { + cellInfos.add((CellInfo) info); + } + } + return cellInfos; + } + + @Override + public boolean hasExpand(String str, String parentStr) { + CellFormatType type = CellFormatType.match(parentStr); + if (type != null) { + return type.hasExpand(parentStr); + } + return false; + } + + @Override + public List getExtraItems(String str) { + CellFormatType type = CellFormatType.match(str); + if (type != null) { + return type.getItems(); + } + return new ArrayList<>(); + } + + @Override + public void replace(Info info, String firstStr, String secondStr) { + CellFormatType type = CellFormatType.match(firstStr); + if (type != null) { + type.replace(info, firstStr, secondStr); + } + } + }, + /** + * 单元格-数据设置 + */ + CELL_DATA_SETTING(SettingContent.CELL_DATA_SETTING_NAME) { + @Override + public List getItems() { + return ITReplaceNorthPanel.digitItems; + } + + @Override + public List showSearchValue(JTemplate jTemplate) { + SearchCellDSColumnAction.getInstance().search4Infos(jTemplate); + return SearchCellDSColumnAction.getInstance().getCellInfos(); + } + + @Override + public List addMatchResult(List list, String settingStr, String extraStr) { + List cellInfos = new ArrayList<>(); + for (Info info : list) { + CellElement cellElement = (CellElement) info.getContent().getReplaceObject(); + //能到这步说明单元格里是数据列 + CellGroupType cellGroupType = CellGroupType.match(settingStr); + if (cellGroupType != null && cellGroupType.isNeed(cellElement, settingStr, extraStr)) { + cellInfos.add((CellInfo) info); + } + } + return cellInfos; + } + + @Override + public List getExtraItems(String str) { + CellGroupType type = CellGroupType.match(str); + if (type != null) { + return type.getItems(); + } + return new ArrayList<>(); + } + + @Override + public boolean hasExpand(String str, String parentStr) { + CellGroupType type = CellGroupType.match(parentStr); + if (type != null) { + return type.hasExpand(parentStr); + } + return false; + } + + @Override + public void replace(Info info, String firstStr, String secondStr) { + CellGroupType type = CellGroupType.match(firstStr); + if (type != null) { + type.replace(info, firstStr, secondStr); + } + } + }, + /** + * 单元格-数据列 + */ + CELL_DS_COLUMN(SettingContent.CELL_DS_COLUMN_NAME) { + @Override + public List showSearchValue(JTemplate jTemplate) { + SearchCellDSColumnAction.getInstance().search4Infos(jTemplate); + return SearchCellDSColumnAction.getInstance().getCellInfos(); + } + + @Override + public List addMatchResult(List list, String settingStr, String extraStr) { + List cellInfos = new ArrayList<>(); + for (Info info : list) { + CellElement cellElement = (CellElement) info.getContent().getReplaceObject(); + //能到这步说明单元格里是数据列 + DSColumn dsColumn = (DSColumn) cellElement.getValue(); + if (isNeed(dsColumn, settingStr, extraStr)) { + cellInfos.add((CellInfo) info); + } + } + return cellInfos; + } + + public boolean isNeed(DSColumn dsColumn, String settingStr, String extraStr) { + return dsColumn != null && StringUtils.equals(settingStr, dsColumn.getDSName()) && dsColumn.getColumn() != null && StringUtils.equals(dsColumn.getColumnName(), extraStr); + } + + @Override + public List getItems() { + JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + List tableDataArray = new ArrayList<>(); + if (jTemplate != null && jTemplate.getTarget() instanceof TableDataSource) { + TableDataSource source = (TableDataSource) jTemplate.getTarget(); + Iterator dataIterator = source.getTableDataNameIterator(); + while (dataIterator.hasNext()) { + String dataName = (String) dataIterator.next(); + tableDataArray.add(dataName); + } + } + return tableDataArray; + } + + @Override + public List getExtraItems(String str) { + JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + List tableDataArray = new ArrayList<>(); + if (jTemplate != null) { + TableDataSource source = jTemplate.getTarget(); + tableDataArray = Arrays.asList(DesignTableDataManager.getSelectedColumnNames(source, str)); + } + return tableDataArray; + } + + @Override + public boolean hasExpand(String str, String parentStr) { + return true; + } + + @Override + public void replace(Info info, String firstStr, String secondStr) { + CellElement cellElement = (CellElement) info.getContent().getReplaceObject(); + DSColumn dsColumn = (DSColumn) cellElement.getValue(); + dsColumn.setDSName(firstStr); + dsColumn.setColumn(TableDataColumn.createColumn(secondStr)); + + } + }, + /** + * 数据源-数据连接 + */ + DATASOURCE_CONNECTION(SettingContent.DATASOURCE_CONNECTION_NAME) { + @Override + public List showSearchValue(JTemplate jTemplate) { + SearchConnectionAction.getInstance().search4Infos(jTemplate); + return SearchConnectionAction.getInstance().getConnectionInfos(); + } + + @Override + public List addMatchResult(List list, String settingStr, String extraStr) { + List connectionInfos = new ArrayList<>(); + for (Info info : list) { + if (StringUtils.equals(info.getContent().getShowStr(), settingStr)) { + connectionInfos.add((ConnectionInfo) info); + } + } + return connectionInfos; + + } + + @Override + public List getItems() { + List nameList = new ArrayList<>(); + for (String name : ConnectionConfig.getInstance().getConnections().keySet()) { + nameList.add(name); + } + return nameList; + } + + }, + /** + * 数据源-数据集 + */ + DATASOURCE_COLLECT(SettingContent.DATASOURCE_COLLECT_NAME) { + @Override + public List showSearchValue(JTemplate jTemplate) { + SearchDSColumnAction.getInstance().search4Infos(jTemplate); + return SearchDSColumnAction.getInstance().getDsColumnInfos(); + } + + + @Override + public List addMatchResult(List list, String settingStr, String extraStr) { + return list; + } + + @Override + public List getItems() { + return ITReplaceNorthPanel.dsColumnItems; + } + + + }; + + + private String name; + + SettingController(String name) { + this.name = name; + } + + + /** + * 匹配 + * + * @param name + * @return + */ + @Nullable + public static SettingController match(String name) { + SettingController[] values = SettingController.values(); + for (SettingController value : values) { + if (StringUtils.equals(value.name, name)) { + return value; + } + } + return null; + } + + /** + * 获取界面的数据,使之与选项匹配 + * + * @param name 选项 + */ + public static List getSettingRefreshItems(String name) { + SettingController[] values = SettingController.values(); + for (SettingController value : values) { + if (StringUtils.equals(value.name, name)) { + return value.getItems(); + } + } + return new ArrayList<>(); + } + + /** + * 获取界面的数据,使之与选项匹配 + * + * @param parentStr 选项 + */ + public static List getSettingExtraRefreshItems(String str, String parentStr) { + SettingController[] values = SettingController.values(); + for (SettingController value : values) { + if (StringUtils.equals(value.name, str)) { + return value.getExtraItems(parentStr); + } + } + return new ArrayList<>(); + } + + /** + * 获取界面数据 + */ + public List getItems() { + return new ArrayList<>(); + } + + /** + * 获取扩展数据 + * + * @param str 父类名称 + * @return 扩展的数据列表 + */ + public List getExtraItems(String str) { + return new ArrayList<>(); + } + + /** + * 是否能扩展选项 + * + * @return 能扩展则返回true + */ + public boolean hasExpand(String str, String parentStr) { + return false; + } + + /** + * 替换 + * + * @param info 存储信息的数据结构 + * @param firstStr 用户设定的第一级下拉框的内容 + * @param secondStr 用户设定的第二级下拉框的内容 + */ + public void replace(Info info, String firstStr, String secondStr) { + + } + + /** + * 是否修改过 + * + * @param info 存储信息的数据结构 + * @param inputStr 用户搜索的一级下拉框内容 + * @param extraStr 用户搜索的二级下拉框内容 + * @return 没修改过则返回false + */ + public boolean isEverChanged(Info info, String inputStr, String extraStr) { + return false; + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchCellDSColumnAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchCellDSColumnAction.java new file mode 100644 index 0000000000..3a79231867 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchCellDSColumnAction.java @@ -0,0 +1,82 @@ +package com.fr.design.actions.replace.action.setting.action; + +import com.fr.design.actions.replace.action.SearchAction; +import com.fr.design.actions.replace.action.content.cell.SearchCellAction; +import com.fr.design.actions.replace.info.CellInfo; +import com.fr.design.mainframe.JTemplate; +import com.fr.general.GeneralUtils; +import com.fr.report.cell.CellElement; +import com.fr.report.cell.cellattr.core.group.DSColumn; + +import java.util.ArrayList; +import java.util.List; + +/** + * 存储单元格-数据列 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-10-26 + */ +public class SearchCellDSColumnAction implements SearchAction { + private List cellInfos = new ArrayList<>(); + + private SearchCellDSColumnAction() { + } + + @Override + public void search4Infos(JTemplate jTemplate) { + List cellInfos = new ArrayList<>(); + SearchCellAction.getInstance().search4Infos(jTemplate); + for (CellInfo info : SearchCellAction.getInstance().getCellInfos()) { + CellElement cellElement = (CellElement) info.getContent().getReplaceObject(); + if (cellElement.getValue() instanceof DSColumn) { + info.getContent().setShowStr(GeneralUtils.objectToString(cellElement.getValue())); + cellInfos.add(info); + } + } + setCellInfos(cellInfos); + } + + public List getCellInfos() { + return cellInfos; + } + + public void setCellInfos(List cellInfos) { + this.cellInfos = cellInfos; + } + + /** + * 对外开放的获取对象的方法 + * + * @return + */ + public static SearchCellDSColumnAction getInstance() { + return SearchCellDSColumnActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchCellDSColumnActionEnum { + /** + * 单例 + */ + SINGLETON; + + private SearchCellDSColumnAction instance; + + SearchCellDSColumnActionEnum() { + instance = new SearchCellDSColumnAction(); + } + + /** + * 获取对象 + * + * @return + */ + public SearchCellDSColumnAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchCellFormatAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchCellFormatAction.java new file mode 100644 index 0000000000..bd607c625b --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchCellFormatAction.java @@ -0,0 +1,92 @@ +package com.fr.design.actions.replace.action.setting.action; + +import com.fr.base.Formula; +import com.fr.design.actions.replace.action.SearchAction; +import com.fr.design.actions.replace.action.content.cell.SearchCellAction; +import com.fr.design.actions.replace.info.CellInfo; +import com.fr.design.mainframe.JTemplate; +import com.fr.general.GeneralUtils; +import com.fr.report.cell.CellElement; +import com.fr.report.cell.cellattr.core.group.DSColumn; + +import java.util.ArrayList; +import java.util.List; + +/** + * 存储有格式的单元格 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-10-25 + */ +public class SearchCellFormatAction implements SearchAction { + private List cellInfos = new ArrayList<>(); + + private SearchCellFormatAction() { + } + + @Override + public void search4Infos(JTemplate jTemplate) { + List cellInfos = new ArrayList<>(); + SearchCellAction.getInstance().search4Infos(jTemplate); + for (CellInfo info : SearchCellAction.getInstance().getCellInfos()) { + CellElement cellElement = (CellElement) info.getContent().getReplaceObject(); + if (isFormatValid(cellElement)) { + info.getContent().setShowStr(GeneralUtils.objectToString(cellElement.getValue())); + cellInfos.add(info); + } + } + setCellInfos(cellInfos); + } + + public boolean isFormatValid(CellElement cellElement) { + return cellElement.getStyle() != null + && (cellElement.getValue() instanceof Formula + || cellElement.getValue() instanceof DSColumn + || cellElement.getValue() instanceof String + || cellElement.getValue() instanceof Integer); + } + + public List getCellInfos() { + return cellInfos; + } + + public void setCellInfos(List cellInfos) { + this.cellInfos = cellInfos; + } + + /** + * 对外开放的获取对象的方法 + * + * @return + */ + public static SearchCellFormatAction getInstance() { + return SearchCellFormatActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchCellFormatActionEnum { + /** + * 单例 + */ + SINGLETON; + + private SearchCellFormatAction instance; + + SearchCellFormatActionEnum() { + instance = new SearchCellFormatAction(); + } + + /** + * 获取对象 + * + * @return + */ + public SearchCellFormatAction getInstance() { + return instance; + } + } + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchConnectionAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchConnectionAction.java new file mode 100644 index 0000000000..199361fd7b --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchConnectionAction.java @@ -0,0 +1,108 @@ +package com.fr.design.actions.replace.action.setting.action; + +import com.fr.base.TableData; +import com.fr.base.TableDataConnection; +import com.fr.data.TableDataSource; +import com.fr.data.impl.Connection; +import com.fr.data.impl.NameDatabaseConnection; +import com.fr.design.actions.replace.action.SearchAction; +import com.fr.design.actions.replace.info.ConnectionInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.mainframe.JTemplate; +import com.fr.file.ConnectionConfig; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +/** + * 存储数据连接信息 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-10-26 + */ +public class SearchConnectionAction implements SearchAction { + private List connectionInfos = new ArrayList<>(); + + + private SearchConnectionAction() { + + } + + @Override + public void search4Infos(JTemplate jTemplate) { + List connectionInfos = new ArrayList<>(); + Map map = ConnectionConfig.getInstance().getConnections(); + Map needMap = new HashMap<>(); + TableDataSource source = (TableDataSource) jTemplate.getTarget(); + Iterator dataIterator = source.getTableDataNameIterator(); + while (dataIterator.hasNext()) { + String dataName = (String) dataIterator.next(); + TableData data = source.getTableData(dataName); + if (isNameDataBaseConnectionValid(data)) { + NameDatabaseConnection connection = (NameDatabaseConnection) ((TableDataConnection) data).getDatabase(); + if (map.containsKey(connection.getName())) { + needMap.put(connection.getName(), connection); + } + } + } + for (String name : needMap.keySet()) { + ITContent content = new ITContent(); + content.setReplaceObject(needMap.get(name)); + content.setTemplateName(jTemplate.getTemplateName()); + content.setJumpAble(false); + content.setShowStr(name); + connectionInfos.add(new ConnectionInfo(content)); + } + setConnectionInfos(connectionInfos); + } + + public boolean isNameDataBaseConnectionValid(TableData data) { + return data instanceof TableDataConnection && ((TableDataConnection) data).getDatabase() instanceof NameDatabaseConnection; + } + + public List getConnectionInfos() { + return connectionInfos; + } + + public void setConnectionInfos(List connectionInfos) { + this.connectionInfos = connectionInfos; + } + + /** + * 对外开放的获取对象的方法 + * + * @return + */ + public static SearchConnectionAction getInstance() { + return SearchConnectionActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchConnectionActionEnum { + /** + * 单例 + */ + SINGLETON; + + private SearchConnectionAction instance; + + SearchConnectionActionEnum() { + instance = new SearchConnectionAction(); + } + + /** + * 获取对象 + * + * @return + */ + public SearchConnectionAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchDSColumnAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchDSColumnAction.java new file mode 100644 index 0000000000..1cba80902b --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchDSColumnAction.java @@ -0,0 +1,87 @@ +package com.fr.design.actions.replace.action.setting.action; + +import com.fr.base.TableData; +import com.fr.data.TableDataSource; +import com.fr.design.actions.replace.action.SearchAction; +import com.fr.design.actions.replace.info.DSColumnInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.mainframe.JTemplate; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * 搜索数据列 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-10-26 + */ +public class SearchDSColumnAction implements SearchAction { + private List dsColumnInfos = new ArrayList<>(); + + + private SearchDSColumnAction() { + } + + @Override + public void search4Infos(JTemplate jTemplate) { + List dsColumnInfos = new ArrayList<>(); + TableDataSource source = (TableDataSource) jTemplate.getTarget(); + Iterator dataIterator = source.getTableDataNameIterator(); + while (dataIterator.hasNext()) { + String dataName = (String) dataIterator.next(); + TableData data = source.getTableData(dataName); + ITContent content = new ITContent(); + content.setJumpAble(false); + content.setReplaceObject(data); + content.setShowStr(dataName); + content.setTemplateName(jTemplate.getTemplateName()); + dsColumnInfos.add(new DSColumnInfo(content)); + setDsColumnInfos(dsColumnInfos); + } + } + + public List getDsColumnInfos() { + return dsColumnInfos; + } + + public void setDsColumnInfos(List dsColumnInfos) { + this.dsColumnInfos = dsColumnInfos; + } + + /** + * 对外开放的获取对象的方法 + * + * @return + */ + public static SearchDSColumnAction getInstance() { + return SearchDSColumnActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchDSColumnActionEnum { + /** + * 单例 + */ + SINGLETON; + + private SearchDSColumnAction instance; + + SearchDSColumnActionEnum() { + instance = new SearchDSColumnAction(); + } + + /** + * 获取对象 + * + * @return + */ + public SearchDSColumnAction getInstance() { + return instance; + } + } +} From 33d82a0db404b475a4ed790ffc033445484944d3 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Thu, 27 Oct 2022 15:39:25 +0800 Subject: [PATCH 18/63] =?UTF-8?q?REPORT-80695=20=E3=80=90=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E5=85=A8=E5=B1=80=E7=BA=A7=E5=88=AB=E6=9F=A5=E6=89=BE?= =?UTF-8?q?=E6=9B=BF=E6=8D=A2=E4=BA=8C=E6=9C=9F=E3=80=91=E9=80=82=E9=85=8D?= =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E5=A4=9A=E5=87=BA=E6=9D=A5=E7=9A=84=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2=E5=90=8E=E5=86=85=E5=AE=B9=E8=BF=99=E4=B8=80=E5=88=97?= =?UTF-8?q?=EF=BC=8C=E4=BB=A5=E5=8F=8A=E9=83=A8=E5=88=86=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../content/component/ComponentType.java | 10 +- .../content/formula/FormulaReplaceObject.java | 118 ++++++++++-------- .../action/content/formula/FormulaTag.java | 41 ++++-- .../template/SearchTemplateFormulaAction.java | 4 +- .../replace/action/content/js/JSCheckTag.java | 15 +++ .../action/content/js/JSCheckType.java | 65 ++++++++++ .../action/content/widget/FrmWidgetType.java | 1 + 7 files changed, 191 insertions(+), 63 deletions(-) create mode 100644 designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/JSCheckTag.java create mode 100644 designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/JSCheckType.java diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/component/ComponentType.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/component/ComponentType.java index bb6e190f69..13712a570a 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/component/ComponentType.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/component/ComponentType.java @@ -126,7 +126,9 @@ public enum ComponentType implements DealWithInfoValue { info.updateOldStr(titleLayout.getWidgetName(), findStr); titleLayout.setWidgetName(ShowValueUtils.replaceAll(titleLayout.getWidgetName(), findStr, replaceStr)); CRBoundsWidget crBoundsWidget = ((CRBoundsWidget) titleLayout.getWidget(0)); - crBoundsWidget.getWidget().setWidgetName(ShowValueUtils.replaceAll(crBoundsWidget.getWidget().getWidgetName(), findStr, replaceStr)); + String str = crBoundsWidget.getWidget().getWidgetName(); + ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr); + crBoundsWidget.getWidget().setWidgetName(ShowValueUtils.replaceAll(str, findStr, replaceStr)); } } }, @@ -144,7 +146,9 @@ public enum ComponentType implements DealWithInfoValue { info.updateOldStr(scaleLayout.getWidgetName(), findStr); scaleLayout.setWidgetName(ShowValueUtils.replaceAll(scaleLayout.getWidgetName(), findStr, replaceStr)); CRBoundsWidget crBoundsWidget = ((CRBoundsWidget) scaleLayout.getWidget(0)); - crBoundsWidget.getWidget().setWidgetName(ShowValueUtils.replaceAll(crBoundsWidget.getWidget().getWidgetName(), findStr, replaceStr)); + String str = crBoundsWidget.getWidget().getWidgetName(); + ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr); + crBoundsWidget.getWidget().setWidgetName(ShowValueUtils.replaceAll(str, findStr, replaceStr)); } } }, @@ -333,7 +337,9 @@ public enum ComponentType implements DealWithInfoValue { Object replaceObject = info.getContent().getReplaceObject(); if (replaceObject instanceof Widget) { Widget widget = ((Widget) replaceObject); + String str = widget.getWidgetName(); info.updateOldStr(widget.getWidgetName(), findStr); + ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr); widget.setWidgetName(widget.getWidgetName().replaceAll(findStr, replaceStr)); } } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaReplaceObject.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaReplaceObject.java index 02cd18810e..a58ae83d11 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaReplaceObject.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaReplaceObject.java @@ -58,12 +58,14 @@ public enum FormulaReplaceObject implements DealWithInfoValue { public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { Object replaceObject = info.getContent().getReplaceObject(); info.updateOldStr(((Formula) replaceObject).getContent(), findStr); - ((Formula) replaceObject).setContent(ShowValueUtils.replaceAll(((Formula) replaceObject).getContent(), findStr, replaceStr)); + String str = ((Formula) replaceObject).getContent(); + ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr); + ((Formula) replaceObject).setContent(ShowValueUtils.replaceAll(str, findStr, replaceStr)); } @Override public boolean check(Info info) { - if (info.getContent().getReplaceObject() instanceof Formula){ + if (info.getContent().getReplaceObject() instanceof Formula) { Formula formula = (Formula) info.getContent().getReplaceObject(); return StringUtils.equals(formula.getContent(), info.getContent().getOldShowStr()); } @@ -88,13 +90,14 @@ public enum FormulaReplaceObject implements DealWithInfoValue { Object replaceObject = info.getContent().getReplaceObject(); //更新上一次操作的信息 info.updateOldStr(((FormulaCondition) replaceObject).getFormula(), findStr); - - ((FormulaCondition) replaceObject).setFormula(ShowValueUtils.replaceAll(((FormulaCondition) replaceObject).getFormula(), findStr, replaceStr)); + String str = ((FormulaCondition) replaceObject).getFormula(); + ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr); + ((FormulaCondition) replaceObject).setFormula(ShowValueUtils.replaceAll(str, findStr, replaceStr)); } @Override public boolean check(Info info) { - if (info.getContent().getReplaceObject() instanceof FormulaCondition){ + if (info.getContent().getReplaceObject() instanceof FormulaCondition) { FormulaCondition condition = (FormulaCondition) info.getContent().getReplaceObject(); return StringUtils.equals(condition.getFormula(), info.getContent().getOldShowStr()); } @@ -120,14 +123,15 @@ public enum FormulaReplaceObject implements DealWithInfoValue { if (((Compare) replaceObject).getValue() instanceof Formula) { Formula formula = (Formula) ((Compare) replaceObject).getValue(); info.updateOldStr(formula.getContent(), findStr); - - formula.setContent(ShowValueUtils.replaceAll(formula.getContent(), findStr, replaceStr)); + String str = formula.getContent(); + ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr); + formula.setContent(ShowValueUtils.replaceAll(str, findStr, replaceStr)); } } @Override public boolean check(Info info) { - if (info.getContent().getReplaceObject() instanceof Compare){ + if (info.getContent().getReplaceObject() instanceof Compare) { Compare compare = (Compare) info.getContent().getReplaceObject(); return StringUtils.equals(GeneralUtils.objectToString(compare.getValue()), info.getContent().getOldShowStr()); } @@ -151,13 +155,14 @@ public enum FormulaReplaceObject implements DealWithInfoValue { public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { Object replaceObject = info.getContent().getReplaceObject(); info.updateOldStr(((Formula) ((com.fr.base.core.KV) replaceObject).getValue()).getContent(), findStr); - - ((Formula) ((com.fr.base.core.KV) replaceObject).getValue()).setContent(ShowValueUtils.replaceAll(((Formula) ((com.fr.base.core.KV) replaceObject).getValue()).getContent(), findStr, replaceStr)); + String str = ((Formula) ((com.fr.base.core.KV) replaceObject).getValue()).getContent(); + ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr); + ((Formula) ((com.fr.base.core.KV) replaceObject).getValue()).setContent(ShowValueUtils.replaceAll(str, findStr, replaceStr)); } @Override public boolean check(Info info) { - if (info.getContent().getReplaceObject() instanceof com.fr.base.core.KV){ + if (info.getContent().getReplaceObject() instanceof com.fr.base.core.KV) { com.fr.base.core.KV kv = (com.fr.base.core.KV) info.getContent().getReplaceObject(); return StringUtils.equals(GeneralUtils.objectToString(kv.getValue()), info.getContent().getOldShowStr()); } @@ -181,12 +186,14 @@ public enum FormulaReplaceObject implements DealWithInfoValue { public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { Object replaceObject = info.getContent().getReplaceObject(); info.updateOldStr(((Formula) (((CellInsertPolicyAttr) replaceObject).getDefaultInsertValue())).getContent(), findStr); - ((Formula) (((CellInsertPolicyAttr) replaceObject).getDefaultInsertValue())).setContent(ShowValueUtils.replaceAll(((Formula) (((CellInsertPolicyAttr) replaceObject).getDefaultInsertValue())).getContent(), findStr, replaceStr)); + String str = ((Formula) (((CellInsertPolicyAttr) replaceObject).getDefaultInsertValue())).getContent(); + ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr); + ((Formula) (((CellInsertPolicyAttr) replaceObject).getDefaultInsertValue())).setContent(ShowValueUtils.replaceAll(str, findStr, replaceStr)); } @Override public boolean check(Info info) { - if (info.getContent().getReplaceObject() instanceof CellInsertPolicyAttr){ + if (info.getContent().getReplaceObject() instanceof CellInsertPolicyAttr) { CellInsertPolicyAttr policyAttr = (CellInsertPolicyAttr) info.getContent().getReplaceObject(); return StringUtils.equals(GeneralUtils.objectToString(policyAttr.getDefaultInsertValue()), info.getContent().getOldShowStr()); } @@ -210,13 +217,14 @@ public enum FormulaReplaceObject implements DealWithInfoValue { public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { Object replaceObject = info.getContent().getReplaceObject(); info.updateOldStr(((FormulaPresent) replaceObject).getFormulaContent(), findStr); - - ((FormulaPresent) replaceObject).setFormulaContent(ShowValueUtils.replaceAll(((FormulaPresent) replaceObject).getFormulaContent(), findStr, replaceStr)); + String str = ((FormulaPresent) replaceObject).getFormulaContent(); + ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr); + ((FormulaPresent) replaceObject).setFormulaContent(ShowValueUtils.replaceAll(str, findStr, replaceStr)); } @Override public boolean check(Info info) { - if (info.getContent().getReplaceObject() instanceof FormulaPresent){ + if (info.getContent().getReplaceObject() instanceof FormulaPresent) { FormulaPresent present = (FormulaPresent) info.getContent().getReplaceObject(); return StringUtils.equals(present.getFormulaContent(), info.getContent().getOldShowStr()); } @@ -240,12 +248,14 @@ public enum FormulaReplaceObject implements DealWithInfoValue { public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { Object replaceObject = info.getContent().getReplaceObject(); info.updateOldStr(((SingleJavaScript) replaceObject).getFileName(), findStr); - ((SingleJavaScript) replaceObject).setFileName(ShowValueUtils.replaceAll(((SingleJavaScript) replaceObject).getFileName(), findStr, replaceStr)); + String str = ((SingleJavaScript) replaceObject).getFileName(); + ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr); + ((SingleJavaScript) replaceObject).setFileName(ShowValueUtils.replaceAll(str, findStr, replaceStr)); } @Override public boolean check(Info info) { - if (info.getContent().getReplaceObject() instanceof SingleJavaScript){ + if (info.getContent().getReplaceObject() instanceof SingleJavaScript) { SingleJavaScript javaScript = (SingleJavaScript) info.getContent().getReplaceObject(); return StringUtils.equals(javaScript.getFileName(), info.getContent().getOldShowStr()); } @@ -269,15 +279,16 @@ public enum FormulaReplaceObject implements DealWithInfoValue { public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { Object replaceObject = info.getContent().getReplaceObject(); info.updateOldStr(((Formula) (((ParameterProvider) replaceObject).getValue())).getContent(), findStr); - - ((Formula) (((ParameterProvider) replaceObject).getValue())).setContent(ShowValueUtils.replaceAll(((Formula) (((ParameterProvider) replaceObject).getValue())).getContent(), findStr, replaceStr)); + String str = ((Formula) (((ParameterProvider) replaceObject).getValue())).getContent(); + ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr); + ((Formula) (((ParameterProvider) replaceObject).getValue())).setContent(ShowValueUtils.replaceAll(str, findStr, replaceStr)); } @Override public boolean check(Info info) { - if (info.getContent().getReplaceObject() instanceof ParameterProvider){ + if (info.getContent().getReplaceObject() instanceof ParameterProvider) { ParameterProvider provider = (ParameterProvider) info.getContent().getReplaceObject(); - if (provider.getValue() instanceof Formula){ + if (provider.getValue() instanceof Formula) { return StringUtils.equals(GeneralUtils.objectToString(provider.getValue()), info.getContent().getOldShowStr()); } } @@ -301,13 +312,14 @@ public enum FormulaReplaceObject implements DealWithInfoValue { public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { Object replaceObject = info.getContent().getReplaceObject(); info.updateOldStr(((FormulaProvider) replaceObject).getContent(), findStr); - - ((FormulaProvider) replaceObject).setContent(ShowValueUtils.replaceAll(((FormulaProvider) replaceObject).getContent(), findStr, replaceStr)); + String str = ((FormulaProvider) replaceObject).getContent(); + ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr); + ((FormulaProvider) replaceObject).setContent(ShowValueUtils.replaceAll(str, findStr, replaceStr)); } @Override public boolean check(Info info) { - if (info.getContent().getReplaceObject() instanceof FormulaProvider){ + if (info.getContent().getReplaceObject() instanceof FormulaProvider) { FormulaProvider provider = (FormulaProvider) info.getContent().getReplaceObject(); return StringUtils.equals(provider.getContent(), info.getContent().getOldShowStr()); } @@ -331,15 +343,16 @@ public enum FormulaReplaceObject implements DealWithInfoValue { public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { Object replaceObject = info.getContent().getReplaceObject(); info.updateOldStr(((Formula) (((Parameter) replaceObject).getValue())).getContent(), findStr); - - ((Formula) (((Parameter) replaceObject).getValue())).setContent(ShowValueUtils.replaceAll(((Formula) (((Parameter) replaceObject).getValue())).getContent(), findStr, replaceStr)); + String str = ((Formula) (((Parameter) replaceObject).getValue())).getContent(); + ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr); + ((Formula) (((Parameter) replaceObject).getValue())).setContent(ShowValueUtils.replaceAll(str, findStr, replaceStr)); } @Override public boolean check(Info info) { - if (info.getContent().getReplaceObject() instanceof Parameter){ + if (info.getContent().getReplaceObject() instanceof Parameter) { Parameter parameter = (Parameter) info.getContent().getReplaceObject(); - if (parameter.getValue() instanceof Formula){ + if (parameter.getValue() instanceof Formula) { return StringUtils.equals(((Formula) parameter.getValue()).getContent(), info.getContent().getOldShowStr()); } } @@ -363,13 +376,14 @@ public enum FormulaReplaceObject implements DealWithInfoValue { public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { Object replaceObject = info.getContent().getReplaceObject(); info.updateOldStr(((DSColumn) replaceObject).getResult(), findStr); - - ((DSColumn) replaceObject).setResult(ShowValueUtils.replaceAll(((DSColumn) replaceObject).getResult(), findStr, replaceStr)); + String str = ((DSColumn) replaceObject).getResult(); + ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr); + ((DSColumn) replaceObject).setResult(ShowValueUtils.replaceAll(str, findStr, replaceStr)); } @Override public boolean check(Info info) { - if (info.getContent().getReplaceObject() instanceof DSColumn){ + if (info.getContent().getReplaceObject() instanceof DSColumn) { DSColumn column = (DSColumn) info.getContent().getReplaceObject(); return StringUtils.equals(column.getResult(), info.getContent().getOldShowStr()); } @@ -393,13 +407,14 @@ public enum FormulaReplaceObject implements DealWithInfoValue { public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { Object replaceObject = info.getContent().getReplaceObject(); info.updateOldStr(((BaseFormula) replaceObject).getContent(), findStr); - - ((BaseFormula) replaceObject).setContent(ShowValueUtils.replaceAll(((BaseFormula) replaceObject).getContent(), findStr, replaceStr)); + String str = ((BaseFormula) replaceObject).getContent(); + ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr); + ((BaseFormula) replaceObject).setContent(ShowValueUtils.replaceAll(str, findStr, replaceStr)); } @Override public boolean check(Info info) { - if (info.getContent().getReplaceObject() instanceof BaseFormula){ + if (info.getContent().getReplaceObject() instanceof BaseFormula) { BaseFormula formula = (BaseFormula) info.getContent().getReplaceObject(); return StringUtils.equals(formula.getContent(), info.getContent().getOldShowStr()); } @@ -423,16 +438,17 @@ public enum FormulaReplaceObject implements DealWithInfoValue { public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { Object replaceObject = info.getContent().getReplaceObject(); info.updateOldStr(((Formula) ((StoreProcedureParameter) replaceObject).getValue()).getContent(), findStr); - - ((Formula) ((StoreProcedureParameter) replaceObject).getValue()).setContent(ShowValueUtils.replaceAll(((Formula) ((StoreProcedureParameter) replaceObject).getValue()).getContent(), findStr, replaceStr)); + String str = ((Formula) ((StoreProcedureParameter) replaceObject).getValue()).getContent(); + ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr); + ((Formula) ((StoreProcedureParameter) replaceObject).getValue()).setContent(ShowValueUtils.replaceAll(str, findStr, replaceStr)); } @Override public boolean check(Info info) { - if (info.getContent().getReplaceObject() instanceof StoreProcedureParameter){ + if (info.getContent().getReplaceObject() instanceof StoreProcedureParameter) { StoreProcedureParameter procedureParameter = (StoreProcedureParameter) info.getContent().getReplaceObject(); - if (procedureParameter.getValue() instanceof Formula){ + if (procedureParameter.getValue() instanceof Formula) { return StringUtils.equals(GeneralUtils.objectToString(procedureParameter.getValue()), info.getContent().getOldShowStr()); } } @@ -457,13 +473,15 @@ public enum FormulaReplaceObject implements DealWithInfoValue { WorkBook workBook = (WorkBook) HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget(); WatermarkAttr watermarkAttr = (WatermarkAttr) info.getContent().getReplaceObject(); info.updateOldStr(watermarkAttr.getText(), findStr); - watermarkAttr.setText(ShowValueUtils.replaceAll(watermarkAttr.getText(), findStr, replaceStr)); + String str = watermarkAttr.getText(); + ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr); + watermarkAttr.setText(ShowValueUtils.replaceAll(str, findStr, replaceStr)); workBook.addAttrMark(watermarkAttr); } @Override public boolean check(Info info) { - if (info.getContent().getReplaceObject() instanceof WatermarkAttr){ + if (info.getContent().getReplaceObject() instanceof WatermarkAttr) { WatermarkAttr watermarkAttr = ((WatermarkAttr) info.getContent().getReplaceObject()); return StringUtils.equals(watermarkAttr.getText(), info.getContent().getOldShowStr()); } @@ -473,11 +491,11 @@ public enum FormulaReplaceObject implements DealWithInfoValue { /** * 存储字符串类型需要特殊处理 */ - STRING("String"){ + STRING("String") { @Override public Map getValue(Object... o) { HashMap map = new HashMap<>(); - if (StringUtils.isNotEmpty(GeneralUtils.objectToString(o[0]))){ + if (StringUtils.isNotEmpty(GeneralUtils.objectToString(o[0]))) { map.put("content", GeneralUtils.objectToString(o[0])); } return map; @@ -486,7 +504,7 @@ public enum FormulaReplaceObject implements DealWithInfoValue { @Override public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { FormulaTag formulaTag = FormulaTag.match(info.getContent().getTag()); - if (formulaTag != null){ + if (formulaTag != null) { info.updateOldStr(GeneralUtils.objectToString(info.getContent().getReplaceObject()), findStr); formulaTag.setValue(info, findStr, replaceStr, operatorArray); } @@ -500,7 +518,7 @@ public enum FormulaReplaceObject implements DealWithInfoValue { /** * 排序 */ - FORMULA_SORT_EXPRESSION("FormulaSortExpression"){ + FORMULA_SORT_EXPRESSION("FormulaSortExpression") { @Override public Map getValue(Object... o) { HashMap map = new HashMap<>(); @@ -514,19 +532,20 @@ public enum FormulaReplaceObject implements DealWithInfoValue { public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { Object replaceObject = info.getContent().getReplaceObject(); info.updateOldStr((((FormulaSortExpression) replaceObject).getFormula()), findStr); - ((FormulaSortExpression) replaceObject).setFormula(ShowValueUtils.replaceAll((((FormulaSortExpression) replaceObject).getFormula()), findStr, replaceStr)); + String str = (((FormulaSortExpression) replaceObject).getFormula()); + ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr); + ((FormulaSortExpression) replaceObject).setFormula(ShowValueUtils.replaceAll(str, findStr, replaceStr)); } @Override public boolean check(Info info) { - if (info.getContent().getReplaceObject() instanceof FormulaSortExpression){ + if (info.getContent().getReplaceObject() instanceof FormulaSortExpression) { FormulaSortExpression sortExpression = (FormulaSortExpression) info.getContent().getReplaceObject(); return StringUtils.equals(sortExpression.getFormula(), info.getContent().getOldShowStr()); } return false; } - } - ; + }; String name; @@ -554,6 +573,7 @@ public enum FormulaReplaceObject implements DealWithInfoValue { /** * 校验内容 + * * @param info * @return */ diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaTag.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaTag.java index c3f3c83a1d..be35a76671 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaTag.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaTag.java @@ -33,7 +33,9 @@ public enum FormulaTag implements DealWithInfoValue { public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { if (info.getContent().getHoldObject() instanceof VanMapReportDefinition) { VanMapReportDefinition definition = (VanMapReportDefinition) info.getContent().getHoldObject(); - definition.setLongitude(ShowValueUtils.replaceAll(GeneralUtils.objectToString(definition.getLongitude()), findStr, replaceStr)); + String str = GeneralUtils.objectToString(definition.getLongitude()); + ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr); + definition.setLongitude(ShowValueUtils.replaceAll(str, findStr, replaceStr)); } } }, @@ -45,7 +47,9 @@ public enum FormulaTag implements DealWithInfoValue { public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { if (info.getContent().getHoldObject() instanceof VanMapReportDefinition) { VanMapReportDefinition definition = (VanMapReportDefinition) info.getContent().getHoldObject(); - definition.setLatitude(ShowValueUtils.replaceAll(GeneralUtils.objectToString(definition.getLatitude()), findStr, replaceStr)); + String str = GeneralUtils.objectToString(definition.getLatitude()); + ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr); + definition.setLatitude(ShowValueUtils.replaceAll(str, findStr, replaceStr)); } } }, @@ -57,7 +61,9 @@ public enum FormulaTag implements DealWithInfoValue { public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { if (info.getContent().getHoldObject() instanceof VanMapReportDefinition) { VanMapReportDefinition definition = (VanMapReportDefinition) info.getContent().getHoldObject(); - definition.setCategoryName(ShowValueUtils.replaceAll(GeneralUtils.objectToString(definition.getCategoryName()), findStr, replaceStr)); + String str = GeneralUtils.objectToString(definition.getCategoryName()); + ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr); + definition.setCategoryName(ShowValueUtils.replaceAll(str, findStr, replaceStr)); } } }, @@ -69,7 +75,9 @@ public enum FormulaTag implements DealWithInfoValue { public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { if (info.getContent().getHoldObject() instanceof VanMapReportDefinition) { VanMapReportDefinition definition = (VanMapReportDefinition) info.getContent().getHoldObject(); - definition.setEndLongitude(ShowValueUtils.replaceAll(GeneralUtils.objectToString(definition.getEndLongitude()), findStr, replaceStr)); + String str = GeneralUtils.objectToString(definition.getEndLongitude()); + ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr); + definition.setEndLongitude(ShowValueUtils.replaceAll(str, findStr, replaceStr)); } } }, @@ -81,7 +89,9 @@ public enum FormulaTag implements DealWithInfoValue { public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { if (info.getContent().getHoldObject() instanceof VanMapReportDefinition) { VanMapReportDefinition definition = (VanMapReportDefinition) info.getContent().getHoldObject(); - definition.setEndLatitude(ShowValueUtils.replaceAll(GeneralUtils.objectToString(definition.getEndLatitude()), findStr, replaceStr)); + String str = GeneralUtils.objectToString(definition.getEndLatitude()); + ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr); + definition.setEndLatitude(ShowValueUtils.replaceAll(str, findStr, replaceStr)); } } }, @@ -93,7 +103,9 @@ public enum FormulaTag implements DealWithInfoValue { public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { if (info.getContent().getHoldObject() instanceof VanMapReportDefinition) { VanMapReportDefinition definition = (VanMapReportDefinition) info.getContent().getHoldObject(); - definition.setEndAreaName(ShowValueUtils.replaceAll(GeneralUtils.objectToString(definition.getEndAreaName()), findStr, replaceStr)); + String str = GeneralUtils.objectToString(definition.getEndAreaName()); + ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr); + definition.setEndAreaName(ShowValueUtils.replaceAll(str, findStr, replaceStr)); } } }, @@ -105,7 +117,9 @@ public enum FormulaTag implements DealWithInfoValue { public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { if (info.getContent().getHoldObject() instanceof VerifyItem) { VerifyItem item = (VerifyItem) info.getContent().getHoldObject(); - item.setMessage(ShowValueUtils.replaceAll(item.getMessage(), findStr, replaceStr)); + String str = item.getMessage(); + ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr); + item.setMessage(ShowValueUtils.replaceAll(str, findStr, replaceStr)); } } }, @@ -119,6 +133,7 @@ public enum FormulaTag implements DealWithInfoValue { WorkBook workBook = (WorkBook) info.getContent().getHoldObject(); int sheetId = Integer.parseInt(info.getContent().getSheetID()); String name = workBook.getReportName(sheetId); + ShowValueUtils.updateAfterReplaceStr(info, name, findStr, replaceStr); workBook.setReportName(sheetId, ShowValueUtils.replaceAll(name, findStr, replaceStr)); } } @@ -131,7 +146,9 @@ public enum FormulaTag implements DealWithInfoValue { public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { if (info.getContent().getHoldObject() instanceof CellGUIAttr) { CellGUIAttr attr = (CellGUIAttr) info.getContent().getHoldObject(); - attr.setTooltipText(ShowValueUtils.replaceAll(attr.getTooltipText(), findStr, replaceStr)); + String str = attr.getTooltipText(); + ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr); + attr.setTooltipText(ShowValueUtils.replaceAll(str, findStr, replaceStr)); } } }, @@ -140,7 +157,9 @@ public enum FormulaTag implements DealWithInfoValue { public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { if (info.getContent().getHoldObject() instanceof FormulaDictionary) { FormulaDictionary dictionary = (FormulaDictionary) info.getContent().getHoldObject(); - dictionary.setExcuteFormula(ShowValueUtils.replaceAll(dictionary.getExcuteFormula(), findStr, replaceStr)); + String str = dictionary.getExcuteFormula(); + ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr); + dictionary.setExcuteFormula(ShowValueUtils.replaceAll(str, findStr, replaceStr)); } } }, @@ -149,7 +168,9 @@ public enum FormulaTag implements DealWithInfoValue { public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { if (info.getContent().getHoldObject() instanceof FormulaDictionary) { FormulaDictionary dictionary = (FormulaDictionary) info.getContent().getHoldObject(); - dictionary.setProduceFormula(ShowValueUtils.replaceAll(dictionary.getProduceFormula(), findStr, replaceStr)); + String str = dictionary.getProduceFormula(); + ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr); + dictionary.setProduceFormula(ShowValueUtils.replaceAll(str, findStr, replaceStr)); } } }; diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/template/SearchTemplateFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/template/SearchTemplateFormulaAction.java index 0dd6919558..0dab4a7e4b 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/template/SearchTemplateFormulaAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/template/SearchTemplateFormulaAction.java @@ -149,8 +149,8 @@ public class SearchTemplateFormulaAction implements SearchTemplateFormula { @Override public void searchTemplateWaterMarkFormula(JTemplate jTemplate, List formulaInfos, ITContent content) { - WatermarkAttr watermarkAttr = ReportUtils.getWatermarkAttrFromTemplateAndGlobal((AttrMark) jTemplate.getTarget()); - if (watermarkAttr != null) { + WatermarkAttr watermarkAttr = ReportUtils.getWatermarkAttrFromTemplate((AttrMark) jTemplate.getTarget()); + if (watermarkAttr != null && watermarkAttr.isValid()) { ITContent waterMarkContent = ITContent.copy(content); waterMarkContent.addOtherPos(Toolkit.i18nText("Fine-Design_Form_WaterMark")); waterMarkContent.setReplaceObject(watermarkAttr); diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/JSCheckTag.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/JSCheckTag.java new file mode 100644 index 0000000000..71f5d82d6f --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/JSCheckTag.java @@ -0,0 +1,15 @@ +package com.fr.design.actions.replace.action.content.js; + +/** + * 检查JS的标签 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-10-26 + */ +public class JSCheckTag { + /** + * 单元格-超级链接 + */ + public static final int CELL_HYPERLINK = 0; +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/JSCheckType.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/JSCheckType.java new file mode 100644 index 0000000000..5d4ff03c7d --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/JSCheckType.java @@ -0,0 +1,65 @@ +package com.fr.design.actions.replace.action.content.js; + +import com.fr.design.actions.replace.info.Info; +import com.fr.js.NameJavaScript; +import com.fr.js.NameJavaScriptGroup; +import com.fr.report.cell.Elem; +import org.jetbrains.annotations.Nullable; + +/** + * 检查JS是否修改过 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-10-26 + */ +public enum JSCheckType { + /** + * 单元格-超级链接 + */ + CELL_HYPERLINK(JSCheckTag.CELL_HYPERLINK) { + @Override + public boolean check(Info info) { + Elem elem = (Elem) info.getContent().getHoldObject(); + NameJavaScriptGroup group = elem.getNameHyperlinkGroup(); + int len = group.size(); + if (len == 0) { + return false; + } + NameJavaScript javaScript = (NameJavaScript) info.getContent().getReplaceObject(); + for (int i = 0; i < len; i++) { + if (group.getNameHyperlink(i).equals(javaScript)) { + return true; + } + } + return false; + } + }; + + + int index; + + JSCheckType(int index) { + this.index = index; + } + + /** + * 匹配 + * + * @param index + * @return + */ + @Nullable + public static JSCheckType match(int index) { + JSCheckType[] values = JSCheckType.values(); + for (JSCheckType value : values) { + if (value.index == index) { + return value; + } + } + return null; + } + + public abstract boolean check(Info info); + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/widget/FrmWidgetType.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/widget/FrmWidgetType.java index 98d2282f5d..5aa8e208c5 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/widget/FrmWidgetType.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/widget/FrmWidgetType.java @@ -167,6 +167,7 @@ public enum FrmWidgetType implements SearchFrmWidget, DealWithInfoValue { if (((WidgetInfo) info).isWaterMark()) { WaterMark waterMark = (WaterMark) widget; info.updateOldStr(waterMark.getWaterMark(), findStr); + ShowValueUtils.updateAfterReplaceStr(info, waterMark.getWaterMark(), findStr, replaceStr); waterMark.setWaterMark(ShowValueUtils.replaceAll(waterMark.getWaterMark(), findStr, replaceStr)); } else { info.updateOldStr(widget.getWidgetName(), findStr); From 65963e7d2dea12aefe3e8ce8230db54c5decd9b9 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Thu, 27 Oct 2022 15:42:06 +0800 Subject: [PATCH 19/63] =?UTF-8?q?REPORT-80695=20=E3=80=90=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E5=85=A8=E5=B1=80=E7=BA=A7=E5=88=AB=E6=9F=A5=E6=89=BE?= =?UTF-8?q?=E6=9B=BF=E6=8D=A2=E4=BA=8C=E6=9C=9F=E3=80=91=E8=A1=A5=E5=85=85?= =?UTF-8?q?=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../actions/replace/action/content/js/JSCheckType.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/JSCheckType.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/JSCheckType.java index 5d4ff03c7d..b3357721ed 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/JSCheckType.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/JSCheckType.java @@ -60,6 +60,11 @@ public enum JSCheckType { return null; } + /** + * 校验是否修改 + * @param info 存储信息的数据结构 + * @return + */ public abstract boolean check(Info info); } From 0cd4b400538d1710a8d00c95a6ad30e8f608368d Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Thu, 27 Oct 2022 15:44:26 +0800 Subject: [PATCH 20/63] =?UTF-8?q?REPORT-80695=20=E3=80=90=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E5=85=A8=E5=B1=80=E7=BA=A7=E5=88=AB=E6=9F=A5=E6=89=BE?= =?UTF-8?q?=E6=9B=BF=E6=8D=A2=E4=BA=8C=E6=9C=9F=E3=80=91=E8=A1=A5=E5=85=85?= =?UTF-8?q?=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../action/setting/action/SearchCellFormatAction.java | 6 ++++++ .../action/setting/action/SearchConnectionAction.java | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchCellFormatAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchCellFormatAction.java index bd607c625b..016f6b259b 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchCellFormatAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchCellFormatAction.java @@ -39,6 +39,12 @@ public class SearchCellFormatAction implements SearchAction { setCellInfos(cellInfos); } + /** + * 单元格的内容是否是在查找范围内 + * + * @param cellElement 单元格 + * @return 在查找范围内返回true + */ public boolean isFormatValid(CellElement cellElement) { return cellElement.getStyle() != null && (cellElement.getValue() instanceof Formula diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchConnectionAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchConnectionAction.java index 199361fd7b..2f4a75ba48 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchConnectionAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchConnectionAction.java @@ -60,6 +60,12 @@ public class SearchConnectionAction implements SearchAction { setConnectionInfos(connectionInfos); } + /** + * 数据连接是否可用 + * + * @param data 数据库 + * @return 可用返回true + */ public boolean isNameDataBaseConnectionValid(TableData data) { return data instanceof TableDataConnection && ((TableDataConnection) data).getDatabase() instanceof NameDatabaseConnection; } From 4b2237b70ef10097bfa24e15c6cc3613a0357e12 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Thu, 27 Oct 2022 15:58:54 +0800 Subject: [PATCH 21/63] =?UTF-8?q?REPORT-80695=20=E3=80=90=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E5=85=A8=E5=B1=80=E7=BA=A7=E5=88=AB=E6=9F=A5=E6=89=BE?= =?UTF-8?q?=E6=9B=BF=E6=8D=A2=E4=BA=8C=E6=9C=9F=E3=80=91=E8=A1=A5=E5=85=85?= =?UTF-8?q?=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../replace/action/setting/CellFormatType.java | 2 ++ .../replace/action/setting/CellGroupType.java | 3 +-- .../replace/action/setting/SettingContent.java | 2 ++ .../actions/replace/ui/ITReplaceMainDialog.java | 8 ++++++++ .../actions/replace/ui/ITReplaceNorthPanel.java | 15 ++++++++++++--- .../actions/replace/ui/ITReplaceSouthPanel.java | 5 +++++ 6 files changed, 30 insertions(+), 5 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellFormatType.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellFormatType.java index 9f77d7d2b4..ab2a71ba97 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellFormatType.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellFormatType.java @@ -16,6 +16,8 @@ import java.util.Arrays; import java.util.List; /** + * 单元格-格式 + * * @author Destiny.Lin * @version 11.0 * created by Destiny.Lin on 2022-10-25 diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellGroupType.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellGroupType.java index 8e769b4715..a9b20b6627 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellGroupType.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellGroupType.java @@ -207,10 +207,9 @@ public enum CellGroupType { return new MinFunction(); case COUNT_FUNCTION: return new CountFunction(); - case NONE_FUNCTION: + default: return new NoneFunction(); } - return new NoneFunction(); } /** diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/SettingContent.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/SettingContent.java index 67211b77e9..a72ddd3a74 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/SettingContent.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/SettingContent.java @@ -4,6 +4,8 @@ import com.fr.design.actions.replace.utils.ShowValueUtils; import com.fr.design.i18n.Toolkit; /** + * 设置项的一些常用常量 + * * @author Destiny.Lin * @version 11.0 * created by Destiny.Lin on 2022-10-24 diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java index f80609e39d..8497dcff01 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java @@ -527,6 +527,10 @@ public class ITReplaceMainDialog extends UIDialog { public void checkValid() throws Exception { } + /** + * 获取模板内容数据 + * @return 存储数据的list + */ public static List getSearchContentResultList() { return searchContentResultList; } @@ -535,6 +539,10 @@ public class ITReplaceMainDialog extends UIDialog { this.searchContentResultList = searchContentResultList; } + /** + * 获取设置项数据 + * @return 存储数据的list + */ public static List getSearchSettingResultList() { return searchSettingResultList; } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java index 60300de2a9..cf358ad384 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java @@ -88,7 +88,7 @@ public class ITReplaceNorthPanel { private static final int FIRST_X = 20, SECOND_X = 80; private static final int LABEL_WIDTH = 60; private static final Icon CHANGE_ICON = IconUtils.readIcon("/com/fr/design/images/replace/change_normal.svg"); - private static final String[] rangeItems = new String[]{Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Current")}; + private static final String[] RANGE_ITEMS = new String[]{Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Current")}; public static final String CARD_CONTENT = "Content"; public static final String CARD_SETTING = "setting"; @@ -186,7 +186,7 @@ public class ITReplaceNorthPanel { resultLabel = new UILabel(); String[] replaceInputItems = new String[]{StringUtils.EMPTY}; findCombobox = new UIComboBox(findItems.toArray()); - rangeCombobox = new UIComboBox(rangeItems); + rangeCombobox = new UIComboBox(RANGE_ITEMS); findInputCombobox = new UIComboBox(findInputItems.toArray()) { @Override public void setEditor(ComboBoxEditor comboBoxEditor) { @@ -233,7 +233,7 @@ public class ITReplaceNorthPanel { rangeSettingLabel = new UILabel(Toolkit.i18nText("Fine-Design_Replace_Search_Range")); settingResultLabel = new UILabel(); findSettingComboBox = new UIComboBox(findSettingItems.toArray()); - rangeSettingComboBox = new UIComboBox(rangeItems); + rangeSettingComboBox = new UIComboBox(RANGE_ITEMS); findSettingInputComboBox = new UIComboBox(formatItems.toArray()) { @Override public void setEditor(ComboBoxEditor anEditor) { @@ -703,10 +703,19 @@ public class ITReplaceNorthPanel { this.searchButton = searchButton; } + /** + * 获取CardLayout + * @return CardLayout + */ public static CardLayout getCardLayout() { return cardLayout; } + /** + * 获取表格主界面 + * + * @return cardPanel + */ public static JPanel getCardPanel() { return cardPanel; } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java index 24c441b9a3..cd086d903c 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java @@ -47,6 +47,11 @@ public class ITReplaceSouthPanel { this.tableEditorPane = tableEditorPane; } + /** + * 获取表格的editor + * + * @return 表格的editor + */ public static ITTableEditor getItTableEditor() { return itTableEditor; } From 6b517c213ccc4f99e155cf65917aefd22c5d2fb5 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Thu, 27 Oct 2022 16:24:49 +0800 Subject: [PATCH 22/63] =?UTF-8?q?REPORT-80695=20=E3=80=90=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E5=85=A8=E5=B1=80=E7=BA=A7=E5=88=AB=E6=9F=A5=E6=89=BE?= =?UTF-8?q?=E6=9B=BF=E6=8D=A2=E4=BA=8C=E6=9C=9F=E3=80=91=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E9=A1=B9=E7=9A=84=E6=BB=9A=E8=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java index cf358ad384..16d2926a60 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java @@ -163,7 +163,7 @@ public class ITReplaceNorthPanel { cardPanel.add(contentScrollPane, CARD_CONTENT); - cardPanel.add(upSettingPanel, CARD_SETTING); + cardPanel.add(settingScrollPane, CARD_SETTING); } /** @@ -267,7 +267,7 @@ public class ITReplaceNorthPanel { replaceSettingButton = new UIButton(Toolkit.i18nText("Fine-Design_Replace_Button")); replaceSettingButton.setEnabled(false); - + upSettingPanel.setPreferredSize(new Dimension(limit_width, HEIGHT)); upSettingPanel.add(findSettingLabel); upSettingPanel.add(rangeSettingLabel); upSettingPanel.add(findSettingComboBox); From 518e74dfaf5a6f1aae9a7593640b9b61a2355e0f Mon Sep 17 00:00:00 2001 From: "Link.Zhao" Date: Thu, 27 Oct 2022 18:29:30 +0800 Subject: [PATCH 23/63] =?UTF-8?q?REPORT-80750=20=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E4=B8=AD=E7=9A=84=E4=B8=B4=E6=97=B6=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E7=9B=AE=E5=BD=95=E6=A2=B3=E7=90=86=E5=92=8C=E6=95=B4?= =?UTF-8?q?=E6=94=B9=201=E3=80=81=E5=B0=86=E4=B8=8D=E5=BF=85=E8=A6=81?= =?UTF-8?q?=E5=85=B1=E4=BA=AB=E7=9A=84=E8=B5=84=E6=BA=90=E4=BB=8Eassets?= =?UTF-8?q?=E8=BF=81=E7=A7=BB=E5=88=B0=E5=85=B6=E4=BB=96=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=202=E3=80=81=E5=B0=86=E8=BF=87=E6=97=B6=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E4=BB=8Eassets=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/gui/style/TranslucentBorderSpecialPane.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/style/TranslucentBorderSpecialPane.java b/designer-base/src/main/java/com/fr/design/gui/style/TranslucentBorderSpecialPane.java index 20e47f556c..e3ef66bfeb 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/TranslucentBorderSpecialPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/TranslucentBorderSpecialPane.java @@ -191,7 +191,7 @@ public class TranslucentBorderSpecialPane extends AbstractBorderPackerPane imple String lastUsedBorderImageDirPath = history.getLastSelectedBorderImageDir(); File lastUsedBorderImageDir = StringUtils.isNotEmpty(lastUsedBorderImageDirPath) ? new File(lastUsedBorderImageDirPath) : null; - File inbuiltBorderImagesDir = new File(StableUtils.pathJoin(ProjectLibrary.getInstance().getLibHome(), ProjectConstants.ASSETS_NAME, "border_images")); + File inbuiltBorderImagesDir = new File(StableUtils.pathJoin(ProjectLibrary.getInstance().getLibHome(), ProjectConstants.NOT_SHARE, ProjectConstants.BORDER_IMAGES)); if (lastUsedBorderImageDir!= null && lastUsedBorderImageDir.exists()) { imageFileChooser.setCurrentDirectory(lastUsedBorderImageDir); From ae78045a4b20a337c9b67cedf785c3292c9ea103 Mon Sep 17 00:00:00 2001 From: "Coral.Chen" Date: Thu, 27 Oct 2022 19:23:22 +0800 Subject: [PATCH 24/63] =?UTF-8?q?REPORT-82546&REPORT-82706=20=E6=8B=96?= =?UTF-8?q?=E5=8A=A8=E6=A8=A1=E6=9D=BF=E8=BF=9B=E5=85=A5=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E5=AD=98=E5=9C=A8=E5=A4=A7=E9=87=8F=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E3=80=90xxx=20is=20a=20different=20type=20path=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/mainframe/JTemplate.java | 3 ++- .../src/main/java/com/fr/nx/app/designer/JStreamBook.java | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index 844b8d0144..b59df2cf08 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -111,6 +111,7 @@ import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.FontMetrics; import java.io.ByteArrayOutputStream; +import java.nio.file.Paths; import java.util.Set; import java.util.concurrent.Callable; @@ -1620,7 +1621,7 @@ public abstract class JTemplate> return StringUtils.EMPTY; } String path = this.getEditingFILE().getPath(); - CptxMetadata metadata = CptxFileUtils.getMetadata(path); + CptxMetadata metadata = Paths.get(path).isAbsolute() ? null : CptxFileUtils.getMetadata(path); //是否是兼容模式,兼容模式下,设置了新引擎的cpt和cptx的后缀不同 if (metadata != null && metadata.isForceCpt()) { if (path.endsWith(".cptx")) { diff --git a/designer-realize/src/main/java/com/fr/nx/app/designer/JStreamBook.java b/designer-realize/src/main/java/com/fr/nx/app/designer/JStreamBook.java index 15f64a044e..94a057337d 100644 --- a/designer-realize/src/main/java/com/fr/nx/app/designer/JStreamBook.java +++ b/designer-realize/src/main/java/com/fr/nx/app/designer/JStreamBook.java @@ -14,11 +14,11 @@ import com.fr.general.ComparatorUtils; import com.fr.locale.InterProviderFactory; import com.fr.log.FineLoggerFactory; import com.fr.main.impl.WorkBook; -import com.fr.nx.cptx.entry.metadata.CptxMetadata; import com.fr.nx.app.designer.menu.CalculateAttrAction; import com.fr.nx.app.designer.toolbar.TemplateTransformer; import com.fr.nx.app.designer.toolbar.TransformResult; import com.fr.nx.app.designer.toolbar.TransformResultInfo; +import com.fr.nx.cptx.entry.metadata.CptxMetadata; import com.fr.nx.cptx.utils.CptxFileUtils; import com.fr.stable.StringUtils; import com.fr.stable.project.ProjectConstants; @@ -27,6 +27,7 @@ import com.fr.third.jodd.util.ArraysUtil; import java.io.File; import java.io.FileOutputStream; import java.io.OutputStream; +import java.nio.file.Paths; public class JStreamBook extends JWorkBook { @@ -103,7 +104,8 @@ public class JStreamBook extends JWorkBook { } private String getSuffix() { - CptxMetadata metadata = CptxFileUtils.getMetadata(this.getEditingFILE().getPath()); + String path = this.getEditingFILE().getPath(); + CptxMetadata metadata = Paths.get(path).isAbsolute() ? null : CptxFileUtils.getMetadata(path); if (metadata != null && metadata.isForceCpt()) { return InterProviderFactory.getProvider().getLocText("Fine-Plugin_Engine_Compatibility_Mode"); } From 5082c190bdff7d75bc1c63dc6689b6b46a5da9ec Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Thu, 27 Oct 2022 19:34:24 +0800 Subject: [PATCH 25/63] =?UTF-8?q?REPORT-80695=20=E3=80=90=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E5=85=A8=E5=B1=80=E7=BA=A7=E5=88=AB=E6=9F=A5=E6=89=BE?= =?UTF-8?q?=E6=9B=BF=E6=8D=A2=E4=BA=8C=E6=9C=9F=E3=80=91=E5=8E=BB=E9=99=A4?= =?UTF-8?q?=E5=A4=9A=E4=BD=99=E5=BC=95=E5=85=A5=EF=BC=8C=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../actions/replace/action/ShowValue.java | 21 ++++++++++--------- .../design/actions/replace/info/JSInfo.java | 1 - 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/ShowValue.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/ShowValue.java index 34211f1f8a..b1b73122a6 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/ShowValue.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/ShowValue.java @@ -18,19 +18,19 @@ public interface ShowValue { /** * 获取搜索结果 * - * @param jTemplate - * @return + * @param jTemplate 要搜索的模板 + * @return 所有对应类型的集合 */ default List showSearchValue(JTemplate jTemplate) { return new ArrayList<>(); } /** - * 对搜索结果进行过滤 + * 对搜索结果进行过滤(主要针对模板内容,只需要用户输入要搜索的文本内容即可) * - * @param str - * @param list - * @return + * @param str 用户输入的内容 + * @param list 包含所有内容的列表 + * @return 过滤后的内容 */ default List addMatchResult(String str, List list) { return new ArrayList<>(); @@ -38,11 +38,12 @@ public interface ShowValue { /** * 对搜索结果进行过滤(多个过滤条件,主要针对设置项) + * 通过用户输入的级别去界定指定的搜索类型 * - * @param list - * @param settingStr - * @param extraStr - * @return + * @param list 包含所有内容的列表 + * @param settingStr 用户输入的第一级下拉框内容 + * @param extraStr 用户输入的第二级下拉框内容 + * @return 界定后符合条件的内容组合成的列表 */ default List addMatchResult(List list, String settingStr, String extraStr) { return new ArrayList<>(); diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/JSInfo.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/JSInfo.java index 3718381f12..3f0632fe84 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/info/JSInfo.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/JSInfo.java @@ -1,7 +1,6 @@ package com.fr.design.actions.replace.info; -import com.fr.design.actions.replace.action.content.js.JSCheckType; import com.fr.design.actions.replace.info.base.ITContent; import com.fr.stable.AssistUtils; From 4ce4e31ba721f0192077441fcc96931656123a7f Mon Sep 17 00:00:00 2001 From: "Leo.Qin" Date: Fri, 28 Oct 2022 09:30:42 +0800 Subject: [PATCH 26/63] =?UTF-8?q?REPORT-80690=20=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E5=8D=95=E5=85=83=E6=A0=BC=20=E3=80=90?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E5=8E=9F=E5=9B=A0=E3=80=91=20=E3=80=90?= =?UTF-8?q?=E6=94=B9=E5=8A=A8=E6=80=9D=E8=B7=AF=E3=80=91=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=93=8D=E4=BD=9C=E5=8D=95=E5=85=83=E6=A0=BC?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=20=E3=80=90review=E5=BB=BA=E8=AE=AE=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/EastRegionContainerPane.java | 7 +- .../cell/AbstractCellElementAction.java | 49 ++-- .../design/dscolumn/DSColumnAdvancedPane.java | 80 ------ .../dscolumn/ResultSetGroupDockingPane.java | 11 + .../design/dscolumn/ResultSetGroupPane.java | 25 +- .../com/fr/grid/selection/CellSelection.java | 70 +++++- .../com/fr/quickeditor/CellQuickEditor.java | 234 +++++++++++++++--- .../cellquick/CellDSColumnEditor.java | 198 ++++++++++++--- .../cellquick/CellFormulaQuickEditor.java | 50 ---- .../cellquick/CellStringQuickEditor.java | 52 ---- 10 files changed, 480 insertions(+), 296 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java index d640f84f44..d32a54ca4f 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java @@ -354,12 +354,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer { public void updateCellElementState(boolean isSelectedOneCell) { PropertyItem cellElement = propertyItemMap.get(KEY_CELL_ELEMENT); - if (isSelectedOneCell) { - enableCellElementPane(cellElement); - } else { // 如果选中多个单元格,禁用单元格元素 tab - disableCellElementPane(cellElement); - refreshRightPane(); - } + enableCellElementPane(cellElement); } // 禁用单元格元素tab diff --git a/designer-realize/src/main/java/com/fr/design/actions/cell/AbstractCellElementAction.java b/designer-realize/src/main/java/com/fr/design/actions/cell/AbstractCellElementAction.java index e4108e6d2f..0b2e702de3 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/cell/AbstractCellElementAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/cell/AbstractCellElementAction.java @@ -14,6 +14,8 @@ import com.fr.report.core.SheetUtils; import com.fr.report.elementcase.TemplateElementCase; import com.fr.report.stable.ReportConstants; +import java.awt.Rectangle; + /** * TODO ALEX_SEP 这个类与AbstractCellAction有什么关系? * @@ -45,28 +47,31 @@ public abstract class AbstractCellElementAction extends CellSelectionAction { dialog.addDialogActionListener(new DialogActionAdapter() { @Override public void doOk() { - // 需要先行后列地增加新元素。 - for (int j = 0; j < finalCS.getRowSpan(); j++) { - for (int i = 0; i < finalCS.getColumnSpan(); i++) { - int column = i + finalCS.getColumn(); - int row = j + finalCS.getRow(); - TemplateCellElement editCellElement = tplEC.getTemplateCellElement(column, row); - if (editCellElement == null) { - editCellElement = DefaultThemedTemplateCellElementCase.createInstance(column, row); - tplEC.addCellElement(editCellElement); - } - // alex:不加这一句话会导致跨行跨列的格子被多次update - if (editCellElement.getColumn() != column || editCellElement.getRow() != row) { - continue; - } - updateBasicPane(bp, editCellElement); - // update cell attributes - if (isNeedShinkToFit()) { - // shink to fit.(如果value是String) - Object editElementValue = editCellElement.getValue(); - if (editElementValue != null && (editElementValue instanceof String || editElementValue instanceof Number)) { - // TODO ALEX_SEP 暂时用FIT_DEFAULT替代,不取reportsetting里面的设置,因为也不知道是应该放在report里面还是elementcase里面 - GridUtils.shrinkToFit(ReportConstants.AUTO_SHRINK_TO_FIT_DEFAULT, tplEC, editCellElement); + for (int rect = 0; rect < finalCS.getCellRectangleCount(); rect++) { + Rectangle cellRectangle = finalCS.getCellRectangle(rect); + // 需要先行后列地增加新元素。 + for (int j = 0; j < cellRectangle.height; j++) { + for (int i = 0; i < cellRectangle.width; i++) { + int column = i + cellRectangle.x; + int row = j + cellRectangle.y; + TemplateCellElement editCellElement = tplEC.getTemplateCellElement(column, row); + if (editCellElement == null) { + editCellElement = DefaultThemedTemplateCellElementCase.createInstance(column, row); + tplEC.addCellElement(editCellElement); + } + // alex:不加这一句话会导致跨行跨列的格子被多次update + if (editCellElement.getColumn() != column || editCellElement.getRow() != row) { + continue; + } + updateBasicPane(bp, editCellElement); + // update cell attributes + if (isNeedShinkToFit()) { + // shink to fit.(如果value是String) + Object editElementValue = editCellElement.getValue(); + if (editElementValue != null && (editElementValue instanceof String || editElementValue instanceof Number)) { + // TODO ALEX_SEP 暂时用FIT_DEFAULT替代,不取reportsetting里面的设置,因为也不知道是应该放在report里面还是elementcase里面 + GridUtils.shrinkToFit(ReportConstants.AUTO_SHRINK_TO_FIT_DEFAULT, tplEC, editCellElement); + } } } } diff --git a/designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java b/designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java index 91c8fa292c..e1b8a676ad 100644 --- a/designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java +++ b/designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java @@ -8,7 +8,6 @@ import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.formula.CustomVariableResolver; import com.fr.design.formula.FormulaFactory; import com.fr.design.formula.UIFormula; -import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icombobox.UIComboBox; @@ -16,7 +15,6 @@ import com.fr.design.gui.icontainer.UIScrollPane; 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.gui.style.TextFormatPane; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; @@ -52,7 +50,6 @@ public class DSColumnAdvancedPane extends BasicPane { private SortPane sortPane; private SelectCountPane selectCountPane; private ValuePane valuePane; - private FormatAttrPane formatAttrPane; private UICheckBox horizontalExtendableCheckBox; private UICheckBox verticalExtendableCheckBox; private UICheckBox useMultiplyNumCheckBox; @@ -89,10 +86,6 @@ public class DSColumnAdvancedPane extends BasicPane { valuePane = new ValuePane(); valuePane.setBorder(UITitledBorder.createBorderWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Bind_Column_Custom_Data_Appearance"))); - formatAttrPane = new FormatAttrPane(); - JPanel titleBorderedFormatPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_Format")); - titleBorderedFormatPane.add(formatAttrPane, BorderLayout.NORTH); - JPanel extendablePane = null; if (setting > DSColumnPane.SETTING_DSRELATED) { // extendableDirectionPane @@ -130,7 +123,6 @@ public class DSColumnAdvancedPane extends BasicPane { {sortPane}, {selectCountPane}, {valuePane}, - {titleBorderedFormatPane}, {extendablePane}, {multiNumPane} }; @@ -138,7 +130,6 @@ public class DSColumnAdvancedPane extends BasicPane { components = new Component[][]{ {sortPane}, {valuePane}, - {titleBorderedFormatPane} }; } @@ -161,7 +152,6 @@ public class DSColumnAdvancedPane extends BasicPane { sortPane.populateBean(cellElement); valuePane.populate(cellElement); - formatAttrPane.populate(cellElement); if (selectCountPane != null) { selectCountPane.populate(cellElement); @@ -211,7 +201,6 @@ public class DSColumnAdvancedPane extends BasicPane { sortPane.updateBean(cellElement); valuePane.update(cellElement); - formatAttrPane.update(cellElement); if (selectCountPane != null) { selectCountPane.update(cellElement); @@ -518,75 +507,6 @@ public class DSColumnAdvancedPane extends BasicPane { } } - - public static class ReLayoutTextFormatPane extends TextFormatPane { - - protected void initLayout() { - JComponent[][] components = new JComponent[][] { {typeComboBox, textField, roundingBox} }; - double[] rowSize = new double[] { TableLayout.FILL }; - double[] columnSize = {TableLayout.PREFERRED, 200, TableLayout.PREFERRED}; - - JPanel settingPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 4, 0); - - addComponents(4, new JComponent[]{settingPane, previewLabel}); - } - - @Override - protected void setRoundingBoxVisible(boolean visible) { - roundingBox.setVisible(visible); - } - - public void populate(CellElement cellElement) { - if (cellElement != null) { - populateBean(cellElement.getStyle()); - } - } - - public void update(CellElement cellElement) { - if (cellElement != null) { - cellElement.setStyle(update(cellElement.getStyle())); - } - } - } - - public static class FormatAttrPane extends AbstractAttrNoScrollPane { - private TextFormatPane formatPane; - - @Override - protected JPanel createContentPane() { - this.formatPane = new ReLayoutTextFormatPane(); - return this.formatPane; - } - - @Override - public Dimension getPreferredSize() { - if (formatPane == null) { - return super.getPreferredSize(); - } - return formatPane.getPreferredSize(); - } - - protected void initContentPane() { - leftContentPane = createContentPane(); - if (leftContentPane != null) { - leftContentPane.setBorder(BorderFactory.createEmptyBorder()); - this.add(leftContentPane, BorderLayout.CENTER); - } - } - - public void populate(CellElement cellElement) { - if (cellElement != null && formatPane != null) { - formatPane.populateBean(cellElement.getStyle()); - } - } - - public void update(CellElement cellElement) { - if (cellElement != null && formatPane != null) { - cellElement.setStyle(formatPane.update(cellElement.getStyle())); - } - } - } - private void checkButtonEnabled() { if (useMultiplyNumCheckBox.isSelected()) { multiNumSpinner.setEnabled(true); diff --git a/designer-realize/src/main/java/com/fr/design/dscolumn/ResultSetGroupDockingPane.java b/designer-realize/src/main/java/com/fr/design/dscolumn/ResultSetGroupDockingPane.java index b1784cb24b..a485fab05d 100644 --- a/designer-realize/src/main/java/com/fr/design/dscolumn/ResultSetGroupDockingPane.java +++ b/designer-realize/src/main/java/com/fr/design/dscolumn/ResultSetGroupDockingPane.java @@ -26,6 +26,7 @@ import java.awt.Component; import java.awt.Dimension; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.util.Set; /** * 这个pane是选中数据列后,在上方QuickRegion处显示的pane @@ -167,6 +168,11 @@ public class ResultSetGroupDockingPane extends ResultSetGroupPane { @Override public void update() { + updateCellElement(cellElement); + } + + + private void updateCellElement(TemplateCellElement cellElement) { if (isNPE(cellElement)) { return; } @@ -242,4 +248,9 @@ public class ResultSetGroupDockingPane extends ResultSetGroupPane { groupComboBox.removeItemListener(this.listener); functionComboBox.removeItemListener(this.listener); } + + @Override + public void update(Set cellElements) { + cellElements.forEach(this::updateCellElement); + } } \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/design/dscolumn/ResultSetGroupPane.java b/designer-realize/src/main/java/com/fr/design/dscolumn/ResultSetGroupPane.java index 2097dfcfc3..2fb7b98496 100644 --- a/designer-realize/src/main/java/com/fr/design/dscolumn/ResultSetGroupPane.java +++ b/designer-realize/src/main/java/com/fr/design/dscolumn/ResultSetGroupPane.java @@ -1,17 +1,10 @@ package com.fr.design.dscolumn; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JPanel; -import javax.swing.SwingUtilities; - import com.fr.design.data.DesignTableDataManager; +import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; -import com.fr.design.dialog.DialogActionAdapter; - import com.fr.report.cell.CellElement; import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.cellattr.core.group.CustomGrouper; @@ -19,6 +12,12 @@ import com.fr.report.cell.cellattr.core.group.DSColumn; import com.fr.report.cell.cellattr.core.group.FunctionGrouper; import com.fr.report.cell.cellattr.core.group.RecordGrouper; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Set; + //august:1:31 我又改回以前的样子了 neil那个方法还是有bug 9922 public abstract class ResultSetGroupPane extends JPanel { @@ -38,7 +37,15 @@ public abstract class ResultSetGroupPane extends JPanel { abstract void update(); - abstract void setRecordGrouper(RecordGrouper recordGrouper); + /** + * 批量更新数据设置 + * + * @param cellElements 需要更新的单元格 + */ + public void update(Set cellElements) { + } + + abstract void setRecordGrouper(RecordGrouper recordGrouper); void fireTargetChanged() { }; diff --git a/designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java b/designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java index 7a23a1396a..4d3568cd86 100644 --- a/designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java +++ b/designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java @@ -34,6 +34,7 @@ import com.fr.design.report.RowColumnPane; import com.fr.design.selection.QuickEditor; import com.fr.grid.GridUtils; import com.fr.report.cell.CellElement; +import com.fr.report.cell.DefaultTemplateCellElement; import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.cellattr.CellGUIAttr; import com.fr.report.elementcase.TemplateElementCase; @@ -46,8 +47,10 @@ import javax.swing.JOptionPane; import javax.swing.SwingUtilities; import java.awt.Rectangle; import java.util.ArrayList; +import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Set; /** * the cell selection (column,row)是所选单元格中左上角的位置 , 这个数据结构就是一个Rectangle @@ -739,16 +742,77 @@ public class CellSelection extends Selection { TemplateElementCase tplEC = ePane.getEditingElementCase(); TemplateCellElement cellElement = tplEC.getTemplateCellElement(column, row); Object value = null; - boolean b = ePane.isSelectedOneCell(); - if (cellElement != null && b) { + if (cellElement != null) { value = cellElement.getValue(); } - value = value == null ? StringUtils.EMPTY : value; + Set allCellElement = getAllCellElements(tplEC); + + boolean sameType = checkSameType(allCellElement); + + // 多选时,多元格元素类型 + value = sameType && value != null ? value : StringUtils.EMPTY; //之前是少了个bigInteger,刚kunsnat又发现少了个bigDecimal,数字类型的都用stringEditor,没必要那个样子 QuickEditor editor = ActionFactory.getCellEditor((value instanceof Number) ? (Number.class) : (value.getClass())); return editor; } + /** + * 选中的单元格插入元素类型是否相同 + * + * @param cellElements 单元格 + * @return true: 相同 + */ + public boolean checkSameType(Set cellElements) { + Class lastType = null; + for (TemplateCellElement cellElement : cellElements) { + + Object value = cellElement.getValue(); + if (value == null) { + value = StringUtils.EMPTY; + } + + Class type = value.getClass(); + if (lastType != null && lastType != type) { + return false; + } + lastType = type; + } + return true; + } + + /** + * 获取当前选中的所有单元格,若选中未编辑状态的单元格,暂时不添加为编辑状态 + * + * @param elementCase + * @return 获取当前选中的所有单元格 + */ + public Set getAllCellElements(TemplateElementCase elementCase) { + + Set cellElements = new HashSet<>(); + // 遍历选择的rect + for (int rect = 0; rect < getCellRectangleCount(); rect++) { + Rectangle cellRectangle = getCellRectangle(rect); + // 遍历rect中每个ce + for (int j = 0; j < cellRectangle.height; j++) { + for (int i = 0; i < cellRectangle.width; i++) { + int column = i + cellRectangle.x; + int row = j + cellRectangle.y; + + TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row); + + if (cellElement == null) { + cellElement = new DefaultTemplateCellElement(column, row); + } + + cellElements.add(cellElement); + + } + } + } + + return cellElements; + } + @Override public void populatePropertyPane(ElementCasePane ePane) { CellElementPropertyPane.getInstance().reInit(ePane); diff --git a/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java b/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java index 6c177d1334..dde927a168 100644 --- a/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java +++ b/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java @@ -1,13 +1,17 @@ package com.fr.quickeditor; import com.fr.base.GraphHelper; +import com.fr.base.Style; import com.fr.design.actions.UpdateAction; import com.fr.design.actions.core.ActionFactory; import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; +import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.iscrollbar.UIScrollBar; import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.gui.style.TextFormatPane; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; @@ -23,6 +27,7 @@ import com.fr.design.widget.FRWidgetFactory; import com.fr.grid.selection.CellSelection; import com.fr.quickeditor.cellquick.layout.CellElementBarLayout; import com.fr.report.cell.TemplateCellElement; +import com.fr.report.elementcase.TemplateElementCase; import com.fr.stable.ColumnRow; import javax.swing.BorderFactory; @@ -31,6 +36,7 @@ import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollBar; import java.awt.BorderLayout; +import java.awt.CardLayout; import java.awt.Component; import java.awt.Container; import java.awt.Dimension; @@ -41,6 +47,8 @@ import java.awt.event.AdjustmentListener; import java.awt.event.MouseWheelEvent; import java.awt.event.MouseWheelListener; import java.util.ArrayList; +import java.util.Objects; +import java.util.Set; /** * @author zhou, yaoh.wu @@ -59,6 +67,13 @@ public abstract class CellQuickEditor extends QuickEditor { private static final int CONTENT_PANE_WIDTH_GAP = 3; private static final int MOUSE_WHEEL_SPEED = 5; private static final int SCROLLBAR_WIDTH = 7; + + /** + * 区分单选多选单元格,生成相应设置面板 + */ + private final String SINGLE_SELECT = "singleSelect"; + private final String MULTIPLE_SELECT = "multipleSelect"; + private int maxHeight = 280; private static final int TITLE_HEIGHT = 50; @@ -67,11 +82,22 @@ public abstract class CellQuickEditor extends QuickEditor { */ protected UITextField columnRowTextField; protected TemplateCellElement cellElement; + protected TextFormatPane formatPane; + private final JPanel topContentContainer; + private final JComponent centerBodyContainer; + + private CardLayout topCardLayout; + /** + * 不同单元格元素产生的面板 + */ + private CardLayout centerCardLayout; // 占位label protected final UILabel EMPTY_LABEL = new UILabel(); - private UIComboBox comboBox; + private UIComboBox singleComboBox; + private UIComboBox multipleComboBox; + private UpdateAction[] cellInsertActions; private int selectedIndex; private int currentSelectedIndex; @@ -84,16 +110,19 @@ public abstract class CellQuickEditor extends QuickEditor { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; double[] columnSize = {p, f}; - JComponent centerBody = createCenterBody(); - JPanel topContent = initTopContent(); + JPanel formatContainerPanel = createFormatPane(); + topContentContainer = initTopContent(); + centerBodyContainer = createAllCenterBody(); if (isScrollAll()) { - double[] scrollAllRowSize = {p, p}; + double[] scrollAllRowSize = {p, p, p}; prepareScrollBar(); - topContent.setBorder(BorderFactory.createMatteBorder(10, 10, 0, 0, this.getBackground())); - centerBody.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 0, this.getBackground())); + topContentContainer.setBorder(BorderFactory.createMatteBorder(10, 10, 0, 0, this.getBackground())); + formatContainerPanel.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 0, this.getBackground())); + centerBodyContainer.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 0, this.getBackground())); Component[][] components = new Component[][]{ - new Component[]{topContent, null}, - new Component[]{centerBody, null} + new Component[]{topContentContainer, null}, + new Component[]{formatContainerPanel, null}, + new Component[]{centerBodyContainer, null} }; leftContentPane = TableLayoutHelper.createGapTableLayoutPane(components, scrollAllRowSize, columnSize, HGAP, VGAP); this.setLayout(new CellElementBarLayout(leftContentPane) { @@ -122,12 +151,14 @@ public abstract class CellQuickEditor extends QuickEditor { this.add(scrollBar); this.add(leftContentPane); } else { - double[] scrollContentRowSize = {p, f}; - topContent.setBorder(BorderFactory.createMatteBorder(10, 10, 0, 10, this.getBackground())); - centerBody.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 0, this.getBackground())); + double[] scrollContentRowSize = {p, p, f}; + topContentContainer.setBorder(BorderFactory.createMatteBorder(10, 10, 0, 10, this.getBackground())); + formatContainerPanel.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 10, this.getBackground())); + centerBodyContainer.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 0, this.getBackground())); Component[][] components = new Component[][]{ - new Component[]{topContent, null}, - new Component[]{centerBody, null} + new Component[]{topContentContainer, null}, + new Component[]{formatContainerPanel, null}, + new Component[]{centerBodyContainer, null} }; this.setLayout(new BorderLayout()); this.add(TableLayoutHelper.createGapTableLayoutPane(components, scrollContentRowSize, columnSize, HGAP, VGAP), BorderLayout.CENTER); @@ -156,48 +187,99 @@ public abstract class CellQuickEditor extends QuickEditor { */ public abstract Object getComboBoxSelected(); + /** + * 初始化创建单选及多选面板 + * + * @return 创建的面板 + */ + private JComponent createAllCenterBody() { + centerCardLayout = new CardLayout(); + + JPanel centerPanel = new JPanel(centerCardLayout); + + centerPanel.add(SINGLE_SELECT, createCenterBody()); + centerPanel.add(MULTIPLE_SELECT, createCenterBody4Multiple()); + + return centerPanel; + } + + /** + * 为多选单元格创建详细面板,默认创建空面板 + * + * @return 空面板 + */ + public JComponent createCenterBody4Multiple() { + return new JPanel(); + } + + /** * 刷新 */ @Override protected void refresh() { + + refreshPanel(); + + refreshFormatPanel(); + + refreshDetails(); + } + + private void refreshFormatPanel() { + if (cellElement != null) { + formatPane.populateBean(cellElement.getStyle()); + } else { + formatPane.populateBean(Style.DEFAULT_STYLE); + } + } + + private void refreshPanel() { + CellSelection cs = (CellSelection) tc.getSelection(); ColumnRow columnRow = ColumnRow.valueOf(cs.getColumn(), cs.getRow()); + String selectType = tc.isSelectedOneCell() ? SINGLE_SELECT : MULTIPLE_SELECT; + + topCardLayout.show(topContentContainer, selectType); + centerCardLayout.show(centerBodyContainer, selectType); + columnRowTextField.setText(columnRow.toString()); cellElement = tc.getEditingElementCase().getTemplateCellElement(cs.getColumn(), cs.getRow()); JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); if (jTemplate != null) { - comboBox.removeActionListener(comboBoxActionListener); - comboBox.removeAllItems(); + singleComboBox.removeActionListener(comboBoxActionListener); + singleComboBox.removeAllItems(); String[] items = getDefaultComboBoxItems(); for (String item : items) { - comboBox.addItem(item); + singleComboBox.addItem(item); + multipleComboBox.addItem(item); } Object comboBoxSelected = getComboBoxSelected(); if (comboBoxSelected != null) { - comboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName()); + singleComboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName()); + multipleComboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName()); } else { - comboBox.setSelectedIndex(1); + singleComboBox.setSelectedIndex(1); + multipleComboBox.setSelectedIndex(1); } - currentSelectedIndex = comboBox.getSelectedIndex(); + currentSelectedIndex = singleComboBox.getSelectedIndex(); comboBoxActionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { cellInsertActions = ActionFactory.createCellInsertAction(ElementCasePane.class, tc); - selectedIndex = comboBox.getSelectedIndex(); - comboBox.setPopupVisible(false); - comboBox.repaint(); + selectedIndex = singleComboBox.getSelectedIndex(); + singleComboBox.setPopupVisible(false); + singleComboBox.repaint(); // comboBox.getSelectedIndex()可能返回-1 if (selectedIndex != -1 && selectedIndex < cellInsertActions.length) { cellInsertActions[selectedIndex].actionPerformed(e); } - comboBox.setSelectedIndex(currentSelectedIndex); + singleComboBox.setSelectedIndex(currentSelectedIndex); } }; - comboBox.addActionListener(comboBoxActionListener); + singleComboBox.addActionListener(comboBoxActionListener); } - refreshDetails(); } /** @@ -207,6 +289,10 @@ public abstract class CellQuickEditor extends QuickEditor { private JPanel initTopContent() { + topCardLayout = new CardLayout(); + JPanel topContentPane = new JPanel(topCardLayout); + + // 单选面板 double p = TableLayout.PREFERRED; double f = TableLayout.FILL; double[] columnSize = {GraphHelper.getWidth(Toolkit.i18nText("Fine-Design_Report_Insert_Cell_Element")), f}; @@ -216,9 +302,31 @@ public abstract class CellQuickEditor extends QuickEditor { initCellElementEditComboBox(); Component[][] components = new Component[][]{ new Component[]{cellLabel, columnRowTextField = initColumnRowTextField()}, - new Component[]{insertContentLabel, UIComponentUtils.wrapWithBorderLayoutPane(comboBox)}, + new Component[]{insertContentLabel, UIComponentUtils.wrapWithBorderLayoutPane(singleComboBox)}, + }; + JPanel singlePanel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP); + topContentPane.add(SINGLE_SELECT, singlePanel); + + + // 多选面板 + UILabel multipleTipLabel = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Basic_Cell_Element_Multiple_Tip")); + multipleTipLabel.setEnabled(false); + multipleTipLabel.setBorder(BorderFactory.createMatteBorder(5, 0, 0, 0, this.getBackground())); + UILabel insertContentLabel1 = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Report_Insert_Cell_Element")); + Component[][] components1 = new Component[][]{ + new Component[]{insertContentLabel1, UIComponentUtils.wrapWithBorderLayoutPane(multipleComboBox)}, }; - return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP); + multipleComboBox.setEnabled(false); + JPanel insertPanel = TableLayoutHelper.createGapTableLayoutPane(components1, new double[]{p}, columnSize, HGAP, + VGAP); + Component[][] components2 = new Component[][]{ + new Component[]{multipleTipLabel}, + new Component[]{insertPanel}, + }; + JPanel multiplePanel = TableLayoutHelper.createGapTableLayoutPane(components2, rowSize, new double[]{f}, HGAP, VGAP); + topContentPane.add(MULTIPLE_SELECT, multiplePanel); + + return topContentPane; } private void prepareScrollBar() { @@ -266,19 +374,23 @@ public abstract class CellQuickEditor extends QuickEditor { private void initCellElementEditComboBox() { JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); if (jTemplate == null) { - comboBox = new UIComboBox(); + singleComboBox = new UIComboBox(); + multipleComboBox = new UIComboBox(); return; } final String[] items = getDefaultComboBoxItems(); - comboBox = new UIComboBox(items); + singleComboBox = new UIComboBox(items); + multipleComboBox = new UIComboBox(items); final Object comboBoxSelected = getComboBoxSelected(); if (comboBoxSelected != null) { - comboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName()); + singleComboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName()); + multipleComboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName()); } else { - comboBox.setSelectedIndex(1); + singleComboBox.setSelectedIndex(1); + multipleComboBox.setSelectedIndex(1); } - currentSelectedIndex = comboBox.getSelectedIndex(); - comboBox.addActionListener(comboBoxActionListener); + currentSelectedIndex = singleComboBox.getSelectedIndex(); + singleComboBox.addActionListener(comboBoxActionListener); } private String[] getDefaultComboBoxItems() { @@ -324,4 +436,60 @@ public abstract class CellQuickEditor extends QuickEditor { }); return columnRowTextField; } + + private JPanel createFormatPane() { + formatPane = new TextFormatPane(); + AbstractAttrNoScrollPane container = new AbstractAttrNoScrollPane() { + @Override + protected JPanel createContentPane() { + return formatPane; + } + + protected void initContentPane() { + leftContentPane = createContentPane(); + if (leftContentPane != null) { + leftContentPane.setBorder(BorderFactory.createEmptyBorder()); + this.add(leftContentPane, BorderLayout.CENTER); + } + } + + @Override + public Dimension getPreferredSize() { + if (formatPane == null) { + return super.getPreferredSize(); + } + return formatPane.getPreferredSize(); + } + }; + + container.addAttributeChangeListener(new AttributeChangeListener() { + @Override + public void attributeChange() { + + isEditing = true; + boolean updateStyle = false; + + CellSelection cs = (CellSelection) tc.getSelection(); + TemplateElementCase editingElementCase = tc.getEditingElementCase(); + Set allCellElements = cs.getAllCellElements(editingElementCase); + for (TemplateCellElement cellElement : allCellElements) { + Style elementStyle = cellElement.getStyle(); + Style style = formatPane.update(elementStyle); + if (!Objects.equals(style.getFormat(), elementStyle.getFormat())) { + // 点击单元格,但未设置格式时,不将单元格设置为编辑状态,防止将所选的每个单元格都设置为编辑状态 + editingElementCase.addCellElement(cellElement); + cellElement.setStyle(style); + updateStyle = true; + } + } + + if (updateStyle) { + // 防止频繁触发保存 + fireTargetModified(); + } + isEditing = false; + } + }); + return container; + } } diff --git a/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java b/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java index 1c50499f77..0b7b011f04 100644 --- a/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java +++ b/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java @@ -15,10 +15,8 @@ import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.formula.CustomVariableResolver; import com.fr.design.formula.FormulaFactory; import com.fr.design.formula.UIFormula; -import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ibutton.UIHeadGroup; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icombobox.UIComboBox; @@ -26,7 +24,6 @@ import com.fr.design.gui.ilable.MultilineLabel; 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.gui.style.TextFormatPane; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; @@ -36,6 +33,7 @@ import com.fr.design.sort.celldscolumn.CellDSColumnSortPane; import com.fr.design.utils.gui.UIComponentUtils; import com.fr.design.widget.FRWidgetFactory; import com.fr.general.IOUtils; +import com.fr.grid.selection.CellSelection; import com.fr.quickeditor.CellQuickEditor; import com.fr.report.cell.CellElement; import com.fr.report.cell.TemplateCellElement; @@ -46,12 +44,9 @@ import com.fr.report.cell.cellattr.core.group.SelectCount; import com.fr.stable.StringUtils; import javax.swing.BorderFactory; -import javax.swing.Icon; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.SwingUtilities; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Color; @@ -63,6 +58,8 @@ import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; import static com.fr.report.cell.cellattr.core.group.FilterTypeEnum.BOTTOM; import static com.fr.report.cell.cellattr.core.group.FilterTypeEnum.EVEN; @@ -110,6 +107,10 @@ public class CellDSColumnEditor extends CellQuickEditor { * 数据列高级设置 */ private DSColumnAdvancedEditorPane cellDSColumnAdvancedPane; + /** + * 多选面板设置 + */ + private DSColumnMultipleEditorPane cellDSColumnMultiplePane; public CellDSColumnEditor() { super(); @@ -144,6 +145,7 @@ public class CellDSColumnEditor extends CellQuickEditor { protected void refreshDetails() { cellDSColumnBasicPane.populate(); cellDSColumnAdvancedPane.populate(); + cellDSColumnMultiplePane.populate(); this.validate(); } @@ -188,6 +190,8 @@ public class CellDSColumnEditor extends CellQuickEditor { super.release(); cellDSColumnBasicPane.release(); cellDSColumnAdvancedPane.release(); + cellDSColumnMultiplePane.release(); + } /** @@ -352,10 +356,6 @@ public class CellDSColumnEditor extends CellQuickEditor { * 自定义值显示 */ private CustomValuePane valuePane; - /** - * 文本格式 - */ - private FormatAttrPane formatAttrPane; /** * 横向可扩展性 */ @@ -402,7 +402,6 @@ public class CellDSColumnEditor extends CellQuickEditor { public void update() { if (cellElement != null) { valuePane.update(cellElement); - formatAttrPane.update(cellElement); filterPane.update(cellElement); //更新单元格扩展属性 updateExtendConfig(); @@ -417,7 +416,6 @@ public class CellDSColumnEditor extends CellQuickEditor { if (cellElement != null) { this.removeAttributeChangeListener(); valuePane.populate(cellElement); - formatAttrPane.populate(cellElement); filterPane.populate(cellElement); CellExpandAttr cellExpandAttr = cellElement.getCellExpandAttr(); if (cellExpandAttr == null) { @@ -529,9 +527,6 @@ public class CellDSColumnEditor extends CellQuickEditor { //自定义值显示 valuePane = new CustomValuePane(); - // 文本格式 - formatAttrPane = new FormatAttrPane(); - //可扩展性 JPanel extendableDirectionPane = FRGUIPaneFactory.createYBoxEmptyBorderPane(); extendableDirectionPane.add(heCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_ExpandD_Horizontal_Extendable"))); @@ -559,7 +554,6 @@ public class CellDSColumnEditor extends CellQuickEditor { Component[][] components = new Component[][]{ {filterPane}, {valuePane}, - {formatAttrPane}, {extendableDirectionPane}, {multiNumPane} }; @@ -1030,45 +1024,167 @@ public class CellDSColumnEditor extends CellQuickEditor { } } - public class FormatAttrPane extends AbstractAttrNoScrollPane { - private TextFormatPane formatPane; + } + - @Override - protected JPanel createContentPane() { - this.formatPane = new TextFormatPane(); - return this.formatPane; + class DSColumnMultipleEditorPane extends AbstractDSCellEditorPane { + + /** + * 数据分组设置 + */ + private ResultSetGroupDockingPane groupPane; + /** + * 条件过滤按钮面板 + */ + private JPanel conditionPane; + + /** + * 条件过滤按钮触发动作 + */ + private DSColumnConditionAction condition; + + /** + * 条件过滤按钮 + */ + private UIButton conditionUIButton; + + + @Override + public String getIconPath() { + return Toolkit.i18nText("Fine-Design_Report_Basic"); + } + + @Override + public String title4PopupWindow() { + return Toolkit.i18nText("FR-Designer_Basic"); + } + + + @Override + public void update() { + groupPane.update(); + } + + @Override + public void populate() { + this.removeAttributeChangeListener(); + if (tc != null) { + CellSelection selection = (CellSelection) tc.getSelection(); + Set cellElements = selection.getAllCellElements(tc.getEditingElementCase()); + conditionPane.setVisible(checkSameDSName(cellElements)); + condition.setEditingComponent(tc); + cellElements.forEach(cellElement -> groupPane.populate(cellElement)); } + this.addAttributeChangeListener(); + } - @Override - public Dimension getPreferredSize() { - if (formatPane == null) { - return super.getPreferredSize(); + /** + * 判断是否属于同一个数据集 + * + * @param cellElements + * @return + */ + private boolean checkSameDSName(Set cellElements) { + String lastDSName = StringUtils.EMPTY; + for (TemplateCellElement cellElement : cellElements) { + DSColumn dsColumn = (DSColumn) cellElement.getValue(); + String dsName = dsColumn.getDSName(); + if (StringUtils.isNotEmpty(lastDSName) && !StringUtils.equals(dsName, lastDSName)) { + return false; } - return formatPane.getPreferredSize(); + lastDSName = dsName; } + return true; + } - protected void initContentPane() { - leftContentPane = createContentPane(); - if (leftContentPane != null) { - leftContentPane.setBorder(BorderFactory.createEmptyBorder()); - this.add(leftContentPane, BorderLayout.CENTER); - } + @Override + protected void release() { + condition.setEditingComponent(null); + } + + + /** + * 创建有内容的面板显示信息 + * + * @return content JPanel + */ + @Override + protected JPanel createContentPane() { + initComponents(); + double[] columnSize = {F}; + double[] rowSize = {P, P}; + Component[][] components = new Component[][]{ + //数据分组设置 + new Component[]{this.groupPane}, + //条件过滤 + new Component[]{this.conditionPane} + }; + return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP); + } + + private void initComponents() { + groupPane = new ResultSetGroupDockingPane(); + initListener(); + double[] rowSize = {P}, columnSize = {60, F}; + UILabel uiLabel = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Report_Filter_Conditions")); + condition = new DSColumnConditionAction(); + if (tc != null) { + condition.setEditingComponent(tc); } + //丢掉icon,修改按钮名称为编辑 + condition.setSmallIcon(UIConstants.EMPTY_ICON); + condition.setName(Toolkit.i18nText("Fine-Design_Basic_Edit")); + conditionUIButton = new UIButton(condition); + Component[][] components = new Component[][]{ + new Component[]{uiLabel, UIComponentUtils.wrapWithBorderLayoutPane(conditionUIButton)} + }; + conditionPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP); + this.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); + } - public void populate(CellElement cellElement) { - if (cellElement != null && formatPane != null) { - formatPane.populateBean(cellElement.getStyle()); + + private void initListener() { + groupPane.setListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + Set cellElements = new HashSet<>(); + if (tc != null) { + CellSelection selection = (CellSelection) tc.getSelection(); + cellElements = selection.getAllCellElements(tc.getEditingElementCase()); + } + + if (e == null) { + //分组-高级-自定义点确定的时候传进来null的e,但是这时候应该触发保存 + groupPane.update(cellElements); + fireTargetModified(); + return; + } + if (e.getStateChange() == ItemEvent.DESELECTED) { + groupPane.update(cellElements); + fireTargetModified(); + } } - } + }); + } - public void update(CellElement cellElement) { - if (cellElement != null && formatPane != null) { - cellElement.setStyle(formatPane.update(cellElement.getStyle())); + @Override + protected AttributeChangeListener getAttributeChangeListener() { + return new AttributeChangeListener() { + @Override + public void attributeChange() { + update(); + fireTargetModified(); } - } + }; } } + @Override + public JComponent createCenterBody4Multiple() { + cellDSColumnMultiplePane = new DSColumnMultipleEditorPane(); + return cellDSColumnMultiplePane; + } + @Override public Object getComboBoxSelected() { return ActionFactory.createAction(DSColumnCellAction.class); diff --git a/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellFormulaQuickEditor.java b/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellFormulaQuickEditor.java index 30a5f0f558..297b0feb9e 100644 --- a/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellFormulaQuickEditor.java +++ b/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellFormulaQuickEditor.java @@ -8,17 +8,13 @@ import com.fr.design.actions.insert.cell.FormulaCellAction; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.formula.FormulaFactory; import com.fr.design.formula.UIFormula; -import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; -import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.itextfield.UITextField; -import com.fr.design.gui.style.TextFormatPane; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase; import com.fr.general.IOUtils; - import com.fr.grid.selection.CellSelection; import com.fr.quickeditor.CellQuickEditor; import com.fr.report.ReportHelper; @@ -50,7 +46,6 @@ import java.util.Arrays; public class CellFormulaQuickEditor extends CellQuickEditor { //文本域 private UITextField formulaTextField; - private TextFormatPane formatPane; //编辑状态 private boolean isEditing = false; @@ -144,57 +139,16 @@ public class CellFormulaQuickEditor extends CellQuickEditor { Component[][] componentLines = new Component[][] { new Component[]{EMPTY_LABEL, content}, - new Component[]{createFormatPane(), null}, }; double[] rowSize = new double[componentLines.length]; Arrays.fill(rowSize, TableLayout.PREFERRED); double[] columnSize = new double[] {TableLayout.PREFERRED, TableLayout.FILL }; return TableLayoutHelper.createGapTableLayoutPane(new Component[][]{ new Component[]{EMPTY_LABEL, content}, - new Component[]{createFormatPane(), null}, }, rowSize, columnSize, HGAP, VGAP); } - private JPanel createFormatPane() { - formatPane = new TextFormatPane(); - AbstractAttrNoScrollPane container = new AbstractAttrNoScrollPane() { - @Override - protected JPanel createContentPane() { - return formatPane; - } - - protected void initContentPane() { - leftContentPane = createContentPane(); - if (leftContentPane != null) { - leftContentPane.setBorder(BorderFactory.createEmptyBorder()); - this.add(leftContentPane, BorderLayout.CENTER); - } - } - }; - - container.addAttributeChangeListener(new AttributeChangeListener() { - @Override - public void attributeChange() { - isEditing = true; - - CellSelection cs1 = (CellSelection) tc.getSelection(); - cellElement = tc.getEditingElementCase().getTemplateCellElement(cs1.getColumn(), cs1.getRow()); - - if (cellElement == null) { - CellSelection cs = (CellSelection) tc.getSelection(); - cellElement = DefaultThemedTemplateCellElementCase.createInstance(cs.getColumn(), cs.getRow()); - tc.getEditingElementCase().addCellElement(cellElement, false); - } - - cellElement.setStyle(formatPane.update(cellElement.getStyle())); - - fireTargetModified(); - isEditing = false; - } - }); - return container; - } @Override public Object getComboBoxSelected() { @@ -257,10 +211,6 @@ public class CellFormulaQuickEditor extends CellQuickEditor { showText(str); formulaTextField.setEditable(tc.isSelectedOneCell()); - if (cellElement != null) { - Style style = cellElement.getStyle(); - formatPane.populateBean(style); - } } /** diff --git a/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellStringQuickEditor.java b/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellStringQuickEditor.java index 1b2c9ae4db..126486d13e 100644 --- a/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellStringQuickEditor.java +++ b/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellStringQuickEditor.java @@ -4,10 +4,7 @@ import com.fr.base.BaseFormula; import com.fr.base.Style; import com.fr.base.TextFormat; import com.fr.design.designer.IntervalConstants; -import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; -import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.gui.itextarea.UITextArea; -import com.fr.design.gui.style.TextFormatPane; import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase; import com.fr.grid.GridKeyListener; import com.fr.grid.selection.CellSelection; @@ -16,7 +13,6 @@ import com.fr.report.ReportHelper; import com.fr.stable.ColumnRow; import com.fr.stable.StringUtils; -import javax.swing.BorderFactory; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.event.DocumentEvent; @@ -31,7 +27,6 @@ import java.awt.event.KeyEvent; public class CellStringQuickEditor extends CellQuickEditor { //文本域 直接可以自适应大小 private UITextArea stringTextArea; - private TextFormatPane formatPane; //编辑状态 private boolean isEditing = false; @@ -95,51 +90,9 @@ public class CellStringQuickEditor extends CellQuickEditor { }); content.add(stringTextArea, BorderLayout.NORTH); - content.add(createFormatPane(), BorderLayout.CENTER); - return content; } - private JPanel createFormatPane() { - formatPane = new TextFormatPane(); - AbstractAttrNoScrollPane container = new AbstractAttrNoScrollPane() { - @Override - protected JPanel createContentPane() { - return formatPane; - } - - protected void initContentPane() { - leftContentPane = createContentPane(); - if (leftContentPane != null) { - leftContentPane.setBorder(BorderFactory.createEmptyBorder()); - this.add(leftContentPane, BorderLayout.CENTER); - } - } - }; - - container.addAttributeChangeListener(new AttributeChangeListener() { - @Override - public void attributeChange() { - isEditing = true; - - CellSelection cs1 = (CellSelection) tc.getSelection(); - cellElement = tc.getEditingElementCase().getTemplateCellElement(cs1.getColumn(), cs1.getRow()); - - if (cellElement == null) { - CellSelection cs = (CellSelection) tc.getSelection(); - cellElement = DefaultThemedTemplateCellElementCase.createInstance(cs.getColumn(), cs.getRow()); - tc.getEditingElementCase().addCellElement(cellElement, false); - } - - cellElement.setStyle(formatPane.update(cellElement.getStyle())); - - fireTargetModified(); - isEditing = false; - } - }); - return container; - } - @Override public boolean isScrollAll() { return true; @@ -200,11 +153,6 @@ public class CellStringQuickEditor extends CellQuickEditor { } showText(str); stringTextArea.setEditable(tc.isSelectedOneCell()); - - if (cellElement != null) { - Style style = cellElement.getStyle(); - formatPane.populateBean(style); - } } /** From c0151166701f3d4c711350f60b75776c6b6bbc9f Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Fri, 28 Oct 2022 10:12:31 +0800 Subject: [PATCH 27/63] =?UTF-8?q?REPORT-80695=20=E3=80=90=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E5=85=A8=E5=B1=80=E7=BA=A7=E5=88=AB=E6=9F=A5=E6=89=BE?= =?UTF-8?q?=E6=9B=BF=E6=8D=A2=E4=BA=8C=E6=9C=9F=E3=80=91=E6=9B=B4=E6=94=B9?= =?UTF-8?q?=E9=83=A8=E5=88=86=E9=9D=99=E6=80=81=EF=BC=8C=E5=88=A0=E5=87=8F?= =?UTF-8?q?=E5=A4=9A=E4=BD=99=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../action/setting/SettingController.java | 6 ++-- .../action/SearchConnectionAction.java | 12 ++++---- .../setting/action/SearchDSColumnAction.java | 12 ++++---- .../actions/replace/info/DSColumnInfo.java | 28 ------------------- ...onnectionInfo.java => DataSourceInfo.java} | 8 +++--- .../replace/ui/ITReplaceMainDialog.java | 20 +++++++++---- .../replace/ui/ITReplaceSouthPanel.java | 11 ++++++-- 7 files changed, 41 insertions(+), 56 deletions(-) delete mode 100644 designer-realize/src/main/java/com/fr/design/actions/replace/info/DSColumnInfo.java rename designer-realize/src/main/java/com/fr/design/actions/replace/info/{ConnectionInfo.java => DataSourceInfo.java} (60%) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/SettingController.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/SettingController.java index fa7fcc0b09..8dd29b2364 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/SettingController.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/SettingController.java @@ -8,7 +8,7 @@ import com.fr.design.actions.replace.action.setting.action.SearchCellFormatActio import com.fr.design.actions.replace.action.setting.action.SearchConnectionAction; import com.fr.design.actions.replace.action.setting.action.SearchDSColumnAction; import com.fr.design.actions.replace.info.CellInfo; -import com.fr.design.actions.replace.info.ConnectionInfo; +import com.fr.design.actions.replace.info.DataSourceInfo; import com.fr.design.actions.replace.info.Info; import com.fr.design.actions.replace.ui.ITReplaceNorthPanel; import com.fr.design.data.DesignTableDataManager; @@ -224,10 +224,10 @@ public enum SettingController implements ShowValue { @Override public List addMatchResult(List list, String settingStr, String extraStr) { - List connectionInfos = new ArrayList<>(); + List connectionInfos = new ArrayList<>(); for (Info info : list) { if (StringUtils.equals(info.getContent().getShowStr(), settingStr)) { - connectionInfos.add((ConnectionInfo) info); + connectionInfos.add((DataSourceInfo) info); } } return connectionInfos; diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchConnectionAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchConnectionAction.java index 2f4a75ba48..bd69a52365 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchConnectionAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchConnectionAction.java @@ -6,7 +6,7 @@ import com.fr.data.TableDataSource; import com.fr.data.impl.Connection; import com.fr.data.impl.NameDatabaseConnection; import com.fr.design.actions.replace.action.SearchAction; -import com.fr.design.actions.replace.info.ConnectionInfo; +import com.fr.design.actions.replace.info.DataSourceInfo; import com.fr.design.actions.replace.info.base.ITContent; import com.fr.design.mainframe.JTemplate; import com.fr.file.ConnectionConfig; @@ -25,7 +25,7 @@ import java.util.Map; * created by Destiny.Lin on 2022-10-26 */ public class SearchConnectionAction implements SearchAction { - private List connectionInfos = new ArrayList<>(); + private List connectionInfos = new ArrayList<>(); private SearchConnectionAction() { @@ -34,7 +34,7 @@ public class SearchConnectionAction implements SearchAction { @Override public void search4Infos(JTemplate jTemplate) { - List connectionInfos = new ArrayList<>(); + List connectionInfos = new ArrayList<>(); Map map = ConnectionConfig.getInstance().getConnections(); Map needMap = new HashMap<>(); TableDataSource source = (TableDataSource) jTemplate.getTarget(); @@ -55,7 +55,7 @@ public class SearchConnectionAction implements SearchAction { content.setTemplateName(jTemplate.getTemplateName()); content.setJumpAble(false); content.setShowStr(name); - connectionInfos.add(new ConnectionInfo(content)); + connectionInfos.add(new DataSourceInfo(content)); } setConnectionInfos(connectionInfos); } @@ -70,11 +70,11 @@ public class SearchConnectionAction implements SearchAction { return data instanceof TableDataConnection && ((TableDataConnection) data).getDatabase() instanceof NameDatabaseConnection; } - public List getConnectionInfos() { + public List getConnectionInfos() { return connectionInfos; } - public void setConnectionInfos(List connectionInfos) { + public void setConnectionInfos(List connectionInfos) { this.connectionInfos = connectionInfos; } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchDSColumnAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchDSColumnAction.java index 1cba80902b..9493cbfa7d 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchDSColumnAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchDSColumnAction.java @@ -3,7 +3,7 @@ package com.fr.design.actions.replace.action.setting.action; import com.fr.base.TableData; import com.fr.data.TableDataSource; import com.fr.design.actions.replace.action.SearchAction; -import com.fr.design.actions.replace.info.DSColumnInfo; +import com.fr.design.actions.replace.info.DataSourceInfo; import com.fr.design.actions.replace.info.base.ITContent; import com.fr.design.mainframe.JTemplate; @@ -19,7 +19,7 @@ import java.util.List; * created by Destiny.Lin on 2022-10-26 */ public class SearchDSColumnAction implements SearchAction { - private List dsColumnInfos = new ArrayList<>(); + private List dsColumnInfos = new ArrayList<>(); private SearchDSColumnAction() { @@ -27,7 +27,7 @@ public class SearchDSColumnAction implements SearchAction { @Override public void search4Infos(JTemplate jTemplate) { - List dsColumnInfos = new ArrayList<>(); + List dsColumnInfos = new ArrayList<>(); TableDataSource source = (TableDataSource) jTemplate.getTarget(); Iterator dataIterator = source.getTableDataNameIterator(); while (dataIterator.hasNext()) { @@ -38,16 +38,16 @@ public class SearchDSColumnAction implements SearchAction { content.setReplaceObject(data); content.setShowStr(dataName); content.setTemplateName(jTemplate.getTemplateName()); - dsColumnInfos.add(new DSColumnInfo(content)); + dsColumnInfos.add(new DataSourceInfo(content)); setDsColumnInfos(dsColumnInfos); } } - public List getDsColumnInfos() { + public List getDsColumnInfos() { return dsColumnInfos; } - public void setDsColumnInfos(List dsColumnInfos) { + public void setDsColumnInfos(List dsColumnInfos) { this.dsColumnInfos = dsColumnInfos; } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/DSColumnInfo.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/DSColumnInfo.java deleted file mode 100644 index f51a75fe5c..0000000000 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/info/DSColumnInfo.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.fr.design.actions.replace.info; - -import com.fr.design.actions.replace.info.base.ITContent; - -/** - * 存储数据列 - * - * @author Destiny.Lin - * @version 11.0 - * created by Destiny.Lin on 2022-10-26 - */ -public class DSColumnInfo implements Info { - private ITContent content; - - - public DSColumnInfo(ITContent content) { - this.content = content; - } - - @Override - public ITContent getContent() { - return content; - } - - public void setContent(ITContent content) { - this.content = content; - } -} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/ConnectionInfo.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/DataSourceInfo.java similarity index 60% rename from designer-realize/src/main/java/com/fr/design/actions/replace/info/ConnectionInfo.java rename to designer-realize/src/main/java/com/fr/design/actions/replace/info/DataSourceInfo.java index b88c8c6e07..f1c4cbd12c 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/info/ConnectionInfo.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/DataSourceInfo.java @@ -3,17 +3,17 @@ package com.fr.design.actions.replace.info; import com.fr.design.actions.replace.info.base.ITContent; /** - * 存储数据连接 + * 存储数据源相关的信息,后续数据源部分如果有自己额外的信息把这个当成父类进行拓展即可 * * @author Destiny.Lin * @version 11.0 - * created by Destiny.Lin on 2022-10-26 + * created by Destiny.Lin on 2022-10-28 */ -public class ConnectionInfo implements Info { +public class DataSourceInfo implements Info{ private ITContent content; - public ConnectionInfo(ITContent content) { + public DataSourceInfo(ITContent content) { this.content = content; } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java index 8497dcff01..e207ca5004 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java @@ -214,7 +214,7 @@ public class ITReplaceMainDialog extends UIDialog { Toolkit.i18nText("Fine-Design_Replace_Message"), Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), JOptionPane.YES_NO_CANCEL_OPTION, - JOptionPane.ERROR_MESSAGE, + JOptionPane.WARNING_MESSAGE, null, // 如果传null, 则按钮为 optionType 类型所表示的按钮(也就是确认对话框) options, @@ -437,7 +437,7 @@ public class ITReplaceMainDialog extends UIDialog { Toolkit.i18nText("Fine-Design_Replace_Message"), Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), JOptionPane.YES_NO_CANCEL_OPTION, - JOptionPane.ERROR_MESSAGE, + JOptionPane.WARNING_MESSAGE, null, // 如果传null, 则按钮为 optionType 类型所表示的按钮(也就是确认对话框) options, @@ -535,8 +535,12 @@ public class ITReplaceMainDialog extends UIDialog { return searchContentResultList; } - public void setSearchContentResultList(List searchContentResultList) { - this.searchContentResultList = searchContentResultList; + /** + * 设置模板内容数据 + * @param searchContentResultList 模板内容表格的数据 + */ + public static void setSearchContentResultList(List searchContentResultList) { + ITReplaceMainDialog.searchContentResultList = searchContentResultList; } /** @@ -547,8 +551,12 @@ public class ITReplaceMainDialog extends UIDialog { return searchSettingResultList; } - public void setSearchSettingResultList(List searchSettingResultList) { - this.searchSettingResultList = searchSettingResultList; + /** + * 设置设置项的数据 + * @param searchSettingResultList 设置项表格的数据 + */ + public static void setSearchSettingResultList(List searchSettingResultList) { + ITReplaceMainDialog.searchSettingResultList = searchSettingResultList; } /** diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java index cd086d903c..2a555a4387 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java @@ -14,7 +14,7 @@ import java.awt.Color; */ public class ITReplaceSouthPanel { ITTableEditorPane tableEditorPane; - public static ITTableEditor itTableEditor; + private static ITTableEditor itTableEditor; //勾选框索引 public static final int CHECKBOX_INDEX = 0; //ITContent在表格的列索引 @@ -56,7 +56,12 @@ public class ITReplaceSouthPanel { return itTableEditor; } - public void setItTableEditor(ITTableEditor itTableEditor) { - this.itTableEditor = itTableEditor; + /** + * 设置表格的editor,可用于刷新表格的数据 + * + * @param itTableEditor 表格的editor + */ + public static void setItTableEditor(ITTableEditor itTableEditor) { + ITReplaceSouthPanel.itTableEditor = itTableEditor; } } From aca1701772f2df3c87acd5d5bdee85cd4801cf34 Mon Sep 17 00:00:00 2001 From: "Leo.Qin" Date: Fri, 28 Oct 2022 11:13:45 +0800 Subject: [PATCH 28/63] =?UTF-8?q?REPORT-80690=20=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E5=8D=95=E5=85=83=E6=A0=BC=20=E3=80=90?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E5=8E=9F=E5=9B=A0=E3=80=91=20=E3=80=90?= =?UTF-8?q?=E6=94=B9=E5=8A=A8=E6=80=9D=E8=B7=AF=E3=80=91=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=93=8D=E4=BD=9C=E5=8D=95=E5=85=83=E6=A0=BC?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=20=E3=80=90review=E5=BB=BA=E8=AE=AE=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/actions/cell/AbstractCellElementAction.java | 6 +++++- .../src/main/java/com/fr/quickeditor/CellQuickEditor.java | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/cell/AbstractCellElementAction.java b/designer-realize/src/main/java/com/fr/design/actions/cell/AbstractCellElementAction.java index 0b2e702de3..450c326915 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/cell/AbstractCellElementAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/cell/AbstractCellElementAction.java @@ -68,7 +68,7 @@ public abstract class AbstractCellElementAction extends CellSelectionAction { if (isNeedShinkToFit()) { // shink to fit.(如果value是String) Object editElementValue = editCellElement.getValue(); - if (editElementValue != null && (editElementValue instanceof String || editElementValue instanceof Number)) { + if (checkValueType(editElementValue)) { // TODO ALEX_SEP 暂时用FIT_DEFAULT替代,不取reportsetting里面的设置,因为也不知道是应该放在report里面还是elementcase里面 GridUtils.shrinkToFit(ReportConstants.AUTO_SHRINK_TO_FIT_DEFAULT, tplEC, editCellElement); } @@ -78,6 +78,10 @@ public abstract class AbstractCellElementAction extends CellSelectionAction { } ePane.fireTargetModified(); } + + private boolean checkValueType(Object editElementValue) { + return editElementValue instanceof String || editElementValue instanceof Number; + } }); //控件设置记住dlg,提交入库智能添加单元格后可以show出来 DesignerContext.setReportWritePane(dialog); diff --git a/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java b/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java index dde927a168..107b06e5e9 100644 --- a/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java +++ b/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java @@ -82,7 +82,7 @@ public abstract class CellQuickEditor extends QuickEditor { */ protected UITextField columnRowTextField; protected TemplateCellElement cellElement; - protected TextFormatPane formatPane; + private TextFormatPane formatPane; private final JPanel topContentContainer; private final JComponent centerBodyContainer; @@ -437,6 +437,10 @@ public abstract class CellQuickEditor extends QuickEditor { return columnRowTextField; } + /** + * 创建格式化面板 + * @return + */ private JPanel createFormatPane() { formatPane = new TextFormatPane(); AbstractAttrNoScrollPane container = new AbstractAttrNoScrollPane() { From b08e6be68d743ab4520c06a9518d15a94301fd8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvan-=E6=AC=A7=E9=98=B3=E5=B8=86?= Date: Fri, 28 Oct 2022 11:18:12 +0800 Subject: [PATCH 29/63] =?UTF-8?q?REPORT-80693=20-=20=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=84=B1=E6=95=8F=E4=BA=8C=E6=9C=9F=EF=BC=88=E6=8A=A5=E8=A1=A8?= =?UTF-8?q?=EF=BC=89=20=E3=80=90=E9=97=AE=E9=A2=98=E5=8E=9F=E5=9B=A0?= =?UTF-8?q?=E3=80=91rt=20=E3=80=90=E6=94=B9=E5=8A=A8=E6=80=9D=E8=B7=AF?= =?UTF-8?q?=E3=80=91=E8=AF=A6=E8=A7=81https://kms.fineres.com/pages/viewpa?= =?UTF-8?q?ge.action=3FpageId=3D550539157=20=E3=80=90review=E5=BB=BA?= =?UTF-8?q?=E8=AE=AE=E3=80=91=E6=96=87=E6=A1=A3=E5=BF=98=E8=AE=B0=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E8=AF=84=E5=AE=A1=E4=BA=86=EF=BC=8Creview=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E5=80=99=E5=B8=AE=E5=BF=99=E6=89=93=E4=B8=AA=E5=88=86?= =?UTF-8?q?=EF=BC=8C=E6=84=9F=E8=B0=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datapane/preview/PreviewTableModel.java | 13 +++ .../datapane/preview/PreviewTablePane.java | 2 +- .../TableDataPreviewDesensitizeManager.java | 51 +++++------ .../model/DesensitizedPreviewTableModel.java | 26 +++--- .../rule/DesensitizationRuleChoosePane.java | 3 + .../rule/DesensitizationRuleDebugPane.java | 2 +- .../rule/DesensitizationRuleEditPane.java | 10 +-- .../TableDataDesensitizationSettingPane.java | 12 +-- .../TableDataDesensitizationTableModel.java | 89 +++++++------------ .../TableDataDesensitizationTablePane.java | 8 +- 10 files changed, 99 insertions(+), 117 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTableModel.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTableModel.java index 49ce4ba420..9074a18d66 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTableModel.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTableModel.java @@ -116,6 +116,19 @@ public class PreviewTableModel extends AbstractTableModel { } } + /** + * 根据列名获取列序号,当返回-1时代表异常,异常会被忽略,不打印日志或给出前台提示 + * @param columnName + * @return + */ + public int getColumnIndexWithExceptionIngore(String columnName) { + try { + return dataModel.getColumnIndex(columnName); + } catch (TableDataException ingore) { + return -1; + } + } + public int getRowCount() { try { return this.dataModel.getRowCount(); diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java index dc3bc6ed8d..b701112f57 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java @@ -776,6 +776,6 @@ public class PreviewTablePane extends BasicPane { */ private boolean isDesensitizeOpened() { return tableData instanceof DesensitizationTableData && - ((DesensitizationTableData) tableData).isDesensitizeOpen(); + ((DesensitizationTableData) tableData).getDesensitizationConfig().isDesensitizeOpened(); } } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/TableDataPreviewDesensitizeManager.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/TableDataPreviewDesensitizeManager.java index 0632de3e65..ed5104fbce 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/TableDataPreviewDesensitizeManager.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/TableDataPreviewDesensitizeManager.java @@ -3,7 +3,7 @@ package com.fr.design.data.datapane.preview.desensitization; import com.fr.base.TableData; import com.fr.data.desensitize.base.DesensitizationTableData; -import com.fr.data.desensitize.base.TableDataDesensitizationBean; +import com.fr.data.desensitize.base.TableDataDesensitizationItem; import com.fr.data.desensitize.manage.DesensitizationManager; import com.fr.data.desensitize.util.DesentizationUtils; import com.fr.decision.webservice.bean.user.DepartmentPostBean; @@ -14,12 +14,10 @@ import com.fr.decision.webservice.v10.user.PositionService; import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.datapane.preview.PreviewTableModel; import com.fr.design.data.datapane.preview.desensitization.model.DesensitizedPreviewTableModel; -import com.fr.design.data.tabledata.wrapper.TableDataWrapper; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; -import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; import java.util.LinkedHashMap; @@ -57,14 +55,14 @@ public class TableDataPreviewDesensitizeManager implements DesensitizationManage /** * 判断数据集预览时是否需要脱敏,这里不需要判断roleIds,因为默认有权限编辑的人一定有权限看脱敏前后字段值 + * 只需要保证此数据集存在脱敏配置就行 * * @param tableData * @return */ public boolean needDesensitize(TableData tableData) { return tableData instanceof DesensitizationTableData && - DesentizationUtils.isCollectionNotEmpty(((DesensitizationTableData) tableData).getDesensitizationBeans()) && - ((DesensitizationTableData) tableData).getDesensitizationBeans().stream().noneMatch(TableDataDesensitizationBean::invalid); + DesentizationUtils.isCollectionNotEmpty(((DesensitizationTableData) tableData).getDesensitizationConfig().getDesensitizationItems()); } /** @@ -75,25 +73,23 @@ public class TableDataPreviewDesensitizeManager implements DesensitizationManage */ public PreviewTableModel desensitizeTableModel(TableData tableData, PreviewTableModel model) { - Map desensitizationBeanMap = new LinkedHashMap<>(); + Map desensitizationItemMap = new LinkedHashMap<>(); // 获取此数据集的所有脱敏信息 - Collection desensitizationBeans = ((DesensitizationTableData) tableData).getDesensitizationBeans(); - // 去除被禁用的规则 + 排序 - List sortedBeans = desensitizationBeans - .stream() - .filter(bean -> bean.getDesensitizationRule().isEnable()) - .sorted(Comparator.comparingInt(TableDataDesensitizationBean::getColumnIndex)) - .collect(Collectors.toList()); - int columnIndex = 0; - for (TableDataDesensitizationBean sortedBean : sortedBeans) { - // 当map中已包含列序号时,代表对这一列设置了不同的脱敏规则,将key + 1 - if (desensitizationBeanMap.containsKey(columnIndex)) { - columnIndex++; + Collection desensitizationItems = ((DesensitizationTableData) tableData).getDesensitizationConfig().getDesensitizationItems(); + if (DesentizationUtils.isCollectionNotEmpty(desensitizationItems)) { + // 先对脱敏配置项集合做过滤和排序处理 + List items = desensitizationItems.stream() + .filter(item -> item.getRule().isEnable() && + matchColumnIndex(item, model) >= 0) + .sorted(Comparator.comparingInt(item -> matchColumnIndex(item, model))) + .collect(Collectors.toList()); + // 然后转换成Map + for (int i = 0; i < items.size(); i++) { + desensitizationItemMap.put(i, items.get(i)); } - desensitizationBeanMap.put(columnIndex, sortedBean); } // 包装TableModel - return new DesensitizedPreviewTableModel(model, desensitizationBeanMap); + return new DesensitizedPreviewTableModel(model, desensitizationItemMap); } /** @@ -104,16 +100,7 @@ public class TableDataPreviewDesensitizeManager implements DesensitizationManage * @return */ public List getColumnNamesByTableData(TableData tableData) { - List> editingDataSet = DesignTableDataManager.getEditingDataSet(DesignTableDataManager.getEditingTableDataSource()); - // 当前所有模板数据集Wrapper,不包括存储过程 - Map templeteDataMap = editingDataSet.get(0); - // 当前所有模板数据集Wrapper,包括存储过程 - Map dataWrapperMap = DesignTableDataManager.getAllDataSetIncludingProcedure(templeteDataMap); - // 找到匹配当前数据集名称的Wrapper - TableDataWrapper tableDataWrapper = dataWrapperMap.get(tableData.getName()); - return tableDataWrapper == null ? - new ArrayList<>() : - tableDataWrapper.calculateColumnNameList(); + return DesignTableDataManager.getColumnNamesByTableData(tableData); } /** @@ -189,4 +176,8 @@ public class TableDataPreviewDesensitizeManager implements DesensitizationManage public String mergeRoleId(String departmentId, String positionId) { return departmentId + CONNECTOR + positionId; } + + public int matchColumnIndex(TableDataDesensitizationItem desensitizationItem, PreviewTableModel previewModel) { + return previewModel.getColumnIndexWithExceptionIngore(desensitizationItem.getColumnName()); + } } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/model/DesensitizedPreviewTableModel.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/model/DesensitizedPreviewTableModel.java index e3598e39c0..d8908fd14d 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/model/DesensitizedPreviewTableModel.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/model/DesensitizedPreviewTableModel.java @@ -1,10 +1,11 @@ package com.fr.design.data.datapane.preview.desensitization.model; -import com.fr.data.desensitize.base.TableDataDesensitizationBean; +import com.fr.data.desensitize.base.TableDataDesensitizationItem; import com.fr.data.desensitize.calculate.DesensitizationCalculator; import com.fr.data.desensitize.rule.base.DesensitizationRule; import com.fr.design.data.datapane.preview.PreviewTableModel; +import com.fr.design.data.datapane.preview.desensitization.TableDataPreviewDesensitizeManager; import java.util.Map; import java.util.Objects; @@ -26,20 +27,20 @@ public class DesensitizedPreviewTableModel extends PreviewTableModel { /** * 脱敏后新组装的TableModel中,列序号 - 脱敏信息 对应的Map */ - private Map desensitizationBeanMap; + private Map desensitizationItemMap; private boolean needDesensitize = false; - public DesensitizedPreviewTableModel(PreviewTableModel previewTableModel, Map desensitizationBeanMap) { + public DesensitizedPreviewTableModel(PreviewTableModel previewTableModel, Map desensitizationItemMap) { this.previewTableModel = previewTableModel; - this.desensitizationBeanMap = desensitizationBeanMap; + this.desensitizationItemMap = desensitizationItemMap; } @Override public String getColumnName(int column) { - int originIndex = needDesensitize && Objects.nonNull(desensitizationBeanMap.get(column)) ? - desensitizationBeanMap.get(column).getColumnIndex() : column; - return previewTableModel.getColumnName(originIndex); + return needDesensitize ? + desensitizationItemMap.get(column).getColumnName() : + previewTableModel.getColumnName(column); } @Override @@ -56,7 +57,7 @@ public class DesensitizedPreviewTableModel extends PreviewTableModel { @Override public Object getValueAt(int rowIndex, int columnIndex) { - return needDesensitize && Objects.nonNull(desensitizationBeanMap.get(columnIndex)) ? + return needDesensitize && Objects.nonNull(desensitizationItemMap.get(columnIndex)) ? getDesensitizedValue(rowIndex, columnIndex) : previewTableModel.getValueAt(rowIndex, columnIndex); } @@ -70,7 +71,7 @@ public class DesensitizedPreviewTableModel extends PreviewTableModel { */ private Object getDesensitizedValue(int rowIndex, int columnIndex) { // 先通过columnIndex找到对应原TableModel的列序号 - int originColumnIndex = desensitizationBeanMap.get(columnIndex).getColumnIndex(); + int originColumnIndex = TableDataPreviewDesensitizeManager.getInstance().matchColumnIndex(desensitizationItemMap.get(columnIndex), previewTableModel); // 获取原值 Object value = previewTableModel.getValueAt(rowIndex, originColumnIndex); // 判空 @@ -91,9 +92,8 @@ public class DesensitizedPreviewTableModel extends PreviewTableModel { * @return */ private String desensitizeValue(String strValue, int columnIndex) { - TableDataDesensitizationBean desensitizationBean = desensitizationBeanMap.get(columnIndex); - DesensitizationRule desensitizationRule = desensitizationBean.getDesensitizationRule(); - return DesensitizationCalculator.getInstance().desensitize(strValue, desensitizationRule); + DesensitizationRule rule = desensitizationItemMap.get(columnIndex).getRule(); + return DesensitizationCalculator.getInstance().desensitize(strValue, rule); } /** @@ -102,7 +102,7 @@ public class DesensitizedPreviewTableModel extends PreviewTableModel { * @return */ public int getDesensitizeColumnsCount() { - return desensitizationBeanMap.size(); + return desensitizationItemMap.size(); } /** diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleChoosePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleChoosePane.java index 16900defa4..fd627e8cc4 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleChoosePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleChoosePane.java @@ -305,6 +305,9 @@ public class DesensitizationRuleChoosePane extends JPanel { public void actionPerformed(ActionEvent e) { // 获取当前选中规则 DesensitizationRule selectedRule = getSelectedValue(); + if (selectedRule == null) { + return; + } DesensitizationRuleDebugPane ruleDebugPane = new DesensitizationRuleDebugPane(selectedRule); BasicDialog ruleDebugDialog = ruleDebugPane.showWindowWithCustomSize(SwingUtilities.getWindowAncestor(parent), null, BasicDialog.DEFAULT); ruleDebugDialog.setVisible(true); diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleDebugPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleDebugPane.java index 5f74dee9c0..eba6d10899 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleDebugPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleDebugPane.java @@ -52,7 +52,7 @@ public class DesensitizationRuleDebugPane extends BasicPane { JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane(); panel.setBorder(BorderFactory.createEmptyBorder(20, 10, 0, 0)); UILabel desensitizationRule = new UILabel(Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule_Algorithm")); - UILabel characterReplace = new UILabel(rule.getRuleType().getTypeName()); + UILabel characterReplace = new UILabel(rule.getRuleType().getRuleTypeName()); UILabel description = new UILabel(DesensitizationRule.getDescription(rule)); JComponent[][] components = new JComponent[][]{ {desensitizationRule, characterReplace}, diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleEditPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleEditPane.java index 2f526f4b8f..7354dc0b11 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleEditPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleEditPane.java @@ -185,8 +185,8 @@ public class DesensitizationRuleEditPane extends BasicBeanPane tableDataDesensitizationBeans) { - tableData.setDesensitizationBeans(tableDataDesensitizationBeans); + public void saveDesensitizationBeans(List desensitizationItems) { + tableData.getDesensitizationConfig().setDesensitizationItems(desensitizationItems); } } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTableModel.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTableModel.java index c43795ac98..bbc91efa2a 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTableModel.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTableModel.java @@ -1,7 +1,7 @@ package com.fr.design.data.datapane.preview.desensitization.view.setting; import com.fr.data.desensitize.base.DesensitizationTableData; -import com.fr.data.desensitize.base.TableDataDesensitizationBean; +import com.fr.data.desensitize.base.TableDataDesensitizationItem; import com.fr.data.desensitize.rule.base.DesensitizationRule; import com.fr.design.data.datapane.preview.desensitization.TableDataPreviewDesensitizeManager; import com.fr.design.data.datapane.preview.desensitization.view.rule.DesensitizationRulePane; @@ -18,7 +18,6 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.stable.StringUtils; -import com.fr.stable.collections.CollectionUtils; import org.jetbrains.annotations.Nullable; import javax.swing.AbstractCellEditor; @@ -33,6 +32,7 @@ import java.awt.Component; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.LinkedHashSet; import java.util.List; @@ -48,7 +48,7 @@ import java.util.Set; * @version 11.0 * Created by Yvan on 2022/9/23 */ -public class TableDataDesensitizationTableModel extends UITableModelAdapter { +public class TableDataDesensitizationTableModel extends UITableModelAdapter { private static final String APOSTROPHE = "..."; @@ -106,59 +106,32 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter= 0 && columnIndex < columnNames.size(); - } - /** * 通过id匹配此用户组对应的部门职位名称(或者说自定义角色名称) * * @param roleIds * @return */ - private List matchRoleNamesByIds(Set roleIds) { + private List matchRoleNamesByIds(Collection roleIds) { List result = new ArrayList<>(); for (String roleId : roleIds) { if (roleMap != null && roleMap.containsKey(roleId)) { @@ -184,7 +157,7 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter generateRolesCheckBoxSelectedValues(TableDataDesensitizationBean desensitizationBean) { + private Map generateRolesCheckBoxSelectedValues(TableDataDesensitizationItem desensitizationItem) { Map result = new HashMap<>(roleMap.size()); for (Map.Entry roleEntry : roleMap.entrySet()) { String roleId = roleEntry.getKey(); String roleName = roleEntry.getValue(); - if (desensitizationBean.getRoleIds().contains(roleId)) { + if (desensitizationItem.getRoleIds().contains(roleId)) { result.put(roleName, true); } else { result.put(roleName, false); @@ -444,7 +419,7 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter editorPane; + private UITableEditorPane editorPane; public TableDataDesensitizationTablePane(DesensitizationTableData tableData, Component parent) { this.tableData = tableData; @@ -54,13 +54,13 @@ public class TableDataDesensitizationTablePane extends JPanel { */ public void populateDesensitizationSetting(DesensitizationTableData tableData) { this.tableData = tableData; - editorPane.populate(tableData.getDesensitizationBeans().toArray(new TableDataDesensitizationBean[0])); + editorPane.populate(tableData.getDesensitizationConfig().getDesensitizationItems().toArray(new TableDataDesensitizationItem[0])); } /** * 获取当前对TableData的配置脱敏规则信息 */ - public List updateDesensitizationSetting() { + public List updateDesensitizationSetting() { return editorPane.update(); } } From 7f1f72ec74725c4889cf240fd1994c1b082ef5f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvan-=E6=AC=A7=E9=98=B3=E5=B8=86?= Date: Fri, 28 Oct 2022 11:30:12 +0800 Subject: [PATCH 30/63] =?UTF-8?q?REPORT-80693=20-=20=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=84=B1=E6=95=8F=E4=BA=8C=E6=9C=9F=EF=BC=88=E6=8A=A5=E8=A1=A8?= =?UTF-8?q?=EF=BC=89=20=E4=BB=A3=E7=A0=81=E8=B4=A8=E9=87=8F=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=E9=97=AE=E9=A2=98=EF=BC=8C=E5=8A=A0=E4=B8=AA=E6=B3=A8?= =?UTF-8?q?=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../desensitization/TableDataPreviewDesensitizeManager.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/TableDataPreviewDesensitizeManager.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/TableDataPreviewDesensitizeManager.java index ed5104fbce..3d3c59331f 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/TableDataPreviewDesensitizeManager.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/TableDataPreviewDesensitizeManager.java @@ -177,6 +177,12 @@ public class TableDataPreviewDesensitizeManager implements DesensitizationManage return departmentId + CONNECTOR + positionId; } + /** + * 根据列名,从PreviewTableModel中匹配列序号,如果返回-1代表未匹配到 + * @param desensitizationItem + * @param previewModel + * @return + */ public int matchColumnIndex(TableDataDesensitizationItem desensitizationItem, PreviewTableModel previewModel) { return previewModel.getColumnIndexWithExceptionIngore(desensitizationItem.getColumnName()); } From 37fe3cad371b68e4b702ad88d185637a85119cc6 Mon Sep 17 00:00:00 2001 From: "Link.Zhao" Date: Fri, 28 Oct 2022 13:52:33 +0800 Subject: [PATCH 31/63] =?UTF-8?q?REPORT-80750=20=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E4=B8=AD=E7=9A=84=E4=B8=B4=E6=97=B6=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E7=9B=AE=E5=BD=95=E6=A2=B3=E7=90=86=E5=92=8C=E6=95=B4?= =?UTF-8?q?=E6=94=B9=201=E3=80=81=E4=BF=AE=E6=94=B9notshare=E4=B8=BAlocal?= =?UTF-8?q?=202=E3=80=81engine=E7=9B=B4=E6=8E=A5=E5=88=A0=E9=99=A4=203?= =?UTF-8?q?=E3=80=81FineReport.Reuse=E9=9C=80=E8=A6=81=E8=BF=81=E7=A7=BB?= =?UTF-8?q?=E5=A4=87=E4=BB=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/gui/style/TranslucentBorderSpecialPane.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/style/TranslucentBorderSpecialPane.java b/designer-base/src/main/java/com/fr/design/gui/style/TranslucentBorderSpecialPane.java index e3ef66bfeb..cc49820de5 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/TranslucentBorderSpecialPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/TranslucentBorderSpecialPane.java @@ -191,7 +191,7 @@ public class TranslucentBorderSpecialPane extends AbstractBorderPackerPane imple String lastUsedBorderImageDirPath = history.getLastSelectedBorderImageDir(); File lastUsedBorderImageDir = StringUtils.isNotEmpty(lastUsedBorderImageDirPath) ? new File(lastUsedBorderImageDirPath) : null; - File inbuiltBorderImagesDir = new File(StableUtils.pathJoin(ProjectLibrary.getInstance().getLibHome(), ProjectConstants.NOT_SHARE, ProjectConstants.BORDER_IMAGES)); + File inbuiltBorderImagesDir = new File(StableUtils.pathJoin(ProjectLibrary.getInstance().getLibHome(), ProjectConstants.LOCAL, ProjectConstants.BORDER_IMAGES)); if (lastUsedBorderImageDir!= null && lastUsedBorderImageDir.exists()) { imageFileChooser.setCurrentDirectory(lastUsedBorderImageDir); From 41838d27860715101e0a5979c9cd279fda5bfdaf Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Fri, 28 Oct 2022 15:23:28 +0800 Subject: [PATCH 32/63] =?UTF-8?q?REPORT-80695=20=E3=80=90=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E5=85=A8=E5=B1=80=E7=BA=A7=E5=88=AB=E6=9F=A5=E6=89=BE?= =?UTF-8?q?=E6=9B=BF=E6=8D=A2=E4=BA=8C=E6=9C=9F=E3=80=91=E5=90=88=E6=B3=95?= =?UTF-8?q?=E6=80=A7=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../actions/replace/info/ComponentInfo.java | 23 +++ .../fr/design/actions/replace/info/Info.java | 16 +++ .../actions/replace/info/WidgetInfo.java | 23 +++ .../actions/replace/info/base/ITContent.java | 24 ++++ .../actions/replace/ui/ITCheckDialog.java | 98 +++++++++++++ .../actions/replace/ui/ITCheckEditor.java | 64 +++++++++ .../replace/ui/ITReplaceMainDialog.java | 132 ++++++++++++++++-- .../actions/replace/utils/ShowValueUtils.java | 2 +- 8 files changed, 367 insertions(+), 15 deletions(-) create mode 100644 designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITCheckDialog.java create mode 100644 designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITCheckEditor.java diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/ComponentInfo.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/ComponentInfo.java index b302376fb6..77993c53db 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/info/ComponentInfo.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/ComponentInfo.java @@ -1,10 +1,14 @@ package com.fr.design.actions.replace.info; import com.fr.design.actions.replace.action.content.component.ComponentType; +import com.fr.design.actions.replace.action.content.component.SearchComponentAction; import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.JTemplate; import com.fr.form.ui.Widget; import com.fr.stable.StringUtils; import com.fr.stable.collections.combination.Pair; +import com.fr.stable.js.WidgetName; import java.util.HashMap; @@ -79,4 +83,23 @@ public class ComponentInfo implements Info { public String getInfoShowStr(Info info) { return this.getContent().getOldShowStr(); } + + @Override + public Boolean isLegalValid(JTemplate jTemplate, String searchStr, String replaceStr) { + if (StringUtils.isEmpty(replaceStr)) { + this.getContent().setCheckStr(Toolkit.i18nText("Fine-Design_Replace_Not_Empty")); + return false; + } + SearchComponentAction.getInstance().search4Infos(jTemplate); + List list = SearchComponentAction.getInstance().getComponentInfos(); + String replacedName = ((Widget)this.getContent().getReplaceObject()).getWidgetName().replace(searchStr, replaceStr); + for (ComponentInfo info : list) { + String widgetName = ((Widget)info.getContent().getReplaceObject()).getWidgetName(); + if (StringUtils.equals(replacedName, widgetName)) { + this.getContent().setCheckStr(Toolkit.i18nText("Fine-Design_Replace_Exist_Same_Name")); + return false; + } + } + return true; + } } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/Info.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/Info.java index 6f26be2595..9fc5aedad6 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/info/Info.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/Info.java @@ -1,6 +1,7 @@ package com.fr.design.actions.replace.info; import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.mainframe.JTemplate; /** @@ -40,4 +41,19 @@ public interface Info extends DealWithInfoValue { //todo 完善所有类型的校验 return true; } + + /** + * 校验合法性(内容是否合法 + * 当前需要检测的目标: + * 控件名:值是否为空、重名 + * 组件名:值是否为空、重名 + * + * @param jTemplate 要检测的模板 + * @param searchStr 搜索的内容 + * @param replaceStr 替换的内容 + * @return 检测合法则返回true + */ + default Boolean isLegalValid(JTemplate jTemplate,String searchStr, String replaceStr) { + return true; + } } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/WidgetInfo.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/WidgetInfo.java index afdf098028..7adfc01536 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/info/WidgetInfo.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/WidgetInfo.java @@ -4,12 +4,16 @@ import com.fr.design.actions.replace.action.content.widget.FrmWidgetType; import com.fr.design.actions.replace.info.base.ITContent; import com.fr.design.actions.replace.utils.ShowValueUtils; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.JTemplate; import com.fr.form.ui.WaterMark; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WScaleLayout; import com.fr.form.ui.widget.CRBoundsWidget; import com.fr.stable.AssistUtils; +import com.fr.stable.StringUtils; import com.fr.stable.collections.combination.Pair; +import com.fr.stable.js.WidgetName; import java.util.HashMap; @@ -128,4 +132,23 @@ public class WidgetInfo implements Info, DealWithInfoValue { } + @Override + public Boolean isLegalValid(JTemplate jTemplate,String searchStr, String replaceStr) { + if (StringUtils.isEmpty(replaceStr)) { + this.getContent().setCheckStr(Toolkit.i18nText("Fine-Design_Replace_Not_Empty")); + return false; + } + if (!this.isWaterMark()) { + String replacedName = ((Widget)this.getContent().getReplaceObject()).getWidgetName().replace(searchStr, replaceStr); + for (WidgetName name : jTemplate.getModel().getWidgetsName()) { + String widgetName = name.getName(); + if (StringUtils.equals(replacedName, widgetName)) { + this.getContent().setCheckStr(Toolkit.i18nText("Fine-Design_Replace_Exist_Same_Name")); + return false; + } + } + } + return true; + } + } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/ITContent.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/ITContent.java index aecbe2ed10..e75b224649 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/ITContent.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/ITContent.java @@ -87,6 +87,13 @@ public class ITContent implements Cloneable { */ private boolean replaced = false; + /** + * + */ + private String checkStr = StringUtils.EMPTY; + + private boolean wrongful = false; + public ITContent() { this.sheetID = StringUtils.EMPTY; this.sheetName = StringUtils.EMPTY; @@ -133,6 +140,7 @@ public class ITContent implements Cloneable { result.setTemplatePath(content.getTemplatePath()); result.setAfterReplaceStr(content.getAfterReplaceStr()); result.setReplaced(content.isReplaced()); + result.setWrongful(content.isWrongful()); } return result; } @@ -245,6 +253,22 @@ public class ITContent implements Cloneable { this.replaced = replaced; } + public String getCheckStr() { + return checkStr; + } + + public void setCheckStr(String checkStr) { + this.checkStr = checkStr; + } + + public boolean isWrongful() { + return wrongful; + } + + public void setWrongful(boolean wrongful) { + this.wrongful = wrongful; + } + /** * 添加位置信息 * diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITCheckDialog.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITCheckDialog.java new file mode 100644 index 0000000000..e597e3172e --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITCheckDialog.java @@ -0,0 +1,98 @@ +package com.fr.design.actions.replace.ui; + + +import com.fr.design.dialog.UIDialog; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ilable.UILabel; + +import com.fr.design.gui.itableeditorpane.UITableEditorPane; + +import com.fr.design.i18n.Toolkit; + +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import static com.fr.design.actions.replace.ui.ITTableEditorPane.getEditTable; + +/** + * 合法性校验的面板 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-10-28 + */ +public class ITCheckDialog extends UIDialog { + private UITableEditorPane editorPane; + private ITCheckEditor editor; + private static final int DIALOG_WIDTH = 660, DIALOG_HEIGHT = 400; + private static final int TABLE_WIDTH = 640, TABLE_HEIGHT = 320; + private static final int LABEL_HEIGHT = 20; + + public static final Object[] columnTitle = {Toolkit.i18nText("Fine-Design_Replace_Check_Content"), Toolkit.i18nText("Fine-Design_Replace_Check_Reason")}; + + public ITCheckDialog() { + super(ITReplaceMainDialog.getInstance()); + setTitle(Toolkit.i18nText("Fine-Design_Replace_Check_Title")); + JPanel centerPanel = new JPanel(); + JPanel southPanel = new JPanel(); + southPanel.setLayout(new FlowLayout(FlowLayout.RIGHT)); + + editor = new ITCheckEditor(); + editorPane = new UITableEditorPane(editor); + editor.add(ITReplaceMainDialog.getCheckValidList()); + + UILabel label = new UILabel("" + Toolkit.i18nText("Fine-Design_Replace_Check") + "" + ITReplaceMainDialog.contentReplaceFailedCount + "" + Toolkit.i18nText("Fine-Design_Replace_Check_Tip")); + JPanel center = new JPanel(new BorderLayout()); + UIButton location = new UIButton(Toolkit.i18nText("Fine-Design_Chart_Location")); + UIButton cancel = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Cancel")); + + location.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + for (int i : ITReplaceMainDialog.getSerialNumber()) { + getEditTable().addRowSelectionInterval(i, i); + } + ITCheckDialog.this.dispose(); + } + }); + + cancel.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + ITCheckDialog.this.dispose(); + } + }); + + + editorPane.setPreferredSize(new Dimension(TABLE_WIDTH, TABLE_HEIGHT)); + label.setPreferredSize(new Dimension(TABLE_WIDTH, LABEL_HEIGHT)); + + centerPanel.add(editorPane); + southPanel.add(location); + southPanel.add(cancel); + center.add(southPanel, BorderLayout.SOUTH); + center.add(label, BorderLayout.NORTH); + center.add(centerPanel, BorderLayout.CENTER); + center.setVisible(true); + //主体部分 + add(center); + + + setSize(DIALOG_WIDTH, DIALOG_HEIGHT); + setMaximumSize(new Dimension(DIALOG_WIDTH, DIALOG_HEIGHT)); + setMinimumSize(new Dimension(DIALOG_WIDTH, DIALOG_HEIGHT)); + + setLocation(ITReplaceMainDialog.getInstance().getX() + ITReplaceMainDialog.getInstance().getWidth() / 2 - DIALOG_WIDTH / 2, ITReplaceMainDialog.getInstance().getY()); + setVisible(true); + } + + + @Override + public void checkValid() throws Exception { + + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITCheckEditor.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITCheckEditor.java new file mode 100644 index 0000000000..1efb8beffc --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITCheckEditor.java @@ -0,0 +1,64 @@ +package com.fr.design.actions.replace.ui; + +import com.fr.design.actions.replace.info.Info; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itableeditorpane.UITableEditAction; +import com.fr.design.gui.itableeditorpane.UITableModelAdapter; +import com.fr.design.i18n.Toolkit; + +import java.util.List; + +/** + * 合法性校验表格的Model + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-10-28 + */ +public class ITCheckEditor extends UITableModelAdapter { + + public ITCheckEditor() { + super(new String[]{ + Toolkit.i18nText("Fine-Design_Replace_Check_Content"), + Toolkit.i18nText("Fine-Design_Replace_Check_Reason") + }); + + this.setColumnClass(new Class[]{ + UILabel.class, + UILabel.class, + }); + } + + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + ITContent content = (ITContent) this.getList().get(rowIndex); + if (columnIndex == 0) { + return content.getShowStr(); + } else { + return content.getCheckStr(); + } + } + + @Override + public boolean isCellEditable(int row, int col) { + return false; + } + + @Override + public UITableEditAction[] createAction() { + return new UITableEditAction[0]; + } + + /** + * 添加数据 + * + * @param list + */ + public void add(List list) { + for (Info info : list) { + addRow(info.getContent()); + } + fireTableDataChanged(); + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java index e207ca5004..868ad8ad2a 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java @@ -16,6 +16,8 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; +import com.fr.design.mainframe.toast.DesignerToastMsgUtil; +import com.fr.design.mainframe.toast.ToastMsgDialog; import com.fr.general.GeneralUtils; import com.fr.stable.StringUtils; @@ -45,6 +47,8 @@ import static com.fr.design.actions.replace.ui.ITTableEditorPane.getEditTable; public class ITReplaceMainDialog extends UIDialog { private static List searchContentResultList = new ArrayList<>(); private static List searchSettingResultList = new ArrayList<>(); + private static List checkValidList = new ArrayList<>(); + private static List serialNumber = new ArrayList<>(); private static boolean ITReplaceFlag = false; private static boolean matched = false; private static volatile ITReplaceMainDialog instance = null; @@ -184,26 +188,15 @@ public class ITReplaceMainDialog extends UIDialog { } /** - * 替换 + * 模板内容替换相关 */ private void replace4Content() { String searchStr = ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).getText(); String replaceStr = ((UITextField) (northPane.getReplaceInputCombobox().getEditor().getEditorComponent())).getText(); clearContentCount(); if (isITReplaceValid() && checkTemplateChanged(searchContentResultList)) { - if (StringUtils.equals(getSearchStr(), searchStr) && StringUtils.isNotEmpty(replaceStr)) { - HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified(true); - for (Info info : searchContentResultList) { - if (isAllow2Replace(info)) { - info.setValue(info, searchStr, replaceStr, info.getContent().getOperatorArray()); - info.getContent().setReplaced(true); - contentReplaceCount++; - } - } - northPane.getResultLabel().setText(ShowValueUtils.getResultTip(searchContentResultList.size(), contentReplaceCount, contentReplaceFailedCount)); - southPanel.getTableEditorPane().update(); - northPane.refreshReplaceInputComboBoxItems(); - ITTableEditorPane.getEditTable().repaint(); + if (StringUtils.equals(getSearchStr(), searchStr)) { + checkLegalValiditySelector(searchStr, replaceStr); } else { search4Content(); } @@ -227,6 +220,86 @@ public class ITReplaceMainDialog extends UIDialog { } } + /** + * 替换 + * + * @param searchStr + * @param replaceStr + */ + public void replace(String searchStr, String replaceStr) { + HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified(true); + for (Info info : searchContentResultList) { + if (!info.getContent().isWrongful()) { + info.setValue(info, searchStr, replaceStr, info.getContent().getOperatorArray()); + } + info.getContent().setReplaced(true); + } + northPane.getResultLabel().setText(ShowValueUtils.getResultTip(searchContentResultList.size(), contentReplaceCount, contentReplaceFailedCount)); + southPanel.getTableEditorPane().update(); + northPane.refreshReplaceInputComboBoxItems(); + ITTableEditorPane.getEditTable().repaint(); + } + + /** + * 合法性校验选择器(选择是否进行校验) + */ + public void checkLegalValiditySelector(String searchStr, String replaceStr) { + Object[] options = new Object[]{Toolkit.i18nText("Fine-Design_Replace_Go_To_Check"), Toolkit.i18nText("Fine-Design_Replace_Direct")}; + int optionSelected = FineJOptionPane.showOptionDialog( + ITReplaceMainDialog.this, + Toolkit.i18nText("Fine-Design_Replace_Legal"), + Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), + JOptionPane.YES_NO_CANCEL_OPTION, + JOptionPane.WARNING_MESSAGE, + null, + // 如果传null, 则按钮为 optionType 类型所表示的按钮(也就是确认对话框) + options, + options[0] + ); + //如果选择了直接替换,则直接执行替换 + if (optionSelected == 1) { + updateCheckValidList(); + replace(searchStr, replaceStr); + } else { + checkLegalValidity(); + } + } + + /** + * 检测 + */ + public void checkLegalValidity() { + updateCheckValidList(); + if (contentReplaceFailedCount == 0) { + ToastMsgDialog dialog = DesignerToastMsgUtil.createPromptDialog(Toolkit.i18nText("Fine-Design_Replace_Check_None")); + dialog.setVisible(true); + } else { + new ITCheckDialog(); + } + } + + private void updateCheckValidList() { + checkValidList.clear(); + serialNumber.clear(); + int count = 0; + String searchStr = ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).getText(); + String replaceStr = ((UITextField) (northPane.getReplaceInputCombobox().getEditor().getEditorComponent())).getText(); + for (Info info : searchContentResultList) { + if (isAllow2Replace(info)) { + if (!info.isLegalValid(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(), searchStr, replaceStr)) { + contentReplaceFailedCount++; + checkValidList.add(info); + serialNumber.add(count); + info.getContent().setWrongful(true); + } else { + contentReplaceCount++; + } + count++; + } + } + + } + /** * 是否能够替换 * @@ -520,6 +593,15 @@ public class ITReplaceMainDialog extends UIDialog { this.settingExtraStr = settingExtraStr; } + /** + * 获取不合法的序号 + * + * @return 不合法的元素的序号列表 + */ + public static List getSerialNumber() { + return serialNumber; + } + /** * 检测结果是否合法 */ @@ -529,6 +611,7 @@ public class ITReplaceMainDialog extends UIDialog { /** * 获取模板内容数据 + * * @return 存储数据的list */ public static List getSearchContentResultList() { @@ -537,6 +620,7 @@ public class ITReplaceMainDialog extends UIDialog { /** * 设置模板内容数据 + * * @param searchContentResultList 模板内容表格的数据 */ public static void setSearchContentResultList(List searchContentResultList) { @@ -545,6 +629,7 @@ public class ITReplaceMainDialog extends UIDialog { /** * 获取设置项数据 + * * @return 存储数据的list */ public static List getSearchSettingResultList() { @@ -553,12 +638,31 @@ public class ITReplaceMainDialog extends UIDialog { /** * 设置设置项的数据 + * * @param searchSettingResultList 设置项表格的数据 */ public static void setSearchSettingResultList(List searchSettingResultList) { ITReplaceMainDialog.searchSettingResultList = searchSettingResultList; } + /** + * 获取检测的列表 + * + * @return + */ + public static List getCheckValidList() { + return checkValidList; + } + + /** + * 设置检测列表 + * + * @param checkValidList + */ + public static void setCheckValidList(List checkValidList) { + ITReplaceMainDialog.checkValidList = checkValidList; + } + /** * 重置计数 */ diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java index 8f1174e8fc..01205bf886 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java @@ -395,7 +395,7 @@ public class ShowValueUtils { if (replaceCount != 0) { str.append(Toolkit.i18nText("Fine-Design_Replace_Also_Finish")).append("").append(replaceCount).append("").append(Toolkit.i18nText("Fine-Design_Replace_Result_Count")); if (failedCount != 0) { - str.append(Toolkit.i18nText("Fine-Design_Replace_Have")).append("").append(replaceCount).append("").append(Toolkit.i18nText("Fine-Design_Replace_Can_Not_Replace")); + str.append(Toolkit.i18nText("Fine-Design_Replace_Have")).append("").append(failedCount).append("").append(Toolkit.i18nText("Fine-Design_Replace_Can_Not_Replace")); } } From b688e55822c67bd3e24b47e3016a80c7caecc80e Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Fri, 28 Oct 2022 15:29:59 +0800 Subject: [PATCH 33/63] =?UTF-8?q?REPORT-80695=20=E3=80=90=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E5=85=A8=E5=B1=80=E7=BA=A7=E5=88=AB=E6=9F=A5=E6=89=BE?= =?UTF-8?q?=E6=9B=BF=E6=8D=A2=E4=BA=8C=E6=9C=9F=E3=80=91=E5=88=AA=E9=99=A4?= =?UTF-8?q?=E5=A4=9A=E4=BD=99=E5=B8=B8=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/actions/replace/ui/ITCheckDialog.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITCheckDialog.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITCheckDialog.java index e597e3172e..3c586fac4e 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITCheckDialog.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITCheckDialog.java @@ -32,8 +32,6 @@ public class ITCheckDialog extends UIDialog { private static final int TABLE_WIDTH = 640, TABLE_HEIGHT = 320; private static final int LABEL_HEIGHT = 20; - public static final Object[] columnTitle = {Toolkit.i18nText("Fine-Design_Replace_Check_Content"), Toolkit.i18nText("Fine-Design_Replace_Check_Reason")}; - public ITCheckDialog() { super(ITReplaceMainDialog.getInstance()); setTitle(Toolkit.i18nText("Fine-Design_Replace_Check_Title")); From faa21e95f9c5e446748a70a36da657a59b6d9f1b Mon Sep 17 00:00:00 2001 From: "John.Ying" Date: Mon, 31 Oct 2022 00:09:03 +0800 Subject: [PATCH 34/63] =?UTF-8?q?REPORT-80513=20=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E5=A4=A7=E6=95=B0=E6=8D=AE=E6=94=AF=E6=8C=81csv?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/fit/menupane/FitRadioGroup.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/designer-form/src/main/java/com/fr/design/fit/menupane/FitRadioGroup.java b/designer-form/src/main/java/com/fr/design/fit/menupane/FitRadioGroup.java index 46fb327686..70bf18fd69 100644 --- a/designer-form/src/main/java/com/fr/design/fit/menupane/FitRadioGroup.java +++ b/designer-form/src/main/java/com/fr/design/fit/menupane/FitRadioGroup.java @@ -77,4 +77,12 @@ public class FitRadioGroup extends ButtonGroup { } } + /** + * + * @return 被选中的按钮 + */ + public UIRadioButton getSelectedButton() { + return radioButtons.get(this.getSelectRadioIndex()); + } + } From 193473d4e3e782e11ac34d1e386f3d9b5dbd1773 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Mon, 31 Oct 2022 14:43:22 +0800 Subject: [PATCH 35/63] =?UTF-8?q?REPORT-80695=20=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E5=85=A8=E5=B1=80=E7=BA=A7=E5=88=AB=E6=9F=A5=E6=89=BE=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2=E4=BA=8C=E6=9C=9F=20=E4=BF=AE=E5=A4=8D=E4=B8=8B?= =?UTF-8?q?=E6=8B=89=E6=A1=86=E5=86=85=E5=AE=B9=E4=B8=8E=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E4=B8=8D=E5=8C=B9=E9=85=8D=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=8C=E5=AE=8C=E5=96=84=E5=8D=95=E5=85=83=E6=A0=BC=E8=BF=87?= =?UTF-8?q?=E6=BB=A4=EF=BC=8C=E5=A2=9E=E5=8A=A0=E8=AE=BE=E7=BD=AE=E9=A1=B9?= =?UTF-8?q?=E3=80=81SQL=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../action/setting/CellFormatType.java | 69 +++++++++++++++++-- .../action/setting/SettingController.java | 13 ++++ .../action/SearchCellFormatAction.java | 17 +++-- .../design/actions/replace/info/SQLInfo.java | 9 +++ .../replace/ui/ITReplaceNorthPanel.java | 15 ++-- 5 files changed, 106 insertions(+), 17 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellFormatType.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellFormatType.java index ab2a71ba97..a468dc995c 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellFormatType.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellFormatType.java @@ -35,7 +35,7 @@ public enum CellFormatType { @Override public List getItems() { - return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_NUMBER))); + return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_NUMBER), false)); } @Override @@ -57,6 +57,12 @@ public enum CellFormatType { public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) { return cellElement.getStyle().getFormat() == null; } + + @Override + public boolean isEverChanged(Info info, String inputStr, String extraStr) { + CellElement cellElement = (CellElement) info.getContent().getReplaceObject(); + return (cellElement.getStyle() != null && cellElement.getStyle().getFormat() == null); + } }, /** * 单元格-格式-货币 @@ -69,7 +75,7 @@ public enum CellFormatType { @Override public List getItems() { - return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_MONEY))); + return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_MONEY), false)); } @Override @@ -89,7 +95,7 @@ public enum CellFormatType { @Override public List getItems() { - return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_DATE))); + return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_DATE), false)); } @Override @@ -97,6 +103,11 @@ public enum CellFormatType { Format format = cellElement.getStyle().getFormat(); return format instanceof FineDateFormat && StringUtils.equals(((FineDateFormat) format).toPattern(), secondStr); } + + @Override + public boolean isEverChanged(Info info, String inputStr, String extraStr) { + return isEverChanged4FineDataFormat(info, extraStr); + } }, /** * 单元格-格式-时间 @@ -109,7 +120,7 @@ public enum CellFormatType { @Override public List getItems() { - return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_TIME))); + return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_TIME), false)); } @Override @@ -117,6 +128,11 @@ public enum CellFormatType { Format format = cellElement.getStyle().getFormat(); return format instanceof FineDateFormat && StringUtils.equals(((FineDateFormat) format).toPattern(), secondStr); } + + @Override + public boolean isEverChanged(Info info, String inputStr, String extraStr) { + return isEverChanged4FineDataFormat(info, extraStr); + } }, /** * 单元格-格式-科学计数 @@ -129,7 +145,7 @@ public enum CellFormatType { @Override public List getItems() { - return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_SCIENCE))); + return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_SCIENCE), false)); } @Override @@ -149,7 +165,7 @@ public enum CellFormatType { @Override public List getItems() { - return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_PERCENT))); + return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_PERCENT), false)); } @Override @@ -169,7 +185,7 @@ public enum CellFormatType { @Override public List getItems() { - return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_PERMILLAGE))); + return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_PERMILLAGE), false)); } @Override @@ -187,6 +203,14 @@ public enum CellFormatType { Format format = cellElement.getStyle().getFormat(); return format instanceof TextFormat; } + + @Override + public boolean isEverChanged(Info info, String inputStr, String extraStr) { + CellElement cellElement = (CellElement) info.getContent().getReplaceObject(); + return !(cellElement.getStyle() != null + && cellElement.getStyle().getFormat() != null + && cellElement.getStyle().getFormat() instanceof TextFormat); + } }; @@ -256,4 +280,35 @@ public enum CellFormatType { ((NameStyle) cellElement.getStyle()).refreshStyle(); } } + + /** + * 是否修改过 + * + * @param info 存储单元格信息的数据结构 + * @param inputStr 用户输入的第一级下拉框内容 + * @param extraStr 用户输入的第二级下拉框内容 + * @return 修改过返回true + */ + public boolean isEverChanged(Info info, String inputStr, String extraStr) { + CellElement cellElement = (CellElement) info.getContent().getReplaceObject(); + return !(cellElement.getStyle() != null + && cellElement.getStyle().getFormat() != null + && cellElement.getStyle().getFormat() instanceof CoreDecimalFormat + && StringUtils.equals(((CoreDecimalFormat) cellElement.getStyle().getFormat()).toPattern(), extraStr)); + } + + /** + * 针对日期和时间类型的修改判定 + * + * @param info 存储单元格信息的数据结构 + * @param extraStr 用户输入的第二级下拉框内容 + * @return 修改过返回true + */ + public boolean isEverChanged4FineDataFormat(Info info, String extraStr) { + CellElement cellElement = (CellElement) info.getContent().getReplaceObject(); + return !(cellElement.getStyle() != null + && cellElement.getStyle().getFormat() != null + && cellElement.getStyle().getFormat() instanceof FineDateFormat + && StringUtils.equals(((FineDateFormat) cellElement.getStyle().getFormat()).toPattern(), extraStr)); + } } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/SettingController.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/SettingController.java index 8dd29b2364..0b481a1272 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/SettingController.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/SettingController.java @@ -10,6 +10,7 @@ import com.fr.design.actions.replace.action.setting.action.SearchDSColumnAction; import com.fr.design.actions.replace.info.CellInfo; import com.fr.design.actions.replace.info.DataSourceInfo; import com.fr.design.actions.replace.info.Info; +import com.fr.design.actions.replace.info.ReplaceObject; import com.fr.design.actions.replace.ui.ITReplaceNorthPanel; import com.fr.design.data.DesignTableDataManager; import com.fr.design.file.HistoryTemplateListCache; @@ -88,6 +89,18 @@ public enum SettingController implements ShowValue { type.replace(info, firstStr, secondStr); } } + + @Override + public boolean isEverChanged(Info info, String inputStr, String extraStr) { + CellElement cellElement = (CellElement) info.getContent().getReplaceObject(); + if (cellElement.getStyle() != null) { + CellFormatType type = CellFormatType.match(inputStr); + if (type != null) { + return type.isEverChanged(info, inputStr, extraStr); + } + } + return false; + } }, /** * 单元格-数据设置 diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchCellFormatAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchCellFormatAction.java index 016f6b259b..e7c8e45dd4 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchCellFormatAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchCellFormatAction.java @@ -1,13 +1,16 @@ package com.fr.design.actions.replace.action.setting.action; -import com.fr.base.Formula; +import com.fr.chart.chartattr.ChartCollection; import com.fr.design.actions.replace.action.SearchAction; import com.fr.design.actions.replace.action.content.cell.SearchCellAction; import com.fr.design.actions.replace.info.CellInfo; import com.fr.design.mainframe.JTemplate; import com.fr.general.GeneralUtils; +import com.fr.general.ImageWithSuffix; import com.fr.report.cell.CellElement; -import com.fr.report.cell.cellattr.core.group.DSColumn; +import com.fr.report.cell.cellattr.core.RichText; +import com.fr.report.cell.cellattr.core.SubReport; +import com.fr.report.cell.painter.BiasTextPainter; import java.util.ArrayList; import java.util.List; @@ -47,10 +50,12 @@ public class SearchCellFormatAction implements SearchAction { */ public boolean isFormatValid(CellElement cellElement) { return cellElement.getStyle() != null - && (cellElement.getValue() instanceof Formula - || cellElement.getValue() instanceof DSColumn - || cellElement.getValue() instanceof String - || cellElement.getValue() instanceof Integer); + && !(cellElement.getValue() instanceof SubReport + || cellElement.getValue() instanceof BiasTextPainter + || cellElement.getValue() instanceof ChartCollection + || cellElement.getValue() instanceof RichText + || cellElement.getValue() instanceof ImageWithSuffix + ); } public List getCellInfos() { diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/SQLInfo.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/SQLInfo.java index 6006c83754..0fdbbb86de 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/info/SQLInfo.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/SQLInfo.java @@ -68,4 +68,13 @@ public class SQLInfo implements Info { public String getInfoShowStr(Info info) { return this.getContent().getOldShowStr(); } + + @Override + public Boolean checkValid() { + ReplaceObject o = ReplaceObject.match(this.content.getReplaceObject().getClass().getSimpleName()); + if (o != null) { + return o.check(this); + } + return false; + } } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java index 16d2926a60..913150dcd3 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java @@ -249,11 +249,9 @@ public class ITReplaceNorthPanel { }; replaceSettingInputComboBox.setSelectedIndex(-1); - - ((UITextField) (findSettingInputComboBox.getEditor().getEditorComponent())).setPlaceholder(Toolkit.i18nText("Fine-Design_Replace_Choose_Search") + SettingContent.CELL_FORMAT_NAME); + updateSettingPlaceholder(SettingContent.CELL_FORMAT_NAME); findSettingInputComboBox.setEditable(true); ((UITextField) (findSettingInputComboBox.getEditor().getEditorComponent())).setEditable(false); - ((UITextField) (replaceSettingInputComboBox.getEditor().getEditorComponent())).setPlaceholder(Toolkit.i18nText("Fine-Design_Replace_Choose_Replace") + SettingContent.CELL_FORMAT_NAME); replaceSettingInputComboBox.setEditable(true); ((UITextField) (replaceSettingInputComboBox.getEditor().getEditorComponent())).setEditable(false); @@ -301,7 +299,7 @@ public class ITReplaceNorthPanel { refreshSettingComboBox(SettingController.getSettingRefreshItems(str)); setDataSourceComboBoxStatus(isAllow2Replace()); replaceSettingButton.setEnabled(false); - + updateSettingPlaceholder(str); } }); @@ -784,4 +782,13 @@ public class ITReplaceNorthPanel { public void setSettingResultLabel(UILabel settingResultLabel) { this.settingResultLabel = settingResultLabel; } + + /** + * 更新展示的默认值 + * @param str 默认值 + */ + public void updateSettingPlaceholder(String str) { + ((UITextField) (findSettingInputComboBox.getEditor().getEditorComponent())).setPlaceholder(Toolkit.i18nText("Fine-Design_Replace_Choose_Search") + str); + ((UITextField) (replaceSettingInputComboBox.getEditor().getEditorComponent())).setPlaceholder(Toolkit.i18nText("Fine-Design_Replace_Choose_Replace") + str); + } } From a9314ea89a7fa66dbf2793b3d1574e017e44b6a6 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Mon, 31 Oct 2022 15:09:39 +0800 Subject: [PATCH 36/63] =?UTF-8?q?REPORT-80695=20=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E5=85=A8=E5=B1=80=E7=BA=A7=E5=88=AB=E6=9F=A5=E6=89=BE=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2=E4=BA=8C=E6=9C=9F=20=E5=A2=9E=E5=8A=A0=E5=85=B3?= =?UTF-8?q?=E9=97=AD=E9=9D=A2=E6=9D=BF=E5=90=8E=E7=9A=84=E6=B8=85=E9=99=A4?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=8A=A8=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../replace/ui/ITReplaceMainDialog.java | 19 +++++++++++++++++++ .../replace/ui/ITReplaceNorthPanel.java | 8 ++++++++ 2 files changed, 27 insertions(+) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java index 868ad8ad2a..27162e863d 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java @@ -25,11 +25,15 @@ import com.fr.stable.StringUtils; import javax.swing.JOptionPane; import javax.swing.JPanel; +import javax.swing.WindowConstants; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.event.WindowListener; import java.util.ArrayList; import java.util.List; @@ -132,6 +136,7 @@ public class ITReplaceMainDialog extends UIDialog { southPanel = new ITReplaceSouthPanel(); westPanel = new ITReplaceWestPanel(); + initCloseListener(); northPane.fitScreen(0, 0, jTemplate.getWidth()); JPanel center = new JPanel(new BorderLayout()); @@ -187,6 +192,20 @@ public class ITReplaceMainDialog extends UIDialog { center.setVisible(true); } + private void initCloseListener() { + this.addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + searchContentResultList.clear(); + searchSettingResultList.clear(); + ITReplaceSouthPanel.getItTableEditor().clear(); + northPane.clear(); + dialogExit(); + } + + }); + } + /** * 模板内容替换相关 */ diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java index 913150dcd3..977d819807 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java @@ -791,4 +791,12 @@ public class ITReplaceNorthPanel { ((UITextField) (findSettingInputComboBox.getEditor().getEditorComponent())).setPlaceholder(Toolkit.i18nText("Fine-Design_Replace_Choose_Search") + str); ((UITextField) (replaceSettingInputComboBox.getEditor().getEditorComponent())).setPlaceholder(Toolkit.i18nText("Fine-Design_Replace_Choose_Replace") + str); } + + /** + * 清除搜索结果 + */ + public void clear() { + settingResultLabel.setText(StringUtils.EMPTY); + resultLabel.setText(StringUtils.EMPTY); + } } From cdf23d5e87686b4916583d09831516378931b61f Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Mon, 31 Oct 2022 15:10:35 +0800 Subject: [PATCH 37/63] =?UTF-8?q?REPORT-80695=20=E5=8E=BB=E9=99=A4?= =?UTF-8?q?=E5=A4=9A=E4=BD=99=E5=BC=95=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/actions/replace/ui/ITReplaceMainDialog.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java index 27162e863d..7f2530d2c6 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java @@ -25,7 +25,6 @@ import com.fr.stable.StringUtils; import javax.swing.JOptionPane; import javax.swing.JPanel; -import javax.swing.WindowConstants; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.Point; @@ -33,7 +32,6 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; -import java.awt.event.WindowListener; import java.util.ArrayList; import java.util.List; From a138f031ef82fb382c8ad689fda4baa4682541d1 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Mon, 31 Oct 2022 16:40:49 +0800 Subject: [PATCH 38/63] =?UTF-8?q?REPORT-80695=20=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E5=85=A8=E5=B1=80=E6=9F=A5=E6=89=BE=E6=9B=BF=E6=8D=A2=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A0=A1=E9=AA=8C=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E5=8F=AA=E5=85=81=E8=AE=B8=E7=BB=84=E4=BB=B6=E5=92=8C=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E9=9D=A2=E6=9D=BF=E6=8E=A7=E4=BB=B6=E5=8F=82=E4=B8=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../action/content/widget/FrmWidgetType.java | 2 +- .../content/widget/SearchWidgetAction.java | 2 +- .../actions/replace/info/WidgetInfo.java | 23 +++++- .../actions/replace/ui/ITCheckDialog.java | 1 + .../replace/ui/ITReplaceMainDialog.java | 14 +++- .../actions/replace/utils/CheckUtils.java | 77 +++++++++++++++++++ 6 files changed, 111 insertions(+), 8 deletions(-) create mode 100644 designer-realize/src/main/java/com/fr/design/actions/replace/utils/CheckUtils.java diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/widget/FrmWidgetType.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/widget/FrmWidgetType.java index 5aa8e208c5..8c6333e11a 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/widget/FrmWidgetType.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/widget/FrmWidgetType.java @@ -130,7 +130,7 @@ public enum FrmWidgetType implements SearchFrmWidget, DealWithInfoValue { public List dealAbsoluteWidget(ITContent content, Widget widget) { ArrayList widgetInfos = new ArrayList<>(); ITContent newContent = ITContent.copy(content); - widgetInfos.add(new WidgetInfo(newContent)); + widgetInfos.add(new WidgetInfo(newContent, true)); return widgetInfos; } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/widget/SearchWidgetAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/widget/SearchWidgetAction.java index 32a21bee54..63b5df9d8f 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/widget/SearchWidgetAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/widget/SearchWidgetAction.java @@ -148,7 +148,7 @@ public class SearchWidgetAction implements SearchAction { newContent.setReplaceObject(widget); newContent.setJumpAble(false); newContent.setShowObject(Toolkit.i18nText("Fine-Design_Parameter_Panel")); - widgetInfos.add(new WidgetInfo(newContent)); + widgetInfos.add(new WidgetInfo(newContent, true)); } } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/WidgetInfo.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/WidgetInfo.java index 7adfc01536..4ebae73da9 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/info/WidgetInfo.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/WidgetInfo.java @@ -3,6 +3,7 @@ package com.fr.design.actions.replace.info; import com.fr.design.actions.replace.action.content.widget.FrmWidgetType; import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.actions.replace.utils.CheckUtils; import com.fr.design.actions.replace.utils.ShowValueUtils; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.JTemplate; @@ -30,11 +31,17 @@ import java.util.Map; public class WidgetInfo implements Info, DealWithInfoValue { private ITContent content; private boolean waterMarkFlag = true; + private boolean need2Check = false; public WidgetInfo(ITContent content) { this.content = content; } + public WidgetInfo(ITContent content, boolean need2Check) { + this.content = content; + this.need2Check = need2Check; + } + @Override public ITContent getContent() { return content; @@ -96,7 +103,9 @@ public class WidgetInfo implements Info, DealWithInfoValue { */ public WidgetInfo copy(WidgetInfo widgetInfo) { ITContent content = ITContent.copy(widgetInfo.getContent()); - return new WidgetInfo(content); + WidgetInfo info = new WidgetInfo(content); + info.setNeed2Check(widgetInfo.isNeed2Check()); + return info; } /** @@ -112,6 +121,14 @@ public class WidgetInfo implements Info, DealWithInfoValue { this.waterMarkFlag = waterMarkFlag; } + public boolean isNeed2Check() { + return need2Check; + } + + public void setNeed2Check(boolean need2Check) { + this.need2Check = need2Check; + } + /** * ReplaceObject是否存在 * @@ -138,9 +155,9 @@ public class WidgetInfo implements Info, DealWithInfoValue { this.getContent().setCheckStr(Toolkit.i18nText("Fine-Design_Replace_Not_Empty")); return false; } - if (!this.isWaterMark()) { + if (!this.isWaterMark() && this.isNeed2Check()) { String replacedName = ((Widget)this.getContent().getReplaceObject()).getWidgetName().replace(searchStr, replaceStr); - for (WidgetName name : jTemplate.getModel().getWidgetsName()) { + for (WidgetName name : CheckUtils.getNeed2CheckWidgetsName(jTemplate)) { String widgetName = name.getName(); if (StringUtils.equals(replacedName, widgetName)) { this.getContent().setCheckStr(Toolkit.i18nText("Fine-Design_Replace_Exist_Same_Name")); diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITCheckDialog.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITCheckDialog.java index 3c586fac4e..9b82dea3ce 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITCheckDialog.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITCheckDialog.java @@ -34,6 +34,7 @@ public class ITCheckDialog extends UIDialog { public ITCheckDialog() { super(ITReplaceMainDialog.getInstance()); + setModal(true); setTitle(Toolkit.i18nText("Fine-Design_Replace_Check_Title")); JPanel centerPanel = new JPanel(); JPanel southPanel = new JPanel(); diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java index 7f2530d2c6..7fa5ad2804 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java @@ -213,7 +213,13 @@ public class ITReplaceMainDialog extends UIDialog { clearContentCount(); if (isITReplaceValid() && checkTemplateChanged(searchContentResultList)) { if (StringUtils.equals(getSearchStr(), searchStr)) { - checkLegalValiditySelector(searchStr, replaceStr); + String str = GeneralUtils.objectToString(northPane.getFindCombobox().getSelectedItem()); + //如果是控件或组件才要进行合法性校验 + if (StringUtils.equals(str, Toolkit.i18nText("Fine-Design_Replace_Component")) || StringUtils.equals(str, Toolkit.i18nText("Fine-Design_Basic_Widget"))) { + checkLegalValiditySelector(searchStr, replaceStr); + } else { + replace(searchStr, replaceStr); + } } else { search4Content(); } @@ -273,9 +279,9 @@ public class ITReplaceMainDialog extends UIDialog { options, options[0] ); + updateCheckValidList(); //如果选择了直接替换,则直接执行替换 if (optionSelected == 1) { - updateCheckValidList(); replace(searchStr, replaceStr); } else { checkLegalValidity(); @@ -286,7 +292,6 @@ public class ITReplaceMainDialog extends UIDialog { * 检测 */ public void checkLegalValidity() { - updateCheckValidList(); if (contentReplaceFailedCount == 0) { ToastMsgDialog dialog = DesignerToastMsgUtil.createPromptDialog(Toolkit.i18nText("Fine-Design_Replace_Check_None")); dialog.setVisible(true); @@ -308,12 +313,15 @@ public class ITReplaceMainDialog extends UIDialog { checkValidList.add(info); serialNumber.add(count); info.getContent().setWrongful(true); + info.getContent().setReplaced(true); } else { contentReplaceCount++; } count++; } } + southPanel.getTableEditorPane().update(); + ITTableEditorPane.getEditTable().repaint(); } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/CheckUtils.java b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/CheckUtils.java new file mode 100644 index 0000000000..18020aaf74 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/CheckUtils.java @@ -0,0 +1,77 @@ +package com.fr.design.actions.replace.utils; + +import com.fr.design.mainframe.JTemplate; +import com.fr.form.main.Form; +import com.fr.form.main.WidgetGatherAdapter; +import com.fr.form.ui.Widget; +import com.fr.main.impl.WorkBook; +import com.fr.main.impl.WorkBookHelper; +import com.fr.stable.Filter; +import com.fr.stable.StringUtils; +import com.fr.stable.js.WidgetName; + +import java.util.ArrayList; +import java.util.List; + +/** + * 用于合法性检验相关的工具类 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-10-31 + */ +public class CheckUtils { + + /** + * 获取需要检测的控件名称 + * + * @param jTemplate 模板 + * @return 控件名称列表 + */ + public static List getNeed2CheckWidgetsName(JTemplate jTemplate) { + if (jTemplate.getTarget() instanceof WorkBook) { + return getWorkBookNeedWidgetsName((WorkBook) jTemplate.getTarget()); + } else if (jTemplate.getTarget() instanceof Form) { + return getFormNeedWidgetsName((Form) jTemplate.getTarget()); + } + return new ArrayList<>(); + } + + private static List getFormNeedWidgetsName(Form target) { + final List list = new ArrayList(); + Form.traversalFormWidget(target.getContainer(), new WidgetGatherAdapter() { + + @Override + public void dealWith(Widget widget) { + if (widgetAccepted(widget)) { + list.add(new WidgetName(widget.getWidgetName())); + } + } + + @Override + public boolean dealWithAllCards() { + return true; + } + }); + return list; + } + + private static List getWorkBookNeedWidgetsName(WorkBook wb) { + return WorkBookHelper.listWidgetNamesInWorkBook(wb, new Filter() { + @Override + public boolean accept(Widget widget) { + return widgetAccepted(widget); + } + }, new Filter() { + @Override + public boolean accept(Widget widget) { + return false; + } + }); + } + + + private static boolean widgetAccepted(Widget widget) { + return widget != null && StringUtils.isNotEmpty(widget.getWidgetName()); + } +} From db42b4e512b111963b2dae894b4d906b866206ce Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Mon, 31 Oct 2022 16:47:26 +0800 Subject: [PATCH 39/63] =?UTF-8?q?REPORT-80695=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E9=AD=94=E6=B3=95=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/actions/replace/ui/ITReplaceMainDialog.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java index 7fa5ad2804..b2ae3cae09 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java @@ -73,6 +73,8 @@ public class ITReplaceMainDialog extends UIDialog { public static int contentReplaceFailedCount = 0; public static int settingReplaceCount = 0; public static int settingReplaceFailedCount = 0; + public static final String COMPONENT = Toolkit.i18nText("Fine-Design_Replace_Component"); + public static final String WIDGET = Toolkit.i18nText("Fine-Design_Basic_Widget"); public ITReplaceMainDialog() { @@ -215,7 +217,7 @@ public class ITReplaceMainDialog extends UIDialog { if (StringUtils.equals(getSearchStr(), searchStr)) { String str = GeneralUtils.objectToString(northPane.getFindCombobox().getSelectedItem()); //如果是控件或组件才要进行合法性校验 - if (StringUtils.equals(str, Toolkit.i18nText("Fine-Design_Replace_Component")) || StringUtils.equals(str, Toolkit.i18nText("Fine-Design_Basic_Widget"))) { + if (StringUtils.equals(str, COMPONENT) || StringUtils.equals(str, WIDGET)) { checkLegalValiditySelector(searchStr, replaceStr); } else { replace(searchStr, replaceStr); From 62affbceb37acda679ed4603c84ad8772f1ed26d Mon Sep 17 00:00:00 2001 From: "Leo.Qin" Date: Tue, 1 Nov 2022 11:21:02 +0800 Subject: [PATCH 40/63] =?UTF-8?q?REPORT-83305=20=E3=80=90=E6=89=B9?= =?UTF-8?q?=E9=87=8F=E6=93=8D=E4=BD=9C=E5=8D=95=E5=85=83=E6=A0=BC=E3=80=91?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A0=BC=E5=BC=8F->=E6=92=A4=E9=94=80?= =?UTF-8?q?=EF=BC=8C=E6=A0=BC=E5=BC=8F=E6=81=A2=E5=A4=8D=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=20=E3=80=90=E9=97=AE=E9=A2=98=E5=8E=9F=E5=9B=A0=E3=80=91?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E4=B8=8D=E5=90=8C=E6=A0=BC=E5=BC=8F=EF=BC=8C?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E9=9D=A2=E6=9D=BF=E5=8F=91=E7=94=9F=E5=A4=9A?= =?UTF-8?q?=E6=AC=A1=E5=8F=98=E5=8C=96=EF=BC=8C=E5=AF=BC=E8=87=B4=E5=A4=9A?= =?UTF-8?q?=E6=AC=A1=E8=A7=A6=E5=8F=91=E4=BF=9D=E5=AD=98=20=E3=80=90?= =?UTF-8?q?=E6=94=B9=E5=8A=A8=E6=80=9D=E8=B7=AF=E3=80=91=E6=9B=B4=E6=94=B9?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E4=BF=AE=E6=94=B9=E6=96=B9=E5=BC=8F=20?= =?UTF-8?q?=E3=80=90review=E5=BB=BA=E8=AE=AE=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/style/TextFormatPaneContainer.java | 72 +++++ .../dscolumn/ResultSetGroupDockingPane.java | 12 +- .../design/dscolumn/ResultSetGroupPane.java | 4 - .../dscolumn/SelectedDataColumnPane.java | 10 + .../com/fr/grid/selection/CellSelection.java | 10 +- .../com/fr/quickeditor/CellQuickEditor.java | 301 ++++++++---------- .../cellquick/CellDSColumnEditor.java | 241 +++----------- 7 files changed, 282 insertions(+), 368 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/gui/style/TextFormatPaneContainer.java diff --git a/designer-base/src/main/java/com/fr/design/gui/style/TextFormatPaneContainer.java b/designer-base/src/main/java/com/fr/design/gui/style/TextFormatPaneContainer.java new file mode 100644 index 0000000000..3d2b658670 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/style/TextFormatPaneContainer.java @@ -0,0 +1,72 @@ +package com.fr.design.gui.style; + +import com.fr.base.Style; +import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; +import com.fr.design.gui.frpane.AttributeChangeListener; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.text.Format; + +/** + * 封装格式panel,管理 AttributeChangeListener + * + * @author Leo.Qin + * @version 11.0 + * Created by Leo.Qin on 2022/10/31 + */ +public class TextFormatPaneContainer extends AbstractAttrNoScrollPane { + private TextFormatPane formatPane; + private AttributeChangeListener oldListner; + + @Override + protected JPanel createContentPane() { + formatPane = new TextFormatPane(); + return formatPane; + } + + protected void initContentPane() { + leftContentPane = createContentPane(); + if (leftContentPane != null) { + leftContentPane.setBorder(BorderFactory.createEmptyBorder()); + this.add(leftContentPane, BorderLayout.CENTER); + } + } + + @Override + public Dimension getPreferredSize() { + if (formatPane == null) { + return super.getPreferredSize(); + } + return formatPane.getPreferredSize(); + } + + public void populateBean(Style style) { + formatPane.populateBean(style); + } + + public Format update() { + return formatPane.update(); + } + + public Style update(Style style) { + return formatPane.update(style); + } + + @Override + public void removeAttributeChangeListener() { + super.removeAttributeChangeListener(); + } + + @Override + public void addAttributeChangeListener(AttributeChangeListener listener) { + oldListner = listener; + super.addAttributeChangeListener(listener); + } + + public void restoreAttributeChangeListener() { + super.addAttributeChangeListener(oldListner); + } +} diff --git a/designer-realize/src/main/java/com/fr/design/dscolumn/ResultSetGroupDockingPane.java b/designer-realize/src/main/java/com/fr/design/dscolumn/ResultSetGroupDockingPane.java index a485fab05d..2c994cc7be 100644 --- a/designer-realize/src/main/java/com/fr/design/dscolumn/ResultSetGroupDockingPane.java +++ b/designer-realize/src/main/java/com/fr/design/dscolumn/ResultSetGroupDockingPane.java @@ -229,7 +229,7 @@ public class ResultSetGroupDockingPane extends ResultSetGroupPane { } void fireTargetChanged() { - listener.itemStateChanged(null); + } @Override @@ -249,8 +249,16 @@ public class ResultSetGroupDockingPane extends ResultSetGroupPane { functionComboBox.removeItemListener(this.listener); } - @Override public void update(Set cellElements) { cellElements.forEach(this::updateCellElement); } + + @Override + public Dimension getPreferredSize() { + if (this.isVisible()) { + return super.getPreferredSize(); + } else { + return new Dimension(); + } + } } \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/design/dscolumn/ResultSetGroupPane.java b/designer-realize/src/main/java/com/fr/design/dscolumn/ResultSetGroupPane.java index 2fb7b98496..3741ba8296 100644 --- a/designer-realize/src/main/java/com/fr/design/dscolumn/ResultSetGroupPane.java +++ b/designer-realize/src/main/java/com/fr/design/dscolumn/ResultSetGroupPane.java @@ -47,9 +47,6 @@ public abstract class ResultSetGroupPane extends JPanel { abstract void setRecordGrouper(RecordGrouper recordGrouper); - void fireTargetChanged() { - }; - ActionListener groupAdvancedListener = new ActionListener() { public void actionPerformed(ActionEvent evt) { if (cellElement == null) { @@ -75,7 +72,6 @@ public abstract class ResultSetGroupPane extends JPanel { dSColumn.setGrouper(rg); } setRecordGrouper(rg); - fireTargetChanged(); JTemplate targetComponent = DesignerContext.getDesignerFrame().getSelectedJTemplate(); if (targetComponent != null) { targetComponent.fireTargetModified(); diff --git a/designer-realize/src/main/java/com/fr/design/dscolumn/SelectedDataColumnPane.java b/designer-realize/src/main/java/com/fr/design/dscolumn/SelectedDataColumnPane.java index ad670abf33..052fba9046 100644 --- a/designer-realize/src/main/java/com/fr/design/dscolumn/SelectedDataColumnPane.java +++ b/designer-realize/src/main/java/com/fr/design/dscolumn/SelectedDataColumnPane.java @@ -392,4 +392,14 @@ public class SelectedDataColumnPane extends BasicPane { } return new ArrayList<>(); } + + @Override + public Dimension getPreferredSize() { + if (this.isVisible()) { + return super.getPreferredSize(); + } + else { + return new Dimension(); + } + } } diff --git a/designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java b/designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java index 4d3568cd86..b5419cf391 100644 --- a/designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java +++ b/designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java @@ -70,6 +70,7 @@ public class CellSelection extends Selection { private Rectangle editRectangle = new Rectangle(0, 0, 1, 1); private List cellRectangleList = new ArrayList(); + private Set cellElements = new HashSet<>(); public CellSelection() { this(0, 0, 1, 1); @@ -745,9 +746,10 @@ public class CellSelection extends Selection { if (cellElement != null) { value = cellElement.getValue(); } - Set allCellElement = getAllCellElements(tplEC); - boolean sameType = checkSameType(allCellElement); + cellElements = getAllCellElements(tplEC); + + boolean sameType = checkSameType(cellElements); // 多选时,多元格元素类型 value = sameType && value != null ? value : StringUtils.EMPTY; @@ -813,6 +815,10 @@ public class CellSelection extends Selection { return cellElements; } + public Set getCellElements() { + return cellElements; + } + @Override public void populatePropertyPane(ElementCasePane ePane) { CellElementPropertyPane.getInstance().reInit(ePane); diff --git a/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java b/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java index 107b06e5e9..6f060b4f06 100644 --- a/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java +++ b/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java @@ -5,13 +5,12 @@ import com.fr.base.Style; import com.fr.design.actions.UpdateAction; import com.fr.design.actions.core.ActionFactory; import com.fr.design.file.HistoryTemplateListCache; -import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.iscrollbar.UIScrollBar; import com.fr.design.gui.itextfield.UITextField; -import com.fr.design.gui.style.TextFormatPane; +import com.fr.design.gui.style.TextFormatPaneContainer; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; @@ -35,8 +34,8 @@ import javax.swing.JComponent; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollBar; +import javax.swing.SwingUtilities; import java.awt.BorderLayout; -import java.awt.CardLayout; import java.awt.Component; import java.awt.Container; import java.awt.Dimension; @@ -46,6 +45,7 @@ import java.awt.event.AdjustmentEvent; import java.awt.event.AdjustmentListener; import java.awt.event.MouseWheelEvent; import java.awt.event.MouseWheelListener; +import java.text.Format; import java.util.ArrayList; import java.util.Objects; import java.util.Set; @@ -67,12 +67,7 @@ public abstract class CellQuickEditor extends QuickEditor { private static final int CONTENT_PANE_WIDTH_GAP = 3; private static final int MOUSE_WHEEL_SPEED = 5; private static final int SCROLLBAR_WIDTH = 7; - - /** - * 区分单选多选单元格,生成相应设置面板 - */ - private final String SINGLE_SELECT = "singleSelect"; - private final String MULTIPLE_SELECT = "multipleSelect"; + private UILabel cellLabel; private int maxHeight = 280; private static final int TITLE_HEIGHT = 50; @@ -82,21 +77,16 @@ public abstract class CellQuickEditor extends QuickEditor { */ protected UITextField columnRowTextField; protected TemplateCellElement cellElement; - private TextFormatPane formatPane; - private final JPanel topContentContainer; - private final JComponent centerBodyContainer; + private TextFormatPaneContainer formatPane; + private JPanel topContentContainer; + private JComponent centerBodyContainer; + private UILabel multipleLabelTip; - private CardLayout topCardLayout; - /** - * 不同单元格元素产生的面板 - */ - private CardLayout centerCardLayout; // 占位label protected final UILabel EMPTY_LABEL = new UILabel(); - private UIComboBox singleComboBox; - private UIComboBox multipleComboBox; + private UIComboBox comboBox; private UpdateAction[] cellInsertActions; private int selectedIndex; @@ -106,23 +96,38 @@ public abstract class CellQuickEditor extends QuickEditor { private ActionListener comboBoxActionListener; public CellQuickEditor() { + + initComponents(); + + createPanelBody(); + } + + private void initComponents() { EMPTY_LABEL.setPreferredSize(LABEL_DIMENSION); + topContentContainer = initTopContent(); + formatPane = createFormatPane(); + centerBodyContainer = createCenterBody(); + + multipleLabelTip = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Basic_Cell_Element_Multiple_Tip")); + multipleLabelTip.setEnabled(false); + } + + private void createPanelBody() { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; - double[] columnSize = {p, f}; - JPanel formatContainerPanel = createFormatPane(); - topContentContainer = initTopContent(); - centerBodyContainer = createAllCenterBody(); + double[] columnSize = {f}; if (isScrollAll()) { - double[] scrollAllRowSize = {p, p, p}; + double[] scrollAllRowSize = {p, p, p, p}; prepareScrollBar(); - topContentContainer.setBorder(BorderFactory.createMatteBorder(10, 10, 0, 0, this.getBackground())); - formatContainerPanel.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 0, this.getBackground())); + multipleLabelTip.setBorder(BorderFactory.createMatteBorder(5, 10, 0, 0, this.getBackground())); + topContentContainer.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 0, this.getBackground())); + formatPane.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 0, this.getBackground())); centerBodyContainer.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 0, this.getBackground())); Component[][] components = new Component[][]{ - new Component[]{topContentContainer, null}, - new Component[]{formatContainerPanel, null}, - new Component[]{centerBodyContainer, null} + new Component[]{multipleLabelTip}, + new Component[]{topContentContainer}, + new Component[]{formatPane}, + new Component[]{centerBodyContainer} }; leftContentPane = TableLayoutHelper.createGapTableLayoutPane(components, scrollAllRowSize, columnSize, HGAP, VGAP); this.setLayout(new CellElementBarLayout(leftContentPane) { @@ -151,14 +156,16 @@ public abstract class CellQuickEditor extends QuickEditor { this.add(scrollBar); this.add(leftContentPane); } else { - double[] scrollContentRowSize = {p, p, f}; - topContentContainer.setBorder(BorderFactory.createMatteBorder(10, 10, 0, 10, this.getBackground())); - formatContainerPanel.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 10, this.getBackground())); + double[] scrollContentRowSize = {p, p, p, f}; + multipleLabelTip.setBorder(BorderFactory.createMatteBorder(5, 10, 0, 0, this.getBackground())); + topContentContainer.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 10, this.getBackground())); + formatPane.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 10, this.getBackground())); centerBodyContainer.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 0, this.getBackground())); Component[][] components = new Component[][]{ - new Component[]{topContentContainer, null}, - new Component[]{formatContainerPanel, null}, - new Component[]{centerBodyContainer, null} + new Component[]{multipleLabelTip}, + new Component[]{topContentContainer}, + new Component[]{formatPane}, + new Component[]{centerBodyContainer} }; this.setLayout(new BorderLayout()); this.add(TableLayoutHelper.createGapTableLayoutPane(components, scrollContentRowSize, columnSize, HGAP, VGAP), BorderLayout.CENTER); @@ -187,31 +194,6 @@ public abstract class CellQuickEditor extends QuickEditor { */ public abstract Object getComboBoxSelected(); - /** - * 初始化创建单选及多选面板 - * - * @return 创建的面板 - */ - private JComponent createAllCenterBody() { - centerCardLayout = new CardLayout(); - - JPanel centerPanel = new JPanel(centerCardLayout); - - centerPanel.add(SINGLE_SELECT, createCenterBody()); - centerPanel.add(MULTIPLE_SELECT, createCenterBody4Multiple()); - - return centerPanel; - } - - /** - * 为多选单元格创建详细面板,默认创建空面板 - * - * @return 空面板 - */ - public JComponent createCenterBody4Multiple() { - return new JPanel(); - } - /** * 刷新 @@ -224,61 +206,90 @@ public abstract class CellQuickEditor extends QuickEditor { refreshFormatPanel(); refreshDetails(); + + refreshMultipleDetails(); + } + + /** + * 多选时默认隐藏与插入元素类型相关的所有面板 + * 若其他面板需要扩展多选时可修改的内容, + * 通过重写改方法,实现显示/隐藏部分组件 + */ + public void refreshMultipleDetails() { + centerBodyContainer.setVisible(tc.isSelectedOneCell()); } private void refreshFormatPanel() { + // 在populate的时候会多次触发AttributeChangeListener事件, + // 导致不断更新单元格格式,因此populate的时候暂时删除listener + formatPane.removeAttributeChangeListener(); + if (cellElement != null) { formatPane.populateBean(cellElement.getStyle()); } else { formatPane.populateBean(Style.DEFAULT_STYLE); } + + formatPane.restoreAttributeChangeListener(); } private void refreshPanel() { + changeVisiableState(); CellSelection cs = (CellSelection) tc.getSelection(); ColumnRow columnRow = ColumnRow.valueOf(cs.getColumn(), cs.getRow()); - String selectType = tc.isSelectedOneCell() ? SINGLE_SELECT : MULTIPLE_SELECT; - - topCardLayout.show(topContentContainer, selectType); - centerCardLayout.show(centerBodyContainer, selectType); columnRowTextField.setText(columnRow.toString()); cellElement = tc.getEditingElementCase().getTemplateCellElement(cs.getColumn(), cs.getRow()); JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); if (jTemplate != null) { - singleComboBox.removeActionListener(comboBoxActionListener); - singleComboBox.removeAllItems(); + comboBox.removeActionListener(comboBoxActionListener); + comboBox.removeAllItems(); String[] items = getDefaultComboBoxItems(); for (String item : items) { - singleComboBox.addItem(item); - multipleComboBox.addItem(item); + comboBox.addItem(item); } Object comboBoxSelected = getComboBoxSelected(); if (comboBoxSelected != null) { - singleComboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName()); - multipleComboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName()); + comboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName()); } else { - singleComboBox.setSelectedIndex(1); - multipleComboBox.setSelectedIndex(1); + comboBox.setSelectedIndex(1); } - currentSelectedIndex = singleComboBox.getSelectedIndex(); + currentSelectedIndex = comboBox.getSelectedIndex(); comboBoxActionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { cellInsertActions = ActionFactory.createCellInsertAction(ElementCasePane.class, tc); - selectedIndex = singleComboBox.getSelectedIndex(); - singleComboBox.setPopupVisible(false); - singleComboBox.repaint(); + selectedIndex = comboBox.getSelectedIndex(); + comboBox.setPopupVisible(false); + comboBox.repaint(); // comboBox.getSelectedIndex()可能返回-1 if (selectedIndex != -1 && selectedIndex < cellInsertActions.length) { cellInsertActions[selectedIndex].actionPerformed(e); } - singleComboBox.setSelectedIndex(currentSelectedIndex); + comboBox.setSelectedIndex(currentSelectedIndex); } }; - singleComboBox.addActionListener(comboBoxActionListener); + comboBox.addActionListener(comboBoxActionListener); + } + } + + /** + * 单选多选时切换部分组件的 隐藏/显示 状态 + */ + private void changeVisiableState() { + boolean selectedOneCell = tc.isSelectedOneCell(); + + comboBox.setEnabled(selectedOneCell); + if (selectedOneCell) { + columnRowTextField.setPreferredSize(null); + cellLabel.setPreferredSize(null); + multipleLabelTip.setPreferredSize(new Dimension()); + } else { + columnRowTextField.setPreferredSize(new Dimension()); + cellLabel.setPreferredSize(new Dimension()); + multipleLabelTip.setPreferredSize(null); } } @@ -289,44 +300,19 @@ public abstract class CellQuickEditor extends QuickEditor { private JPanel initTopContent() { - topCardLayout = new CardLayout(); - JPanel topContentPane = new JPanel(topCardLayout); - // 单选面板 double p = TableLayout.PREFERRED; double f = TableLayout.FILL; double[] columnSize = {GraphHelper.getWidth(Toolkit.i18nText("Fine-Design_Report_Insert_Cell_Element")), f}; double[] rowSize = {p, p}; - UILabel cellLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Cell")); + cellLabel = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Basic_Cell")); UILabel insertContentLabel = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Report_Insert_Cell_Element")); initCellElementEditComboBox(); Component[][] components = new Component[][]{ new Component[]{cellLabel, columnRowTextField = initColumnRowTextField()}, - new Component[]{insertContentLabel, UIComponentUtils.wrapWithBorderLayoutPane(singleComboBox)}, - }; - JPanel singlePanel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP); - topContentPane.add(SINGLE_SELECT, singlePanel); - - - // 多选面板 - UILabel multipleTipLabel = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Basic_Cell_Element_Multiple_Tip")); - multipleTipLabel.setEnabled(false); - multipleTipLabel.setBorder(BorderFactory.createMatteBorder(5, 0, 0, 0, this.getBackground())); - UILabel insertContentLabel1 = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Report_Insert_Cell_Element")); - Component[][] components1 = new Component[][]{ - new Component[]{insertContentLabel1, UIComponentUtils.wrapWithBorderLayoutPane(multipleComboBox)}, - }; - multipleComboBox.setEnabled(false); - JPanel insertPanel = TableLayoutHelper.createGapTableLayoutPane(components1, new double[]{p}, columnSize, HGAP, - VGAP); - Component[][] components2 = new Component[][]{ - new Component[]{multipleTipLabel}, - new Component[]{insertPanel}, + new Component[]{insertContentLabel, UIComponentUtils.wrapWithBorderLayoutPane(comboBox)}, }; - JPanel multiplePanel = TableLayoutHelper.createGapTableLayoutPane(components2, rowSize, new double[]{f}, HGAP, VGAP); - topContentPane.add(MULTIPLE_SELECT, multiplePanel); - - return topContentPane; + return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP); } private void prepareScrollBar() { @@ -374,23 +360,19 @@ public abstract class CellQuickEditor extends QuickEditor { private void initCellElementEditComboBox() { JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); if (jTemplate == null) { - singleComboBox = new UIComboBox(); - multipleComboBox = new UIComboBox(); + comboBox = new UIComboBox(); return; } final String[] items = getDefaultComboBoxItems(); - singleComboBox = new UIComboBox(items); - multipleComboBox = new UIComboBox(items); + comboBox = new UIComboBox(items); final Object comboBoxSelected = getComboBoxSelected(); if (comboBoxSelected != null) { - singleComboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName()); - multipleComboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName()); + comboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName()); } else { - singleComboBox.setSelectedIndex(1); - multipleComboBox.setSelectedIndex(1); + comboBox.setSelectedIndex(1); } - currentSelectedIndex = singleComboBox.getSelectedIndex(); - singleComboBox.addActionListener(comboBoxActionListener); + currentSelectedIndex = comboBox.getSelectedIndex(); + comboBox.addActionListener(comboBoxActionListener); } private String[] getDefaultComboBoxItems() { @@ -439,61 +421,52 @@ public abstract class CellQuickEditor extends QuickEditor { /** * 创建格式化面板 - * @return */ - private JPanel createFormatPane() { - formatPane = new TextFormatPane(); - AbstractAttrNoScrollPane container = new AbstractAttrNoScrollPane() { - @Override - protected JPanel createContentPane() { - return formatPane; - } - - protected void initContentPane() { - leftContentPane = createContentPane(); - if (leftContentPane != null) { - leftContentPane.setBorder(BorderFactory.createEmptyBorder()); - this.add(leftContentPane, BorderLayout.CENTER); - } - } + private TextFormatPaneContainer createFormatPane() { + TextFormatPaneContainer formatPane = new TextFormatPaneContainer(); - @Override - public Dimension getPreferredSize() { - if (formatPane == null) { - return super.getPreferredSize(); - } - return formatPane.getPreferredSize(); - } - }; - - container.addAttributeChangeListener(new AttributeChangeListener() { + AttributeChangeListener attributeChangeListener = new AttributeChangeListener() { @Override public void attributeChange() { - isEditing = true; - boolean updateStyle = false; - - CellSelection cs = (CellSelection) tc.getSelection(); - TemplateElementCase editingElementCase = tc.getEditingElementCase(); - Set allCellElements = cs.getAllCellElements(editingElementCase); - for (TemplateCellElement cellElement : allCellElements) { - Style elementStyle = cellElement.getStyle(); - Style style = formatPane.update(elementStyle); - if (!Objects.equals(style.getFormat(), elementStyle.getFormat())) { - // 点击单元格,但未设置格式时,不将单元格设置为编辑状态,防止将所选的每个单元格都设置为编辑状态 - editingElementCase.addCellElement(cellElement); - cellElement.setStyle(style); - updateStyle = true; + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + // 耗时任务放线程中,让其他UI组件更新界面, + // 防止多次调用此处每次获取的界面值不同,导致不断更新单元格格式 + isEditing = true; + boolean updateStyle = false; + + CellSelection cs = (CellSelection) tc.getSelection(); + TemplateElementCase editingElementCase = tc.getEditingElementCase(); + Set allCellElements = cs.getCellElements(); + Style oldStyle = cellElement == null ? Style.DEFAULT_STYLE : cellElement.getStyle(); + Style style = formatPane.update(oldStyle); + for (TemplateCellElement cellElement : allCellElements) { + Format elementFormat = cellElement.getStyle().getFormat(); + Format paneFormat = style.getFormat(); + if (!Objects.equals(paneFormat, elementFormat)) { + // 点击单元格,但未设置格式时,不将单元格设置为编辑状态,防止将所选的每个单元格都设置为编辑状态 + editingElementCase.addCellElement(cellElement); + cellElement.setStyle(style); + updateStyle = true; + } + } + + if (updateStyle) { + // 防止频繁触发保存 + fireTargetModified(); + } + + isEditing = false; } - } + }); - if (updateStyle) { - // 防止频繁触发保存 - fireTargetModified(); - } - isEditing = false; } - }); - return container; + }; + + formatPane.addAttributeChangeListener(attributeChangeListener); + + return formatPane; } } diff --git a/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java b/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java index 0b7b011f04..c53439fcba 100644 --- a/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java +++ b/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java @@ -54,11 +54,8 @@ import java.awt.Component; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; import java.util.ArrayList; import java.util.Arrays; -import java.util.HashSet; import java.util.Set; import static com.fr.report.cell.cellattr.core.group.FilterTypeEnum.BOTTOM; @@ -107,10 +104,6 @@ public class CellDSColumnEditor extends CellQuickEditor { * 数据列高级设置 */ private DSColumnAdvancedEditorPane cellDSColumnAdvancedPane; - /** - * 多选面板设置 - */ - private DSColumnMultipleEditorPane cellDSColumnMultiplePane; public CellDSColumnEditor() { super(); @@ -145,7 +138,6 @@ public class CellDSColumnEditor extends CellQuickEditor { protected void refreshDetails() { cellDSColumnBasicPane.populate(); cellDSColumnAdvancedPane.populate(); - cellDSColumnMultiplePane.populate(); this.validate(); } @@ -190,7 +182,6 @@ public class CellDSColumnEditor extends CellQuickEditor { super.release(); cellDSColumnBasicPane.release(); cellDSColumnAdvancedPane.release(); - cellDSColumnMultiplePane.release(); } @@ -241,7 +232,10 @@ public class CellDSColumnEditor extends CellQuickEditor { @Override public void update() { dataPane.update(cellElement); - groupPane.update(); + + CellSelection selection = (CellSelection) tc.getSelection(); + Set allCellElements = selection.getCellElements(); + groupPane.update(allCellElements); } @Override @@ -286,7 +280,6 @@ public class CellDSColumnEditor extends CellQuickEditor { private void initComponents(){ dataPane = new SelectedDataColumnPane(true, true); groupPane = new ResultSetGroupDockingPane(); - initListener(); double[] rowSize = {P}, columnSize = {60, F}; UILabel uiLabel = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Report_Filter_Conditions")); condition = new DSColumnConditionAction(); @@ -303,35 +296,8 @@ public class CellDSColumnEditor extends CellQuickEditor { conditionPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP); this.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); } - - - private void initListener() { - dataPane.setListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - if (e.getStateChange() == ItemEvent.SELECTED) { - dataPane.update(cellElement); - fireTargetModified(); - } - } - }); - groupPane.setListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - if (e == null) { - //分组-高级-自定义点确定的时候传进来null的e,但是这时候应该触发保存 - groupPane.update(); - fireTargetModified(); - return; - } - if (e.getStateChange() == ItemEvent.DESELECTED) { - groupPane.update(); - fireTargetModified(); - } - } - }); - } - + + @Override protected AttributeChangeListener getAttributeChangeListener() { return new AttributeChangeListener() { @@ -342,6 +308,40 @@ public class CellDSColumnEditor extends CellQuickEditor { } }; } + + + public void setMultipleVisible(boolean selectedOneCell) { + // 数据源面板 需要在单选与多选间切换显示状态 + dataPane.setVisible(selectedOneCell); + + if (!selectedOneCell) { + // 只有在批量操作的时候才需要判断是否隐藏条件面板 + CellSelection selection = (CellSelection) tc.getSelection(); + boolean sameDSName = checkSameDSName(selection.getCellElements()); + conditionPane.setVisible(sameDSName); + } + } + + /** + * 判断是否属于同一个数据集 + * + * @param cellElements + * @return + */ + private boolean checkSameDSName(Set cellElements) { + String lastDSName = StringUtils.EMPTY; + for (TemplateCellElement cellElement : cellElements) { + DSColumn dsColumn = (DSColumn) cellElement.getValue(); + String dsName = dsColumn.getDSName(); + if (StringUtils.isNotEmpty(lastDSName) && !StringUtils.equals(dsName, lastDSName)) { + return false; + } + lastDSName = dsName; + } + return true; + } + + } @@ -1026,163 +1026,12 @@ public class CellDSColumnEditor extends CellQuickEditor { } - - class DSColumnMultipleEditorPane extends AbstractDSCellEditorPane { - - /** - * 数据分组设置 - */ - private ResultSetGroupDockingPane groupPane; - /** - * 条件过滤按钮面板 - */ - private JPanel conditionPane; - - /** - * 条件过滤按钮触发动作 - */ - private DSColumnConditionAction condition; - - /** - * 条件过滤按钮 - */ - private UIButton conditionUIButton; - - - @Override - public String getIconPath() { - return Toolkit.i18nText("Fine-Design_Report_Basic"); - } - - @Override - public String title4PopupWindow() { - return Toolkit.i18nText("FR-Designer_Basic"); - } - - - @Override - public void update() { - groupPane.update(); - } - - @Override - public void populate() { - this.removeAttributeChangeListener(); - if (tc != null) { - CellSelection selection = (CellSelection) tc.getSelection(); - Set cellElements = selection.getAllCellElements(tc.getEditingElementCase()); - conditionPane.setVisible(checkSameDSName(cellElements)); - condition.setEditingComponent(tc); - cellElements.forEach(cellElement -> groupPane.populate(cellElement)); - } - this.addAttributeChangeListener(); - } - - /** - * 判断是否属于同一个数据集 - * - * @param cellElements - * @return - */ - private boolean checkSameDSName(Set cellElements) { - String lastDSName = StringUtils.EMPTY; - for (TemplateCellElement cellElement : cellElements) { - DSColumn dsColumn = (DSColumn) cellElement.getValue(); - String dsName = dsColumn.getDSName(); - if (StringUtils.isNotEmpty(lastDSName) && !StringUtils.equals(dsName, lastDSName)) { - return false; - } - lastDSName = dsName; - } - return true; - } - - @Override - protected void release() { - condition.setEditingComponent(null); - } - - - /** - * 创建有内容的面板显示信息 - * - * @return content JPanel - */ - @Override - protected JPanel createContentPane() { - initComponents(); - double[] columnSize = {F}; - double[] rowSize = {P, P}; - Component[][] components = new Component[][]{ - //数据分组设置 - new Component[]{this.groupPane}, - //条件过滤 - new Component[]{this.conditionPane} - }; - return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP); - } - - private void initComponents() { - groupPane = new ResultSetGroupDockingPane(); - initListener(); - double[] rowSize = {P}, columnSize = {60, F}; - UILabel uiLabel = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Report_Filter_Conditions")); - condition = new DSColumnConditionAction(); - if (tc != null) { - condition.setEditingComponent(tc); - } - //丢掉icon,修改按钮名称为编辑 - condition.setSmallIcon(UIConstants.EMPTY_ICON); - condition.setName(Toolkit.i18nText("Fine-Design_Basic_Edit")); - conditionUIButton = new UIButton(condition); - Component[][] components = new Component[][]{ - new Component[]{uiLabel, UIComponentUtils.wrapWithBorderLayoutPane(conditionUIButton)} - }; - conditionPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP); - this.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); - } - - - private void initListener() { - groupPane.setListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - Set cellElements = new HashSet<>(); - if (tc != null) { - CellSelection selection = (CellSelection) tc.getSelection(); - cellElements = selection.getAllCellElements(tc.getEditingElementCase()); - } - - if (e == null) { - //分组-高级-自定义点确定的时候传进来null的e,但是这时候应该触发保存 - groupPane.update(cellElements); - fireTargetModified(); - return; - } - if (e.getStateChange() == ItemEvent.DESELECTED) { - groupPane.update(cellElements); - fireTargetModified(); - } - } - }); - } - - @Override - protected AttributeChangeListener getAttributeChangeListener() { - return new AttributeChangeListener() { - @Override - public void attributeChange() { - update(); - fireTargetModified(); - } - }; - } - } - @Override - public JComponent createCenterBody4Multiple() { - cellDSColumnMultiplePane = new DSColumnMultipleEditorPane(); - return cellDSColumnMultiplePane; + public void refreshMultipleDetails() { + tabsHeaderIconPane.setVisible(tc.isSelectedOneCell()); + cellDSColumnAdvancedPane.setVisible(tc.isSelectedOneCell()); + + cellDSColumnBasicPane.setMultipleVisible(tc.isSelectedOneCell()); } @Override From 47cc6f0f27cb38f663de40d1ddb564f01cbf5d73 Mon Sep 17 00:00:00 2001 From: "Leo.Qin" Date: Tue, 1 Nov 2022 11:26:56 +0800 Subject: [PATCH 41/63] =?UTF-8?q?REPORT-83305=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/style/TextFormatPaneContainer.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/style/TextFormatPaneContainer.java b/designer-base/src/main/java/com/fr/design/gui/style/TextFormatPaneContainer.java index 3d2b658670..bf58ab6558 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/TextFormatPaneContainer.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/TextFormatPaneContainer.java @@ -8,7 +8,6 @@ import javax.swing.BorderFactory; import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.Dimension; -import java.text.Format; /** * 封装格式panel,管理 AttributeChangeListener @@ -43,14 +42,21 @@ public class TextFormatPaneContainer extends AbstractAttrNoScrollPane { return formatPane.getPreferredSize(); } + /** + * 根据单元格样式填充面板设置 + * + * @param style 单元格样式 + */ public void populateBean(Style style) { formatPane.populateBean(style); } - public Format update() { - return formatPane.update(); - } - + /** + * 根据面板设置获取修改后的单元格样式 + * + * @param style 单元格当前样式 + * @return 更新后的单元格样式 + */ public Style update(Style style) { return formatPane.update(style); } @@ -66,6 +72,9 @@ public class TextFormatPaneContainer extends AbstractAttrNoScrollPane { super.addAttributeChangeListener(listener); } + /** + * 恢复使用AttributeChangeListener + */ public void restoreAttributeChangeListener() { super.addAttributeChangeListener(oldListner); } From 7a272a97d78aa18941f1aa2fc8f5a5b93dd3aa6c Mon Sep 17 00:00:00 2001 From: "Leo.Qin" Date: Tue, 1 Nov 2022 11:37:13 +0800 Subject: [PATCH 42/63] =?UTF-8?q?REPORT-80690=20=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=9C=AA=E4=BD=BF=E7=94=A8=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/dscolumn/ResultSetGroupDockingPane.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/dscolumn/ResultSetGroupDockingPane.java b/designer-realize/src/main/java/com/fr/design/dscolumn/ResultSetGroupDockingPane.java index 2c994cc7be..3a51af2844 100644 --- a/designer-realize/src/main/java/com/fr/design/dscolumn/ResultSetGroupDockingPane.java +++ b/designer-realize/src/main/java/com/fr/design/dscolumn/ResultSetGroupDockingPane.java @@ -228,9 +228,6 @@ public class ResultSetGroupDockingPane extends ResultSetGroupPane { this.listener = listener; } - void fireTargetChanged() { - - } @Override public void setRecordGrouper(RecordGrouper recordGrouper) { From 16e871420934e59c796dc6a26678f179fca066e4 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Tue, 1 Nov 2022 16:52:01 +0800 Subject: [PATCH 43/63] =?UTF-8?q?REPORT-83339=20=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E9=A1=B9-=E5=88=87=E6=8D=A2=E6=A8=A1=E6=9D=BF=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E6=95=B0=E6=8D=AE=E9=9B=86=E7=9A=84=E6=9F=A5=E6=89=BE?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E8=BF=98=E6=98=AF=E4=B8=8A=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../replace/action/setting/action/SearchDSColumnAction.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchDSColumnAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchDSColumnAction.java index 9493cbfa7d..5e17f2e9a0 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchDSColumnAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchDSColumnAction.java @@ -39,8 +39,8 @@ public class SearchDSColumnAction implements SearchAction { content.setShowStr(dataName); content.setTemplateName(jTemplate.getTemplateName()); dsColumnInfos.add(new DataSourceInfo(content)); - setDsColumnInfos(dsColumnInfos); } + setDsColumnInfos(dsColumnInfos); } public List getDsColumnInfos() { From c558887d0380d26c976929943940e45e8acf28ea Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Tue, 1 Nov 2022 16:54:44 +0800 Subject: [PATCH 44/63] =?UTF-8?q?REPORT-83501=20=E5=A4=9A=E6=AC=A1?= =?UTF-8?q?=E6=9B=BF=E6=8D=A2=E6=97=B6=EF=BC=8C=E4=B8=8B=E4=B8=80=E6=AC=A1?= =?UTF-8?q?=E4=BC=9A=E8=A6=86=E7=9B=96=E4=B8=8A=E4=B8=80=E6=AC=A1=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2=E7=9A=84=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/actions/replace/ui/ITReplaceMainDialog.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java index b2ae3cae09..9d28ff31be 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java @@ -514,7 +514,7 @@ public class ITReplaceMainDialog extends UIDialog { String thirdStr = GeneralUtils.objectToString(northPane.getReplaceExtraSettingComboBox().getSelectedItem()); HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified(true); for (Info info : searchSettingResultList) { - if (info.getContent().isSelected()) { + if (isSupportReplace(info)) { SettingController controller = SettingController.match(firstStr); if (controller != null) { controller.replace(info, secondStr, thirdStr); @@ -549,6 +549,10 @@ public class ITReplaceMainDialog extends UIDialog { } } } + + private boolean isSupportReplace(Info info) { + return info.getContent().isSelected() && !info.getContent().isReplaced(); + } private boolean isSelectSearch(int optionSelected) { return optionSelected == NONE; From d217d2a03597da020b6b5802bdcffc67a22cc2a6 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Tue, 1 Nov 2022 16:55:38 +0800 Subject: [PATCH 45/63] =?UTF-8?q?REPORT-83498=20=E5=8D=95=E5=85=83?= =?UTF-8?q?=E6=A0=BC-=E6=A0=BC=E5=BC=8F-=E5=B8=B8=E8=A7=84=E9=80=89?= =?UTF-8?q?=E4=B8=AD=E6=9B=BF=E6=8D=A2=E4=BC=9A=E6=8F=90=E7=A4=BA=E6=9F=A5?= =?UTF-8?q?=E6=89=BE=E5=86=85=E5=AE=B9=E4=B8=8D=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/actions/replace/action/setting/CellFormatType.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellFormatType.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellFormatType.java index a468dc995c..b22434a457 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellFormatType.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellFormatType.java @@ -61,7 +61,7 @@ public enum CellFormatType { @Override public boolean isEverChanged(Info info, String inputStr, String extraStr) { CellElement cellElement = (CellElement) info.getContent().getReplaceObject(); - return (cellElement.getStyle() != null && cellElement.getStyle().getFormat() == null); + return !(cellElement.getStyle() != null && cellElement.getStyle().getFormat() == null); } }, /** From 59c4ea72018e566d027af9b594f6dd8c3a279ffe Mon Sep 17 00:00:00 2001 From: "Leo.Qin" Date: Tue, 1 Nov 2022 20:01:28 +0800 Subject: [PATCH 46/63] =?UTF-8?q?REPORT-83305=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=90=8E=E7=95=8C=E9=9D=A2=E5=87=BA=E7=8E=B0?= =?UTF-8?q?=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cellquick/CellDSColumnEditor.java | 37 ++++++++++++++++++- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java b/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java index c53439fcba..bd449de01d 100644 --- a/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java +++ b/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java @@ -54,6 +54,8 @@ import java.awt.Component; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; import java.util.ArrayList; import java.util.Arrays; import java.util.Set; @@ -157,6 +159,10 @@ public class CellDSColumnEditor extends CellQuickEditor { tabsHeaderIconPane = new UIHeadGroup(iconArray) { @Override public void tabChanged(int index) { + + // 由于多选的时候修改了 cellDSColumnBasicPane 中组件的visiable属性,切换时需要将其设置为false + cellDSColumnBasicPane.setVisible(false); + card.show(cardContainer, paneList.get(index).title4PopupWindow()); paneList.get(index).populate(); } @@ -280,6 +286,7 @@ public class CellDSColumnEditor extends CellQuickEditor { private void initComponents(){ dataPane = new SelectedDataColumnPane(true, true); groupPane = new ResultSetGroupDockingPane(); + initListener(); double[] rowSize = {P}, columnSize = {60, F}; UILabel uiLabel = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Report_Filter_Conditions")); condition = new DSColumnConditionAction(); @@ -297,14 +304,38 @@ public class CellDSColumnEditor extends CellQuickEditor { this.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); } + private void initListener() { + dataPane.setListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + if (e.getStateChange() == ItemEvent.SELECTED) { + dataPane.update(cellElement); + fireTargetModified(); + } + } + }); + groupPane.setListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + CellSelection selection = (CellSelection) tc.getSelection(); + Set allCellElements = selection.getCellElements(); + groupPane.update(allCellElements); + if (e == null || e.getStateChange() == ItemEvent.DESELECTED) { + //分组-高级-自定义点确定的时候传进来null的e,但是这时候应该触发保存 + groupPane.update(allCellElements); + fireTargetModified(); + } + } + }); + } + @Override protected AttributeChangeListener getAttributeChangeListener() { return new AttributeChangeListener() { @Override public void attributeChange() { - update(); - fireTargetModified(); + } }; } @@ -319,6 +350,8 @@ public class CellDSColumnEditor extends CellQuickEditor { CellSelection selection = (CellSelection) tc.getSelection(); boolean sameDSName = checkSameDSName(selection.getCellElements()); conditionPane.setVisible(sameDSName); + } else { + conditionPane.setVisible(true); } } From 468e268723335edaa79e03dfd4775de17205a0a6 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Wed, 2 Nov 2022 17:11:05 +0800 Subject: [PATCH 47/63] =?UTF-8?q?REPORT-83571=20=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=88=97=E8=AE=BE=E7=BD=AE=E4=BB=8E=E5=88=86=E7=BB=84-?= =?UTF-8?q?=E6=99=AE=E9=80=9A=E6=9B=BF=E6=8D=A2=E4=B8=BA=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E4=B8=8D=E7=94=9F=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../actions/replace/action/setting/CellGroupType.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellGroupType.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellGroupType.java index a9b20b6627..27aebee07d 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellGroupType.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellGroupType.java @@ -237,7 +237,11 @@ public enum CellGroupType { */ public void replace(Info info, String firstStr, String secondStr) { FunctionGrouper grouper = new FunctionGrouper(); - grouper.setDivideMode(getGroupType(secondStr)); + if (StringUtils.equals(firstStr, SettingContent.DIGIT_SETTING_LIST)) { + grouper.setDivideMode(getGroupType(firstStr)); + } else { + grouper.setDivideMode(getGroupType(secondStr)); + } CellElement cellElement = (CellElement) info.getContent().getReplaceObject(); DSColumn column = (DSColumn) cellElement.getValue(); column.setGrouper(grouper); From 35a6960a47af9d173be90422a59710c36f3f8659 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Wed, 2 Nov 2022 17:19:12 +0800 Subject: [PATCH 48/63] =?UTF-8?q?REPORT-83302=20=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E9=A1=B9=E5=BC=B9=E7=AA=97=E6=89=93=E5=BC=80=E5=90=8E=E5=86=8D?= =?UTF-8?q?=E6=AC=A1=E7=BC=96=E8=BE=91=E7=9A=84=E5=86=85=E5=AE=B9=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E5=AE=9E=E6=97=B6=E6=98=BE=E7=A4=BA=E5=9C=A8=E5=8F=AF?= =?UTF-8?q?=E9=80=89=E9=A1=B9=E9=87=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../replace/ui/ITReplaceNorthPanel.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java index 977d819807..a11886c2c8 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java @@ -20,6 +20,8 @@ import javax.swing.Icon; import javax.swing.JCheckBox; import javax.swing.JPanel; import javax.swing.ScrollPaneConstants; +import javax.swing.event.PopupMenuEvent; +import javax.swing.event.PopupMenuListener; import java.awt.CardLayout; import java.awt.Dimension; import java.awt.event.ActionEvent; @@ -317,6 +319,45 @@ public class ITReplaceNorthPanel { refreshExtraComboBox(replaceSettingInputComboBox, replaceExtraSettingComboBox); } }); + + initInputComboBoxPopupListener(findSettingInputComboBox); + initInputComboBoxPopupListener(replaceSettingInputComboBox); + + } + + private void initInputComboBoxPopupListener(UIComboBox box) { + box.addPopupMenuListener(new PopupMenuListener() { + @Override + public void popupMenuWillBecomeVisible(PopupMenuEvent e) { + String str = GeneralUtils.objectToString(findSettingComboBox.getSelectedItem()); + int findExtraIndex = findExtraSettingComboBox.getSelectedIndex(); + int replaceExtraIndex = replaceExtraSettingComboBox.getSelectedIndex(); + box.refreshBoxItems(SettingController.getSettingRefreshItems(str)); + dealExtraItemSelect(findExtraSettingComboBox, findExtraIndex); + dealExtraItemSelect(replaceExtraSettingComboBox, replaceExtraIndex); + } + + @Override + public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { + + } + + @Override + public void popupMenuCanceled(PopupMenuEvent e) { + + } + }); + } + + /** + * 重新设置额外下拉框的选中索引 + * @param comboBox 额外下拉框 + * @param index 索引 + */ + private void dealExtraItemSelect(UIComboBox comboBox, int index) { + if (comboBox.getItemCount() > index) { + comboBox.setSelectedIndex(index); + } } /** From 0178d770ad2a26a0c0519801e015ae661b0115e1 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Wed, 2 Nov 2022 17:22:40 +0800 Subject: [PATCH 49/63] =?UTF-8?q?REPORT-83604=20=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E6=89=80=E6=9C=89=E7=B1=BB=E5=9E=8B=E7=9A=84?= =?UTF-8?q?=E6=9B=BF=E6=8D=A2=EF=BC=9A=E5=8D=95=E6=9D=A1=E6=9B=BF=E6=8D=A2?= =?UTF-8?q?=E4=BC=9A=E6=9B=BF=E6=8D=A2=E6=89=80=E6=9C=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/actions/replace/ui/ITReplaceMainDialog.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java index 9d28ff31be..78daf0a09f 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java @@ -254,7 +254,7 @@ public class ITReplaceMainDialog extends UIDialog { public void replace(String searchStr, String replaceStr) { HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified(true); for (Info info : searchContentResultList) { - if (!info.getContent().isWrongful()) { + if (!info.getContent().isWrongful() && info.getContent().isSelected()) { info.setValue(info, searchStr, replaceStr, info.getContent().getOperatorArray()); } info.getContent().setReplaced(true); From ffe4406165b1e5115fcf5500b98262e539c17b90 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Wed, 2 Nov 2022 17:25:27 +0800 Subject: [PATCH 50/63] =?UTF-8?q?REPORT-83083=20FR=E5=9B=BE=E8=A1=A8?= =?UTF-8?q?=E5=85=A8=E9=87=8F=E8=A6=86=E7=9B=96-=E9=83=A8=E5=88=86?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE=E5=86=85=E5=AE=B9=E6=9F=A5=E4=B8=8D=E5=88=B0?= =?UTF-8?q?=E7=9B=B8=E5=BA=94=E4=BD=8D=E7=BD=AE=E4=BF=A1=E6=81=AF=EF=BC=8C?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E8=A1=A5=E5=85=85=E4=B8=80=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SearchChartCollectionFormulaAction.java | 153 +++++++++++------- .../SearchChartMapDataFormulaAction.java | 41 +++-- .../SearchChartHyperPopLinkAction.java | 3 +- .../content/js/SearchChartJSAction.java | 56 ++++--- .../actions/replace/utils/SearchJSUtils.java | 142 +++++++++++++--- .../actions/replace/utils/ShowValueUtils.java | 40 ++++- 6 files changed, 312 insertions(+), 123 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartCollectionFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartCollectionFormulaAction.java index aadf2aee41..40e5283ce9 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartCollectionFormulaAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartCollectionFormulaAction.java @@ -13,15 +13,14 @@ import com.fr.chart.chartattr.Plot; import com.fr.chart.chartattr.SwitchTitle; import com.fr.chart.chartattr.Title; -import com.fr.chart.chartdata.NormalReportDataDefinition; -import com.fr.chart.chartdata.SeriesDefinition; + import com.fr.design.actions.replace.action.content.formula.highlight.javascript.SearchJSHighlightAction; import com.fr.design.actions.replace.action.content.formula.widget.DictionaryType; -import com.fr.design.actions.replace.info.CellInfo; import com.fr.design.actions.replace.info.FormulaInfo; -import com.fr.design.actions.replace.info.JSInfo; import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.actions.replace.utils.SearchJSUtils; +import com.fr.design.actions.replace.utils.ShowValueUtils; import com.fr.design.i18n.Toolkit; import com.fr.js.NameJavaScript; @@ -29,10 +28,13 @@ import com.fr.js.NameJavaScriptGroup; import com.fr.plugin.chart.attr.axis.VanChartAlertValue; import com.fr.plugin.chart.attr.axis.VanChartAxis; import com.fr.plugin.chart.attr.axis.VanChartValueAxis; +import com.fr.plugin.chart.attr.plot.VanChartRectanglePlot; +import com.fr.plugin.chart.custom.CustomDefinition; import com.fr.plugin.chart.custom.CustomPlotFactory; import com.fr.plugin.chart.custom.VanChartCustomPlot; + import com.fr.plugin.chart.custom.type.CustomPlotType; -import com.fr.report.cell.TemplateCellElement; +import com.fr.plugin.chart.map.VanChartMapPlot; import com.fr.stable.StringUtils; import java.util.List; @@ -111,21 +113,41 @@ public class SearchChartCollectionFormulaAction { } private void dealPlot(List formulaInfos, ITContent content, Plot plot) { - NameJavaScriptGroup javaScriptGroup = plot.getHotHyperLink(); + if (SearchJSUtils.isCustomMapPlot(plot)) { + dealNameJavaScriptGroup(formulaInfos, ShowValueUtils.getCustomMapContent(content, Toolkit.i18nText("Fine-Design_Chart_Region_Map")), ((VanChartMapPlot) plot).getAreaHotHyperLink()); + dealNameJavaScriptGroup(formulaInfos, ShowValueUtils.getCustomMapContent(content, Toolkit.i18nText("Fine-Design_Chart_LineMap")), ((VanChartMapPlot) plot).getLineHotHyperLink()); + dealNameJavaScriptGroup(formulaInfos, ShowValueUtils.getCustomMapContent(content, Toolkit.i18nText("Fine-Design_Chart_PointMap")), ((VanChartMapPlot) plot).getPointHotHyperLink()); + } else { + NameJavaScriptGroup javaScriptGroup = plot.getHotHyperLink(); + dealNameJavaScriptGroup(formulaInfos, content, javaScriptGroup); + } + } + + private void dealNameJavaScriptGroup(List formulaInfos, ITContent content, NameJavaScriptGroup javaScriptGroup) { if (javaScriptGroup != null) { for (int i = 0; i < javaScriptGroup.size(); i++) { + ITContent formulaContent = ITContent.copy(content); NameJavaScript javaScript = javaScriptGroup.getNameHyperlink(i); - content.addOtherPos(javaScript.getName()); + formulaContent.addOtherPos(javaScript.getName()); SearchJSHighlightAction action = SearchJSHighlightAction.getInstance(); - action.searchJSFormulaFromOther(formulaInfos, content, javaScript.getJavaScript()); + action.searchJSFormulaFromOther(formulaInfos, formulaContent, javaScript.getJavaScript()); } } } private void searchFormulaFromChartPresent(List formulaInfos, ITContent content, TopDefinitionProvider provider) { - searchPresent4Formula(provider.getCategoryPresent(), content, formulaInfos); - searchPresent4Formula(provider.getSeriesPresent(), content, formulaInfos); - + if (provider instanceof CustomDefinition) { + CustomDefinition definition = (CustomDefinition) provider; + Map map = definition.getDefinitionProviderMap(); + for (CustomPlotType type : map.keySet()) { + ITContent customContent = ITContent.copy(content); + customContent.addOtherPos(CustomPlotFactory.getTitle(type)); + searchFormulaFromChartPresent(formulaInfos, customContent, map.get(type)); + } + } else { + searchPresent4Formula(provider.getCategoryPresent(), ShowValueUtils.getCustomMapContent(content, Toolkit.i18nText("Fine-Design_Chart_Category")), formulaInfos); + searchPresent4Formula(provider.getSeriesPresent(), ShowValueUtils.getCustomMapContent(content, Toolkit.i18nText("Fine-Design_Chart_Series")), formulaInfos); + } } private void searchPresent4Formula(Present present, ITContent content, List formulaInfos) { @@ -195,36 +217,40 @@ public class SearchChartCollectionFormulaAction { private void searchChartPatternFormulaFromAlertLine(List formulaInfos, ITContent chartContent, Chart chart) { if (chart.getPlot() != null) { - Axis xAxis = chart.getPlot().getxAxis(); - Axis yAxis = chart.getPlot().getyAxis(); + if (chart.getPlot() instanceof VanChartRectanglePlot) { + VanChartRectanglePlot plot = chart.getPlot(); + for (VanChartAxis axis : plot.getXAxisList()) { + dealAlertLineFormula(formulaInfos, chartContent, axis); + } + for (VanChartAxis axis : plot.getYAxisList()) { + dealAlertLineFormula(formulaInfos, chartContent, axis); + } + } else { + dealAlertLineFormula(formulaInfos, chartContent, chart.getPlot().getxAxis()); + dealAlertLineFormula(formulaInfos, chartContent, chart.getPlot().getyAxis()); + } + } + } + + private void dealAlertLineFormula(List formulaInfos, ITContent chartContent, Axis axis) { + if (axis instanceof VanChartAxis) { ITContent content = ITContent.copy(chartContent); content.addOtherPos( Toolkit.i18nText("Fine-Design_Chart_Pattern"), Toolkit.i18nText("Fine-Design_Chart_Background"), Toolkit.i18nText("Fine-Design_Chart_Plot_Region"), - Toolkit.i18nText("Fine-Design_Chart_Alert_Line") + Toolkit.i18nText("Fine-Design_Chart_Alert_Line"), + ((VanChartAxis) axis).getAxisName() ); - if (xAxis instanceof VanChartAxis) { - List list = ((VanChartAxis) xAxis).getAlertValues(); - for (VanChartAlertValue alertValue : list) { - //警戒线设置 - dealAlertValue(formulaInfos, content, alertValue); - //提示文字 - dealAlertContent(formulaInfos, content, alertValue); - } - } - if (yAxis instanceof VanChartAxis) { - List list = ((VanChartAxis) yAxis).getAlertValues(); - for (VanChartAlertValue alertValue : list) { - //警戒线设置 - dealAlertValue(formulaInfos, content, alertValue); - //提示文字 - dealAlertContent(formulaInfos, content, alertValue); - } + + List list = ((VanChartAxis) axis).getAlertValues(); + for (VanChartAlertValue alertValue : list) { + //警戒线设置 + dealAlertValue(formulaInfos, content, alertValue); + //提示文字 + dealAlertContent(formulaInfos, content, alertValue); } } - - } private void dealAlertContent(List formulaInfos, ITContent content, VanChartAlertValue alertValue) { @@ -247,39 +273,42 @@ public class SearchChartCollectionFormulaAction { private void searchChartPatternFormulaFromAxisValue(List formulaInfos, ITContent chartContent, Chart chart) { if (chart.getPlot() != null) { - Axis xAxis = chart.getPlot().getxAxis(); - Axis yAxis = chart.getPlot().getyAxis(); - //样式-坐标轴-x轴 - if (xAxis != null) { - //轴标题 - ITContent xAxisContent = ITContent.copy(chartContent); - if (!chartContent.isFrm()) { - xAxisContent.addOtherPos(chart.getChartName()); - } - xAxisContent.addOtherPos( - Toolkit.i18nText("Fine-Design_Chart_Pattern"), - Toolkit.i18nText("Fine-Design_Chart_Axis"), - Toolkit.i18nText("Fine-Design_Chart_X_Axis") - ); - dealTitle(formulaInfos, xAxisContent, xAxis.getTitle()); - dealChartValueDefine(formulaInfos, xAxisContent, xAxis); + if (chart.getPlot() instanceof VanChartRectanglePlot) { + searchVanChartRectanglePlotAxisFormula(formulaInfos, chartContent, chart.getPlot(), chart); + } else { + Axis xAxis = chart.getPlot().getxAxis(); + Axis yAxis = chart.getPlot().getyAxis(); + //样式-坐标轴 + dealAxisFormula(formulaInfos, chartContent, xAxis, chart); + dealAxisFormula(formulaInfos, chartContent, yAxis, chart); } + } + } - //样式-坐标轴-y轴-轴标题 - if (yAxis != null) { - ITContent yAxisContent = ITContent.copy(chartContent); - yAxisContent.addOtherPos( - chart.getChartName(), - Toolkit.i18nText("Fine-Design_Chart_Pattern"), - Toolkit.i18nText("Fine-Design_Chart_Axis"), - Toolkit.i18nText("Fine-Design_Chart_Y_Axis") - - ); - dealTitle(formulaInfos, yAxisContent, yAxis.getTitle()); - dealChartValueDefine(formulaInfos, yAxisContent, yAxis); - } + private void searchVanChartRectanglePlotAxisFormula(List formulaInfos, ITContent chartContent, VanChartRectanglePlot plot, Chart chart) { + for (VanChartAxis axis : plot.getXAxisList()) { + dealAxisFormula(formulaInfos, chartContent, axis, chart); } + for (VanChartAxis axis : plot.getYAxisList()) { + dealAxisFormula(formulaInfos, chartContent, axis, chart); + } + } + private void dealAxisFormula(List formulaInfos, ITContent chartContent, Axis axis, Chart chart) { + if (axis instanceof VanChartAxis) { + //轴标题 + ITContent content = ITContent.copy(chartContent); + if (!chartContent.isFrm()) { + content.addOtherPos(chart.getChartName()); + } + content.addOtherPos( + Toolkit.i18nText("Fine-Design_Chart_Pattern"), + Toolkit.i18nText("Fine-Design_Chart_Axis"), + ((VanChartAxis) axis).getAxisName() + ); + dealTitle(formulaInfos, content, axis.getTitle()); + dealChartValueDefine(formulaInfos, content, axis); + } } private void dealChartValueDefine(List formulaInfos, ITContent axisContent, Axis axis) { diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartMapDataFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartMapDataFormulaAction.java index b892e35c82..862ab0e6dc 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartMapDataFormulaAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartMapDataFormulaAction.java @@ -34,11 +34,11 @@ public class SearchChartMapDataFormulaAction implements SearchChartDataFormula { //流向地图 ITContent lineContent = ITContent.copy(content); lineContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_LineMap")); - dealLineDefinition(formulaInfos, content, mapDefinition.getLineDefinition()); + dealLineDefinition(formulaInfos, lineContent, mapDefinition.getLineDefinition()); //点地图 ITContent pointContent = ITContent.copy(content); pointContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_PointMap")); - dealPointDefinition(formulaInfos, content, mapDefinition.getPointDefinition()); + dealPointDefinition(formulaInfos, pointContent, mapDefinition.getPointDefinition()); } } @@ -101,7 +101,7 @@ public class SearchChartMapDataFormulaAction implements SearchChartDataFormula { formulaInfos.add(new FormulaInfo(endAreaNameContent)); } //区域名 - dealAreaName(formulaInfos, lineContent, definition.getCategoryName(), definition); + dealAreaName(formulaInfos, lineContent, definition.getCategoryName(), definition, true); } } @@ -160,18 +160,34 @@ public class SearchChartMapDataFormulaAction implements SearchChartDataFormula { } /** - * 处理区域名 - * @param formulaInfos - * @param content - * @param object - * @param definition + * 处理区域名(不用考虑特殊起名) + * @param formulaInfos 存储信息的数据结构 + * @param content ITContent + * @param object 分类 + * @param definition 数据 */ public void dealAreaName(List formulaInfos, ITContent content, Object object, VanMapReportDefinition definition) { + dealAreaName(formulaInfos, content, object, definition, false); + } + + /** + * 处理区域名(特殊起名) + * @param formulaInfos 存储信息的数据结构 + * @param content ITContent + * @param object 分类 + * @param definition 数据 + * @param lineFlag 线地图的标志 + */ + public void dealAreaName(List formulaInfos, ITContent content, Object object, VanMapReportDefinition definition, boolean lineFlag) { + String str; + if (lineFlag) { + str = Toolkit.i18nText("Fine-Design_Chart_Start_Area_Name"); + } else { + str = Toolkit.i18nText("Fine-Design_Chart_Area_Name"); + } if (object instanceof Formula) { ITContent cateContent = ITContent.copy(content); - cateContent.addOtherPos( - Toolkit.i18nText("Fine-Design_Chart_Area_Name") - ); + cateContent.addOtherPos(str); cateContent.setReplaceObject(object); formulaInfos.add(new FormulaInfo(cateContent)); } else if (isFormulaString(object)) { @@ -179,12 +195,11 @@ public class SearchChartMapDataFormulaAction implements SearchChartDataFormula { strContent.setHoldObject(definition); strContent.setTag(SearchTag.CHART_AREA_NAME); strContent.setReplaceObject(object); - strContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Area_Name")); + strContent.addOtherPos(str); formulaInfos.add(new FormulaInfo(strContent)); } } - /** * 处理系列名&值 */ diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/javascript/SearchChartHyperPopLinkAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/javascript/SearchChartHyperPopLinkAction.java index 4edd5b4f17..4fa710878c 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/javascript/SearchChartHyperPopLinkAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/javascript/SearchChartHyperPopLinkAction.java @@ -27,7 +27,8 @@ public class SearchChartHyperPopLinkAction implements SearchJSFormula { if (javaScript instanceof ChartHyperPoplink) { ChartHyperPoplink chartHyperPoplink = (ChartHyperPoplink) javaScript; if (chartHyperPoplink.getChartCollection() instanceof ChartCollection) { - SearchChartCollectionFormulaAction.getInstance().searchChartCollectionFormula(formulaInfos, content, (ChartCollection) chartHyperPoplink.getChartCollection()); + ITContent chartContent = ITContent.copy(content); + SearchChartCollectionFormulaAction.getInstance().searchChartCollectionFormula(formulaInfos, chartContent, (ChartCollection) chartHyperPoplink.getChartCollection()); } } } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchChartJSAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchChartJSAction.java index ad97655263..dc3092c01a 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchChartJSAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchChartJSAction.java @@ -13,6 +13,7 @@ import com.fr.js.NameJavaScript; import com.fr.js.NameJavaScriptGroup; import com.fr.plugin.chart.attr.axis.VanChartAxis; import com.fr.plugin.chart.attr.plot.VanChartPlot; +import com.fr.plugin.chart.attr.plot.VanChartRectanglePlot; import com.fr.plugin.chart.base.RefreshMoreLabel; import com.fr.plugin.chart.base.VanChartHtmlLabel; import com.fr.plugin.chart.custom.CustomPlotFactory; @@ -45,7 +46,7 @@ public class SearchChartJSAction { */ public void searchChartJS(ChartCollection chartCollection, ITContent content, List jsInfos) { List> htmlLabels = SearchJSUtils.getHtmlLabel(chartCollection); - List nameJavaScripts = SearchJSUtils.getNameJavaScript(chartCollection); + List nameJavaScripts = SearchJSUtils.getNameJavaScript(chartCollection, content, jsInfos); //图表-样式-标签以及图表-特效-条件显示 ITContent htmlITContent = ITContent.copy(content); htmlITContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Chart")); @@ -117,29 +118,44 @@ public class SearchChartJSAction { private void searchAxisJS(List jsInfos, ITContent chartContent, Chart chart) { if (chart.getPlot() != null) { - Axis xAxis = chart.getPlot().getxAxis(); - Axis yAxis = chart.getPlot().getyAxis(); - if (xAxis instanceof VanChartAxis) { - ITContent xAxisContent = ITContent.copy(chartContent); - xAxisContent.addOtherPos( - Toolkit.i18nText("Fine-Design_Chart_Axis"), - Toolkit.i18nText("Fine-Design_Chart_X_Axis"), - Toolkit.i18nText("Fine-Design_Chart_Axis_Label_Format") - ); - dealAxisHtmlLabelJS(jsInfos, ((VanChartAxis) xAxis).getHtmlLabel(), xAxisContent); + if (chart.getPlot() instanceof VanChartRectanglePlot) { + searchVanChartRectanglePlotAxisJS(jsInfos, chartContent, chart.getPlot()); + } else { + Axis xAxis = chart.getPlot().getxAxis(); + Axis yAxis = chart.getPlot().getyAxis(); + dealAxis(jsInfos, chartContent, xAxis); + dealAxis(jsInfos, chartContent, yAxis); } + } - if (yAxis instanceof VanChartAxis) { - ITContent yAxisContent = ITContent.copy(chartContent); - yAxisContent.addOtherPos( - Toolkit.i18nText("Fine-Design_Chart_Axis"), - Toolkit.i18nText("Fine-Design_Chart_Y_Axis"), - Toolkit.i18nText("Fine-Design_Chart_Axis_Label_Format") - ); - dealAxisHtmlLabelJS(jsInfos, ((VanChartAxis) yAxis).getHtmlLabel(), yAxisContent); - } + } + + private void dealAxis(List jsInfos, ITContent chartContent, Axis axis) { + if (axis instanceof VanChartAxis) { + ITContent yAxisContent = ITContent.copy(chartContent); + yAxisContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Chart_Axis"), + ((VanChartAxis) axis).getAxisName(), + Toolkit.i18nText("Fine-Design_Chart_Axis_Label_Format") + ); + dealAxisHtmlLabelJS(jsInfos, ((VanChartAxis) axis).getHtmlLabel(), yAxisContent); } + } + + /** + * 自定义的图表可以存放多个轴 + * @param jsInfos 存储信息的数据结构 + * @param chartContent ITContent + * @param plot 图表的VanChartRectanglePlot + */ + private void searchVanChartRectanglePlotAxisJS(List jsInfos, ITContent chartContent, VanChartRectanglePlot plot) { + for (VanChartAxis axis : plot.getXAxisList()) { + dealAxis(jsInfos, chartContent, axis); + } + for (VanChartAxis axis : plot.getYAxisList()) { + dealAxis(jsInfos, chartContent, axis); + } } private void dealAxisHtmlLabelJS(List jsInfos, VanChartHtmlLabel label, ITContent content) { diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/SearchJSUtils.java b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/SearchJSUtils.java index ef2909db6b..8901f76edb 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/SearchJSUtils.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/SearchJSUtils.java @@ -2,6 +2,7 @@ package com.fr.design.actions.replace.utils; import com.fr.chart.base.DataSeriesCondition; import com.fr.chart.chartattr.ChartCollection; +import com.fr.chart.chartattr.Plot; import com.fr.chart.chartglyph.ConditionAttr; import com.fr.chart.chartglyph.ConditionCollection; import com.fr.chart.web.ChartHyperPoplink; @@ -22,9 +23,13 @@ import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.base.AttrLabel; import com.fr.plugin.chart.base.AttrTooltip; import com.fr.plugin.chart.base.VanChartHtmlLabel; +import com.fr.plugin.chart.custom.CustomPlotFactory; +import com.fr.plugin.chart.custom.VanChartCustomPlot; +import com.fr.plugin.chart.custom.type.CustomPlotType; import com.fr.plugin.chart.map.VanChartMapPlot; import com.fr.plugin.chart.map.attr.AttrMapLabel; import com.fr.plugin.chart.map.attr.AttrMapTooltip; +import com.fr.plugin.chart.type.MapType; import com.fr.plugin.chart.vanchart.VanChart; import com.fr.report.cell.Elem; import com.fr.stable.StringUtils; @@ -119,16 +124,60 @@ public class SearchJSUtils { for (int i = 0; i < collection.getChartCount(); i++) { if (collection.getChart(i) instanceof VanChart) { VanChart chart = ((VanChart) collection.getChart(i)); - int size = chart.getPlot().getConditionCollection().getConditionAttrSize(); - ConditionCollection conditionCollection = chart.getPlot().getConditionCollection(); + //如果是组合图 + if (chart.getPlot() instanceof VanChartCustomPlot) { + VanChartCustomPlot plot = chart.getPlot(); + for (VanChartPlot vanChartPlot : plot.getCustomPlotList()) { + dealPlotHtmlLabel(arrayList, vanChartPlot); + } + } else if (chart.getPlot() instanceof VanChartPlot){ + dealPlotHtmlLabel(arrayList, chart.getPlot()); + } addAttrLabelHtmlLabel(chart, arrayList); - for (int j = 0; j < size; j++) { - searchConditionCollection(arrayList, conditionCollection.getConditionAttr(j)); - } } } } + private static void dealPlotHtmlLabel(List> arrayList, VanChartPlot plot) { + //如果是组合地图 + if (plot instanceof VanChartMapPlot) { + dealMapPlotHtmlLabel(arrayList, (VanChartMapPlot) plot); + } else { + dealCommonPlotHtmlLabel(arrayList, plot); + } + + } + + private static void dealMapPlotHtmlLabel(List> arrayList, VanChartMapPlot plot) { + ConditionCollection area = plot.getConditionCollection(); + ConditionCollection line = plot.getLineConditionCollection(); + ConditionCollection point = plot.getPointConditionCollection(); + dealMapCollectionHtmlLabel(arrayList, area, Toolkit.i18nText("Fine-Design_Chart_Region_Map")); + dealMapCollectionHtmlLabel(arrayList, line, Toolkit.i18nText("Fine-Design_Chart_LineMap")); + dealMapCollectionHtmlLabel(arrayList, point, Toolkit.i18nText("Fine-Design_Chart_PointMap")); + + } + + private static void dealMapCollectionHtmlLabel(List> arrayList, ConditionCollection collection, String i18nText) { + for (int i = 0, size = collection.getConditionAttrSize(); i < size; i++) { + searchConditionCollection(arrayList, collection.getConditionAttr(i), i18nText); + } + } + + private static void dealCommonPlotHtmlLabel(List> arrayList, VanChartPlot plot) { + int size = plot.getConditionCollection().getConditionAttrSize(); + CustomPlotType plotType = CustomPlotFactory.getCustomType(plot); + ConditionCollection conditionCollection = plot.getConditionCollection(); + for (int j = 0; j < size; j++) { + if (plotType != null) { + searchConditionCollection(arrayList, conditionCollection.getConditionAttr(j), CustomPlotFactory.getTitle(plotType)); + } else { + searchConditionCollection(arrayList, conditionCollection.getConditionAttr(j), StringUtils.EMPTY); + } + + } + } + /** * 将图表-样式-标签以及图表-样式-提示中的HtmlLabel加入数组 * @@ -140,15 +189,26 @@ public class SearchJSUtils { //如果是地图类型要特殊处理 if (plot instanceof VanChartMapPlot) { addMapJS2Array((VanChartMapPlot) plot, arrayList); - } else { - addAttrToolTipCondition2Array(plot, arrayList); - if (isAttrLabelExist(plot)) { - addAttrLabelDetail2Array(plot, arrayList); - addAttrSecondLabelDetail2Array(plot, arrayList); + } else if(plot instanceof VanChartCustomPlot){ + for (VanChartPlot vanChartPlot : ((VanChartCustomPlot) plot).getCustomPlotList()) { + CustomPlotType plotType = CustomPlotFactory.getCustomType(vanChartPlot); + dealAttrLabelHtml4VanChartPlot(vanChartPlot, arrayList, CustomPlotFactory.getTitle(plotType)); } + } else { + dealAttrLabelHtml4VanChartPlot(plot, arrayList, StringUtils.EMPTY); + } + } + + private static void dealAttrLabelHtml4VanChartPlot(VanChartPlot plot, List> arrayList, String str) { + addAttrToolTipCondition2Array(plot, arrayList, str); + if (isAttrLabelExist(plot)) { + addAttrLabelDetail2Array(plot, arrayList, str); + addAttrSecondLabelDetail2Array(plot, arrayList, str); } } + + /** * 用于处理地图类型图表中的样式中的JS(AttrMapTooltip 与 AttrMapLabel) * @@ -195,9 +255,9 @@ public class SearchJSUtils { } } - private static void addAttrToolTipCondition2Array(VanChartPlot plot, List> arrayList) { + private static void addAttrToolTipCondition2Array(VanChartPlot plot, List> arrayList, String str) { if (isToolTipValid(plot.getAttrTooltipFromConditionCollection())) { - arrayList.add(new Pair<>(((AttrTooltip) plot.getAttrTooltipFromConditionCollection()).getContent().getHtmlLabel(), STYLE_TOOLTIP_CUSTOM)); + arrayList.add(new Pair<>(((AttrTooltip) plot.getAttrTooltipFromConditionCollection()).getContent().getHtmlLabel(), ShowValueUtils.getChartOtherPos(STYLE_TOOLTIP_CUSTOM, str))); } } @@ -205,9 +265,9 @@ public class SearchJSUtils { return tooltip instanceof AttrTooltip && ((AttrTooltip) tooltip).isEnable() && ((AttrTooltip) tooltip).getContent() != null && ((AttrTooltip) tooltip).getContent().getHtmlLabel() != null; } - private static void addAttrLabelDetail2Array(VanChartPlot plot, List> arrayList) { + private static void addAttrLabelDetail2Array(VanChartPlot plot, List> arrayList, String str) { if (isLabelDetailValid(plot)) { - arrayList.add(new Pair<>(plot.getAttrLabelFromConditionCollection().getAttrLabelDetail().getContent().getHtmlLabel(), STYLE_LABEL)); + arrayList.add(new Pair<>(plot.getAttrLabelFromConditionCollection().getAttrLabelDetail().getContent().getHtmlLabel(), ShowValueUtils.getChartOtherPos(STYLE_LABEL, str))); } } @@ -217,9 +277,9 @@ public class SearchJSUtils { && plot.getAttrLabelFromConditionCollection().getAttrLabelDetail().getContent().getHtmlLabel() != null; } - private static void addAttrSecondLabelDetail2Array(VanChartPlot plot, List> arrayList) { + private static void addAttrSecondLabelDetail2Array(VanChartPlot plot, List> arrayList, String str) { if (isSecondLabelDetailValid(plot)) { - arrayList.add(new Pair<>(plot.getAttrLabelFromConditionCollection().getSecondLabelDetail().getContent().getHtmlLabel(), CATEGORY_LABEL)); + arrayList.add(new Pair<>(plot.getAttrLabelFromConditionCollection().getSecondLabelDetail().getContent().getHtmlLabel(), ShowValueUtils.getChartOtherPos(CATEGORY_LABEL, str))); } } @@ -239,21 +299,22 @@ public class SearchJSUtils { * @param arrayList * @param conditionAttr */ - private static void searchConditionCollection(List> arrayList, ConditionAttr conditionAttr) { + private static void searchConditionCollection(List> arrayList, ConditionAttr conditionAttr, String name) { int conditionSize = conditionAttr.getDataSeriesConditionCount(); for (int t = 0; t < conditionSize; t++) { DataSeriesCondition condition = conditionAttr.getDataSeriesCondition(t); - String str = Toolkit.i18nText("Fine-Design_Chart_Animation_Special") + "-" + Toolkit.i18nText("Fine-Design_Chart_Condition_Display"); + String str = ShowValueUtils.joinStr4Position(Toolkit.i18nText("Fine-Design_Chart_Animation_Special"), Toolkit.i18nText("Fine-Design_Chart_Condition_Display")); if (StringUtils.isNotEmpty(conditionAttr.getName())) { - str += "-" + conditionAttr.getName(); + str = ShowValueUtils.joinStr4Position(str, conditionAttr.getName()); } + str = ShowValueUtils.joinStr4Position(str, name); if (condition instanceof AttrTooltip) { - arrayList.add(new Pair<>(((AttrTooltip) condition).getContent().getHtmlLabel(), str + "-" + Toolkit.i18nText("Fine-Design_Chart_Data_Point_Tooltip"))); + arrayList.add(new Pair<>(((AttrTooltip) condition).getContent().getHtmlLabel(), ShowValueUtils.joinStr4Position(str, Toolkit.i18nText("Fine-Design_Chart_Data_Point_Tooltip")))); } if (condition instanceof AttrLabel) { AttrLabel label = (AttrLabel) condition; if (isAttrLabelValid(label)) { - arrayList.add(new Pair<>(label.getContent().getHtmlLabel(), str + "-" + Toolkit.i18nText("Fine-Design_Chart_Label"))); + arrayList.add(new Pair<>(label.getContent().getHtmlLabel(), ShowValueUtils.joinStr4Position(str, Toolkit.i18nText("Fine-Design_Chart_Label")))); } } @@ -270,18 +331,51 @@ public class SearchJSUtils { * @param chartCollection * @return */ - public static List getNameJavaScript(ChartCollection chartCollection) { + public static List getNameJavaScript(ChartCollection chartCollection, ITContent content, List jsInfos) { ArrayList nameJavaScriptArrayList = new ArrayList<>(); for (int i = 0; i < chartCollection.getChartCount(); i++) { if (chartCollection.getChart(i) instanceof VanChart) { VanChart chart = ((VanChart) chartCollection.getChart(i)); - NameJavaScriptGroup nameJavaScriptGroup = chart.getPlot().getHotHyperLink(); - addNameJavaScript2Array(nameJavaScriptArrayList, nameJavaScriptGroup); + if (isCustomMapPlot(chart.getPlot())) { + dealMapNameJavaScript(content, chart.getPlot(), jsInfos); + } else { + NameJavaScriptGroup nameJavaScriptGroup = chart.getPlot().getHotHyperLink(); + addNameJavaScript2Array(nameJavaScriptArrayList, nameJavaScriptGroup); + } } } return nameJavaScriptArrayList; } + /** + * 是否是组合地图 + * @param plot 图表的plot + * @return 是则返回true + */ + public static boolean isCustomMapPlot(Plot plot) { + return plot instanceof VanChartMapPlot && ((VanChartMapPlot) plot).getMapType() == MapType.CUSTOM; + } + + + /** + * 处理图表的交互属性(可能存在多种地图) + * @param content 存储信息的数据结构 + * @param plot 图表的VanChartMapPlot + */ + private static void dealMapNameJavaScript(ITContent content, VanChartMapPlot plot, List jsInfos) { + List areaJavaScriptList = new ArrayList<>(); + List lineJavaScriptList = new ArrayList<>(); + List pointJavaScriptList = new ArrayList<>(); + + addNameJavaScript2Array(areaJavaScriptList, plot.getAreaHotHyperLink()); + addNameJavaScript2Array(lineJavaScriptList, plot.getLineHotHyperLink()); + addNameJavaScript2Array(pointJavaScriptList, plot.getPointHotHyperLink()); + + addJSInfosFromNameJS(ShowValueUtils.getCustomMapContent(content, Toolkit.i18nText("Fine-Design_Chart_Region_Map")), areaJavaScriptList, jsInfos); + addJSInfosFromNameJS(ShowValueUtils.getCustomMapContent(content, Toolkit.i18nText("Fine-Design_Chart_LineMap")), lineJavaScriptList, jsInfos); + addJSInfosFromNameJS(ShowValueUtils.getCustomMapContent(content, Toolkit.i18nText("Fine-Design_Chart_PointMap")), pointJavaScriptList, jsInfos); + } + private static void addNameJavaScript2Array(List nameJavaScriptArrayList, NameJavaScriptGroup nameJavaScriptGroup) { if (isNameJavaScriptGroupExist(nameJavaScriptGroup)) { for (int j = 0; j < nameJavaScriptGroup.size(); j++) { diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java index 01205bf886..cbd49d822d 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java @@ -2,6 +2,7 @@ package com.fr.design.actions.replace.utils; import com.fr.design.actions.replace.info.Info; +import com.fr.design.actions.replace.info.base.ITContent; import com.fr.design.actions.replace.ui.ITReplaceMainDialog; import com.fr.design.i18n.Toolkit; import com.fr.stable.StableUtils; @@ -391,14 +392,47 @@ public class ShowValueUtils { */ public static String getResultTip(int findCount, int replaceCount, int failedCount) { StringBuilder str = new StringBuilder(); - str.append("").append(Toolkit.i18nText("Fine-Design_Replace_Search_Finish")).append("").append(findCount).append("").append(Toolkit.i18nText("Fine-Design_Replace_Result")); + str.append("").append(Toolkit.i18nText("Fine-Design_Replace_Search_Finish", "" + findCount+ "")); if (replaceCount != 0) { - str.append(Toolkit.i18nText("Fine-Design_Replace_Also_Finish")).append("").append(replaceCount).append("").append(Toolkit.i18nText("Fine-Design_Replace_Result_Count")); + str.append(Toolkit.i18nText("Fine-Design_Replace_Also_Finish", "" + replaceCount + "")); if (failedCount != 0) { - str.append(Toolkit.i18nText("Fine-Design_Replace_Have")).append("").append(failedCount).append("").append(Toolkit.i18nText("Fine-Design_Replace_Can_Not_Replace")); + str.append(Toolkit.i18nText("Fine-Design_Replace_Have", "" + failedCount + "")); + } + } else { + if (failedCount != 0) { + str.append(Toolkit.i18nText("Fine-Design_Replace_Also_Finish", "" + replaceCount + "")); + str.append(Toolkit.i18nText("Fine-Design_Replace_Have", "" + failedCount + "")); } } return str.toString(); } + + + /** + * 返回图表类型的位置信息(组合图就需要加上对应的类型名称) + * @param str 基础信息 + * @param customStyle 组合图的类型信息 + * @return 组合后的位置信息 + */ + public static String getChartOtherPos(String str, String customStyle) { + if (StringUtils.isNotEmpty(customStyle)) { + return joinStr4Position(str, customStyle); + } else { + return str; + } + + } + + /** + * 用于获取增加指定地图后缀的ITContent + * @param content 原ITContent + * @param str 后缀 + * @return 处理后的新的ITContent + */ + public static ITContent getCustomMapContent(ITContent content, String str) { + ITContent resultContent = ITContent.copy(content); + resultContent.addOtherPos(str); + return resultContent; + } } From 7065e55ef02f036fa99c99f1d22fa234688f62a8 Mon Sep 17 00:00:00 2001 From: "Leo.Qin" Date: Thu, 3 Nov 2022 09:26:04 +0800 Subject: [PATCH 51/63] =?UTF-8?q?REPORT-80690=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E9=80=82=E9=85=8D=E9=80=82=E9=85=8D=E5=9F=8B=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cell/AbstractCellElementAction.java | 4 ++ .../actions/columnrow/ColumnWidthAction.java | 5 +- .../actions/columnrow/RowHeightAction.java | 4 ++ .../com/fr/quickeditor/CellQuickEditor.java | 50 +++++++++++++++++++ .../cellquick/CellDSColumnEditor.java | 4 +- 5 files changed, 65 insertions(+), 2 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/cell/AbstractCellElementAction.java b/designer-realize/src/main/java/com/fr/design/actions/cell/AbstractCellElementAction.java index 450c326915..52f3539788 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/cell/AbstractCellElementAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/cell/AbstractCellElementAction.java @@ -9,6 +9,7 @@ import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase; import com.fr.grid.GridUtils; import com.fr.grid.selection.CellSelection; +import com.fr.quickeditor.CellQuickEditor; import com.fr.report.cell.TemplateCellElement; import com.fr.report.core.SheetUtils; import com.fr.report.elementcase.TemplateElementCase; @@ -76,6 +77,9 @@ public abstract class AbstractCellElementAction extends CellSelectionAction { } } } + if (!ePane.isSelectedOneCell()) { + CellQuickEditor.record(CellQuickEditor.multipleOperationType.FILTER); + } ePane.fireTargetModified(); } diff --git a/designer-realize/src/main/java/com/fr/design/actions/columnrow/ColumnWidthAction.java b/designer-realize/src/main/java/com/fr/design/actions/columnrow/ColumnWidthAction.java index e363ee29e9..8ec7c90331 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/columnrow/ColumnWidthAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/columnrow/ColumnWidthAction.java @@ -4,8 +4,8 @@ package com.fr.design.actions.columnrow; import com.fr.design.mainframe.ElementCasePane; - import com.fr.grid.selection.CellSelection; +import com.fr.quickeditor.CellQuickEditor; import com.fr.report.elementcase.ElementCase; import com.fr.stable.unit.UNIT; @@ -32,6 +32,9 @@ public class ColumnWidthAction extends ColumnRowSizingAction { for (int i = 0; i < columns.length; i++) { report.setColumnWidth(columns[i], len); } + if (columns.length > 1) { + CellQuickEditor.record(CellQuickEditor.multipleOperationType.HEIHT_AND_COLUMN); + } } protected UNIT getIndexLen(int index, ElementCase report){ diff --git a/designer-realize/src/main/java/com/fr/design/actions/columnrow/RowHeightAction.java b/designer-realize/src/main/java/com/fr/design/actions/columnrow/RowHeightAction.java index 9485dc270a..ff4d63a1e9 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/columnrow/RowHeightAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/columnrow/RowHeightAction.java @@ -6,6 +6,7 @@ package com.fr.design.actions.columnrow; import com.fr.design.mainframe.ElementCasePane; import com.fr.grid.selection.CellSelection; +import com.fr.quickeditor.CellQuickEditor; import com.fr.report.elementcase.ElementCase; import com.fr.stable.unit.UNIT; @@ -32,6 +33,9 @@ public class RowHeightAction extends ColumnRowSizingAction { for (int i = 0; i < rows.length; i++) { report.setRowHeight(rows[i], len); } + if (rows.length > 1) { + CellQuickEditor.record(CellQuickEditor.multipleOperationType.HEIHT_AND_COLUMN); + } } @Override diff --git a/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java b/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java index 6f060b4f06..c84396b483 100644 --- a/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java +++ b/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java @@ -455,6 +455,9 @@ public abstract class CellQuickEditor extends QuickEditor { if (updateStyle) { // 防止频繁触发保存 + if (!tc.isSelectedOneCell()) { + record(multipleOperationType.FORMAT); + } fireTargetModified(); } @@ -469,4 +472,51 @@ public abstract class CellQuickEditor extends QuickEditor { return formatPane; } + + + /** + * 用于适配记录批量操作的埋点数据 + * + * @param type 批量操作修改类型 + * @return 批量修改类型名称 + */ + public static String record(multipleOperationType type) { + return type.getType(); + } + + /** + * 批量操作的类型 + */ + public enum multipleOperationType { + /** + * 批量修改格式 + */ + FORMAT("FORMAT"), + + /** + * 批量修改数据列的数据设置 + */ + TYPE_OF_DATA("type-of-data"), + + /** + * 批量修改过滤条件 + */ + FILTER("filter"), + + /** + * 批量修改行高列宽 + */ + HEIHT_AND_COLUMN("row-height-and-column-width"); + + + private final String type; + + multipleOperationType(String type) { + this.type = type; + } + + public String getType() { + return type; + } + } } diff --git a/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java b/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java index bd449de01d..575f89fb07 100644 --- a/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java +++ b/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java @@ -319,10 +319,12 @@ public class CellDSColumnEditor extends CellQuickEditor { public void itemStateChanged(ItemEvent e) { CellSelection selection = (CellSelection) tc.getSelection(); Set allCellElements = selection.getCellElements(); - groupPane.update(allCellElements); if (e == null || e.getStateChange() == ItemEvent.DESELECTED) { //分组-高级-自定义点确定的时候传进来null的e,但是这时候应该触发保存 groupPane.update(allCellElements); + if (!tc.isSelectedOneCell()) { + CellQuickEditor.record(multipleOperationType.TYPE_OF_DATA); + } fireTargetModified(); } } From 66ff36803c2bd10bcae73939bcda361b8f7b400b Mon Sep 17 00:00:00 2001 From: "Leo.Qin" Date: Thu, 3 Nov 2022 11:54:38 +0800 Subject: [PATCH 52/63] =?UTF-8?q?REPORT-80690=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=BC=A0=E5=85=A5=E6=A0=BC=E5=BC=8F=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/quickeditor/CellQuickEditor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java b/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java index c84396b483..55a3712626 100644 --- a/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java +++ b/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java @@ -491,7 +491,7 @@ public abstract class CellQuickEditor extends QuickEditor { /** * 批量修改格式 */ - FORMAT("FORMAT"), + FORMAT("Format"), /** * 批量修改数据列的数据设置 From cdde517142da265966ac84eb1a5a87501502fe36 Mon Sep 17 00:00:00 2001 From: "Leo.Qin" Date: Thu, 3 Nov 2022 14:08:14 +0800 Subject: [PATCH 53/63] =?UTF-8?q?REPORT-80690=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=BC=A0=E5=85=A5=E6=A0=BC=E5=BC=8F=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/quickeditor/CellQuickEditor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java b/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java index 55a3712626..354eb438fc 100644 --- a/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java +++ b/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java @@ -491,7 +491,7 @@ public abstract class CellQuickEditor extends QuickEditor { /** * 批量修改格式 */ - FORMAT("Format"), + FORMAT("format"), /** * 批量修改数据列的数据设置 From 9eeede7f68cf61766f2b36766ed96271b993853a Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Thu, 3 Nov 2022 14:38:42 +0800 Subject: [PATCH 54/63] =?UTF-8?q?REPORT-83624=20=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E6=9F=A5=E6=89=BE=E6=9B=BF=E6=8D=A2=E6=8F=90=E7=A4=BA=E8=AF=AD?= =?UTF-8?q?=E5=8F=A5key=E5=90=88=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/actions/replace/ui/ITCheckDialog.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITCheckDialog.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITCheckDialog.java index 9b82dea3ce..ac392692f0 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITCheckDialog.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITCheckDialog.java @@ -44,7 +44,7 @@ public class ITCheckDialog extends UIDialog { editorPane = new UITableEditorPane(editor); editor.add(ITReplaceMainDialog.getCheckValidList()); - UILabel label = new UILabel("" + Toolkit.i18nText("Fine-Design_Replace_Check") + "" + ITReplaceMainDialog.contentReplaceFailedCount + "" + Toolkit.i18nText("Fine-Design_Replace_Check_Tip")); + UILabel label = new UILabel("" + Toolkit.i18nText("Fine-Design_Replace_Check", "" + ITReplaceMainDialog.contentReplaceFailedCount + "")); JPanel center = new JPanel(new BorderLayout()); UIButton location = new UIButton(Toolkit.i18nText("Fine-Design_Chart_Location")); UIButton cancel = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Cancel")); From b427149792417182ce863348b97ea620a9187c9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvan-=E6=AC=A7=E9=98=B3=E5=B8=86?= Date: Thu, 3 Nov 2022 15:42:18 +0800 Subject: [PATCH 55/63] =?UTF-8?q?REPORT-83313=20=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=84=B1=E6=95=8F-=E7=82=B9=E5=87=BB=E2=80=9C=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=84=B1=E6=95=8F=E8=AE=BE=E7=BD=AE=E2=80=9D=E5=90=8E?= =?UTF-8?q?=E9=A2=84=E8=A7=88=E9=A1=B5=E9=9D=A2=E6=B2=A1=E6=9C=89=E6=B6=88?= =?UTF-8?q?=E5=A4=B1=20=E3=80=90=E9=97=AE=E9=A2=98=E5=8E=9F=E5=9B=A0?= =?UTF-8?q?=E3=80=91=E5=8E=9F=E6=9C=AC=E5=81=9A=E7=9A=84=E6=98=AF"?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=84=B1=E6=95=8F=E8=AE=BE=E7=BD=AE"?= =?UTF-8?q?=E9=9D=A2=E6=9D=BF=E6=98=AF=E9=A2=84=E8=A7=88=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=E4=B8=BAparent=E7=9A=84=E5=8F=A6=E4=B8=80=E4=B8=AAdialog?= =?UTF-8?q?=EF=BC=8C=E6=B2=A1=E6=8C=89=E7=85=A7=E4=BA=A7=E5=93=81=E6=96=87?= =?UTF-8?q?=E6=A1=A3=E9=87=8C=E5=81=9A=20=E3=80=90=E6=94=B9=E5=8A=A8?= =?UTF-8?q?=E6=96=B9=E6=A1=88=E3=80=91=E4=BF=AE=E6=94=B9=E4=B8=8B=EF=BC=8C?= =?UTF-8?q?=E6=89=93=E5=BC=80=E8=84=B1=E6=95=8F=E8=AE=BE=E7=BD=AE=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF=E7=9A=84=E5=90=8C=E6=97=B6=EF=BC=8C=E9=A2=84=E8=A7=88?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=B6=88=E5=A4=B1=20=E3=80=90review=E5=BB=BA?= =?UTF-8?q?=E8=AE=AE=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/data/datapane/preview/PreviewTablePane.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java index b701112f57..b09af3659b 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java @@ -248,8 +248,6 @@ public class PreviewTablePane extends BasicPane { if (Objects.nonNull(editingTemplate)) { editingTemplate.fireTargetModified(true); } - // 刷新预览页面 - refreshTable(); } @Override @@ -258,6 +256,8 @@ public class PreviewTablePane extends BasicPane { } }, BasicDialog.DEFAULT); dialog.setVisible(true); + // 关闭预览页面 + PreviewTablePane.this.dialog.setVisible(false); } }); From b86ab2dbaf2f08b9393bb65f9a4b2a7159799e18 Mon Sep 17 00:00:00 2001 From: "Leo.Qin" Date: Thu, 3 Nov 2022 16:18:51 +0800 Subject: [PATCH 56/63] =?UTF-8?q?REPORT-80690=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/quickeditor/CellQuickEditor.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java b/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java index 354eb438fc..67a65672f1 100644 --- a/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java +++ b/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java @@ -476,9 +476,10 @@ public abstract class CellQuickEditor extends QuickEditor { /** * 用于适配记录批量操作的埋点数据 + * 真正的埋点提交方案在云端运维插件中 * * @param type 批量操作修改类型 - * @return 批量修改类型名称 + * @return 批量修改类型名称,用于云端运维埋点记录 */ public static String record(multipleOperationType type) { return type.getType(); From 4a753e5782e25ee8aca17fdd203783aa9d89a91a Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Fri, 4 Nov 2022 09:46:26 +0800 Subject: [PATCH 57/63] =?UTF-8?q?REPORT-80695=20=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E5=85=A8=E5=B1=80=E7=BA=A7=E5=88=AB=E6=9F=A5=E6=89=BE=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2=E4=BA=8C=E6=9C=9F=20=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../actions/replace/action/ITChecker.java | 123 ++++++++++++++++++ .../content/component/ComponentType.java | 2 +- .../actions/replace/info/ComponentInfo.java | 4 +- .../actions/replace/info/WidgetInfo.java | 2 +- .../replace/ui/ITReplaceMainDialog.java | 31 ++++- .../replace/ui/ITReplaceNorthPanel.java | 9 +- 6 files changed, 157 insertions(+), 14 deletions(-) create mode 100644 designer-realize/src/main/java/com/fr/design/actions/replace/action/ITChecker.java diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/ITChecker.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/ITChecker.java new file mode 100644 index 0000000000..fddee0f038 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/ITChecker.java @@ -0,0 +1,123 @@ +package com.fr.design.actions.replace.action; + +import com.fr.design.actions.replace.info.Info; +import com.fr.design.i18n.Toolkit; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 校验JS、公式、控件、组件 + * 比较用户的所有对应类别的改动,不论是否选中要替换,只要整体类别改动过就算模板内容改动过 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-11-03 + */ +public enum ITChecker { + WIDGET_CHECK_TAG(Toolkit.i18nText("Fine-Design_Basic_Widget")), + FORMULA_CHECK_TAG(Toolkit.i18nText("Fine-Design_Basic_Formula")), + JS_CHECK_TAG(Toolkit.i18nText("Fine-Design_Replace_JS")), + COMPONENT_CHECK_TAG(Toolkit.i18nText("Fine-Design_Replace_Component")) + ; + + + String name; + + ITChecker(String name) { + this.name = name; + } + + + /** + * 匹配 + * + * @param name 对应的检查类型 + * @return 对应的检查checker + */ + @Nullable + public static ITChecker match(String name) { + ITChecker[] values = ITChecker.values(); + for (ITChecker value : values) { + if (value.name.equals(name)) { + return value; + } + } + return null; + } + + public static List checkList = new ArrayList<>(); + public static Map appearTimesMap = new HashMap<>(); + + + /** + * 更新对应的check列表 + * + * @param list 查找后的searchList + */ + public static void updateCheckInfo(List list) { + checkList = list; + updateCheckMapFromList(list); + } + + /** + * 根据列表来更新对应元素的匹配Map + * + * @param list 更新后的checkList + */ + private static void updateCheckMapFromList(List list) { + appearTimesMap.clear(); + for (Info info : list) { + String showStr = info.getContent().getOldShowStr(); + if (appearTimesMap.containsKey(showStr)) { + //如果已经存过了就个数+1 + appearTimesMap.put(showStr, appearTimesMap.get(showStr) + 1); + } else { + //没有的话就把个数初始化为1个 + appearTimesMap.put(showStr, 1); + } + } + } + + + /** + * 判断是否修改过 + * + * @param list 重新获取的当前模板最新的list + * @return 修改过返回true + */ + public boolean isChanged(List list) { + if (list.size() != checkList.size()) { + //如果总的数据的数量变了,就说明肯定修改过,没必要再进行下一步 + return true; + } + return isChangedCheckByMap(list); + } + + /** + * 通过检查Map来比较是否修改过 + * + * @param list 传入的用于比较的list + * @return 修改过则返回true + */ + private boolean isChangedCheckByMap(List list) { + for (Info info : list) { + String showStr = info.getContent().getOldShowStr(); + if (appearTimesMap.containsKey(showStr)) { + //如果map中存在对应的值,就抵消,个数-1 + appearTimesMap.put(showStr, appearTimesMap.get(showStr) - 1); + if (appearTimesMap.get(showStr) < 0) { + //如果map中的值小于0了,就说明数量对不上,修改过 + return true; + } + } else { + //如果存在map中没存的值就没必要继续下去了,肯定改过 + return true; + } + } + return false; + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/component/ComponentType.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/component/ComponentType.java index 13712a570a..de747cbeaa 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/component/ComponentType.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/component/ComponentType.java @@ -340,7 +340,7 @@ public enum ComponentType implements DealWithInfoValue { String str = widget.getWidgetName(); info.updateOldStr(widget.getWidgetName(), findStr); ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr); - widget.setWidgetName(widget.getWidgetName().replaceAll(findStr, replaceStr)); + widget.setWidgetName(ShowValueUtils.replaceAll(widget.getWidgetName(), findStr, replaceStr)); } } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/ComponentInfo.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/ComponentInfo.java index 77993c53db..c5667c7c41 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/info/ComponentInfo.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/ComponentInfo.java @@ -3,6 +3,7 @@ package com.fr.design.actions.replace.info; import com.fr.design.actions.replace.action.content.component.ComponentType; import com.fr.design.actions.replace.action.content.component.SearchComponentAction; import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.actions.replace.utils.ShowValueUtils; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.JTemplate; import com.fr.form.ui.Widget; @@ -92,7 +93,8 @@ public class ComponentInfo implements Info { } SearchComponentAction.getInstance().search4Infos(jTemplate); List list = SearchComponentAction.getInstance().getComponentInfos(); - String replacedName = ((Widget)this.getContent().getReplaceObject()).getWidgetName().replace(searchStr, replaceStr); + + String replacedName = ShowValueUtils.replaceAll(((Widget)this.getContent().getReplaceObject()).getWidgetName(), searchStr, replaceStr); for (ComponentInfo info : list) { String widgetName = ((Widget)info.getContent().getReplaceObject()).getWidgetName(); if (StringUtils.equals(replacedName, widgetName)) { diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/WidgetInfo.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/WidgetInfo.java index 4ebae73da9..051105bfad 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/info/WidgetInfo.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/WidgetInfo.java @@ -156,7 +156,7 @@ public class WidgetInfo implements Info, DealWithInfoValue { return false; } if (!this.isWaterMark() && this.isNeed2Check()) { - String replacedName = ((Widget)this.getContent().getReplaceObject()).getWidgetName().replace(searchStr, replaceStr); + String replacedName = ShowValueUtils.replaceAll(((Widget)this.getContent().getReplaceObject()).getWidgetName(), searchStr, replaceStr); for (WidgetName name : CheckUtils.getNeed2CheckWidgetsName(jTemplate)) { String widgetName = name.getName(); if (StringUtils.equals(replacedName, widgetName)) { diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java index 78daf0a09f..1990062967 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java @@ -1,6 +1,7 @@ package com.fr.design.actions.replace.ui; +import com.fr.design.actions.replace.action.ITChecker; import com.fr.design.actions.replace.action.ShowSearchResultAction; import com.fr.design.actions.replace.action.setting.SettingController; @@ -37,6 +38,7 @@ import java.util.ArrayList; import java.util.List; import java.util.regex.Pattern; +import static com.fr.design.actions.replace.ui.ITTableEditorPane.editTable; import static com.fr.design.actions.replace.ui.ITTableEditorPane.getEditTable; /** @@ -210,10 +212,13 @@ public class ITReplaceMainDialog extends UIDialog { * 模板内容替换相关 */ private void replace4Content() { + String type = ((UITextField) (northPane.getFindCombobox().getEditor().getEditorComponent())).getText(); String searchStr = ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).getText(); String replaceStr = ((UITextField) (northPane.getReplaceInputCombobox().getEditor().getEditorComponent())).getText(); clearContentCount(); - if (isITReplaceValid() && checkTemplateChanged(searchContentResultList)) { + if (isITReplaceValid() && checkTemplateChanged(searchContentResultList, type)) { + ShowSearchResultAction searchAction = ShowSearchResultAction.match(GeneralUtils.objectToString(northPane.getFindCombobox().getSelectedItem())); + ITChecker.updateCheckInfo(searchAction.addMatchResult(searchStr, searchAction.showSearchValue(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()))); if (StringUtils.equals(getSearchStr(), searchStr)) { String str = GeneralUtils.objectToString(northPane.getFindCombobox().getSelectedItem()); //如果是控件或组件才要进行合法性校验 @@ -257,7 +262,9 @@ public class ITReplaceMainDialog extends UIDialog { if (!info.getContent().isWrongful() && info.getContent().isSelected()) { info.setValue(info, searchStr, replaceStr, info.getContent().getOperatorArray()); } - info.getContent().setReplaced(true); + if (info.getContent().isSelected()) { + info.getContent().setReplaced(true); + } } northPane.getResultLabel().setText(ShowValueUtils.getResultTip(searchContentResultList.size(), contentReplaceCount, contentReplaceFailedCount)); southPanel.getTableEditorPane().update(); @@ -338,10 +345,18 @@ public class ITReplaceMainDialog extends UIDialog { } - private Boolean checkTemplateChanged(List searchResultList) { - for (Info info : searchResultList) { - if (!info.getContent().isReplaced() && !info.checkValid()) { - return false; + private Boolean checkTemplateChanged(List searchResultList, String type) { + ITChecker checker = ITChecker.match(type); + //对于JS、控件、组件、公式进行全量校验,不只针对当前选中的地方,这边先这样处理 + if (checker != null) { + ShowSearchResultAction searchAction = ShowSearchResultAction.match(GeneralUtils.objectToString(northPane.getFindCombobox().getSelectedItem())); + return !checker.isChanged(searchAction.addMatchResult(searchStr, searchAction.showSearchValue(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()))); + } else { + //其他地方走各自的校验逻辑 + for (Info info : searchResultList) { + if (!info.getContent().isReplaced() && !info.checkValid()) { + return false; + } } } return true; @@ -436,7 +451,9 @@ public class ITReplaceMainDialog extends UIDialog { ShowSearchResultAction searchAction = ShowSearchResultAction.match(GeneralUtils.objectToString(northPane.getFindCombobox().getSelectedItem())); //搜索 if (searchAction != null) { - searchContentResultList = searchAction.addMatchResult(searchStr, searchAction.showSearchValue(jTemplate)); + List showValueList = searchAction.showSearchValue(jTemplate); + searchContentResultList = searchAction.addMatchResult(searchStr, showValueList); + ITChecker.updateCheckInfo(searchContentResultList); itTableEditor.add(searchContentResultList); northPane.getResultLabel().setText(ShowValueUtils.getResultTip(searchContentResultList.size(), contentReplaceCount, contentReplaceFailedCount)); } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java index a11886c2c8..6739d3a42f 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java @@ -5,6 +5,7 @@ import com.fr.design.actions.replace.action.setting.SettingContent; import com.fr.design.actions.replace.action.setting.SettingController; import com.fr.design.data.datapane.TableDataComboBox; import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; @@ -51,7 +52,7 @@ public class ITReplaceNorthPanel { private UILabel resultLabel; private UIComboBox findCombobox; private UIComboBox rangeCombobox; - private JCheckBox matchRadioButton; + private UICheckBox matchRadioButton; private UILabel iconLabel; private UIComboBox findInputCombobox; private UIComboBox replaceInputCombobox; @@ -201,7 +202,7 @@ public class ITReplaceNorthPanel { super.setEditor(new ITComboBoxEditor()); } }; - matchRadioButton = new JCheckBox(Toolkit.i18nText("Fine-Design_Replace_WildCard")); + matchRadioButton = new UICheckBox(Toolkit.i18nText("Fine-Design_Replace_WildCard")); matchRadioButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -702,11 +703,11 @@ public class ITReplaceNorthPanel { this.rangeCombobox = rangeCombobox; } - public JCheckBox getMatchRadioButton() { + public UICheckBox getMatchRadioButton() { return matchRadioButton; } - public void setMatchRadioButton(JCheckBox checkBox) { + public void setMatchRadioButton(UICheckBox checkBox) { this.matchRadioButton = checkBox; } From 31c30d8c4fb900e368ee2ef4b6037fe8705f82ad Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Fri, 4 Nov 2022 09:51:26 +0800 Subject: [PATCH 58/63] =?UTF-8?q?REPORT-80695=20=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E5=85=A8=E5=B1=80=E7=BA=A7=E5=88=AB=E6=9F=A5=E6=89=BE=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2=E4=BA=8C=E6=9C=9F=20=E4=B8=BA=E4=BA=86=E9=80=9A?= =?UTF-8?q?=E8=BF=87=E6=8F=92=E4=BB=B6=E6=A0=A1=E9=AA=8C=EF=BC=8C=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E4=B8=80=E4=B8=8B=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/actions/replace/action/ITChecker.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/ITChecker.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/ITChecker.java index fddee0f038..ca15cd1a5b 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/ITChecker.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/ITChecker.java @@ -18,9 +18,21 @@ import java.util.Map; * created by Destiny.Lin on 2022-11-03 */ public enum ITChecker { + /** + * 控件 + */ WIDGET_CHECK_TAG(Toolkit.i18nText("Fine-Design_Basic_Widget")), + /** + * 公式 + */ FORMULA_CHECK_TAG(Toolkit.i18nText("Fine-Design_Basic_Formula")), + /** + * JS + */ JS_CHECK_TAG(Toolkit.i18nText("Fine-Design_Replace_JS")), + /** + * 组件 + */ COMPONENT_CHECK_TAG(Toolkit.i18nText("Fine-Design_Replace_Component")) ; From 246f174b2ec6fed8fcd1e97e5cc0c5a42dd3a638 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Fri, 4 Nov 2022 14:34:01 +0800 Subject: [PATCH 59/63] =?UTF-8?q?REPORT-80695=20=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E5=85=A8=E5=B1=80=E7=BA=A7=E5=88=AB=E6=9F=A5=E6=89=BE=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2=E4=BA=8C=E6=9C=9F=20=E4=BF=AE=E6=94=B9=E9=92=BB?= =?UTF-8?q?=E5=8F=96=E5=9C=B0=E5=9B=BE=E7=9A=84=E8=8E=B7=E5=8F=96=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SearchChartCollectionFormulaAction.java | 5 ++++ .../actions/replace/utils/SearchJSUtils.java | 29 ++++++++++++++++--- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartCollectionFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartCollectionFormulaAction.java index 40e5283ce9..69b763248c 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartCollectionFormulaAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartCollectionFormulaAction.java @@ -34,6 +34,7 @@ import com.fr.plugin.chart.custom.CustomPlotFactory; import com.fr.plugin.chart.custom.VanChartCustomPlot; import com.fr.plugin.chart.custom.type.CustomPlotType; +import com.fr.plugin.chart.drillmap.VanChartDrillMapPlot; import com.fr.plugin.chart.map.VanChartMapPlot; import com.fr.stable.StringUtils; @@ -106,6 +107,10 @@ public class SearchChartCollectionFormulaAction { customContent.addOtherPos(CustomPlotFactory.getTitle(CustomPlotFactory.getCustomType(plot.getCustomPlotList().get(i)))); dealPlot(formulaInfos, customContent, plot.getCustomPlotList().get(i)); } + } else if (chart.getPlot() instanceof VanChartDrillMapPlot) { + ITContent drillContent = ITContent.copy(conditionContent); + drillContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Drill_Dir")); + dealNameJavaScriptGroup(formulaInfos, drillContent, ((VanChartDrillMapPlot) chart.getPlot()).getDrillUpHyperLink()); } else if (chart.getPlot() != null) { dealPlot(formulaInfos, conditionContent, chart.getPlot()); } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/SearchJSUtils.java b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/SearchJSUtils.java index 8901f76edb..dbec52eefc 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/SearchJSUtils.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/SearchJSUtils.java @@ -26,6 +26,7 @@ import com.fr.plugin.chart.base.VanChartHtmlLabel; import com.fr.plugin.chart.custom.CustomPlotFactory; import com.fr.plugin.chart.custom.VanChartCustomPlot; import com.fr.plugin.chart.custom.type.CustomPlotType; +import com.fr.plugin.chart.drillmap.VanChartDrillMapPlot; import com.fr.plugin.chart.map.VanChartMapPlot; import com.fr.plugin.chart.map.attr.AttrMapLabel; import com.fr.plugin.chart.map.attr.AttrMapTooltip; @@ -338,6 +339,8 @@ public class SearchJSUtils { VanChart chart = ((VanChart) chartCollection.getChart(i)); if (isCustomMapPlot(chart.getPlot())) { dealMapNameJavaScript(content, chart.getPlot(), jsInfos); + } else if (chart.getPlot() instanceof VanChartDrillMapPlot) { + dealDrillNameJavaScript(content, chart.getPlot(), jsInfos); } else { NameJavaScriptGroup nameJavaScriptGroup = chart.getPlot().getHotHyperLink(); addNameJavaScript2Array(nameJavaScriptArrayList, nameJavaScriptGroup); @@ -347,6 +350,19 @@ public class SearchJSUtils { return nameJavaScriptArrayList; } + private static void dealDrillNameJavaScript(ITContent content, VanChartDrillMapPlot plot, List jsInfos) { + ITContent chartContent = ITContent.copy(content); + chartContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Chart_Chart"), + Toolkit.i18nText("Fine-Design_Chart_Animation_Special"), + Toolkit.i18nText("Fine-Design_Chart_Interactive"), + Toolkit.i18nText("Fine-Design_Chart_Drill_Dir") + ); + List list = new ArrayList<>(); + addNameJavaScript2Array(list, plot.getDrillUpHyperLink()); + addJSInfosFromNameJS(chartContent, list, jsInfos); + } + /** * 是否是组合地图 * @param plot 图表的plot @@ -366,14 +382,19 @@ public class SearchJSUtils { List areaJavaScriptList = new ArrayList<>(); List lineJavaScriptList = new ArrayList<>(); List pointJavaScriptList = new ArrayList<>(); - + ITContent chartContent = ITContent.copy(content); + chartContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Chart_Chart"), + Toolkit.i18nText("Fine-Design_Chart_Animation_Special"), + Toolkit.i18nText("Fine-Design_Chart_Interactive") + ); addNameJavaScript2Array(areaJavaScriptList, plot.getAreaHotHyperLink()); addNameJavaScript2Array(lineJavaScriptList, plot.getLineHotHyperLink()); addNameJavaScript2Array(pointJavaScriptList, plot.getPointHotHyperLink()); - addJSInfosFromNameJS(ShowValueUtils.getCustomMapContent(content, Toolkit.i18nText("Fine-Design_Chart_Region_Map")), areaJavaScriptList, jsInfos); - addJSInfosFromNameJS(ShowValueUtils.getCustomMapContent(content, Toolkit.i18nText("Fine-Design_Chart_LineMap")), lineJavaScriptList, jsInfos); - addJSInfosFromNameJS(ShowValueUtils.getCustomMapContent(content, Toolkit.i18nText("Fine-Design_Chart_PointMap")), pointJavaScriptList, jsInfos); + addJSInfosFromNameJS(ShowValueUtils.getCustomMapContent(chartContent, Toolkit.i18nText("Fine-Design_Chart_Region_Map")), areaJavaScriptList, jsInfos); + addJSInfosFromNameJS(ShowValueUtils.getCustomMapContent(chartContent, Toolkit.i18nText("Fine-Design_Chart_LineMap")), lineJavaScriptList, jsInfos); + addJSInfosFromNameJS(ShowValueUtils.getCustomMapContent(chartContent, Toolkit.i18nText("Fine-Design_Chart_PointMap")), pointJavaScriptList, jsInfos); } private static void addNameJavaScript2Array(List nameJavaScriptArrayList, NameJavaScriptGroup nameJavaScriptGroup) { From 588ee54b08b5f7c8b99155f1c24a55364402e3b9 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Fri, 4 Nov 2022 14:42:10 +0800 Subject: [PATCH 60/63] =?UTF-8?q?REPORT-80695=20=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E5=85=A8=E5=B1=80=E7=BA=A7=E5=88=AB=E6=9F=A5=E6=89=BE=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2=E4=BA=8C=E6=9C=9F=20=E4=BF=AE=E6=94=B9=E9=92=BB?= =?UTF-8?q?=E5=8F=96=E5=9C=B0=E5=9B=BE=E7=9A=84=E8=8E=B7=E5=8F=96=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../actions/replace/utils/SearchJSUtils.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/SearchJSUtils.java b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/SearchJSUtils.java index dbec52eefc..2a1a4ef188 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/SearchJSUtils.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/SearchJSUtils.java @@ -64,6 +64,14 @@ public class SearchJSUtils { */ public static final String CATEGORY_LABEL = ShowValueUtils.joinStr4Position(Toolkit.i18nText("Fine-Design_Basic_Style"), Toolkit.i18nText("Fine-Design_Chart_Data_Label"), Toolkit.i18nText("Fine-Design_Chart_Category_Label")); + /** + * 条件属性 + */ + public static final String CONDITION = ShowValueUtils.joinStr4Position( + Toolkit.i18nText("Fine-Design_Chart_Chart"), + Toolkit.i18nText("Fine-Design_Chart_Animation_Special"), + Toolkit.i18nText("Fine-Design_Chart_Interactive")); + /** * 从Listener中获取JS */ @@ -353,9 +361,7 @@ public class SearchJSUtils { private static void dealDrillNameJavaScript(ITContent content, VanChartDrillMapPlot plot, List jsInfos) { ITContent chartContent = ITContent.copy(content); chartContent.addOtherPos( - Toolkit.i18nText("Fine-Design_Chart_Chart"), - Toolkit.i18nText("Fine-Design_Chart_Animation_Special"), - Toolkit.i18nText("Fine-Design_Chart_Interactive"), + CONDITION, Toolkit.i18nText("Fine-Design_Chart_Drill_Dir") ); List list = new ArrayList<>(); @@ -383,11 +389,7 @@ public class SearchJSUtils { List lineJavaScriptList = new ArrayList<>(); List pointJavaScriptList = new ArrayList<>(); ITContent chartContent = ITContent.copy(content); - chartContent.addOtherPos( - Toolkit.i18nText("Fine-Design_Chart_Chart"), - Toolkit.i18nText("Fine-Design_Chart_Animation_Special"), - Toolkit.i18nText("Fine-Design_Chart_Interactive") - ); + chartContent.addOtherPos(CONDITION); addNameJavaScript2Array(areaJavaScriptList, plot.getAreaHotHyperLink()); addNameJavaScript2Array(lineJavaScriptList, plot.getLineHotHyperLink()); addNameJavaScript2Array(pointJavaScriptList, plot.getPointHotHyperLink()); From aa1322dcf050087ac3cc29cc6acc9785e74a8354 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Fri, 4 Nov 2022 15:12:11 +0800 Subject: [PATCH 61/63] =?UTF-8?q?REPORT-83876=20=E5=8D=95=E5=85=83?= =?UTF-8?q?=E6=A0=BC=E6=9B=BF=E6=8D=A2=E4=BA=863=E6=AC=A1=E4=BD=86?= =?UTF-8?q?=E6=92=A4=E5=9B=9E=E5=8F=98=E6=88=90=E4=BA=862=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/actions/replace/ui/ITReplaceMainDialog.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java index 1990062967..ba7b4bf445 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java @@ -257,7 +257,6 @@ public class ITReplaceMainDialog extends UIDialog { * @param replaceStr */ public void replace(String searchStr, String replaceStr) { - HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified(true); for (Info info : searchContentResultList) { if (!info.getContent().isWrongful() && info.getContent().isSelected()) { info.setValue(info, searchStr, replaceStr, info.getContent().getOperatorArray()); @@ -266,6 +265,7 @@ public class ITReplaceMainDialog extends UIDialog { info.getContent().setReplaced(true); } } + HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified(true); northPane.getResultLabel().setText(ShowValueUtils.getResultTip(searchContentResultList.size(), contentReplaceCount, contentReplaceFailedCount)); southPanel.getTableEditorPane().update(); northPane.refreshReplaceInputComboBoxItems(); @@ -529,7 +529,6 @@ public class ITReplaceMainDialog extends UIDialog { if (isInputStrValid(inputStr, extraStr)) { String secondStr = GeneralUtils.objectToString(northPane.getReplaceSettingInputComboBox().getSelectedItem()); String thirdStr = GeneralUtils.objectToString(northPane.getReplaceExtraSettingComboBox().getSelectedItem()); - HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified(true); for (Info info : searchSettingResultList) { if (isSupportReplace(info)) { SettingController controller = SettingController.match(firstStr); @@ -540,10 +539,10 @@ public class ITReplaceMainDialog extends UIDialog { } } } + HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified(true); northPane.getSettingResultLabel().setText(ShowValueUtils.getResultTip(searchSettingResultList.size(), settingReplaceCount, settingReplaceFailedCount)); southPanel.getTableEditorPane().update(); ITTableEditorPane.getEditTable().repaint(); - HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified(); } else { search4Setting(); } From 03a0807fef75e5c221751cffe827b8bcac84231e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvan-=E6=AC=A7=E9=98=B3=E5=B8=86?= Date: Fri, 4 Nov 2022 16:06:07 +0800 Subject: [PATCH 62/63] =?UTF-8?q?REPORT-80693=20=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=84=B1=E6=95=8F=E4=BA=8C=E6=9C=9F=20=E3=80=90=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E5=8E=9F=E5=9B=A0=E3=80=91=E4=B8=80=E6=9C=9F=E5=92=8C?= =?UTF-8?q?=E4=BA=8C=E6=9C=9F=E4=B8=80=E8=B5=B7=E5=89=A9=E4=BD=99=E4=BA=86?= =?UTF-8?q?=E6=AF=94=E8=BE=83=E5=A4=9A=E7=9A=84bug=EF=BC=8C=E5=A4=84?= =?UTF-8?q?=E7=90=86=E6=9C=89=E9=A3=8E=E9=99=A9=EF=BC=8C=E8=B7=9FLipei?= =?UTF-8?q?=E3=80=81Harrison=E3=80=81Alicia=E9=80=8F=E6=98=8E=E8=AE=A8?= =?UTF-8?q?=E8=AE=BA=E5=90=8E=EF=BC=8C=E7=A1=AE=E5=AE=9A=E5=85=88=E5=BB=B6?= =?UTF-8?q?=E6=9C=9F=E8=BF=AD=E4=BB=A3=EF=BC=8C=E5=B7=B2=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=9A=84=E4=BB=A3=E7=A0=81=E5=B1=8F=E8=94=BD=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=85=A5=E5=8F=A3=E4=B8=8E=E5=85=B3=E9=94=AE=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=20=E3=80=90=E6=94=B9=E5=8A=A8=E6=96=B9=E6=A1=88=E3=80=91?= =?UTF-8?q?=E5=85=B7=E4=BD=93=E5=B1=8F=E8=94=BD=E7=9A=84=E5=86=85=E5=AE=B9?= =?UTF-8?q?=EF=BC=8C=E8=AF=A6=E8=A7=81https://kms.fineres.com/pages/viewpa?= =?UTF-8?q?ge.action=3FpageId=3D568269880=20=E3=80=90review=E5=BB=BA?= =?UTF-8?q?=E8=AE=AE=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datapane/preview/PreviewTablePane.java | 421 ++++-------------- 1 file changed, 88 insertions(+), 333 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java index b09af3659b..5926dcb2df 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java @@ -3,39 +3,28 @@ */ package com.fr.design.data.datapane.preview; +import com.fr.base.BaseUtils; import com.fr.base.TableData; -import com.fr.base.svg.IconUtils; import com.fr.data.TableDataSource; -import com.fr.data.desensitize.base.DesensitizationTableData; import com.fr.data.impl.DBTableData; import com.fr.data.impl.EmbeddedTableData; import com.fr.data.impl.NameDataModel; import com.fr.data.operator.DataOperator; import com.fr.design.DesignerEnvManager; -import com.fr.design.constants.UIConstants; import com.fr.design.data.DesignTableDataManager; -import com.fr.design.data.datapane.preview.desensitization.TableDataPreviewDesensitizeManager; -import com.fr.design.data.datapane.preview.desensitization.model.DesensitizedPreviewTableModel; -import com.fr.design.data.datapane.preview.desensitization.view.setting.TableDataDesensitizationSettingPane; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicPane; -import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.gui.frpane.UITabbedPane; -import com.fr.design.gui.ibutton.UIToggleButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.iprogressbar.AutoProgressBar; import com.fr.design.gui.itable.SortableJTable; import com.fr.design.gui.itable.TableSorter; import com.fr.design.gui.itextfield.UINumberField; -import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; -import com.fr.design.mainframe.JTemplate; -import com.fr.design.menu.SeparatorDef; -import com.fr.design.menu.ToolBarDef; import com.fr.design.ui.util.UIUtil; import com.fr.function.TIME; import com.fr.general.FRFont; @@ -50,7 +39,6 @@ import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; -import javax.swing.SwingUtilities; import javax.swing.SwingWorker; import javax.swing.UIManager; import javax.swing.table.DefaultTableCellRenderer; @@ -69,19 +57,12 @@ import java.sql.Timestamp; import java.util.ArrayList; import java.util.Date; import java.util.List; -import java.util.Objects; import java.util.concurrent.CancellationException; /** * august: PreviewTablePane一共提供5个共有的静态方法,用来预览。 */ public class PreviewTablePane extends BasicPane { - - private static final String DATA_DESENSITIZATION_CONFIG = Toolkit.i18nText("Fine-Design_Report_Desensitization_Config"); - private static final String LEFT_BRACKET = "("; - private static final String RIGHT_BRACKET = ")"; - private static final String COUNT = Toolkit.i18nText("Fine-Design_Report_Desensitization_Count"); - private TableData tableData; private DataModel dataModel; private UINumberField maxPreviewNumberField; @@ -97,54 +78,6 @@ public class PreviewTablePane extends BasicPane { private static PreviewTablePane THIS; private EmbeddedTableData previewTableData; - private UILabel desensitizationLabel; - - /** - * 用于refreshLabel的鼠标监听 - */ - private final MouseAdapter refreshLabelMouseAdapter = new MouseAdapter() { - boolean mouseEntered = false; - boolean buttonPressed = false; - - @Override - public void mouseEntered(MouseEvent e) { // 当鼠标进入时候调用. - mouseEntered = true; - if (!buttonPressed) { - refreshLabel.setBackground(java.awt.Color.WHITE); - refreshLabel.setOpaque(true); - refreshLabel.setBorder(BorderFactory.createLineBorder(java.awt.Color.GRAY)); - } - } - - @Override - public void mouseExited(MouseEvent e) { - mouseEntered = false; - refreshLabel.setOpaque(false); - refreshLabel.setBorder(BorderFactory.createEmptyBorder()); - } - - @Override - public void mousePressed(MouseEvent e) { - buttonPressed = true; - refreshLabel.setBackground(java.awt.Color.lightGray); - } - - @Override - public void mouseReleased(MouseEvent e) { - buttonPressed = false; - if (mouseEntered) { - refreshLabel.setBackground(java.awt.Color.WHITE); - try { - populate(tableData); - if (dataModel != null) { - setRowsLimitTableModel(); - } - } catch (Exception ignore) { - } - } - } - }; - public static final PreviewTablePane getInstance() { if (THIS == null) { THIS = new PreviewTablePane(); @@ -154,175 +87,91 @@ public class PreviewTablePane extends BasicPane { private PreviewTablePane() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); - // northPane - this.add(initNorthPane(), BorderLayout.NORTH); - // centerPane - this.add(initCenterPane(), BorderLayout.CENTER); - // dialog - initDialog(); - // progressBar - initProgressBar(); - } - /** - * 初始化northPane - * - * @return - */ - private JComponent initNorthPane() { - JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - // 预览行数面板 - northPane.add(initPreviewNumberPane(), BorderLayout.CENTER); - // 脱敏预览设置面板 - northPane.add(initDesensitizationPane(), BorderLayout.EAST); - return northPane; - } - - /** - * 初始化预览行数面板 - * - * @return - */ - private JComponent initPreviewNumberPane() { + // elalke:预览行数 JPanel previewNumberPanel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); - // 当前行数 + this.add(previewNumberPanel, BorderLayout.NORTH); + JPanel currentPreviewPanel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + previewNumberPanel.add(currentPreviewPanel); currentPreviewPanel.add(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Current_Preview_Rows") + ":")); + currentRowsField = new UINumberField(); currentPreviewPanel.add(currentRowsField); currentRowsField.setEditable(false); currentRowsField.setColumns(4); currentRowsField.setInteger(true); - // 最大行数 + JPanel maxPanel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + previewNumberPanel.add(maxPanel); maxPanel.add(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Datasource_Maximum_Number_of_Preview_Rows") + ":")); + maxPreviewNumberField = new UINumberField(); maxPanel.add(maxPreviewNumberField); maxPreviewNumberField.setColumns(4); maxPreviewNumberField.setInteger(true); - maxPreviewNumberField.setValue(DesignerEnvManager.getEnvManager().getMaxNumberOrPreviewRow()); + + DesignerEnvManager designerEnvManager = DesignerEnvManager.getEnvManager(); + maxPreviewNumberField.setValue(designerEnvManager.getMaxNumberOrPreviewRow()); + maxPreviewNumberField.addActionListener(new ActionListener() { - @Override public void actionPerformed(ActionEvent evt) { DesignerEnvManager designerEnvManager = DesignerEnvManager.getEnvManager(); designerEnvManager.setMaxNumberOrPreviewRow((int) ((UINumberField) evt.getSource()).getValue()); } }); - // 刷新按钮 - initRefreshLabel(); - previewNumberPanel.add(currentPreviewPanel); - previewNumberPanel.add(maxPanel); - previewNumberPanel.add(refreshLabel); - return previewNumberPanel; - } - - private void initRefreshLabel() { - Icon refreshImage = IconUtils.readIcon("/com/fr/design/images/control/refresh"); + Icon refreshImage = BaseUtils.readIcon("/com/fr/design/images/control/refresh.png"); refreshLabel = new UILabel(refreshImage); - refreshLabel.addMouseListener(refreshLabelMouseAdapter); - } - - /** - * 初始化脱敏设置面板 - * - * @return - */ - private JComponent initDesensitizationPane() { - JPanel desensitizationPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); - // 初始化Label - desensitizationLabel = new UILabel(DATA_DESENSITIZATION_CONFIG); - desensitizationLabel.setForeground(UIConstants.NORMAL_BLUE); - desensitizationLabel.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - TableDataDesensitizationSettingPane settingPane = new TableDataDesensitizationSettingPane((DesensitizationTableData) tableData); - settingPane.populateBean((DesensitizationTableData) tableData); - BasicDialog dialog = settingPane.showWindowWithCustomSize(SwingUtilities.getWindowAncestor(PreviewTablePane.this), new DialogActionAdapter() { - @Override - public void doOk() { - // 保存脱敏规则配置 - settingPane.updateBean(); - // 改变模板保存状态 - JTemplate editingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - if (Objects.nonNull(editingTemplate)) { - editingTemplate.fireTargetModified(true); - } - } + previewNumberPanel.add(refreshLabel); + refreshLabel.addMouseListener(new MouseAdapter() { + boolean mouseEntered = false; + boolean buttonPressed = false; + + public void mouseEntered(MouseEvent e) { // 当鼠标进入时候调用. + mouseEntered = true; + if (!buttonPressed) { + refreshLabel.setBackground(java.awt.Color.WHITE); + refreshLabel.setOpaque(true); + refreshLabel.setBorder(BorderFactory.createLineBorder(java.awt.Color.GRAY)); + } + } - @Override - public void doCancel() { + public void mouseExited(MouseEvent e) { + mouseEntered = false; + refreshLabel.setOpaque(false); + refreshLabel.setBorder(BorderFactory.createEmptyBorder()); + } - } - }, BasicDialog.DEFAULT); - dialog.setVisible(true); - // 关闭预览页面 - PreviewTablePane.this.dialog.setVisible(false); + public void mousePressed(MouseEvent e) { + buttonPressed = true; + refreshLabel.setBackground(java.awt.Color.lightGray); } - }); - // 初始化分隔符 - ToolBarDef toolbarDef = new ToolBarDef(); - toolbarDef.addShortCut(SeparatorDef.DEFAULT); - UIToolbar toolBar = ToolBarDef.createJToolBar(); - toolBar.setBorderPainted(false); - toolbarDef.updateToolBar(toolBar); - - // 初始化预览按钮 - UIToggleButton previewToggle = new UIToggleButton(new Icon[]{IconUtils.readIcon("/com/fr/design/images/m_file/preview"), IconUtils.readIcon("/com/fr/design/images/m_file/preview")}, true); - previewToggle.setToolTipText(Toolkit.i18nText("Fine-Design_Report_Desensitization_Preview")); - previewToggle.setSelected(false); - previewToggle.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - // 切换TableModel的脱敏状态 - togglePreviewTableModelDesensitizeStatus(); - // 刷新页面,展示 - refreshTable(); + public void mouseReleased(MouseEvent e) { + buttonPressed = false; + if (mouseEntered) { + refreshLabel.setBackground(java.awt.Color.WHITE); + try { + populate(tableData); + if (dataModel != null) { + setRowsLimitTableModel(); + } + } catch (Exception e1) { + } + } } }); - desensitizationPane.add(desensitizationLabel); - desensitizationPane.add(toolBar); - desensitizationPane.add(previewToggle); - return desensitizationPane; - } - - /** - * 设置脱敏设置的个数 - * - * @param model - */ - private void setDesensitizationCount(TableModel model) { - if (isDesensitizeOpened()) { - int count = model instanceof DesensitizedPreviewTableModel ? ((DesensitizedPreviewTableModel) model).getDesensitizeColumnsCount() : 0; - desensitizationLabel.setText(DATA_DESENSITIZATION_CONFIG + LEFT_BRACKET + count + RIGHT_BRACKET + COUNT); - } else { - desensitizationLabel.setText(DATA_DESENSITIZATION_CONFIG); - } - } - - /** - * 初始化centerPane - * - * @return - */ - private JComponent initCenterPane() { preveiwTable = new CopyableJTable(new TableSorter()); preveiwTable.setRowSelectionAllowed(false); preveiwTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); - return new JScrollPane(preveiwTable); - } - private void initDialog() { + this.add(new JScrollPane(preveiwTable), BorderLayout.CENTER); if (this.dialog == null) { this.dialog = this.showWindow(new JFrame()); } - } - - private void initProgressBar() { progressBar = new AutoProgressBar(this, Toolkit.i18nText("Fine-Design_Basic_Loading_Data"), "", 0, 100) { - @Override public void doMonitorCanceled() { if (getWorker() != null) { getWorker().cancel(true); @@ -333,7 +182,7 @@ public class PreviewTablePane extends BasicPane { } public AutoProgressBar getProgressBar() { - return PreviewTablePane.progressBar; + return this.progressBar; } @Override @@ -373,19 +222,13 @@ public class PreviewTablePane extends BasicPane { return this.worker; } - /** - * 为预览表的columnIndex列着色. - * - * @param columnIndex 列索引值 - * @param c 颜色 - */ + // elake:为预览表的columnIndex列着c色. private void setPreviewTableColumnColor(final int columnIndex, final Color c) { addLoadedListener(new LoadedEventListener() { @Override public void fireLoaded() { TableColumn column = preveiwTable.getColumnModel().getColumn(columnIndex); DefaultTableCellRenderer cellRenderer = new DefaultTableCellRenderer() { - @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JComponent comp = (JComponent) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); comp.setBackground(c); @@ -406,7 +249,7 @@ public class PreviewTablePane extends BasicPane { getInstance().preveiwTable = new SortableJTable(new TableSorter()); getInstance().preveiwTable.setRowSelectionAllowed(false); getInstance().preveiwTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); - PreviewTablePane.progressBar.close(); + getInstance().progressBar.close(); getInstance().repaint(); } @@ -488,7 +331,6 @@ public class PreviewTablePane extends BasicPane { private void previewTableDataSQL() throws Exception { connectionBar = new AutoProgressBar(this, Toolkit.i18nText("Fine-Design_Basic_Utils_Now_Create_Connection"), "", 0, 100) { - @Override public void doMonitorCanceled() { getWorker().cancel(true); getDialog().setVisible(false); @@ -503,49 +345,42 @@ public class PreviewTablePane extends BasicPane { private void setPreviewTableColumnValue(final Graphics g) { for (int i = 0; i < preveiwTable.getColumnModel().getColumnCount(); i++) { TableColumn column = preveiwTable.getColumnModel().getColumn(i); - DefaultTableCellRenderer cellRenderer = getDefaultTableCellRenderer(); - column.setCellRenderer(cellRenderer); - } - } - - /** - * 默认表格格子渲染器 - * - * @return - */ - private DefaultTableCellRenderer getDefaultTableCellRenderer() { - return new DefaultTableCellRenderer() { - @Override - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { - JComponent comp = (JComponent) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); - Font f = table.getFont(); - - //默认在系统不支持 无法显示时 如自造的字 ,字体设置为空. - Font defaultShowFont = FRFont.getInstance("", f.getStyle(), f.getSize()); - if (value instanceof String) { - String str = (String) value; - for (int j = 0; j < str.length(); j++) { - char c = str.charAt(j); - if (!f.canDisplay(c)) { - table.setFont(defaultShowFont); + DefaultTableCellRenderer cellRenderer = new DefaultTableCellRenderer() { + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + JComponent comp = (JComponent) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + Font f = table.getFont(); + + //默认在系统不支持 无法显示时 如自造的字 ,字体设置为空. + Font defaultShowFont = FRFont.getInstance("", f.getStyle(), f.getSize()); + if (value instanceof String) { + String str = (String) value; + for (int j = 0; j < str.length(); j++) { + char c = str.charAt(j); + if (!f.canDisplay(c)) { + table.setFont(defaultShowFont); + } } } + return comp; } - return comp; - } - }; + }; + column.setCellRenderer(cellRenderer); + } } private void setWorker() { - worker = new SwingWorker() { - - @Override - protected TableModel doInBackground() throws Exception { + worker = new SwingWorker() { + protected PreviewTableModel doInBackground() throws Exception { connectionBar.start(); try { - testDBTableDataConnection(tableData); + if (tableData instanceof DBTableData) { + boolean status = DataOperator.getInstance().testConnection(((DBTableData) tableData).getDatabase()); + if (!status) { + throw new Exception(Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed")); + } + } } finally { // 将close操作放到EDT线程中 UIUtil.invokeLaterIfNeeded(() -> connectionBar.close()); @@ -555,20 +390,22 @@ public class PreviewTablePane extends BasicPane { // parameterInputDialog // update之后的parameters,转成一个parameterMap,用于预览TableData PreviewTableModel previewModel = new PreviewTableModel(previewTableData.createDataModel(null), (int) maxPreviewNumberField.getValue()); - if (TableDataPreviewDesensitizeManager.getInstance().needDesensitize(tableData)) { - // 数据集预览脱敏 - previewModel = TableDataPreviewDesensitizeManager.getInstance().desensitizeTableModel(tableData, previewModel); + for (int i = 0; i < previewTableData.getColumnCount(); i++) { + Class cls = previewTableData.getColumnClass(i); + if (cls == Date.class || cls == TIME.class || cls == Timestamp.class) { + previewModel.dateIndexs.add(i); + } } - dealWithPreviewTableModelColumnClass(previewModel, previewTableData); return previewModel; } - @Override public void done() { try { - TableModel model = get(); - setPreviewTableModel(model); + PreviewTableModel model = get(); + setModel(model); + setCurrentRows(model.getRowCount()); setPreviewTableColumnValue(getParent().getGraphics()); + fireLoadedListener(); } catch (Exception e) { if (!(e instanceof CancellationException)) { FineLoggerFactory.getLogger().error(e.getMessage(), e); @@ -583,36 +420,6 @@ public class PreviewTablePane extends BasicPane { }; } - /** - * 检查DBTableData连接 - * - * @param tableData - * @throws Exception - */ - private void testDBTableDataConnection(TableData tableData) throws Exception { - if (tableData instanceof DBTableData) { - boolean status = DataOperator.getInstance().testConnection(((DBTableData) tableData).getDatabase()); - if (!status) { - throw new Exception(Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed")); - } - } - } - - /** - * 处理预览Model的列类型 - * - * @param previewModel - * @param previewTableData - */ - private void dealWithPreviewTableModelColumnClass(PreviewTableModel previewModel, EmbeddedTableData previewTableData) { - for (int i = 0; i < previewTableData.getColumnCount(); i++) { - Class cls = previewTableData.getColumnClass(i); - if (cls == Date.class || cls == TIME.class || cls == Timestamp.class) { - previewModel.dateIndexs.add(i); - } - } - } - /** * 直接预览存储过程的一个返回数据集,没有实际值和显示值 * @@ -721,61 +528,9 @@ public class PreviewTablePane extends BasicPane { } catch (Exception e) { previewModel = new PreviewTableModel((int) maxPreviewNumberField.getValue()); } - setPreviewTableModel(previewModel); - - } - - /** - * 切换TableModel的展示状态 - */ - private void togglePreviewTableModelDesensitizeStatus() { - if (!isDesensitizeOpened()) { - // 未启用数据脱敏时,不需要切换 - return; - } - TableSorter tableSorter = (TableSorter) preveiwTable.getModel(); - TableModel originTableModel = tableSorter.getTableModel(); - if (originTableModel instanceof DesensitizedPreviewTableModel) { - ((DesensitizedPreviewTableModel) originTableModel).toggleNeedDesensite(); - } - } - - /** - * 刷新一下预览页面,用于切换脱敏和非脱敏时的显示 - */ - private void refreshTable() { - TableModel originTableModel = getCurrentTableModel(); - setPreviewTableModel(originTableModel); - } - - /** - * 获取当前的TableModel,已经除掉了TableSorter的包装 - * - * @return - */ - private TableModel getCurrentTableModel() { - TableSorter tableSorter = (TableSorter) preveiwTable.getModel(); - return tableSorter.getTableModel(); - } - - /** - * 设置预览TableModel - * - * @param previewTableModel - */ - private void setPreviewTableModel(TableModel previewTableModel) { - setDesensitizationCount(previewTableModel); - setModel(previewTableModel); - setCurrentRows(previewTableModel.getRowCount()); + setModel(previewModel); + setCurrentRows(previewModel.getRowCount()); fireLoadedListener(); - } - /** - * 数据脱敏是否启用 - * @return - */ - private boolean isDesensitizeOpened() { - return tableData instanceof DesensitizationTableData && - ((DesensitizationTableData) tableData).getDesensitizationConfig().isDesensitizeOpened(); } } From 7c2c59c2be07fe6d36eb4f31062bf32c7802cb5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvan-=E6=AC=A7=E9=98=B3=E5=B8=86?= Date: Fri, 4 Nov 2022 16:15:42 +0800 Subject: [PATCH 63/63] =?UTF-8?q?REPORT-80693=20=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=84=B1=E6=95=8F=E4=BA=8C=E6=9C=9F=20=E5=9C=88=E5=A4=8D?= =?UTF-8?q?=E6=9D=82=E5=BA=A6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/data/datapane/preview/PreviewTablePane.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java index 5926dcb2df..c9708087bf 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java @@ -222,7 +222,11 @@ public class PreviewTablePane extends BasicPane { return this.worker; } - // elake:为预览表的columnIndex列着c色. + /** + * elake:为预览表的columnIndex列着色. + * @param columnIndex + * @param c + */ private void setPreviewTableColumnColor(final int columnIndex, final Color c) { addLoadedListener(new LoadedEventListener() { @Override