diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java index 1c70ef870d..4f7e0a1366 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java @@ -273,7 +273,38 @@ public class XCardSwitchButton extends XButton { // 这里是鼠标的绝对位置 int ex = e.getX() + diff; int ey = e.getY(); + // 获取tab布局的位置,鼠标相对于tab按钮的位置 + double[] tabPositionInBody = getTabAbsolutePositionInBody(); + // 参数界面对坐标的影响 + JForm jform = (JForm) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); + if (jform.getFormDesign().getParaComponent() != null) { + ey -= jform.getFormDesign().getParaHeight(); + } + //减掉tab布局的相对位置 + ex -= tabPositionInBody[0]; + ey -= tabPositionInBody[1]; + + XLayoutContainer titleLayout = tagLayout.getBackupParent(); + Point titlePoint = titleLayout.getLocation(); + // button position + XCardSwitchButton button = this; + Point position = button.getLocation(); + int width = button.getWidth(); + // 鼠标进入按钮右侧删除图标区域 + double recX = position.getX() + titlePoint.getX() + (width - CLOSE_ICON_RIGHT_OFFSET); + double recY = position.getY() + titlePoint.getY() + CLOSE_ICON_TOP_OFFSET; + // 比较的是相对位置的偏移量是否在一定距离内 + // 所以要得到鼠标相对于当前tab块的坐标 + return (recX < ex && ex < recX + CLOSE_ICON_RIGHT_OFFSET && ey < recY && ey > position.getY()); + } + + /** + * 获取tab布局在body内的绝对位置 + * + * @return + */ + private double[] getTabAbsolutePositionInBody() { // 获取tab布局的位置,鼠标相对于tab按钮的位置 Container mainLayout = cardLayout.getBackupParent(); // 这个point是当前tab布局的相对坐标,是相对于父容器的坐标 @@ -290,42 +321,14 @@ public class XCardSwitchButton extends XButton { mainLayout = mainLayout.getParent(); - if (mainLayout instanceof XWCardMainBorderLayout) { - x += mainLayout.getX(); - y += mainLayout.getY(); - } - - if (mainLayout instanceof XWAbsoluteLayout) { + if ((mainLayout instanceof XWCardMainBorderLayout) || (mainLayout instanceof XWAbsoluteLayout)) { x += mainLayout.getX(); y += mainLayout.getY(); } } double mainX = point.getX() + x; double mainY = point.getY() + y; - - // 参数界面对坐标的影响 - JForm jform = (JForm) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); - if(jform.getFormDesign().getParaComponent() != null){ - ey -= jform.getFormDesign().getParaHeight(); - } - - //减掉tab布局的相对位置 - ex -= mainX; - ey -= mainY; - - XLayoutContainer titleLayout = tagLayout.getBackupParent(); - Point titlePoint = titleLayout.getLocation(); - // button position - XCardSwitchButton button = this; - Point position = button.getLocation(); - int width = button.getWidth(); - - // 鼠标进入按钮右侧删除图标区域 - double recX = position.getX() + titlePoint.getX() + (width - CLOSE_ICON_RIGHT_OFFSET); - double recY = position.getY() + titlePoint.getY() + CLOSE_ICON_TOP_OFFSET; - // 比较的是相对位置的偏移量是否在一定距离内 - // 所以要得到鼠标相对于当前tab块的坐标 - return (recX < ex && ex < recX + CLOSE_ICON_RIGHT_OFFSET && ey < recY && ey > position.getY()); + return new double[]{mainX, mainY}; } //将当前switchButton改为选中状态 @@ -337,7 +340,7 @@ public class XCardSwitchButton extends XButton { } } - @Override + @Override public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java index a88b6847e4..7ded6ee77e 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java @@ -460,9 +460,7 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout { public void deleteRelatedComponent(XCreator creator, FormDesigner designer) { XWCardTagLayout tagLayout = (XWCardTagLayout) creator; // 先删除所有tab按钮 - for (int i = 0; i < tagLayout.getComponentCount(); i++) { - tagLayout.remove(i); - } + tagLayout.removeAll(); //逐层回溯找出最外层的XWCardMainBorderLayout XWCardTitleLayout cardTitleLayout = (XWCardTitleLayout) tagLayout.getBackupParent(); XWCardMainBorderLayout mainLayout = (XWCardMainBorderLayout) cardTitleLayout.getBackupParent();