forked from fanruan/design
neil
9 years ago
19 changed files with 544 additions and 142 deletions
@ -0,0 +1,70 @@
|
||||
package com.fr.design.report.mobile; |
||||
|
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.gui.icheckbox.UICheckBox; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.general.Inter; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
public class MobileRadioCheckPane extends BasicBeanPane<Boolean> { |
||||
|
||||
private List<UICheckBox> checkBoxes = new ArrayList<UICheckBox>(); |
||||
|
||||
public MobileRadioCheckPane(String title) { |
||||
initComponents(title); |
||||
} |
||||
|
||||
private void initComponents(String title) { |
||||
double p = TableLayout.PREFERRED; |
||||
double[] rowSize = {p}; |
||||
double[] columnSize = {p,p}; |
||||
|
||||
UICheckBox checkBox = new UICheckBox(Inter.getLocText("FR-Designer_Mobile-Open")); |
||||
checkBox.setSelected(true); |
||||
|
||||
checkBoxes.add(checkBox); |
||||
|
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{new UILabel(title), checkBox} |
||||
}; |
||||
JPanel fitOpsPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); |
||||
fitOpsPane.setBorder(BorderFactory.createEmptyBorder(10, 13, 10, 10)); |
||||
|
||||
this.add(fitOpsPane); |
||||
} |
||||
|
||||
public int getCurrentState() { |
||||
return checkBoxes.get(0).isSelected() ? 0 : 1; |
||||
} |
||||
/** |
||||
* 设置按钮状态 |
||||
*/ |
||||
public void setEnabled(boolean enabled) { |
||||
for (UICheckBox checkBox : checkBoxes) { |
||||
checkBox.setEnabled(enabled); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return StringUtils.EMPTY; |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(Boolean ob) { |
||||
checkBoxes.get(0).setSelected(ob); |
||||
} |
||||
|
||||
@Override |
||||
public Boolean updateBean() { |
||||
int state = getCurrentState(); |
||||
return state == 0 ? true : false; |
||||
} |
||||
} |
@ -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,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 BodyAppRelayoutTable extends AbstractPropertyTable { |
||||
|
||||
private XWBodyFitLayout xwBodyFitLayout; |
||||
|
||||
public BodyAppRelayoutTable(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 = BodyAppRelayoutTable.super.rowAtPoint(event.getPoint()); |
||||
int column = BodyAppRelayoutTable.super.columnAtPoint(event.getPoint()); |
||||
if(row != -1 && column == 0){ |
||||
return String.valueOf(this.getValueAt(row, column)); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/** |
||||
* 待说明 |
||||
*/ |
||||
public void firePropertyEdit() { |
||||
|
||||
} |
||||
} |
@ -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,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.BodyAppRelayoutTable; |
||||
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 BodyMobilePropertyUI extends AbstractWidgetPropertyUIProvider { |
||||
|
||||
private XCreator xCreator; |
||||
|
||||
public BodyMobilePropertyUI(XWBodyFitLayout xWBodyFitLayout) { |
||||
this.xCreator = xWBodyFitLayout; |
||||
} |
||||
|
||||
@Override |
||||
public AbstractPropertyTable createWidgetAttrTable() { |
||||
return new BodyAppRelayoutTable((XWBodyFitLayout) xCreator); |
||||
} |
||||
|
||||
@Override |
||||
public String tableTitle() { |
||||
return Inter.getLocText("FR-Designer_Mobile-Attr"); |
||||
} |
||||
} |
@ -0,0 +1,59 @@
|
||||
package com.fr.design.gui.xtable; |
||||
|
||||
import com.fr.base.FRContext; |
||||
import com.fr.design.designer.creator.CRPropertyDescriptor; |
||||
import com.fr.design.designer.creator.XCreator; |
||||
import com.fr.design.mainframe.FormDesigner; |
||||
import com.fr.general.Inter; |
||||
import java.lang.reflect.Method; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.report.stable.FormConstants; |
||||
|
||||
import javax.swing.*; |
||||
|
||||
public class ReportAppPropertyGroupModel extends PropertyGroupModel { |
||||
|
||||
private static final double MAX_HEIGHT = 0.8; |
||||
|
||||
public ReportAppPropertyGroupModel(String name, XCreator creator, CRPropertyDescriptor[] propArray, |
||||
FormDesigner designer) { |
||||
super(name, creator, propArray, designer); |
||||
} |
||||
|
||||
@Override |
||||
public boolean setValue(Object value, int row, int column) { |
||||
double state = 0; |
||||
if (column == 0) { |
||||
return false; |
||||
} |
||||
if (value instanceof Double) { |
||||
state = (Double) value; |
||||
} |
||||
|
||||
try { |
||||
Method m = properties[row].getWriteMethod(); |
||||
if (state > MAX_HEIGHT) { |
||||
//弹窗提示
|
||||
JOptionPane.showMessageDialog(null, |
||||
Inter.getLocText("FR-Designer_Mobile-Warning"), |
||||
Inter.getLocText("FR-Designer_Tooltips"), |
||||
JOptionPane.PLAIN_MESSAGE); |
||||
return false; |
||||
} |
||||
m.invoke(dealCreatorData(), value); |
||||
//属性名称为控件名时,单独处理下
|
||||
if(ComparatorUtils.equals(FormConstants.NAME, properties[row].getName())){ |
||||
creator.resetCreatorName(value.toString()); |
||||
} |
||||
properties[row].firePropertyChanged(); |
||||
return true; |
||||
} catch (Exception e) { |
||||
FRContext.getLogger().error(e.getMessage(), e); |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
private Object dealCreatorData() { |
||||
return creator.getPropertyDescriptorCreator().toData(); |
||||
} |
||||
} |
@ -0,0 +1,31 @@
|
||||
package com.fr.design.mainframe.widget.editors; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.event.KeyAdapter; |
||||
import java.awt.event.KeyEvent; |
||||
import java.awt.event.KeyListener; |
||||
import java.text.ParseException; |
||||
|
||||
public class RefinedDoubleEditor extends DoubleEditor { |
||||
|
||||
private JFormattedTextField textField; |
||||
|
||||
public RefinedDoubleEditor() { |
||||
super(); |
||||
textField = (JFormattedTextField) super.getCustomEditor(); |
||||
} |
||||
|
||||
@Override |
||||
public KeyListener createKeyListener() { |
||||
return new KeyAdapter() { |
||||
|
||||
public void keyReleased(KeyEvent e) { |
||||
try { |
||||
textField.commitEdit(); |
||||
return; |
||||
} catch (ParseException e1) { |
||||
} |
||||
} |
||||
}; |
||||
} |
||||
} |
Loading…
Reference in new issue