Browse Source

bug修复:

手机重布局不能触发保存以及保存不能生效的问题,已经得到解决了,不采用model的写法,会额外new一个对象,导致读属性和写属性所在对象不是同一个,严重bug,这样代码也得到了很大的精简。
master
Lee 8 years ago
parent
commit
9b56656743
  1. 21
      designer_form/src/com/fr/design/designer/beans/adapters/layout/FRBodyFitLayoutAdapter.java
  2. 20
      designer_form/src/com/fr/design/designer/creator/XWBodyFitLayout.java
  3. 4
      designer_form/src/com/fr/design/designer/creator/XWFitLayout.java
  4. 63
      designer_form/src/com/fr/design/designer/properties/BodyAppRelayoutTable.java
  5. 111
      designer_form/src/com/fr/design/designer/properties/BodyMobileLayoutPropertiesGroupModel.java
  6. 8
      designer_form/src/com/fr/design/designer/properties/mobile/BodyMobilePropertyUI.java

21
designer_form/src/com/fr/design/designer/beans/adapters/layout/FRBodyFitLayoutAdapter.java

@ -1,21 +0,0 @@
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.XWFitLayout;
import com.fr.design.designer.properties.BodyMobileLayoutPropertiesGroupModel;
public class FRBodyFitLayoutAdapter extends FRFitLayoutAdapter {
public FRBodyFitLayoutAdapter(XLayoutContainer container) {
super(container);
}
/**
* 返回布局自身属性方便一些特有设置在layout刷新时处理
*/
@Override
public GroupModel getLayoutProperties() {
XWFitLayout xfl = (XWFitLayout) container;
return new BodyMobileLayoutPropertiesGroupModel(xfl);
}
}

20
designer_form/src/com/fr/design/designer/creator/XWBodyFitLayout.java

@ -1,20 +0,0 @@
package com.fr.design.designer.creator;
import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRBodyFitLayoutAdapter;
import com.fr.form.ui.container.WFitLayout;
import java.awt.Dimension;
public class XWBodyFitLayout extends XWFitLayout {
public XWBodyFitLayout() {
this(new WFitLayout(), new Dimension());
}
public XWBodyFitLayout(WFitLayout widget, Dimension initSize) {
super(widget, initSize);
}
@Override
public LayoutAdapter getLayoutAdapter() {
return new FRBodyFitLayoutAdapter(this);
}
}

4
designer_form/src/com/fr/design/designer/creator/XWFitLayout.java

@ -51,7 +51,7 @@ public class XWFitLayout extends XLayoutContainer {
public XWFitLayout(WFitLayout widget, Dimension initSize) {
super(widget, initSize);
initPercent();
}
@ -1160,7 +1160,7 @@ public class XWFitLayout extends XLayoutContainer {
@Override
public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() {
return new WidgetPropertyUIProvider[]{ new BodyMobilePropertyUI(new XWBodyFitLayout())};
return new WidgetPropertyUIProvider[]{ new BodyMobilePropertyUI(this)};
}
}

63
designer_form/src/com/fr/design/designer/properties/BodyAppRelayoutTable.java

@ -1,40 +1,39 @@
package com.fr.design.designer.properties;
import java.awt.event.MouseEvent;
import java.beans.IntrospectionException;
import java.util.ArrayList;
import javax.swing.JTable;
import javax.swing.table.TableColumn;
import javax.swing.table.TableModel;
import com.fr.design.beans.GroupModel;
import com.fr.base.FRContext;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.*;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.gui.itable.AbstractPropertyTable;
import com.fr.design.gui.itable.PropertyGroup;
import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.gui.xtable.ReportAppPropertyGroupModel;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.mainframe.widget.editors.InChangeBooleanEditor;
import com.fr.general.Inter;
public class BodyAppRelayoutTable extends AbstractPropertyTable {
private XWBodyFitLayout xwBodyFitLayout;
private XCreator xCreator;
private FormDesigner designer;
public BodyAppRelayoutTable(XWBodyFitLayout xwBodyFitLayout) {
super();
setDesigner(xwBodyFitLayout);
public BodyAppRelayoutTable(XCreator xCreator) {
this.xCreator = xCreator;
}
public static ArrayList<PropertyGroup> getCreatorPropertyGroup(XCreator source) {
ArrayList<PropertyGroup> groups = new ArrayList<PropertyGroup>();
if (source instanceof XLayoutContainer) {
LayoutAdapter layoutAdapter = ((XLayoutContainer)source).getLayoutAdapter();
if(layoutAdapter != null){
GroupModel m = layoutAdapter.getLayoutProperties();
if (m != null) {
groups.add(new PropertyGroup(m));
}
}
}
return groups;
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException {
CRPropertyDescriptor[] propertyTableEditor = {
new CRPropertyDescriptor("appRelayout", this.xCreator.toData().getClass()).setEditorClass(InChangeBooleanEditor.class)
.setI18NName(Inter.getLocText("FR-Designer-App_ReLayout"))
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, Inter.getLocText("FR-Designer-Layout_Adaptive_Layout"))
};
return propertyTableEditor;
}
/**
@ -43,20 +42,24 @@ public class BodyAppRelayoutTable extends AbstractPropertyTable {
*/
public void initPropertyGroups(Object source) {
groups = getCreatorPropertyGroup(xwBodyFitLayout);
this.designer = WidgetPropertyPane.getInstance().getEditingFormDesigner();
groups = new ArrayList<PropertyGroup>();
CRPropertyDescriptor[] propertyTableEditor = null;
try {
propertyTableEditor = supportedDescriptor();
}catch (IntrospectionException e) {
FRContext.getLogger().error(e.getMessage());
}
groups.add(new PropertyGroup(new ReportAppPropertyGroupModel(Inter.getLocText("FR-Designer-Layout_Adaptive_Layout"), xCreator, propertyTableEditor, designer)));
TableModel model = new BeanTableModel();
setModel(model);
this.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
TableColumn tc = this.getColumn(this.getColumnName(0));
tc.setPreferredWidth(30);
this.repaint();
}
private void setDesigner(XWBodyFitLayout xwBodyFitLayout) {
this.xwBodyFitLayout = xwBodyFitLayout;
}
/**
* 单元格tooltip
@ -78,6 +81,6 @@ public class BodyAppRelayoutTable extends AbstractPropertyTable {
* 待说明
*/
public void firePropertyEdit() {
designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_EDITED);
}
}

111
designer_form/src/com/fr/design/designer/properties/BodyMobileLayoutPropertiesGroupModel.java

@ -1,111 +0,0 @@
package com.fr.design.designer.properties;
import com.fr.design.beans.GroupModel;
import com.fr.form.ui.container.WFitLayout;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.mainframe.widget.editors.BooleanEditor;
import com.fr.design.mainframe.widget.editors.PropertyCellEditor;
import com.fr.general.Inter;
import javax.swing.*;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import java.awt.*;
public class BodyMobileLayoutPropertiesGroupModel implements GroupModel {
private PropertyCellEditor reLayoutEditor;
private CheckBoxCellRenderer reLayoutrenderer;
private WFitLayout layout;
private XWFitLayout xfl;
public BodyMobileLayoutPropertiesGroupModel(XWFitLayout xfl) {
this.xfl = xfl;
this.layout = xfl.toData();
reLayoutrenderer = new CheckBoxCellRenderer();
reLayoutEditor = new PropertyCellEditor(new BooleanEditor());
}
@Override
public String getGroupName() {
return Inter.getLocText("FR-Designer-Layout_Adaptive_Layout");
}
@Override
public int getRowCount() {
return 1;
}
@Override
public TableCellRenderer getRenderer(int row) {
return reLayoutrenderer;
}
@Override
public TableCellEditor getEditor(int row) {
return reLayoutEditor;
}
@Override
public Object getValue(int row, int column) {
if (column == 0) {
return Inter.getLocText("FR-Designer-App_ReLayout");
}else {
return layout.getAppRelayout();
}
}
@Override
public boolean setValue(Object value, int row, int column) {
int state = 0;
boolean appRelayoutState = true;
if(value instanceof Integer) {
state = (Integer)value;
}else if (value instanceof Boolean) {
appRelayoutState = (boolean)value;
}
if (column == 0 || state < 0) {
return false;
} else {
layout.setAppRelayout(appRelayoutState);
return true;
}
}
/**
* 是否可编辑
* @param row
* @return
*/
@Override
public boolean isEditable(int row) {
return true;
}
private class CheckBoxCellRenderer extends UICheckBox implements TableCellRenderer {
public CheckBoxCellRenderer() {
super();
setOpaque(true);
}
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
if (value instanceof Boolean) {
setSelected(((Boolean) value).booleanValue());
setEnabled(table.isCellEditable(row, column));
if (isSelected) {
setBackground(table.getSelectionBackground());
setForeground(table.getSelectionForeground());
} else {
setForeground(table.getForeground());
setBackground(table.getBackground());
}
} else {
return null;
}
return this;
}
}
}

8
designer_form/src/com/fr/design/designer/properties/mobile/BodyMobilePropertyUI.java

@ -1,7 +1,7 @@
package com.fr.design.designer.properties.mobile;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XWBodyFitLayout;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.properties.BodyAppRelayoutTable;
import com.fr.design.fun.impl.AbstractWidgetPropertyUIProvider;
import com.fr.design.gui.itable.AbstractPropertyTable;
@ -14,13 +14,13 @@ public class BodyMobilePropertyUI extends AbstractWidgetPropertyUIProvider {
private XCreator xCreator;
public BodyMobilePropertyUI(XWBodyFitLayout xWBodyFitLayout) {
this.xCreator = xWBodyFitLayout;
public BodyMobilePropertyUI(XWFitLayout xwFitLayout) {
this.xCreator = xwFitLayout;
}
@Override
public AbstractPropertyTable createWidgetAttrTable() {
return new BodyAppRelayoutTable((XWBodyFitLayout) xCreator);
return new BodyAppRelayoutTable(xCreator);
}
@Override

Loading…
Cancel
Save