|
|
@ -33,18 +33,39 @@ public class FormSelectionUtils { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* @param designer 编辑器 |
|
|
|
* @param designer 编辑器 |
|
|
|
* @param parent 粘贴依据的组件 |
|
|
|
* @param parent 粘贴依据的组件 |
|
|
|
* @param clipBoard 剪贴板内容 |
|
|
|
* @param clipboard 剪贴板内容 |
|
|
|
* @param x x |
|
|
|
* @param x x |
|
|
|
* @param y y |
|
|
|
* @param y y |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static void paste2Container(FormDesigner designer, XLayoutContainer parent, |
|
|
|
public static void paste2Container(FormDesigner designer, XLayoutContainer parent, |
|
|
|
FormSelection clipBoard, int x, int y) { |
|
|
|
FormSelection clipboard, int x, int y) { |
|
|
|
LayoutAdapter adapter = parent.getLayoutAdapter(); |
|
|
|
LayoutAdapter adapter = parent.getLayoutAdapter(); |
|
|
|
if (parent instanceof XWAbsoluteLayout) { |
|
|
|
if (parent instanceof XWAbsoluteLayout) { |
|
|
|
//绝对布局
|
|
|
|
//绝对布局
|
|
|
|
|
|
|
|
absolutePaste(designer, clipboard, adapter, x, y); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} else if (parent instanceof XWFitLayout) { |
|
|
|
|
|
|
|
//相对布局
|
|
|
|
|
|
|
|
relativePaste(designer, clipboard, adapter, x, y); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Toolkit.getDefaultToolkit().beep(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 绝对布局粘贴 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param designer |
|
|
|
|
|
|
|
* @param clipboard |
|
|
|
|
|
|
|
* @param adapter |
|
|
|
|
|
|
|
* @param x |
|
|
|
|
|
|
|
* @param y |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private static void absolutePaste(FormDesigner designer, FormSelection clipboard, LayoutAdapter adapter, int x, int y) { |
|
|
|
|
|
|
|
|
|
|
|
designer.getSelectionModel().getSelection().reset(); |
|
|
|
designer.getSelectionModel().getSelection().reset(); |
|
|
|
Rectangle rec = clipBoard.getSelctionBounds(); |
|
|
|
Rectangle rec = clipboard.getSelctionBounds(); |
|
|
|
for (XCreator creator : clipBoard.getSelectedCreators()) { |
|
|
|
for (XCreator creator : clipboard.getSelectedCreators()) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
Widget copied = copyWidget(designer, creator); |
|
|
|
Widget copied = copyWidget(designer, creator); |
|
|
|
XCreator copiedCreator = XCreatorUtils.createXCreator(copied, creator.getSize()); |
|
|
|
XCreator copiedCreator = XCreatorUtils.createXCreator(copied, creator.getSize()); |
|
|
@ -54,11 +75,9 @@ public class FormSelectionUtils { |
|
|
|
x + creator.getX() - rec.x + copiedCreator.getWidth() / 2, |
|
|
|
x + creator.getX() - rec.x + copiedCreator.getWidth() / 2, |
|
|
|
y + creator.getY() - rec.y + copiedCreator.getHeight() / 2); |
|
|
|
y + creator.getY() - rec.y + copiedCreator.getHeight() / 2); |
|
|
|
boolean addSuccess = adapter.addBean(copiedCreator, point.x, point.y); |
|
|
|
boolean addSuccess = adapter.addBean(copiedCreator, point.x, point.y); |
|
|
|
|
|
|
|
|
|
|
|
if (addSuccess) { |
|
|
|
if (addSuccess) { |
|
|
|
designer.getSelectionModel().getSelection().addSelectedCreator(copiedCreator); |
|
|
|
designer.getSelectionModel().getSelection().addSelectedCreator(copiedCreator); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} catch (CloneNotSupportedException e) { |
|
|
|
} catch (CloneNotSupportedException e) { |
|
|
|
FRContext.getLogger().error(e.getMessage(), e); |
|
|
|
FRContext.getLogger().error(e.getMessage(), e); |
|
|
|
} |
|
|
|
} |
|
|
@ -66,20 +85,28 @@ public class FormSelectionUtils { |
|
|
|
rebuildSelection(designer); |
|
|
|
rebuildSelection(designer); |
|
|
|
designer.getEditListenerTable().fireCreatorModified( |
|
|
|
designer.getEditListenerTable().fireCreatorModified( |
|
|
|
designer.getSelectionModel().getSelection().getSelectedCreator(), DesignerEvent.CREATOR_PASTED); |
|
|
|
designer.getSelectionModel().getSelection().getSelectedCreator(), DesignerEvent.CREATOR_PASTED); |
|
|
|
return; |
|
|
|
|
|
|
|
} else if (parent instanceof XWFitLayout) { |
|
|
|
} |
|
|
|
//相对布局
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 相对布局粘贴 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param designer |
|
|
|
|
|
|
|
* @param clipboard |
|
|
|
|
|
|
|
* @param adapter |
|
|
|
|
|
|
|
* @param x |
|
|
|
|
|
|
|
* @param y |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private static void relativePaste(FormDesigner designer, FormSelection clipboard, LayoutAdapter adapter, int x, int y) { |
|
|
|
designer.getSelectionModel().getSelection().reset(); |
|
|
|
designer.getSelectionModel().getSelection().reset(); |
|
|
|
for (XCreator creator : clipBoard.getSelectedCreators()) { |
|
|
|
for (XCreator creator : clipboard.getSelectedCreators()) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
Widget copied = copyWidget(designer, creator); |
|
|
|
Widget copied = copyWidget(designer, creator); |
|
|
|
XCreator copiedCreator = XCreatorUtils.createXCreator(copied, creator.getSize()); |
|
|
|
XCreator copiedCreator = XCreatorUtils.createXCreator(copied, creator.getSize()); |
|
|
|
boolean addSuccess = adapter.addBean(copiedCreator, x, y); |
|
|
|
boolean addSuccess = adapter.addBean(copiedCreator, x, y); |
|
|
|
|
|
|
|
|
|
|
|
if (addSuccess) { |
|
|
|
if (addSuccess) { |
|
|
|
designer.getSelectionModel().getSelection().addSelectedCreator(copiedCreator); |
|
|
|
designer.getSelectionModel().getSelection().addSelectedCreator(copiedCreator); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} catch (CloneNotSupportedException e) { |
|
|
|
} catch (CloneNotSupportedException e) { |
|
|
|
FRContext.getLogger().error(e.getMessage(), e); |
|
|
|
FRContext.getLogger().error(e.getMessage(), e); |
|
|
|
} |
|
|
|
} |
|
|
@ -87,9 +114,6 @@ public class FormSelectionUtils { |
|
|
|
rebuildSelection(designer); |
|
|
|
rebuildSelection(designer); |
|
|
|
designer.getEditListenerTable().fireCreatorModified( |
|
|
|
designer.getEditListenerTable().fireCreatorModified( |
|
|
|
designer.getSelectionModel().getSelection().getSelectedCreator(), DesignerEvent.CREATOR_PASTED); |
|
|
|
designer.getSelectionModel().getSelection().getSelectedCreator(), DesignerEvent.CREATOR_PASTED); |
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Toolkit.getDefaultToolkit().beep(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|