From 9af7ee1f8148f887a2b2d722cda1163649cc590e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Thu, 5 May 2022 14:55:16 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-69470=20=E5=A4=9A=E5=88=86=E7=B1=BB?= =?UTF-8?q?=E5=9D=90=E6=A0=87=E8=BD=B4=E5=88=86=E5=B1=82=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=EF=BC=8C=E9=80=89=E6=8B=A9=E9=83=A8=E5=88=86=E8=BD=B4=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E9=A2=9C=E8=89=B2=E5=BC=B9=E7=AA=97=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=85=B3=E9=97=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/frpane/ClosableBubbleFloatPane.java | 46 +++++++++++++++++++ .../design/gui/frpane/UIBubbleFloatPane.java | 20 +++++++- ...VanChartCategoryStylePaneWithCheckBox.java | 4 +- 3 files changed, 66 insertions(+), 4 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/gui/frpane/ClosableBubbleFloatPane.java diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/ClosableBubbleFloatPane.java b/designer-base/src/main/java/com/fr/design/gui/frpane/ClosableBubbleFloatPane.java new file mode 100644 index 000000000..41a4471da --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/ClosableBubbleFloatPane.java @@ -0,0 +1,46 @@ +package com.fr.design.gui.frpane; + +import com.fr.base.BaseUtils; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.gui.ilable.UILabel; + +import javax.swing.Icon; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Point; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +public abstract class ClosableBubbleFloatPane extends UIBubbleFloatPane { + public ClosableBubbleFloatPane(int arrowPosition, Point arrowPoint, BasicBeanPane contentPane) { + super(arrowPosition, arrowPoint, contentPane); + } + + public ClosableBubbleFloatPane(int arrowPosition, Point arrowPoint, BasicBeanPane contentPane, int width, int height) { + super(arrowPosition, arrowPoint, contentPane, width, height); + } + + protected void initAWTEventListener() { + + } + + public boolean forceLockFocus() { + return true; + } + + protected JPanel initTopOptionMenu() { + JPanel menu = new JPanel(new BorderLayout()); + Icon icon = BaseUtils.readIcon("/com/fr/design/images/buttonicon/close_icon.png"); + UILabel label = new UILabel(icon); + label.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + showDialog.setVisible(false); + updateContentPane(); + } + }); + + menu.add(label, BorderLayout.EAST); + return menu; + } +} diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/UIBubbleFloatPane.java b/designer-base/src/main/java/com/fr/design/gui/frpane/UIBubbleFloatPane.java index 03927ca46..e50140121 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/UIBubbleFloatPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/UIBubbleFloatPane.java @@ -48,7 +48,7 @@ public abstract class UIBubbleFloatPane extends BasicBeanPane { private int arrowPosition; private double time = 0.5; - private UIDialog showDialog; + protected UIDialog showDialog; /** * @param arrowPosition 箭头的位置,上下左右,暂时只处理了左边,后面用到了再说 TODO @@ -93,11 +93,22 @@ public abstract class UIBubbleFloatPane extends BasicBeanPane { populateBean(ob); if (showDialog == null) { showDialog = showUnsizedWindow(SwingUtilities.getWindowAncestor(fatherPane)); + if (forceLockFocus()) { + showDialog.setModalityType(Dialog.ModalityType.DOCUMENT_MODAL); + } } - Toolkit.getDefaultToolkit().addAWTEventListener(awt, AWTEvent.MOUSE_EVENT_MASK); + initAWTEventListener(); showDialog.setVisible(true); } + public boolean forceLockFocus() { + return false; + } + + protected void initAWTEventListener() { + Toolkit.getDefaultToolkit().addAWTEventListener(awt, AWTEvent.MOUSE_EVENT_MASK); + } + /** * 数据展现 */ @@ -213,9 +224,14 @@ public abstract class UIBubbleFloatPane extends BasicBeanPane { } this.setLayout(new BorderLayout()); + this.add(initTopOptionMenu(), BorderLayout.NORTH); this.add(contentPane, BorderLayout.CENTER); } + protected JPanel initTopOptionMenu() { + return new JPanel(); + } + private class CustomShapedDialog extends UIDialog { private static final int GAP_SMALL = 10; diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/component/VanChartCategoryStylePaneWithCheckBox.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/component/VanChartCategoryStylePaneWithCheckBox.java index acc87572f..79e4aad9b 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/component/VanChartCategoryStylePaneWithCheckBox.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/component/VanChartCategoryStylePaneWithCheckBox.java @@ -1,7 +1,7 @@ package com.fr.van.chart.designer.style.axis.component; import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; -import com.fr.design.gui.frpane.UIBubbleFloatPane; +import com.fr.design.gui.frpane.ClosableBubbleFloatPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.i18n.Toolkit; @@ -68,7 +68,7 @@ public class VanChartCategoryStylePaneWithCheckBox extends JPanel { Point comPoint = settingButton.getLocationOnScreen(); Point arrowPoint = new Point(comPoint.x +settingButton.getWidth() - 25, comPoint.y + settingButton.getHeight()); Dimension size = settingPane.getPreferredSize(); - UIBubbleFloatPane pane = new UIBubbleFloatPane(Constants.LEFT, arrowPoint, settingPane, size.width, 230) { + ClosableBubbleFloatPane pane = new ClosableBubbleFloatPane(Constants.LEFT, arrowPoint, settingPane, size.width, 240) { @Override public void updateContentPane() {