Browse Source

手机重布局

master
xiaxiang 9 years ago
parent
commit
22deb8b103
  1. 78
      designer_form/src/com/fr/design/designer/properties/FRFitLayoutPropertiesGroupModel.java

78
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;
}
}
}
Loading…
Cancel
Save