Browse Source

REPORT-64149

feature/x
方磊 3 years ago
parent
commit
6b50519a15
  1. 1
      designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java
  2. 6
      designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java
  3. 34
      designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java
  4. 3
      designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java
  5. 11
      designer-form/src/main/java/com/fr/design/mainframe/ToolBarButton.java
  6. 11
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetBlock.java
  7. 16
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/OnlineWidgetBlock.java

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

@ -198,6 +198,7 @@ public class EditingMouseListener extends MouseInputAdapter {
}
lastPressEvent = null;
lastXCreator = null;
designer.stopDragging();
e.translatePoint(oldX - e.getX(), oldY - e.getY());
if (isAutoFire(transEvent, clickEvent)) {
// click只有在mouseReleased和mousePressed前后x/y坐标相等时才会被触发在mouseReleased之后

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

@ -168,21 +168,21 @@ public class FormCreatorDropTarget extends DropTarget {
private void entering(int x, int y) {
// 将要添加的组件图标移动到鼠标下的位置
designer.getDraggingModel().moveTo(x, y);
designer.updateDraggingPosition(x, y);
designer.repaint();
}
private void exiting() {
cancelPromptWidgetForbidEnter();
// 隐藏组件图标
designer.getDraggingModel().reset();
designer.resetDraggingPosition();
designer.setPainter(null);
designer.repaint();
}
private void hovering(int x, int y) {
// 当前位置移植鼠标e所在的位置
designer.getDraggingModel().moveTo(x, y);
designer.updateDraggingPosition(x, y);
// 获取e所在的焦点组件
XCreator hotspot = designer.getComponentAt(x, y);
// 获取焦点组件所在的焦点容器

34
designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java

@ -785,6 +785,31 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
repaint();
}
/**
* 停止拖拽
*/
public void stopDragging() {
draggingModel = null;
}
/**
* 更新拖拽model的位置
*/
public void updateDraggingPosition(int x, int y) {
if (draggingModel != null) {
draggingModel.moveTo(x, y);
}
}
/**
* 重置拖拽model的位置
*/
public void resetDraggingPosition() {
if (draggingModel != null) {
draggingModel.reset();
}
}
/**
* 设置其UI类为DesignerUI负责渲染
*/
@ -1202,15 +1227,6 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
repaint();
}
public void startDraggingNewWidget(XCreator xCreator, MouseEvent lastPressEvent, MouseEvent dragEvent) {
draggingModel = new DraggingModel()
.designer(this)
.creator(xCreator)
.lastPressEvent(lastPressEvent)
.dragEvent(dragEvent);
startDraggingNewWidget(xCreator);
}
/**
* 绑定transferHandler主要实现拖拽结束的回调在拖拽已有组件的时候有用需要在回调里面手动把拖拽失败的组件复原否则组件会消失
*

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

@ -200,6 +200,9 @@ public class FormDesignerUI extends ComponentUI {
*/
private void paintDraggingBean(Graphics g) {
DraggingModel model = designer.getDraggingModel();
if (model == null) {
return;
}
XCreator bean = model.getCreator();
int x = model.getCreatorLeftTopX();
int y = model.getCreatorLeftTopY() ;

11
designer-form/src/main/java/com/fr/design/mainframe/ToolBarButton.java

@ -1,6 +1,7 @@
package com.fr.design.mainframe;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.designer.beans.models.DraggingModel;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.file.HistoryTemplateListCache;
@ -75,7 +76,7 @@ public class ToolBarButton extends UIButton implements MouseListener, MouseMotio
}
public void mouseReleased(MouseEvent e) {
WidgetToolBarPane.getTarget().stopDragging();
}
@Override
@ -105,7 +106,13 @@ public class ToolBarButton extends UIButton implements MouseListener, MouseMotio
}
if (creatorSource != null) {
XCreator xCreator = XCreatorUtils.createThemedXCreator(creatorSource);
WidgetToolBarPane.getTarget().startDraggingNewWidget(xCreator, lastPressEvent, e);
FormDesigner designer = WidgetToolBarPane.getTarget();
designer.setDraggingModel(new DraggingModel()
.designer(designer)
.creator(xCreator)
.lastPressEvent(lastPressEvent)
.dragEvent(e));
designer.startDraggingNewWidget(xCreator);
FormDesignerUtils.addWidgetProcessInfo(xCreator.toData());
lastPressEvent = null;
this.setBorder(null);

11
designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetBlock.java

@ -4,6 +4,7 @@ import com.fr.base.FRContext;
import com.fr.base.GraphHelper;
import com.fr.base.iofile.attr.SharableAttrMark;
import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.designer.beans.models.DraggingModel;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.form.util.XCreatorConstants;
@ -11,6 +12,7 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.WidgetToolBarPane;
import com.fr.design.mainframe.share.group.ui.GroupMoveDialog;
import com.fr.design.mainframe.share.ui.actions.SharedComponentPopupAction;
@ -180,6 +182,7 @@ public class LocalWidgetBlock extends PreviewWidgetBlock<DefaultSharableWidget>
dealClickAction(e);
}
pressed = false;
WidgetToolBarPane.getTarget().stopDragging();
}
@Override
@ -237,7 +240,13 @@ public class LocalWidgetBlock extends PreviewWidgetBlock<DefaultSharableWidget>
if (xCreator == null) {
return;
}
WidgetToolBarPane.getTarget().startDraggingNewWidget(xCreator, lastPressEvent, e);
FormDesigner designer = WidgetToolBarPane.getTarget();
designer.setDraggingModel(new DraggingModel()
.designer(designer)
.creator(xCreator)
.lastPressEvent(lastPressEvent)
.dragEvent(e));
designer.startDraggingNewWidget(xCreator);
lastPressEvent = null;
this.setBorder(null);
}

16
designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/OnlineWidgetBlock.java

@ -4,6 +4,7 @@ import com.fr.base.GraphHelper;
import com.fr.base.iofile.attr.SharableAttrMark;
import com.fr.design.DesignerEnvManager;
import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.designer.beans.models.DraggingModel;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.gui.ilable.UILabel;
@ -11,6 +12,7 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.login.DesignerLoginHelper;
import com.fr.design.login.DesignerLoginSource;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.WidgetToolBarPane;
import com.fr.design.mainframe.share.collect.ComponentCollector;
import com.fr.design.mainframe.share.ui.online.AbstractOnlineWidgetSelectPane;
@ -163,6 +165,12 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock {
}
}
@Override
public void mouseReleased(MouseEvent e) {
super.mouseReleased(e);
WidgetToolBarPane.getTarget().stopDragging();
}
@Override
public void mouseDragged(MouseEvent e) {
if (!getWidget().isCompatibleWithCurrentEnv()) {
@ -200,7 +208,13 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock {
} else {
xCreator = ShareComponentUtils.createXCreator(creatorSource, shareId, bindInfo);
}
WidgetToolBarPane.getTarget().startDraggingNewWidget(xCreator, lastPressEvent, e);
FormDesigner designer = WidgetToolBarPane.getTarget();
designer.setDraggingModel(new DraggingModel()
.designer(designer)
.creator(xCreator)
.lastPressEvent(lastPressEvent)
.dragEvent(e));
designer.startDraggingNewWidget(xCreator);
lastPressEvent = null;
this.setBorder(null);
}

Loading…
Cancel
Save