|
|
|
@ -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,8 +381,49 @@ public class ComponentTree extends JTree {
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void mouseClicked(MouseEvent 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); |
|
|
|
@ -389,8 +433,7 @@ public class ComponentTree extends JTree {
|
|
|
|
|
Point point = bounds.getLocation(); |
|
|
|
|
SwingUtilities.convertPointToScreen(point, tree); |
|
|
|
|
XCreator comp = (XCreator) path.getLastPathComponent(); |
|
|
|
|
startEditing(comp, e); |
|
|
|
|
} |
|
|
|
|
consumer.accept(comp); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|