Browse Source

REPORT-55188 【组件背景分离】组件复用-设计器右侧组件目录树选中组件应也触发绝对布局下组件的工具栏

zheng-1641779399395
hades 3 years ago
parent
commit
428e1e63b1
  1. 31
      designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java

31
designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java

@ -4,6 +4,7 @@ import com.fr.design.constants.UIConstants;
import com.fr.design.designer.creator.XCreator; 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.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;
@ -378,22 +379,30 @@ public class ComponentTree extends JTree {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
// 鼠标左键 双击 Point p = e.getPoint();
if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1 && !designer.isFormParaDesigner()) { // 解析组件树路径 获取选中的组件
Point p = e.getPoint(); int selRow = tree.getRowForLocation(p.x, p.y);
// 解析组件树路径 获取选中的组件 TreePath path = tree.getPathForRow(selRow);
int selRow = tree.getRowForLocation(p.x, p.y); Rectangle bounds = tree.getPathBounds(path);
TreePath path = tree.getPathForRow(selRow); if (bounds != null) {
Rectangle bounds = tree.getPathBounds(path); Point point = bounds.getLocation();
if (bounds != null) { SwingUtilities.convertPointToScreen(point, tree);
Point point = bounds.getLocation(); XCreator comp = (XCreator) path.getLastPathComponent();
SwingUtilities.convertPointToScreen(point, tree); // 鼠标左键 双击
XCreator comp = (XCreator) path.getLastPathComponent(); if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1 && !designer.isFormParaDesigner()) {
startEditing(comp, e); startEditing(comp, e);
} else if (e.getClickCount() == 1 && e.getButton() == MouseEvent.BUTTON1) {
showSelectedPopup(comp);
} }
} }
} }
private void showSelectedPopup(XCreator comp) {
Rectangle rectangle = getRelativeBounds(comp);
comp.showSelectedPopup(designer, rectangle, comp.acceptType(XWTitleLayout.class));
comp.setSelected(true);
}
/** /**
* 组件进入编辑状态 * 组件进入编辑状态
* *

Loading…
Cancel
Save