Browse Source

frm本地组件复用 绝对布局,遗留:重命名问题

master
yaoh.wu 8 years ago
parent
commit
5a9c222dc2
  1. 52
      designer_base/src/com/fr/design/beans/location/MoveUtils.java
  2. 56
      designer_base/src/com/fr/design/beans/location/WidgetForbidWindow.java
  3. 2
      designer_base/src/com/fr/design/mainframe/BaseJForm.java
  4. 18
      designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDockPlus.java
  5. 2
      designer_base/src/com/fr/design/parameter/ParameterDesignerProvider.java
  6. 19
      designer_form/src/com/fr/design/designer/beans/adapters/layout/AbstractLayoutAdapter.java
  7. 45
      designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java
  8. 34
      designer_form/src/com/fr/design/designer/beans/location/AccessDirection.java
  9. 50
      designer_form/src/com/fr/design/designer/beans/models/SelectionModel.java
  10. 12
      designer_form/src/com/fr/design/form/parameter/FormParaDesigner.java
  11. 2
      designer_form/src/com/fr/design/mainframe/EditingMouseListener.java
  12. 56
      designer_form/src/com/fr/design/mainframe/FormDesigner.java
  13. 151
      designer_form/src/com/fr/design/mainframe/FormSelectionUtils.java
  14. 56
      designer_form/src/com/fr/design/mainframe/JForm.java
  15. 3
      designer_form/src/com/fr/design/mainframe/MobileWidgetTable.java
  16. 7
      designer_form/src/com/fr/design/mainframe/WidgetPropertyPane.java

52
designer_base/src/com/fr/design/beans/location/MoveUtils.java

@ -279,13 +279,13 @@ public class MoveUtils {
}
}
public static void displayForbidWindow(int x, int y) {
widgetForbidWindow.showWindow(x, y);
}
// public static void displayForbidWindow(int x, int y) {
// widgetForbidWindow.showWindow(x, y);
// }
public static void hideForbidWindow() {
widgetForbidWindow.hideWindow();
}
// public static void hideForbidWindow() {
// widgetForbidWindow.hideWindow();
// }
/**
* 吸附
@ -319,24 +319,24 @@ public class MoveUtils {
java.util.List<Rectangle> cacheRecs = new ArrayList<Rectangle>();
//是否存在控件重叠
boolean isWidgetsIntersects = false;
// boolean isWidgetsIntersects = false;
while (iterator.hasNext()) {
Rectangle bounds = iterator.nextRectangle();
cacheRecs.add(bounds);
boolean isIntersects = operatingRectangle.intersects(bounds);
// boolean isIntersects = operatingRectangle.intersects(bounds);
findX(px, bounds, left, right, width);
findY(py, bounds, top, bottom, height);
if(!isParameterLayout){
if(isIntersects) {
isWidgetsIntersects = true;
}
else{
// if(isIntersects) {
// isWidgetsIntersects = true;
// }
// else{
findEquidistantLine(bounds, left, top, height, width);
// }
}
}
}
showForbiddenWindow(designer, x, y, isWidgetsIntersects);
//showForbiddenWindow(designer, x, y, isWidgetsIntersects);
createXAbsorptionline(px, designer, width, cacheRecs);
createYAbsorptionline(py, designer, height, cacheRecs);
@ -353,18 +353,18 @@ public class MoveUtils {
return sorptionPoint;
}
public static void showForbiddenWindow(RectangleDesigner designer, int x, int y, boolean isIntersects){
if (isIntersects){
if(designer.getDesignerLocationOnScreen() != null) {
displayForbidWindow(x + designer.getDesignerLocationOnScreen().x, y + designer.getDesignerLocationOnScreen().y);
}
designer.setWidgetsIntersected(true);
}
else{
designer.setWidgetsIntersected(false);
hideForbidWindow();
}
}
// public static void showForbiddenWindow(RectangleDesigner designer, int x, int y, boolean isIntersects){
// if (isIntersects){
// if(designer.getDesignerLocationOnScreen() != null) {
// displayForbidWindow(x + designer.getDesignerLocationOnScreen().x, y + designer.getDesignerLocationOnScreen().y);
// }
// designer.setWidgetsIntersected(true);
// }
// else{
// designer.setWidgetsIntersected(false);
// hideForbidWindow();
// }
// }
private static void createXAbsorptionline(PlacePointing px, RectangleDesigner designer, int width, java.util.List<Rectangle> cacheRecs) {
Absorptionline line = null;

56
designer_base/src/com/fr/design/beans/location/WidgetForbidWindow.java

@ -17,32 +17,32 @@ public class WidgetForbidWindow extends JWindow {
private UIButton promptButton = new UIButton(Inter.getLocText("FR-Designer_Forbid_Widgets_Intersects"), BaseUtils.readIcon(IconPathConstants.FORBID_ICON_PATH));
/**
* 构造函数
*/
public WidgetForbidWindow() {
this.add(promptButton);
this.setSize(WIDTH, HEIGHT);
}
/**
* 在指定位置显示窗口, 默认将window的中心点放到指定位置上
*
* @param x x坐标
* @param y y坐标
*
*/
public void showWindow(int x, int y){
this.setLocation(x - WIDTH / 2, y - HEIGHT / 2);
this.setVisible(true);
}
/**
* 隐藏当前窗口
*
*/
public void hideWindow(){
this.setVisible(false);
}
// /**
// * 构造函数
// */
// public WidgetForbidWindow() {
// this.add(promptButton);
//
// this.setSize(WIDTH, HEIGHT);
// }
//
// /**
// * 在指定位置显示窗口, 默认将window的中心点放到指定位置上
// *
// * @param x x坐标
// * @param y y坐标
// *
// */
// public void showWindow(int x, int y){
// this.setLocation(x - WIDTH / 2, y - HEIGHT / 2);
// this.setVisible(true);
// }
//
// /**
// * 隐藏当前窗口
// *
// */
// public void hideWindow(){
// this.setVisible(false);
// }
}

2
designer_base/src/com/fr/design/mainframe/BaseJForm.java

@ -1 +1 @@
package com.fr.design.mainframe; import javax.swing.JComponent; import com.fr.form.FormElementCaseContainerProvider; /** * Author : Shockway * Date: 13-7-15 * Time: 上午10:28 */ public interface BaseJForm extends JTemplateProvider{ public static final String XML_TAG = "JForm"; public static final int FORM_TAB = 0; public static final int ELEMENTCASE_TAB = 1; public static final int ELEMENTCASE_CHANGE_TAB = 2; /** * 刷新所有控件 */ { { { { { public static final String XML_TAG = "JForm"; { public static final int FORM_TAB = 0; public void populateParameter(); /** { public static final int ELEMENTCASE_CHANGE_TAB = 2; */ { /** /** { * 刷新所有控件 */ { */ /** { */ public static final String XML_TAG = "JForm"; /** public static final int FORM_TAB = 0; */ public static final int ELEMENTCASE_TAB = 1; { * 只在Form和ElementCase之间切换 /** { public static final int FORM_TAB = 0; * 刷新所有控件 /** */ public static final String XML_TAG = "JForm"; public static final String XML_TAG = "JForm"; { { public static final int FORM_TAB = 0; public void tabChanged(int index, FormElementCaseContainerProvider ecContainer); }
package com.fr.design.mainframe; import javax.swing.JComponent; import com.fr.form.FormElementCaseContainerProvider; /** * Author : Shockway * Date: 13-7-15 * Time: 上午10:28 */ public interface BaseJForm extends JTemplateProvider { public static final String XML_TAG = "JForm"; public static final int FORM_TAB = 0; public static final String XML_TAG = "JForm"; public static final int ELEMENTCASE_TAB = 1; public static final String XML_TAG = "JForm"; public static final int ELEMENTCASE_CHANGE_TAB = 2; public static final String XML_TAG = "JForm"; /** public static final String XML_TAG = "JForm"; * 刷新所有控件 public static final String XML_TAG = "JForm"; */ public static final int FORM_TAB = 0; public static final int FORM_TAB = 0; { public static final int FORM_TAB = 0; /** public static final int FORM_TAB = 0; public static final String XML_TAG = "JForm"; public static final int FORM_TAB = 0; { public static final int FORM_TAB = 0; public static final int FORM_TAB = 0; /** * 刷新选中的控件 public static final int FORM_TAB = 0; { public static final int FORM_TAB = 0; public static final int ELEMENTCASE_CHANGE_TAB = 2; public static final String XML_TAG = "JForm"; */ public static final int FORM_TAB = 0; /** public static final int FORM_TAB = 0; { public static final int FORM_TAB = 0; * 刷新所有控件 public static final String XML_TAG = "JForm"; */ * 执行撤销 public static final int ELEMENTCASE_TAB = 1; * @param o 之前保存的状态 public static final int FORM_TAB = 0; { public static final int ELEMENTCASE_TAB = 1; public static final String XML_TAG = "JForm"; */ public static final int ELEMENTCASE_TAB = 1; public static final String XML_TAG = "JForm"; */ JComponent getEditingPane(); public static final String XML_TAG = "JForm"; public static final int FORM_TAB = 0; public static final String XML_TAG = "JForm"; */ public static final int ELEMENTCASE_TAB = 1; public static final int ELEMENTCASE_TAB = 1; * * @param index 切换位置 public static final int FORM_TAB = 0; { public static final int ELEMENTCASE_TAB = 1; /** public static final String XML_TAG = "JForm"; public static final int FORM_TAB = 0; /** public static final int ELEMENTCASE_TAB = 1; * 刷新所有控件 * public static final int ELEMENTCASE_TAB = 1; */ public static final int ELEMENTCASE_CHANGE_TAB = 2; public static final int FORM_TAB = 0; { public static final int ELEMENTCASE_CHANGE_TAB = 2; { void tabChanged(int index, FormElementCaseContainerProvider ecContainer); }

18
designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDockPlus.java

@ -12,52 +12,52 @@ public interface ToolBarMenuDockPlus {
*
* @return 工具
*/
public ToolBarDef[] toolbars4Target();
ToolBarDef[] toolbars4Target();
/**
* 文件菜单的子菜单
*
* @return 子菜单
*/
public ShortCut[] shortcut4FileMenu();
ShortCut[] shortcut4FileMenu();
/**
* 目标的菜单
*
* @return 菜单
*/
public MenuDef[] menus4Target();
MenuDef[] menus4Target();
/**
* 表单的工具栏
*
* @return 表单工具栏
*/
public JPanel[] toolbarPanes4Form();
JPanel[] toolbarPanes4Form();
/**
* 表单的工具按钮
*
* @return 工具按钮
*/
public JComponent[] toolBarButton4Form();
JComponent[] toolBarButton4Form();
/**
* 权限细粒度状态下的工具面板
*
* @return 工具面板
*/
public JComponent toolBar4Authority();
JComponent toolBar4Authority();
public int getMenuState();
int getMenuState();
public int getToolBarHeight();
int getToolBarHeight();
/**
* 导出菜单的子菜单 目前用于图表设计器
*
* @return 子菜单
*/
public ShortCut[] shortcut4ExportMenu();
ShortCut[] shortcut4ExportMenu();
}

2
designer_base/src/com/fr/design/parameter/ParameterDesignerProvider.java

@ -1 +1 @@
package com.fr.design.parameter; import com.fr.base.Parameter; import com.fr.base.parameter.ParameterUI; import com.fr.design.mainframe.AuthorityEditPane; import javax.swing.*; import java.awt.*; /** * 参数设计界面接口 */ public interface ParameterDesignerProvider { public void addListener(ParaDefinitePane paraDefinitePane); public Component createWrapper(); public void setDesignHeight(int height); public Dimension getDesignSize(); public Dimension getPreferredSize(); public void populate(ParameterUI p); public void refreshAllNameWidgets(); public void refresh4TableData(String oldName, String newName); d">public void addListener(ParaDefinitePane paraDefinitePane); d">public void addListener(ParaDefinitePane paraDefinitePane); d">public void addListener(ParaDefinitePane paraDefinitePane); d">public void addListener(ParaDefinitePane paraDefinitePane); d">public void addListener(ParaDefinitePane paraDefinitePane); public Component createWrapper(); d">public void addListener(ParaDefinitePane paraDefinitePane); public void setDesignHeight(int height); d">public void addListener(ParaDefinitePane paraDefinitePane); public Dimension getDesignSize(); d">public void addListener(ParaDefinitePane paraDefinitePane); public Dimension getPreferredSize(); d">public void addListener(ParaDefinitePane paraDefinitePane); public void populate(ParameterUI p); d">public void addListener(ParaDefinitePane paraDefinitePane); public void refreshAllNameWidgets(); d">public void addListener(ParaDefinitePane paraDefinitePane); public void refresh4TableData(String oldName, String newName); d">public void addListener(ParaDefinitePane paraDefinitePane); public Component createWrapper(); public void setDesignHeight(int height); public Dimension getDesignSize(); public Dimension getPreferredSize(); public void populate(ParameterUI p); public void refreshAllNameWidgets(); public ParameterBridge getParaComponent(); }
package com.fr.design.parameter; import com.fr.base.Parameter; import com.fr.base.parameter.ParameterUI; import com.fr.design.mainframe.AuthorityEditPane; import javax.swing.*; import java.awt.*; /** * 参数设计界面接口 */ public interface ParameterDesignerProvider { void addListener(ParaDefinitePane paraDefinitePane); public Component createWrapper(); d">public void addListener(ParaDefinitePane paraDefinitePane); public Component createWrapper(); public Component createWrapper(); public Component createWrapper(); public Component createWrapper(); public void setDesignHeight(int height); public Component createWrapper(); public Dimension getDesignSize(); public Component createWrapper(); public Dimension getPreferredSize(); public Component createWrapper(); public void populate(ParameterUI p); public Component createWrapper(); public void refreshAllNameWidgets(); public Component createWrapper(); public void refresh4TableData(String oldName, String newName); public void setDesignHeight(int height); public void setDesignHeight(int height); d">public void addListener(ParaDefinitePane paraDefinitePane); public Component createWrapper(); d">public void addListener(ParaDefinitePane paraDefinitePane); public void setDesignHeight(int height); public Component createWrapper(); d">public void addListener(ParaDefinitePane paraDefinitePane); boolean isBlank(); public Component createWrapper(); d">public void addListener(ParaDefinitePane paraDefinitePane); ParameterUI getParaTarget(); public Component createWrapper(); d">public void addListener(ParaDefinitePane paraDefinitePane); boolean addingParameter2Editor(Parameter parameter, int index); public Component createWrapper(); d">public void addListener(ParaDefinitePane paraDefinitePane); boolean addingParameter2EditorWithQueryButton(Parameter parameter, int index); public Component createWrapper(); d">public void addListener(ParaDefinitePane paraDefinitePane); void addingAllParameter2Editor(Parameter[] parameterArray, int currentIndex); public Component createWrapper(); d">public void addListener(ParaDefinitePane paraDefinitePane); JPanel[] toolbarPanes4Form(); public Component createWrapper(); d">public void addListener(ParaDefinitePane paraDefinitePane); JComponent[] toolBarButton4Form(); public Component createWrapper(); d">public void addListener(ParaDefinitePane paraDefinitePane); public Dimension getDesignSize(); public Dimension getDesignSize(); d">public void addListener(ParaDefinitePane paraDefinitePane); public Dimension getDesignSize(); public Dimension getDesignSize(); public Component createWrapper(); public Dimension getDesignSize(); public void setDesignHeight(int height); public Dimension getDesignSize(); public Dimension getDesignSize(); public Dimension getDesignSize(); public Dimension getPreferredSize(); public Dimension getDesignSize(); public void populate(ParameterUI p); public Dimension getDesignSize(); public void refreshAllNameWidgets(); ParameterBridge getParaComponent(); }

19
designer_form/src/com/fr/design/designer/beans/adapters/layout/AbstractLayoutAdapter.java

@ -26,6 +26,7 @@ public abstract class AbstractLayoutAdapter implements LayoutAdapter {
/**
* 是否使用控件备份大小
*
* @param xCreator 控件
* @return 所在容器相同且支持备份的话返回true
*/
@ -41,6 +42,7 @@ public abstract class AbstractLayoutAdapter implements LayoutAdapter {
/**
* 是否支持用备份大小
*
* @return
*/
public boolean supportBackupSize() {
@ -49,6 +51,7 @@ public abstract class AbstractLayoutAdapter implements LayoutAdapter {
/**
* 有的控件在拖拽调整大小后需要根据自身内容重新计算下当前的尺寸是否合适如果不合适就需要重新fix一下
*
* @param creator 组件
*/
public void fix(XCreator creator) {
@ -56,6 +59,7 @@ public abstract class AbstractLayoutAdapter implements LayoutAdapter {
/**
* 显示parent的字组件child解决CardLayout中显示某个非显示组件的特殊情况
*
* @param child 组件
*/
@Override
@ -66,6 +70,7 @@ public abstract class AbstractLayoutAdapter implements LayoutAdapter {
/**
* 组件的ComponentAdapter在添加组件时如果发现布局管理器不为空会继而调用该布局管理器的
* addComp方法来完成组件的具体添加在该方法内布局管理器可以提供额外的功能
*
* @param creator 被添加的新组件
* @param x 添加的位置x该位置是相对于container的
* @param y 添加的位置y该位置是相对于container的
@ -83,9 +88,10 @@ public abstract class AbstractLayoutAdapter implements LayoutAdapter {
/**
* 删除组件
*
* @param creator 组件
* @param initWidth 组件之前宽度
* @param initHeight 组件之前高度
* @param creatorWidth
* @param creatorHeight
*/
public void removeBean(XCreator creator, int creatorWidth, int creatorHeight) {
delete(creator, creatorWidth, creatorHeight);
@ -98,6 +104,7 @@ public abstract class AbstractLayoutAdapter implements LayoutAdapter {
/**
* 增加下一个组件
*
* @param dragged 组件
*/
@Override
@ -108,6 +115,7 @@ public abstract class AbstractLayoutAdapter implements LayoutAdapter {
/**
* 目标控件位置插入组件
*
* @param target 目标
* @param added 增加组件
*/
@ -126,6 +134,7 @@ public abstract class AbstractLayoutAdapter implements LayoutAdapter {
/**
* 插在目标组件后面
*
* @param target 目标
* @param added 增加组件
*/
@ -155,6 +164,7 @@ public abstract class AbstractLayoutAdapter implements LayoutAdapter {
/**
* 是否能接收更多的组件
*
* @return 能则返回true
*/
@Override
@ -171,4 +181,9 @@ public abstract class AbstractLayoutAdapter implements LayoutAdapter {
public GroupModel getLayoutProperties() {
return null;
}
public XLayoutContainer getContainer() {
return this.container;
}
}

45
designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java

@ -42,6 +42,7 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
/**
* 是否能在指定位置添加组件
*
* @param creator 组件
* @param x 坐标x
* @param y 坐标y
@ -67,7 +68,7 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
creator.setBounds(rec);
return false;
}
//判断下组件能不能拖入绝对布局
//判断组件能不能拖入绝对布局
if (!creator.canEnterIntoAbsolutePane()) {
return false;
}
@ -79,44 +80,47 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
//绝对布局嵌套,处于内层,不可编辑,不添加,topLayout只能获取到最外层可编辑的布局
else if (((XLayoutContainer) topLayout.getParent()).acceptType(XWAbsoluteLayout.class)) {
return false;
}
else {
} else {
return acceptWidget(creator, x, y);
}
}
else{
} else {
FRLogger.getLogger().error("top layout is null!");
}
return false;
}
//toplayout假如可以编辑的话就往里面添加组件
//topLayout假如可以编辑的话就往里面添加组件
private boolean topLayoutAccept(XCreator creator, int x, int y, XLayoutContainer topLayout) {
//判断有没有和当前控件重叠
//允许组件重叠,可以不判断有没有和当前控件重叠
//先计算当前控件的位置
int creatorX, creatorY;
if (XCreatorUtils.getParentXLayoutContainer(creator) != null) {
Rectangle creatorRectangle = ComponentUtils.getRelativeBounds(creator);
creatorX = creatorRectangle.x;
creatorY = creatorRectangle.y;
} else {
//这边计算得到的组件其实位置是正确的,
//因为传入的x和y已经加上了宽度或者高度的一半,再减去相同的宽度和高度的一半是没区别的,
// 例如高度为21,那么就是+10-10;
// 高度为20,那么就是+10-10; 没区别
int w = creator.getWidth() / 2;
int h = creator.getHeight() / 2;
creatorX = x - w;
creatorY = y - h;
}
//再判断和布局中其他控件重叠
Rectangle curRec = new Rectangle(creatorX, creatorY, creator.getWidth(), creator.getHeight());
WAbsoluteLayout wAbsoluteLayout = (WAbsoluteLayout)topLayout.toData();
for (int i = 0, count = wAbsoluteLayout.getWidgetCount(); i < count; i++) {
BoundsWidget temp = (BoundsWidget) wAbsoluteLayout.getWidget(i);
Rectangle rectangle = temp.getBounds();
if (curRec.intersects(rectangle)){
return false;
}
}
//frm 组件复用允许组件重叠
//无须再判断和布局中其他控件重叠
//Rectangle curRec = new Rectangle(creatorX, creatorY, creator.getWidth(), creator.getHeight());
//WAbsoluteLayout wAbsoluteLayout = (WAbsoluteLayout) topLayout.toData();
//for (int i = 0, count = wAbsoluteLayout.getWidgetCount(); i < count; i++) {
//BoundsWidget temp = (BoundsWidget) wAbsoluteLayout.getWidget(i);
//Rectangle rectangle = temp.getBounds();
//if (curRec.intersects(rectangle)) {
//允许组件重叠
//return false;
//}
//}
if (creatorX < 0 || creatorX + creator.getWidth() > container.getWidth()) {
return false;
}
@ -129,6 +133,7 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
/**
* 判断是否鼠标在组件的三等分区域如果组件在布局管理器中间上下左右都可能会三等分
*
* @param parentComp 鼠标所在区域的组件
* @param x 坐标x
* @param y 坐标y
@ -279,6 +284,7 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
/**
* 新拖入组件时计算调整其他关联组件位置大小
*
* @param child 新拖入的组件
* @param x 鼠标所在x坐标
* @param y 鼠标所在y坐标
@ -291,6 +297,7 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
} else if (isCrossPointArea(parentComp, x, y)) {
//交叉区域插入组件时,根据具体位置进行上下或者左右或者相邻三个组件的位置大小插入
fixCrossPointArea(parentComp, child, x, y);
//TODO 尽量不要出现这种写法吧?if else条件要么互斥,要么多个if判断return,不要在一条if else语句里面return吧?
return;
} else if (isTrisectionArea(parentComp, x, y)) {
// 在边界三等分区域,就不再和组件二等分了
@ -303,6 +310,7 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
/**
* 组件拖拽后调整大小
*
* @param creator 组件
*/
@Override
@ -317,6 +325,7 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
/**
* 调整组件大小到合适尺寸位置
*
* @param creator 组件
* @param x 坐标x
* @param y 坐标y

34
designer_form/src/com/fr/design/designer/beans/location/AccessDirection.java

@ -69,7 +69,7 @@ public abstract class AccessDirection implements Direction {
boolean findInY = current_bounds.getHeight() <= MoveUtils.SORPTION_UNIT ? true : false;
WAbsoluteLayout layout =getLayout(designer);
FormSelection selection = designer.getSelectionModel().getSelection();
boolean isWidgetsIntersect = false;
// boolean isWidgetsIntersect = false;
for (int i = 0, count = layout.getWidgetCount(); i < count; i++) {
BoundsWidget temp = (BoundsWidget) layout.getWidget(i);
if (!temp.isVisible() || selection.contains(temp.getWidget())) {
@ -105,11 +105,11 @@ public abstract class AccessDirection implements Direction {
break;
}
if (current_bounds.intersects(bounds) && !(layout instanceof WParameterLayout)){
isWidgetsIntersect = true;
// if (current_bounds.intersects(bounds) && !(layout instanceof WParameterLayout)) {
// isWidgetsIntersect = true;
// }
}
}
processRectangleIntersects(designer, point.x, point.y, isWidgetsIntersect);
// processRectangleIntersects(designer, point.x, point.y, isWidgetsIntersect);
setDesignerStateModelProperties(designer, findInX, findInY, current_bounds, point);
}
@ -131,18 +131,18 @@ public abstract class AccessDirection implements Direction {
return relativeRec;
}
private void processRectangleIntersects(FormDesigner designer, int x, int y, boolean isIntersects){
if(isIntersects){
if(designer.getLocationOnScreen() != null) {
MoveUtils.displayForbidWindow(x + designer.getLocationOnScreen().x, y + designer.getLocationOnScreen().y);
}
designer.setWidgetsIntersect(true);
}
else{
MoveUtils.hideForbidWindow();
designer.setWidgetsIntersect(false);
}
}
// private void processRectangleIntersects(FormDesigner designer, int x, int y, boolean isIntersects){
// if(isIntersects){
// if(designer.getLocationOnScreen() != null) {
// MoveUtils.displayForbidWindow(x + designer.getLocationOnScreen().x, y + designer.getLocationOnScreen().y);
// }
// designer.setWidgetsIntersect(true);
// }
// else{
// MoveUtils.hideForbidWindow();
// designer.setWidgetsIntersect(false);
// }
// }
private WAbsoluteLayout getLayout(final FormDesigner designer){
XLayoutContainer formLayoutContainer = (XLayoutContainer) XCreatorUtils.createXCreator(

50
designer_form/src/com/fr/design/designer/beans/models/SelectionModel.java

@ -11,11 +11,7 @@ import com.fr.design.designer.beans.LayoutAdapter;
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.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.creator.XWParameterLayout;
import com.fr.design.designer.creator.*;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelection;
@ -27,6 +23,7 @@ import com.fr.stable.ArrayUtils;
* 该model保存当前选择的组件和剪切版信息
*/
public class SelectionModel {
//被粘贴组件在所选组件位置处往下、往右各错开20像素。执行多次粘贴时,在上一次粘贴的位置处错开20像素。
private static final int DELTA_X_Y = 20; //粘贴时候的偏移距离
private static FormSelection CLIP_BOARD = new FormSelection();
private FormDesigner designer;
@ -48,6 +45,7 @@ public class SelectionModel {
/**
* formSelction是否为空
*
* @return 是否为空
*/
public static boolean isEmpty() {
@ -56,6 +54,7 @@ public class SelectionModel {
/**
* 鼠标点击一下所选中的单个组件按下Ctrl或者shift键时鼠标可以进行多选
*
* @param e 鼠标事件
*/
public void selectACreatorAtMouseEvent(MouseEvent e) {
@ -106,14 +105,30 @@ public class SelectionModel {
/**
* 从剪切板粘帖组件
*
* @return
*/
public boolean pasteFromClipBoard() {
if (!CLIP_BOARD.isEmpty()) {
XLayoutContainer parent = null;
if (!hasSelectionComponent()) {
FormSelectionUtils.paste2Container(designer, designer.getRootComponent(),CLIP_BOARD, DELTA_X_Y, DELTA_X_Y);
if (designer.getClass().equals(FormDesigner.class)) {
//编辑器外面还有两层容器,使用designer.getRootComponent()获取到的是编辑器中层的容器,不是编辑器表层
//当前选择的就是编辑器表层
FormSelectionUtils.paste2Container(designer, (XLayoutContainer) selection.getSelectedCreator(),
CLIP_BOARD,
DELTA_X_Y,
DELTA_X_Y);
} else {
//cpt本地组件复用,编辑器就一层,是最底层,使用designer.getRootComponent()就可以获取到
//使用selection.getSelectedCreator()也应该是可以获取到的。
FormSelectionUtils.paste2Container(designer, designer.getRootComponent(),
CLIP_BOARD,
DELTA_X_Y,
DELTA_X_Y);
}
} else {
//获取到编辑器的表层容器(已选的组件的父容器就是表层容器)
parent = XCreatorUtils.getParentXLayoutContainer(selection.getSelectedCreator());
if (parent != null) {
Rectangle rec = selection.getSelctionBounds();
@ -203,14 +218,35 @@ public class SelectionModel {
/**
* 是否有组件被选择如果所选组件是最底层容器也视为无选择
*
* @return 是则返回true
* yaoh.wu 不应该通过判断是否是最底层容器来判断是否选择了组件
* 而是应该判断选择的容器是否是编辑器的最表层容器,也就是点击空白地方选择的容器
* 但是直接判断选择的容器是否是编辑器最表层类型又会引发拖动时选不上的情况
* 因此通过判断父容器来实现
* <p>
* 举例frm组件复用 绝对布局情况下不选择时有三层容器
* 底层@see {@link com.fr.design.designer.creator.XWBorderLayout}
* 中层@see {@link XWFitLayout}
* 表层@see {@link com.fr.design.designer.creator.XWAbsoluteBodyLayout}
* <p>
* 但是编辑窗口的最外层其实是表层@see {@link com.fr.design.designer.creator.XWAbsoluteBodyLayout},
* 其他两层不是靠添加组件就可以编辑的
*/
public boolean hasSelectionComponent() {
return !selection.isEmpty() && selection.getSelectedCreator().getParent() != null;
if (designer.getClass().equals(FormDesigner.class)) {
//frm组件复用选择
return selection.getSelectedCreator() != null && !(selection.getSelectedCreator().getParent() instanceof
XWFitLayout);
} else {
//cpt本地组件复用
return selection.getSelectedCreator() != null && selection.getSelectedCreator().getParent() != null;
}
}
/**
* 移动组件至指定位置
*
* @param x 坐标x
* @param y 坐标y
*/

12
designer_form/src/com/fr/design/form/parameter/FormParaDesigner.java

@ -125,6 +125,7 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP
/**
* 创建权限编辑面板
*
* @return 面板
*/
public AuthorityEditPane createAuthorityEditPane() {
@ -133,6 +134,7 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP
/**
* 内容属性表面板
*
* @return 内容属性表面板
*/
public JPanel getEastUpPane() {
@ -141,6 +143,7 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP
/**
* 参数属性表
*
* @return 参数属性表
*/
@ -150,6 +153,7 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP
/**
* 权限编辑面板
*
* @return 权限编辑面板
*/
public AuthorityEditPane getAuthorityEditPane() {
@ -314,6 +318,7 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP
/**
* 返回复制粘贴删除等动作
*
* @return 同上
*/
public Action[] getActions() {
@ -380,6 +385,7 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP
/**
* 报表直接判断底层是否是绝对布局
*
* @return 是则返回true
*/
public boolean hasWAbsoluteLayout() {
@ -401,6 +407,7 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP
/**
* 是否是报表的参数面板
*
* @return
*/
public boolean isFormParaDesigner() {
@ -554,6 +561,7 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP
/**
* 加入参数
*
* @param parameter 参数 c
* @param currentIndex 位置 w
* @return 是否加入 s
@ -580,6 +588,7 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP
/**
* 加入参数
*
* @param parameter 参数 c
* @param currentIndex 位置 w
* @return 是否加入 s
@ -614,6 +623,7 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP
/**
* 加入参数
*
* @param parameterArray 参数 c
* @param currentIndex 位置 w
* @return 是否加入 s
@ -672,6 +682,7 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP
/**
* 工具栏
*
* @return 工具栏面板 g
*/
public JPanel[] toolbarPanes4Form() {
@ -680,6 +691,7 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP
/**
* 复制等按钮
*
* @return 按钮组 a
*/
public JComponent[] toolBarButton4Form() {

2
designer_form/src/com/fr/design/mainframe/EditingMouseListener.java

@ -202,7 +202,7 @@ public class EditingMouseListener extends MouseInputAdapter {
XCreator selectionXCreator = designer.getSelectionModel().getSelection().getSelectedCreator();
if(selectionXCreator != null){
selectionXCreator.setBounds(dragBackupBounds.x, dragBackupBounds.y, dragBackupBounds.width, dragBackupBounds.height);
MoveUtils.hideForbidWindow();
// MoveUtils.hideForbidWindow();
}
}
dragBackupBounds = null;

56
designer_form/src/com/fr/design/mainframe/FormDesigner.java

@ -6,7 +6,10 @@ import com.fr.design.DesignState;
import com.fr.design.designer.TargetComponent;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.Painter;
import com.fr.design.designer.beans.actions.CopyAction;
import com.fr.design.designer.beans.actions.CutAction;
import com.fr.design.designer.beans.actions.FormDeleteAction;
import com.fr.design.designer.beans.actions.PasteAction;
import com.fr.design.designer.beans.adapters.layout.FRParameterLayoutAdapter;
import com.fr.design.designer.beans.events.CreatorEventListenerTable;
import com.fr.design.designer.beans.events.DesignerEditListener;
@ -214,6 +217,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 是否有查询按钮
*
* @return 有无查询按钮
*/
public boolean isWithQueryButton() {
@ -223,6 +227,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 加入参数到参数面板
*
* @param parameter 参数
* @return 是否加入
*/
@ -256,6 +261,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 加入参数到参数面板有查询按钮
*
* @param parameter 参数
* @return 是否加入
*/
@ -357,6 +363,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 自动添加组件
*
* @param xCreator 组件
* @param x 横坐标
* @param y 纵坐标
@ -375,6 +382,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 在参数很多时全部添加的时候可以向下一次排版若去掉就会在参数面板堆到一起
*
* @param creator 组件
* @param x 长度
* @param y 长度
@ -425,6 +433,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 返回根节点父容器
*
* @return 父容器
*/
public Component getTopContainer() {
@ -437,6 +446,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 返回参数界面高度
*
* @return para高度
*/
public int getParaHeight() {
@ -445,6 +455,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 重置para的高度
*
* @param height 高度
*/
public void setParaHeight(int height) {
@ -472,6 +483,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 切换
*
* @param elementCaseContainer 容器
*/
public void switchTab(FormElementCaseContainerProvider elementCaseContainer) {
@ -524,6 +536,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 增加监听事件
*
* @param listener 界面组件编辑事件
*/
public void addDesignerEditListener(DesignerEditListener listener) {
@ -539,13 +552,13 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 表单则判断参数面板是否为绝对布局
*
* @return 是则返回true
*/
public boolean hasWAbsoluteLayout() {
if (paraComponent != null && paraComponent.acceptType(XWParameterLayout.class)) {
return true;
}
else{
} else {
if (this.getSelectionModel().getSelection().getSelectedCreator().getParent() != null
&& ((XLayoutContainer) this.getSelectionModel().getSelection().getSelectedCreator().getParent()).acceptType(XWAbsoluteLayout.class)) {
return true;
@ -556,6 +569,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 设置是否为报表块编辑
*
* @param isEditing 是否为报表块编辑
*/
public void setReportBlockEditing(boolean isEditing) {
@ -564,6 +578,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 是否为报表块编辑
*
* @return 是否为报表块编辑
*/
public boolean isReportBlockEditing() {
@ -580,6 +595,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 是否重命名控件
*
* @param creator 组件
* @param newName 新的组件名
* @return 组件名有变化且不和其他一样返回true
@ -609,6 +625,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 更新界面布局重绘
*
* @param proxy 动态代理类
* @param method 接口方法
* @param args 参数
@ -654,6 +671,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 增加组件事件
*
* @param h 动态代理
*/
public void addInvocationHandler(InvocationHandler h) {
@ -741,6 +759,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 更新边框线状态
*
* @param e 鼠标事件
*/
public void updateDrawLineMode(MouseEvent e) {
@ -841,6 +860,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 是否是报表的参数面板
*
* @return (表单的)
*/
public boolean isFormParaDesigner() {
@ -849,6 +869,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 是否为底层容器
*
* @param comp 组件
* @return 是则返回true
*/
@ -941,6 +962,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 拖拽准备
*
* @param xCreator 组件
*/
public void startDraggingBean(XCreator xCreator) {
@ -954,6 +976,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 拖拽时相关处理
*
* @param xCreator 组件
* @param lastPressEvent 鼠标事件
* @param x 坐标x
@ -978,6 +1001,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 改变组件值
*
* @param e 组件选择事件
*/
@Override
@ -1024,6 +1048,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 是否支持权限编辑
*
* @return 是则返回true
*/
public boolean isSupportAuthority() {
@ -1049,6 +1074,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 是否含有action名
*
* @param name action名
* @return 有则返回true
*/
@ -1058,6 +1084,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 显示组件
*
* @param comp 组件
*/
public void makeVisible(XCreator comp) {
@ -1088,14 +1115,14 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 返回复制粘贴删除等动作
* 鼠标右键菜单
*
* @return 同上
*/
public Action[] getActions() {
if (designer_actions == null) {
//先把复制粘贴按钮去掉,只留下删除
// designer_actions = new Action[]{new CutAction(this), new CopyAction(this), new PasteAction(this),
// new FormDeleteAction(this)};
designer_actions = new Action[]{new FormDeleteAction(this)};
designer_actions = new Action[]{new CutAction(this), new CopyAction(this), new PasteAction(this),
new FormDeleteAction(this)};
}
return designer_actions;
}
@ -1120,6 +1147,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 返回表单区域
*
* @return 表单区域
*/
public FormArea getArea() {
@ -1128,6 +1156,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 设置上层区域
*
* @param formArea 表单区域
*/
public void setParent(FormArea formArea) {
@ -1136,6 +1165,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 绘制组件根节点
*
* @param clipg 图形
*/
public void paintContent(Graphics clipg) {
@ -1157,6 +1187,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 返回连线类
*
* @return ConnectorHelper类
*/
public ConnectorHelper getDrawLineHelper() {
@ -1165,6 +1196,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 是否画线模式
*
* @return 是则返回true
*/
public boolean isDrawLineMode() {
@ -1173,6 +1205,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 设置DrawLineMode
*
* @param mode 是or或
*/
public void setDrawLineMode(boolean mode) {
@ -1199,6 +1232,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 返回表单控件权限编辑pane
*
* @return 同上
*/
public AuthorityEditPane createAuthorityEditPane() {
@ -1249,6 +1283,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 粘贴
*
* @return
*/
@Override
@ -1259,6 +1294,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 剪切
*
* @return
*/
@Override
@ -1273,6 +1309,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 工具栏菜单
*
* @return 同上
*/
@Override
@ -1286,6 +1323,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 模版菜单
*
* @return 同上
*/
@Override
@ -1295,6 +1333,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 权限菜单
*
* @return 同上
*/
public ShortCut[] shortCuts4Authority() {
@ -1304,6 +1343,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 返回ToolBarDef
*
* @return 同上
*/
@Override
@ -1313,10 +1353,12 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 返回工具栏按钮组件
*
* @return 同上
*/
public JComponent[] toolBarButton4Form() {
return new JComponent[0];
return new JComponent[]{new CutAction(this).createToolBarComponent(), new CopyAction(this).createToolBarComponent(), new PasteAction(this).createToolBarComponent(),
new FormDeleteAction(this).createToolBarComponent()};
}

151
designer_form/src/com/fr/design/mainframe/FormSelectionUtils.java

@ -1,13 +1,13 @@
package com.fr.design.mainframe;
import java.awt.Component;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.fr.base.FRContext;
import com.fr.design.designer.beans.adapters.layout.AbstractLayoutAdapter;
import com.fr.form.ui.container.WLayout;
import com.fr.general.ComparatorUtils;
import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.events.DesignerEvent;
@ -15,53 +15,142 @@ import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWAbsoluteLayout;
import com.fr.form.main.ClonedWidgetCreator;
import com.fr.form.ui.Widget;
public class FormSelectionUtils {
public static void paste2Container(FormDesigner designer, XLayoutContainer parent, FormSelection selection, int x,
//组件复制时坐标偏移
private static final int DELAY_X = 20;
private static final int DELAY_Y = 20;
//组件复制时是否已经向左上偏移
private static boolean BACK_OFFSET = false;
//组件重命名后缀
private static final String postfix = "_c";
/**
* @param designer 编辑器
* @param parent 粘贴依据的组件
* @param clipBoard 剪贴板内容
* @param x x
* @param y y
*/
public static void paste2Container(FormDesigner designer, XLayoutContainer parent, FormSelection clipBoard, int x,
int y) {
LayoutAdapter adapter = parent.getLayoutAdapter();
if (selection.size() == 1) {
try {
XCreator creator = selection.getSelectedCreator();
Widget cloned = new ClonedWidgetCreator(designer.getTarget()).clonedWidgetWithNoRepeatName(creator
.toData());
XCreator clondCreator = XCreatorUtils.createXCreator(cloned, creator.getSize());
if (adapter.addBean(clondCreator, x + clondCreator.getWidth() / 2, y + clondCreator.getHeight() / 2)) {
designer.getSelectionModel().getSelection().setSelectedCreator(clondCreator);
designer.getEditListenerTable().fireCreatorModified(clondCreator, DesignerEvent.CREATOR_PASTED);
return;
}
} catch (CloneNotSupportedException e) {
FRContext.getLogger().error(e.getMessage(), e);
}
} else if (selection.size() > 1) {
if (parent instanceof XWAbsoluteLayout) {
designer.getSelectionModel().getSelection().reset();
Rectangle rec = selection.getSelctionBounds();
for (XCreator creator : selection.getSelectedCreators()) {
Rectangle rec = clipBoard.getSelctionBounds();
for (XCreator creator : clipBoard.getSelectedCreators()) {
try {
Widget cloned = new ClonedWidgetCreator(designer.getTarget())
.clonedWidgetWithNoRepeatName(creator.toData());
XCreator clondCreator = XCreatorUtils.createXCreator(cloned, creator.getSize());
// 设置位置,移动20x20,防止被粘帖的组件重叠,照顾表单布局情况下
adapter.addBean(clondCreator, x + creator.getX() - rec.x + clondCreator.getWidth() / 2, y
+ creator.getY() - rec.y + clondCreator.getHeight() / 2);
designer.getSelectionModel().getSelection().addSelectedCreator(clondCreator);
Widget copied = copyWidget(designer, creator.toData());
XCreator copiedCreator = XCreatorUtils.createXCreator(copied, creator.getSize());
// 获取位置
Point point = getPasteLocation((AbstractLayoutAdapter) adapter,
copiedCreator,
x + creator.getX() - rec.x + copiedCreator.getWidth() / 2,
y + creator.getY() - rec.y + copiedCreator.getHeight() / 2);
boolean addSuccess = adapter.addBean(copiedCreator, point.x, point.y);
if (addSuccess) {
designer.getSelectionModel().getSelection().addSelectedCreator(copiedCreator);
}
} catch (CloneNotSupportedException e) {
FRContext.getLogger().error(e.getMessage(), e);
}
}
rebuildSelection(designer);
designer.getEditListenerTable().fireCreatorModified(
designer.getSelectionModel().getSelection().getSelectedCreator(), DesignerEvent.CREATOR_PASTED);
return;
}
}
Toolkit.getDefaultToolkit().beep();
}
/**
* 组件复用绝对布局获取粘贴组件位置
*
* @param layoutAdapter 绝对布局容器AbstractLayoutAdapter
* @param copiedCreator 复制的组件
* @param x x=组件x + clonedCreator.getWidth() / 2
* @param y y=组件y + clonedCreator.getHeight() / 2
* 除2的步骤会导致当宽度或者高度为奇数是中心点向左上各偏移一个像素
* 由于中心点向左上各偏移一个像素依赖中心点计算的右下点就会相应的想做上偏移一个像素导致结果不准确
* @return 新位置坐标
*/
private static Point getPasteLocation(AbstractLayoutAdapter layoutAdapter, XCreator copiedCreator, int x, int y) {
//当宽度为奇数时 设置偏移
int x_offset = (copiedCreator.getWidth() & 1) == 1 ? 1 : 0;
//当高度为奇数时 设置偏移
int y_offset = (copiedCreator.getHeight() & 1) == 1 ? 1 : 0;
if (!layoutAdapter.accept(copiedCreator, x, y)) {
XLayoutContainer container = layoutAdapter.getContainer();
boolean xOut = x < 0 || x + copiedCreator.getWidth() / 2 + x_offset > container.getWidth();
boolean yOut = y < 0 || y + copiedCreator.getHeight() / 2 + y_offset > container.getHeight();
/*
* 组件原始位置位于布局的右下角
* 和布局右下边界线紧挨
* 粘贴时组件在原始位置向左错开20像素
* x,y同时越界
*/
if (xOut && yOut) {
x = BACK_OFFSET ? container.getWidth() - copiedCreator.getWidth() / 2 - x_offset
: container.getWidth() - copiedCreator.getWidth() / 2 - DELAY_X - x_offset;
y = BACK_OFFSET ?
container.getHeight() - copiedCreator.getHeight() / 2 - y_offset
: container.getHeight() - copiedCreator.getHeight() / 2 - DELAY_Y - y_offset;
BACK_OFFSET = !BACK_OFFSET;
return new Point(x, y);
}
/*
* 组件原始位置与布局边界距离小于20像素下边界&右边界同时小于或者任意一个边界小于
* 则粘贴时距离小于20像素一侧直接贴近布局边界
* 距离大于20像素的一侧正常错开
* x,y中只有一个越界
*/
else if ((xOut || yOut)) {
x = xOut ? container.getWidth() - copiedCreator.getWidth() / 2 - x_offset : x;
y = yOut ? container.getHeight() - copiedCreator.getHeight() / 2 - y_offset : y;
return new Point(x, y);
}
}
return new Point(x, y);
}
private static Widget copyWidget(FormDesigner formDesigner, Widget widget) throws
CloneNotSupportedException {
ArrayList<String> clonedNameList = new ArrayList<String>();
Widget copied = (Widget) widget.clone();
//重命名拷贝的组件
setCopiedName(formDesigner, copied, clonedNameList);
if (copied instanceof WLayout) {
for (int i = 0; i < ((WLayout) copied).getWidgetCount(); i++) {
setCopiedName(formDesigner, ((WLayout) copied).getWidget(i), clonedNameList);
}
}
return copied;
}
/**
* 组件拷贝命名规则
*
* @param formDesigner
* @param copied
* @param clonedNameList
*/
private static void setCopiedName(FormDesigner formDesigner, Widget copied, ArrayList<String> clonedNameList) {
String name = copied.getWidgetName();
do {
name += postfix;
} while (formDesigner.getTarget().isNameExist(name) || clonedNameList.contains(name));
copied.setWidgetName(name);
clonedNameList.add(name);
}
public static void rebuildSelection(FormDesigner designer) {
ArrayList<XCreator> newSelection = new ArrayList<XCreator>();
List<Widget> widgetList = new ArrayList<Widget>();
@ -117,8 +206,6 @@ public class FormSelectionUtils {
}
if (c instanceof XLayoutContainer) {
_rebuild((XLayoutContainer) c, selectionWidget, newSelection);
} else {
continue;
}
}
}

56
designer_form/src/com/fr/design/mainframe/JForm.java

@ -4,10 +4,12 @@ import com.fr.base.BaseUtils;
import com.fr.design.DesignState;
import com.fr.design.actions.core.WorkBookSupportable;
import com.fr.design.actions.file.WebPreviewUtils;
import com.fr.design.mainframe.actions.FormMobileAttrAction;
import com.fr.design.cell.FloatElementsProvider;
import com.fr.design.constants.UIConstants;
import com.fr.design.designer.beans.actions.CopyAction;
import com.fr.design.designer.beans.actions.CutAction;
import com.fr.design.designer.beans.actions.FormDeleteAction;
import com.fr.design.designer.beans.actions.PasteAction;
import com.fr.design.designer.beans.events.DesignerEditListener;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.*;
@ -20,6 +22,7 @@ import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.gui.xpane.FormHyperlinkGroupPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.actions.EmbeddedFormExportExportAction;
import com.fr.design.mainframe.actions.FormMobileAttrAction;
import com.fr.design.mainframe.actions.TemplateParameterAction;
import com.fr.design.mainframe.form.FormECCompositeProvider;
import com.fr.design.mainframe.form.FormECDesignerProvider;
@ -264,10 +267,10 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
}
@Override
/**
* 焦点放到JForm
*/
@Override
public void requestFocus() {
super.requestFocus();
formDesign.requestFocus();
@ -281,12 +284,12 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
formDesign.requestFocus();
}
@Override
/**
* 保存文件的后缀名
*
* @return 返回后缀名
*/
@Override
public String suffix() {
// daniel改成三个字
return ".frm";
@ -319,30 +322,33 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
formDesign.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_SELECTED);
}
@Override
/**
*复制 f
* 复制
*/
@Override
public void copy() {
this.formDesign.copy();
}
@Override
/**
*
* 粘贴
*
* @return 是否成功
*/
@Override
public boolean paste() {
return this.formDesign.paste();
}
@Override
/**
*
* 剪切
*
* @return 是否成功
*/
@Override
public boolean cut() {
return this.formDesign.cut();
}
@ -352,36 +358,38 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
// ////////////////////////////////////////////////////////////////////
@Override
/**
* 目标菜单
*
* @return 菜单
*/
@Override
public MenuDef[] menus4Target() {
return this.index == FORM_TAB ?
(MenuDef[]) ArrayUtils.addAll(super.menus4Target(), this.formDesign.menus4Target()) :
(MenuDef[]) ArrayUtils.addAll(super.menus4Target(), this.elementCaseDesign.menus4Target());
}
@Override
/**
* 模板的工具
*
* @return 工具
*/
@Override
public ToolBarDef[] toolbars4Target() {
return this.index == FORM_TAB ?
this.formDesign.toolbars4Target() :
this.elementCaseDesign.toolbars4Target();
}
@Override
/**
* 模板菜单
*
* @return 返回菜单
*/
@Override
public ShortCut[] shortcut4TemplateMenu() {
if (this.index == FORM_TAB) {
return (ShortCut[]) ArrayUtils.addAll(new ShortCut[]{
@ -407,11 +415,6 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
}
@Override
/**
* undo的表单state
*
* @return 表单State
*/
protected FormUndoState createUndoState() {
FormUndoState cur = new FormUndoState(this, this.formDesign.getArea());
if (this.formDesign.isReportBlockEditing()) {
@ -452,10 +455,8 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
}
return rootLayout;
}
@Override
/**
* 应用undoState的表单数据
*/
protected void applyUndoState(FormUndoState u) {
try {
//JForm的target重置
@ -487,19 +488,11 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
}
@Override
/**
*
*/
protected FormModelAdapter createDesignModel() {
return new FormModelAdapter(this);
}
@Override
/**
* 表单的工具栏
*
* @return 表单工具栏
*/
public JPanel[] toolbarPanes4Form() {
return this.index == FORM_TAB ?
new JPanel[]{FormParaWidgetPane.getInstance(formDesign)} :
@ -514,10 +507,9 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
public JComponent[] toolBarButton4Form() {
return this.index == FORM_TAB ?
new JComponent[]{
//自适应布局里的复制粘贴意义不大, 先屏蔽掉
// new CutAction(formDesign).createToolBarComponent(),
// new CopyAction(formDesign).createToolBarComponent(),
// new PasteAction(formDesign).createToolBarComponent(),
new CutAction(formDesign).createToolBarComponent(),
new CopyAction(formDesign).createToolBarComponent(),
new PasteAction(formDesign).createToolBarComponent(),
new FormDeleteAction(formDesign).createToolBarComponent()} :
elementCaseDesign.toolBarButton4Form();
}

3
designer_form/src/com/fr/design/mainframe/MobileWidgetTable.java

@ -251,7 +251,8 @@ public class MobileWidgetTable extends JTable {
}
//选择的控件
Widget selectedModel = designer.getSelectionModel().getSelection().getSelectedCreator().toData();
XCreator selectedCreator = designer.getSelectionModel().getSelection().getSelectedCreator();
Widget selectedModel = selectedCreator != null ? selectedCreator.toData() : null;
if(selectedModel == null){
return new String[0][0];

7
designer_form/src/com/fr/design/mainframe/WidgetPropertyPane.java

@ -200,6 +200,7 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper
/**
* 判断是将拓展的tab放入属性表还是将原来的tab放入属性表
*
* @param widgetAttrProviders 拓展的tab
*/
private void addWidgetAttr(WidgetPropertyUIProvider[] widgetAttrProviders) {
@ -219,6 +220,7 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper
/**
* 如果是body的拓展属性表那么要额外加上一张控件顺序表
*
* @return
*/
private Component getExtraBodyTable(AbstractPropertyTable abstractPropertyTable) {
@ -243,9 +245,10 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper
tabbedPane.addTab(Inter.getLocText("FR-Widget_Mobile_Terminal"), wsp);
}
//
/**
* 选中的组件是否在参数面板里
*
* @param designer 设计器
* @return 是则返回true
*/
@ -255,6 +258,7 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper
xCreator = designer.getRootComponent();
}
XLayoutContainer container = XCreatorUtils.getHotspotContainer(xCreator);
//TODO container可能为空,引发空指针异常
return xCreator.acceptType(XWParameterLayout.class) || container.acceptType(XWParameterLayout.class);
}
@ -335,6 +339,7 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper
/**
* 响应界面改变事件
*
* @param evt 事件
*/
public void fireCreatorModified(DesignerEvent evt) {

Loading…
Cancel
Save