|
|
@ -16,6 +16,7 @@ import com.fr.design.utils.ComponentUtils; |
|
|
|
import com.fr.env.utils.DesignerInteractionHistory; |
|
|
|
import com.fr.env.utils.DesignerInteractionHistory; |
|
|
|
import com.fr.form.ui.container.WAbsoluteLayout; |
|
|
|
import com.fr.form.ui.container.WAbsoluteLayout; |
|
|
|
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget; |
|
|
|
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget; |
|
|
|
|
|
|
|
import com.fr.form.ui.container.WBorderLayout; |
|
|
|
|
|
|
|
|
|
|
|
import java.awt.*; |
|
|
|
import java.awt.*; |
|
|
|
|
|
|
|
|
|
|
@ -29,7 +30,7 @@ public abstract class AccessDirection implements Direction { |
|
|
|
private int ymin; |
|
|
|
private int ymin; |
|
|
|
private int xmin; |
|
|
|
private int xmin; |
|
|
|
|
|
|
|
|
|
|
|
abstract int getCursor(); |
|
|
|
abstract int getCursor(); |
|
|
|
|
|
|
|
|
|
|
|
protected abstract Rectangle getDraggedBounds(int dx, int dy, Rectangle currentBounds, FormDesigner designer, |
|
|
|
protected abstract Rectangle getDraggedBounds(int dx, int dy, Rectangle currentBounds, FormDesigner designer, |
|
|
|
Rectangle oldBounds); |
|
|
|
Rectangle oldBounds); |
|
|
@ -56,14 +57,14 @@ public abstract class AccessDirection implements Direction { |
|
|
|
x = designer.getRootComponent().getWidth(); |
|
|
|
x = designer.getRootComponent().getWidth(); |
|
|
|
} |
|
|
|
} |
|
|
|
//参数面板可以无下限拉长
|
|
|
|
//参数面板可以无下限拉长
|
|
|
|
if (y < 0) { |
|
|
|
if (y < 0) { |
|
|
|
y = 0; |
|
|
|
y = 0; |
|
|
|
} else if (y > designer.getRootComponent().getHeight() + designer.getParaHeight() && designer.getSelectionModel().hasSelectionComponent() |
|
|
|
} else if (y > designer.getRootComponent().getHeight() + designer.getParaHeight() && designer.getSelectionModel().hasSelectionComponent() |
|
|
|
&& !designer.getSelectionModel().getSelection().getSelectedCreator().acceptType(XWParameterLayout.class)) { |
|
|
|
&& !designer.getSelectionModel().getSelection().getSelectedCreator().acceptType(XWParameterLayout.class)) { |
|
|
|
y = designer.getRootComponent().getHeight() + designer.getParaHeight(); |
|
|
|
y = designer.getRootComponent().getHeight() + designer.getParaHeight(); |
|
|
|
} |
|
|
|
} |
|
|
|
return new Point(x, y); |
|
|
|
return new Point(x, y); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected void sorptionPoint(Point point, Rectangle currentBounds, FormDesigner designer) { |
|
|
|
protected void sorptionPoint(Point point, Rectangle currentBounds, FormDesigner designer) { |
|
|
|
boolean findInX = currentBounds.getWidth() <= MoveUtils.SORPTION_UNIT; |
|
|
|
boolean findInX = currentBounds.getWidth() <= MoveUtils.SORPTION_UNIT; |
|
|
@ -100,10 +101,10 @@ public abstract class AccessDirection implements Direction { |
|
|
|
findInY = true; |
|
|
|
findInY = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if (findInX && findInY) { |
|
|
|
if (findInX && findInY) { |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
setDesignerStateModelProperties(designer, findInX, findInY, currentBounds, point); |
|
|
|
setDesignerStateModelProperties(designer, findInX, findInY, currentBounds, point); |
|
|
@ -129,11 +130,10 @@ public abstract class AccessDirection implements Direction { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private WAbsoluteLayout getLayout(final FormDesigner designer){ |
|
|
|
private WAbsoluteLayout getLayout(final FormDesigner designer) { |
|
|
|
XLayoutContainer formLayoutContainer = (XLayoutContainer) XCreatorUtils.createXCreator( |
|
|
|
|
|
|
|
designer.getTarget().getContainer()); |
|
|
|
|
|
|
|
WAbsoluteLayout layout; |
|
|
|
WAbsoluteLayout layout; |
|
|
|
if (formLayoutContainer.acceptType(XWBorderLayout.class)) {//看起来这边的作用应该是为了区别cpt(得到XWParameterLayout)还是frm(得到XWBorderLayout)的参数界面
|
|
|
|
//看起来这边的作用应该是为了区别cpt(得到XWParameterLayout)还是frm(得到XWBorderLayout)的参数界面
|
|
|
|
|
|
|
|
if (designer.getTarget().getContainer().acceptType(WBorderLayout.class)) { |
|
|
|
Container container = designer.getSelectionModel().getSelection().getSelectedCreator().getParent(); |
|
|
|
Container container = designer.getSelectionModel().getSelection().getSelectedCreator().getParent(); |
|
|
|
if (container instanceof XWAbsoluteLayout) { |
|
|
|
if (container instanceof XWAbsoluteLayout) { |
|
|
|
layout = ((XWAbsoluteLayout) container).toData(); |
|
|
|
layout = ((XWAbsoluteLayout) container).toData(); |
|
|
@ -161,49 +161,49 @@ public abstract class AccessDirection implements Direction { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
//设定控件最小高度21,因每次拖曳至少移动1,防止控件高度等于21时,拖曳导致rec.y的变化使得控件不停的向上或向下移动。
|
|
|
|
//设定控件最小高度21,因每次拖曳至少移动1,防止控件高度等于21时,拖曳导致rec.y的变化使得控件不停的向上或向下移动。
|
|
|
|
if(rec.height == MINHEIGHT){ |
|
|
|
if (rec.height == MINHEIGHT) { |
|
|
|
ymin = rec.y; |
|
|
|
ymin = rec.y; |
|
|
|
} |
|
|
|
} |
|
|
|
if(rec.height == MINHEIGHT - 1){ |
|
|
|
if (rec.height == MINHEIGHT - 1) { |
|
|
|
ymin = ymin == rec.y ? rec.y : rec.y - 1; |
|
|
|
ymin = ymin == rec.y ? rec.y : rec.y - 1; |
|
|
|
} |
|
|
|
} |
|
|
|
if(rec.height < MINHEIGHT){ |
|
|
|
if (rec.height < MINHEIGHT) { |
|
|
|
rec.height = MINHEIGHT; |
|
|
|
rec.height = MINHEIGHT; |
|
|
|
rec.y = ymin; |
|
|
|
rec.y = ymin; |
|
|
|
} |
|
|
|
} |
|
|
|
// 增加下宽度也设最小为21
|
|
|
|
// 增加下宽度也设最小为21
|
|
|
|
if (rec.width == MINWIDTH) { |
|
|
|
if (rec.width == MINWIDTH) { |
|
|
|
xmin = rec.x; |
|
|
|
xmin = rec.x; |
|
|
|
} |
|
|
|
} |
|
|
|
if(rec.width == MINWIDTH - 1){ |
|
|
|
if (rec.width == MINWIDTH - 1) { |
|
|
|
xmin = xmin == rec.x ? rec.x : rec.x - 1; |
|
|
|
xmin = xmin == rec.x ? rec.x : rec.x - 1; |
|
|
|
} |
|
|
|
} |
|
|
|
if (rec.width < MINWIDTH) { |
|
|
|
if (rec.width < MINWIDTH) { |
|
|
|
rec.width = MINWIDTH; |
|
|
|
rec.width = MINWIDTH; |
|
|
|
rec.x = xmin; |
|
|
|
rec.x = xmin; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 更新鼠标指针形状 |
|
|
|
* 更新鼠标指针形状 |
|
|
|
* @param formEditor 设计界面组件 |
|
|
|
* @param formEditor 设计界面组件 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void updateCursor(FormDesigner formEditor) { |
|
|
|
public void updateCursor(FormDesigner formEditor) { |
|
|
|
|
|
|
|
|
|
|
|
// 调用位置枚举的多态方法getCursor获取鼠标形状
|
|
|
|
// 调用位置枚举的多态方法getCursor获取鼠标形状
|
|
|
|
int type = getCursor(); |
|
|
|
int type = getCursor(); |
|
|
|
|
|
|
|
|
|
|
|
if (type != formEditor.getCursor().getType()) { |
|
|
|
if (type != formEditor.getCursor().getType()) { |
|
|
|
// 设置当前形状
|
|
|
|
// 设置当前形状
|
|
|
|
formEditor.setCursor(Cursor.getPredefinedCursor(type)); |
|
|
|
formEditor.setCursor(Cursor.getPredefinedCursor(type)); |
|
|
|
|
|
|
|
|
|
|
|
// 显示/改变Tooltip
|
|
|
|
// 显示/改变Tooltip
|
|
|
|
showTooltip(formEditor); |
|
|
|
showTooltip(formEditor); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void showTooltip(FormDesigner formEditor) { |
|
|
|
private void showTooltip(FormDesigner formEditor) { |
|
|
|
// 显示拖拽改变组件尺寸相关的提示信息
|
|
|
|
// 显示拖拽改变组件尺寸相关的提示信息
|
|
|
|
int cursorType = formEditor.getCursor().getType(); |
|
|
|
int cursorType = formEditor.getCursor().getType(); |
|
|
|
if (Cursor.SW_RESIZE_CURSOR <= cursorType && cursorType <= Cursor.E_RESIZE_CURSOR) { |
|
|
|
if (Cursor.SW_RESIZE_CURSOR <= cursorType && cursorType <= Cursor.E_RESIZE_CURSOR) { |
|
|
@ -217,15 +217,15 @@ public abstract class AccessDirection implements Direction { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String getTooltip() { |
|
|
|
public String getTooltip() { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 生成组件备用的bound |
|
|
|
|
|
|
|
* @param formEditor 设计界面组件 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public void backupBounds(FormDesigner formEditor) { |
|
|
|
|
|
|
|
formEditor.getSelectionModel().getSelection().backupBounds(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 生成组件备用的bound |
|
|
|
|
|
|
|
* @param formEditor 设计界面组件 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public void backupBounds(FormDesigner formEditor) { |
|
|
|
|
|
|
|
formEditor.getSelectionModel().getSelection().backupBounds(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |