Browse Source

Pull request #4964: REPORT-55178 【组件背景分离】组件复用-设计界面,现在需要点两下选中组件才能出现工具栏 && REPORT-55188 【组件背景分离】组件复用-设计器右侧组件目录树选中组件应也触发绝对布局下组件的工具栏

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

* commit '2428f726947ac7e5376312af636e99c3b21de888':
  REPORT-55188 【组件背景分离】组件复用-设计器右侧组件目录树选中组件应也触发绝对布局下组件的工具栏 update
  REPORT-55188 【组件背景分离】组件复用-设计器右侧组件目录树选中组件应也触发绝对布局下组件的工具栏
  REPORT-55178 【组件背景分离】组件复用-设计界面,现在需要点两下选中组件才能出现工具栏
persist/11.0
Hades 3 years ago
parent
commit
400a8098f0
  1. 67
      designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java
  2. 13
      designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java

67
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.XCreatorUtils;
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.ComponentTreeModel;
import com.fr.design.file.HistoryTemplateListCache;
@ -16,6 +17,7 @@ import com.fr.stable.StringUtils;
import java.awt.Rectangle;
import java.awt.event.MouseListener;
import java.util.Stack;
import java.util.function.Consumer;
import javax.swing.BorderFactory;
import javax.swing.DropMode;
import javax.swing.JPanel;
@ -349,6 +351,7 @@ public class ComponentTree extends JTree {
private final class ComponetTreeMouseListener extends MouseAdapter {
private final JTree tree;
private XCreator selectedCreator;
private ComponetTreeMouseListener(JTree tree) {
this.tree = tree;
@ -378,19 +381,59 @@ public class ComponentTree extends JTree {
@Override
public void mouseClicked(MouseEvent e) {
// 鼠标左键 双击
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);
Rectangle bounds = tree.getPathBounds(path);
if (bounds != null) {
Point point = bounds.getLocation();
SwingUtilities.convertPointToScreen(point, tree);
XCreator comp = (XCreator) path.getLastPathComponent();
startEditing(comp, e);
onMouseEvent(e, new Consumer<XCreator>() {
@Override
public void accept(XCreator creator) {
if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1 && !designer.isFormParaDesigner()) {
startEditing(creator, e);
}
}
});
}
@Override
public void mousePressed(MouseEvent e) {
onMouseEvent(e, new Consumer<XCreator>() {
@Override
public void accept(XCreator creator) {
if (e.getButton() == MouseEvent.BUTTON1) {
selectedCreator = creator;
}
}
});
}
@Override
public void mouseReleased(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON1 && selectedCreator != null) {
showSelectedPopup(selectedCreator);
}
}
private void showSelectedPopup(XCreator comp) {
Rectangle rectangle = getRelativeBounds(comp);
comp.showSelectedPopup(designer, rectangle, comp.acceptType(XWTitleLayout.class));
comp.setSelected(true);
}
/**
* 响应鼠标事件并解析选中的组件
*
* @param e
* @param consumer
*/
private void onMouseEvent(final MouseEvent e, Consumer<XCreator> consumer) {
Point p = e.getPoint();
// 解析组件树路径 获取选中的组件
int selRow = tree.getRowForLocation(p.x, p.y);
TreePath path = tree.getPathForRow(selRow);
Rectangle bounds = tree.getPathBounds(path);
if (bounds != null) {
Point point = bounds.getLocation();
SwingUtilities.convertPointToScreen(point, tree);
XCreator comp = (XCreator) path.getLastPathComponent();
consumer.accept(comp);
}
}

13
designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java

@ -631,9 +631,16 @@ public class EditingMouseListener extends MouseInputAdapter {
selectionModel.selectACreatorAtMouseEvent(e);
refreshTopXCreator();
XCreator[] xCreators = selectionModel.getSelection().getSelectedCreators();
for (XCreator xCreator : xCreators) {
xCreator.setSelected(true);
}
// 放到事件队尾执行
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
for (XCreator xCreator : xCreators) {
xCreator.setSelected(true);
}
}
});
} else if (clickedNonCardButton && responseTabLayout(oldCreator, e)) {
// do nothing
} else {

Loading…
Cancel
Save