From f601add9669952b02bb206477ce83d04934c7574 Mon Sep 17 00:00:00 2001 From: Starryi Date: Wed, 14 Jul 2021 15:33:14 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-55187=E3=80=90=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E8=83=8C=E6=99=AF=E5=88=86=E7=A6=BB=E3=80=91=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E5=A4=8D=E7=94=A8-body=E5=92=8C=E5=8F=82=E6=95=B0=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF=E9=87=8C=E7=9A=84=E6=8E=A7=E4=BB=B6=EF=BC=88frm?= =?UTF-8?q?=E5=8F=82=E9=9D=A2=E5=92=8Cbody=20=E4=BB=A5=E5=8F=8A=20cpt?= =?UTF-8?q?=E5=8F=82=E9=9D=A2=EF=BC=89=EF=BC=8C=E5=BA=94=E8=AF=A5=E4=B9=9F?= =?UTF-8?q?=E6=9C=89=E5=8F=AA=E6=98=BE=E7=A4=BA=E9=94=81=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E7=9A=84=E5=B7=A5=E5=85=B7=E6=A0=8F=EF=BC=8C=E7=8E=B0=E5=9C=A8?= =?UTF-8?q?=E6=98=AF=E6=B2=A1=E6=9C=89=E5=B7=A5=E5=85=B7=E6=A0=8F=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 子功能: 组件尺寸比例锁定 & 组件工具栏 【问题原因】 工具栏按显示条件更新 【改动思路】 修改工具栏按钮的显示条件: 1. 编辑按钮仅在当前控件为标题控件(图表块/报表块)时可见 2. 比例锁定按钮仅在当前控件所在布局为绝对布局时可见 3. 设置按钮仅在当前控件为可复用组件时可见 4. 所有按钮在拖拽时不显示 4. 若没有按钮显示,则工具栏整体不显示 【review建议】 (cherry picked from commit 6a7996edba76858a8b99386fc40ba95cfea8a640) --- .../com/fr/design/designer/creator/XCreator.java | 2 +- .../fr/design/designer/ui/PopupControlPanel.java | 15 +++++++++++++-- .../design/designer/ui/SelectedPopupDialog.java | 4 ++++ .../com/fr/design/mainframe/FormDesignerUI.java | 2 +- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java b/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java index 0983dded9b..a7860faece 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java @@ -778,7 +778,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo int extraY = (int) (bounds.y * designer.getScale()); popup.setLocation(designer.getLocationOnScreen().x + designer.getPaintX() + extraX, designer.getLocationOnScreen().y + designer.getPaintY() + extraY); popup.updatePane(designer); - popup.setVisible(selected && accept); + popup.setVisible(selected && accept && popup.hasVisibleButtons()); popup.setRelativeBounds(bounds); } diff --git a/designer-form/src/main/java/com/fr/design/designer/ui/PopupControlPanel.java b/designer-form/src/main/java/com/fr/design/designer/ui/PopupControlPanel.java index ee0db4571d..14f92581be 100644 --- a/designer-form/src/main/java/com/fr/design/designer/ui/PopupControlPanel.java +++ b/designer-form/src/main/java/com/fr/design/designer/ui/PopupControlPanel.java @@ -4,6 +4,7 @@ import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.adapters.layout.FRAbsoluteLayoutAdapter; import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.creator.XWTitleLayout; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.VerticalFlowLayout; @@ -58,7 +59,7 @@ public class PopupControlPanel extends JPanel { addButton(toggleButton, 1); addButton(settingButton, 2); - setButtonVisible(editButton, true); + setButtonVisible(editButton, false); setButtonVisible(toggleButton, false); setButtonVisible(settingButton, false); } @@ -139,7 +140,7 @@ public class PopupControlPanel extends JPanel { if (index > 0) { getComponent(2 * index - 1).setVisible(false); } - buttons.get(index).setVisible(true); + buttons.get(index).setVisible(visible); if (!visible) { // 如果当前按钮设置为不可见,且在当前按钮之前的其他按钮也不可见,则下一个可见按钮前无分割线 @@ -192,6 +193,7 @@ public class PopupControlPanel extends JPanel { } public void updatePane(FormDesigner designer) { + setButtonVisible(editButton, creator.acceptType(XWTitleLayout.class)); setButtonVisible(settingButton, creator.isShared()); setButtonVisible(toggleButton, AdapterBus.searchLayoutAdapter(designer, creator) instanceof FRAbsoluteLayoutAdapter); toggleButton.setSelected(creator.toData().isAspectRatioLocked()); @@ -199,6 +201,15 @@ public class PopupControlPanel extends JPanel { updateDimension(); } + public boolean hasVisibleButtons() { + for (int i = 0; i < buttons.size(); i++) { + if (buttons.get(i).isVisible()) { + return true; + } + } + return false; + } + private void updateDimension() { int height = 0; for (int i = 0; i < buttons.size(); i++) { diff --git a/designer-form/src/main/java/com/fr/design/designer/ui/SelectedPopupDialog.java b/designer-form/src/main/java/com/fr/design/designer/ui/SelectedPopupDialog.java index 6702fe7f42..bceba44d30 100644 --- a/designer-form/src/main/java/com/fr/design/designer/ui/SelectedPopupDialog.java +++ b/designer-form/src/main/java/com/fr/design/designer/ui/SelectedPopupDialog.java @@ -34,6 +34,10 @@ public class SelectedPopupDialog extends JDialog { this.setSize(controlPanel.getDefaultDimension()); } + public boolean hasVisibleButtons() { + return controlPanel.hasVisibleButtons(); + } + public void setRelativeBounds(Rectangle rectangle) { this.controlPanel.setRelativeBounds(rectangle); } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java b/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java index c49902c8d9..893297081c 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java @@ -326,7 +326,7 @@ public class FormDesignerUI extends ComponentUI { } creator.paintBorder(g, creatorBounds); // 拖拽时不绘制 - creator.showSelectedPopup(designer, creatorBounds, !designer.getStateModel().isDragging() && creator.acceptType(XWTitleLayout.class)); + creator.showSelectedPopup(designer, creatorBounds, !designer.getStateModel().isDragging()); } }