Browse Source

表单body属性面板,在事件右边增加“移动端属性”,然后把手机重布局移到移动端属性面板里面。

这个花的时间较多,主要是整个代码结构都不太一样了,熟悉了好久。。
master
Lee 9 years ago
parent
commit
d76e2e27a0
  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. 7
      designer_form/src/com/fr/design/designer/creator/XWFitLayout.java
  4. 111
      designer_form/src/com/fr/design/designer/properties/BodyMobileLayoutPropertiesGroupModel.java
  5. 62
      designer_form/src/com/fr/design/designer/properties/FRFitLayoutPropertiesGroupModel.java
  6. 83
      designer_form/src/com/fr/design/designer/properties/WidgetLayoutTable.java
  7. 30
      designer_form/src/com/fr/design/designer/properties/mobile/BodyElementCasePropertyUI.java

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

@ -0,0 +1,21 @@
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

@ -0,0 +1,20 @@
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);
}
}

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

@ -13,7 +13,9 @@ import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRFitLayoutAdapter;
import com.fr.design.designer.beans.location.Direction;
import com.fr.design.designer.creator.cardlayout.XWTabFitLayout;
import com.fr.design.designer.properties.mobile.BodyElementCasePropertyUI;
import com.fr.design.form.layout.FRFitLayout;
import com.fr.design.fun.WidgetPropertyUIProvider;
import com.fr.design.mainframe.FormArea;
import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.ui.PaddingMargin;
@ -1156,4 +1158,9 @@ public class XWFitLayout extends XLayoutContainer {
return this;
}
@Override
public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() {
return new WidgetPropertyUIProvider[]{ new BodyElementCasePropertyUI(new XWBodyFitLayout())};
}
}

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

@ -0,0 +1,111 @@
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;
}
}
}

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

@ -5,19 +5,15 @@ package com.fr.design.designer.properties;
import com.fr.design.beans.GroupModel;
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.FitLayoutDirectionEditor;
import com.fr.design.mainframe.widget.editors.IntegerPropertyEditor;
import com.fr.design.mainframe.widget.editors.PropertyCellEditor;
import com.fr.form.ui.container.WFitLayout;
import com.fr.general.Inter;
import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import java.awt.*;
/**
* 自适应布局自身的属性表
@ -32,8 +28,6 @@ public class FRFitLayoutPropertiesGroupModel implements GroupModel {
private DefaultTableCellRenderer renderer;
private FitLayoutDirectionEditor stateEditor;
private FitStateRenderer stateRenderer;
private PropertyCellEditor reLayoutEditor;
private CheckBoxCellRenderer reLayoutrenderer;
private WFitLayout layout;
private XWFitLayout xfl;
@ -44,8 +38,6 @@ public class FRFitLayoutPropertiesGroupModel implements GroupModel {
editor = new PropertyCellEditor(new IntegerPropertyEditor());
stateEditor = new FitLayoutDirectionEditor();
stateRenderer = new FitStateRenderer();
reLayoutrenderer = new CheckBoxCellRenderer();
reLayoutEditor = new PropertyCellEditor(new BooleanEditor());
}
/**
@ -58,7 +50,7 @@ public class FRFitLayoutPropertiesGroupModel implements GroupModel {
@Override
public int getRowCount() {
return 3;
return 2;
}
@Override
@ -66,11 +58,8 @@ public class FRFitLayoutPropertiesGroupModel implements GroupModel {
switch (row) {
case 0:
return renderer;
case 1:
return stateRenderer;
default:
return reLayoutrenderer;
return stateRenderer;
}
}
@ -79,10 +68,8 @@ public class FRFitLayoutPropertiesGroupModel implements GroupModel {
switch (row) {
case 0:
return editor;
case 1:
return stateEditor;
default:
return reLayoutEditor;
return stateEditor;
}
}
@ -92,19 +79,15 @@ public class FRFitLayoutPropertiesGroupModel implements GroupModel {
switch (row) {
case 0:
return Inter.getLocText("FR-Designer_Component_Interval");
case 1 :
return Inter.getLocText("FR-Designer_Component_Scale");
default:
return Inter.getLocText("FR-Designer-App_ReLayout");
return Inter.getLocText("FR-Designer_Component_Scale");
}
} else {
switch (row) {
case 0:
return layout.getCompInterval();
case 1 :
return layout.getCompState();
default:
return layout.getAppRelayout();
return layout.getCompState();
}
}
}
@ -112,11 +95,8 @@ public class FRFitLayoutPropertiesGroupModel implements GroupModel {
@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;
@ -128,9 +108,6 @@ public class FRFitLayoutPropertiesGroupModel implements GroupModel {
}else if (row == 1) {
layout.setCompState(state);
return true;
} else if (row == 2) {
layout.setAppRelayout(appRelayoutState);
return true;
}
return false;
}
@ -155,33 +132,4 @@ public class FRFitLayoutPropertiesGroupModel implements GroupModel {
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;
}
}
}

83
designer_form/src/com/fr/design/designer/properties/WidgetLayoutTable.java

@ -0,0 +1,83 @@
package com.fr.design.designer.properties;
import java.awt.event.MouseEvent;
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.design.designer.creator.*;
import com.fr.design.gui.itable.AbstractPropertyTable;
import com.fr.design.gui.itable.PropertyGroup;
import com.fr.design.designer.beans.LayoutAdapter;
public class WidgetLayoutTable extends AbstractPropertyTable {
private XWBodyFitLayout xwBodyFitLayout;
public WidgetLayoutTable(XWBodyFitLayout xwBodyFitLayout) {
super();
setDesigner(xwBodyFitLayout);
}
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;
}
/**
* 初始化属性表组
* @param source 控件
*/
public void initPropertyGroups(Object source) {
groups = getCreatorPropertyGroup(xwBodyFitLayout);
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
* 属性名悬浮提示
*
* @param 鼠标点击事件
* @return 单元格tooltip
*/
public String getToolTipText(MouseEvent event) {
int row = WidgetLayoutTable.super.rowAtPoint(event.getPoint());
int column = WidgetLayoutTable.super.columnAtPoint(event.getPoint());
if(row != -1 && column == 0){
return String.valueOf(this.getValueAt(row, column));
}
return null;
}
/**
* 待说明
*/
public void firePropertyEdit() {
}
}

30
designer_form/src/com/fr/design/designer/properties/mobile/BodyElementCasePropertyUI.java

@ -0,0 +1,30 @@
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.properties.WidgetLayoutTable;
import com.fr.design.fun.impl.AbstractWidgetPropertyUIProvider;
import com.fr.design.gui.itable.AbstractPropertyTable;
import com.fr.general.Inter;
/**
* Created by Administrator on 2016/5/16/0016.
*/
public class BodyElementCasePropertyUI extends AbstractWidgetPropertyUIProvider {
private XCreator xCreator;
public BodyElementCasePropertyUI(XWBodyFitLayout xWBodyFitLayout) {
this.xCreator = xWBodyFitLayout;
}
@Override
public AbstractPropertyTable createWidgetAttrTable() {
return new WidgetLayoutTable((XWBodyFitLayout) xCreator);
}
@Override
public String tableTitle() {
return Inter.getLocText("FR-Designer_Mobile-Attr");
}
}
Loading…
Cancel
Save