|
|
@ -31,94 +31,95 @@ import com.fr.stable.core.PropertyChangeAdapter; |
|
|
|
* @since 6.5.3 |
|
|
|
* @since 6.5.3 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class XDateEditor extends XDirectWriteEditor { |
|
|
|
public class XDateEditor extends XDirectWriteEditor { |
|
|
|
|
|
|
|
|
|
|
|
private UITextField textField; |
|
|
|
private UITextField textField; |
|
|
|
private LimpidButton btn; |
|
|
|
private LimpidButton btn; |
|
|
|
|
|
|
|
|
|
|
|
public XDateEditor(DateEditor widget, Dimension initSize) { |
|
|
|
public XDateEditor(DateEditor widget, Dimension initSize) { |
|
|
|
super(widget, initSize); |
|
|
|
super(widget, initSize); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 控件的属性列表 |
|
|
|
* 控件的属性列表 |
|
|
|
|
|
|
|
* |
|
|
|
* @return 此控件所用的属性列表 |
|
|
|
* @return 此控件所用的属性列表 |
|
|
|
* @throws IntrospectionException 异常 |
|
|
|
* @throws IntrospectionException 异常 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { |
|
|
|
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { |
|
|
|
CRPropertyDescriptor [] tempt=(CRPropertyDescriptor[]) ArrayUtils.addAll( |
|
|
|
CRPropertyDescriptor[] tempt = (CRPropertyDescriptor[]) ArrayUtils.addAll( |
|
|
|
new CRPropertyDescriptor[] { |
|
|
|
new CRPropertyDescriptor[]{ |
|
|
|
new CRPropertyDescriptor("widgetValue", this.data.getClass()).setI18NName( |
|
|
|
new CRPropertyDescriptor("widgetValue", this.data.getClass()).setI18NName( |
|
|
|
Inter.getLocText(new String[]{"Widget", "Value"})).setEditorClass( |
|
|
|
Inter.getLocText(new String[]{"Widget", "Value"})).setEditorClass( |
|
|
|
WidgetValueEditor.class).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, |
|
|
|
WidgetValueEditor.class).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, |
|
|
|
"Advanced").setPropertyChangeListener(new PropertyChangeAdapter() { |
|
|
|
"Advanced").setPropertyChangeListener(new PropertyChangeAdapter() { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void propertyChange() { |
|
|
|
public void propertyChange() { |
|
|
|
initFieldText(); |
|
|
|
initFieldText(); |
|
|
|
} |
|
|
|
} |
|
|
|
})},super.supportedDescriptor()); |
|
|
|
})}, super.supportedDescriptor()); |
|
|
|
return (CRPropertyDescriptor[]) ArrayUtils.addAll(tempt, |
|
|
|
return (CRPropertyDescriptor[]) ArrayUtils.addAll(tempt, |
|
|
|
new CRPropertyDescriptor[] { |
|
|
|
new CRPropertyDescriptor[]{ |
|
|
|
new CRPropertyDescriptor("formatText", this.data.getClass()).setI18NName( |
|
|
|
new CRPropertyDescriptor("formatText", this.data.getClass()).setI18NName( |
|
|
|
Inter.getLocText("FR-Engine_Format")).setEditorClass(formatClass()).setRendererClass( |
|
|
|
Inter.getLocText("FR-Engine_Format")).setEditorClass(formatClass()).setRendererClass( |
|
|
|
DateCellRenderer.class).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"), |
|
|
|
DateCellRenderer.class).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"), |
|
|
|
new CRPropertyDescriptor("startDate", this.data.getClass()).setI18NName( |
|
|
|
new CRPropertyDescriptor("startDate", this.data.getClass()).setI18NName( |
|
|
|
Inter.getLocText("FR-Designer_Start-Date")).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, |
|
|
|
Inter.getLocText("FR-Designer_Start-Date")).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, |
|
|
|
"Advanced").setEditorClass(DateRangeEditor.class), |
|
|
|
"Advanced").setEditorClass(DateRangeEditor.class), |
|
|
|
new CRPropertyDescriptor("endDate", this.data.getClass()).setI18NName( |
|
|
|
new CRPropertyDescriptor("endDate", this.data.getClass()).setI18NName( |
|
|
|
Inter.getLocText("FR-Designer_End-Date")).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, |
|
|
|
Inter.getLocText("FR-Designer_End-Date")).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, |
|
|
|
"Advanced").setEditorClass(DateRangeEditor.class), |
|
|
|
"Advanced").setEditorClass(DateRangeEditor.class), |
|
|
|
new CRPropertyDescriptor("waterMark", this.data.getClass()).setI18NName( |
|
|
|
new CRPropertyDescriptor("waterMark", this.data.getClass()).setI18NName( |
|
|
|
Inter.getLocText("FR-Designer_WaterMark")).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, |
|
|
|
Inter.getLocText("FR-Designer_WaterMark")).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, |
|
|
|
"Advanced"), |
|
|
|
"Advanced"), |
|
|
|
new CRPropertyDescriptor("returnDate", this.data.getClass()).setI18NName( |
|
|
|
new CRPropertyDescriptor("returnDate", this.data.getClass()).setI18NName( |
|
|
|
Inter.getLocText("FR-Designer_Return-Date")).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, |
|
|
|
Inter.getLocText("FR-Designer_Return-Date")).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, |
|
|
|
"Advanced") |
|
|
|
"Advanced") |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected Class formatClass() { |
|
|
|
protected Class formatClass() { |
|
|
|
return DateFormatEditor.class; |
|
|
|
return DateFormatEditor.class; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initFieldText() { |
|
|
|
|
|
|
|
DateEditor dateEditor = (DateEditor) data; |
|
|
|
|
|
|
|
if (dateEditor.getWidgetValue() != null) { |
|
|
|
|
|
|
|
WidgetValue widgetValue = dateEditor.getWidgetValue(); |
|
|
|
|
|
|
|
//控件值.toString
|
|
|
|
|
|
|
|
String valueStr = widgetValue.toString(); |
|
|
|
|
|
|
|
//控件值
|
|
|
|
|
|
|
|
Object value = widgetValue.getValue(); |
|
|
|
|
|
|
|
//格式
|
|
|
|
|
|
|
|
String format = dateEditor.getFormatText(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (value instanceof Date) { |
|
|
|
|
|
|
|
valueStr = DateUtils.getDate2Str(format, (Date) value); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//日期控件默认值
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(valueStr)) { |
|
|
|
|
|
|
|
valueStr = DateUtils.getDate2Str(format, new Date()); |
|
|
|
|
|
|
|
dateEditor.setWidgetValue(new WidgetValue(new Date())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
textField.setText(valueStr); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
protected void initXCreatorProperties() { |
|
|
|
|
|
|
|
super.initXCreatorProperties(); |
|
|
|
|
|
|
|
initFieldText(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initFieldText() { |
|
|
|
|
|
|
|
DateEditor dateEditor = (DateEditor) data; |
|
|
|
|
|
|
|
if (dateEditor.getWidgetValue() != null) { |
|
|
|
|
|
|
|
WidgetValue widgetValue = dateEditor.getWidgetValue(); |
|
|
|
|
|
|
|
//控件值.toString
|
|
|
|
|
|
|
|
String valueStr = widgetValue.toString(); |
|
|
|
|
|
|
|
//控件值
|
|
|
|
|
|
|
|
Object value = widgetValue.getValue(); |
|
|
|
|
|
|
|
//格式
|
|
|
|
|
|
|
|
String format = dateEditor.getFormatText(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(value instanceof Date){ |
|
|
|
|
|
|
|
valueStr = DateUtils.getDate2Str(format, (Date) value); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//日期控件默认值
|
|
|
|
|
|
|
|
if(StringUtils.isEmpty(valueStr)){ |
|
|
|
|
|
|
|
valueStr = DateUtils.getDate2Str(format, new Date()); |
|
|
|
|
|
|
|
dateEditor.setWidgetValue(new WidgetValue(new Date())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
textField.setText(valueStr); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
protected void initXCreatorProperties() { |
|
|
|
|
|
|
|
super.initXCreatorProperties(); |
|
|
|
|
|
|
|
initFieldText(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected JComponent initEditor() { |
|
|
|
protected JComponent initEditor() { |
|
|
|
if (editor == null) { |
|
|
|
if (editor == null) { |
|
|
|
editor = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
editor = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
editor.add(textField = new UITextField(5), BorderLayout.CENTER); |
|
|
|
editor.add(textField = new UITextField(5), BorderLayout.CENTER); |
|
|
|
btn = new LimpidButton("", this.getIconPath(), toData().isVisible() ? FULL_OPACITY : HALF_OPACITY); |
|
|
|
btn = new LimpidButton("", this.getIconPath(), toData().isVisible() ? FULL_OPACITY : HALF_OPACITY); |
|
|
|
btn.setPreferredSize(new Dimension(21, 21)); |
|
|
|
btn.setPreferredSize(new Dimension(21, 21)); |
|
|
|
editor.add(btn, BorderLayout.EAST); |
|
|
|
editor.add(btn, BorderLayout.EAST); |
|
|
|
textField.setOpaque(false); |
|
|
|
textField.setOpaque(false); |
|
|
@ -132,54 +133,46 @@ public class XDateEditor extends XDirectWriteEditor { |
|
|
|
return "date_16.png"; |
|
|
|
return "date_16.png"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected void makeVisible(boolean visible) { |
|
|
|
protected void makeVisible(boolean visible) { |
|
|
|
btn.makeVisible(visible); |
|
|
|
btn.makeVisible(visible); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 获取当前XCreator的一个封装父容器 |
|
|
|
* 获取当前XCreator的一个封装父容器 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param widgetName 当前组件名 |
|
|
|
* @param widgetName 当前组件名 |
|
|
|
* |
|
|
|
* @return 封装的父容器 |
|
|
|
* @return 封装的父容器 |
|
|
|
* @date 2014-11-25-下午4:47:23 |
|
|
|
* |
|
|
|
*/ |
|
|
|
* |
|
|
|
protected XLayoutContainer getCreatorWrapper(String widgetName) { |
|
|
|
* @date 2014-11-25-下午4:47:23 |
|
|
|
return new XWScaleLayout(); |
|
|
|
* |
|
|
|
} |
|
|
|
*/ |
|
|
|
|
|
|
|
protected XLayoutContainer getCreatorWrapper(String widgetName){ |
|
|
|
/** |
|
|
|
return new XWScaleLayout(); |
|
|
|
* 将当前对象添加到父容器中 |
|
|
|
} |
|
|
|
* |
|
|
|
|
|
|
|
* @param parentPanel 父容器组件 |
|
|
|
/** |
|
|
|
* @date 2014-11-25-下午4:57:55 |
|
|
|
* 将当前对象添加到父容器中 |
|
|
|
*/ |
|
|
|
* |
|
|
|
protected void addToWrapper(XLayoutContainer parentPanel, int width, int minHeight) { |
|
|
|
* @param parentPanel 父容器组件 |
|
|
|
this.setSize(width, minHeight); |
|
|
|
* |
|
|
|
parentPanel.add(this); |
|
|
|
* |
|
|
|
} |
|
|
|
* @date 2014-11-25-下午4:57:55 |
|
|
|
|
|
|
|
* |
|
|
|
/** |
|
|
|
*/ |
|
|
|
* 此控件在自适应布局要保持原样高度 |
|
|
|
protected void addToWrapper(XLayoutContainer parentPanel, int width, int minHeight){ |
|
|
|
* |
|
|
|
this.setSize(width, minHeight); |
|
|
|
* @return 是则返回true |
|
|
|
parentPanel.add(this); |
|
|
|
*/ |
|
|
|
} |
|
|
|
@Override |
|
|
|
|
|
|
|
public boolean shouldScaleCreator() { |
|
|
|
/** |
|
|
|
return true; |
|
|
|
* 此控件在自适应布局要保持原样高度 |
|
|
|
} |
|
|
|
* |
|
|
|
|
|
|
|
* @return 是则返回true |
|
|
|
/** |
|
|
|
*/ |
|
|
|
* data属性改变触发其他操作 |
|
|
|
@Override |
|
|
|
*/ |
|
|
|
public boolean shouldScaleCreator() { |
|
|
|
public void firePropertyChange() { |
|
|
|
return true; |
|
|
|
initFieldText(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* data属性改变触发其他操作 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public void firePropertyChange(){ |
|
|
|
|
|
|
|
initFieldText(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |