Browse Source

REPORT-64149

feature/x
方磊 3 years ago
parent
commit
2f24920cbd
  1. 2
      designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java
  2. 4
      designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java
  3. 20
      designer-form/src/main/java/com/fr/design/designer/beans/models/DraggingModel.java
  4. 12
      designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java
  5. 42
      designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java
  6. 9
      designer-form/src/main/java/com/fr/design/mainframe/ToolBarButton.java
  7. 12
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetBlock.java
  8. 18
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/OnlineWidgetBlock.java
  9. 2
      designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/GuideCreateUtils.java

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

@ -352,7 +352,7 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
@Override
public void dragging(DraggingModel model) {
FormDesigner designer = model.getDesigner();
MouseEvent dragEvent = model.getDragEvent();
MouseEvent dragEvent = model.getCurrentDragEvent();
designer.getStateModel().dragging(dragEvent);
}

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

@ -1253,8 +1253,8 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
@Override
public void dragging(DraggingModel model) {
FormDesigner designer = model.getDesigner();
MouseEvent lastPressEvent = model.getLastPressEvent();
MouseEvent dragEvent = model.getDragEvent();
MouseEvent lastPressEvent = model.getStartDragEvent();
MouseEvent dragEvent = model.getCurrentDragEvent();
XCreator creator = model.getCreator();
if ((lastPressEvent == null) || (creator == null)) {
return;

20
designer-form/src/main/java/com/fr/design/designer/beans/models/DraggingModel.java

@ -10,8 +10,8 @@ import java.awt.event.MouseEvent;
public class DraggingModel {
private FormDesigner designer;
private XCreator creator;
private MouseEvent lastPressEvent;
private MouseEvent dragEvent;
private MouseEvent startDragEvent;
private MouseEvent currentDragEvent;
private int creatorLeftTopX = -999; // 隐藏
private int creatorLeftTopY = -999; // 隐藏
@ -24,13 +24,13 @@ public class DraggingModel {
return this;
}
public DraggingModel lastPressEvent(MouseEvent lastPressEvent) {
this.lastPressEvent = lastPressEvent;
public DraggingModel startDragEvent(MouseEvent startDragEvent) {
this.startDragEvent = startDragEvent;
return this;
}
public DraggingModel dragEvent(MouseEvent dragEvent) {
this.dragEvent = dragEvent;
public DraggingModel currentDragEvent(MouseEvent dragEvent) {
this.currentDragEvent = dragEvent;
return this;
}
@ -43,12 +43,12 @@ public class DraggingModel {
return designer;
}
public MouseEvent getLastPressEvent() {
return lastPressEvent;
public MouseEvent getStartDragEvent() {
return startDragEvent;
}
public MouseEvent getDragEvent() {
return dragEvent;
public MouseEvent getCurrentDragEvent() {
return currentDragEvent;
}
public XCreator getCreator() {

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

@ -4,12 +4,10 @@ import com.fr.base.vcs.DesignerMode;
import com.fr.common.inputevent.InputEventBaseOnOS;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.events.DesignerEditor;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.beans.location.Direction;
import com.fr.design.designer.beans.location.Location;
import com.fr.design.designer.beans.models.DraggingModel;
import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.beans.models.StateModel;
import com.fr.design.designer.creator.XBorderStyleWidgetCreator;
@ -465,15 +463,7 @@ public class EditingMouseListener extends MouseInputAdapter {
return;
}
designer.setDraggingModel(new DraggingModel()
.designer(designer)
.creator(lastXCreator)
.lastPressEvent(lastPressEvent)
.dragEvent(e));
XLayoutContainer container = designer.getDraggingHotspotLayout();
LayoutAdapter adapter = container.getLayoutAdapter();
adapter.dragging(designer.getDraggingModel());
designer.startDraggingFormWidget(lastXCreator, lastPressEvent, e);
e.translatePoint(oldX - e.getX(), oldY - e.getY());
designer.repaint();
}

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

@ -9,6 +9,7 @@ import com.fr.design.actions.UpdateAction;
import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.designer.TargetComponent;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.Painter;
import com.fr.design.designer.beans.actions.CopyAction;
import com.fr.design.designer.beans.actions.CutAction;
@ -1218,7 +1219,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
*
* @param xCreator 组件
*/
public void startDraggingNewWidget(XCreator xCreator) {
public void startDraggingBean(XCreator xCreator) {
// 根据所选择的组件的BeanInfo生成相应的AddingModel
// AddingModel和StateModel不一样,适合当前选择的组件相关的
addingModel = new AddingModel(this, xCreator);
@ -1227,6 +1228,43 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
repaint();
}
/**
* 拖入新的组件
*
* @param xCreator
* @param startDragEvent
* @param currentDragEvent
*/
public void startDraggingNewWidget(XCreator xCreator, MouseEvent startDragEvent, MouseEvent currentDragEvent) {
draggingModel = new DraggingModel()
.designer(this)
.creator(xCreator)
.startDragEvent(startDragEvent)
.currentDragEvent(currentDragEvent);
addingModel = new AddingModel(this, xCreator);
this.setDropTarget(new FormCreatorDropTarget(this));
// 触发状态添加模式事件
repaint();
}
/**
* 拖拽表单上的组件
*
* @param xCreator
* @param startDragEvent
* @param currentDragEvent
*/
public void startDraggingFormWidget(XCreator xCreator, MouseEvent startDragEvent, MouseEvent currentDragEvent) {
draggingModel = new DraggingModel()
.designer(this)
.creator(xCreator)
.startDragEvent(startDragEvent)
.currentDragEvent(currentDragEvent);
XLayoutContainer container = this.getDraggingHotspotLayout();
LayoutAdapter adapter = container.getLayoutAdapter();
adapter.dragging(this.getDraggingModel());
}
/**
* 绑定transferHandler主要实现拖拽结束的回调在拖拽已有组件的时候有用需要在回调里面手动把拖拽失败的组件复原否则组件会消失
*
@ -1257,7 +1295,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
*/
public XLayoutContainer getDraggingHotspotLayout() {
DraggingModel model = this.draggingModel;
MouseEvent dragEvent = model.getDragEvent();
MouseEvent dragEvent = model.getCurrentDragEvent();
XCreator hotspot = this.getComponentAt(dragEvent.getX(), dragEvent.getY());
return XCreatorUtils.getHotspotContainer(hotspot);
}

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

@ -1,7 +1,6 @@
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;
@ -106,13 +105,7 @@ public class ToolBarButton extends UIButton implements MouseListener, MouseMotio
}
if (creatorSource != null) {
XCreator xCreator = XCreatorUtils.createThemedXCreator(creatorSource);
FormDesigner designer = WidgetToolBarPane.getTarget();
designer.setDraggingModel(new DraggingModel()
.designer(designer)
.creator(xCreator)
.lastPressEvent(lastPressEvent)
.dragEvent(e));
designer.startDraggingNewWidget(xCreator);
WidgetToolBarPane.getTarget().startDraggingNewWidget(xCreator, lastPressEvent, e);
FormDesignerUtils.addWidgetProcessInfo(xCreator.toData());
lastPressEvent = null;
this.setBorder(null);

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

@ -4,7 +4,6 @@ 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;
@ -12,14 +11,13 @@ 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;
import com.fr.design.mainframe.share.ui.actions.SharedComponentPopupMenu;
import com.fr.design.mainframe.share.ui.constants.ColorConstants;
import com.fr.design.mainframe.share.ui.local.LocalWidgetRepoUpdater;
import com.fr.design.mainframe.share.ui.local.LocalWidgetRepoPane;
import com.fr.design.mainframe.share.ui.local.LocalWidgetRepoUpdater;
import com.fr.design.mainframe.share.ui.local.LocalWidgetSelectPane;
import com.fr.design.mainframe.share.ui.local.WidgetSelectedManager;
import com.fr.design.mainframe.share.util.ShareComponentUtils;
@ -240,13 +238,7 @@ public class LocalWidgetBlock extends PreviewWidgetBlock<DefaultSharableWidget>
if (xCreator == null) {
return;
}
FormDesigner designer = WidgetToolBarPane.getTarget();
designer.setDraggingModel(new DraggingModel()
.designer(designer)
.creator(xCreator)
.lastPressEvent(lastPressEvent)
.dragEvent(e));
designer.startDraggingNewWidget(xCreator);
WidgetToolBarPane.getTarget().startDraggingNewWidget(xCreator, lastPressEvent, e);
lastPressEvent = null;
this.setBorder(null);
}

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

@ -4,7 +4,6 @@ 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;
@ -12,24 +11,23 @@ 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.local.LocalWidgetRepoPane;
import com.fr.design.mainframe.share.ui.online.AbstractOnlineWidgetSelectPane;
import com.fr.design.mainframe.share.ui.online.CarouselStateManger;
import com.fr.form.share.DefaultSharableWidget;
import com.fr.form.share.group.DefaultShareGroup;
import com.fr.design.mainframe.share.ui.local.LocalWidgetRepoPane;
import com.fr.design.mainframe.share.ui.online.OnlineWidgetRepoPane;
import com.fr.design.mainframe.share.util.DownloadUtils;
import com.fr.design.mainframe.share.util.ShareComponentUtils;
import com.fr.design.mainframe.share.util.ShareUIUtils;
import com.fr.design.ui.util.UIUtil;
import com.fr.form.share.DefaultSharableWidget;
import com.fr.form.share.Group;
import com.fr.form.share.SharableWidgetProvider;
import com.fr.form.share.bean.OnlineShareWidget;
import com.fr.form.share.constants.ShareComponentConstants;
import com.fr.form.share.group.DefaultShareGroup;
import com.fr.form.share.group.DefaultShareGroupManager;
import com.fr.form.share.Group;
import com.fr.form.share.utils.ShareUtils;
import com.fr.form.ui.AbstractBorderStyleWidget;
import com.fr.form.ui.Widget;
@ -208,13 +206,7 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock {
} else {
xCreator = ShareComponentUtils.createXCreator(creatorSource, shareId, bindInfo);
}
FormDesigner designer = WidgetToolBarPane.getTarget();
designer.setDraggingModel(new DraggingModel()
.designer(designer)
.creator(xCreator)
.lastPressEvent(lastPressEvent)
.dragEvent(e));
designer.startDraggingNewWidget(xCreator);
WidgetToolBarPane.getTarget().startDraggingNewWidget(xCreator, lastPressEvent, e);
lastPressEvent = null;
this.setBorder(null);
}

2
designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/GuideCreateUtils.java

@ -139,7 +139,7 @@ public class GuideCreateUtils {
designer.setDropTarget(new FormCreatorDropTarget(designer));
designer.repaint();
} else {
designer.startDraggingNewWidget(xCreator);
designer.startDraggingBean(xCreator);
}
FormCreatorDropTarget dropTarget = (FormCreatorDropTarget) designer.getDropTarget();

Loading…
Cancel
Save