From 22deb8b103a6ed98187a6b4ef4f98814cc23d690 Mon Sep 17 00:00:00 2001 From: xiaxiang <1438003374@qq.com> Date: Mon, 25 Apr 2016 10:32:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=8B=E6=9C=BA=E9=87=8D=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FRFitLayoutPropertiesGroupModel.java | 78 ++++++++++++++++--- 1 file changed, 66 insertions(+), 12 deletions(-) diff --git a/designer_form/src/com/fr/design/designer/properties/FRFitLayoutPropertiesGroupModel.java b/designer_form/src/com/fr/design/designer/properties/FRFitLayoutPropertiesGroupModel.java index 529008c000..bbabddcc86 100644 --- a/designer_form/src/com/fr/design/designer/properties/FRFitLayoutPropertiesGroupModel.java +++ b/designer_form/src/com/fr/design/designer/properties/FRFitLayoutPropertiesGroupModel.java @@ -3,18 +3,22 @@ */ package com.fr.design.designer.properties; -import javax.swing.table.DefaultTableCellRenderer; -import javax.swing.table.TableCellEditor; -import javax.swing.table.TableCellRenderer; - 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.design.designer.creator.XWFitLayout; 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.*; + /** * 自适应布局自身的属性表 * 主要为布局内组件间隔(合并水平和竖直间隔),原样缩放(为web端保持当前设计的款高比例) @@ -28,6 +32,8 @@ 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; @@ -38,6 +44,8 @@ public class FRFitLayoutPropertiesGroupModel implements GroupModel { editor = new PropertyCellEditor(new IntegerPropertyEditor()); stateEditor = new FitLayoutDirectionEditor(); stateRenderer = new FitStateRenderer(); + reLayoutrenderer = new CheckBoxCellRenderer(); + reLayoutEditor = new PropertyCellEditor(new BooleanEditor()); } /** @@ -50,7 +58,7 @@ public class FRFitLayoutPropertiesGroupModel implements GroupModel { @Override public int getRowCount() { - return 2; + return 3; } @Override @@ -58,8 +66,11 @@ public class FRFitLayoutPropertiesGroupModel implements GroupModel { switch (row) { case 0: return renderer; - default: + case 1: return stateRenderer; + default: + return reLayoutrenderer; + } } @@ -68,8 +79,10 @@ public class FRFitLayoutPropertiesGroupModel implements GroupModel { switch (row) { case 0: return editor; - default: + case 1: return stateEditor; + default: + return reLayoutEditor; } } @@ -79,22 +92,32 @@ public class FRFitLayoutPropertiesGroupModel implements GroupModel { switch (row) { case 0: return Inter.getLocText("FR-Designer_Component_Interval"); - default : + case 1 : return Inter.getLocText("FR-Designer_Component_Scale"); + default: + return Inter.getLocText("FR-Designer-App_ReLayout"); } } else { switch (row) { case 0: return layout.getCompInterval(); - default : - return layout.getCompState(); + case 1 : + return layout.getCompState(); + default: + return layout.getAppRelayout(); } } } @Override public boolean setValue(Object value, int row, int column) { - int state = (Integer) value; + 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 { @@ -105,6 +128,9 @@ 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; } @@ -130,4 +156,32 @@ public class FRFitLayoutPropertiesGroupModel implements GroupModel { 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; + } + } + } \ No newline at end of file