From 4100e7889a39efa193129683f9e6c900ed85cd0a Mon Sep 17 00:00:00 2001 From: Starryi Date: Tue, 19 Oct 2021 22:11:41 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-61219=20=E3=80=90=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E3=80=91=E5=8F=B3=E9=94=AE=E6=9C=89=E4=B8=BB?= =?UTF-8?q?=E9=A2=98=E7=9A=84=E7=BB=84=E4=BB=B6=EF=BC=8C=E9=BC=A0=E6=A0=87?= =?UTF-8?q?=E4=BB=8E=E8=8E=B7=E5=8F=96=E4=B8=BB=E9=A2=98=E6=BB=91=E5=88=B0?= =?UTF-8?q?=E8=AF=A6=E7=BB=86=E8=AF=B4=E6=98=8E=EF=BC=8C=E4=B8=A4=E4=B8=AA?= =?UTF-8?q?=E9=83=BD=E8=A2=AB=E9=80=89=E4=B8=AD=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 修改主题下载交互 【改动思路】 同上 --- .../share/ui/actions/LoadingMenuItem.java | 6 ++- .../SharedComponentActionMenuItemUI.java | 54 +++++++++++++------ 2 files changed, 42 insertions(+), 18 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/LoadingMenuItem.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/LoadingMenuItem.java index 6262c34a3..883a30644 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/LoadingMenuItem.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/LoadingMenuItem.java @@ -23,7 +23,7 @@ public class LoadingMenuItem extends UIMenuItem { super(action); setOpaque(true); setBackground(ColorConstants.BACKGROUND); - setUI(new SharedComponentActionMenuItemUI(false)); + setUI(new SharedComponentActionMenuItemUI()); } public void startLoading() { @@ -40,6 +40,10 @@ public class LoadingMenuItem extends UIMenuItem { repaint(); } + public boolean isLoading() { + return loading; + } + @Override protected void paintBorder(Graphics g) { super.paintBorder(g); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/SharedComponentActionMenuItemUI.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/SharedComponentActionMenuItemUI.java index 8a3fe5e1c..a400ccf37 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/SharedComponentActionMenuItemUI.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/SharedComponentActionMenuItemUI.java @@ -2,6 +2,8 @@ package com.fr.design.mainframe.share.ui.actions; import com.fr.design.constants.UIConstants; import com.fr.design.gui.imenu.UIMenuItemUI; +import com.fr.design.gui.imenu.UIPopupMenu; +import com.fr.design.mainframe.share.ui.constants.ColorConstants; import com.fr.design.utils.gui.GUIPaintUtils; import com.fr.stable.Constants; @@ -10,6 +12,8 @@ import javax.swing.JMenu; import javax.swing.JMenuItem; import javax.swing.MenuSelectionManager; import java.awt.Color; +import java.awt.Component; +import java.awt.Container; import java.awt.Graphics; import java.awt.Graphics2D; @@ -20,16 +24,6 @@ import java.awt.Graphics2D; */ public class SharedComponentActionMenuItemUI extends UIMenuItemUI { - private final boolean autoClosePopup; - - public SharedComponentActionMenuItemUI(boolean autoClosePopup) { - this.autoClosePopup = autoClosePopup; - } - - public SharedComponentActionMenuItemUI() { - this(true); - } - @Override protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) { ButtonModel model = menuItem.getModel(); @@ -37,19 +31,45 @@ public class SharedComponentActionMenuItemUI extends UIMenuItemUI { int menuWidth = menuItem.getWidth(); int menuHeight = menuItem.getHeight(); - if (model.isArmed() || (menuItem instanceof JMenu && model.isSelected())) { - GUIPaintUtils.fillPaint((Graphics2D) g, 0, 0, menuWidth, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 0); + g.setColor(ColorConstants.BACKGROUND); + g.fillRect(0, 0, menuWidth, menuHeight); + if (menuItem.isOpaque()) { + if (model.isArmed() || (menuItem instanceof JMenu && model.isSelected())) { + GUIPaintUtils.fillPaint((Graphics2D) g, 0, 0, menuWidth, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 7); + } else { + GUIPaintUtils.fillPaint((Graphics2D) g, 0, 0, menuWidth, menuHeight, true, Constants.NULL, menuItem.getBackground(), 7); + } + g.setColor(oldColor); + } else if (model.isArmed() || (menuItem instanceof JMenu && + model.isSelected())) { + GUIPaintUtils.fillPaint((Graphics2D) g, 0, 0, menuWidth, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 7); + g.setColor(oldColor); } - - g.setColor(oldColor); } @Override protected void doClick(MenuSelectionManager msm) { - if (autoClosePopup) { - super.doClick(msm); - } else { + if (hasLoadingMenuItem()) { + return; + } + + if (menuItem instanceof LoadingMenuItem) { menuItem.doClick(0); + } else { + super.doClick(msm); + } + } + + private boolean hasLoadingMenuItem() { + Container parent = menuItem.getParent(); + if (parent instanceof UIPopupMenu) { + Component[] components = parent.getComponents(); + for (Component component: components) { + if (component instanceof LoadingMenuItem && ((LoadingMenuItem) component).isLoading()) { + return true; + } + } } + return false; } }