From 6d83456d3dc974edf639745b69a244f934acba9d Mon Sep 17 00:00:00 2001 From: "Leo.Qin" Date: Mon, 21 Nov 2022 19:50:00 +0800 Subject: [PATCH 1/4] =?UTF-8?q?REPORT-84407=20=E8=AE=BE=E8=AE=A1=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF-=E5=8D=95=E5=85=83=E6=A0=BC=E5=85=83=E7=B4=A0?= =?UTF-8?q?=EF=BC=8C=E5=9B=BD=E9=99=85=E5=8C=96=E6=98=BE=E7=A4=BA=20?= =?UTF-8?q?=E3=80=90=E9=97=AE=E9=A2=98=E5=8E=9F=E5=9B=A0=E3=80=91UIlabel?= =?UTF-8?q?=E9=AB=98=E5=BA=A6=E8=A2=AB=E9=BB=98=E8=AE=A4=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?3=20=E3=80=90=E6=94=B9=E5=8A=A8=E6=80=9D=E8=B7=AF=E3=80=91UIlab?= =?UTF-8?q?el=E9=AB=98=E5=BA=A6=E5=87=8F=E5=B0=913=20=E3=80=90review?= =?UTF-8?q?=E5=BB=BA=E8=AE=AE=E3=80=91=E6=97=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/quickeditor/CellQuickEditor.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java b/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java index 67a65672f1..1793efa17d 100644 --- a/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java +++ b/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java @@ -67,6 +67,7 @@ public abstract class CellQuickEditor extends QuickEditor { private static final int CONTENT_PANE_WIDTH_GAP = 3; private static final int MOUSE_WHEEL_SPEED = 5; private static final int SCROLLBAR_WIDTH = 7; + private final int HTML_SHIFT_HEIGHT = -3; private UILabel cellLabel; private int maxHeight = 280; @@ -285,10 +286,11 @@ public abstract class CellQuickEditor extends QuickEditor { if (selectedOneCell) { columnRowTextField.setPreferredSize(null); cellLabel.setPreferredSize(null); - multipleLabelTip.setPreferredSize(new Dimension()); + // 使用UILabel.getPreferredSize时,若文本为html高度被默认增加3 + multipleLabelTip.setPreferredSize(new Dimension(0, HTML_SHIFT_HEIGHT)); } else { - columnRowTextField.setPreferredSize(new Dimension()); - cellLabel.setPreferredSize(new Dimension()); + columnRowTextField.setPreferredSize(new Dimension(0, HTML_SHIFT_HEIGHT)); + cellLabel.setPreferredSize(new Dimension(0, HTML_SHIFT_HEIGHT)); multipleLabelTip.setPreferredSize(null); } } From 947e420b837868876e34d549adda6a87cd15f0a3 Mon Sep 17 00:00:00 2001 From: "Leo.Qin" Date: Tue, 22 Nov 2022 13:36:43 +0800 Subject: [PATCH 2/4] =?UTF-8?q?REPORT-84407=20=E4=BF=AE=E6=94=B9=E9=9A=90?= =?UTF-8?q?=E8=97=8F=E9=9D=A2=E6=9D=BF=E6=97=B6=E7=BB=84=E4=BB=B6=E7=9A=84?= =?UTF-8?q?=E5=AE=BD=E5=BA=A6=E3=80=81=E9=AB=98=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/quickeditor/CellQuickEditor.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java b/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java index 1793efa17d..0b0650478b 100644 --- a/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java +++ b/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java @@ -58,6 +58,9 @@ import java.util.Set; public abstract class CellQuickEditor extends QuickEditor { protected static final Dimension LABEL_DIMENSION = new Dimension(GraphHelper.getWidth(Toolkit.i18nText("Fine-Design_Report_Insert_Cell_Element")), 20); + + // 使用UILabel.getPreferredSize时,若文本为html高度被默认增加3 + protected static final Dimension HIDDEN_LABEL_DIMENSION = new Dimension(0, -3); protected static final int VGAP = 10, HGAP = 8, VGAP_INNER = 3; /** @@ -67,7 +70,6 @@ public abstract class CellQuickEditor extends QuickEditor { private static final int CONTENT_PANE_WIDTH_GAP = 3; private static final int MOUSE_WHEEL_SPEED = 5; private static final int SCROLLBAR_WIDTH = 7; - private final int HTML_SHIFT_HEIGHT = -3; private UILabel cellLabel; private int maxHeight = 280; @@ -286,11 +288,10 @@ public abstract class CellQuickEditor extends QuickEditor { if (selectedOneCell) { columnRowTextField.setPreferredSize(null); cellLabel.setPreferredSize(null); - // 使用UILabel.getPreferredSize时,若文本为html高度被默认增加3 - multipleLabelTip.setPreferredSize(new Dimension(0, HTML_SHIFT_HEIGHT)); + multipleLabelTip.setPreferredSize(HIDDEN_LABEL_DIMENSION); } else { - columnRowTextField.setPreferredSize(new Dimension(0, HTML_SHIFT_HEIGHT)); - cellLabel.setPreferredSize(new Dimension(0, HTML_SHIFT_HEIGHT)); + columnRowTextField.setPreferredSize(HIDDEN_LABEL_DIMENSION); + cellLabel.setPreferredSize(HIDDEN_LABEL_DIMENSION); multipleLabelTip.setPreferredSize(null); } } From 9d9551b7666b2509a5683f740dfba18210fc2700 Mon Sep 17 00:00:00 2001 From: Harrison Date: Wed, 23 Nov 2022 10:32:53 +0800 Subject: [PATCH 3/4] =?UTF-8?q?REPORT-85210=20&&=20REPORT-85293=201-?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E6=9D=A1=E6=A0=B7=E5=BC=8F=E4=BC=98=E5=8C=96?= =?UTF-8?q?=202-=E5=90=AF=E5=8A=A8=E5=BC=82=E5=B8=B8=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E4=BC=98=E5=8C=96=203-=E7=BB=99=E5=BC=82=E6=AD=A5=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=20envmanager=20=E6=8F=90=E4=BE=9B=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/DesignerEnvManager.java | 52 +++++++++++++----- .../gui/iprogressbar/ProgressDialog.java | 4 ++ .../com/fr/startup/ui/StartupPageWindow.java | 14 +++-- .../gui/iprogressbar/ProgressDialogTest.java | 55 +++++++++++++++++++ .../DesignerStartupPageActivator.java | 6 +- 5 files changed, 113 insertions(+), 18 deletions(-) create mode 100644 designer-base/src/test/java/com/fr/design/gui/iprogressbar/ProgressDialogTest.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 6b681699be..199834fb77 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -4,6 +4,7 @@ package com.fr.design; import com.fr.base.BaseXMLUtils; +import com.fr.base.OptimizeUtil; import com.fr.base.Utils; import com.fr.collections.api.Callback; import com.fr.design.actions.help.alphafine.AlphaFineConfigManager; @@ -95,6 +96,7 @@ import java.util.ListIterator; import java.util.Locale; import java.util.Map; import java.util.Map.Entry; +import java.util.concurrent.atomic.AtomicBoolean; /** * The manager of Designer GUI. @@ -263,19 +265,10 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter, AsyncXmlReada designerEnvManager = new DesignerEnvManager(); //REPORT-15332有一个国际化调用比较早,需要在这边就设置好locale,由于后台GeneralContext默认是China GeneralContext.setLocale(designerEnvManager.getLanguage()); - try { - 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); - } + + if (!asyncInitEnvManager()) { + // 如果异步读取失败, 则恢复原来的逻辑 + compatibleInitEnvManager(); } // james:如果没有env定义,要设置一个默认的 @@ -292,6 +285,39 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter, AsyncXmlReada return designerEnvManager; } + + private static void compatibleInitEnvManager() { + + 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); + } + } + + /** + * 异步初始化环境管理, 提供配置, 帮助处理预期外的问题 + * 1-当优化开启时,才走异步逻辑 + * 2-如果异步执行中出错,则返回异常 false, 否则返回 true + * + * @return 是/否 + */ + private static boolean asyncInitEnvManager() { + + AtomicBoolean noEx = new AtomicBoolean(false); + OptimizeUtil.open(DesignerEnvManager.class.getSimpleName().toLowerCase(), OptimizeUtil.Module.COMMON, () -> { + try { + designerEnvManager.initElements(designerEnvManager.getDesignerEnvFile()); + noEx.set(true); + } catch (Throwable retryEx) { + FineLoggerFactory.getLogger().debug("try async init DesignerEnvManager failed", retryEx); + } + }); + return noEx.get(); + } public ColorSelectConfigManager getColorConfigManager() { return this.configManager; diff --git a/designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java b/designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java index 2c1e6abf56..10ece3d3ab 100644 --- a/designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java +++ b/designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java @@ -20,6 +20,10 @@ import java.awt.Frame; /** * 加载进度弹窗 + * 使用注意点: + * 1-需要等到 父frame 启动好之后,才能启动进度条。 + * 2-或者到使用时再初始化,不要作为属性存在 + * 见 {@link com.fr.design.gui.iprogressbar.ProgressDialogTest} */ public class ProgressDialog extends UIDialog { protected static final FRFont font = DesignUtils 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 0b57247ac0..8905d6004c 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 @@ -91,8 +91,6 @@ public class StartupPageWindow extends JFrame { initCenter(pageModel); - loadingPanel = new StartupLoadingPanel(this); - // Workspace-detail setSize(SCREEN_SIZE); setDefaultTitle(); @@ -103,7 +101,10 @@ public class StartupPageWindow extends JFrame { revalidate(); setFullScreen(); - + + // 必须放最后 + // 见 https://work.fineres.com/browse/REPORT-85293 + loadingPanel = new StartupLoadingPanel(this); } private void initCenter(StartupPageModel pageModel) { @@ -230,7 +231,11 @@ public class StartupPageWindow extends JFrame { private void enterWorkspace(Runnable action) { - loadingPanel.show(); + UIUtil.invokeAndWaitIfNeeded(() -> { + loadingPanel.show(); + setEnabled(false); + }); + SwingWorker task = new SwingWorker() { @Override protected Void doInBackground() throws Exception { @@ -257,6 +262,7 @@ public class StartupPageWindow extends JFrame { .modal(false) .build() .setVisible(true); + setEnabled(true); }); FineLoggerFactory.getLogger().error(e.getMessage(), e); } finally { diff --git a/designer-base/src/test/java/com/fr/design/gui/iprogressbar/ProgressDialogTest.java b/designer-base/src/test/java/com/fr/design/gui/iprogressbar/ProgressDialogTest.java new file mode 100644 index 0000000000..336850f26b --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/gui/iprogressbar/ProgressDialogTest.java @@ -0,0 +1,55 @@ +package com.fr.design.gui.iprogressbar; + +import com.fr.design.utils.DevUtils; + +import java.awt.Dimension; +import java.awt.Frame; +import java.util.function.Consumer; + +/** + * @author Harrison + * @version 11.0 + * Created by Harrison on 2022/11/23 + */ +public class ProgressDialogTest { + + public static void main(String[] args) { + + mockInitSize(); + } + + /** + * 模拟 frame 的大小未初始化好的情况 + */ + private static void mockNotInitSize() { + + DevUtils.show(new Consumer() { + @Override + public void accept(Frame frame) { + + Dimension origin = frame.getSize(); + frame.setSize(0, 0); + ProgressDialog progressDialog = new ProgressDialog(frame); + progressDialog.setVisible(true); + progressDialog.updateLoadingText("test"); + frame.setSize(origin); + } + }); + } + + /** + * 模拟 frame 的大小初始化好的情况 + */ + private static void mockInitSize() { + + DevUtils.show(new Consumer() { + @Override + public void accept(Frame frame) { + + ProgressDialog progressDialog = new ProgressDialog(frame); + progressDialog.setVisible(true); + progressDialog.updateLoadingText("test"); + } + }); + } +} \ No newline at end of file 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 87f84c9d60..d861fa052a 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 @@ -149,7 +149,11 @@ public class DesignerStartupPageActivator extends Activator { StopWatch stopWatch = StopWatch.createStarted(); try { - DesignerStartupContext.getRecorder().resume(); + + StopWatch recorder = DesignerStartupContext.getRecorder(); + if (recorder.isSuspended()) { + recorder.resume(); + } // 等待中切换 DesignerStartupContext.getInstance().setOnWaiting(false); From 3a5752a973c29879760476b55c382067e03bf78a Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Wed, 23 Nov 2022 14:29:24 +0800 Subject: [PATCH 4/4] =?UTF-8?q?REPORT-84427=20=E3=80=90=E6=9F=A5=E6=89=BE?= =?UTF-8?q?=E4=B8=8E=E6=9B=BF=E6=8D=A2=E3=80=91=E5=88=87=E6=8D=A2=E6=9F=A5?= =?UTF-8?q?=E6=89=BE=E5=86=85=E5=AE=B9=E4=BC=9A=E5=87=BA=E7=8E=B0=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E5=AE=9A=E4=BD=8D=E7=9A=84=E6=83=85=E5=86=B5=EF=BC=88?= =?UTF-8?q?=E7=89=B9=E6=AE=8A=E5=9C=BA=E6=99=AF=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../actions/replace/ui/ITReplaceSouthPanel.java | 2 +- .../design/actions/replace/ui/ITTableButton.java | 13 ------------- .../design/actions/replace/ui/ITTableEditor.java | 2 +- .../actions/replace/ui/ITTableEditorPane.java | 14 ++++++++++++++ 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java index 2a555a4387..57b81077dd 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java @@ -29,7 +29,7 @@ public class ITReplaceSouthPanel { RowSorter sorter = new TableRowSorter(itTableEditor) { @Override public boolean isSortable(int column) { - return column != CHECKBOX_INDEX || column != CONTENT_INDEX; + return column != CHECKBOX_INDEX && column != CONTENT_INDEX; } }; tableEditorPane.getEditTable().setRowSorter(sorter); diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java index ce11d184d0..5cee5af04f 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java @@ -38,19 +38,6 @@ public class ITTableButton extends AbstractCellEditor implements TableCellEditor paraButton = new UIButton("" + Toolkit.i18nText("Fine-Design_Chart_Location") + " "); paraButton.setVisible(true); paraButton.setBorderPainted(false); - paraButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - ITContent content = (ITContent) getEditTable().getValueAt(getEditTable().getEditingRow(), ITReplaceSouthPanel.CONTENT_INDEX); - if (StringUtils.isNotEmpty(GeneralUtils.objectToString(content.getTrlString()))) { - ITReplaceMainDialog.setITReplaceFlag(true); - TRL trl = new TRL(GeneralUtils.objectToString(content.getTrlString())); - DesignerContext.getDesignerFrame().openOrActiveTemplate(content.getTemplatePath()); - HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().navigate(trl); - } - ITReplaceMainDialog.setITReplaceFlag(false); - } - }); } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditor.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditor.java index 7f4960d21b..d805d430ee 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditor.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditor.java @@ -94,7 +94,7 @@ public class ITTableEditor extends UITableModelAdapter { */ @Override public boolean isCellEditable(int row, int col) { - return col == ITReplaceSouthPanel.CONTENT_INDEX || col == ITReplaceSouthPanel.CHECKBOX_INDEX; + return col == ITReplaceSouthPanel.CHECKBOX_INDEX; } /** diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java index f46ea95ac4..ef32da98d6 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java @@ -1,17 +1,21 @@ package com.fr.design.actions.replace.ui; +import com.fr.base.TRL; import com.fr.design.actions.replace.info.base.ITContent; import com.fr.design.border.UIRoundedBorder; import com.fr.design.constants.UIConstants; import com.fr.design.dialog.BasicPane; +import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itableeditorpane.UITableEditAction; import com.fr.design.gui.itableeditorpane.UITableModelAdapter; import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.share.ui.base.MouseClickListener; +import com.fr.general.GeneralUtils; import com.fr.stable.StringUtils; @@ -75,6 +79,16 @@ public class ITTableEditorPane extends BasicPane { //改变面板的各个状态 changeComponentStatus(content, row, col); } + if (col == ITReplaceSouthPanel.CONTENT_INDEX) { + ITContent content = (ITContent) editTable.getValueAt(row, ITReplaceSouthPanel.CONTENT_INDEX); + if (StringUtils.isNotEmpty(GeneralUtils.objectToString(content.getTrlString()))) { + ITReplaceMainDialog.setITReplaceFlag(true); + TRL trl = new TRL(GeneralUtils.objectToString(content.getTrlString())); + DesignerContext.getDesignerFrame().openOrActiveTemplate(content.getTemplatePath()); + HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().navigate(trl); + } + ITReplaceMainDialog.setITReplaceFlag(false); + } } });