Browse Source

无任务 代码调整

master
yaoh.wu 8 years ago
parent
commit
2715c3c598
  1. 8
      designer_base/src/com/fr/design/actions/edit/CopyAction.java
  2. 2
      designer_base/src/com/fr/design/beans/location/MoveUtils.java
  3. 73
      designer_base/src/com/fr/design/parameter/ParameterDesignerProvider.java
  4. 11
      designer_base/src/com/fr/design/utils/ComponentUtils.java
  5. 11
      designer_form/src/com/fr/design/designer/beans/actions/CopyAction.java
  6. 6
      designer_form/src/com/fr/design/designer/beans/adapters/layout/AbstractLayoutAdapter.java
  7. 28
      designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java
  8. 42
      designer_form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java
  9. 3
      designer_form/src/com/fr/design/designer/beans/adapters/layout/FRTabFitLayoutAdapter.java
  10. 67
      designer_form/src/com/fr/design/designer/beans/location/AccessDirection.java
  11. 80
      designer_form/src/com/fr/design/designer/beans/models/SelectionModel.java
  12. 12
      designer_form/src/com/fr/design/form/parameter/FormParaDesigner.java
  13. 85
      designer_form/src/com/fr/design/mainframe/EditingMouseListener.java
  14. 21
      designer_form/src/com/fr/design/mainframe/FormDesigner.java
  15. 6
      designer_form/src/com/fr/design/mainframe/FormSelectionUtils.java
  16. 1
      designer_form/src/com/fr/design/mainframe/JForm.java
  17. 3
      designer_form/src/com/fr/design/mainframe/MobileWidgetTable.java

8
designer_base/src/com/fr/design/actions/edit/CopyAction.java

@ -3,15 +3,14 @@
*/ */
package com.fr.design.actions.edit; package com.fr.design.actions.edit;
import java.awt.event.KeyEvent;
import javax.swing.KeyStroke;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.design.actions.TemplateComponentAction; import com.fr.design.actions.TemplateComponentAction;
import com.fr.design.designer.TargetComponent; import com.fr.design.designer.TargetComponent;
import com.fr.general.Inter; import com.fr.general.Inter;
import javax.swing.*;
import java.awt.event.KeyEvent;
/** /**
* Copy. * Copy.
*/ */
@ -31,7 +30,6 @@ public class CopyAction extends TemplateComponentAction {
if (tc != null) { if (tc != null) {
tc.copy(); tc.copy();
} }
return false; return false;
} }
} }

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

@ -18,7 +18,7 @@ public class MoveUtils {
public static final int SORPTION_UNIT = 5; public static final int SORPTION_UNIT = 5;
private static final int EQUIDISTANTLINE_UNIT = 4; private static final int EQUIDISTANTLINE_UNIT = 4;
public static ArrayList<EquidistantLine> equidistantLines = new ArrayList<>(); private static ArrayList<EquidistantLine> equidistantLines = new ArrayList<>();
private MoveUtils() { private MoveUtils() {

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

@ -1 +1,72 @@
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); Component createWrapper(); void setDesignHeight(int height); Dimension getDesignSize(); Dimension getPreferredSize(); void populate(ParameterUI p); void refreshAllNameWidgets(); void refresh4TableData(String oldName, String newName); void refreshParameter(ParaDefinitePane paraDefinitePane); boolean isWithQueryButton(); java.util.List<String> getAllXCreatorNameList(); boolean isWithoutParaXCreator(Parameter[] ps); boolean isBlank(); ParameterUI getParaTarget(); boolean addingParameter2Editor(Parameter parameter, int index); boolean addingParameter2EditorWithQueryButton(Parameter parameter, int index); void addingAllParameter2Editor(Parameter[] parameterArray, int currentIndex); JPanel[] toolbarPanes4Form(); JComponent[] toolBarButton4Form(); void initBeforeUpEdit(); void populateParameterPropertyPane(ParaDefinitePane p); void initWidgetToolbarPane(); AuthorityEditPane getAuthorityEditPane(); JPanel getEastUpPane(); JPanel getEastDownPane(); boolean isSupportAuthority(); void removeSelection(); 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);
Component createWrapper();
void setDesignHeight(int height);
Dimension getDesignSize();
Dimension getPreferredSize();
void populate(ParameterUI p);
void refreshAllNameWidgets();
void refresh4TableData(String oldName, String newName);
void refreshParameter(ParaDefinitePane paraDefinitePane);
boolean isWithQueryButton();
java.util.List<String> getAllXCreatorNameList();
boolean isWithoutParaXCreator(Parameter[] ps);
boolean isBlank();
ParameterUI getParaTarget();
boolean addingParameter2Editor(Parameter parameter, int index);
boolean addingParameter2EditorWithQueryButton(Parameter parameter, int index);
void addingAllParameter2Editor(Parameter[] parameterArray, int currentIndex);
JPanel[] toolbarPanes4Form();
JComponent[] toolBarButton4Form();
void initBeforeUpEdit();
void populateParameterPropertyPane(ParaDefinitePane p);
void initWidgetToolbarPane();
AuthorityEditPane getAuthorityEditPane();
JPanel getEastUpPane();
JPanel getEastDownPane();
boolean isSupportAuthority();
void removeSelection();
ParameterBridge getParaComponent();
}

11
designer_base/src/com/fr/design/utils/ComponentUtils.java

@ -12,6 +12,9 @@ import java.util.ArrayList;
*/ */
public class ComponentUtils { public class ComponentUtils {
private ComponentUtils() {
}
public static boolean isComponentVisible(Component comp) { public static boolean isComponentVisible(Component comp) {
if (!comp.isVisible() && !isRootComponent(comp)) { if (!comp.isVisible() && !isRootComponent(comp)) {
return false; return false;
@ -79,7 +82,7 @@ public class ComponentUtils {
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
Component child = container.getComponent(i); Component child = container.getComponent(i);
if (child == target) { if (child.equals(target)) {
return i; return i;
} }
} }
@ -105,10 +108,10 @@ public class ComponentUtils {
* 计算组件root相对于其顶层容器的可见区域 * 计算组件root相对于其顶层容器的可见区域
*/ */
public static Rectangle computeVisibleRect(JComponent root) { public static Rectangle computeVisibleRect(JComponent root) {
Rectangle root_bounds = ComponentUtils.getRelativeBounds(root); Rectangle rootBounds = ComponentUtils.getRelativeBounds(root);
Rectangle rect = computeVisibleRectRel2Root(root); Rectangle rect = computeVisibleRectRel2Root(root);
rect.x -= root_bounds.x; rect.x -= rootBounds.x;
rect.y -= root_bounds.y; rect.y -= rootBounds.y;
return rect; return rect;
} }

11
designer_form/src/com/fr/design/designer/beans/actions/CopyAction.java

@ -1,13 +1,12 @@
package com.fr.design.designer.beans.actions; package com.fr.design.designer.beans.actions;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import javax.swing.KeyStroke;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.general.Inter;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.general.Inter;
import javax.swing.*;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
public class CopyAction extends FormEditAction { public class CopyAction extends FormEditAction {

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

@ -1,8 +1,5 @@
package com.fr.design.designer.beans.adapters.layout; package com.fr.design.designer.beans.adapters.layout;
import java.awt.LayoutManager;
import com.fr.general.ComparatorUtils;
import com.fr.design.beans.GroupModel; import com.fr.design.beans.GroupModel;
import com.fr.design.designer.beans.ConstraintsGroupModel; import com.fr.design.designer.beans.ConstraintsGroupModel;
import com.fr.design.designer.beans.HoverPainter; import com.fr.design.designer.beans.HoverPainter;
@ -13,6 +10,9 @@ import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWidgetCreator; import com.fr.design.designer.creator.XWidgetCreator;
import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.ComponentUtils;
import com.fr.design.utils.gui.LayoutUtils; import com.fr.design.utils.gui.LayoutUtils;
import com.fr.general.ComparatorUtils;
import java.awt.*;
public abstract class AbstractLayoutAdapter implements LayoutAdapter { public abstract class AbstractLayoutAdapter implements LayoutAdapter {

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

@ -1,7 +1,5 @@
package com.fr.design.designer.beans.adapters.layout; package com.fr.design.designer.beans.adapters.layout;
import java.awt.*;
import com.fr.design.beans.GroupModel; import com.fr.design.beans.GroupModel;
import com.fr.design.designer.beans.ConstraintsGroupModel; import com.fr.design.designer.beans.ConstraintsGroupModel;
import com.fr.design.designer.beans.HoverPainter; import com.fr.design.designer.beans.HoverPainter;
@ -9,13 +7,14 @@ import com.fr.design.designer.beans.painters.FRAbsoluteLayoutPainter;
import com.fr.design.designer.creator.*; import com.fr.design.designer.creator.*;
import com.fr.design.designer.properties.BoundsGroupModel; import com.fr.design.designer.properties.BoundsGroupModel;
import com.fr.design.designer.properties.FRAbsoluteLayoutPropertiesGroupModel; import com.fr.design.designer.properties.FRAbsoluteLayoutPropertiesGroupModel;
import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.ComponentUtils;
import com.fr.design.utils.gui.LayoutUtils; import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.ui.widget.BoundsWidget; import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger; import com.fr.general.FRLogger;
import java.awt.*;
public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter { public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
//是不是添加到父容器上 //是不是添加到父容器上
private boolean isAdd2ParentLayout = false; private boolean isAdd2ParentLayout = false;
@ -75,13 +74,13 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer((XCreator) comp).getTopLayout(); XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer((XCreator) comp).getTopLayout();
if (topLayout != null) { if (topLayout != null) {
if (topLayout.isEditable()) { if (topLayout.isEditable()) {
return topLayoutAccept(creator, x, y, topLayout); return topLayoutAccept(creator, x, y);
} }
//绝对布局嵌套,处于内层,不可编辑,不添加,topLayout只能获取到最外层可编辑的布局 //绝对布局嵌套,处于内层,不可编辑,不添加,topLayout只能获取到最外层可编辑的布局
else if (((XLayoutContainer) topLayout.getParent()).acceptType(XWAbsoluteLayout.class)) { else if (((XLayoutContainer) topLayout.getParent()).acceptType(XWAbsoluteLayout.class)) {
return false; return false;
} else { } else {
return acceptWidget(creator, x, y); return acceptWidget(x, y);
} }
} else { } else {
FRLogger.getLogger().error("top layout is null!"); FRLogger.getLogger().error("top layout is null!");
@ -91,7 +90,7 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
} }
//topLayout假如可以编辑的话就往里面添加组件 //topLayout假如可以编辑的话就往里面添加组件
private boolean topLayoutAccept(XCreator creator, int x, int y, XLayoutContainer topLayout) { private boolean topLayoutAccept(XCreator creator, int x, int y) {
//允许组件重叠,可以不判断有没有和当前控件重叠 //允许组件重叠,可以不判断有没有和当前控件重叠
//先计算当前控件的位置 //先计算当前控件的位置
int creatorX, creatorY; int creatorX, creatorY;
@ -109,18 +108,6 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
creatorX = x - w; creatorX = x - w;
creatorY = y - h; creatorY = y - h;
} }
//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()) { if (creatorX < 0 || creatorX + creator.getWidth() > container.getWidth()) {
return false; return false;
} }
@ -174,11 +161,10 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
} }
//当前绝对布局不可编辑,就当成一个控件,组件添加在周围 //当前绝对布局不可编辑,就当成一个控件,组件添加在周围
private boolean acceptWidget(XCreator creator, int x, int y) { private boolean acceptWidget(int x, int y) {
isFindRelatedComps = false; isFindRelatedComps = false;
//拖入组件判断时,先判断是否为交叉点区域,其次三等分区域,再次平分区域 //拖入组件判断时,先判断是否为交叉点区域,其次三等分区域,再次平分区域
Component comp = container.getComponentAt(x, y); Component comp = container.getComponentAt(x, y);
boolean isMatchEdge = false;
//如果当前处于边缘地带, 那么就把他贴到父容器上 //如果当前处于边缘地带, 那么就把他贴到父容器上
XLayoutContainer parent = container.findNearestFit(); XLayoutContainer parent = container.findNearestFit();
container = parent != null ? parent : container; container = parent != null ? parent : container;

42
designer_form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java

@ -3,12 +3,6 @@
*/ */
package com.fr.design.designer.beans.adapters.layout; package com.fr.design.designer.beans.adapters.layout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.List;
import com.fr.design.beans.GroupModel; import com.fr.design.beans.GroupModel;
import com.fr.design.designer.beans.ConstraintsGroupModel; import com.fr.design.designer.beans.ConstraintsGroupModel;
import com.fr.design.designer.beans.HoverPainter; import com.fr.design.designer.beans.HoverPainter;
@ -31,6 +25,10 @@ import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout;
import com.fr.form.ui.widget.BoundsWidget; import com.fr.form.ui.widget.BoundsWidget;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
/** /**
* 自适应布局的容器适配器 * 自适应布局的容器适配器
* *
@ -270,13 +268,6 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
return super.isCrossPointArea(currentComp, x, y); return super.isCrossPointArea(currentComp, x, y);
} }
protected void initCompsList() {
super.initCompsList();
}
protected void clearCompsList() {
super.clearCompsList();
}
protected Rectangle getLayoutBound(XWCardMainBorderLayout mainLayout) { protected Rectangle getLayoutBound(XWCardMainBorderLayout mainLayout) {
return mainLayout.getBounds(); return mainLayout.getBounds();
@ -559,8 +550,8 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
difference = Math.max(difference, minWidth - getMinWidth(leftComps)); difference = Math.max(difference, minWidth - getMinWidth(leftComps));
} }
//重新计算左右两侧组件size、point //重新计算左右两侧组件size、point
if (CalculateLefttRelatComponent(difference)) { if (calculateLefttRelatComponent(difference)) {
CalculateRightRelatComponent(objx + difference, -difference); calculateRightRelatComponent(objx + difference, -difference);
} }
} }
@ -675,10 +666,9 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
difference = Math.max(difference, minHeight - getMinHeight(upComps)); difference = Math.max(difference, minHeight - getMinHeight(upComps));
} }
//重新计算上下两侧组件size、point //重新计算上下两侧组件size、point
if (CalculateUpRelatComponent(difference)) { if (calculateUpRelatComponent(difference)) {
CalculateDownRelatComponent(objY + difference, -difference); calculateDownRelatComponent(objY + difference, -difference);
} }
;
} }
/** /**
@ -758,13 +748,13 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
int height = creatorHeight; int height = creatorHeight;
calculateRelatedComponent(x, y, width, height); calculateRelatedComponent(x, y, width, height);
if (!rightComps.isEmpty() && getAllHeight(rightComps) == height) { if (!rightComps.isEmpty() && getAllHeight(rightComps) == height) {
CalculateRightRelatComponent(x, width + actualVal); calculateRightRelatComponent(x, width + actualVal);
} else if (!leftComps.isEmpty() && getAllHeight(leftComps) == height) { } else if (!leftComps.isEmpty() && getAllHeight(leftComps) == height) {
CalculateLefttRelatComponent(width + actualVal); calculateLefttRelatComponent(width + actualVal);
} else if (!downComps.isEmpty() && getAllWidth(downComps) == width) { } else if (!downComps.isEmpty() && getAllWidth(downComps) == width) {
CalculateDownRelatComponent(y, height + actualVal); calculateDownRelatComponent(y, height + actualVal);
} else if (!upComps.isEmpty() && getAllWidth(upComps) == width) { } else if (!upComps.isEmpty() && getAllWidth(upComps) == width) {
CalculateUpRelatComponent(height + actualVal); calculateUpRelatComponent(height + actualVal);
} else { } else {
// 由于布局三等分的存在,可能会出现删除组件时,找不到关联的组件填充,此时特殊处理 // 由于布局三等分的存在,可能会出现删除组件时,找不到关联的组件填充,此时特殊处理
calculateNoRelatedComponent(x, y, width, height); calculateNoRelatedComponent(x, y, width, height);
@ -1070,7 +1060,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
* @param objX 调整后的坐标x * @param objX 调整后的坐标x
* @param objWidth 调整后的宽度 * @param objWidth 调整后的宽度
*/ */
protected void CalculateRightRelatComponent(int objX, int objWidth) { protected void calculateRightRelatComponent(int objX, int objWidth) {
int count = rightComps.size(); int count = rightComps.size();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
XCreator creator = (XCreator) rightComps.get(i); XCreator creator = (XCreator) rightComps.get(i);
@ -1110,7 +1100,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
/** /**
* 删除或拉伸控件左边框时 调整左侧的组件位置大小 * 删除或拉伸控件左边框时 调整左侧的组件位置大小
*/ */
protected boolean CalculateLefttRelatComponent(int objWidth) { protected boolean calculateLefttRelatComponent(int objWidth) {
if (isBeyondAdjustWidthScope(objWidth)) { if (isBeyondAdjustWidthScope(objWidth)) {
return false; return false;
} }
@ -1128,7 +1118,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
/** /**
* 删除或拉伸下边框 调整下方的组件位置大小 * 删除或拉伸下边框 调整下方的组件位置大小
*/ */
protected void CalculateDownRelatComponent(int objY, int objHeight) { protected void calculateDownRelatComponent(int objY, int objHeight) {
int count = downComps.size(); int count = downComps.size();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
XCreator creator = (XCreator) downComps.get(i); XCreator creator = (XCreator) downComps.get(i);
@ -1168,7 +1158,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
/** /**
* 删除或拉伸上边框 调整上方的组件位置大小 * 删除或拉伸上边框 调整上方的组件位置大小
*/ */
protected boolean CalculateUpRelatComponent(int objHeight) { protected boolean calculateUpRelatComponent(int objHeight) {
if (isBeyondAdjustHeightScope(objHeight)) { if (isBeyondAdjustHeightScope(objHeight)) {
return false; return false;
} }

3
designer_form/src/com/fr/design/designer/beans/adapters/layout/FRTabFitLayoutAdapter.java

@ -7,7 +7,6 @@ package com.fr.design.designer.beans.adapters.layout;
import com.fr.design.beans.GroupModel; import com.fr.design.beans.GroupModel;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWParameterLayout;
import com.fr.design.designer.creator.XWidgetCreator; import com.fr.design.designer.creator.XWidgetCreator;
import com.fr.design.designer.creator.cardlayout.XWCardLayout; import com.fr.design.designer.creator.cardlayout.XWCardLayout;
import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout;
@ -28,8 +27,6 @@ import java.awt.*;
* @date 2014-6-24 * @date 2014-6-24
*/ */
public class FRTabFitLayoutAdapter extends FRFitLayoutAdapter { public class FRTabFitLayoutAdapter extends FRFitLayoutAdapter {
//标题栏高度对tab布局内部组件的y坐标造成了偏移
private static int TAB_HEIGHT = 40;
/** /**
* 构造函数 * 构造函数

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

@ -3,19 +3,17 @@
*/ */
package com.fr.design.designer.beans.location; package com.fr.design.designer.beans.location;
import java.awt.*;
import com.fr.design.beans.location.Absorptionline; import com.fr.design.beans.location.Absorptionline;
import com.fr.design.beans.location.MoveUtils; import com.fr.design.beans.location.MoveUtils;
import com.fr.design.designer.creator.*; import com.fr.design.designer.creator.*;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelection; import com.fr.design.mainframe.FormSelection;
import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.ComponentUtils;
import com.fr.form.main.Form;
import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WParameterLayout;
import com.fr.form.ui.widget.BoundsWidget; import com.fr.form.ui.widget.BoundsWidget;
import java.awt.*;
/** /**
* @author richer * @author richer
* @since 6.5.3 * @since 6.5.3
@ -28,10 +26,10 @@ public abstract class AccessDirection implements Direction {
abstract int getCursor(); abstract int getCursor();
protected abstract Rectangle getDraggedBounds(int dx, int dy, Rectangle current_bounds, FormDesigner designer, protected abstract Rectangle getDraggedBounds(int dx, int dy, Rectangle currentBounds, FormDesigner designer,
Rectangle oldbounds); Rectangle oldBounds);
protected int[] sorption(int x, int y,Rectangle current_bounds, FormDesigner designer) { protected int[] sorption(int x, int y, Rectangle currentBounds, FormDesigner designer) {
// 自适应布局不需要吸附线,但需要对齐线,对齐线后面处理 // 自适应布局不需要吸附线,但需要对齐线,对齐线后面处理
if (!designer.hasWAbsoluteLayout()) { if (!designer.hasWAbsoluteLayout()) {
designer.getStateModel().setEquidistantLine(null); designer.getStateModel().setEquidistantLine(null);
@ -39,16 +37,14 @@ public abstract class AccessDirection implements Direction {
designer.getStateModel().setYAbsorptionline(null); designer.getStateModel().setYAbsorptionline(null);
return new int[]{x, y}; return new int[]{x, y};
} else { } else {
int posy = current_bounds.y; Point relativePoint = getRelativePoint(x, y, currentBounds, designer);
sorptionPoint(relativePoint, currentBounds, designer);
Point relativePoint = getRelativePoint(x, y, current_bounds,designer);
sorptionPoint(relativePoint,current_bounds, designer);
return new int[]{relativePoint.x, relativePoint.y}; return new int[]{relativePoint.x, relativePoint.y};
} }
} }
protected Point getRelativePoint(int x, int y, Rectangle current_bounds,FormDesigner designer) { protected Point getRelativePoint(int x, int y, Rectangle currentBounds, FormDesigner designer) {
if (x < 0) { if (x < 0) {
x = 0; x = 0;
} else if (x > designer.getRootComponent().getWidth() && designer.getSelectionModel().hasSelectionComponent()) { } else if (x > designer.getRootComponent().getWidth() && designer.getSelectionModel().hasSelectionComponent()) {
@ -64,12 +60,11 @@ public abstract class AccessDirection implements Direction {
return new Point(x, y); return new Point(x, y);
} }
protected void sorptionPoint(Point point, Rectangle current_bounds,FormDesigner designer) { protected void sorptionPoint(Point point, Rectangle currentBounds, FormDesigner designer) {
boolean findInX = current_bounds.getWidth() <= MoveUtils.SORPTION_UNIT ? true : false; boolean findInX = currentBounds.getWidth() <= MoveUtils.SORPTION_UNIT;
boolean findInY = current_bounds.getHeight() <= MoveUtils.SORPTION_UNIT ? true : false; boolean findInY = currentBounds.getHeight() <= MoveUtils.SORPTION_UNIT;
WAbsoluteLayout layout = getLayout(designer); WAbsoluteLayout layout = getLayout(designer);
FormSelection selection = designer.getSelectionModel().getSelection(); FormSelection selection = designer.getSelectionModel().getSelection();
// boolean isWidgetsIntersect = false;
for (int i = 0, count = layout.getWidgetCount(); i < count; i++) { for (int i = 0, count = layout.getWidgetCount(); i < count; i++) {
BoundsWidget temp = (BoundsWidget) layout.getWidget(i); BoundsWidget temp = (BoundsWidget) layout.getWidget(i);
if (!temp.isVisible() || selection.contains(temp.getWidget())) { if (!temp.isVisible() || selection.contains(temp.getWidget())) {
@ -105,17 +100,14 @@ public abstract class AccessDirection implements Direction {
break; break;
} }
// if (current_bounds.intersects(bounds) && !(layout instanceof WParameterLayout)) {
// isWidgetsIntersect = true;
// }
} }
// processRectangleIntersects(designer, point.x, point.y, isWidgetsIntersect); setDesignerStateModelProperties(designer, findInX, findInY, currentBounds, point);
setDesignerStateModelProperties(designer, findInX, findInY, current_bounds, point);
} }
private void setDesignerStateModelProperties (FormDesigner designer, boolean findInX, boolean findInY, Rectangle current_bounds, Point point) { private void setDesignerStateModelProperties(FormDesigner designer, boolean findInX, boolean findInY, Rectangle
designer.getStateModel().setXAbsorptionline(findInX && current_bounds.getWidth() > MoveUtils.SORPTION_UNIT ? Absorptionline.createXAbsorptionline(point.x) : null); currentBounds, Point point) {
designer.getStateModel().setYAbsorptionline(findInY && current_bounds.getHeight() > MoveUtils.SORPTION_UNIT ? Absorptionline.createYAbsorptionline(point.y) : null); designer.getStateModel().setXAbsorptionline(findInX && currentBounds.getWidth() > MoveUtils.SORPTION_UNIT ? Absorptionline.createXAbsorptionline(point.x) : null);
designer.getStateModel().setYAbsorptionline(findInY && currentBounds.getHeight() > MoveUtils.SORPTION_UNIT ? Absorptionline.createYAbsorptionline(point.y) : null);
designer.getStateModel().setEquidistantLine(null); designer.getStateModel().setEquidistantLine(null);
} }
@ -131,18 +123,6 @@ public abstract class AccessDirection implements Direction {
return relativeRec; 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 WAbsoluteLayout getLayout(final FormDesigner designer) { private WAbsoluteLayout getLayout(final FormDesigner designer) {
XLayoutContainer formLayoutContainer = (XLayoutContainer) XCreatorUtils.createXCreator( XLayoutContainer formLayoutContainer = (XLayoutContainer) XCreatorUtils.createXCreator(
@ -152,8 +132,7 @@ public abstract class AccessDirection implements Direction {
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();
} } else {
else {
layout = (WAbsoluteLayout) designer.getParaComponent().toData(); layout = (WAbsoluteLayout) designer.getParaComponent().toData();
} }
} else { } else {
@ -164,12 +143,18 @@ public abstract class AccessDirection implements Direction {
/** /**
* 拖拽 * 拖拽
*
* @param dx 坐标x * @param dx 坐标x
* @param dy 坐标y * @param dy 坐标y
* @param designer 设计界面 * @param designer 设计界面
*/ */
public void drag(int dx, int dy, FormDesigner designer) { public void drag(int dx, int dy, FormDesigner designer) {
Rectangle rec = getDraggedBounds(dx, dy, designer.getSelectionModel().getSelection().getRelativeBounds(), designer, designer.getSelectionModel().getSelection().getBackupBounds()); Rectangle rec = getDraggedBounds(dx, dy, designer.getSelectionModel().getSelection().getRelativeBounds(), designer, designer.getSelectionModel().getSelection().getBackupBounds());
if (rec != null) {
designer.getSelectionModel().getSelection().setSelectionBounds(rec, designer);
} else {
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;
@ -192,13 +177,12 @@ public abstract class AccessDirection implements Direction {
rec.width = MINWIDTH; rec.width = MINWIDTH;
rec.x = xmin; rec.x = xmin;
} }
if(rec != null) {
designer.getSelectionModel().getSelection().setSelectionBounds(rec, designer);
}
} }
/** /**
* 更新鼠标指针形状 * 更新鼠标指针形状
*
* @param formEditor 设计界面组件 * @param formEditor 设计界面组件
*/ */
public void updateCursor(FormDesigner formEditor) { public void updateCursor(FormDesigner formEditor) {
@ -214,6 +198,7 @@ public abstract class AccessDirection implements Direction {
/** /**
* 生成组件备用的bound * 生成组件备用的bound
*
* @param formEditor 设计界面组件 * @param formEditor 设计界面组件
*/ */
public void backupBounds(FormDesigner formEditor) { public void backupBounds(FormDesigner formEditor) {

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

@ -1,11 +1,5 @@
package com.fr.design.designer.beans.models; package com.fr.design.designer.beans.models;
import java.awt.LayoutManager;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.beans.events.DesignerEvent;
@ -20,9 +14,12 @@ import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelection; import com.fr.design.mainframe.FormSelection;
import com.fr.design.mainframe.FormSelectionUtils; import com.fr.design.mainframe.FormSelectionUtils;
import com.fr.design.utils.gui.LayoutUtils; import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
/** /**
* 该model保存当前选择的组件和剪切版信息 * 该model保存当前选择的组件和剪切版信息
*/ */
@ -30,10 +27,10 @@ public class SelectionModel {
//被粘贴组件在所选组件位置处往下、往右各错开20像素。执行多次粘贴时,在上一次粘贴的位置处错开20像素。 //被粘贴组件在所选组件位置处往下、往右各错开20像素。执行多次粘贴时,在上一次粘贴的位置处错开20像素。
private static final int DELTA_X_Y = 20; //粘贴时候的偏移距离 private static final int DELTA_X_Y = 20; //粘贴时候的偏移距离
private static final int BORDER_PROPORTION = 20; private static final int BORDER_PROPORTION = 20;
private static FormSelection CLIP_BOARD = new FormSelection(); private static FormSelection clipboard = new FormSelection();
private FormDesigner designer; private FormDesigner designer;
private FormSelection selection; private FormSelection selection;
private Rectangle hotspot_bounds; private Rectangle hotspotBounds;
public SelectionModel(FormDesigner designer) { public SelectionModel(FormDesigner designer) {
this.designer = designer; this.designer = designer;
@ -45,7 +42,7 @@ public class SelectionModel {
*/ */
public void reset() { public void reset() {
selection.reset(); selection.reset();
hotspot_bounds = null; hotspotBounds = null;
} }
/** /**
@ -54,7 +51,7 @@ public class SelectionModel {
* @return 是否为空 * @return 是否为空
*/ */
public static boolean isEmpty() { public static boolean isEmpty() {
return CLIP_BOARD.isEmpty(); return clipboard.isEmpty();
} }
/** /**
@ -67,7 +64,6 @@ public class SelectionModel {
// 如果Ctrl或者Shift键盘没有按下,则清除已经选择的组件 // 如果Ctrl或者Shift键盘没有按下,则清除已经选择的组件
selection.reset(); selection.reset();
} }
// 获取e所在的组件 // 获取e所在的组件
XCreator comp = designer.getComponentAt(e); XCreator comp = designer.getComponentAt(e);
@ -93,7 +89,7 @@ public class SelectionModel {
*/ */
public void cutSelectedCreator2ClipBoard() { public void cutSelectedCreator2ClipBoard() {
if (hasSelectionComponent()) { if (hasSelectionComponent()) {
selection.cut2ClipBoard(CLIP_BOARD); selection.cut2ClipBoard(clipboard);
designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_CUTED); designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_CUTED);
designer.repaint(); designer.repaint();
} }
@ -104,7 +100,7 @@ public class SelectionModel {
*/ */
public void copySelectedCreator2ClipBoard() { public void copySelectedCreator2ClipBoard() {
if (!selection.isEmpty()) { if (!selection.isEmpty()) {
selection.copy2ClipBoard(CLIP_BOARD); selection.copy2ClipBoard(clipboard);
} }
} }
@ -114,7 +110,7 @@ public class SelectionModel {
* @return * @return
*/ */
public boolean pasteFromClipBoard() { public boolean pasteFromClipBoard() {
if (!CLIP_BOARD.isEmpty()) { if (!clipboard.isEmpty()) {
XLayoutContainer parent = null; XLayoutContainer parent = null;
//未选 //未选
if (!hasSelectionComponent()) { if (!hasSelectionComponent()) {
@ -124,14 +120,14 @@ public class SelectionModel {
Rectangle rec = selection.getRelativeBounds(); Rectangle rec = selection.getRelativeBounds();
//Tab布局 //Tab布局
FormSelectionUtils.paste2Container(designer, (XLayoutContainer) selection.getSelectedCreator(), FormSelectionUtils.paste2Container(designer, (XLayoutContainer) selection.getSelectedCreator(),
CLIP_BOARD, clipboard,
rec.x + rec.width / 2, rec.x + rec.width / 2,
rec.y + BORDER_PROPORTION); rec.y + BORDER_PROPORTION);
} else { } else {
Rectangle rec = selection.getRelativeBounds(); Rectangle rec = selection.getRelativeBounds();
//自适应布局 //自适应布局
FormSelectionUtils.paste2Container(designer, designer.getRootComponent(), FormSelectionUtils.paste2Container(designer, designer.getRootComponent(),
CLIP_BOARD, clipboard,
rec.x + rec.width / 2, rec.x + rec.width / 2,
rec.y + BORDER_PROPORTION); rec.y + BORDER_PROPORTION);
} }
@ -140,7 +136,7 @@ public class SelectionModel {
//编辑器外面还有两层容器,使用designer.getRootComponent()获取到的是编辑器中层的容器,不是编辑器表层 //编辑器外面还有两层容器,使用designer.getRootComponent()获取到的是编辑器中层的容器,不是编辑器表层
//当前选择的就是编辑器表层 //当前选择的就是编辑器表层
FormSelectionUtils.paste2Container(designer, (XLayoutContainer) selection.getSelectedCreator(), FormSelectionUtils.paste2Container(designer, (XLayoutContainer) selection.getSelectedCreator(),
CLIP_BOARD, clipboard,
DELTA_X_Y, DELTA_X_Y,
DELTA_X_Y); DELTA_X_Y);
} }
@ -148,7 +144,7 @@ public class SelectionModel {
//cpt本地组件复用,编辑器就一层,是最底层,使用designer.getRootComponent()就可以获取到 //cpt本地组件复用,编辑器就一层,是最底层,使用designer.getRootComponent()就可以获取到
//使用selection.getSelectedCreator()也应该是可以获取到的。 //使用selection.getSelectedCreator()也应该是可以获取到的。
FormSelectionUtils.paste2Container(designer, designer.getRootComponent(), FormSelectionUtils.paste2Container(designer, designer.getRootComponent(),
CLIP_BOARD, clipboard,
DELTA_X_Y, DELTA_X_Y,
DELTA_X_Y); DELTA_X_Y);
} }
@ -157,19 +153,16 @@ public class SelectionModel {
else { else {
//获取到编辑器的表层容器(已选的组件的父容器就是表层容器) //获取到编辑器的表层容器(已选的组件的父容器就是表层容器)
parent = XCreatorUtils.getParentXLayoutContainer(selection.getSelectedCreator()); parent = XCreatorUtils.getParentXLayoutContainer(selection.getSelectedCreator());
if (selection.getSelectedCreator().getParent() instanceof XWFitLayout) { if (parent != null && selection.getSelectedCreator().getParent() instanceof XWFitLayout) {
//自适应布局 //自适应布局
if (parent != null) {
Rectangle rec = selection.getRelativeBounds(); Rectangle rec = selection.getRelativeBounds();
FormSelectionUtils.paste2Container(designer, parent, CLIP_BOARD, rec.x + rec.width / 2, rec.y + FormSelectionUtils.paste2Container(designer, parent, clipboard, rec.x + rec.width / 2, rec.y +
rec.height - BORDER_PROPORTION); rec.height - BORDER_PROPORTION);
}
} else if (selection.getSelectedCreator().getParent() instanceof XWAbsoluteLayout) { } else if (parent != null && selection.getSelectedCreator().getParent() instanceof XWAbsoluteLayout) {
//绝对布局 //绝对布局
if (parent != null) {
Rectangle rec = selection.getSelctionBounds(); Rectangle rec = selection.getSelctionBounds();
FormSelectionUtils.paste2Container(designer, parent, CLIP_BOARD, rec.x + DELTA_X_Y, rec.y + DELTA_X_Y); FormSelectionUtils.paste2Container(designer, parent, clipboard, rec.x + DELTA_X_Y, rec.y + DELTA_X_Y);
}
} }
} }
} else { } else {
@ -223,14 +216,14 @@ public class SelectionModel {
* 设置选择区域 * 设置选择区域
*/ */
public void setHotspotBounds(Rectangle rect) { public void setHotspotBounds(Rectangle rect) {
hotspot_bounds = rect; hotspotBounds = rect;
} }
/** /**
* 获得当前选择区域 * 获得当前选择区域
*/ */
public Rectangle getHotspotBounds() { public Rectangle getHotspotBounds() {
return hotspot_bounds; return hotspotBounds;
} }
private void removeCreatorFromContainer(XCreator creator, int creatorWidth, int creatorHeight) { private void removeCreatorFromContainer(XCreator creator, int creatorWidth, int creatorHeight) {
@ -271,22 +264,28 @@ public class SelectionModel {
* 其他两层不是靠添加组件就可以编辑的 * 其他两层不是靠添加组件就可以编辑的
*/ */
public boolean hasSelectionComponent() { public boolean hasSelectionComponent() {
XCreator selectionXCreator = selection.getSelectedCreator();
if (designer.getClass().equals(FormDesigner.class)) { if (designer.getClass().equals(FormDesigner.class)) {
//frm本地组件复用 //frm本地组件复用
return selection.getSelectedCreator() != null if (selectionXCreator != null) {
&& !( if (selectionXCreator.getClass().equals(XWAbsoluteBodyLayout.class)) {
//frm绝对布局编辑器 //frm绝对布局编辑器
selection.getSelectedCreator().getClass().equals(XWAbsoluteBodyLayout.class) return false;
} else if (selectionXCreator.getClass().equals(XWCardMainBorderLayout.class)
|| selectionXCreator.getClass().equals(XWCardLayout.class)
|| selectionXCreator.getClass().equals(XWTabFitLayout.class)) {
//Tab布局编辑器 //Tab布局编辑器
|| selection.getSelectedCreator().getClass().equals(XWCardMainBorderLayout.class) return false;
|| selection.getSelectedCreator().getClass().equals(XWCardLayout.class) } else {
|| selection.getSelectedCreator().getClass().equals(XWTabFitLayout.class)
//自适应布局编辑器 //自适应布局编辑器
|| selection.getSelectedCreator().getClass().equals(XWFitLayout.class) return !selectionXCreator.getClass().equals(XWFitLayout.class);
); }
} else {
return false;
}
} else { } else {
//cpt本地组件复用,selection.getSelectedCreator().getParent()=@XWParameterLayout instanceof @XWAbsoluteLayout //cpt本地组件复用,selection.getSelectedCreator().getParent()=@XWParameterLayout instanceof @XWAbsoluteLayout
return selection.getSelectedCreator() != null && selection.getSelectedCreator().getParent() != null; return selectionXCreator != null && selectionXCreator.getParent() != null;
} }
} }
@ -330,11 +329,10 @@ public class SelectionModel {
int x = e.getX() + designer.getArea().getHorizontalValue(); int x = e.getX() + designer.getArea().getHorizontalValue();
int y = e.getY() + designer.getArea().getVerticalValue(); int y = e.getY() + designer.getArea().getVerticalValue();
dir = getDirection(selection.getRelativeBounds(), x, y); dir = getDirection(selection.getRelativeBounds(), x, y);
if (selection.size() == 1) { if (selection.size() == 1 && !ArrayUtils.contains(selection.getSelectedCreator().getDirections(), dir
if (!ArrayUtils.contains(selection.getSelectedCreator().getDirections(), dir.getActual())) { .getActual())) {
dir = Location.outer; dir = Location.outer;
} }
}
} else { } else {
dir = Location.outer; dir = Location.outer;
} }

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

@ -313,7 +313,7 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP
*/ */
public boolean isWithQueryButton() { public boolean isWithQueryButton() {
XLayoutContainer rootContainer = this.getRootComponent(); XLayoutContainer rootContainer = this.getRootComponent();
return SearchQueryCreators(rootContainer); return searchQueryCreators(rootContainer);
} }
/** /**
@ -322,18 +322,18 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP
* @return 同上 * @return 同上
*/ */
public Action[] getActions() { public Action[] getActions() {
if (designer_actions == null) { if (designerActions == null) {
designer_actions = new Action[]{new CutAction(this), new CopyAction(this), new PasteAction(this), designerActions = new Action[]{new CutAction(this), new CopyAction(this), new PasteAction(this),
new FormDeleteAction(this)}; new FormDeleteAction(this)};
} }
return designer_actions; return designerActions;
} }
private boolean SearchQueryCreators(XLayoutContainer rootContainer) { private boolean searchQueryCreators(XLayoutContainer rootContainer) {
boolean b = false; boolean b = false;
for (int i = 0; i < rootContainer.getXCreatorCount(); i++) { for (int i = 0; i < rootContainer.getXCreatorCount(); i++) {
if (rootContainer.getXCreator(i) instanceof XLayoutContainer) { if (rootContainer.getXCreator(i) instanceof XLayoutContainer) {
b = SearchQueryCreators((XLayoutContainer) rootContainer.getXCreator(i)); b = searchQueryCreators((XLayoutContainer) rootContainer.getXCreator(i));
} else if (rootContainer.getXCreator(i) instanceof XFormSubmit) { } else if (rootContainer.getXCreator(i) instanceof XFormSubmit) {
b = true; b = true;
} }

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

@ -1,7 +1,6 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.design.beans.location.MoveUtils;
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.ComponentAdapter;
import com.fr.design.designer.beans.events.DesignerEditor; import com.fr.design.designer.beans.events.DesignerEditor;
@ -31,7 +30,6 @@ import java.awt.event.MouseEvent;
*/ */
public class EditingMouseListener extends MouseInputAdapter { public class EditingMouseListener extends MouseInputAdapter {
private static final int INDEX = 0;
private FormDesigner designer; private FormDesigner designer;
/** /**
@ -56,6 +54,7 @@ public class EditingMouseListener extends MouseInputAdapter {
* 选择模型存储当前选择的组件和剪切板 * 选择模型存储当前选择的组件和剪切板
*/ */
private SelectionModel selectionModel; private SelectionModel selectionModel;
/** /**
* 获取选择模型 * 获取选择模型
* *
@ -65,10 +64,10 @@ public class EditingMouseListener extends MouseInputAdapter {
return selectionModel; return selectionModel;
} }
private XCreator last_creator; private XCreator lastXCreator;
private MouseEvent lastPressEvent; private MouseEvent lastPressEvent;
private DesignerEditor<? extends JComponent> current_editor; private DesignerEditor<? extends JComponent> currentEditor;
private XCreator current_creator; private XCreator currentXCreator;
//备份开始拖动的位置和大小 //备份开始拖动的位置和大小
private Rectangle dragBackupBounds; private Rectangle dragBackupBounds;
@ -113,11 +112,11 @@ public class EditingMouseListener extends MouseInputAdapter {
private void promptWidgetForbidEnter(int x, int y, XLayoutContainer container) { private void promptWidgetForbidEnter(int x, int y, XLayoutContainer container) {
container.setBorder(BorderFactory.createLineBorder(Color.RED, Constants.LINE_MEDIUM)); container.setBorder(BorderFactory.createLineBorder(Color.RED, Constants.LINE_MEDIUM));
int screen_X = (int)designer.getArea().getLocationOnScreen().getX(); int screenX = (int) designer.getArea().getLocationOnScreen().getX();
int screen_Y = (int)designer.getArea().getLocationOnScreen().getY(); int screenY = (int) designer.getArea().getLocationOnScreen().getY();
this.promptWindow.setSize(promptWindow.getPreferredSize()); this.promptWindow.setSize(promptWindow.getPreferredSize());
this.promptWindow.setPreferredSize(promptWindow.getPreferredSize()); this.promptWindow.setPreferredSize(promptWindow.getPreferredSize());
promptWindow.setLocation(screen_X + x + GAP, screen_Y + y + GAP); promptWindow.setLocation(screenX + x + GAP, screenY + y + GAP);
promptWindow.setVisible(true); promptWindow.setVisible(true);
} }
@ -129,6 +128,7 @@ public class EditingMouseListener extends MouseInputAdapter {
/** /**
* 按下 * 按下
*
* @param e 鼠标事件 * @param e 鼠标事件
*/ */
public void mousePressed(MouseEvent e) { public void mousePressed(MouseEvent e) {
@ -139,9 +139,7 @@ public class EditingMouseListener extends MouseInputAdapter {
// 获取焦点,以便获取热键 // 获取焦点,以便获取热键
designer.requestFocus(); designer.requestFocus();
} }
if (e.isPopupTrigger()) { if (e.getButton() == MouseEvent.BUTTON1) {
// 为触发上下文菜单预留
} else if (e.getButton() == MouseEvent.BUTTON1) {
Direction dir = selectionModel.getDirectionAt(e); Direction dir = selectionModel.getDirectionAt(e);
if (!BaseUtils.isAuthorityEditing()) { if (!BaseUtils.isAuthorityEditing()) {
@ -157,7 +155,7 @@ public class EditingMouseListener extends MouseInputAdapter {
designer.getArea().getHorizontalValue() + e.getX(), designer.getArea().getHorizontalValue() + e.getX(),
designer.getArea().getVerticalValue() + e.getY())) { designer.getArea().getVerticalValue() + e.getY())) {
lastPressEvent = e; lastPressEvent = e;
last_creator = selectionModel.getSelection().getSelectedCreator(); lastXCreator = selectionModel.getSelection().getSelectedCreator();
} else { } else {
stateModel.startSelecting(e); stateModel.startSelecting(e);
} }
@ -170,6 +168,7 @@ public class EditingMouseListener extends MouseInputAdapter {
/** /**
* 释放 * 释放
*
* @param e 鼠标事件 * @param e 鼠标事件
*/ */
public void mouseReleased(MouseEvent e) { public void mouseReleased(MouseEvent e) {
@ -192,7 +191,7 @@ public class EditingMouseListener extends MouseInputAdapter {
} }
} }
lastPressEvent = null; lastPressEvent = null;
last_creator = null; lastXCreator = null;
} }
private void mouseDraggingRelease(MouseEvent e) { private void mouseDraggingRelease(MouseEvent e) {
@ -202,7 +201,6 @@ public class EditingMouseListener extends MouseInputAdapter {
XCreator selectionXCreator = designer.getSelectionModel().getSelection().getSelectedCreator(); XCreator selectionXCreator = designer.getSelectionModel().getSelection().getSelectedCreator();
if (selectionXCreator != null) { if (selectionXCreator != null) {
selectionXCreator.setBounds(dragBackupBounds.x, dragBackupBounds.y, dragBackupBounds.width, dragBackupBounds.height); selectionXCreator.setBounds(dragBackupBounds.x, dragBackupBounds.y, dragBackupBounds.width, dragBackupBounds.height);
// MoveUtils.hideForbidWindow();
} }
} }
dragBackupBounds = null; dragBackupBounds = null;
@ -231,17 +229,14 @@ public class EditingMouseListener extends MouseInputAdapter {
} }
/** /**
* 激活上下文菜单待完善 * TODO 激活上下文菜单待完善
* 6.56暂时不支持右键 bugid 8777 * 6.56暂时不支持右键 bugid 8777
*/ */
private void trigger_popup(MouseEvent e) { private void triggerPopup(MouseEvent e) {
XCreator creator = selectionModel.getSelection().getSelectedCreator(); XCreator creator = selectionModel.getSelection().getSelectedCreator();
if (creator == null) { if (creator == null) {
return; return;
} }
JPopupMenu popupMenu = null; JPopupMenu popupMenu = null;
ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, creator); ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, creator);
popupMenu = adapter.getContextPopupMenu(e); popupMenu = adapter.getContextPopupMenu(e);
@ -255,6 +250,7 @@ public class EditingMouseListener extends MouseInputAdapter {
/** /**
* 移动 * 移动
*
* @param e 鼠标事件 * @param e 鼠标事件
*/ */
public void mouseMoved(MouseEvent e) { public void mouseMoved(MouseEvent e) {
@ -409,6 +405,7 @@ public class EditingMouseListener extends MouseInputAdapter {
/** /**
* 拖拽 * 拖拽
*
* @param e 鼠标事件 * @param e 鼠标事件
*/ */
public void mouseDragged(MouseEvent e) { public void mouseDragged(MouseEvent e) {
@ -446,13 +443,13 @@ public class EditingMouseListener extends MouseInputAdapter {
// 如果是拖拽选择区域状态,则更新选择区域 // 如果是拖拽选择区域状态,则更新选择区域
stateModel.changeSelection(e); stateModel.changeSelection(e);
} else { } else {
if ((lastPressEvent == null) || (last_creator == null)) { if ((lastPressEvent == null) || (lastXCreator == null)) {
return; return;
} }
if (e.getPoint().distance(lastPressEvent.getPoint()) > minDragSize) { if (e.getPoint().distance(lastPressEvent.getPoint()) > minDragSize) {
//参数面板和自适应布局不支持拖拽 //参数面板和自适应布局不支持拖拽
if (last_creator.isSupportDrag()){ if (lastXCreator.isSupportDrag()) {
designer.startDraggingComponent(last_creator, lastPressEvent, e.getX(), e.getY()); designer.startDraggingComponent(lastXCreator, lastPressEvent, e.getX(), e.getY());
} }
e.consume(); e.consume();
lastPressEvent = null; lastPressEvent = null;
@ -483,7 +480,7 @@ public class EditingMouseListener extends MouseInputAdapter {
} }
private boolean isCreatorInLayout(XCreator creator, XCreator layout) { private boolean isCreatorInLayout(XCreator creator, XCreator layout) {
if (creator == layout){ if (creator.equals(layout)) {
return true; return true;
} }
if (layout.getParent() != null) { if (layout.getParent() != null) {
@ -495,7 +492,8 @@ public class EditingMouseListener extends MouseInputAdapter {
private XCreator processTopLayoutMouseClick(XCreator creator) { private XCreator processTopLayoutMouseClick(XCreator creator) {
XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer(creator).getTopLayout(); XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer(creator).getTopLayout();
if (topLayout != null) { if (topLayout != null) {
if (clickTopLayout != null && clickTopLayout != topLayout && !isCreatorInLayout(clickTopLayout, topLayout)){ if (clickTopLayout != null && !clickTopLayout.equals(topLayout) && !isCreatorInLayout(clickTopLayout,
topLayout)) {
clickTopLayout.setEditable(false); clickTopLayout.setEditable(false);
setTopLayoutUnEditable(clickTopLayout, topLayout); setTopLayoutUnEditable(clickTopLayout, topLayout);
} }
@ -503,8 +501,7 @@ public class EditingMouseListener extends MouseInputAdapter {
if (!topLayout.isEditable()) { if (!topLayout.isEditable()) {
creator = topLayout; creator = topLayout;
} }
} } else {
else{
if (clickTopLayout != null) { if (clickTopLayout != null) {
clickTopLayout.setEditable(false); clickTopLayout.setEditable(false);
setTopLayoutUnEditable(clickTopLayout, null); setTopLayoutUnEditable(clickTopLayout, null);
@ -513,8 +510,10 @@ public class EditingMouseListener extends MouseInputAdapter {
return creator; return creator;
} }
/** /**
* 点击 * 点击
*
* @param e 鼠标事件 * @param e 鼠标事件
*/ */
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
@ -534,9 +533,9 @@ public class EditingMouseListener extends MouseInputAdapter {
} }
/** /**
* 离开 * 离开
*
* @param e 鼠标事件 * @param e 鼠标事件
*/ */
public void mouseExited(MouseEvent e) { public void mouseExited(MouseEvent e) {
@ -551,6 +550,7 @@ public class EditingMouseListener extends MouseInputAdapter {
/** /**
* 开始编辑 * 开始编辑
*
* @param creator 容器 * @param creator 容器
* @param designerEditor 设计器 * @param designerEditor 设计器
* @param adapter 适配器 * @param adapter 适配器
@ -558,8 +558,8 @@ public class EditingMouseListener extends MouseInputAdapter {
public void startEditing(XCreator creator, DesignerEditor<? extends JComponent> designerEditor, ComponentAdapter adapter) { public void startEditing(XCreator creator, DesignerEditor<? extends JComponent> designerEditor, ComponentAdapter adapter) {
if (designerEditor != null) { if (designerEditor != null) {
Rectangle rect = ComponentUtils.getRelativeBounds(creator); Rectangle rect = ComponentUtils.getRelativeBounds(creator);
current_editor = designerEditor; currentEditor = designerEditor;
current_creator = creator; currentXCreator = creator;
Rectangle bounds = new Rectangle(1, 1, creator.getWidth() - 2, creator.getHeight() - 2); Rectangle bounds = new Rectangle(1, 1, creator.getWidth() - 2, creator.getHeight() - 2);
bounds.x += (rect.x - designer.getArea().getHorizontalValue()); bounds.x += (rect.x - designer.getArea().getHorizontalValue());
bounds.y += (rect.y - designer.getArea().getVerticalValue()); bounds.y += (rect.y - designer.getArea().getVerticalValue());
@ -574,22 +574,23 @@ public class EditingMouseListener extends MouseInputAdapter {
/** /**
* 停止编辑 * 停止编辑
*
* @return 是否编辑成功 * @return 是否编辑成功
*/ */
public boolean stopEditing() { public boolean stopEditing() {
if (current_editor != null) { if (currentEditor != null) {
designer.remove(current_editor.getEditorTarget()); designer.remove(currentEditor.getEditorTarget());
current_editor.fireEditStoped(); currentEditor.fireEditStoped();
Container container = current_creator.getParent(); Container container = currentXCreator.getParent();
if (container != null) { if (container != null) {
LayoutUtils.layoutRootContainer(container); LayoutUtils.layoutRootContainer(container);
} }
designer.invalidate(); designer.invalidate();
designer.repaint(); designer.repaint();
current_creator = null; currentXCreator = null;
current_editor = null; currentEditor = null;
return true; return true;
} }
return true; return true;
@ -599,22 +600,22 @@ public class EditingMouseListener extends MouseInputAdapter {
* 重置编辑控件大小 * 重置编辑控件大小
*/ */
public void resetEditorComponentBounds() { public void resetEditorComponentBounds() {
if (current_editor == null) { if (currentEditor == null) {
return; return;
} }
if (current_creator.getParent() == null) { if (currentXCreator.getParent() == null) {
stopEditing(); stopEditing();
return; return;
} }
Rectangle rect = ComponentUtils.getRelativeBounds(current_creator); Rectangle rect = ComponentUtils.getRelativeBounds(currentXCreator);
Rectangle bounds = new Rectangle(1, 1, current_creator.getWidth() - 2, current_creator.getHeight() - 2); Rectangle bounds = new Rectangle(1, 1, currentXCreator.getWidth() - 2, currentXCreator.getHeight() - 2);
bounds.x += (rect.x - designer.getArea().getHorizontalValue()); bounds.x += (rect.x - designer.getArea().getHorizontalValue());
bounds.y += (rect.y - designer.getArea().getVerticalValue()); bounds.y += (rect.y - designer.getArea().getVerticalValue());
if (current_creator instanceof XEditorHolder) { if (currentXCreator instanceof XEditorHolder) {
ToolTipEditor.getInstance().resetBounds((XEditorHolder) current_creator, bounds, current_editor.getEditorTarget().getBounds()); ToolTipEditor.getInstance().resetBounds((XEditorHolder) currentXCreator, bounds, currentEditor.getEditorTarget().getBounds());
} }
current_editor.getEditorTarget().setBounds(bounds); currentEditor.getEditorTarget().setBounds(bounds);
} }
} }

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

@ -46,7 +46,6 @@ import com.fr.form.ui.container.WFitLayout;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger; import com.fr.general.FRLogger;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.plugin.ExtraClassManager;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.bridge.StableFactory; import com.fr.stable.bridge.StableFactory;
@ -72,7 +71,6 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
protected static final ArrayList<String> NAME_ARRAY_LIST = new ArrayList<String>( protected static final ArrayList<String> NAME_ARRAY_LIST = new ArrayList<String>(
Arrays.asList(new String[]{Inter.getLocText("M_Edit-Cut"), Inter.getLocText("M_Edit-Copy"), Inter.getLocText("M_Edit-Delete")}) Arrays.asList(new String[]{Inter.getLocText("M_Edit-Cut"), Inter.getLocText("M_Edit-Copy"), Inter.getLocText("M_Edit-Delete")})
); );
private static final int BORDER_WIDTH = 6;
//底层容器的默认大小 //底层容器的默认大小
protected static final Dimension LARGE_PREFERRED_SIZE = new Dimension(WBorderLayout.DEFAULT_WIDTH, WBorderLayout.DEFAULT_HEIGHT); protected static final Dimension LARGE_PREFERRED_SIZE = new Dimension(WBorderLayout.DEFAULT_WIDTH, WBorderLayout.DEFAULT_HEIGHT);
private int paraHeight = 0; private int paraHeight = 0;
@ -84,7 +82,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
private XLayoutContainer paraComponent; private XLayoutContainer paraComponent;
private boolean drawLineMode; private boolean drawLineMode;
private FormArea formArea; private FormArea formArea;
private ConnectorHelper ConnectorHelper; private ConnectorHelper connectorHelper;
private boolean isReportBlockEditing = false; private boolean isReportBlockEditing = false;
//组件重叠 //组件重叠
@ -107,7 +105,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
// 编辑状态的事件表 // 编辑状态的事件表
private CreatorEventListenerTable edit; private CreatorEventListenerTable edit;
protected Action[] designer_actions; protected Action[] designerActions;
private FormDesignerModeForSpecial<?> desigerMode; private FormDesignerModeForSpecial<?> desigerMode;
private Action switchAction; private Action switchAction;
private FormElementCaseContainerProvider elementCaseContainer; private FormElementCaseContainerProvider elementCaseContainer;
@ -763,13 +761,10 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
* @param e 鼠标事件 * @param e 鼠标事件
*/ */
public void updateDrawLineMode(MouseEvent e) { public void updateDrawLineMode(MouseEvent e) {
Point p = ConnectorHelper.getNearWidgetPoint(e); Point p = connectorHelper.getNearWidgetPoint(e);
if (p == null) { if (p == null && getComponentAt(e) == rootComponent) {
XComponent comp = getComponentAt(e);
if (comp == rootComponent) {
p = new Point(e.getX() + formArea.getHorizontalValue(), e.getY() + formArea.getVerticalValue()); p = new Point(e.getX() + formArea.getHorizontalValue(), e.getY() + formArea.getVerticalValue());
} }
}
stateModel.startDrawLine(p); stateModel.startDrawLine(p);
} }
@ -1120,11 +1115,11 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
* @return 同上 * @return 同上
*/ */
public Action[] getActions() { public Action[] getActions() {
if (designer_actions == null) { if (designerActions == null) {
designer_actions = new Action[]{new CutAction(this), new CopyAction(this), new PasteAction(this), designerActions = new Action[]{new CutAction(this), new CopyAction(this), new PasteAction(this),
new FormDeleteAction(this)}; new FormDeleteAction(this)};
} }
return designer_actions; return designerActions;
} }
protected Border getOuterBorder() { protected Border getOuterBorder() {
@ -1191,7 +1186,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
* @return ConnectorHelper类 * @return ConnectorHelper类
*/ */
public ConnectorHelper getDrawLineHelper() { public ConnectorHelper getDrawLineHelper() {
return ConnectorHelper; return connectorHelper;
} }
/** /**

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

@ -204,14 +204,14 @@ public class FormSelectionUtils {
private static ArrayList<XCreator> rebuildSelection(XCreator rootComponent, List<Widget> selectionWidget, private static ArrayList<XCreator> rebuildSelection(XCreator rootComponent, List<Widget> selectionWidget,
ArrayList<XCreator> newSelection) { ArrayList<XCreator> newSelection) {
FormSelectionUtils._rebuild(rootComponent, selectionWidget, newSelection); FormSelectionUtils.rebuild(rootComponent, selectionWidget, newSelection);
if (newSelection.isEmpty()) { if (newSelection.isEmpty()) {
newSelection.add(rootComponent); newSelection.add(rootComponent);
} }
return newSelection; return newSelection;
} }
private static void _rebuild(XCreator root, List<Widget> selectionWidget, List<XCreator> newSelection) { private static void rebuild(XCreator root, List<Widget> selectionWidget, List<XCreator> newSelection) {
if (selectionWidget.isEmpty()) { if (selectionWidget.isEmpty()) {
return; return;
} }
@ -238,7 +238,7 @@ public class FormSelectionUtils {
} }
} }
if (c instanceof XLayoutContainer) { if (c instanceof XLayoutContainer) {
_rebuild((XLayoutContainer) c, selectionWidget, newSelection); rebuild((XLayoutContainer) c, selectionWidget, newSelection);
} }
} }
} }

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

@ -43,7 +43,6 @@ import com.fr.form.FormElementCaseProvider;
import com.fr.form.main.Form; import com.fr.form.main.Form;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WBorderLayout; import com.fr.form.ui.container.WBorderLayout;
import com.fr.form.ui.container.WFitLayout;
import com.fr.form.ui.container.WLayout; import com.fr.form.ui.container.WLayout;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger; import com.fr.general.FRLogger;

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

@ -36,7 +36,7 @@ public class MobileWidgetTable extends JTable {
private static final int WIDGET_TABLE_ROW_HEIGHT = 22; private static final int WIDGET_TABLE_ROW_HEIGHT = 22;
private UILabel moveComponent = new UILabel(); // 作为拖动时候随鼠标移动的那个半透明控件 private UILabel moveComponent = new UILabel(); // 作为拖动时候随鼠标移动的那个半透明控件
private int selectedRow = -1; private int selectedRow = -1;
private int GAP = 11; private static final int GAP = 11;
private boolean draging = false; private boolean draging = false;
private boolean collapsed = false; // 控件列表是否折叠 private boolean collapsed = false; // 控件列表是否折叠
@ -334,6 +334,7 @@ public class MobileWidgetTable extends JTable {
/** /**
* 是否可编辑 * 是否可编辑
*
* @param row 行号 * @param row 行号
* @param column 列号 * @param column 列号
* @return 是否可编辑 * @return 是否可编辑

Loading…
Cancel
Save