From 850e2c968e35804ebac4c46bc900638b7715be8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvan-=E6=AC=A7=E9=98=B3=E5=B8=86?= Date: Mon, 14 Nov 2022 14:35:11 +0800 Subject: [PATCH 01/15] =?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=B8=8A?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=9B=A0=E4=B8=BA=E8=BF=AD=E4=BB=A3=E5=BB=B6?= =?UTF-8?q?=E6=9C=9F=E5=B1=8F=E8=94=BD=E4=BA=86=E4=BB=A3=E7=A0=81=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=85=A5=E5=8F=A3=20=E3=80=90=E6=94=B9=E5=8A=A8?= =?UTF-8?q?=E6=80=9D=E8=B7=AF=E3=80=91=E5=B0=86=E5=B1=8F=E8=94=BD=E5=8F=96?= =?UTF-8?q?=E6=B6=88=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 --- .../datapane/preview/PreviewTablePane.java | 424 ++++++++++++++---- 1 file changed, 333 insertions(+), 91 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 c9708087bf..6859c77874 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.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; @@ -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((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); } - } catch (Exception e1) { } - } + + @Override + public void doCancel() { + + } + }, BasicDialog.DEFAULT); + dialog.setVisible(true); + // 关闭预览页面 + PreviewTablePane.this.dialog.setVisible(false); } }); + // 初始化分隔符 + 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 @@ -223,9 +374,10 @@ public class PreviewTablePane extends BasicPane { } /** - * elake:为预览表的columnIndex列着色. - * @param columnIndex - * @param c + * 为预览表的columnIndex列着色. + * + * @param columnIndex 列索引值 + * @param c 颜色 */ private void setPreviewTableColumnColor(final int columnIndex, final Color c) { addLoadedListener(new LoadedEventListener() { @@ -233,6 +385,7 @@ public class PreviewTablePane extends BasicPane { 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); @@ -253,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(); } @@ -335,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); @@ -349,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()); @@ -394,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); @@ -424,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); + } + } + } + /** * 直接预览存储过程的一个返回数据集,没有实际值和显示值 * @@ -454,7 +643,7 @@ public class PreviewTablePane extends BasicPane { /** * 直接预览数据集的结果集 * - * @param dataModel 结果集 + * @param dataModel 结果集 * @param keyIndex * @param valueIndex */ @@ -532,9 +721,62 @@ 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 DesensitizationTableData && + ((DesensitizationTableData) tableData).getDesensitizationConfig().isDesensitizeOpened(); } } From 34f9aba6eb86c4b242c575de5ac192547e41a250 Mon Sep 17 00:00:00 2001 From: "Coral.Chen" Date: Mon, 14 Nov 2022 15:59:05 +0800 Subject: [PATCH 02/15] =?UTF-8?q?REPORT-83625=20=E9=80=82=E9=85=8DBaseCrit?= =?UTF-8?q?eria=E5=9C=A8cbb=E4=B8=AD=E7=9A=84=E5=8C=85=E5=90=8D=E6=94=B9?= =?UTF-8?q?=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/mainframe/loghandler/DesignerLogHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java index 621956ce6a..b36ca47294 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java @@ -1,6 +1,6 @@ package com.fr.design.mainframe.loghandler; -import com.finebi.cbb.base.tuple.Pair; +import com.fr.stable.collections.combination.Pair; import com.fr.base.BaseUtils; import com.fr.base.TRL; import com.fr.design.file.HistoryTemplateListCache; From 56e2d9acbd75d23c2262ed33fd9e34aa321a3281 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Mon, 14 Nov 2022 16:57:18 +0800 Subject: [PATCH 03/15] =?UTF-8?q?REPORT-83391=20=E9=A1=B6=E9=83=A8?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E9=9D=A2=E6=9D=BF=E4=BD=93=E9=AA=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/topparam/MobileTopParamPane.java | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/topparam/MobileTopParamPane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/topparam/MobileTopParamPane.java index 7f19bd3683..34a5f9758b 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/topparam/MobileTopParamPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/topparam/MobileTopParamPane.java @@ -2,8 +2,12 @@ package com.fr.design.mainframe.mobile.ui.topparam; import com.fr.design.beans.BasicBeanPane; import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.ispinner.UISpinner; 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.form.ui.mobile.impl.MobileTopParamStyle; import javax.swing.*; @@ -11,6 +15,13 @@ import java.awt.*; public class MobileTopParamPane extends BasicBeanPane { private UICheckBox autoCommitCheckBox; + private UISpinner maxDirectShowCountSpinner; + private UILabel showCountTextField; + private static final int MAX_VALUE = 4; + private static final int MIN_VALUE = 0; + private static final int DEFAULT_DIERTA = 1; + private static final int DEFAULT_VALUE = 0; + private static final int GAP = 2; public MobileTopParamPane() { this.init(); @@ -21,19 +32,29 @@ public class MobileTopParamPane extends BasicBeanPane { JPanel panel = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Plugin-TopParam_Setting")); panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); autoCommitCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Plugin-TopParam_AutoCommit"), true); - panel.add(autoCommitCheckBox); + maxDirectShowCountSpinner = new UISpinner(MIN_VALUE, MAX_VALUE, DEFAULT_DIERTA, DEFAULT_VALUE); + showCountTextField = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_Show_Count")); + Component[][] components = {{autoCommitCheckBox},{showCountTextField, maxDirectShowCountSpinner}}; + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] portRowSize = {p, p}; + double[] portColumnSize = {p, f}; + JPanel portComPane = TableLayoutHelper.createCommonTableLayoutPane(components, portRowSize, portColumnSize, GAP); + panel.add(portComPane); this.add(panel, BorderLayout.CENTER); } @Override public void populateBean(MobileTopParamStyle topParamStyle) { autoCommitCheckBox.setSelected(topParamStyle.isAutoCommit()); + maxDirectShowCountSpinner.setValue(topParamStyle.getMaxDirectShowCount()); } @Override public MobileTopParamStyle updateBean() { MobileTopParamStyle topParamStyle = new MobileTopParamStyle(); topParamStyle.setAutoCommit(autoCommitCheckBox.isSelected()); + topParamStyle.setMaxDirectShowCount((int) maxDirectShowCountSpinner.getValue()); return topParamStyle; } From 7a96c504410d4e1fa9fb8a8ba2da2c4a2343ab3e Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Mon, 14 Nov 2022 17:17:35 +0800 Subject: [PATCH 04/15] =?UTF-8?q?REPORT-83391=20=E9=A1=B6=E9=83=A8?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E9=9D=A2=E6=9D=BF=E4=BD=93=E9=AA=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96=20=E4=BF=AE=E6=94=B9=E4=B8=8B=E5=8F=98=E9=87=8F?= =?UTF-8?q?=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/mobile/ui/topparam/MobileTopParamPane.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/topparam/MobileTopParamPane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/topparam/MobileTopParamPane.java index 34a5f9758b..c0fb6028ed 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/topparam/MobileTopParamPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/topparam/MobileTopParamPane.java @@ -37,10 +37,10 @@ public class MobileTopParamPane extends BasicBeanPane { Component[][] components = {{autoCommitCheckBox},{showCountTextField, maxDirectShowCountSpinner}}; double p = TableLayout.PREFERRED; double f = TableLayout.FILL; - double[] portRowSize = {p, p}; - double[] portColumnSize = {p, f}; - JPanel portComPane = TableLayoutHelper.createCommonTableLayoutPane(components, portRowSize, portColumnSize, GAP); - panel.add(portComPane); + double[] rowSize = {p, p}; + double[] columnSize = {p, f}; + JPanel paraPane = TableLayoutHelper.createCommonTableLayoutPane(components, rowSize, columnSize, GAP); + panel.add(paraPane); this.add(panel, BorderLayout.CENTER); } From 6c53a08939474a426042844e1612743d5d2f94c3 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Mon, 14 Nov 2022 17:24:46 +0800 Subject: [PATCH 05/15] =?UTF-8?q?REPORT-83391=20=E9=A1=B6=E9=83=A8?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E9=9D=A2=E6=9D=BF=E4=BD=93=E9=AA=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96=20=E4=BF=AE=E6=94=B9.*=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/mobile/ui/topparam/MobileTopParamPane.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/topparam/MobileTopParamPane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/topparam/MobileTopParamPane.java index c0fb6028ed..f367365f75 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/topparam/MobileTopParamPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/topparam/MobileTopParamPane.java @@ -10,8 +10,10 @@ import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.form.ui.mobile.impl.MobileTopParamStyle; -import javax.swing.*; -import java.awt.*; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.FlowLayout; public class MobileTopParamPane extends BasicBeanPane { private UICheckBox autoCommitCheckBox; From b3836e0a3994f1001f9898d7fea674f77ec5719a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvan-=E6=AC=A7=E9=98=B3=E5=B8=86?= Date: Tue, 15 Nov 2022 11:00:40 +0800 Subject: [PATCH 06/15] =?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=E5=A4=84?= =?UTF-8?q?=E7=90=86=E6=96=B0=E5=A2=9E=E4=BB=A3=E7=A0=81=E8=A1=8C=E6=95=B0?= =?UTF-8?q?=E5=A4=AA=E5=A4=9A=E7=9A=84=E9=97=AE=E9=A2=98=20=E3=80=90?= =?UTF-8?q?=E6=94=B9=E5=8A=A8=E6=80=9D=E8=B7=AF=E3=80=91=E5=B0=86=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E7=9A=84UI=E9=9D=A2=E6=9D=BF=E6=8B=86=E5=87=BA?= =?UTF-8?q?=E6=9D=A5=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 --- .../datapane/preview/PreviewTablePane.java | 115 ++++++----------- .../view/PreviewTableDesensitizationPane.java | 120 ++++++++++++++++++ 2 files changed, 156 insertions(+), 79 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/PreviewTableDesensitizationPane.java 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 6859c77874..e4d1667405 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 @@ -12,10 +12,10 @@ 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.PreviewTableDesensitizationPane; import com.fr.design.data.datapane.preview.desensitization.view.setting.TableDataDesensitizationSettingPane; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicPane; @@ -23,19 +23,15 @@ 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; @@ -61,8 +57,6 @@ import java.awt.Color; import java.awt.Component; import java.awt.Font; import java.awt.Graphics; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.sql.Timestamp; @@ -77,11 +71,6 @@ import java.util.concurrent.CancellationException; */ 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,7 +86,7 @@ public class PreviewTablePane extends BasicPane { private static PreviewTablePane THIS; private EmbeddedTableData previewTableData; - private UILabel desensitizationLabel; + private PreviewTableDesensitizationPane desensitizationPane; /** * 用于refreshLabel的鼠标监听 @@ -201,12 +190,9 @@ public class PreviewTablePane extends BasicPane { maxPreviewNumberField.setColumns(4); maxPreviewNumberField.setInteger(true); 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()); - } + maxPreviewNumberField.addActionListener(event -> { + DesignerEnvManager designerEnvManager = DesignerEnvManager.getEnvManager(); + designerEnvManager.setMaxNumberOrPreviewRow((int) ((UINumberField) event.getSource()).getValue()); }); // 刷新按钮 initRefreshLabel(); @@ -229,63 +215,36 @@ public class PreviewTablePane extends BasicPane { * @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); - } - } - - @Override - public void doCancel() { + desensitizationPane = new PreviewTableDesensitizationPane(this); + return desensitizationPane; + } - } - }, BasicDialog.DEFAULT); - dialog.setVisible(true); - // 关闭预览页面 - PreviewTablePane.this.dialog.setVisible(false); + /** + * 点击脱敏配置后的操作 + */ + public void clickDesensitizationLabel() { + 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); + } } - }); - // 初始化分隔符 - 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 doCancel() { - desensitizationPane.add(desensitizationLabel); - desensitizationPane.add(toolBar); - desensitizationPane.add(previewToggle); - return desensitizationPane; + } + }, BasicDialog.DEFAULT); + dialog.setVisible(true); + // 关闭预览页面 + PreviewTablePane.this.dialog.setVisible(false); } /** @@ -294,12 +253,10 @@ public class PreviewTablePane extends BasicPane { * @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); - } + desensitizationPane.setDesensitizationCount(isDesensitizeOpened(), + model instanceof DesensitizedPreviewTableModel ? + ((DesensitizedPreviewTableModel) model).getDesensitizeColumnsCount() : + 0); } /** @@ -728,7 +685,7 @@ public class PreviewTablePane extends BasicPane { /** * 切换TableModel的展示状态 */ - private void togglePreviewTableModelDesensitizeStatus() { + public void togglePreviewTableModelDesensitizeStatus() { if (!isDesensitizeOpened()) { // 未启用数据脱敏时,不需要切换 return; @@ -743,7 +700,7 @@ public class PreviewTablePane extends BasicPane { /** * 刷新一下预览页面,用于切换脱敏和非脱敏时的显示 */ - private void refreshTable() { + public void refreshTable() { TableModel originTableModel = getCurrentTableModel(); setPreviewTableModel(originTableModel); } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/PreviewTableDesensitizationPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/PreviewTableDesensitizationPane.java new file mode 100644 index 0000000000..1bf150dd51 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/PreviewTableDesensitizationPane.java @@ -0,0 +1,120 @@ +package com.fr.design.data.datapane.preview.desensitization.view; + +import com.fr.base.svg.IconUtils; +import com.fr.design.constants.UIConstants; +import com.fr.design.data.datapane.preview.PreviewTablePane; +import com.fr.design.gui.ibutton.UIToggleButton; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itoolbar.UIToolbar; +import com.fr.design.i18n.Toolkit; +import com.fr.design.menu.SeparatorDef; +import com.fr.design.menu.ToolBarDef; + +import javax.swing.Icon; +import javax.swing.JPanel; +import java.awt.Component; +import java.awt.FlowLayout; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +/** + * 数据集预览-脱敏配置面板,主要展示当前脱敏开启状态、当前脱敏设定数量等 + * + * @author Yvan + * @version 11.0 + * Created by Yvan on 2022/11/14 + */ +public class PreviewTableDesensitizationPane extends JPanel { + + 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 PreviewTablePane previewTablePane; + + /** + * "数据脱敏设置"-标签 + */ + private UILabel desensitizationLabel; + + /** + * 脱敏效果预览按钮 + */ + private UIToggleButton previewToggle; + + + public PreviewTableDesensitizationPane(PreviewTablePane previewTablePane) { + this.previewTablePane = previewTablePane; + initComponents(); + } + + /** + * 初始化面板 + */ + private void initComponents() { + this.setLayout(new FlowLayout(FlowLayout.LEFT)); + this.add(initDesensitizationLabel()); + this.add(initToolBar()); + this.add(initPreviewButton()); + } + + /** + * 初始化Label + * + * @return + */ + private Component initDesensitizationLabel() { + // 初始化Label + desensitizationLabel = new UILabel(DATA_DESENSITIZATION_CONFIG); + desensitizationLabel.setForeground(UIConstants.NORMAL_BLUE); + desensitizationLabel.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + previewTablePane.clickDesensitizationLabel(); + } + }); + return desensitizationLabel; + } + + /** + * 初始化分隔符 + * + * @return + */ + private UIToolbar initToolBar() { + ToolBarDef toolbarDef = new ToolBarDef(); + toolbarDef.addShortCut(SeparatorDef.DEFAULT); + UIToolbar toolBar = ToolBarDef.createJToolBar(); + toolBar.setBorderPainted(false); + toolbarDef.updateToolBar(toolBar); + return toolBar; + } + + /** + * 初始化脱敏效果预览按钮 + * + * @return + */ + private UIToggleButton initPreviewButton() { + 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(e -> { + // 切换TableModel的脱敏状态 + previewTablePane.togglePreviewTableModelDesensitizeStatus(); + // 刷新预览页面,展示 + previewTablePane.refreshTable(); + }); + return previewToggle; + } + + public void setDesensitizationCount(boolean desensitizeOpen, int count) { + desensitizationLabel.setText(desensitizeOpen ? + DATA_DESENSITIZATION_CONFIG + LEFT_BRACKET + count + RIGHT_BRACKET + COUNT : + DATA_DESENSITIZATION_CONFIG); + } +} From 0fbd8b0c6bb88422991de31f81f694592595d716 Mon Sep 17 00:00:00 2001 From: Harrison Date: Tue, 15 Nov 2022 20:03:33 +0800 Subject: [PATCH 07/15] =?UTF-8?q?REPORT-83197=E3=80=90=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E3=80=91=E5=90=AF=E5=8A=A8=E9=A1=B5=E6=80=A7=E8=83=BD?= =?UTF-8?q?=E4=BC=98=E5=8C=96=201=E3=80=81DesignerEnvManager=20=E5=BC=82?= =?UTF-8?q?=E6=AD=A5=E5=8A=A0=E8=BD=BD=202=E3=80=81=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=8A=9F=E8=83=BD=E4=BC=98=E5=8C=96,=20?= =?UTF-8?q?=E6=94=B9=E6=88=90=E5=BC=82=E6=AD=A5=203=E3=80=81=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E9=A1=B5=E5=90=AF=E5=8A=A8=E6=97=B6=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E5=8F=98=E5=8C=96=204=E3=80=81=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E5=BC=82=E6=AD=A5=E9=9D=A2=E6=9D=BF=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/DesignerEnvManager.java | 292 +++++++++++++++--- .../fr/design/actions/core/ActionFactory.java | 40 ++- .../env/LocalDesignerWorkspaceInfo.java | 7 + .../main/java/com/fr/start/BaseDesigner.java | 3 +- .../fr/start/common/DesignerStartupPool.java | 21 +- .../fr/startup/ui/StartupLoadingPanel.java | 113 +++++++ .../com/fr/startup/ui/StartupPageWindow.java | 87 +++--- .../main/java/com/fr/start/MainDesigner.java | 30 +- .../fr/start/module/DesignerActivator.java | 39 ++- .../com/fr/start/module/DesignerStartup.java | 2 +- .../DesignerStartupPageActivator.java | 54 +++- .../com/fr/start/preload/PreLoadService.java | 20 +- 12 files changed, 566 insertions(+), 142 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/startup/ui/StartupLoadingPanel.java diff --git a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java index f7bff1f5b5..b4a9f5934f 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -5,6 +5,7 @@ package com.fr.design; import com.fr.base.BaseXMLUtils; import com.fr.base.Utils; +import com.fr.collections.api.Callback; import com.fr.design.actions.help.alphafine.AlphaFineConfigManager; import com.fr.design.carton.SwitchForSwingChecker; import com.fr.design.constants.UIConstants; @@ -21,8 +22,8 @@ import com.fr.design.locale.impl.ProductImproveMark; import com.fr.design.login.DesignerLoginType; import com.fr.design.login.config.DesignerLoginConfigManager; import com.fr.design.mainframe.ComponentReuseNotifyUtil; -import com.fr.design.mainframe.simple.SimpleDesignerConfig; import com.fr.design.mainframe.reuse.ComponentReuseNotificationInfo; +import com.fr.design.mainframe.simple.SimpleDesignerConfig; import com.fr.design.mainframe.vcs.VcsConfigManager; import com.fr.design.notification.SnapChatConfig; import com.fr.design.os.impl.SupportOSImpl; @@ -41,6 +42,12 @@ import com.fr.general.SupportLocale; import com.fr.general.locale.LocaleCenter; import com.fr.general.locale.LocaleMark; import com.fr.general.xml.GeneralXMLTools; +import com.fr.general.xml.async.AsyncXmlElement; +import com.fr.general.xml.async.AsyncXmlReadable; +import com.fr.general.xml.async.SimpleXmlElement; +import com.fr.general.xml.async.XmlElement; +import com.fr.general.xml.async.XmlException; +import com.fr.general.xml.async.XmlInitialFactory; import com.fr.log.FineLoggerFactory; import com.fr.log.LogHandler; import com.fr.stable.CommonUtils; @@ -58,8 +65,10 @@ import com.fr.stable.xml.XMLTools; import com.fr.stable.xml.XMLWriter; import com.fr.stable.xml.XMLableReader; import com.fr.start.common.DesignerStartupConfig; +import com.fr.start.common.DesignerStartupPool; import com.fr.third.apache.logging.log4j.core.appender.FileAppender; import com.fr.third.apache.logging.log4j.core.layout.PatternLayout; +import com.fr.third.org.apache.commons.io.FileUtils; import com.fr.third.org.apache.commons.io.FilenameUtils; import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContextCallback; @@ -90,8 +99,8 @@ import java.util.Map.Entry; /** * The manager of Designer GUI. */ -public class DesignerEnvManager implements XMLReadable, XMLWriter { - +public class DesignerEnvManager implements XMLReadable, XMLWriter, AsyncXmlReadable { + private static final int MAX_SHOW_NUM = 10; private static final String VERSION_80 = "80"; private static final String VERSION_90 = "90"; @@ -104,21 +113,26 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { * 指定默认工作空间 */ public static final String DEFAULT_WORKSPACE_PATH = "fr.designer.workspace.default"; - + + public static final String LAST_EAST_REGION_LAYOUT = "LastEastRegionLayout"; + public static final String LAST_WEST_REGION_LAYOUT = "LastWestRegionLayout"; + private static DesignerEnvManager designerEnvManager; // gui. private String activationKey = null; private String logLocation = null; private Rectangle windowBounds = null; // window bounds. private String DialogCurrentDirectory = null; private String CurrentDirectoryPrefix = null; + private Map> recentOpenedFileListMap = new HashMap<>(); private List tempRecentOpenedFilePathList = new ArrayList(); + private XmlElement>> recentOpenedMapping = SimpleXmlElement.of(recentOpenedFileListMap); + private boolean showPaintToolBar = true; private int maxNumberOrPreviewRow = 200; - // name和Env的键值对 - private Map nameEnvMap = new ListMap<>(); - // marks: 当前报表服务器名字 - private String curEnvName = null; + + private XmlElement envConfig = SimpleXmlElement.of(new EnvConfiguration()); + private boolean showProjectPane = true; private boolean showDataPane = true; //p:这是当前选择的数据库连接的名字,这个在新建数据源的时候用到. @@ -181,7 +195,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { /** * alphafine */ - private AlphaFineConfigManager alphaFineConfigManager = AlphaFineConfigManager.getInstance(); + private XmlElement alphaFineConfigManager; /** * 阅后即焚的配置项 @@ -230,7 +244,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { private boolean propertiesUsable; - private SimpleDesignerConfig fvsDesignerConfig = SimpleDesignerConfig.getInstance("FvsDesignerConfig"); + private XmlElement fvsDesignerConfig = SimpleXmlElement.of(SimpleDesignerConfig.getInstance("FvsDesignerConfig")); /** * DesignerEnvManager. @@ -245,12 +259,18 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { //REPORT-15332有一个国际化调用比较早,需要在这边就设置好locale,由于后台GeneralContext默认是China GeneralContext.setLocale(designerEnvManager.getLanguage()); try { - XMLTools.readFileXML(designerEnvManager, designerEnvManager.getDesignerEnvFile()); - } catch (FileNotFoundException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - XmlHandler.Self.handle(e); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); + designerEnvManager.initElements(designerEnvManager.getDesignerEnvFile()); + } catch (Exception retryEx) { + FineLoggerFactory.getLogger().debug("try async init DesignerEnvManager failed", retryEx); + + try { + XMLTools.readFileXML(designerEnvManager, designerEnvManager.getDesignerEnvFile()); + } catch (FileNotFoundException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + XmlHandler.Self.handle(e); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } } // james:如果没有env定义,要设置一个默认的 @@ -273,7 +293,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { } public static void checkNameEnvMap() { - if (designerEnvManager == null || designerEnvManager.nameEnvMap.size() > 0) { + + if (designerEnvManager == null || designerEnvManager.getNameEnvMap().size() > 0) { return; } String installHome = StableUtils.getInstallHome(); @@ -443,8 +464,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { FineLoggerFactory.getLogger().error(e.getMessage(), e); } // 清空前一个版本中的工作目录和最近打开 - nameEnvMap = new ListMap(); - curEnvName = null; + getEnvConfig().setNameEnvMap(new ListMap<>()); + getEnvConfig().setCurEnvName(null); designerEnvManager.saveXMLFile(); } @@ -606,7 +627,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { String installHome = StableUtils.getInstallHome(); String defaultenvPath = getDefaultenvPath(installHome); defaultenvPath = new File(defaultenvPath).getPath(); - Iterator> entryIt = nameEnvMap.entrySet().iterator(); + Iterator> entryIt = getNameEnvMap().entrySet().iterator(); while (entryIt.hasNext()) { Entry entry = entryIt.next(); DesignerWorkspaceInfo env = entry.getValue(); @@ -627,8 +648,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { String installHome = StableUtils.getInstallHome(); String defaultenvPath = getDefaultenvPath(installHome); defaultenvPath = new File(defaultenvPath).getPath(); - if (nameEnvMap.size() >= 0) { - Iterator> entryIt = nameEnvMap.entrySet().iterator(); + if (getNameEnvMap().size() >= 0) { + Iterator> entryIt = getNameEnvMap().entrySet().iterator(); while (entryIt.hasNext()) { Entry entry = entryIt.next(); DesignerWorkspaceInfo env = entry.getValue(); @@ -1019,21 +1040,21 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { } public SimpleDesignerConfig getFvsDesignerConfig() { - return fvsDesignerConfig; + return fvsDesignerConfig.getValue(); } /** * 返回环境名称迭代器 */ public Iterator getEnvNameIterator() { - return this.nameEnvMap.keySet().iterator(); + return this.getNameEnvMap().keySet().iterator(); } /** * 根据名称返回环境 */ public DesignerWorkspaceInfo getWorkspaceInfo(String name) { - return this.nameEnvMap.get(name); + return this.getNameEnvMap().get(name); } /** @@ -1044,7 +1065,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { */ public void putEnv(String name, DesignerWorkspaceInfo info) { - this.nameEnvMap.put(name, info); + this.getNameEnvMap().put(name, info); } /** @@ -1053,14 +1074,14 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { * @param name 环境的名字 */ public void removeEnv(String name) { - this.nameEnvMap.remove(name); + this.getNameEnvMap().remove(name); } /** * 清除全部环境 */ public void clearAllEnv() { - this.nameEnvMap.clear(); + this.getNameEnvMap().clear(); } /** @@ -1082,14 +1103,14 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { * 返回当前环境的名称. */ public String getCurEnvName() { - return this.curEnvName; + return getEnvConfig().getCurEnvName(); } /** * 设置当前环境的名称 */ public void setCurEnvName(String envName) { - this.curEnvName = envName; + getEnvConfig().setCurEnvName(envName); } /** @@ -1146,12 +1167,12 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { if (StringUtils.isEmpty(envName)) { return tempRecentOpenedFilePathList; } else { - if (!recentOpenedFileListMap.containsKey(envName)) { - recentOpenedFileListMap.put(envName, tempRecentOpenedFilePathList); + if (!recentOpenedMapping.getValue().containsKey(envName)) { + recentOpenedMapping.getValue().put(envName, tempRecentOpenedFilePathList); } } - return recentOpenedFileListMap.get(envName); + return recentOpenedMapping.getValue().get(envName); } /** @@ -1755,11 +1776,11 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { } public AlphaFineConfigManager getAlphaFineConfigManager() { - return alphaFineConfigManager; + return alphaFineConfigManager.getValue(); } public void setAlphaFineConfigManager(AlphaFineConfigManager alphaFineConfigManager) { - this.alphaFineConfigManager = alphaFineConfigManager; + this.alphaFineConfigManager.setValue(alphaFineConfigManager); } public boolean isImageCompress() { @@ -1801,7 +1822,99 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { public void setLayoutTemplateStyle(int layoutTemplateStyle) { this.layoutTemplateStyle = layoutTemplateStyle; } - + + @Override + public void initElements(File xmlFile) throws XmlException { + + try { + backupOldXmlFile(); + XmlInitialFactory xmlInitialFactory = XmlInitialFactory.create(xmlFile); + xmlInitialFactory + .init("XMLVersion", DesignerEnvManager.this::readXMLVersion) + .init("Attributes", DesignerEnvManager.this::readAttributes) + .init("ReportPaneAttributions", DesignerEnvManager.this::readReportPaneAttributions) + .init("RecentOpenedFilePath", (e) -> { + this.recentOpenedMapping = AsyncXmlElement.of(DesignerStartupPool.common(), () -> { + DesignerEnvManager.this.readRecentOpenFileList0(e); + return recentOpenedFileListMap; + }).callback(new Callback>>() { + @Override + public void exec(Map> stringListMap) { + checkRecentOpenedFileNum(); + } + }); + }) + .init("EnvConfigMap", (e) -> { + + final EnvConfiguration previousConfig = this.envConfig.getValue(); + this.envConfig = AsyncXmlElement.of(DesignerStartupPool.common(), () -> { + DesignerEnvManager.this.readEnvConfigMap(e, previousConfig); + return previousConfig; + }); + }) + .init("LogLocation", DesignerEnvManager.this::readLogLocation) + .init("Language", DesignerEnvManager.this::readLanguage) + .init("JettyServerPort", DesignerEnvManager.this::readJettyPort) + .init("PLengthUnit", DesignerEnvManager.this::readPageLengthUnit) + .init("RLengthUnit", DesignerEnvManager.this::readReportLengthUnit) + .init("LastOpenFilePath", DesignerEnvManager.this::readLastOpenFile) + .init("EncryptionKey", DesignerEnvManager.this::readEncrytionKey) + .init("jdkHome", (e) -> this.jdkHome = e.getElementValue()) + .init("lastBBSTime", DesignerEnvManager.this::readLastBBSTime) + .init("lastBBSNewsTime", DesignerEnvManager.this::readLastBBSNewsTime) + .init("ActivationKey", DesignerEnvManager.this::readActiveKey) + .init("status", DesignerEnvManager.this::readActiveStatus) + .init(CAS_PARAS, DesignerEnvManager.this::readHttpsParas) + .init("AlphaFineConfigManager", (e) -> { + this.alphaFineConfigManager = AsyncXmlElement.of(DesignerStartupPool.common(), () -> { + AlphaFineConfigManager config = AlphaFineConfigManager.getInstance(); + e.readXMLObject(config); + return config; + }); + }) + .init("RecentColors", DesignerEnvManager.this::readRecentColor) + .init("OpenDebug", DesignerEnvManager.this::readOpenDebug) + .init(ComponentReuseNotificationInfo.XML_TAG, DesignerEnvManager.this::readComponentReuseNotificationInfo) + .init(DesignerPushUpdateConfigManager.XML_TAG, DesignerEnvManager.this::readDesignerPushUpdateAttr) + .init(VcsConfigManager.XML_TAG, DesignerEnvManager.this::readVcsAttr) + .init(DesignerPort.XML_TAG, DesignerEnvManager.this::readDesignerPort) + .init(SnapChatConfig.XML_TAG, DesignerEnvManager.this::readSnapChatConfig) + .init(DesignerLoginConfigManager.XML_TAG, DesignerEnvManager.this::readDesignerLoginAttr) + .init(fvsDesignerConfig.getValue().getName(), (e) -> { + SimpleDesignerConfig config = this.fvsDesignerConfig.getValue(); + this.fvsDesignerConfig = AsyncXmlElement.of(() -> { + e.readXMLObject(config); + return config; + }); + }) + .init(SwitchForSwingChecker.XML_TAG, DesignerEnvManager.this::readSwitchForSwingCheckerAttr) + .init(LAST_WEST_REGION_LAYOUT, DesignerEnvManager.this::readLastWestRegionLayout) + .init(LAST_EAST_REGION_LAYOUT, DesignerEnvManager.this::readLastEastRegionLayout); + } catch (Exception e) { + throw new XmlException(e); + } + } + + /** + * 备份老的 xml 文件, 防止第一次修改存在问题 + * 但是,只备份一次。其他都走老逻辑 + */ + private void backupOldXmlFile() { + + try { + File oldFile = getEnvFile(); + String newFilePath = ProductConstants.getEnvHome() + File.separator + ProductConstants.APP_NAME + "Env_backup.xml"; + File newFile = new File(newFilePath); + if (newFile.exists()) { + return; + } + if (oldFile.exists()) { + FileUtils.copyFile(oldFile, newFile); + } + } catch (Exception ignored) { + } + } + /** * Read XML.
* The method will be invoked when read data from XML file.
@@ -1865,7 +1978,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { readComponentReuseNotificationInfo(reader); } else if (name.equals(DesignerPushUpdateConfigManager.XML_TAG)) { readDesignerPushUpdateAttr(reader); - } else if (name.equals(vcsConfigManager.XML_TAG)) { + } else if (name.equals(VcsConfigManager.XML_TAG)) { readVcsAttr(reader); } else if (DesignerPort.XML_TAG.equals(name)) { readDesignerPort(reader); @@ -1873,7 +1986,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { readSnapChatConfig(reader); } else if (name.equals(DesignerLoginConfigManager.XML_TAG)) { readDesignerLoginAttr(reader); - } else if (name.equals(fvsDesignerConfig.getName())) { + } else if (name.equals(fvsDesignerConfig.getValue().getName())) { readFvsDesignerConfig(reader); } else if (name.equals(SwitchForSwingChecker.XML_TAG)) { readSwitchForSwingCheckerAttr(reader); @@ -1893,7 +2006,10 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { } private void readAlphaFineAttr(XMLableReader reader) { - reader.readXMLObject(this.alphaFineConfigManager = AlphaFineConfigManager.getInstance()); + + AlphaFineConfigManager config = AlphaFineConfigManager.getInstance(); + reader.readXMLObject(config); + this.alphaFineConfigManager = SimpleXmlElement.of(config); } private void readEnvDetectorConfig(XMLableReader reader) { @@ -1918,9 +2034,9 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { private void readLayout(XMLableReader reader, String name) { - if ("LastEastRegionLayout".equals(name)) { + if (LAST_EAST_REGION_LAYOUT.equals(name)) { this.readLastEastRegionLayout(reader); - } else if ("LastWestRegionLayout".equals(name)) { + } else if (LAST_WEST_REGION_LAYOUT.equals(name)) { this.readLastWestRegionLayout(reader); } } @@ -2015,6 +2131,40 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { this.setPaginationLineColor(new Color(Integer.parseInt(tmpVal))); } } + + private void readEnvConfigMap(XMLableReader reader, EnvConfiguration envConfigs) { + + String currentEnv = reader.getAttrAsString("currentEnv", StringUtils.EMPTY); + envConfigs.setCurEnvName(currentEnv); + reader.readXMLObject(new XMLReadable() { + @Override + public void readXML(XMLableReader reader) { + if (reader.isAttr()) { + envConfigs.getNameEnvMap().clear(); + } else if (reader.isChildNode()) { + String tagName = reader.getTagName(); + if ("EnvConfigElement".equals(tagName)) { + final String name = reader.getAttrAsString("name", StringUtils.EMPTY); + reader.readXMLObject(new XMLReadable() { + @Override + public void readXML(XMLableReader reader) { + if (reader.isChildNode()) { + String tagName = reader.getTagName(); + if (DesignerWorkspaceType.Local.toString().equals(tagName)) { + LocalDesignerWorkspaceInfo envConfig = (LocalDesignerWorkspaceInfo) GeneralXMLTools.readXMLable(reader); + envConfigs.getNameEnvMap().put(name, envConfig); + } else if (DesignerWorkspaceType.Remote.toString().equals(tagName)) { + RemoteDesignerWorkspaceInfo envConfig = (RemoteDesignerWorkspaceInfo) GeneralXMLTools.readXMLable(reader); + envConfigs.getNameEnvMap().put(name, envConfig); + } + } + } + }); + } + } + } + }); + } private void readEnvConfigMap(XMLableReader reader) { String currentEnv = reader.getAttrAsString("currentEnv", StringUtils.EMPTY); @@ -2048,8 +2198,15 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { } }); } - + private void readRecentOpenFileList(XMLableReader reader) { + + readRecentOpenFileList0(reader); + checkRecentOpenedFileNum(); + } + + private void readRecentOpenFileList0(XMLableReader reader) { + reader.readXMLObject(new XMLReadable() { @Override public void readXML(XMLableReader reader) { @@ -2081,7 +2238,6 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { } } }); - checkRecentOpenedFileNum(); } private void readDesignerPushUpdateAttr(XMLableReader reader) { @@ -2151,7 +2307,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { private void writeAlphaFineAttr(XMLPrintWriter writer) { if (this.alphaFineConfigManager != null) { - this.alphaFineConfigManager.writeXML(writer); + this.alphaFineConfigManager.getValue().writeXML(writer); } } @@ -2228,10 +2384,10 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { writer.end(); writer.startTAG("EnvConfigMap"); - if (this.curEnvName != null) { - writer.attr("currentEnv", this.curEnvName); + if (this.getCurEnvName() != null) { + writer.attr("currentEnv", this.getCurEnvName()); } - for (Entry entry : nameEnvMap.entrySet()) { + for (Entry entry : getNameEnvMap().entrySet()) { writer.startTAG("EnvConfigElement").attr("name", entry.getKey()); DesignerWorkspaceInfo envConfig = entry.getValue(); GeneralXMLTools.writeXMLable(writer, envConfig, envConfig.getType().toString()); @@ -2440,11 +2596,14 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { } private void readFvsDesignerConfig(XMLableReader reader) { - reader.readXMLObject(fvsDesignerConfig); + + SimpleDesignerConfig config = fvsDesignerConfig.getValue(); + reader.readXMLObject(config); + fvsDesignerConfig = SimpleXmlElement.of(config); } private void writeFvsDesignerConfig(XMLPrintWriter writer) { - this.fvsDesignerConfig.writeXML(writer); + this.fvsDesignerConfig.getValue().writeXML(writer); } private void writeSwitchForSwingChecker(XMLPrintWriter writer) { @@ -2479,4 +2638,39 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { public SnapChatConfig getSnapChatConfig() { return snapChatConfig; } + + private EnvConfiguration getEnvConfig() { + + return envConfig.getValue(); + } + + private Map getNameEnvMap() { + + return getEnvConfig().getNameEnvMap(); + } + + private static class EnvConfiguration { + + // name和Env的键值对 + private Map nameEnvMap = new ListMap<>(); + // marks: 当前报表服务器名字 + private String curEnvName = null; + + public Map getNameEnvMap() { + return nameEnvMap; + } + + public void setNameEnvMap(Map nameEnvMap) { + this.nameEnvMap = nameEnvMap; + } + + public String getCurEnvName() { + return curEnvName; + } + + public void setCurEnvName(String curEnvName) { + this.curEnvName = curEnvName; + } + } + } diff --git a/designer-base/src/main/java/com/fr/design/actions/core/ActionFactory.java b/designer-base/src/main/java/com/fr/design/actions/core/ActionFactory.java index 2d4554afdd..db1dbbc7a0 100644 --- a/designer-base/src/main/java/com/fr/design/actions/core/ActionFactory.java +++ b/designer-base/src/main/java/com/fr/design/actions/core/ActionFactory.java @@ -8,6 +8,11 @@ import com.fr.design.menu.MenuKeySet; import com.fr.design.selection.QuickEditor; import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; +import com.fr.start.common.DesignerStartupPool; +import com.fr.third.checkerframework.checker.nullness.qual.Nullable; +import com.fr.third.guava.util.concurrent.FutureCallback; +import com.fr.third.guava.util.concurrent.Futures; +import com.fr.third.guava.util.concurrent.ListenableFutureTask; import javax.swing.Action; import javax.swing.KeyStroke; @@ -18,6 +23,7 @@ import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.CopyOnWriteArraySet; @@ -32,6 +38,7 @@ public class ActionFactory { private static Set> actionClasses = new CopyOnWriteArraySet<>(); private static Set> floatActionClasses = new CopyOnWriteArraySet<>(); private static Class chartCollectionClass = null; + /** * 无需每次实例化的悬浮元素编辑器 */ @@ -57,7 +64,6 @@ public class ActionFactory { private ActionFactory() { } - /** * 元素编辑器释放模板对象 */ @@ -69,7 +75,37 @@ public class ActionFactory { entry.getValue().release(); } } - + + /** + * 注册异步加载的单元格编辑器 + * 首先放到 classMap 中,当初始化成功后,则移除,并放到 cellEditor 中 + * 如果已经存在,则覆盖 + * + * @param keyClazz 作为 key 的类 + * @param editorClazz 作为 编辑器 的类 + */ + public static void registerAsyncInitCellEditorClass(Class keyClazz, Class editorClazz) { + + cellEditorClass.put(keyClazz, editorClazz); + Callable callable = new Callable() { + @Override + public QuickEditor call() throws Exception { + return editorClazz.newInstance(); + } + }; + ListenableFutureTask future = ListenableFutureTask.create(callable); + Futures.addCallback(future, new FutureCallback() { + @Override + public void onSuccess(@Nullable QuickEditor quickEditor) { + cellEditorClass.remove(keyClazz); + cellEditor.put(keyClazz, quickEditor); + } + + @Override + public void onFailure(Throwable throwable) { + } + }, DesignerStartupPool.designer()); + } /** * 注册无需每次实例化的单元格元素编辑器 diff --git a/designer-base/src/main/java/com/fr/design/env/LocalDesignerWorkspaceInfo.java b/designer-base/src/main/java/com/fr/design/env/LocalDesignerWorkspaceInfo.java index ec8d997c3c..bd1c48ce72 100644 --- a/designer-base/src/main/java/com/fr/design/env/LocalDesignerWorkspaceInfo.java +++ b/designer-base/src/main/java/com/fr/design/env/LocalDesignerWorkspaceInfo.java @@ -1,6 +1,7 @@ package com.fr.design.env; import com.fr.general.ComparatorUtils; +import com.fr.stable.CommonUtils; import com.fr.stable.CoreConstants; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; @@ -98,6 +99,12 @@ public class LocalDesignerWorkspaceInfo implements DesignerWorkspaceInfo { @Override public boolean checkValid(){ + + // 如果当前是 debug 模式,就不检测这个逻辑 + if (CommonUtils.isDebug()) { + return true; + } + File file = new File(this.path); //判断不是文件夹/路径不在WEB-INF下/代码启动三种情况 if(!file.isDirectory() || !ComparatorUtils.equals(file.getName(), "WEB-INF") || this.path.startsWith(".")) { diff --git a/designer-base/src/main/java/com/fr/start/BaseDesigner.java b/designer-base/src/main/java/com/fr/start/BaseDesigner.java index 016c6bd6d1..4f71962f60 100644 --- a/designer-base/src/main/java/com/fr/start/BaseDesigner.java +++ b/designer-base/src/main/java/com/fr/start/BaseDesigner.java @@ -39,6 +39,7 @@ import org.jetbrains.annotations.Nullable; import java.awt.Window; import java.lang.reflect.Method; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; /** @@ -136,7 +137,7 @@ public abstract class BaseDesigner extends ToolBarMenuDock { DesignerFrame df = DesignerContext.getDesignerFrame(); isException = openFile(df, isException, file); df.fireDesignerOpened(); - FineLoggerFactory.getLogger().debug("show designer cost {} ms", DesignerStartupContext.getRecorder().getTime()); + FineLoggerFactory.getLogger().info("Designer showed.Time used {} ms", DesignerStartupContext.getRecorder().getTime(TimeUnit.MILLISECONDS)); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); if (!isException) { diff --git a/designer-base/src/main/java/com/fr/start/common/DesignerStartupPool.java b/designer-base/src/main/java/com/fr/start/common/DesignerStartupPool.java index 524c474df1..6625a5a31b 100644 --- a/designer-base/src/main/java/com/fr/start/common/DesignerStartupPool.java +++ b/designer-base/src/main/java/com/fr/start/common/DesignerStartupPool.java @@ -4,17 +4,36 @@ import com.fr.concurrent.FineExecutors; import com.fr.concurrent.NamedThreadFactory; import java.util.concurrent.Executor; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.TimeUnit; /** * created by Harrison on 2022/07/03 **/ public class DesignerStartupPool { - private static final Executor COMMON_EXECUTOR = FineExecutors.newCachedThreadPool(new NamedThreadFactory("startup-common")); + private static final int MAX_THREAD_COUNT = Runtime.getRuntime().availableProcessors() * 2; + private static final Executor COMMON_EXECUTOR = FineExecutors.newThreadPoolExecutor(MAX_THREAD_COUNT, MAX_THREAD_COUNT, 10L, TimeUnit.SECONDS, new LinkedBlockingQueue<>(), new NamedThreadFactory("startup-common")); + + private static final Executor DESIGNER_EXECUTOR = FineExecutors.newThreadPoolExecutor(MAX_THREAD_COUNT, MAX_THREAD_COUNT, 10L, TimeUnit.SECONDS, new LinkedBlockingQueue<>(), new NamedThreadFactory("startup-designer")); + + /** + * + * @return 启动通用线程池 + */ public static Executor common() { return COMMON_EXECUTOR; } + + /** + * + * @return 启动设计器线程池 + */ + public static Executor designer() { + + return DESIGNER_EXECUTOR; + } } diff --git a/designer-base/src/main/java/com/fr/startup/ui/StartupLoadingPanel.java b/designer-base/src/main/java/com/fr/startup/ui/StartupLoadingPanel.java new file mode 100644 index 0000000000..97c0b26a0a --- /dev/null +++ b/designer-base/src/main/java/com/fr/startup/ui/StartupLoadingPanel.java @@ -0,0 +1,113 @@ +package com.fr.startup.ui; + +import com.fr.concurrent.FineExecutors; +import com.fr.concurrent.NamedThreadFactory; +import com.fr.design.gui.iprogressbar.ProgressDialog; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.DesignerContext; +import com.fr.event.Event; +import com.fr.event.EventDispatcher; +import com.fr.event.Listener; +import com.fr.module.ModuleEvent; + +import java.awt.Frame; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + +/** + * created by Harrison on 2022/11/08 + **/ +public class StartupLoadingPanel { + + /** + * 每次更新的步伐 + */ + private static final int STEP = 1; + + /** + * 40ms更新进度 + */ + private static final int STEP_HEARTBEAT = 40; + + private final Listener MODULE_LISTENER = new Listener() { + @Override + public void on(Event event, String param) { + moduleId = param; + } + }; + + private ProgressDialog progressDialog; + private String moduleId; + private int progress; + + public StartupLoadingPanel(Frame frame) { + this.progressDialog = new ProgressDialog(frame); + this.moduleId = Toolkit.i18nText("Fine-Design_Basic_Initializing"); + + initListeners(); + } + + /** + * 隐藏 + */ + public void hide() { + this.progress = progressDialog.getProgressMaximum(); + } + + /** + * 展示 + */ + public void show() { + + final ScheduledExecutorService scheduler = FineExecutors.newScheduledThreadPool(1, + new NamedThreadFactory("StartupLoadingPanel")); + scheduler.scheduleAtFixedRate(new Runnable() { + @Override + public void run() { + if (isComplete()) { + scheduler.shutdown(); + progressDialog.dispose(); + resetListeners(); + return; + } + if (!progressDialog.isVisible()) { + progressDialog = new ProgressDialog(DesignerContext.getDesignerFrame()); + progressDialog.setVisible(true); + String moduleId = getModuleId(); + progressDialog.updateLoadingText(moduleId); + } + progressDialog.setProgressValue(incrementProgress()); + } + }, 0, STEP_HEARTBEAT, TimeUnit.MILLISECONDS); + + } + + private void initListeners() { + + EventDispatcher.listen(ModuleEvent.MajorModuleStarting, MODULE_LISTENER); + } + + private void resetListeners() { + + EventDispatcher.stopListen(MODULE_LISTENER); + } + + private boolean isComplete() { + return this.progress >= progressDialog.getProgressMaximum(); + } + + private String getModuleId() { + + return this.moduleId; + } + + private int incrementProgress() { + + if (progress != progressDialog.getProgressMaximum()) { + progress += STEP; + } + return progress; + } + + +} diff --git a/designer-base/src/main/java/com/fr/startup/ui/StartupPageWindow.java b/designer-base/src/main/java/com/fr/startup/ui/StartupPageWindow.java index 0a0cdb4aac..84350d1726 100644 --- a/designer-base/src/main/java/com/fr/startup/ui/StartupPageWindow.java +++ b/designer-base/src/main/java/com/fr/startup/ui/StartupPageWindow.java @@ -2,7 +2,6 @@ package com.fr.startup.ui; import com.fr.base.svg.IconUtils; import com.fr.design.DesignerEnvManager; -import com.fr.design.components.loading.LoadingPane; import com.fr.design.dialog.UIExpandDialog; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; @@ -25,7 +24,6 @@ import org.jetbrains.annotations.NotNull; import javax.swing.BorderFactory; import javax.swing.JComponent; import javax.swing.JFrame; -import javax.swing.JLayeredPane; import javax.swing.JPanel; import javax.swing.JSeparator; import javax.swing.ScrollPaneConstants; @@ -34,7 +32,6 @@ import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; import java.awt.BorderLayout; import java.awt.Color; -import java.awt.Component; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Font; @@ -84,41 +81,42 @@ public class StartupPageWindow extends JFrame { private JPanel body; - private LoadingPane loadingPane = new LoadingPane(); - - private JLayeredPane layeredPane = new JLayeredPane() { - @Override - public void doLayout() { - for (Component comp : getComponents()) { - comp.setBounds(0, 0, getWidth(), getHeight()); - } - } - }; + private StartupLoadingPanel loadingPanel; public StartupPageWindow(StartupPageModel pageModel) { patchUIAction(pageModel); setLayout(new BorderLayout()); + + initCenter(pageModel); + + loadingPanel = new StartupLoadingPanel(this); + + // Workspace-detail + setSize(SCREEN_SIZE); + setDefaultTitle(); + addDefaultListeners(); + + repaint(); + validate(); + revalidate(); + + setFullScreen(); + + } + + private void initCenter(StartupPageModel pageModel) { this.body = FRGUIPaneFactory.createBorderLayout_S_Pane(); this.body.setBackground(new Color(0, 0, 0, 0)); - // Header - UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_Startup_Page_Select_Workspace")); - Font font = label.getFont(); - Font titleFont = font.deriveFont(font.getStyle(), TITLE_FONT_SIZE); - label.setFont(titleFont); - JPanel headerPanel = new JPanel(); - LayoutManager centerFlowLayout = FRGUIPaneFactory.createCenterFlowLayout(); - headerPanel.setLayout(centerFlowLayout); - headerPanel.add(label); - headerPanel.setBackground(new Color(0, 0, 0, 0)); + JPanel headerPanel = createHeader(); this.body.add(headerPanel, BorderLayout.NORTH); // Workspace-description this.workspacePanel = generateWorkspacePanel(pageModel); this.body.add(workspacePanel, BorderLayout.CENTER); - + workspacePanel.setSelectWorkspaceRunnable(new Runnable() { @Override public void run() { @@ -144,25 +142,24 @@ public class StartupPageWindow extends JFrame { this.contentPane.setLayout(getCenterLayout(body)); this.contentPane.add(this.body, BorderLayout.CENTER); this.contentPane.setPreferredSize(this.body.getPreferredSize()); - - this.layeredPane.setName("layered-pane"); - this.layeredPane.add(this.contentPane, CONTENT_LAYER); - this.layeredPane.add(this.loadingPane, TRANSPARENT_LAYER); - this.layeredPane.moveToFront(this.contentPane); - - add(this.layeredPane, BorderLayout.CENTER); - // Workspace-detail - setSize(SCREEN_SIZE); - setDefaultTitle(); - addDefaultListeners(); - - repaint(); - validate(); - revalidate(); + add(this.contentPane, BorderLayout.CENTER); + } + + @NotNull + private static JPanel createHeader() { - setFullScreen(); - + // Header + UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_Startup_Page_Select_Workspace")); + Font font = label.getFont(); + Font titleFont = font.deriveFont(font.getStyle(), TITLE_FONT_SIZE); + label.setFont(titleFont); + JPanel headerPanel = new JPanel(); + LayoutManager centerFlowLayout = FRGUIPaneFactory.createCenterFlowLayout(); + headerPanel.setLayout(centerFlowLayout); + headerPanel.add(label); + headerPanel.setBackground(new Color(0, 0, 0, 0)); + return headerPanel; } private void setFullScreen() { @@ -214,9 +211,8 @@ public class StartupPageWindow extends JFrame { } private void enterWorkspace(Runnable action) { - - loadingPane.start(); - layeredPane.moveToFront(loadingPane); + + loadingPanel.show(); SwingWorker task = new SwingWorker() { @Override protected Void doInBackground() throws Exception { @@ -245,9 +241,8 @@ public class StartupPageWindow extends JFrame { .setVisible(true); }); FineLoggerFactory.getLogger().error(e.getMessage(), e); - layeredPane.moveToFront(contentPane); } finally { - loadingPane.stop(); + loadingPanel.hide(); } } }; diff --git a/designer-realize/src/main/java/com/fr/start/MainDesigner.java b/designer-realize/src/main/java/com/fr/start/MainDesigner.java index 24c02893bc..926bbbcc66 100644 --- a/designer-realize/src/main/java/com/fr/start/MainDesigner.java +++ b/designer-realize/src/main/java/com/fr/start/MainDesigner.java @@ -72,17 +72,15 @@ import com.fr.start.common.SplashCommon; import com.fr.start.module.StartupArgs; import com.fr.start.preload.PreLoadService; import com.fr.start.server.ServerTray; -import com.fr.third.org.apache.commons.lang3.time.StopWatch; import com.fr.van.chart.map.server.ChartMapEditorAction; import com.fr.workspace.WorkContext; -import javax.swing.JPanel; + import javax.swing.JComponent; +import javax.swing.JPanel; import javax.swing.border.MatteBorder; import java.awt.Component; import java.awt.Dimension; import java.awt.FlowLayout; -import java.awt.Font; -import java.awt.GraphicsEnvironment; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -119,11 +117,11 @@ public class MainDesigner extends BaseDesigner { * @param args 参数 */ public static void main(String[] args) { - StopWatch watch = new StopWatch(); - watch.start(); DesignerStartupContext.getRecorder().start(); - showSplash(); + + DesignerEnvManager.getEnvManager(); + startPreload0(); DesignerLifecycleMonitorContext.getMonitor().beforeStart(); @@ -143,7 +141,7 @@ public class MainDesigner extends BaseDesigner { }); Module designerRoot = ModuleContext.parseRoot("designer-startup.xml"); - FineLoggerFactory.getLogger().debug("designer-startup prepared cost {} ms", DesignerStartupContext.getRecorder().getTime(TimeUnit.MILLISECONDS)); + FineLoggerFactory.getLogger().debug("Designer prepared.Time used {} ms", DesignerStartupContext.getRecorder().getTime(TimeUnit.MILLISECONDS)); //传递启动参数 designerRoot.setSingleton(StartupArgs.class, new StartupArgs(args)); try { @@ -156,8 +154,7 @@ public class MainDesigner extends BaseDesigner { //初始化一下serverTray ServerTray.init(); } - FineLoggerFactory.getLogger().info("Designer started.Time used {} ms", watch.getTime()); - watch.stop(); + FineLoggerFactory.getLogger().info("Designer started.Time used {} ms", DesignerStartupContext.getRecorder().getTime(TimeUnit.MILLISECONDS)); SwitchForSwingChecker.initThreadMonitoring(); } @@ -168,7 +165,9 @@ public class MainDesigner extends BaseDesigner { private static void startPreload1() { CompletableFuture initLookAndFeel = CompletableFuture.runAsync(DesignUtils::initLookAndFeel); - PreLoadService.getInstance().addFuture(initLookAndFeel); + PreLoadService.getInstance().addUIFuture(initLookAndFeel); + + showSplash(); } /** @@ -189,17 +188,12 @@ public class MainDesigner extends BaseDesigner { action.run(); } }); - - Runnable fontLoad = () -> { - Font[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts(); - }; - PreLoadService.getInstance().addRunnable(fontLoad); - } private static void showSplash() { + // 快快显示启动画面 - UIUtil.invokeAndWaitIfNeeded(new Runnable() { + UIUtil.invokeLaterIfNeeded(new Runnable() { @Override public void run() { SplashContext.getInstance().registerSplash(createSplash()); diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java index 66fb549e69..16a923df37 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java @@ -146,13 +146,14 @@ import com.fr.start.common.DesignerStartupPool; import com.fr.task.Once; import com.fr.workspace.WorkContext; import com.fr.xml.ReportXMLUtils; + +import javax.swing.SwingWorker; import java.awt.Image; import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.concurrent.CompletableFuture; -import javax.swing.SwingWorker; /** * Created by juhaoyu on 2018/1/31. @@ -191,7 +192,9 @@ public class DesignerActivator extends Activator implements Prepare { }, DesignerStartupPool.common()); CompletableFuture mainDesignerPrepare = CompletableFuture.runAsync(this::designerModuleStart, DesignerStartupPool.common()); - + + CompletableFuture extendDesignerPrepare = CompletableFuture.runAsync(this::designerExtendStart, DesignerStartupPool.common()); + CompletableFuture otherFeaturesPrepare = CompletableFuture.runAsync(() -> { startBBSLoginAuthServer(); migrateBBSInfoFromFineDB(); @@ -207,7 +210,7 @@ public class DesignerActivator extends Activator implements Prepare { storePassport(); AlphaFineHelper.switchConfig4Locale(); RecoverManager.register(new RecoverForDesigner()); - }); + }, DesignerStartupPool.common()); CompletableFuture resourcePrepare = CompletableFuture.runAsync(() -> { pushUpdateTask.run(); @@ -218,7 +221,7 @@ public class DesignerActivator extends Activator implements Prepare { }, DesignerStartupPool.common()); CompletableFuture - .allOf(mainDesignerPrepare, themeConfigPrepare, otherFeaturesPrepare, resourcePrepare) + .allOf(mainDesignerPrepare, extendDesignerPrepare, themeConfigPrepare, otherFeaturesPrepare, resourcePrepare) .join(); } @@ -272,8 +275,12 @@ public class DesignerActivator extends Activator implements Prepare { designerRegister(); - InformationCollector.getInstance().collectStartTime(); + } + + private void designerExtendStart() { + SharableManager.start(); + InformationCollector.getInstance().collectStartTime(); GuideRegister.register(); } @@ -413,16 +420,16 @@ public class DesignerActivator extends Activator implements Prepare { */ private static void registerCellEditor() { - ActionFactory.registerCellEditor(String.class, new CellStringQuickEditor()); - ActionFactory.registerCellEditor(Number.class, new CellStringQuickEditor()); - ActionFactory.registerCellEditor(BaseFormula.class, new CellFormulaQuickEditor()); - ActionFactory.registerCellEditor(SubReport.class, new CellSubReportEditor()); - ActionFactory.registerCellEditor(RichText.class, new CellRichTextEditor()); - ActionFactory.registerCellEditor(DSColumn.class, new CellDSColumnEditor()); - ActionFactory.registerCellEditor(Image.class, new CellImageQuickEditor()); - ActionFactory.registerCellEditor(BiasTextPainter.class, new CellBiasTextPainterEditor()); - ActionFactory.registerCellEditor(BufferedImage.class, new CellImageQuickEditor()); - ActionFactory.registerCellEditor(CellImagePainter.class, new CellImageQuickEditor()); + ActionFactory.registerAsyncInitCellEditorClass(String.class, CellStringQuickEditor.class); + ActionFactory.registerAsyncInitCellEditorClass(Number.class, CellStringQuickEditor.class); + ActionFactory.registerAsyncInitCellEditorClass(BaseFormula.class, CellFormulaQuickEditor.class); + ActionFactory.registerAsyncInitCellEditorClass(SubReport.class, CellSubReportEditor.class); + ActionFactory.registerAsyncInitCellEditorClass(RichText.class, CellRichTextEditor.class); + ActionFactory.registerAsyncInitCellEditorClass(DSColumn.class, CellDSColumnEditor.class); + ActionFactory.registerAsyncInitCellEditorClass(Image.class, CellImageQuickEditor.class); + ActionFactory.registerAsyncInitCellEditorClass(BiasTextPainter.class, CellBiasTextPainterEditor.class); + ActionFactory.registerAsyncInitCellEditorClass(BufferedImage.class, CellImageQuickEditor.class); + ActionFactory.registerAsyncInitCellEditorClass(CellImagePainter.class, CellImageQuickEditor.class); Set providers = ExtraDesignClassManager.getInstance().getArray(ElementUIProvider.MARK_STRING); for (ElementUIProvider provider : providers) { @@ -430,7 +437,7 @@ public class DesignerActivator extends Activator implements Prepare { if (provider.quickEditor() == null) { continue; } - ActionFactory.registerCellEditor(provider.targetObjectClass(), provider.quickEditor().newInstance()); + ActionFactory.registerAsyncInitCellEditorClass(provider.targetObjectClass(), provider.quickEditor()); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java b/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java index 4a4fbac2b0..834f1ee30a 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java @@ -67,7 +67,7 @@ public class DesignerStartup extends Activator { registerDaoSelector(); Stopwatch beforeWatch = Stopwatch.createStarted(); - PreLoadService.getInstance().waitForAll(); + PreLoadService.getInstance().waitForCommon(); FineLoggerFactory.getLogger().debug( "DesignerStartup cost {} ms to wait load", beforeWatch.elapsed(TimeUnit.MILLISECONDS)); if (DesignUtils.isStarted()) { diff --git a/designer-realize/src/main/java/com/fr/start/module/optimized/DesignerStartupPageActivator.java b/designer-realize/src/main/java/com/fr/start/module/optimized/DesignerStartupPageActivator.java index e41dafcc8f..87f84c9d60 100644 --- a/designer-realize/src/main/java/com/fr/start/module/optimized/DesignerStartupPageActivator.java +++ b/designer-realize/src/main/java/com/fr/start/module/optimized/DesignerStartupPageActivator.java @@ -5,9 +5,11 @@ import com.fr.design.mainframe.DesignerContext; import com.fr.design.ui.util.UIUtil; import com.fr.log.FineLoggerFactory; import com.fr.module.Activator; +import com.fr.module.engine.base.ActivatorContext; import com.fr.start.SplashContext; import com.fr.start.common.DesignerStartupContext; import com.fr.start.module.StartupArgs; +import com.fr.start.preload.PreLoadService; import com.fr.start.util.DesignerStartupPageUtil; import com.fr.startup.metric.DesignerMetrics; import com.fr.startup.metric.DesignerStartupModel; @@ -18,6 +20,7 @@ import com.fr.third.org.apache.commons.lang3.time.StopWatch; import com.fr.value.NotNullLazyValue; import org.jetbrains.annotations.NotNull; +import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; /** @@ -37,6 +40,13 @@ public class DesignerStartupPageActivator extends Activator { } }; + /** + * 上下文 + */ + private final ActivatorContext activatorContext = new ActivatorContext(); + + private final CountDownLatch LATCH = new CountDownLatch(1); + @Override public void start() { @@ -64,14 +74,25 @@ public class DesignerStartupPageActivator extends Activator { // 即时暂停 suspendRecorder(context); + + addMutable(ActivatorContext.KEY, activatorContext); + + PreLoadService.getInstance().waitForUI(); UIUtil.invokeLaterIfNeeded(() -> { StartupPageModel model = StartupPageModel.create(); context.setStartupPageModel(model); - + + StopWatch suspendWatch = new StopWatch(); + final Runnable recordSuspend = () -> { + long suspendTime = suspendWatch.getTime(TimeUnit.MILLISECONDS); + activatorContext.setSuspendTime(suspendTime); + }; + // selectAndOpenLast model.setOpenLastTemplateRunnable(() -> { + recordSuspend.run(); context.setOpenLastFile(true); handleModel(model); launchAfterWarmup(); @@ -79,6 +100,7 @@ public class DesignerStartupPageActivator extends Activator { // selectAndOpenEmpty model.setOpenEmptyTemplateRunnable(() -> { + recordSuspend.run(); context.setOpenEmpty(true); handleModel(model); launchAfterWarmup(); @@ -86,6 +108,7 @@ public class DesignerStartupPageActivator extends Activator { // selectAndCreateNew model.setCreateNewTemplateRunnable(() -> { + recordSuspend.run(); context.setCreateNew(true); handleModel(model); launchAfterWarmup(); @@ -94,8 +117,11 @@ public class DesignerStartupPageActivator extends Activator { StartupPageWindow window = new StartupPageWindow(model); window.setVisible(true); context.setOnWaiting(true); - + suspendWatch.start(); + }); + + waitSubTask(); } private void suspendRecorder(DesignerStartupContext context) { @@ -136,9 +162,9 @@ public class DesignerStartupPageActivator extends Activator { DesignerStartupContext.getInstance().setOnStartup(false); recordStartupEnd(stopWatch); }); + markComplete(); } - FineLoggerFactory.getLogger().debug("designer-startup-page started cost {} ms", DesignerStartupContext.getRecorder().getTime(TimeUnit.MILLISECONDS)); } private void recordStartupEnd(StopWatch stopWatch) { @@ -150,6 +176,28 @@ public class DesignerStartupPageActivator extends Activator { model.fill(); } + /** + * 阻塞住当前的方法。 + * 只有 UI 交互开始执行的时候,才会停止阻塞 + */ + private void waitSubTask() { + + try { + LATCH.await(); + } catch (InterruptedException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + + private void markComplete() { + + try { + LATCH.countDown(); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + @Override public void stop() { diff --git a/designer-realize/src/main/java/com/fr/start/preload/PreLoadService.java b/designer-realize/src/main/java/com/fr/start/preload/PreLoadService.java index b750210749..7f69e750ea 100644 --- a/designer-realize/src/main/java/com/fr/start/preload/PreLoadService.java +++ b/designer-realize/src/main/java/com/fr/start/preload/PreLoadService.java @@ -11,7 +11,9 @@ import java.util.concurrent.CompletableFuture; **/ public class PreLoadService { - private List> futures = new ArrayList<>(); + private List> commonFutures = new ArrayList<>(); + + private List> uIFutures = new ArrayList<>(); public static PreLoadService getInstance() { return PreLoadServiceHolder.INSTANCE; @@ -21,16 +23,24 @@ public class PreLoadService { private static final PreLoadService INSTANCE = new PreLoadService(); } + public void addUIFuture(CompletableFuture future) { + uIFutures.add(future); + } + public void addFuture(CompletableFuture future) { - futures.add(future); + commonFutures.add(future); } public void addRunnable(Runnable runnable) { - futures.add(CompletableFuture.runAsync(runnable, DesignerStartupPool.common())); + commonFutures.add(CompletableFuture.runAsync(runnable, DesignerStartupPool.common())); + } + + public void waitForCommon() { + CompletableFuture.allOf(commonFutures.toArray(new CompletableFuture[0])).join(); } - public void waitForAll() { - CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join(); + public void waitForUI() { + CompletableFuture.allOf(uIFutures.toArray(new CompletableFuture[0])).join(); } } From 227ef1d472fe4b799c3d73daa3ca11964e5fd3ac Mon Sep 17 00:00:00 2001 From: Harrison Date: Tue, 15 Nov 2022 20:35:46 +0800 Subject: [PATCH 08/15] =?UTF-8?q?REPORT-83197=E3=80=90=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E3=80=91=E5=90=AF=E5=8A=A8=E9=A1=B5=E6=80=A7=E8=83=BD?= =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E6=A0=B9=E6=8D=AE=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=EF=BC=8C=E4=BF=AE=E5=A4=8D=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E8=B4=A8=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/DesignerEnvManager.java | 2 + .../fr/design/actions/core/ActionFactory.java | 3 +- .../fr/startup/ui/StartupLoadingPanel.java | 2 + .../com/fr/startup/ui/StartupPageWindow.java | 50 +++++++++++++------ .../com/fr/start/preload/PreLoadService.java | 16 ++++++ 5 files changed, 55 insertions(+), 18 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java index b4a9f5934f..5504a52bf1 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -97,6 +97,8 @@ import java.util.Map; import java.util.Map.Entry; /** + * @author anonymous + * @version 11.0 * The manager of Designer GUI. */ public class DesignerEnvManager implements XMLReadable, XMLWriter, AsyncXmlReadable { diff --git a/designer-base/src/main/java/com/fr/design/actions/core/ActionFactory.java b/designer-base/src/main/java/com/fr/design/actions/core/ActionFactory.java index db1dbbc7a0..5b1aaf6f52 100644 --- a/designer-base/src/main/java/com/fr/design/actions/core/ActionFactory.java +++ b/designer-base/src/main/java/com/fr/design/actions/core/ActionFactory.java @@ -9,7 +9,6 @@ import com.fr.design.selection.QuickEditor; import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; import com.fr.start.common.DesignerStartupPool; -import com.fr.third.checkerframework.checker.nullness.qual.Nullable; import com.fr.third.guava.util.concurrent.FutureCallback; import com.fr.third.guava.util.concurrent.Futures; import com.fr.third.guava.util.concurrent.ListenableFutureTask; @@ -96,7 +95,7 @@ public class ActionFactory { ListenableFutureTask future = ListenableFutureTask.create(callable); Futures.addCallback(future, new FutureCallback() { @Override - public void onSuccess(@Nullable QuickEditor quickEditor) { + public void onSuccess(QuickEditor quickEditor) { cellEditorClass.remove(keyClazz); cellEditor.put(keyClazz, quickEditor); } diff --git a/designer-base/src/main/java/com/fr/startup/ui/StartupLoadingPanel.java b/designer-base/src/main/java/com/fr/startup/ui/StartupLoadingPanel.java index 97c0b26a0a..0c82174465 100644 --- a/designer-base/src/main/java/com/fr/startup/ui/StartupLoadingPanel.java +++ b/designer-base/src/main/java/com/fr/startup/ui/StartupLoadingPanel.java @@ -15,6 +15,8 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; /** + * @author Harrison + * @version 11.0 * created by Harrison on 2022/11/08 **/ public class StartupLoadingPanel { diff --git a/designer-base/src/main/java/com/fr/startup/ui/StartupPageWindow.java b/designer-base/src/main/java/com/fr/startup/ui/StartupPageWindow.java index 84350d1726..0b57247ac0 100644 --- a/designer-base/src/main/java/com/fr/startup/ui/StartupPageWindow.java +++ b/designer-base/src/main/java/com/fr/startup/ui/StartupPageWindow.java @@ -107,11 +107,44 @@ public class StartupPageWindow extends JFrame { } private void initCenter(StartupPageModel pageModel) { - + + initHeaderPanel(); + + initWorkspacePanel(pageModel); + + initRecentOpenPanel(pageModel); + initContentPanel(); + } + + private void initHeaderPanel() { this.body = FRGUIPaneFactory.createBorderLayout_S_Pane(); this.body.setBackground(new Color(0, 0, 0, 0)); JPanel headerPanel = createHeader(); this.body.add(headerPanel, BorderLayout.NORTH); + } + + private void initRecentOpenPanel(StartupPageModel pageModel) { + + this.recentOpenPanel = generateRecentOpenPanel(pageModel); + this.body.add(recentOpenPanel, BorderLayout.SOUTH); + } + + private void initContentPanel() { + this.contentPane = new JPanel() { + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + g.drawImage(BACKGROUND_IMAGE, 0, 0, SCREEN_SIZE.width, SCREEN_SIZE.height, this); + } + }; + this.contentPane.setLayout(getCenterLayout(body)); + this.contentPane.add(this.body, BorderLayout.CENTER); + this.contentPane.setPreferredSize(this.body.getPreferredSize()); + + add(this.contentPane, BorderLayout.CENTER); + } + + private void initWorkspacePanel(StartupPageModel pageModel) { // Workspace-description this.workspacePanel = generateWorkspacePanel(pageModel); @@ -129,21 +162,6 @@ public class StartupPageWindow extends JFrame { repaint(); } }); - - this.recentOpenPanel = generateRecentOpenPanel(pageModel); - this.body.add(recentOpenPanel, BorderLayout.SOUTH); - this.contentPane = new JPanel() { - @Override - protected void paintComponent(Graphics g) { - super.paintComponent(g); - g.drawImage(BACKGROUND_IMAGE, 0, 0, SCREEN_SIZE.width, SCREEN_SIZE.height, this); - } - }; - this.contentPane.setLayout(getCenterLayout(body)); - this.contentPane.add(this.body, BorderLayout.CENTER); - this.contentPane.setPreferredSize(this.body.getPreferredSize()); - - add(this.contentPane, BorderLayout.CENTER); } @NotNull diff --git a/designer-realize/src/main/java/com/fr/start/preload/PreLoadService.java b/designer-realize/src/main/java/com/fr/start/preload/PreLoadService.java index 7f69e750ea..e2abb816fd 100644 --- a/designer-realize/src/main/java/com/fr/start/preload/PreLoadService.java +++ b/designer-realize/src/main/java/com/fr/start/preload/PreLoadService.java @@ -23,6 +23,11 @@ public class PreLoadService { private static final PreLoadService INSTANCE = new PreLoadService(); } + /** + * 添加 UI 的异步任务 + * + * @param future 任务 + */ public void addUIFuture(CompletableFuture future) { uIFutures.add(future); } @@ -31,14 +36,25 @@ public class PreLoadService { commonFutures.add(future); } + /** + * 添加通用的异步任务 + * + * @param runnable 任务 + */ public void addRunnable(Runnable runnable) { commonFutures.add(CompletableFuture.runAsync(runnable, DesignerStartupPool.common())); } + /** + * 等待通用的异步任务执行 + */ public void waitForCommon() { CompletableFuture.allOf(commonFutures.toArray(new CompletableFuture[0])).join(); } + /** + * 等待UI异步任务执行 + */ public void waitForUI() { CompletableFuture.allOf(uIFutures.toArray(new CompletableFuture[0])).join(); } From 87022f0cb95be1c046ebc9d05ebd4358eb0f7917 Mon Sep 17 00:00:00 2001 From: Harrison Date: Tue, 15 Nov 2022 20:53:44 +0800 Subject: [PATCH 09/15] =?UTF-8?q?REPORT-83197=E3=80=90=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E3=80=91=E5=90=AF=E5=8A=A8=E9=A1=B5=E6=80=A7=E8=83=BD?= =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E6=A0=B9=E6=8D=AE=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=EF=BC=8C=E4=BF=AE=E5=A4=8D=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E8=B4=A8=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/DesignerEnvManager.java | 5 ++++- .../src/main/java/com/fr/startup/ui/StartupLoadingPanel.java | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java index 5504a52bf1..9d0f1f4644 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -97,9 +97,12 @@ import java.util.Map; import java.util.Map.Entry; /** + * The manager of Designer GUI. + * 下面的作者日期都是随手写的,具体作者已经无法考究。 + * * @author anonymous * @version 11.0 - * The manager of Designer GUI. + * created by anonymous on 2002/11/08 */ public class DesignerEnvManager implements XMLReadable, XMLWriter, AsyncXmlReadable { diff --git a/designer-base/src/main/java/com/fr/startup/ui/StartupLoadingPanel.java b/designer-base/src/main/java/com/fr/startup/ui/StartupLoadingPanel.java index 0c82174465..fa44903dc9 100644 --- a/designer-base/src/main/java/com/fr/startup/ui/StartupLoadingPanel.java +++ b/designer-base/src/main/java/com/fr/startup/ui/StartupLoadingPanel.java @@ -15,6 +15,8 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; /** + * 启动加载面板 + * * @author Harrison * @version 11.0 * created by Harrison on 2022/11/08 From 55e30fc5792fa3cc0dc7eb69513c4e62966f5785 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Wed, 16 Nov 2022 11:26:47 +0800 Subject: [PATCH 10/15] =?UTF-8?q?REPORT-83391=20=E9=A1=B6=E9=83=A8?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E9=9D=A2=E6=9D=BF=E4=BD=93=E9=AA=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96=20=E4=BA=A4=E4=BA=92=E6=9B=B4=E6=96=B0=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=81=94=E5=8A=A8=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/gui/ispinner/UISpinner.java | 9 ++++++++ .../ui/topparam/MobileTopParamPane.java | 21 ++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java b/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java index 4a722fc50d..18207011fe 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java +++ b/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java @@ -312,6 +312,15 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver componentInitListeners(); } + /** + * 设置最大值 + * @param maxValue 最大值 + */ + public void setMaxValue(double maxValue) { + this.maxValue = maxValue; + textField.setMaxValue(maxValue); + } + private void componentInitListeners() { preButton.addActionListener(new ActionListener() { @Override diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/topparam/MobileTopParamPane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/topparam/MobileTopParamPane.java index f367365f75..6bef041371 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/topparam/MobileTopParamPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/topparam/MobileTopParamPane.java @@ -11,15 +11,20 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.form.ui.mobile.impl.MobileTopParamStyle; import javax.swing.JPanel; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; import java.awt.BorderLayout; import java.awt.Component; import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; public class MobileTopParamPane extends BasicBeanPane { private UICheckBox autoCommitCheckBox; private UISpinner maxDirectShowCountSpinner; private UILabel showCountTextField; private static final int MAX_VALUE = 4; + private static final int MAX_VALUE_AUTO = 3; private static final int MIN_VALUE = 0; private static final int DEFAULT_DIERTA = 1; private static final int DEFAULT_VALUE = 0; @@ -34,7 +39,7 @@ public class MobileTopParamPane extends BasicBeanPane { JPanel panel = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Plugin-TopParam_Setting")); panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); autoCommitCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Plugin-TopParam_AutoCommit"), true); - maxDirectShowCountSpinner = new UISpinner(MIN_VALUE, MAX_VALUE, DEFAULT_DIERTA, DEFAULT_VALUE); + maxDirectShowCountSpinner = new UISpinner(MIN_VALUE, MAX_VALUE_AUTO, DEFAULT_DIERTA, DEFAULT_VALUE); showCountTextField = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_Show_Count")); Component[][] components = {{autoCommitCheckBox},{showCountTextField, maxDirectShowCountSpinner}}; double p = TableLayout.PREFERRED; @@ -44,6 +49,20 @@ public class MobileTopParamPane extends BasicBeanPane { JPanel paraPane = TableLayoutHelper.createCommonTableLayoutPane(components, rowSize, columnSize, GAP); panel.add(paraPane); this.add(panel, BorderLayout.CENTER); + + autoCommitCheckBox.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (autoCommitCheckBox.isSelected()) { + maxDirectShowCountSpinner.setMaxValue(MAX_VALUE_AUTO); + if (maxDirectShowCountSpinner.getValue() >= MAX_VALUE) { + maxDirectShowCountSpinner.setValue(MAX_VALUE_AUTO); + } + } else { + maxDirectShowCountSpinner.setMaxValue(MAX_VALUE); + } + } + }); } @Override From 0f33a0fee9c109d257420e0090aa7a0d7e5b643d Mon Sep 17 00:00:00 2001 From: Harrison Date: Wed, 16 Nov 2022 18:36:44 +0800 Subject: [PATCH 11/15] =?UTF-8?q?REPORT-83197=E3=80=90=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E3=80=91=E5=90=AF=E5=8A=A8=E9=A1=B5=E6=80=A7=E8=83=BD?= =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E5=B0=86=E5=BC=82=E6=AD=A5=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E6=94=BE=E5=88=B0=20UIUtil=20=E4=B8=AD=E5=8E=BB?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E3=80=82=E9=81=BF=E5=85=8D=E5=A4=9A=E7=BA=BF?= =?UTF-8?q?=E7=A8=8B=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/actions/core/ActionFactory.java | 36 ++++++++----------- .../fr/startup/ui/StartupLoadingPanel.java | 29 +++++++-------- 2 files changed, 30 insertions(+), 35 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/actions/core/ActionFactory.java b/designer-base/src/main/java/com/fr/design/actions/core/ActionFactory.java index 5b1aaf6f52..e4b8b9ed62 100644 --- a/designer-base/src/main/java/com/fr/design/actions/core/ActionFactory.java +++ b/designer-base/src/main/java/com/fr/design/actions/core/ActionFactory.java @@ -6,12 +6,10 @@ import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.mainframe.JTemplate; import com.fr.design.menu.MenuKeySet; import com.fr.design.selection.QuickEditor; +import com.fr.design.ui.util.UIUtil; import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; import com.fr.start.common.DesignerStartupPool; -import com.fr.third.guava.util.concurrent.FutureCallback; -import com.fr.third.guava.util.concurrent.Futures; -import com.fr.third.guava.util.concurrent.ListenableFutureTask; import javax.swing.Action; import javax.swing.KeyStroke; @@ -22,7 +20,7 @@ import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.concurrent.Callable; +import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.CopyOnWriteArraySet; @@ -86,23 +84,19 @@ public class ActionFactory { public static void registerAsyncInitCellEditorClass(Class keyClazz, Class editorClazz) { cellEditorClass.put(keyClazz, editorClazz); - Callable callable = new Callable() { - @Override - public QuickEditor call() throws Exception { - return editorClazz.newInstance(); - } - }; - ListenableFutureTask future = ListenableFutureTask.create(callable); - Futures.addCallback(future, new FutureCallback() { - @Override - public void onSuccess(QuickEditor quickEditor) { - cellEditorClass.remove(keyClazz); - cellEditor.put(keyClazz, quickEditor); - } - - @Override - public void onFailure(Throwable throwable) { - } + CompletableFuture.runAsync(() -> { + UIUtil.invokeAndWaitIfNeeded(new Runnable() { + @Override + public void run() { + try { + QuickEditor quickEditor = editorClazz.newInstance(); + cellEditorClass.remove(keyClazz); + cellEditor.put(keyClazz, quickEditor); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + }); }, DesignerStartupPool.designer()); } diff --git a/designer-base/src/main/java/com/fr/startup/ui/StartupLoadingPanel.java b/designer-base/src/main/java/com/fr/startup/ui/StartupLoadingPanel.java index fa44903dc9..59f86fc467 100644 --- a/designer-base/src/main/java/com/fr/startup/ui/StartupLoadingPanel.java +++ b/designer-base/src/main/java/com/fr/startup/ui/StartupLoadingPanel.java @@ -4,7 +4,7 @@ import com.fr.concurrent.FineExecutors; import com.fr.concurrent.NamedThreadFactory; import com.fr.design.gui.iprogressbar.ProgressDialog; import com.fr.design.i18n.Toolkit; -import com.fr.design.mainframe.DesignerContext; +import com.fr.design.ui.util.UIUtil; import com.fr.event.Event; import com.fr.event.EventDispatcher; import com.fr.event.Listener; @@ -68,19 +68,20 @@ public class StartupLoadingPanel { scheduler.scheduleAtFixedRate(new Runnable() { @Override public void run() { - if (isComplete()) { - scheduler.shutdown(); - progressDialog.dispose(); - resetListeners(); - return; - } - if (!progressDialog.isVisible()) { - progressDialog = new ProgressDialog(DesignerContext.getDesignerFrame()); - progressDialog.setVisible(true); - String moduleId = getModuleId(); - progressDialog.updateLoadingText(moduleId); - } - progressDialog.setProgressValue(incrementProgress()); + UIUtil.invokeAndWaitIfNeeded(() -> { + if (isComplete()) { + scheduler.shutdown(); + progressDialog.dispose(); + resetListeners(); + return; + } + if (!progressDialog.isVisible()) { + progressDialog.setVisible(true); + String moduleId = getModuleId(); + progressDialog.updateLoadingText(moduleId); + } + progressDialog.setProgressValue(incrementProgress()); + }); } }, 0, STEP_HEARTBEAT, TimeUnit.MILLISECONDS); From 90d09befcc10c94a8bd05ca06aef907c79a3f066 Mon Sep 17 00:00:00 2001 From: Harrison Date: Wed, 16 Nov 2022 19:03:38 +0800 Subject: [PATCH 12/15] =?UTF-8?q?REPORT-83197=E3=80=90=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E3=80=91=E5=90=AF=E5=8A=A8=E9=A1=B5=E6=80=A7=E8=83=BD?= =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E5=92=8C=20vito=20=E8=AE=A8=E8=AE=BA?= =?UTF-8?q?=EF=BC=8C=E8=BF=99=E9=87=8C=E7=9A=84=E5=BC=82=E6=AD=A5=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E7=9B=B4=E6=8E=A5=E6=94=B9=E6=88=90=20invokeLater=20?= =?UTF-8?q?=E7=9C=81=E5=BF=83=E7=9C=81=E5=8A=9B=EF=BC=8C=20get?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/actions/core/ActionFactory.java | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/actions/core/ActionFactory.java b/designer-base/src/main/java/com/fr/design/actions/core/ActionFactory.java index e4b8b9ed62..3a8137f9d0 100644 --- a/designer-base/src/main/java/com/fr/design/actions/core/ActionFactory.java +++ b/designer-base/src/main/java/com/fr/design/actions/core/ActionFactory.java @@ -9,7 +9,6 @@ import com.fr.design.selection.QuickEditor; import com.fr.design.ui.util.UIUtil; import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; -import com.fr.start.common.DesignerStartupPool; import javax.swing.Action; import javax.swing.KeyStroke; @@ -20,7 +19,6 @@ import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.CopyOnWriteArraySet; @@ -84,20 +82,21 @@ public class ActionFactory { public static void registerAsyncInitCellEditorClass(Class keyClazz, Class editorClazz) { cellEditorClass.put(keyClazz, editorClazz); - CompletableFuture.runAsync(() -> { - UIUtil.invokeAndWaitIfNeeded(new Runnable() { - @Override - public void run() { - try { - QuickEditor quickEditor = editorClazz.newInstance(); - cellEditorClass.remove(keyClazz); - cellEditor.put(keyClazz, quickEditor); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } + // 这里直接用 invokeLater 放到 UI 线程中去调用。 + // 不阻塞主逻辑的启动 + UIUtil.invokeLaterIfNeeded(new Runnable() { + @Override + public void run() { + + try { + QuickEditor quickEditor = editorClazz.newInstance(); + cellEditorClass.remove(keyClazz); + cellEditor.put(keyClazz, quickEditor); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); } - }); - }, DesignerStartupPool.designer()); + } + }); } /** From b00edd1c97fdda77ee1330443fc5a38d3133367e Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Thu, 17 Nov 2022 10:50:18 +0800 Subject: [PATCH 13/15] =?UTF-8?q?REPORT-83391=20=E9=A1=B6=E9=83=A8?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E9=9D=A2=E6=9D=BF=E4=BD=93=E9=AA=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96=20=E4=BA=A4=E4=BA=92=E6=9B=B4=E6=96=B0=EF=BC=8C?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=9F=A5=E6=89=BE=E7=9A=84=E6=97=B6=E5=80=99?= =?UTF-8?q?=E6=9C=80=E5=A4=A7=E5=80=BC=E4=B8=BA4=EF=BC=8C=E6=9C=80?= =?UTF-8?q?=E5=B0=8F=E5=80=BC=E4=B8=BA1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/mobile/ui/topparam/MobileTopParamPane.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/topparam/MobileTopParamPane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/topparam/MobileTopParamPane.java index 6bef041371..60647c74ea 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/topparam/MobileTopParamPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/topparam/MobileTopParamPane.java @@ -25,7 +25,7 @@ public class MobileTopParamPane extends BasicBeanPane { private UILabel showCountTextField; private static final int MAX_VALUE = 4; private static final int MAX_VALUE_AUTO = 3; - private static final int MIN_VALUE = 0; + private static final int MIN_VALUE = 1; private static final int DEFAULT_DIERTA = 1; private static final int DEFAULT_VALUE = 0; private static final int GAP = 2; @@ -39,7 +39,7 @@ public class MobileTopParamPane extends BasicBeanPane { JPanel panel = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Plugin-TopParam_Setting")); panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); autoCommitCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Plugin-TopParam_AutoCommit"), true); - maxDirectShowCountSpinner = new UISpinner(MIN_VALUE, MAX_VALUE_AUTO, DEFAULT_DIERTA, DEFAULT_VALUE); + maxDirectShowCountSpinner = new UISpinner(MIN_VALUE, MAX_VALUE, DEFAULT_DIERTA, DEFAULT_VALUE); showCountTextField = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_Show_Count")); Component[][] components = {{autoCommitCheckBox},{showCountTextField, maxDirectShowCountSpinner}}; double p = TableLayout.PREFERRED; @@ -53,7 +53,7 @@ public class MobileTopParamPane extends BasicBeanPane { autoCommitCheckBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - if (autoCommitCheckBox.isSelected()) { + if (!autoCommitCheckBox.isSelected()) { maxDirectShowCountSpinner.setMaxValue(MAX_VALUE_AUTO); if (maxDirectShowCountSpinner.getValue() >= MAX_VALUE) { maxDirectShowCountSpinner.setValue(MAX_VALUE_AUTO); From 4a23adaeccec116e81a77eda9325a3b945d81363 Mon Sep 17 00:00:00 2001 From: Harrison Date: Thu, 17 Nov 2022 14:13:40 +0800 Subject: [PATCH 14/15] =?UTF-8?q?REPORT-83197=E3=80=90=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E3=80=91=E5=90=AF=E5=8A=A8=E9=A1=B5=E6=80=A7=E8=83=BD?= =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E9=81=97=E6=BC=8F=E4=BA=86=E4=B8=A4?= =?UTF-8?q?=E9=83=A8=E5=88=86=EF=BC=8C=E4=BB=A3=E7=A0=81=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E4=B8=8B=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/DesignerEnvManager.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java index 9d0f1f4644..43e59f2263 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -1870,6 +1870,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter, AsyncXmlReada .init("ActivationKey", DesignerEnvManager.this::readActiveKey) .init("status", DesignerEnvManager.this::readActiveStatus) .init(CAS_PARAS, DesignerEnvManager.this::readHttpsParas) + .init(EnvDetectorConfig.XML_TAG, DesignerEnvManager.this::readEnvDetectorConfig) + .init(DesignerStartupConfig.XML_TAG, DesignerEnvManager.this::readStartupConfig) .init("AlphaFineConfigManager", (e) -> { this.alphaFineConfigManager = AsyncXmlElement.of(DesignerStartupPool.common(), () -> { AlphaFineConfigManager config = AlphaFineConfigManager.getInstance(); From 908d9baca0247f9bce0a48d1da08200472b00ab2 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Thu, 17 Nov 2022 16:00:29 +0800 Subject: [PATCH 15/15] =?UTF-8?q?REPORT-83391=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=91=BD=E5=90=8D=E7=BB=86=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mobile/ui/topparam/MobileTopParamPane.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/topparam/MobileTopParamPane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/topparam/MobileTopParamPane.java index 60647c74ea..8330d2aca5 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/topparam/MobileTopParamPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/topparam/MobileTopParamPane.java @@ -11,8 +11,6 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.form.ui.mobile.impl.MobileTopParamStyle; import javax.swing.JPanel; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; import java.awt.BorderLayout; import java.awt.Component; import java.awt.FlowLayout; @@ -23,11 +21,11 @@ public class MobileTopParamPane extends BasicBeanPane { private UICheckBox autoCommitCheckBox; private UISpinner maxDirectShowCountSpinner; private UILabel showCountTextField; - private static final int MAX_VALUE = 4; - private static final int MAX_VALUE_AUTO = 3; + private static final int MAX_VALUE_AUTO = 4; + private static final int MAX_VALUE = 3; private static final int MIN_VALUE = 1; private static final int DEFAULT_DIERTA = 1; - private static final int DEFAULT_VALUE = 0; + private static final int DEFAULT_VALUE = 4; private static final int GAP = 2; public MobileTopParamPane() { @@ -39,7 +37,7 @@ public class MobileTopParamPane extends BasicBeanPane { JPanel panel = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Plugin-TopParam_Setting")); panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); autoCommitCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Plugin-TopParam_AutoCommit"), true); - maxDirectShowCountSpinner = new UISpinner(MIN_VALUE, MAX_VALUE, DEFAULT_DIERTA, DEFAULT_VALUE); + maxDirectShowCountSpinner = new UISpinner(MIN_VALUE, MAX_VALUE_AUTO, DEFAULT_DIERTA, DEFAULT_VALUE); showCountTextField = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_Show_Count")); Component[][] components = {{autoCommitCheckBox},{showCountTextField, maxDirectShowCountSpinner}}; double p = TableLayout.PREFERRED; @@ -54,12 +52,12 @@ public class MobileTopParamPane extends BasicBeanPane { @Override public void actionPerformed(ActionEvent e) { if (!autoCommitCheckBox.isSelected()) { - maxDirectShowCountSpinner.setMaxValue(MAX_VALUE_AUTO); - if (maxDirectShowCountSpinner.getValue() >= MAX_VALUE) { - maxDirectShowCountSpinner.setValue(MAX_VALUE_AUTO); + maxDirectShowCountSpinner.setMaxValue(MAX_VALUE); + if (maxDirectShowCountSpinner.getValue() >= MAX_VALUE_AUTO) { + maxDirectShowCountSpinner.setValue(MAX_VALUE); } } else { - maxDirectShowCountSpinner.setMaxValue(MAX_VALUE); + maxDirectShowCountSpinner.setMaxValue(MAX_VALUE_AUTO); } } });