From 687f040263802aba61e0149368aac6b37ce1e628 Mon Sep 17 00:00:00 2001 From: zhouping Date: Mon, 1 Aug 2016 23:02:09 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9D=E5=AF=B9=E5=B8=83=E5=B1=80=E7=9A=84?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E8=A1=A8=E7=BC=A9=E6=94=BE=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E6=96=B0=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../layout/FRAbsoluteLayoutAdapter.java | 14 ++- .../designer/creator/XWAbsoluteLayout.java | 31 +++++- .../properties/AbsoluteStateRenderer.java | 12 +++ .../properties/AbsoluteStateWrapper.java | 12 +++ .../FRAbsoluteLayoutPropertiesGroupModel.java | 94 +++++++++++++++++++ .../items/FRAbsoluteConstraintsItems.java | 19 ++++ .../AbsoluteLayoutDirectionEditor.java | 13 +++ 7 files changed, 190 insertions(+), 5 deletions(-) create mode 100644 designer_form/src/com/fr/design/designer/properties/AbsoluteStateRenderer.java create mode 100644 designer_form/src/com/fr/design/designer/properties/AbsoluteStateWrapper.java create mode 100644 designer_form/src/com/fr/design/designer/properties/FRAbsoluteLayoutPropertiesGroupModel.java create mode 100644 designer_form/src/com/fr/design/designer/properties/items/FRAbsoluteConstraintsItems.java create mode 100644 designer_form/src/com/fr/design/mainframe/widget/editors/AbsoluteLayoutDirectionEditor.java diff --git a/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java b/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java index 8ce0d0529e..2847cd8c00 100644 --- a/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java +++ b/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java @@ -2,14 +2,14 @@ package com.fr.design.designer.beans.adapters.layout; import java.awt.*; +import com.fr.design.beans.GroupModel; import com.fr.design.designer.beans.ConstraintsGroupModel; import com.fr.design.designer.beans.HoverPainter; import com.fr.design.designer.beans.painters.FRAbsoluteLayoutPainter; -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.XWAbsoluteLayout; +import com.fr.design.designer.creator.*; import com.fr.design.designer.properties.BoundsGroupModel; +import com.fr.design.designer.properties.FRAbsoluteLayoutPropertiesGroupModel; +import com.fr.design.designer.properties.FRFitLayoutPropertiesGroupModel; import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.gui.LayoutUtils; @@ -112,4 +112,10 @@ public class FRAbsoluteLayoutAdapter extends AbstractLayoutAdapter { public ConstraintsGroupModel getLayoutConstraints(XCreator creator) { return new BoundsGroupModel((XWAbsoluteLayout)container, creator); } + + @Override + public GroupModel getLayoutProperties() { + XWAbsoluteLayout xwAbsoluteLayout = (XWAbsoluteLayout) container; + return new FRAbsoluteLayoutPropertiesGroupModel(xwAbsoluteLayout); + } } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java b/designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java index 46e1c42c2b..b729ce0496 100644 --- a/designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java +++ b/designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java @@ -7,6 +7,7 @@ import java.awt.*; import java.awt.event.ContainerEvent; import java.awt.event.MouseEvent; import java.awt.image.BufferedImage; +import java.beans.IntrospectionException; import java.util.HashMap; import com.fr.design.designer.beans.AdapterBus; @@ -17,15 +18,21 @@ import com.fr.design.designer.beans.adapters.layout.FRAbsoluteLayoutAdapter; import com.fr.design.designer.beans.location.Direction; import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.form.layout.FRAbsoluteLayout; +import com.fr.design.form.util.XCreatorConstants; import com.fr.design.icon.IconPathConstants; import com.fr.design.mainframe.EditingMouseListener; import com.fr.design.mainframe.FormDesigner; +import com.fr.design.mainframe.widget.editors.PaddingMarginEditor; +import com.fr.design.mainframe.widget.editors.WLayoutBorderStyleEditor; +import com.fr.design.mainframe.widget.renderer.LayoutBorderStyleRenderer; +import com.fr.design.mainframe.widget.renderer.PaddingMarginCellRenderer; import com.fr.form.ui.Connector; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget; import com.fr.general.IOUtils; import com.fr.general.Inter; +import com.fr.stable.core.PropertyChangeAdapter; /** * @author richer @@ -105,7 +112,17 @@ public class XWAbsoluteLayout extends XLayoutContainer { protected void initLayoutManager() { this.setLayout(new FRAbsoluteLayout()); } - + + /** + * 是否支持标题样式 + * + * @return 默认false + */ + @Override + public boolean hasTitleStyle() { + return false; + } + @Override public void paintComponent(Graphics g) { super.paintComponent(g); @@ -211,6 +228,18 @@ public class XWAbsoluteLayout extends XLayoutContainer { } } + /** + * 得到属性名 + * @return 属性名 + * @throws java.beans.IntrospectionException + */ + public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { + return new CRPropertyDescriptor[] { + new CRPropertyDescriptor("widgetName", this.data.getClass()).setI18NName( + Inter.getLocText("FR-Designer_Form-Widget_Name")) + }; + } + public void paint(Graphics g) { super.paint(g); //如果鼠标移动到布局内且布局不可编辑,画出编辑蒙层 diff --git a/designer_form/src/com/fr/design/designer/properties/AbsoluteStateRenderer.java b/designer_form/src/com/fr/design/designer/properties/AbsoluteStateRenderer.java new file mode 100644 index 0000000000..4cc770eec8 --- /dev/null +++ b/designer_form/src/com/fr/design/designer/properties/AbsoluteStateRenderer.java @@ -0,0 +1,12 @@ +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 AbsoluteStateRenderer() { + super(new AbsoluteStateWrapper()); + } +} \ No newline at end of file diff --git a/designer_form/src/com/fr/design/designer/properties/AbsoluteStateWrapper.java b/designer_form/src/com/fr/design/designer/properties/AbsoluteStateWrapper.java new file mode 100644 index 0000000000..3a07be8a78 --- /dev/null +++ b/designer_form/src/com/fr/design/designer/properties/AbsoluteStateWrapper.java @@ -0,0 +1,12 @@ +package com.fr.design.designer.properties; + +import com.fr.design.designer.properties.items.FRAbsoluteConstraintsItems; + +/** + * Created by zhouping on 2016/8/1. + */ +public class AbsoluteStateWrapper extends ItemWrapper{ + public AbsoluteStateWrapper() { + super(new FRAbsoluteConstraintsItems()); + } +} diff --git a/designer_form/src/com/fr/design/designer/properties/FRAbsoluteLayoutPropertiesGroupModel.java b/designer_form/src/com/fr/design/designer/properties/FRAbsoluteLayoutPropertiesGroupModel.java new file mode 100644 index 0000000000..fc9c0985cd --- /dev/null +++ b/designer_form/src/com/fr/design/designer/properties/FRAbsoluteLayoutPropertiesGroupModel.java @@ -0,0 +1,94 @@ +package com.fr.design.designer.properties; + +import com.fr.design.beans.GroupModel; +import com.fr.design.designer.creator.XWAbsoluteLayout; +import com.fr.design.mainframe.widget.editors.AbsoluteLayoutDirectionEditor; +import com.fr.design.mainframe.widget.editors.IntegerPropertyEditor; +import com.fr.design.mainframe.widget.editors.PropertyCellEditor; +import com.fr.form.ui.container.WAbsoluteLayout; +import com.fr.general.Inter; + +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; + +/** + * 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; + + public FRAbsoluteLayoutPropertiesGroupModel(XWAbsoluteLayout xwAbsoluteLayout){ + this.xwAbsoluteLayout = xwAbsoluteLayout; + this.layout = xwAbsoluteLayout.toData(); + renderer = new DefaultTableCellRenderer(); + editor = new PropertyCellEditor(new IntegerPropertyEditor()); + stateEditor = new AbsoluteLayoutDirectionEditor(); + stateRenderer = new AbsoluteStateRenderer(); + } + + /** + * 布局管理器自己的属性 + */ + @Override + public String getGroupName() { + return Inter.getLocText("FR-Designer-Widget_Area_Scaling"); + } + + @Override + public int getRowCount() { + return 1; + } + + @Override + public TableCellRenderer getRenderer(int row) { + return stateRenderer; + } + + @Override + public TableCellEditor getEditor(int row) { + return stateEditor; + } + + @Override + public Object getValue(int row, int column) { + if (column == 0) { + return Inter.getLocText("FR-Designer-Widget_Scaling_Mode"); + } else { + return layout.getCompState(); + } + } + + @Override + public boolean setValue(Object value, int row, int column) { + 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; + } +} diff --git a/designer_form/src/com/fr/design/designer/properties/items/FRAbsoluteConstraintsItems.java b/designer_form/src/com/fr/design/designer/properties/items/FRAbsoluteConstraintsItems.java new file mode 100644 index 0000000000..5b46b89564 --- /dev/null +++ b/designer_form/src/com/fr/design/designer/properties/items/FRAbsoluteConstraintsItems.java @@ -0,0 +1,19 @@ +package com.fr.design.designer.properties.items; + +import com.fr.form.ui.container.WAbsoluteLayout; +import com.fr.general.Inter; + +/** + * Created by zhouping on 2016/8/1. + */ +public class FRAbsoluteConstraintsItems implements ItemProvider{ + + public static final Item[] ITEMS = new Item[] { + new Item(Inter.getLocText("FR-Designer_Widget_Scaling_Mode_Fit"), WAbsoluteLayout.STATE_FIT), + new Item(Inter.getLocText("FR-Designer_Widget_Scaling_Mode_Fixed"), WAbsoluteLayout.STATE_FIXED) + }; + + public Item[] getItems() { + return ITEMS; + } +} \ No newline at end of file diff --git a/designer_form/src/com/fr/design/mainframe/widget/editors/AbsoluteLayoutDirectionEditor.java b/designer_form/src/com/fr/design/mainframe/widget/editors/AbsoluteLayoutDirectionEditor.java new file mode 100644 index 0000000000..2998cfdbf6 --- /dev/null +++ b/designer_form/src/com/fr/design/mainframe/widget/editors/AbsoluteLayoutDirectionEditor.java @@ -0,0 +1,13 @@ +package com.fr.design.mainframe.widget.editors; + +import com.fr.design.designer.properties.EnumerationEditor; +import com.fr.design.designer.properties.items.FRAbsoluteConstraintsItems; + +/** + * Created by zhouping on 2016/8/1. + */ +public class AbsoluteLayoutDirectionEditor extends EnumerationEditor { + public AbsoluteLayoutDirectionEditor() { + super(new FRAbsoluteConstraintsItems()); + } +}