Browse Source

Pull request #5020: REPORT-55223 【组件背景分离】组件复用-多层tab嵌套1.外层tab块没有蓝色阴影的选中效果 2.双击目录树tab块内部组件没有选中效果

Merge in DESIGN/design from ~HADES/design:release/10.0 to release/10.0

* commit 'fb32093781a6d47d2a2b452a305e16c5a6c3f6f9':
  REPORT-55223 【组件背景分离】组件复用-多层tab嵌套1.外层tab块没有蓝色阴影的选中效果 2.双击目录树tab块内部组件没有选中效果
zheng-1641779399395
Hades 3 years ago
parent
commit
01384ee75d
  1. 16
      designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java
  2. 15
      designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java
  3. 33
      designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java
  4. 24
      designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java
  5. 11
      designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java

16
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 final int CARDMAINLAYOUT_CHILD_COUNT = 1;
private boolean showOuterShadowBorder;
/** /**
* 构造函数 * 构造函数
*/ */
@ -351,15 +353,18 @@ public class XWCardMainBorderLayout extends XWBorderLayout {
@Override @Override
public void paintBorder(Graphics g, Rectangle bounds){ 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(); Color oldColor = g.getColor();
g.setColor(OUTER_BORDER_COLOR); 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); 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); g.setColor(oldColor);
} }
if (!isMouseEnter) {
super.paintBorder(g, bounds);
}
} }
/** /**
@ -464,4 +469,7 @@ public class XWCardMainBorderLayout extends XWBorderLayout {
return LARGEPREFERREDSIZE; return LARGEPREFERREDSIZE;
} }
public void setShowOuterShadowBorder(boolean showOuterShadowBorder) {
this.showOuterShadowBorder = showOuterShadowBorder;
}
} }

15
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.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWTitleLayout; 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.ComponentTreeCellRenderer;
import com.fr.design.designer.treeview.ComponentTreeModel; import com.fr.design.designer.treeview.ComponentTreeModel;
import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListCache;
@ -453,6 +454,20 @@ public class ComponentTree extends JTree {
if (ArrayUtils.isNotEmpty(listeners) && listeners[0] instanceof EditingMouseListener) { 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)); 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);
}
}
}
});
} }
/** /**

33
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.general.ComparatorUtils;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import java.util.LinkedList;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JPopupMenu; import javax.swing.JPopupMenu;
@ -613,6 +614,7 @@ public class EditingMouseListener extends MouseInputAdapter {
int oldX = e.getX(); int oldX = e.getX();
int oldY = e.getY(); int oldY = e.getY();
offsetEventPoint(e); offsetEventPoint(e);
selectionModel.getSelection().getTabList().clear();
XCreator creator = designer.getComponentAt(e); XCreator creator = designer.getComponentAt(e);
boolean isValidButton = e.getButton() == MouseEvent.BUTTON1 || e.getButton() == MouseEvent.BUTTON3; boolean isValidButton = e.getButton() == MouseEvent.BUTTON1 || e.getButton() == MouseEvent.BUTTON3;
@ -661,14 +663,37 @@ public class EditingMouseListener extends MouseInputAdapter {
} }
private boolean responseTabLayout(XCreator creator, MouseEvent e) { private boolean responseTabLayout(XCreator creator, MouseEvent e) {
LinkedList<XCreator> list = selectionModel.getSelection().getTabList();
if (creator.acceptType(XWCardMainBorderLayout.class)) { if (creator.acceptType(XWCardMainBorderLayout.class)) {
creator.respondClick(this, e); list.add(creator);
return true; }
} else if (creator.getParent() instanceof XCreator) { while (creator.getParent() instanceof XCreator) {
return responseTabLayout((XCreator) creator.getParent(), e); 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 {
return false; return false;
} }
}
/** /**

24
designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java

@ -95,7 +95,7 @@ public class FormDesignerUI extends ComponentUI {
} }
paintBorder(g); paintBorder(g);
paintSelection(g); paintSelection(g);
paintDropBorderShadow(g); paintBorderShadow(g);
if (DesignerMode.isAuthorityEditing()) { if (DesignerMode.isAuthorityEditing()) {
paintAuthorityDetails(g, designer.getRootComponent()); paintAuthorityDetails(g, designer.getRootComponent());
@ -333,22 +333,34 @@ public class FormDesignerUI extends ComponentUI {
} }
/** /**
* 绘制可拖拽进tab块之前的阴影 * 绘制tab块的阴影
* *
* @param g * @param g
*/ */
private void paintDropBorderShadow(Graphics g) { private void paintBorderShadow(Graphics g) {
// 绘制可拖拽进tab块之前的阴影
DropTarget dropTarget = designer.getDropTarget(); DropTarget dropTarget = designer.getDropTarget();
if (dropTarget instanceof FormCreatorDropTarget) { if (dropTarget instanceof FormCreatorDropTarget) {
FormCreatorDropTarget target = (FormCreatorDropTarget) dropTarget; FormCreatorDropTarget target = (FormCreatorDropTarget) dropTarget;
XLayoutContainer layoutContainer = target.getTabDragInner().getBelowXLayoutContainer(); XLayoutContainer layoutContainer = target.getTabDragInner().getBelowXLayoutContainer();
if (layoutContainer != null && layoutContainer.acceptType(XWCardMainBorderLayout.class)) { if (layoutContainer != null && layoutContainer.acceptType(XWCardMainBorderLayout.class)) {
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); Rectangle creatorBounds = ComponentUtils.getRelativeBounds(layoutContainer);
creatorBounds.x -= designer.getHorizontalScaleValue(); creatorBounds.x -= designer.getHorizontalScaleValue();
creatorBounds.y -= designer.getVerticalScaleValue(); creatorBounds.y -= designer.getVerticalScaleValue();
layoutContainer.paintBorder(g, creatorBounds); return creatorBounds;
}
}
} }
/** /**

11
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.XWFitLayout;
import com.fr.design.designer.creator.XWParameterLayout; import com.fr.design.designer.creator.XWParameterLayout;
import com.fr.design.designer.creator.XWTitleLayout; 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.XWCardTagLayout;
import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout;
import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListCache;
@ -25,12 +26,15 @@ import java.awt.Component;
import java.awt.LayoutManager; import java.awt.LayoutManager;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedList;
public class FormSelection { public class FormSelection {
private ArrayList<XCreator> selection; private ArrayList<XCreator> selection;
private Rectangle backupBounds; private Rectangle backupBounds;
private ArrayList<Rectangle> recs = new ArrayList<Rectangle>(); private ArrayList<Rectangle> recs = new ArrayList<Rectangle>();
// 选中的组件外层嵌套的tab块 head->tail 由内向外
private LinkedList<XCreator> tabList = new LinkedList<>();
public FormSelection() { public FormSelection() {
selection = new ArrayList<XCreator>(); selection = new ArrayList<XCreator>();
@ -43,6 +47,9 @@ public class FormSelection {
for (XCreator xCreator : selection) { for (XCreator xCreator : selection) {
xCreator.setSelected(false); xCreator.setSelected(false);
} }
for (XCreator xCreator : tabList) {
((XWCardMainBorderLayout) xCreator).setShowOuterShadowBorder(false);
}
selection.clear(); selection.clear();
} }
@ -404,4 +411,8 @@ public class FormSelection {
} }
} }
} }
public LinkedList<XCreator> getTabList() {
return tabList;
}
} }

Loading…
Cancel
Save