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 22698ef5b9..523533e5e7 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 37094494b4..25bf1f5de7 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 b393d29b06..783e984b9d 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 c48c881010..a8ddce03c9 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 7d3711a695..c25d99b1ae 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; + } }