From f3f80973c40f1e05c3c8c4e731b5fab577612436 Mon Sep 17 00:00:00 2001 From: hades Date: Tue, 20 Jul 2021 14:43:31 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-55223=20=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-=E5=A4=9A=E5=B1=82tab=E5=B5=8C=E5=A5=971.?= =?UTF-8?q?=E5=A4=96=E5=B1=82tab=E5=9D=97=E6=B2=A1=E6=9C=89=E8=93=9D?= =?UTF-8?q?=E8=89=B2=E9=98=B4=E5=BD=B1=E7=9A=84=E9=80=89=E4=B8=AD=E6=95=88?= =?UTF-8?q?=E6=9E=9C=202.=E5=8F=8C=E5=87=BB=E7=9B=AE=E5=BD=95=E6=A0=91tab?= =?UTF-8?q?=E5=9D=97=E5=86=85=E9=83=A8=E7=BB=84=E4=BB=B6=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E9=80=89=E4=B8=AD=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cardlayout/XWCardMainBorderLayout.java | 16 ++++++--- .../fr/design/mainframe/ComponentTree.java | 15 ++++++++ .../mainframe/EditingMouseListener.java | 35 ++++++++++++++++--- .../fr/design/mainframe/FormDesignerUI.java | 26 ++++++++++---- .../fr/design/mainframe/FormSelection.java | 11 ++++++ 5 files changed, 87 insertions(+), 16 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java index 22698ef5b..523533e5e 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java @@ -62,6 +62,8 @@ public class XWCardMainBorderLayout extends XWBorderLayout { private final int CARDMAINLAYOUT_CHILD_COUNT = 1; + private boolean showOuterShadowBorder; + /** * 构造函数 */ @@ -351,15 +353,18 @@ public class XWCardMainBorderLayout extends XWBorderLayout { @Override public void paintBorder(Graphics g, Rectangle bounds){ - if (isDragInAble()) { + if (!isMouseEnter) { + super.paintBorder(g, bounds); + } + } + + public void paintShadowBorder(Graphics g, Rectangle bounds) { + if (isDragInAble() || showOuterShadowBorder) { Color oldColor = g.getColor(); g.setColor(OUTER_BORDER_COLOR); GraphHelper.draw(g, new Rectangle(bounds.x - BORDER_WIDTH, bounds.y - BORDER_WIDTH, bounds.width + BORDER_WIDTH + 3, bounds.height + BORDER_WIDTH + 3), Constants.LINE_LARGE); g.setColor(oldColor); } - if (!isMouseEnter) { - super.paintBorder(g, bounds); - } } /** @@ -464,4 +469,7 @@ public class XWCardMainBorderLayout extends XWBorderLayout { return LARGEPREFERREDSIZE; } + public void setShowOuterShadowBorder(boolean showOuterShadowBorder) { + this.showOuterShadowBorder = showOuterShadowBorder; + } } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java b/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java index 37094494b..25bf1f5de 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java @@ -5,6 +5,7 @@ import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreatorUtils; import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XWTitleLayout; +import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; import com.fr.design.designer.treeview.ComponentTreeCellRenderer; import com.fr.design.designer.treeview.ComponentTreeModel; import com.fr.design.file.HistoryTemplateListCache; @@ -453,6 +454,20 @@ public class ComponentTree extends JTree { if (ArrayUtils.isNotEmpty(listeners) && listeners[0] instanceof EditingMouseListener) { responseClickAll(creator, (EditingMouseListener) listeners[0], new MouseEvent(creator, MouseEvent.MOUSE_CLICKED, e.getWhen(), e.getModifiers(), x, y, e.getClickCount(), false)); } + // 放到事件尾部执行 + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + //处理下tab块的选中 + if (comp.acceptType(XWCardMainBorderLayout.class)) { + XCreator xCreator = designer.getSelectionModel().getSelection().getSelectedCreator(); + if (xCreator != null) { + showSelectedPopup(xCreator); + } + } + } + }); + } /** diff --git a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java index b393d29b0..783e984b9 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java @@ -34,6 +34,7 @@ import com.fr.design.utils.gui.LayoutUtils; import com.fr.general.ComparatorUtils; import com.fr.stable.Constants; +import java.util.LinkedList; import javax.swing.BorderFactory; import javax.swing.JComponent; import javax.swing.JPopupMenu; @@ -613,6 +614,7 @@ public class EditingMouseListener extends MouseInputAdapter { int oldX = e.getX(); int oldY = e.getY(); offsetEventPoint(e); + selectionModel.getSelection().getTabList().clear(); XCreator creator = designer.getComponentAt(e); boolean isValidButton = e.getButton() == MouseEvent.BUTTON1 || e.getButton() == MouseEvent.BUTTON3; @@ -661,13 +663,36 @@ public class EditingMouseListener extends MouseInputAdapter { } private boolean responseTabLayout(XCreator creator, MouseEvent e) { - if (creator.acceptType(XWCardMainBorderLayout.class) ) { - creator.respondClick(this, e); + LinkedList list = selectionModel.getSelection().getTabList(); + if (creator.acceptType(XWCardMainBorderLayout.class)) { + list.add(creator); + } + while (creator.getParent() instanceof XCreator) { + creator = (XCreator) creator.getParent(); + if (creator.acceptType(XWCardMainBorderLayout.class)) { + list.add(creator); + } + } + // 至少存在一层以上tab块的嵌套 + if (list.size() > 1) { + XWCardMainBorderLayout firstCreator = (XWCardMainBorderLayout) list.getFirst(); + XWCardMainBorderLayout lastCreator = (XWCardMainBorderLayout) list.getLast(); + // 内层tab响应事件 + firstCreator.respondClick(this, e); + setCoverPaneNotDisplay(firstCreator, e, false); + final XCreator xCreator = selectionModel.getSelection().getSelectedCreator(); + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + xCreator.setSelected(true); + // 外层tab展示阴影边框效果 + lastCreator.setShowOuterShadowBorder(true); + } + }); return true; - } else if (creator.getParent() instanceof XCreator) { - return responseTabLayout((XCreator) creator.getParent(), e); + } else { + return false; } - return false; } 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 c48c88101..a8ddce03c 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 @@ -95,7 +95,7 @@ public class FormDesignerUI extends ComponentUI { } paintBorder(g); paintSelection(g); - paintDropBorderShadow(g); + paintBorderShadow(g); if (DesignerMode.isAuthorityEditing()) { paintAuthorityDetails(g, designer.getRootComponent()); @@ -333,22 +333,34 @@ public class FormDesignerUI extends ComponentUI { } /** - * 绘制可拖拽进tab块之前的阴影 + * 绘制tab块的阴影 * * @param g */ - private void paintDropBorderShadow(Graphics g) { + private void paintBorderShadow(Graphics g) { + // 绘制可拖拽进tab块之前的阴影 DropTarget dropTarget = designer.getDropTarget(); if (dropTarget instanceof FormCreatorDropTarget) { FormCreatorDropTarget target = (FormCreatorDropTarget) dropTarget; XLayoutContainer layoutContainer = target.getTabDragInner().getBelowXLayoutContainer(); if (layoutContainer != null && layoutContainer.acceptType(XWCardMainBorderLayout.class)) { - Rectangle creatorBounds = ComponentUtils.getRelativeBounds(layoutContainer); - creatorBounds.x -= designer.getHorizontalScaleValue(); - creatorBounds.y -= designer.getVerticalScaleValue(); - layoutContainer.paintBorder(g, creatorBounds); + XWCardMainBorderLayout cardMainBorderLayout = (XWCardMainBorderLayout) layoutContainer; + cardMainBorderLayout.paintShadowBorder(g, getCreatorBounds(layoutContainer)); } } + // 绘制嵌套tab块时的阴影 + if (designer.getSelectionModel().getSelection().getTabList().size() > 1) { + XLayoutContainer layoutContainer = (XLayoutContainer) designer.getSelectionModel().getSelection().getTabList().getLast(); + XWCardMainBorderLayout cardMainBorderLayout = (XWCardMainBorderLayout) layoutContainer; + cardMainBorderLayout.paintShadowBorder(g, getCreatorBounds(layoutContainer)); + } + } + + private Rectangle getCreatorBounds(XLayoutContainer layoutContainer) { + Rectangle creatorBounds = ComponentUtils.getRelativeBounds(layoutContainer); + creatorBounds.x -= designer.getHorizontalScaleValue(); + creatorBounds.y -= designer.getVerticalScaleValue(); + return creatorBounds; } /** diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java b/designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java index 7d3711a69..c25d99b1a 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java @@ -13,6 +13,7 @@ import com.fr.design.designer.creator.XWAbsoluteLayout; import com.fr.design.designer.creator.XWFitLayout; import com.fr.design.designer.creator.XWParameterLayout; import com.fr.design.designer.creator.XWTitleLayout; +import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; import com.fr.design.designer.creator.cardlayout.XWCardTagLayout; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.file.HistoryTemplateListCache; @@ -25,12 +26,15 @@ import java.awt.Component; import java.awt.LayoutManager; import java.awt.Rectangle; import java.util.ArrayList; +import java.util.LinkedList; public class FormSelection { private ArrayList selection; private Rectangle backupBounds; private ArrayList recs = new ArrayList(); + // 选中的组件外层嵌套的tab块 head->tail 由内向外 + private LinkedList tabList = new LinkedList<>(); public FormSelection() { selection = new ArrayList(); @@ -43,6 +47,9 @@ public class FormSelection { for (XCreator xCreator : selection) { xCreator.setSelected(false); } + for (XCreator xCreator : tabList) { + ((XWCardMainBorderLayout) xCreator).setShowOuterShadowBorder(false); + } selection.clear(); } @@ -404,4 +411,8 @@ public class FormSelection { } } } + + public LinkedList getTabList() { + return tabList; + } }