Browse Source

REPORT-54155 设计器布局面板上Tab组件拖拽优化 update-调整下方法位置

feature/10.0
hades 4 years ago
parent
commit
a5d4c13be6
  1. 23
      designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java
  2. 24
      designer-form/src/main/java/com/fr/design/mainframe/TabDragInner.java

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

@ -8,7 +8,6 @@ import com.fr.design.DesignModelAdapter;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.TableDataTreePane; import com.fr.design.data.datapane.TableDataTreePane;
import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.HoverPainter; import com.fr.design.designer.beans.HoverPainter;
import com.fr.design.designer.beans.Painter; import com.fr.design.designer.beans.Painter;
import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.beans.events.DesignerEvent;
@ -132,7 +131,7 @@ public class FormCreatorDropTarget extends DropTarget {
designer.getSelectionModel().setSelectedCreators( designer.getSelectionModel().setSelectedCreators(
FormSelectionUtils.rebuildSelection(xCreator, new Widget[]{widget})); FormSelectionUtils.rebuildSelection(xCreator, new Widget[]{widget}));
designer.getEditListenerTable().fireCreatorModified(addingModel.getXCreator(), DesignerEvent.CREATOR_ADDED); designer.getEditListenerTable().fireCreatorModified(addingModel.getXCreator(), DesignerEvent.CREATOR_ADDED);
tryEditTabContainer(); tabDragInner.tryDragIn();
} else { } else {
Toolkit.getDefaultToolkit().beep(); Toolkit.getDefaultToolkit().beep();
} }
@ -142,24 +141,6 @@ public class FormCreatorDropTarget extends DropTarget {
designer.stopAddingState(); designer.stopAddingState();
} }
/**
* 尝试进入tab编辑
*/
private void tryEditTabContainer() {
XLayoutContainer belowXLayoutContainer = tabDragInner.getBelowXLayoutContainer();
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);
}
}
}
}
private void entering(int x, int y) { private void entering(int x, int y) {
// 将要添加的组件图标移动到鼠标下的位置 // 将要添加的组件图标移动到鼠标下的位置
addingModel.moveTo(x, y); addingModel.moveTo(x, y);
@ -289,7 +270,7 @@ public class FormCreatorDropTarget extends DropTarget {
int x = designer.getRelativeX(loc.x); int x = designer.getRelativeX(loc.x);
int y = designer.getRelativeY(loc.y); int y = designer.getRelativeY(loc.y);
hovering(x, y); hovering(x, y);
tabDragInner.dragIn(designer.getComponentAt(x, y), x, y); tabDragInner.canDragIn(designer.getComponentAt(x, y), x, y);
} }
/** /**

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

@ -1,5 +1,7 @@
package com.fr.design.mainframe; 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.XCreator;
import com.fr.design.designer.creator.XCreatorUtils; import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XLayoutContainer;
@ -36,9 +38,8 @@ public class TabDragInner {
* @param x * @param x
* @param y * @param y
*/ */
public void dragIn(XCreator creator, int x, int y) { public void canDragIn(XCreator creator, int x, int y) {
XCreator xCreator = designer.getComponentAt(x, y); XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer(creator).getTopLayout();
XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer(xCreator).getTopLayout();
boolean dragInAble = false; boolean dragInAble = false;
if (topLayout != null && topLayout.acceptType(XWCardMainBorderLayout.class) && belowXLayoutContainer == null) { if (topLayout != null && topLayout.acceptType(XWCardMainBorderLayout.class) && belowXLayoutContainer == null) {
belowXLayoutContainer = topLayout; belowXLayoutContainer = topLayout;
@ -58,6 +59,23 @@ public class TabDragInner {
oldY = y; 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() { public XLayoutContainer getBelowXLayoutContainer() {
return belowXLayoutContainer; return belowXLayoutContainer;

Loading…
Cancel
Save