diff --git a/designer_base/src/com/fr/design/gui/itable/AbstractPropertyTable.java b/designer_base/src/com/fr/design/gui/itable/AbstractPropertyTable.java index f16be99639..02a6f547b8 100644 --- a/designer_base/src/com/fr/design/gui/itable/AbstractPropertyTable.java +++ b/designer_base/src/com/fr/design/gui/itable/AbstractPropertyTable.java @@ -66,6 +66,9 @@ public abstract class AbstractPropertyTable extends JTable { public TableCellRenderer getCellRenderer(int row, int column) { if (groups != null) { Point pIndex = getGroupIndex(row); + if (pIndex == null){ + return super.getCellRenderer(row, column); + } PropertyGroup group = groups.get(pIndex.x); if (pIndex.y == 0) { if (column == 0) { @@ -192,6 +195,9 @@ public abstract class AbstractPropertyTable extends JTable { @Override public Object getValueAt(int row, int column) { Point pIndex = getGroupIndex(row); + if (pIndex == null){ + return null; + } PropertyGroup group = groups.get(pIndex.x); if (pIndex.y == 0) { if (column == 0) { diff --git a/designer_form/src/com/fr/design/designer/properties/FRAbsoluteBodyLayoutPropertiesGroupModel.java b/designer_form/src/com/fr/design/designer/properties/FRAbsoluteBodyLayoutPropertiesGroupModel.java index 1a7ab03d3f..bdaad048aa 100644 --- a/designer_form/src/com/fr/design/designer/properties/FRAbsoluteBodyLayoutPropertiesGroupModel.java +++ b/designer_form/src/com/fr/design/designer/properties/FRAbsoluteBodyLayoutPropertiesGroupModel.java @@ -1,7 +1,7 @@ package com.fr.design.designer.properties; -import com.fr.design.designer.creator.XWAbsoluteBodyLayout; -import com.fr.design.designer.creator.XWFitLayout; +import com.fr.design.designer.creator.*; +import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormSelectionUtils; import com.fr.design.mainframe.WidgetPropertyPane; @@ -93,6 +93,8 @@ public class FRAbsoluteBodyLayoutPropertiesGroupModel extends FRAbsoluteLayoutPr if (row == 0) { if (state == WBodyLayoutType.FIT.getTypeValue()) { XWFitLayout xfl = (XWFitLayout) xwAbsoluteLayout.getBackupParent(); + //备份一下组件间隔 + int compInterval = xfl.toData().getCompInterval(); Component[] components = xwAbsoluteLayout.getComponents(); Arrays.sort(components, new ComparatorComponentLocation()); @@ -102,15 +104,35 @@ public class FRAbsoluteBodyLayoutPropertiesGroupModel extends FRAbsoluteLayoutPr xfl.toData().setLayoutType(WBodyLayoutType.FIT); for (Component comp : components) { - xfl.add(comp); + XCreator xCreator = (XCreator)comp; + if (xCreator.shouldScaleCreator()){ + XLayoutContainer parentPanel = xCreator.initCreatorWrapper(xCreator.getHeight()); + xfl.add(parentPanel, xCreator.toData().getWidgetName()); + continue; + } + xfl.add(xCreator); } - moveComponents2FitLayout(xfl, components); + //这边计算的时候会先把组件间隔去掉 + moveComponents2FitLayout(xfl); FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); - formDesigner.getSelectionModel().setSelectedCreators( - FormSelectionUtils.rebuildSelection(xfl, new Widget[]{xfl.toData()})); + formDesigner.getSelectionModel().setSelectedCreator(xfl); xfl.convert(); LayoutUtils.layoutContainer(xfl); xfl.adjustCreatorsWhileSlide(xfl.getContainerPercent() - 1.0); + + for (int i = 0; i < components.length; i++) { + Component comp = xfl.getComponent(i); + XCreator creator = (XCreator) comp; + creator.setBackupBound(components[i].getBounds()); + } + + //把组件间隔加上 + if (xfl.toData().getCompInterval() != compInterval) { + xfl.moveContainerMargin(); + xfl.moveCompInterval(xfl.getAcualInterval()); + xfl.toData().setCompInterval(compInterval); + xfl.addCompInterval(xfl.getAcualInterval()); + } return true; } } @@ -147,15 +169,18 @@ public class FRAbsoluteBodyLayoutPropertiesGroupModel extends FRAbsoluteLayoutPr } //把绝对布局中的元素按规则移动到自适应布局中 - private void moveComponents2FitLayout(XWFitLayout xwFitLayout, Component[] components) { + private void moveComponents2FitLayout(XWFitLayout xwFitLayout) { int eachRowCount = 4; + Component[] components = xwFitLayout.getComponents(); if (components.length <= 1){ + xwFitLayout.updateBoundsWidget(); 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(); + xwFitLayout.toData().setCompInterval(0); int row = (components.length / eachRowCount) + (components.length % eachRowCount == 0 ? 0 : 1); //最后一行的列数不定 int column = components.length % eachRowCount == 0 ? eachRowCount : components.length % eachRowCount; @@ -182,6 +207,12 @@ public class FRAbsoluteBodyLayoutPropertiesGroupModel extends FRAbsoluteLayoutPr lastRowHeight ); } + for (int i = 0;i < components.length;i++){ + if (components[i] instanceof XWCardMainBorderLayout){ + ((XWCardMainBorderLayout)components[i]).recalculateChildWidth(components[i].getWidth()); + ((XWCardMainBorderLayout)components[i]).recalculateChildHeight(components[i].getHeight()); + } + } xwFitLayout.updateBoundsWidget(); } diff --git a/designer_form/src/com/fr/design/designer/properties/FRFitLayoutPropertiesGroupModel.java b/designer_form/src/com/fr/design/designer/properties/FRFitLayoutPropertiesGroupModel.java index f6b8ccaf22..c9654e26d0 100644 --- a/designer_form/src/com/fr/design/designer/properties/FRFitLayoutPropertiesGroupModel.java +++ b/designer_form/src/com/fr/design/designer/properties/FRFitLayoutPropertiesGroupModel.java @@ -4,8 +4,7 @@ package com.fr.design.designer.properties; import com.fr.design.beans.GroupModel; -import com.fr.design.designer.creator.XWAbsoluteBodyLayout; -import com.fr.design.designer.creator.XWFitLayout; +import com.fr.design.designer.creator.*; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormSelectionUtils; import com.fr.design.mainframe.WidgetPropertyPane; @@ -91,8 +90,23 @@ public class FRFitLayoutPropertiesGroupModel implements GroupModel { } } + private XLayoutContainer selectedBodyLayout(FormDesigner formDesigner) { + XLayoutContainer rootLayout = formDesigner.getRootComponent(); + if (rootLayout.getComponentCount() == 1 && rootLayout.getXCreator(0).acceptType(XWAbsoluteBodyLayout.class)){ + rootLayout = (XWAbsoluteBodyLayout)rootLayout.getXCreator(0); + } + return rootLayout; + } + @Override public Object getValue(int row, int column) { + FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); + XLayoutContainer rootLayout = selectedBodyLayout(formDesigner); + if (rootLayout != formDesigner.getRootComponent() + && formDesigner.getSelectionModel().getSelection().getSelectedCreator() == formDesigner.getRootComponent()) { + formDesigner.getSelectionModel().setSelectedCreators( + FormSelectionUtils.rebuildSelection(xfl, new Widget[]{selectedBodyLayout(formDesigner).toData()})); + } if (column == 0) { switch (row) { case 0: @@ -140,6 +154,14 @@ public class FRFitLayoutPropertiesGroupModel implements GroupModel { XWAbsoluteBodyLayout xwAbsoluteBodyLayout = new XWAbsoluteBodyLayout(wAbsoluteBodyLayout, new Dimension(0,0)); xfl.getLayoutAdapter().addBean(xwAbsoluteBodyLayout, 0, 0); for (Component component : components) { + XCreator xCreator = (XCreator)component; + //部分控件被ScaleLayout包裹着,绝对布局里面要放出来 + if (xCreator.acceptType(XWScaleLayout.class)){ + if (xCreator.getComponentCount() > 0 && ((XCreator)xCreator.getComponent(0)).shouldScaleCreator()) { + component = xCreator.getComponent(0); + component.setBounds(xCreator.getBounds()); + } + } xwAbsoluteBodyLayout.add(component); } FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); diff --git a/designer_form/src/com/fr/design/mainframe/FormHierarchyTreePane.java b/designer_form/src/com/fr/design/mainframe/FormHierarchyTreePane.java index 410519cafb..2f424a7b7c 100644 --- a/designer_form/src/com/fr/design/mainframe/FormHierarchyTreePane.java +++ b/designer_form/src/com/fr/design/mainframe/FormHierarchyTreePane.java @@ -5,7 +5,8 @@ import java.awt.event.ActionEvent; import javax.swing.BorderFactory; import javax.swing.Icon; - +import com.fr.design.designer.creator.XLayoutContainer; +import com.fr.design.designer.creator.XWAbsoluteBodyLayout; import com.fr.design.actions.community.NeedAction; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.mainframe.widget.UITreeComboBox; @@ -171,10 +172,17 @@ public class FormHierarchyTreePane extends FormDockView implements HierarchyTree */ private void adjustPosition(ComponentTreeModel treeModel,FormDesigner formDesigner){ XCreator root = (XCreator)treeModel.getRoot(); - if(treeModel.getChild(root,PARA) instanceof XWParameterLayout){ + XCreator firstChild = (XCreator)treeModel.getChild(root,PARA); + if(firstChild.acceptType(XWParameterLayout.class)){ return; } - root.add((Component)(treeModel.getChild(root,PARA)),BODY); + // 绝对布局作为body的时候 + // 获取第一个子节点的方法中屏蔽了fit + // 这边另外处理一下 + else if (firstChild.acceptType(XWAbsoluteBodyLayout.class) && firstChild.getBackupParent() != null) { + firstChild = firstChild.getBackupParent(); + } + root.add(firstChild,BODY); treeModel.setRoot(root); componentTree = new ComponentTree(formDesigner,treeModel); } diff --git a/designer_form/src/com/fr/design/mainframe/JForm.java b/designer_form/src/com/fr/design/mainframe/JForm.java index ef18f07135..661ba0ab96 100644 --- a/designer_form/src/com/fr/design/mainframe/JForm.java +++ b/designer_form/src/com/fr/design/mainframe/JForm.java @@ -9,9 +9,7 @@ import com.fr.design.constants.UIConstants; import com.fr.design.designer.beans.actions.FormDeleteAction; import com.fr.design.designer.beans.events.DesignerEditListener; import com.fr.design.designer.beans.events.DesignerEvent; -import com.fr.design.designer.creator.XComponent; -import com.fr.design.designer.creator.XCreator; -import com.fr.design.designer.creator.XCreatorUtils; +import com.fr.design.designer.creator.*; import com.fr.design.designer.properties.FormWidgetAuthorityEditPane; import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; @@ -436,6 +434,18 @@ public class JForm extends JTemplate