Browse Source

REPORT-533 表单初始化布局新功能

master
zhouping 8 years ago
parent
commit
0a231bca2e
  1. 6
      designer_base/src/com/fr/design/gui/itable/AbstractPropertyTable.java
  2. 23
      designer_form/src/com/fr/design/designer/properties/FRAbsoluteBodyLayoutPropertiesGroupModel.java
  3. 16
      designer_form/src/com/fr/design/designer/properties/FRFitLayoutPropertiesGroupModel.java
  4. 13
      designer_form/src/com/fr/design/mainframe/FormHierarchyTreePane.java
  5. 20
      designer_form/src/com/fr/design/mainframe/JForm.java

6
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) {

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

@ -1,7 +1,9 @@
package com.fr.design.designer.properties;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XWAbsoluteBodyLayout;
import com.fr.design.designer.creator.XWFitLayout;
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 +95,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());
@ -104,13 +108,21 @@ public class FRAbsoluteBodyLayoutPropertiesGroupModel extends FRAbsoluteLayoutPr
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()}));
formDesigner.getSelectionModel().setSelectedCreator(xfl);
xfl.convert();
LayoutUtils.layoutContainer(xfl);
xfl.adjustCreatorsWhileSlide(xfl.getContainerPercent() - 1.0);
//把组件间隔加上
if (xfl.toData().getCompInterval() != compInterval) {
xfl.moveContainerMargin();
xfl.moveCompInterval(xfl.getAcualInterval());
xfl.toData().setCompInterval(compInterval);
xfl.addCompInterval(xfl.getAcualInterval());
}
return true;
}
}
@ -156,6 +168,7 @@ public class FRAbsoluteBodyLayoutPropertiesGroupModel extends FRAbsoluteLayoutPr
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 +195,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();
}

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

@ -4,6 +4,7 @@
package com.fr.design.designer.properties;
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.XWFitLayout;
import com.fr.design.mainframe.FormDesigner;
@ -91,8 +92,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:

13
designer_form/src/com/fr/design/mainframe/FormHierarchyTreePane.java

@ -7,6 +7,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.parameter.HierarchyTreePane;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XWParameterLayout;
@ -155,10 +157,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);
}

20
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<Form, FormUndoState> implements BaseJForm {
return !inECUndoForm && this.getUndoManager().canUndo();
}
// 返回当前的body,
// 假如当前body是自适应的话就沿用,
// 假如当前body是绝对布局的话就返回绝对布局body
private XLayoutContainer selectedBodyLayout() {
XLayoutContainer rootLayout = formDesign.getRootComponent();
for (int i = 0; i < rootLayout.getComponentCount(); i++){
if (rootLayout.getXCreator(i).acceptType(XWAbsoluteBodyLayout.class)){
rootLayout = (XWAbsoluteBodyLayout)rootLayout.getXCreator(i);
}
}
return rootLayout;
}
@Override
/**
* 应用undoState的表单数据
@ -447,7 +457,9 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
if (this.index == FORM_TAB) {
JForm.this.refreshRoot();
this.formDesign.getArea().setAreaSize(u.getAreaSize(), u.getHorizontalValue(), u.getVerticalValue(), u.getWidthValue(), u.getHeightValue(), u.getSlideValue());
this.formDesign.getSelectionModel().setSelectedCreators(FormSelectionUtils.rebuildSelection(formDesign.getRootComponent(), u.getSelectWidgets()));
//撤销的时候要重新选择的body布局
this.formDesign.getSelectionModel().setSelectedCreators(FormSelectionUtils.rebuildSelection(formDesign.getRootComponent(),
formDesign.getRootComponent() == selectedBodyLayout() ? u.getSelectWidgets() : new Widget[]{selectedBodyLayout().toData()}));
} else {
String widgetName = this.formDesign.getElementCaseContainerName();
//这儿太坑了,u.getForm() 与 getTarget内容不一样

Loading…
Cancel
Save