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 0000000000..41a4471daa --- /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 03927ca468..e501401217 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 acc87572ff..79e4aad9bd 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() {