Browse Source

绝对布局测试bug修改2

master
zhouping 8 years ago
parent
commit
de754516cc
  1. 10
      designer/src/com/fr/poly/hanlder/BottomCornerMouseHanlder.java
  2. 22
      designer_base/src/com/fr/design/beans/location/MoveUtils.java
  3. 34
      designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java
  4. 4
      designer_form/src/com/fr/design/designer/beans/location/AccessDirection.java
  5. 10
      designer_form/src/com/fr/design/designer/beans/location/Inner.java
  6. 7
      designer_form/src/com/fr/design/designer/beans/models/AddingModel.java
  7. 8
      designer_form/src/com/fr/design/designer/creator/XCreator.java
  8. 20
      designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java
  9. 5
      designer_form/src/com/fr/design/designer/creator/XWParameterLayout.java
  10. 2
      designer_form/src/com/fr/design/form/parameter/XFormSubmit.java
  11. 2
      designer_form/src/com/fr/design/gui/core/FormWidgetOption.java
  12. 18
      designer_form/src/com/fr/design/mainframe/FormCreatorDropTarget.java

10
designer/src/com/fr/poly/hanlder/BottomCornerMouseHanlder.java

@ -183,6 +183,16 @@ public class BottomCornerMouseHanlder extends MouseInputAdapter {
public Point getDesignerLocationOnScreen() {
return null;
}
@Override
public int getDesignerScrollVerticalValue() {
return 0;
}
@Override
public int getDesignerScrollHorizontalValue() {
return 0;
}
};
private RectangleIterator getRectangleIt(){

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

@ -3,8 +3,6 @@
*/
package com.fr.design.beans.location;
import com.fr.stable.ArrayUtils;
import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
@ -98,6 +96,18 @@ public class MoveUtils {
* @param line 吸附线
*/
void setEquidistantLine(Absorptionline line);
/**
* 获取设计器垂直滚动条的值
* @return 滚动条的值
*/
int getDesignerScrollVerticalValue();
/**
* 获取设计器水平滚动条的值
* @return 滚动条的值
*/
int getDesignerScrollHorizontalValue();
}
public interface RectangleIterator {
@ -457,7 +467,13 @@ public class MoveUtils {
right = equidistantLines.get(i).getReference();
}
}
line = Absorptionline.createEquidistantAbsorptionline(operatingRectangle, top, left, bottom, right);
operatingRectangle.x -= designer.getDesignerScrollHorizontalValue();
operatingRectangle.y -= designer.getDesignerScrollVerticalValue();
line = Absorptionline.createEquidistantAbsorptionline(operatingRectangle,
top - designer.getDesignerScrollVerticalValue(),
left - designer.getDesignerScrollHorizontalValue(),
bottom - designer.getDesignerScrollVerticalValue(),
right - designer.getDesignerScrollHorizontalValue());
}
designer.setEquidistantLine(line);
}

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

@ -46,6 +46,10 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
* @param y 坐标y
* @return 能则返回true
*/
//这个地方的逻辑非常复杂,
// 1.当前绝对布局是不可编辑且是最外层,那么其他控件添加在它周围,
// 2.当前绝对布局是不可编辑且不是最外层,那么控件不可添加,(嵌套)
// 3.当前绝对布局可编辑,那么控件添加
@Override
public boolean accept(XCreator creator, int x, int y) {
Component comp = container.getComponentAt(x, y);
@ -55,11 +59,29 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
if (comp == null){
return false;
}
//判断下组件能不能拖入绝对布局
if (!creator.canEnterIntoAbsolutePane()){
return false;
}
XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer((XCreator)comp).getTopLayout();
if(topLayout != null){
if (topLayout.isEditable()){
//判断有没有和当前控件重叠
Rectangle curRec = new Rectangle(x, y, creator.getWidth(), creator.getHeight());
//先计算当前控件的位置
int creatorX, creatorY;
if (XCreatorUtils.getParentXLayoutContainer(creator) != null) {
Rectangle creatorRectangle = ComponentUtils.getRelativeBounds(creator);
creatorX = creatorRectangle.x;
creatorY = creatorRectangle.y;
} else {
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++) {
WAbsoluteLayout.BoundsWidget temp = (WAbsoluteLayout.BoundsWidget) wAbsoluteLayout.getWidget(i);
@ -68,9 +90,19 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
return false;
}
}
if (creatorX < 0
|| creatorX + creator.getWidth() > container.getWidth()
|| creatorY < 0
|| creatorY + creator.getHeight() > container.getHeight()) {
return false;
}
return x >= 0 && y >= 0 && creator.getHeight() <= container.getHeight()
&& creator.getWidth() <= container.getWidth();
}
//绝对布局嵌套,处于内层,不可编辑,不添加,topLayout只能获取到最外层可编辑的布局
else if (((XLayoutContainer)topLayout.getParent()).acceptType(XWAbsoluteLayout.class)) {
return false;
}
else {
return acceptWidget(creator, x, y);
}

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

@ -53,9 +53,9 @@ public abstract class AccessDirection implements Direction {
//参数面板可以无下限拉长
if (y < 0) {
y = 0;
} else if (y > designer.getRootComponent().getHeight() && designer.getSelectionModel().hasSelectionComponent()
} else if (y > designer.getRootComponent().getHeight() + designer.getParaHeight() && designer.getSelectionModel().hasSelectionComponent()
&& !designer.getSelectionModel().getSelection().getSelectedCreator().acceptType(XWParameterLayout.class)) {
y = designer.getRootComponent().getHeight();
y = designer.getRootComponent().getHeight() + designer.getParaHeight();
}
return new Point(x, y);
}

10
designer_form/src/com/fr/design/designer/beans/location/Inner.java

@ -119,6 +119,16 @@ public class Inner extends AccessDirection {
public void setEquidistantLine(Absorptionline line) {
designer.getStateModel().setEquidistantLine(line);
}
@Override
public int getDesignerScrollHorizontalValue() {
return designer.getArea().getHorizontalValue();
}
@Override
public int getDesignerScrollVerticalValue() {
return designer.getArea().getVerticalValue();
}
};
//判断当前操作的是不是参数面板,要特殊处理
boolean isParameterLayout = ((XCreator)(designer.getSelectionModel().getSelection().getSelectedCreator().getParent())).acceptType(XWParameterLayout.class);

7
designer_form/src/com/fr/design/designer/beans/models/AddingModel.java

@ -2,6 +2,7 @@ package com.fr.design.designer.beans.models;
import java.awt.Rectangle;
import com.fr.design.designer.creator.XWAbsoluteLayout;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter;
@ -115,6 +116,12 @@ public class AddingModel {
* @return 成功返回true
*/
public boolean add2Container(FormDesigner designer, XLayoutContainer container, int x, int y) {
//考虑不同布局嵌套的情况,获取顶层容器
XLayoutContainer xLayoutContainer = container.getTopLayout();
if(xLayoutContainer != null && xLayoutContainer.acceptType(XWAbsoluteLayout.class)){
container = xLayoutContainer;
}
Rectangle rect = ComponentUtils.getRelativeBounds(container);
if(!ComparatorUtils.equals(container.getOuterLayout(), container.getBackupParent())){
return added = container.getLayoutAdapter().addBean(creator,x,y);

8
designer_form/src/com/fr/design/designer/creator/XCreator.java

@ -316,6 +316,14 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
return true;
}
/**
* 该组件是否可以拖入绝对布局
* @return 是则返回true
*/
public boolean canEnterIntoAbsolutePane() {
return true;
}
/**
* 该组件是否可以拖拽(表单中参数面板和自适应布局不可以拖拽)
* @return 是则返回true

20
designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java

@ -78,6 +78,16 @@ public class XWAbsoluteLayout extends XLayoutContainer {
initPercent();
}
/**
* 初始化时默认的组件大小
*
* @return 默认Dimension
*/
@Override
public Dimension initEditorSize() {
return new Dimension(500, 300);
}
//根据屏幕大小来确定显示的百分比, 1440*900默认100%, 1366*768缩放90%
private void initPercent(){
Toolkit toolkit = Toolkit.getDefaultToolkit();
@ -155,6 +165,9 @@ public class XWAbsoluteLayout extends XLayoutContainer {
if (xCreator.hasTitleStyle()) {
xCreator = (XLayoutContainer)xCreator.getParent();
}
if (xCreator.acceptType(XWAbsoluteLayout.class)){
((XWAbsoluteLayout) xCreator).updateBoundsWidget();
}
BoundsWidget boundsWidget = layout.getBoundsWidget(xCreator.toData());
Rectangle rectangle = dealWidgetBound(xCreator.getBounds());
}
@ -186,6 +199,11 @@ public class XWAbsoluteLayout extends XLayoutContainer {
Rectangle rec = calculateBound(wgtBound, percentW, percentH);
wgt.setBounds(rec);
creator.setBounds(rec);
//绝对布局嵌套,要更新内部的绝对布局
if (creator.acceptType(XWAbsoluteLayout.class)){
creator.setBackupBound(wgtBound);
((XWAbsoluteLayout) creator).updateBoundsWidget();
}
}
}
}
@ -223,7 +241,7 @@ public class XWAbsoluteLayout extends XLayoutContainer {
@Override
protected String getIconName() {
return "layout_absolute.png";
return "layout_absolute_new.png";
}
/**

5
designer_form/src/com/fr/design/designer/creator/XWParameterLayout.java

@ -190,4 +190,9 @@ public class XWParameterLayout extends XWAbsoluteLayout {
@Override
public void updateBoundsWidget() {
}
@Override
protected String getIconName() {
return "layout_absolute.png";
}
}

2
designer_form/src/com/fr/design/form/parameter/XFormSubmit.java

@ -1 +1 @@
package com.fr.design.form.parameter; import com.fr.design.designer.creator.XButton; import com.fr.design.designer.creator.XCreator; import com.fr.form.parameter.FormSubmitButton; import java.awt.*; /** * 提交按钮 * @editor zhou * @since 2012-3-23下午3:36:00 */ public class XFormSubmit extends XButton { public XFormSubmit(FormSubmitButton widget, Dimension initSize) { super(widget, initSize); } /** * 是否有查询按钮 * @param xCreator 控件或容器 * @return 有无查询按钮 */ public boolean SearchQueryCreators(XCreator xCreator) { return true; } /** * 该组件是否可以拖入表单主体 * @return 是则返回true */ public boolean canEnterIntoAdaptPane(){ return false; } @Override protected String getIconName() { return "preview_16.png"; } }
package com.fr.design.form.parameter; import com.fr.design.designer.creator.XButton; import com.fr.design.designer.creator.XCreator; import com.fr.form.parameter.FormSubmitButton; import java.awt.*; /** * 提交按钮 * @editor zhou * @since 2012-3-23下午3:36:00 */ public class XFormSubmit extends XButton { public XFormSubmit(FormSubmitButton widget, Dimension initSize) { super(widget, initSize); } /** * 是否有查询按钮 * @param xCreator 控件或容器 * @return 有无查询按钮 */ public boolean SearchQueryCreators(XCreator xCreator) { return true; } /** * 该组件是否可以拖入表单主体 * @return 是则返回true */ public boolean canEnterIntoAdaptPane(){ return false; } /** * 该组件是否可以拖入绝对布局 * * @return 是则返回true */ @Override public boolean canEnterIntoAbsolutePane() { return false; } @Override protected String getIconName() { return "preview_16.png"; } }

2
designer_form/src/com/fr/design/gui/core/FormWidgetOption.java

@ -1 +1 @@
package com.fr.design.gui.core; import javax.swing.Icon; import com.fr.base.BaseUtils; import com.fr.form.ui.ElementCaseEditor; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WBorderLayout; import com.fr.form.ui.container.WCardLayout; import com.fr.form.ui.container.WFitLayout; import com.fr.form.ui.container.WHorizontalBoxLayout; import com.fr.form.ui.container.WParameterLayout; import com.fr.form.ui.container.WVerticalBoxLayout; import com.fr.general.Inter; /** * Author : Shockway * Date: 13-6-17 * Time: 上午10:40 */ public class FormWidgetOption extends WidgetOption { /** * 返回名字 * @return 名字 */ @Override public String optionName() { return null; } /** * 返回图标 * @return 图标 */ @Override public Icon optionIcon() { return null; } /** * 组件类 * @return 类 */ @Override public Class<? extends Widget> widgetClass() { return null; } /** * 返回组件 * @return 控件 */ @Override public Widget createWidget() { return null; } /* * 表单容器 */ public static WidgetOption[] getFormContainerInstance() { return new WidgetOption[] { ABSOLUTELAYOUTCONTAINER, BORDERLAYOUTCONTAINER, HORIZONTALBOXLAYOUTCONTAINER, VERTICALBOXLAYOUTCONTAINER, CARDLAYOUTCONTAINER, FITLAYOUTCONTAINER }; } /** * 表单工具栏上的布局 * @return 控件 */ public static WidgetOption[] getFormLayoutInstance() { return new WidgetOption[] {CARDLAYOUTCONTAINER, ABSOLUTELAYOUTCONTAINER}; } public static final WidgetOption ABSOLUTELAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_AbsoluteLayout"), BaseUtils.readIcon("/com/fr/web/images/form/resources/layout_absolute.png"), WAbsoluteLayout.class); public static final WidgetOption BORDERLAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_BorderLayout"), BaseUtils.readIcon("/com/fr/web/images/form/resources/layout_border.png"), WBorderLayout.class); public static final WidgetOption CARDLAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_CardLayout"), BaseUtils.readIcon("/com/fr/web/images/form/resources/card_layout_16.png"), WCardLayout.class); public static final WidgetOption HORIZONTALBOXLAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_Layout-HBox"), BaseUtils.readIcon("/com/fr/web/images/form/resources/boxlayout_h_16.png"), WHorizontalBoxLayout.class); public static final WidgetOption VERTICALBOXLAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_VerticalBoxLayout"), BaseUtils.readIcon("/com/fr/web/images/form/resources/boxlayout_v_16.png"), WVerticalBoxLayout.class); public static final WidgetOption FITLAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter.getLocText("FR-Designer-Layout_Adaptive_Layout"), BaseUtils.readIcon("/com/fr/web/images/form/resources/boxlayout_v_16.png"), WFitLayout.class); public static final WidgetOption PARAMETERCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_Para-Body"), BaseUtils.readIcon("/com/fr/web/images/form/resources/layout_parameter.png"), WParameterLayout.class); public static final WidgetOption ELEMENTCASE = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_Form-Report"), BaseUtils.readIcon("/com/fr/web/images/form/resources/report_16.png"), ElementCaseEditor.class); }
package com.fr.design.gui.core; import javax.swing.Icon; import com.fr.base.BaseUtils; import com.fr.form.ui.ElementCaseEditor; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WBorderLayout; import com.fr.form.ui.container.WCardLayout; import com.fr.form.ui.container.WFitLayout; import com.fr.form.ui.container.WHorizontalBoxLayout; import com.fr.form.ui.container.WParameterLayout; import com.fr.form.ui.container.WVerticalBoxLayout; import com.fr.general.Inter; /** * Author : Shockway * Date: 13-6-17 * Time: 上午10:40 */ public class FormWidgetOption extends WidgetOption { /** * 返回名字 * @return 名字 */ @Override public String optionName() { return null; } /** * 返回图标 * @return 图标 */ @Override public Icon optionIcon() { return null; } /** * 组件类 * @return 类 */ @Override public Class<? extends Widget> widgetClass() { return null; } /** * 返回组件 * @return 控件 */ @Override public Widget createWidget() { return null; } /* * 表单容器 */ public static WidgetOption[] getFormContainerInstance() { return new WidgetOption[] { ABSOLUTELAYOUTCONTAINER, BORDERLAYOUTCONTAINER, HORIZONTALBOXLAYOUTCONTAINER, VERTICALBOXLAYOUTCONTAINER, CARDLAYOUTCONTAINER, FITLAYOUTCONTAINER }; } /** * 表单工具栏上的布局 * @return 控件 */ public static WidgetOption[] getFormLayoutInstance() { return new WidgetOption[] {CARDLAYOUTCONTAINER, ABSOLUTELAYOUTCONTAINER}; } public static final WidgetOption ABSOLUTELAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_AbsoluteLayout"), BaseUtils.readIcon("/com/fr/web/images/form/resources/layout_absolute_new.png"), WAbsoluteLayout.class); public static final WidgetOption BORDERLAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_BorderLayout"), BaseUtils.readIcon("/com/fr/web/images/form/resources/layout_border.png"), WBorderLayout.class); public static final WidgetOption CARDLAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_CardLayout"), BaseUtils.readIcon("/com/fr/web/images/form/resources/card_layout_16.png"), WCardLayout.class); public static final WidgetOption HORIZONTALBOXLAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_Layout-HBox"), BaseUtils.readIcon("/com/fr/web/images/form/resources/boxlayout_h_16.png"), WHorizontalBoxLayout.class); public static final WidgetOption VERTICALBOXLAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_VerticalBoxLayout"), BaseUtils.readIcon("/com/fr/web/images/form/resources/boxlayout_v_16.png"), WVerticalBoxLayout.class); public static final WidgetOption FITLAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter.getLocText("FR-Designer-Layout_Adaptive_Layout"), BaseUtils.readIcon("/com/fr/web/images/form/resources/boxlayout_v_16.png"), WFitLayout.class); public static final WidgetOption PARAMETERCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_Para-Body"), BaseUtils.readIcon("/com/fr/web/images/form/resources/layout_parameter.png"), WParameterLayout.class); public static final WidgetOption ELEMENTCASE = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_Form-Report"), BaseUtils.readIcon("/com/fr/web/images/form/resources/report_16.png"), ElementCaseEditor.class); }

18
designer_form/src/com/fr/design/mainframe/FormCreatorDropTarget.java

@ -20,11 +20,7 @@ import com.fr.design.designer.beans.HoverPainter;
import com.fr.design.designer.beans.Painter;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.beans.models.AddingModel;
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.gui.ibutton.UIButton;
import com.fr.design.icon.IconPathConstants;
@ -135,8 +131,16 @@ public class FormCreatorDropTarget extends DropTarget {
// 取消前一个焦点容器的提示渲染器
designer.setPainter(null);
}
painter = AdapterBus.getContainerPainter(designer, container);
//获取painter的时候要考虑布局之间嵌套的问题
XLayoutContainer xLayoutContainer = container.getTopLayout();
if (xLayoutContainer != null && xLayoutContainer.getParent() != null
&& ((XLayoutContainer)xLayoutContainer.getParent()).acceptType(XWAbsoluteLayout.class)){
if(!xLayoutContainer.isEditable()){
xLayoutContainer = (XLayoutContainer)xLayoutContainer.getParent();
}
}
painter = AdapterBus.getContainerPainter(designer,
xLayoutContainer != null && xLayoutContainer.acceptType(XWAbsoluteLayout.class) ? xLayoutContainer : container);
// 为界面设计器设置提示渲染提示器
designer.setPainter(painter);

Loading…
Cancel
Save