Browse Source

修复冲突

master
zhouping 8 years ago
parent
commit
a996143c18
  1. 10
      designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java
  2. 19
      designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java
  3. 180
      designer_form/src/com/fr/design/designer/properties/FRAbsoluteLayoutPropertiesGroupModel.java
  4. 65
      designer_form/src/com/fr/design/designer/properties/FRFitLayoutPropertiesGroupModel.java
  5. 14
      designer_form/src/com/fr/design/designer/properties/LayoutTypeRenderer.java
  6. 13
      designer_form/src/com/fr/design/designer/properties/LayoutTypeWrapper.java
  7. 4
      designer_form/src/com/fr/design/designer/properties/items/FRFitConstraintsItems.java
  8. 16
      designer_form/src/com/fr/design/designer/properties/items/FRLayoutTypeItems.java
  9. 27
      designer_form/src/com/fr/design/designer/treeview/ComponentTreeModel.java
  10. 2
      designer_form/src/com/fr/design/gui/core/FormWidgetOption.java
  11. 9
      designer_form/src/com/fr/design/mainframe/ComponentTree.java
  12. 9
      designer_form/src/com/fr/design/mainframe/FormParaWidgetPane.java
  13. 15
      designer_form/src/com/fr/design/mainframe/widget/editors/LayoutTypeEditor.java

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

@ -12,6 +12,7 @@ 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.gui.LayoutUtils;
import com.fr.form.ui.container.WBodyLayoutType;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
@ -330,6 +331,15 @@ 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);
}
}
}

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

@ -75,9 +75,17 @@ 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;
}
/**
* 初始化时默认的组件大小
*
@ -443,4 +451,15 @@ public class XWAbsoluteLayout extends XLayoutContainer {
}
}
}
/**
* 设置布局是否可编辑不可则显示编辑蒙层
* 假如是body的话始终要能编辑不会出现蒙层
*
* @param isEditable 可否编辑
*/
@Override
public void setEditable(boolean isEditable) {
super.setEditable(toData().isAbsoluteLayoutAsBody() || isEditable);
}
}

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

@ -2,27 +2,40 @@ 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;
public FRAbsoluteLayoutPropertiesGroupModel(XWAbsoluteLayout xwAbsoluteLayout){
this.xwAbsoluteLayout = xwAbsoluteLayout;
@ -33,31 +46,65 @@ 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("FR-Designer-Widget_Area_Scaling");
return Inter.getLocText(layoutType == WBodyLayoutType.ABSOLUTE ? "FR-Designer_Attr_Layout" : "FR-Designer-Widget_Area_Scaling");
}
@Override
public int getRowCount() {
return 1;
return layoutType == WBodyLayoutType.ABSOLUTE ? 2 : 1;
}
@Override
public TableCellRenderer getRenderer(int row) {
if (layoutType == WBodyLayoutType.ABSOLUTE) {
return row == 0 ? layoutTypeRenderer : stateRenderer;
}
else {
return stateRenderer;
}
}
@Override
public TableCellEditor getEditor(int row) {
if (layoutType == WBodyLayoutType.ABSOLUTE) {
return row == 0 ? layoutTypeEditor : stateEditor;
}
else{
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 {
@ -67,6 +114,42 @@ 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;
@ -91,4 +174,95 @@ 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;
}
}
}
}
}

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

@ -4,16 +4,25 @@
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.FitLayoutDirectionEditor;
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.WAbsoluteLayout;
import com.fr.form.ui.container.WBodyLayoutType;
import com.fr.form.ui.container.WFitLayout;
import com.fr.general.Inter;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import java.awt.*;
/**
* 自适应布局自身的属性表
@ -28,6 +37,8 @@ public class FRFitLayoutPropertiesGroupModel implements GroupModel {
private DefaultTableCellRenderer renderer;
private FitLayoutDirectionEditor stateEditor;
private FitStateRenderer stateRenderer;
private LayoutTypeEditor layoutTypeEditor;
private LayoutTypeRenderer layoutTypeRenderer;
private WFitLayout layout;
private XWFitLayout xfl;
@ -38,6 +49,8 @@ public class FRFitLayoutPropertiesGroupModel implements GroupModel {
editor = new PropertyCellEditor(new IntegerPropertyEditor());
stateEditor = new FitLayoutDirectionEditor();
stateRenderer = new FitStateRenderer();
layoutTypeEditor = new LayoutTypeEditor();
layoutTypeRenderer = new LayoutTypeRenderer();
}
/**
@ -45,21 +58,23 @@ public class FRFitLayoutPropertiesGroupModel implements GroupModel {
*/
@Override
public String getGroupName() {
return Inter.getLocText("FR-Designer-Layout_Adaptive_Layout");
return Inter.getLocText("FR-Designer_Layout");
}
@Override
public int getRowCount() {
return 2;
return 3;
}
@Override
public TableCellRenderer getRenderer(int row) {
switch (row) {
case 0:
return renderer;
default:
return layoutTypeRenderer;
case 1:
return stateRenderer;
default:
return renderer;
}
}
@ -67,9 +82,11 @@ public class FRFitLayoutPropertiesGroupModel implements GroupModel {
public TableCellEditor getEditor(int row) {
switch (row) {
case 0:
return editor;
default:
return layoutTypeEditor;
case 1:
return stateEditor;
default:
return editor;
}
}
@ -78,16 +95,20 @@ public class FRFitLayoutPropertiesGroupModel implements GroupModel {
if (column == 0) {
switch (row) {
case 0:
return Inter.getLocText("FR-Designer_Component_Interval");
default:
return Inter.getLocText("FR-Designer_Attr_Layout_Type");
case 1:
return Inter.getLocText("FR-Designer_Component_Scale");
default:
return Inter.getLocText("FR-Designer_Component_Interval");
}
} else {
switch (row) {
case 0:
return layout.getCompInterval();
default:
return layout.getBodyLayoutType().getTypeValue();
case 1:
return layout.getCompState();
default:
return layout.getCompInterval();
}
}
}
@ -101,13 +122,35 @@ public class FRFitLayoutPropertiesGroupModel implements GroupModel {
if (column == 0 || state < 0) {
return false;
} else {
if (row ==0 && xfl.canAddInterval(state)) {
if (row == 2 && xfl.canAddInterval(state)) {
// 设置完间隔后,要同步处理界面组件,容器刷新后显示出对应效果
setLayoutGap(state);
return true;
}else if (row == 1) {
layout.setCompState(state);
return true;
}else if (row == 0) {
layout.setLayoutType(WBodyLayoutType.parse(state));
if (state == WBodyLayoutType.ABSOLUTE.getTypeValue()) {
WAbsoluteLayout wAbsoluteLayout = new WAbsoluteLayout("body");
wAbsoluteLayout.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);
for (Component component : components) {
xwAbsoluteLayout.add(component);
}
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner();
formDesigner.getSelectionModel().setSelectedCreators(
FormSelectionUtils.rebuildSelection(xfl, new Widget[]{wAbsoluteLayout}));
}
else {
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner();
formDesigner.getSelectionModel().setSelectedCreators(
FormSelectionUtils.rebuildSelection(xfl, new Widget[]{xfl.toData()}));
}
return true;
}
return false;
}

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

@ -0,0 +1,14 @@
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 LayoutTypeRenderer() {
super(new LayoutTypeWrapper());
}
}

13
designer_form/src/com/fr/design/designer/properties/LayoutTypeWrapper.java

@ -0,0 +1,13 @@
package com.fr.design.designer.properties;
import com.fr.design.designer.properties.items.FRLayoutTypeItems;
/**
* Created by zhouping on 2016/9/18.
*/
public class LayoutTypeWrapper extends ItemWrapper{
public LayoutTypeWrapper() {
super(new FRLayoutTypeItems());
}
}

4
designer_form/src/com/fr/design/designer/properties/items/FRFitConstraintsItems.java

@ -13,8 +13,8 @@ import com.fr.general.Inter;
public class FRFitConstraintsItems implements ItemProvider{
public static final Item[] ITEMS = new Item[] {
new Item(Inter.getLocText("Adaptive_Full_Area"), WFitLayout.STATE_FULL),
new Item(Inter.getLocText("Adaptive_Original_Scale"), WFitLayout.STATE_ORIGIN)};
new Item(Inter.getLocText("FR-Designer_Attr_Bidirectional_Adaptive"), WFitLayout.STATE_FULL),
new Item(Inter.getLocText("FR_Designer_Attr_Horizontal_Adaptive"), WFitLayout.STATE_ORIGIN)};
public Item[] getItems() {
return ITEMS;

16
designer_form/src/com/fr/design/designer/properties/items/FRLayoutTypeItems.java

@ -0,0 +1,16 @@
package com.fr.design.designer.properties.items;
import com.fr.form.ui.container.WBodyLayoutType;
/**
* Created by zhouping on 2016/9/18.
*/
public class FRLayoutTypeItems implements ItemProvider{
public static final Item[] ITEMS = new Item[] {
new Item(WBodyLayoutType.FIT.description(), WBodyLayoutType.FIT.getTypeValue()),
new Item(WBodyLayoutType.ABSOLUTE.description(), WBodyLayoutType.ABSOLUTE.getTypeValue())};
public Item[] getItems() {
return ITEMS;
}
}

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

@ -10,11 +10,9 @@ import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath;
import com.fr.base.FRContext;
import com.fr.design.designer.creator.*;
import com.fr.design.mainframe.FormDesigner;
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.XWidgetCreator;
import com.fr.form.ui.Widget;
public class ComponentTreeModel implements TreeModel {
@ -23,6 +21,8 @@ public class ComponentTreeModel implements TreeModel {
private Component root;
private FormDesigner designer;
private final int ABSOLUTE_AS_BODY_NOT_FOUND = -1;
public ComponentTreeModel(FormDesigner designer, Component root) {
this.designer = designer;
this.root = root;
@ -38,6 +38,11 @@ public class ComponentTreeModel implements TreeModel {
if (parent != null && parent instanceof XLayoutContainer) {
XLayoutContainer xlayout = (XLayoutContainer) parent;
XCreator creator = xlayout.getXCreator(index);
//绝对布局作为body的时候不显示自适应布局父层
int absoluteBodyIndex = getAbsoluteBodyIndex(creator);
if (absoluteBodyIndex > ABSOLUTE_AS_BODY_NOT_FOUND){
return creator.getComponent(absoluteBodyIndex);
}
return creator.getXCreator();
}
return null;
@ -135,4 +140,20 @@ public class ComponentTreeModel implements TreeModel {
FRContext.getLogger().error(e.getMessage(), e);
}
}
private int getAbsoluteBodyIndex(XCreator xCreator){
//绝对布局作为body,父层是自适应布局,找到绝对布局位于父层的index
int index = ABSOLUTE_AS_BODY_NOT_FOUND;
if (xCreator.acceptType(XWFitLayout.class)){
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()){
index = i;
}
}
}
return index;
}
}

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_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); }
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_Layout_Block_Absolute"), 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_Layout_Block_Tab"), 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); }

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

@ -18,6 +18,8 @@ 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.treeview.ComponentTreeCellRenderer;
import com.fr.design.designer.treeview.ComponentTreeModel;
import com.fr.stable.StringUtils;
@ -277,6 +279,13 @@ public class ComponentTree extends JTree {
if (creator != comp ) {
creator.notShowInComponentTree(path);
}
//绝对布局作为body的时候不显示自适应布局父层
if (((XCreator) parent).acceptType(XWAbsoluteLayout.class)
&& ((XCreator)parent.getParent()).acceptType(XWFitLayout.class)
&& ((XWAbsoluteLayout)parent).toData().isAbsoluteLayoutAsBody()){
parent = parent.getParent().getParent();
continue;
}
parent = parent.getParent();
}
Object[] components = path.toArray();

9
designer_form/src/com/fr/design/mainframe/FormParaWidgetPane.java

@ -94,12 +94,6 @@ public class FormParaWidgetPane extends JPanel{
private void initFormParaComponent() {
this.removeAll();
// 菜单中的布局先注释掉
JPanel reportPane = new JPanel(new FlowLayout());
reportPane.add(new ToolBarButton(FormWidgetOption.ELEMENTCASE));
add(createNormalCombinationPane(reportPane,Inter.getLocText("FR-Designer-Form-ToolBar_Report")));
add(createJSeparator());
JPanel paraPane = new JPanel(new FlowLayout());
ToolBarButton paraButton = new paraButton(FormWidgetOption.PARAMETERCONTAINER);
paraPane.add(paraButton);
@ -111,7 +105,8 @@ public class FormParaWidgetPane extends JPanel{
for(WidgetOption option : loadLayoutOptions()){
layoutPane.add(new ToolBarButton(option));
}
add(createNormalCombinationPane(layoutPane,Inter.getLocText("FR-Designer_Layout")));
layoutPane.add(new ToolBarButton(FormWidgetOption.ELEMENTCASE));
add(createNormalCombinationPane(layoutPane,Inter.getLocText("FR-Designer_Layout_Block_Blank")));
jSeparatorLayout = createJSeparator();
add(jSeparatorLayout);

15
designer_form/src/com/fr/design/mainframe/widget/editors/LayoutTypeEditor.java

@ -0,0 +1,15 @@
package com.fr.design.mainframe.widget.editors;
import com.fr.design.designer.properties.EnumerationEditor;
import com.fr.design.designer.properties.items.FRLayoutTypeItems;
/**
* Created by zhouping on 2016/9/18.
*/
public class LayoutTypeEditor extends EnumerationEditor {
public LayoutTypeEditor() {
super(new FRLayoutTypeItems());
}
}
Loading…
Cancel
Save