Browse Source

Merge pull request #386 in BA/design from ~ZHOUPING/design:dev to dev

* commit 'facf2abffe6f6e496c012deb2ced988e555145a2':
  REPORT-533 表单初始化布局新功能 bugfix: 1.抽出一个类extends absolute 2.代码质量 3.初始化布局的测试bug
master
superman 8 years ago
parent
commit
507dccceec
  1. BIN
      designer_base/src/com/fr/design/images/control/combobox.png
  2. 30
      designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteBodyLayoutAdapter.java
  3. 11
      designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java
  4. 1
      designer_form/src/com/fr/design/designer/creator/XCreatorUtils.java
  5. 45
      designer_form/src/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java
  6. 24
      designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java
  7. 5
      designer_form/src/com/fr/design/designer/properties/AbsoluteStateRenderer.java
  8. 23
      designer_form/src/com/fr/design/designer/properties/BodyLayoutAttrRenderer.java
  9. 239
      designer_form/src/com/fr/design/designer/properties/FRAbsoluteBodyLayoutPropertiesGroupModel.java
  10. 192
      designer_form/src/com/fr/design/designer/properties/FRAbsoluteLayoutPropertiesGroupModel.java
  11. 15
      designer_form/src/com/fr/design/designer/properties/FRFitLayoutPropertiesGroupModel.java
  12. 4
      designer_form/src/com/fr/design/designer/properties/FitStateRenderer.java
  13. 4
      designer_form/src/com/fr/design/designer/properties/LayoutTypeRenderer.java
  14. 3
      designer_form/src/com/fr/design/designer/treeview/ComponentTreeModel.java
  15. 10
      designer_form/src/com/fr/design/mainframe/ComponentTree.java

BIN
designer_base/src/com/fr/design/images/control/combobox.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 B

30
designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteBodyLayoutAdapter.java

@ -0,0 +1,30 @@
package com.fr.design.designer.beans.adapters.layout;
import com.fr.design.beans.GroupModel;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWAbsoluteBodyLayout;
import com.fr.design.designer.creator.XWAbsoluteLayout;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.properties.FRAbsoluteBodyLayoutPropertiesGroupModel;
import com.fr.design.designer.properties.FRAbsoluteLayoutPropertiesGroupModel;
import com.fr.form.ui.container.WBodyLayoutType;
/**
* Created by zhouping on 2016/10/14.
*/
public class FRAbsoluteBodyLayoutAdapter extends FRAbsoluteLayoutAdapter {
public FRAbsoluteBodyLayoutAdapter(XLayoutContainer container) {
super(container);
}
@Override
public GroupModel getLayoutProperties() {
XWAbsoluteBodyLayout xwAbsoluteBodyLayout = (XWAbsoluteBodyLayout) container;
//如果body是绝对布局,那么获取原来自适应body的属性--布局类型
WBodyLayoutType layoutType = WBodyLayoutType.FIT;
if (container.getParent() != null) {
layoutType = ((XWFitLayout)container.getParent()).toData().getBodyLayoutType();
}
return new FRAbsoluteBodyLayoutPropertiesGroupModel(xwAbsoluteBodyLayout, layoutType);
}
}

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

@ -331,15 +331,6 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
@Override
public GroupModel getLayoutProperties() {
XWAbsoluteLayout xwAbsoluteLayout = (XWAbsoluteLayout) container;
if (xwAbsoluteLayout.toData().isAbsoluteLayoutAsBody()){
//如果body是绝对布局,那么获取原来自适应body的属性--布局类型
WBodyLayoutType layoutType = WBodyLayoutType.FIT;
if (container.getParent() != null) {
layoutType = ((XWFitLayout)container.getParent()).toData().getBodyLayoutType();
}
return new FRAbsoluteLayoutPropertiesGroupModel(xwAbsoluteLayout, layoutType);
} else {
return new FRAbsoluteLayoutPropertiesGroupModel(xwAbsoluteLayout);
}
return new FRAbsoluteLayoutPropertiesGroupModel(xwAbsoluteLayout);
}
}

1
designer_form/src/com/fr/design/designer/creator/XCreatorUtils.java

@ -77,6 +77,7 @@ public class XCreatorUtils {
xLayoutMap.put(WAbsoluteLayout.class, XWAbsoluteLayout.class);
xLayoutMap.put(WParameterLayout.class, XWParameterLayout.class);
xLayoutMap.put(WAbsoluteBodyLayout.class, XWAbsoluteBodyLayout.class);
xLayoutMap.put(WAbsoluteLayout.class, XWAbsoluteLayout.class);
xLayoutMap.put(WHorizontalBoxLayout.class, XWHorizontalBoxLayout.class);
xLayoutMap.put(WBorderLayout.class, XWBorderLayout.class);

45
designer_form/src/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java

@ -0,0 +1,45 @@
package com.fr.design.designer.creator;
import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRAbsoluteBodyLayoutAdapter;
import com.fr.form.ui.container.WAbsoluteBodyLayout;
import java.awt.*;
/**
* Created by zhouping on 2016/10/14.
* 用作body的绝对布局
*/
public class XWAbsoluteBodyLayout extends XWAbsoluteLayout {
public XWAbsoluteBodyLayout(WAbsoluteBodyLayout widget, Dimension initSize) {
super(widget, initSize);
this.editable = true;
}
/**
* 返回对应的widget容器
*
* @return 返回WAbsoluteLayout
*/
@Override
public WAbsoluteBodyLayout toData() {
return (WAbsoluteBodyLayout)data;
}
@Override
public LayoutAdapter getLayoutAdapter() {
return new FRAbsoluteBodyLayoutAdapter(this);
}
/**
* 假如是body的话始终要能编辑不会出现蒙层
*
* @param isEditable 可否编辑
*/
@Override
public void setEditable(boolean isEditable) {
super.setEditable(true);
}
}

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

@ -75,15 +75,7 @@ public class XWAbsoluteLayout extends XLayoutContainer {
xConnectorMap.put(connector, new XConnector(connector, this));
}
this.editable = widget.isAbsoluteLayoutAsBody();
initPercent();
}
public XWAbsoluteLayout(WAbsoluteLayout widget, Dimension initSize, boolean isAbsoluteLayoutAsBody) {
this(widget, initSize);
widget.setAbsoluteLayoutAsBody(isAbsoluteLayoutAsBody);
this.editable = isAbsoluteLayoutAsBody;
initPercent(widget);
}
/**
@ -97,13 +89,14 @@ public class XWAbsoluteLayout extends XLayoutContainer {
}
//根据屏幕大小来确定显示的百分比, 1440*900默认100%, 1366*768缩放90%
private void initPercent(){
private void initPercent(WAbsoluteLayout widget){
Toolkit toolkit = Toolkit.getDefaultToolkit();
Dimension scrnsize = toolkit.getScreenSize();
double screenValue = FRScreen.getByDimension(scrnsize).getValue();
if(screenValue != FormArea.DEFAULT_SLIDER){
this.setContainerPercent(screenValue / FormArea.DEFAULT_SLIDER);
}
widget.setDesigningResolution(scrnsize);
}
/**
@ -451,15 +444,4 @@ public class XWAbsoluteLayout extends XLayoutContainer {
}
}
}
/**
* 设置布局是否可编辑不可则显示编辑蒙层
* 假如是body的话始终要能编辑不会出现蒙层
*
* @param isEditable 可否编辑
*/
@Override
public void setEditable(boolean isEditable) {
super.setEditable(toData().isAbsoluteLayoutAsBody() || isEditable);
}
}

5
designer_form/src/com/fr/design/designer/properties/AbsoluteStateRenderer.java

@ -1,11 +1,10 @@
package com.fr.design.designer.properties;
import com.fr.design.mainframe.widget.renderer.EncoderCellRenderer;
/**
* Created by zhouping on 2016/8/1.
*/
public class AbsoluteStateRenderer extends EncoderCellRenderer {
public class AbsoluteStateRenderer extends BodyLayoutAttrRenderer {
public AbsoluteStateRenderer() {
super(new AbsoluteStateWrapper());
}

23
designer_form/src/com/fr/design/designer/properties/BodyLayoutAttrRenderer.java

@ -0,0 +1,23 @@
package com.fr.design.designer.properties;
import com.fr.design.mainframe.widget.renderer.EncoderCellRenderer;
import com.fr.general.IOUtils;
import java.awt.*;
import java.awt.image.BufferedImage;
/**
* Created by zhouping on 2016/10/14.
*/
public class BodyLayoutAttrRenderer extends EncoderCellRenderer {
public BodyLayoutAttrRenderer(Encoder encoder) {
super(encoder);
}
@Override
public void paint(Graphics g) {
super.paint(g);
BufferedImage image = IOUtils.readImage("com/fr/design/images/control/combobox.png");
g.drawImage(image, getWidth() - image.getWidth(), 0, image.getWidth(), image.getHeight(), null, this);
}
}

239
designer_form/src/com/fr/design/designer/properties/FRAbsoluteBodyLayoutPropertiesGroupModel.java

@ -0,0 +1,239 @@
package com.fr.design.designer.properties;
import com.fr.design.designer.creator.XWAbsoluteBodyLayout;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelectionUtils;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.mainframe.widget.editors.LayoutTypeEditor;
import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WBodyLayoutType;
import com.fr.general.FRScreen;
import com.fr.general.Inter;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import java.awt.*;
import java.awt.geom.Arc2D;
import java.util.Arrays;
import java.util.Comparator;
/**
* Created by zhouping on 2016/10/14.
*/
public class FRAbsoluteBodyLayoutPropertiesGroupModel extends FRAbsoluteLayoutPropertiesGroupModel {
private LayoutTypeEditor layoutTypeEditor;
private LayoutTypeRenderer layoutTypeRenderer;
//默认body是0,自适应布局;1,绝对布局.
private WBodyLayoutType layoutType = WBodyLayoutType.ABSOLUTE;
public FRAbsoluteBodyLayoutPropertiesGroupModel(XWAbsoluteBodyLayout xwAbsoluteBodyLayout) {
super(xwAbsoluteBodyLayout);
}
public FRAbsoluteBodyLayoutPropertiesGroupModel(XWAbsoluteBodyLayout xwAbsoluteBodyLayout, WBodyLayoutType layoutType){
this(xwAbsoluteBodyLayout);
this.layoutTypeEditor = new LayoutTypeEditor();
this.layoutTypeRenderer = new LayoutTypeRenderer();
this.layoutType = layoutType;
}
/**
* 布局管理器自己的属性
*/
@Override
public String getGroupName() {
return Inter.getLocText("FR-Designer_Attr_Layout");
}
@Override
public int getRowCount() {
return 2;
}
@Override
public TableCellRenderer getRenderer(int row) {
return row == 0 ? layoutTypeRenderer : stateRenderer;
}
@Override
public TableCellEditor getEditor(int row) {
return row == 0 ? layoutTypeEditor : stateEditor;
}
@Override
public Object getValue(int row, int column) {
if (column == 0) {
switch (row) {
case 0:
return Inter.getLocText("FR-Designer_Attr_Layout_Type");
default:
return Inter.getLocText("FR-Designer-Widget_Scaling_Mode");
}
} else {
switch (row) {
case 0:
return layoutType.getTypeValue();
default:
return layout.getCompState();
}
}
}
@Override
public boolean setValue(Object value, int row, int column) {
if (layoutType == WBodyLayoutType.ABSOLUTE){
int state = 0;
if(value instanceof Integer) {
state = (Integer)value;
}
if (column == 0 || state < 0) {
return false;
} else {
if (row == 0) {
if (state == WBodyLayoutType.FIT.getTypeValue()) {
XWFitLayout xfl = (XWFitLayout) xwAbsoluteLayout.getBackupParent();
Component[] components = xwAbsoluteLayout.getComponents();
Arrays.sort(components, new ComparatorComponentLocation());
xfl.getLayoutAdapter().removeBean(xwAbsoluteLayout, xwAbsoluteLayout.getWidth(), xwAbsoluteLayout.getHeight());
xfl.remove(xwAbsoluteLayout);
xfl.toData().setLayoutType(WBodyLayoutType.FIT);
for (Component comp : components) {
xfl.add(comp);
}
moveComponents2FitLayout(xfl, components);
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner();
formDesigner.getSelectionModel().setSelectedCreators(
FormSelectionUtils.rebuildSelection(xfl, new Widget[]{xfl.toData()}));
xfl.convert();
LayoutUtils.layoutContainer(xfl);
xfl.adjustCreatorsWhileSlide(xfl.getContainerPercent() - 1.0);
return true;
}
}
if (row == 1) {
layout.setCompState(state);
return true;
}
return false;
}
}
int state = 0;
if(value instanceof Integer) {
state = (Integer)value;
}
if (column == 0 || state < 0) {
return false;
} else {
if (row == 0) {
layout.setCompState(state);
return true;
}
return false;
}
}
/**
* 是否可编辑
* @param row
* @return
*/
@Override
public boolean isEditable(int row) {
return true;
}
//把绝对布局中的元素按规则移动到自适应布局中
private void moveComponents2FitLayout(XWFitLayout xwFitLayout, Component[] components) {
int eachRowCount = 4;
if (components.length <= 1){
return;
}
int layoutWidth = xwFitLayout.getWidth() - xwFitLayout.toData().getMargin().getLeft() - xwFitLayout.toData().getMargin().getRight();
int layoutHeight = xwFitLayout.getHeight() - xwFitLayout.toData().getMargin().getTop() - xwFitLayout.toData().getMargin().getBottom();
int leftMargin = xwFitLayout.toData().getMargin().getLeft();
int topMargin = xwFitLayout.toData().getMargin().getTop();
int row = (components.length / eachRowCount) + (components.length % eachRowCount == 0 ? 0 : 1);
//最后一行的列数不定
int column = components.length % eachRowCount == 0 ? eachRowCount : components.length % eachRowCount;
int componentWidth = layoutWidth / eachRowCount;
int componentHeight = layoutHeight / row;
for(int i = 0;i < row - 1;i++){
for(int j = 0;j < eachRowCount;j++){
components[eachRowCount * i + j].setBounds(
leftMargin + componentWidth * j,
topMargin + componentHeight * i,
j == eachRowCount - 1 ? layoutWidth - componentWidth * (eachRowCount - 1) : componentWidth,
componentHeight
);
}
}
//最后一行列数是特殊的,要单独处理
int lastRowWidth = layoutWidth / column;
int lastRowHeight = layoutHeight - componentHeight * (row - 1);
for (int i = 0;i < column;i++) {
components[eachRowCount * (row - 1) + i].setBounds(
leftMargin + lastRowWidth * i,
topMargin + componentHeight * (row - 1),
i == column - 1 ? layoutWidth - lastRowWidth * (column - 1) : lastRowWidth,
lastRowHeight
);
}
xwFitLayout.updateBoundsWidget();
}
private class ComponentLocationInfo{
private Component component;
private int horizontalNO;
private int verticalNO;
public ComponentLocationInfo(Component component, int horizontalNO, int verticalNO){
this.component = component;
this.horizontalNO = horizontalNO;
this.verticalNO = verticalNO;
}
public int getHorizontalNO() {
return this.horizontalNO;
}
public int getVerticalNO() {
return this.verticalNO;
}
public void setHorizontalNO(int horizontalNO){
this.horizontalNO = horizontalNO;
}
public void setVerticalNO(int verticalNO){
this.verticalNO = verticalNO;
}
}
//以组件的位置来确定先后顺序,y小的在前,x小的在前
private class ComparatorComponentLocation implements Comparator {
@Override
public int compare(Object o1, Object o2) {
if(((Component)o1).getY() < ((Component)o2).getY()){
return -1;
}
else if (((Component)o1).getY() > ((Component)o2).getY()) {
return 1;
}
else {
if (((Component)o1).getX() < ((Component)o2).getX()){
return -1;
}
else if (((Component)o1).getX() > ((Component)o2).getX()) {
return 1;
}
else{
return 0;
}
}
}
}
}

192
designer_form/src/com/fr/design/designer/properties/FRAbsoluteLayoutPropertiesGroupModel.java

@ -2,40 +2,27 @@ package com.fr.design.designer.properties;
import com.fr.design.beans.GroupModel;
import com.fr.design.designer.creator.XWAbsoluteLayout;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelectionUtils;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.mainframe.widget.editors.AbsoluteLayoutDirectionEditor;
import com.fr.design.mainframe.widget.editors.IntegerPropertyEditor;
import com.fr.design.mainframe.widget.editors.LayoutTypeEditor;
import com.fr.design.mainframe.widget.editors.PropertyCellEditor;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WBodyLayoutType;
import com.fr.general.Inter;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import java.awt.*;
import java.util.Arrays;
import java.util.Comparator;
/**
* Created by zhouping on 2016/8/1.
*/
public class FRAbsoluteLayoutPropertiesGroupModel implements GroupModel {
private PropertyCellEditor editor;
private DefaultTableCellRenderer renderer;
private AbsoluteLayoutDirectionEditor stateEditor;
private AbsoluteStateRenderer stateRenderer;
private WAbsoluteLayout layout;
private XWAbsoluteLayout xwAbsoluteLayout;
private LayoutTypeEditor layoutTypeEditor;
private LayoutTypeRenderer layoutTypeRenderer;
//默认body是0,自适应布局;1,绝对布局.
private WBodyLayoutType layoutType = WBodyLayoutType.FIT;
protected AbsoluteLayoutDirectionEditor stateEditor;
protected AbsoluteStateRenderer stateRenderer;
protected WAbsoluteLayout layout;
protected XWAbsoluteLayout xwAbsoluteLayout;
public FRAbsoluteLayoutPropertiesGroupModel(XWAbsoluteLayout xwAbsoluteLayout){
this.xwAbsoluteLayout = xwAbsoluteLayout;
@ -46,65 +33,31 @@ public class FRAbsoluteLayoutPropertiesGroupModel implements GroupModel {
stateRenderer = new AbsoluteStateRenderer();
}
public FRAbsoluteLayoutPropertiesGroupModel(XWAbsoluteLayout xwAbsoluteLayout, WBodyLayoutType layoutType){
this(xwAbsoluteLayout);
this.layoutTypeEditor = new LayoutTypeEditor();
this.layoutTypeRenderer = new LayoutTypeRenderer();
this.layoutType = layoutType;
}
/**
* 布局管理器自己的属性
*/
@Override
public String getGroupName() {
return Inter.getLocText(layoutType == WBodyLayoutType.ABSOLUTE ? "FR-Designer_Attr_Layout" : "FR-Designer-Widget_Area_Scaling");
return Inter.getLocText("FR-Designer-Widget_Area_Scaling");
}
@Override
public int getRowCount() {
return layoutType == WBodyLayoutType.ABSOLUTE ? 2 : 1;
return 1;
}
@Override
public TableCellRenderer getRenderer(int row) {
if (layoutType == WBodyLayoutType.ABSOLUTE) {
return row == 0 ? layoutTypeRenderer : stateRenderer;
}
else {
return stateRenderer;
}
return stateRenderer;
}
@Override
public TableCellEditor getEditor(int row) {
if (layoutType == WBodyLayoutType.ABSOLUTE) {
return row == 0 ? layoutTypeEditor : stateEditor;
}
else{
return stateEditor;
}
return stateEditor;
}
@Override
public Object getValue(int row, int column) {
if (layoutType == WBodyLayoutType.ABSOLUTE){
if (column == 0) {
switch (row) {
case 0:
return Inter.getLocText("FR-Designer_Attr_Layout_Type");
default:
return Inter.getLocText("FR-Designer-Widget_Scaling_Mode");
}
} else {
switch (row) {
case 0:
return layoutType.getTypeValue();
default:
return layout.getCompState();
}
}
}
if (column == 0) {
return Inter.getLocText("FR-Designer-Widget_Scaling_Mode");
} else {
@ -114,42 +67,6 @@ public class FRAbsoluteLayoutPropertiesGroupModel implements GroupModel {
@Override
public boolean setValue(Object value, int row, int column) {
if (layoutType == WBodyLayoutType.ABSOLUTE){
int state = 0;
if(value instanceof Integer) {
state = (Integer)value;
}
if (column == 0 || state < 0) {
return false;
} else {
if (row == 0) {
if (state == WBodyLayoutType.FIT.getTypeValue()) {
XWFitLayout xfl = (XWFitLayout) xwAbsoluteLayout.getBackupParent();
Component[] components = xwAbsoluteLayout.getComponents();
Arrays.sort(components, new ComparatorComponentLocation());
xfl.getLayoutAdapter().removeBean(xwAbsoluteLayout, xwAbsoluteLayout.getWidth(), xwAbsoluteLayout.getHeight());
xfl.remove(xwAbsoluteLayout);
xfl.toData().setLayoutType(WBodyLayoutType.FIT);
for (Component comp : components) {
xfl.add(comp);
}
moveComponents2FitLayout(xfl, components);
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner();
formDesigner.getSelectionModel().setSelectedCreators(
FormSelectionUtils.rebuildSelection(xfl, new Widget[]{xfl.toData()}));
return true;
}
}
if (row == 1) {
layout.setCompState(state);
return true;
}
return false;
}
}
int state = 0;
if(value instanceof Integer) {
state = (Integer)value;
@ -174,95 +91,4 @@ public class FRAbsoluteLayoutPropertiesGroupModel implements GroupModel {
public boolean isEditable(int row) {
return true;
}
//把绝对布局中的元素按规则移动到自适应布局中
private void moveComponents2FitLayout(XWFitLayout xwFitLayout, Component[] components) {
int eachRowCount = 4;
if (components.length <= 1){
return;
}
int layoutWidth = xwFitLayout.getWidth() - xwFitLayout.toData().getMargin().getLeft() - xwFitLayout.toData().getMargin().getRight();
int layoutHeight = xwFitLayout.getHeight() - xwFitLayout.toData().getMargin().getTop() - xwFitLayout.toData().getMargin().getBottom();
int leftMargin = xwFitLayout.toData().getMargin().getLeft();
int topMargin = xwFitLayout.toData().getMargin().getTop();
int row = (components.length / eachRowCount) + (components.length % eachRowCount == 0 ? 0 : 1);
//最后一行的列数不定
int column = components.length % eachRowCount;
int componentWidth = layoutWidth / eachRowCount;
int componentHeight = layoutHeight / row;
for(int i = 0;i < row - 1;i++){
for(int j = 0;j < eachRowCount;j++){
components[eachRowCount * i + j].setBounds(
leftMargin + componentWidth * j,
topMargin + componentHeight * i,
j == eachRowCount - 1 ? layoutWidth - componentWidth * (eachRowCount-1) : componentWidth,
componentHeight
);
}
}
//最后一行列数是特殊的,要单独处理
int lastRowWidth = layoutWidth / column;
int lastRowHeight = layoutHeight - componentHeight * (row - 1);
for (int i = 0;i < column;i++) {
components[eachRowCount * (row - 1) + i].setBounds(
leftMargin + lastRowWidth * i,
topMargin + componentHeight * (row - 1),
i == column - 1 ? layoutWidth - lastRowWidth * (column-1) : lastRowWidth,
lastRowHeight
);
}
xwFitLayout.updateBoundsWidget();
}
private class ComponentLocationInfo{
private Component component;
private int horizontalNO;
private int verticalNO;
public ComponentLocationInfo(Component component, int horizontalNO, int verticalNO){
this.component = component;
this.horizontalNO = horizontalNO;
this.verticalNO = verticalNO;
}
public int getHorizontalNO() {
return this.horizontalNO;
}
public int getVerticalNO() {
return this.verticalNO;
}
public void setHorizontalNO(int horizontalNO){
this.horizontalNO = horizontalNO;
}
public void setVerticalNO(int verticalNO){
this.verticalNO = verticalNO;
}
}
//以组件的位置来确定先后顺序,y小的在前,x小的在前
private class ComparatorComponentLocation implements Comparator {
@Override
public int compare(Object o1, Object o2) {
if(((Component)o1).getY() < ((Component)o2).getY()){
return -1;
}
else if (((Component)o1).getY() > ((Component)o2).getY()) {
return 1;
}
else {
if (((Component)o1).getX() < ((Component)o2).getX()){
return -1;
}
else if (((Component)o1).getX() > ((Component)o2).getX()) {
return 1;
}
else{
return 0;
}
}
}
}
}

15
designer_form/src/com/fr/design/designer/properties/FRFitLayoutPropertiesGroupModel.java

@ -4,7 +4,7 @@
package com.fr.design.designer.properties;
import com.fr.design.beans.GroupModel;
import com.fr.design.designer.creator.XWAbsoluteLayout;
import com.fr.design.designer.creator.XWAbsoluteBodyLayout;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelectionUtils;
@ -14,6 +14,7 @@ import com.fr.design.mainframe.widget.editors.LayoutTypeEditor;
import com.fr.design.mainframe.widget.editors.IntegerPropertyEditor;
import com.fr.design.mainframe.widget.editors.PropertyCellEditor;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WAbsoluteBodyLayout;
import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WBodyLayoutType;
import com.fr.form.ui.container.WFitLayout;
@ -132,18 +133,18 @@ public class FRFitLayoutPropertiesGroupModel implements GroupModel {
}else if (row == 0) {
layout.setLayoutType(WBodyLayoutType.parse(state));
if (state == WBodyLayoutType.ABSOLUTE.getTypeValue()) {
WAbsoluteLayout wAbsoluteLayout = new WAbsoluteLayout("body");
wAbsoluteLayout.setCompState(WAbsoluteLayout.STATE_FIXED);
WAbsoluteBodyLayout wAbsoluteBodyLayout = new WAbsoluteBodyLayout("body");
wAbsoluteBodyLayout.setCompState(WAbsoluteLayout.STATE_FIXED);
Component[] components = xfl.getComponents();
xfl.removeAll();
XWAbsoluteLayout xwAbsoluteLayout = new XWAbsoluteLayout(wAbsoluteLayout, new Dimension(0,0), true);
xfl.getLayoutAdapter().addBean(xwAbsoluteLayout, 0, 0);
XWAbsoluteBodyLayout xwAbsoluteBodyLayout = new XWAbsoluteBodyLayout(wAbsoluteBodyLayout, new Dimension(0,0));
xfl.getLayoutAdapter().addBean(xwAbsoluteBodyLayout, 0, 0);
for (Component component : components) {
xwAbsoluteLayout.add(component);
xwAbsoluteBodyLayout.add(component);
}
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner();
formDesigner.getSelectionModel().setSelectedCreators(
FormSelectionUtils.rebuildSelection(xfl, new Widget[]{wAbsoluteLayout}));
FormSelectionUtils.rebuildSelection(xfl, new Widget[]{wAbsoluteBodyLayout}));
}
else {
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner();

4
designer_form/src/com/fr/design/designer/properties/FitStateRenderer.java

@ -3,13 +3,11 @@
*/
package com.fr.design.designer.properties;
import com.fr.design.mainframe.widget.renderer.EncoderCellRenderer;
/**
* @author jim
* @date 2014-7-31
*/
public class FitStateRenderer extends EncoderCellRenderer{
public class FitStateRenderer extends BodyLayoutAttrRenderer{
/**
* @param encoder

4
designer_form/src/com/fr/design/designer/properties/LayoutTypeRenderer.java

@ -1,11 +1,9 @@
package com.fr.design.designer.properties;
import com.fr.design.mainframe.widget.renderer.EncoderCellRenderer;
/**
* Created by zhouping on 2016/9/18.
*/
public class LayoutTypeRenderer extends EncoderCellRenderer {
public class LayoutTypeRenderer extends BodyLayoutAttrRenderer {
public LayoutTypeRenderer() {
super(new LayoutTypeWrapper());

3
designer_form/src/com/fr/design/designer/treeview/ComponentTreeModel.java

@ -148,8 +148,7 @@ public class ComponentTreeModel implements TreeModel {
XWFitLayout bodyFitLayout = (XWFitLayout)xCreator;
for (int i = 0;i < bodyFitLayout.getXCreatorCount();i++){
//类型是绝对布局并且还是body
if (bodyFitLayout.getXCreator(i).acceptType(XWAbsoluteLayout.class)
&& ((XWAbsoluteLayout)bodyFitLayout.getXCreator(i)).toData().isAbsoluteLayoutAsBody()){
if (bodyFitLayout.getXCreator(i).acceptType(XWAbsoluteBodyLayout.class)){
index = i;
}
}

10
designer_form/src/com/fr/design/mainframe/ComponentTree.java

@ -16,10 +16,7 @@ import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.events.DesignerEditListener;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWAbsoluteLayout;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.creator.*;
import com.fr.design.designer.treeview.ComponentTreeCellRenderer;
import com.fr.design.designer.treeview.ComponentTreeModel;
import com.fr.stable.StringUtils;
@ -280,10 +277,9 @@ public class ComponentTree extends JTree {
creator.notShowInComponentTree(path);
}
//绝对布局作为body的时候不显示自适应布局父层
if (((XCreator) parent).acceptType(XWAbsoluteLayout.class)
if (((XCreator) parent).acceptType(XWAbsoluteBodyLayout.class)
&& (parent.getParent() != null)
&& ((XCreator)parent.getParent()).acceptType(XWFitLayout.class)
&& ((XWAbsoluteLayout)parent).toData().isAbsoluteLayoutAsBody()){
&& ((XCreator)parent.getParent()).acceptType(XWFitLayout.class)){
parent = parent.getParent().getParent();
continue;
}

Loading…
Cancel
Save