Browse Source

Pull request #4783: REPORT-54155 设计器布局面板上Tab组件拖拽优化

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

* commit 'a5d4c13be6d0126a748edb971592f28a0cc079ca':
  REPORT-54155 设计器布局面板上Tab组件拖拽优化 update-调整下方法位置
  REPORT-54155 设计器布局面板上Tab组件拖拽优化
feature/10.0
Hades 3 years ago
parent
commit
975b1b1a9e
  1. 2
      designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java
  2. 7
      designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java
  3. 9
      designer-form/src/main/java/com/fr/design/designer/creator/XLayoutContainer.java
  4. 5
      designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java
  5. 9
      designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java
  6. 83
      designer-form/src/main/java/com/fr/design/mainframe/TabDragInner.java

2
designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java

@ -72,7 +72,7 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
}
XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer((XCreator)comp).getTopLayout();
if(topLayout != null){
if (topLayout.isEditable()){
if (topLayout.isDragInAble() || topLayout.isEditable()){
return topLayoutAccept(creator, x, y);
}
//绝对布局嵌套,处于内层,不可编辑,不添加,topLayout只能获取到最外层可编辑的布局

7
designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java

@ -19,12 +19,7 @@ import com.fr.design.designer.creator.cardlayout.XWCardTitleLayout;
import com.fr.design.designer.creator.cardlayout.XWTabFitLayout;
import com.fr.design.designer.properties.FRFitLayoutConstraints;
import com.fr.design.designer.properties.FRFitLayoutPropertiesGroupModel;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.fun.FormWidgetOptionProvider;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.JForm;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.utils.ComponentUtils;
import com.fr.form.ui.LayoutBorderStyle;
import com.fr.form.ui.container.WAbsoluteLayout;
@ -169,7 +164,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
//布局控件要先判断是不是可编辑
XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer((XCreator) comp).getTopLayout();
boolean access = topLayout != null && !isMatchEdge && !topLayout.isEditable() && !topLayout.acceptType(XWAbsoluteLayout.class) && !isExtraContainer(comp);
boolean access = topLayout != null && !isMatchEdge && !topLayout.isEditable() && !topLayout.acceptType(XWAbsoluteLayout.class) && !isExtraContainer(comp) && !topLayout.isDragInAble();
if (access) {
return false;
}

9
designer-form/src/main/java/com/fr/design/designer/creator/XLayoutContainer.java

@ -48,6 +48,8 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
//鼠标移动到布局画出编辑层
protected boolean isMouseEnter = false;
private volatile boolean dragInAble;
public void setMouseEnter(boolean mouseEnter) {
isMouseEnter = mouseEnter;
}
@ -577,4 +579,11 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
return false;
}
public boolean isDragInAble() {
return dragInAble;
}
public void setDragInAble(boolean dragInAble) {
this.dragInAble = dragInAble;
}
}

5
designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java

@ -447,4 +447,9 @@ public class XWCardMainBorderLayout extends XWBorderLayout {
return true;
}
@Override
public Dimension initEditorSize() {
return LARGEPREFERREDSIZE;
}
}

9
designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java

@ -66,6 +66,8 @@ public class FormCreatorDropTarget extends DropTarget {
private AddingModel addingModel;
private static final int GAP = 30;
private TabDragInner tabDragInner;
private JWindow promptWindow = new JWindow();
private UIButton promptButton = new UIButton("", BaseUtils.readIcon(IconPathConstants.FORBID_ICON_PATH));
@ -73,6 +75,7 @@ public class FormCreatorDropTarget extends DropTarget {
this.designer = designer;
this.addingModel = designer.getAddingModel();
this.promptWindow.add(promptButton);
this.tabDragInner = new TabDragInner(designer);
}
private void adding(int x, int y) {
@ -128,6 +131,7 @@ public class FormCreatorDropTarget extends DropTarget {
designer.getSelectionModel().setSelectedCreators(
FormSelectionUtils.rebuildSelection(xCreator, new Widget[]{widget}));
designer.getEditListenerTable().fireCreatorModified(addingModel.getXCreator(), DesignerEvent.CREATOR_ADDED);
tabDragInner.tryDragIn();
} else {
Toolkit.getDefaultToolkit().beep();
}
@ -263,7 +267,10 @@ public class FormCreatorDropTarget extends DropTarget {
@Override
public synchronized void dragOver(DropTargetDragEvent dtde) {
Point loc = dtde.getLocation();
hovering(designer.getRelativeX(loc.x), designer.getRelativeY(loc.y));
int x = designer.getRelativeX(loc.x);
int y = designer.getRelativeY(loc.y);
hovering(x, y);
tabDragInner.canDragIn(designer.getComponentAt(x, y), x, y);
}
/**

83
designer-form/src/main/java/com/fr/design/mainframe/TabDragInner.java

@ -0,0 +1,83 @@
package com.fr.design.mainframe;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter;
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.cardlayout.XWCardMainBorderLayout;
/**
* 判断tab块是否能拖入
*
* @author hades
* @version 10.0
* Created by hades on 2021/6/29
*/
public class TabDragInner {
/**
* 悬浮停留的时间间隔
*/
private static final long TIME_GAP = 1000;
private FormDesigner designer;
private XLayoutContainer belowXLayoutContainer;
private long timer;
private int oldX;
private int oldY;
public TabDragInner(FormDesigner designer) {
this.designer = designer;
}
/**
* 判断拖入
*
* @param creator 当前拖拽的组件下方所在布局最上层的组件
* @param x
* @param y
*/
public void canDragIn(XCreator creator, int x, int y) {
XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer(creator).getTopLayout();
boolean dragInAble = false;
if (topLayout != null && topLayout.acceptType(XWCardMainBorderLayout.class) && belowXLayoutContainer == null) {
belowXLayoutContainer = topLayout;
timer = System.currentTimeMillis();
} else if (topLayout == belowXLayoutContainer && topLayout != null && oldX == x && oldY == y) {
if (System.currentTimeMillis() - timer > TIME_GAP) {
dragInAble = true;
}
} else {
timer = 0;
belowXLayoutContainer = null;
}
if (topLayout != null) {
topLayout.setDragInAble(dragInAble);
}
oldX = x;
oldY = y;
}
/**
* 尝试进入tab编辑
*/
public void tryDragIn() {
if (belowXLayoutContainer != null && belowXLayoutContainer.isDragInAble()) {
EditingMouseListener editingMouseListener = new EditingMouseListener(designer);
editingMouseListener.refreshTopXCreator();
belowXLayoutContainer.setEditable(true);
if (editingMouseListener.stopEditing() && belowXLayoutContainer != designer.getRootComponent()) {
ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, belowXLayoutContainer);
if (adapter != null) {
editingMouseListener.startEditing(belowXLayoutContainer, adapter.getDesignerEditor(), adapter);
}
}
}
}
public XLayoutContainer getBelowXLayoutContainer() {
return belowXLayoutContainer;
}
}
Loading…
Cancel
Save