Lee
9 years ago
7 changed files with 278 additions and 58 deletions
@ -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); |
||||
} |
||||
} |
@ -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); |
||||
} |
||||
} |
@ -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; |
||||
} |
||||
} |
||||
} |
@ -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() { |
||||
|
||||
} |
||||
} |
@ -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…
Reference in new issue