Browse Source

REPORT-560 && REPORT-565 解决日期控件设置format后无法保存和日文设计器下超链接对话框选项后显示的问题

master
kerry 8 years ago
parent
commit
0a8aeb8c61
  1. 93
      designer/src/com/fr/design/widget/ui/DateEditorDefinePane.java
  2. 4
      designer_base/src/com/fr/design/hyperlink/AbstractHyperlinkPane.java

93
designer/src/com/fr/design/widget/ui/DateEditorDefinePane.java

@ -31,7 +31,7 @@ public class DateEditorDefinePane extends DirectWriteEditorDefinePane<DateEditor
private UIComboBox returnTypeComboBox; private UIComboBox returnTypeComboBox;
private UILabel sampleLabel;// preview private UILabel sampleLabel;// preview
// content // content
private UITextField patternTextField = null; private UIComboBox dateFormatComboBox;
private ValueEditorPane startDv; private ValueEditorPane startDv;
private ValueEditorPane endDv; private ValueEditorPane endDv;
@ -42,7 +42,7 @@ public class DateEditorDefinePane extends DirectWriteEditorDefinePane<DateEditor
private void initComponets() { private void initComponets() {
super.initComponents(); super.initComponents();
} }
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return "Date"; return "Date";
@ -63,25 +63,21 @@ public class DateEditorDefinePane extends DirectWriteEditorDefinePane<DateEditor
// sample pane // sample pane
sampleLabel = new UILabel(""); sampleLabel = new UILabel("");
// samplePane.add(sampleLabel, BorderLayout.CENTER);
sampleLabel.setBorder(BorderFactory.createEmptyBorder(2, 4, 4, 4)); sampleLabel.setBorder(BorderFactory.createEmptyBorder(2, 4, 4, 4));
sampleLabel.setHorizontalAlignment(SwingConstants.CENTER); sampleLabel.setHorizontalAlignment(SwingConstants.CENTER);
sampleLabel.setFont(FRContext.getDefaultValues().getFRFont()); sampleLabel.setFont(FRContext.getDefaultValues().getFRFont());
// content pane // content pane
patternTextField = new UITextField(); String[] arr = getDateFormateArray();
patternTextField.getDocument().addDocumentListener(patternTextDocumentListener); dateFormatComboBox = new UIComboBox(arr);
dateFormatComboBox.setPreferredSize(new Dimension(150,20));
String[] arr = getDateFormateArray(); dateFormatComboBox.addActionListener(new ActionListener(){
final UIComboBox comboBox = new UIComboBox(arr);
comboBox.setPreferredSize(new Dimension(150,20));
comboBox.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){ public void actionPerformed(ActionEvent e){
patternTextField.setText( (String)comboBox.getSelectedItem()); refreshPreviewLabel();
} }
}); });
JPanel secondPanel = GUICoreUtils.createFlowPane(new JComponent[]{new UILabel(Inter.getLocText("FR-Engine_Format") + ":"),comboBox,sampleLabel}, FlowLayout.LEFT, 5); JPanel secondPanel = GUICoreUtils.createFlowPane(new JComponent[]{new UILabel(Inter.getLocText("FR-Engine_Format") + ":"),dateFormatComboBox,sampleLabel}, FlowLayout.LEFT, 5);
secondPanel.setPreferredSize(new Dimension(220,30)); secondPanel.setPreferredSize(new Dimension(220,30));
otherContentPane.add(secondPanel); otherContentPane.add(secondPanel);
otherContentPane.add(initStartEndDatePane(), BorderLayout.SOUTH); otherContentPane.add(initStartEndDatePane(), BorderLayout.SOUTH);
@ -104,33 +100,20 @@ public class DateEditorDefinePane extends DirectWriteEditorDefinePane<DateEditor
return rangePane; return rangePane;
} }
private DocumentListener patternTextDocumentListener = new DocumentListener() {
public void insertUpdate(DocumentEvent evt) {
refreshPreviewLabel();
}
public void removeUpdate(DocumentEvent evt) {
refreshPreviewLabel();
}
public void changedUpdate(DocumentEvent evt) {
refreshPreviewLabel();
}
};
private void refreshPreviewLabel() { private void refreshPreviewLabel() {
String text = patternTextField.getText(); String text = (String) dateFormatComboBox.getSelectedItem();
if (text != null && text.length() > 0) { if (text != null && text.length() > 0) {
try { try {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(text); SimpleDateFormat simpleDateFormat = new SimpleDateFormat(text);
String sample = simpleDateFormat.format(new Date()); String sample = simpleDateFormat.format(new Date());
Color c = Color.black; Color c = Color.black;
if (!ArrayUtils.contains(FormatField.getInstance().getDateFormatArray(), text)) { if (!ArrayUtils.contains(FormatField.getInstance().getDateFormatArray(), text)) {
sample += " " + Inter.getLocText("DateFormat-Custom_Warning"); sample += " " + Inter.getLocText("DateFormat-Custom_Warning");
c = Color.red; c = Color.red;
} }
this.sampleLabel.setText(sample); this.sampleLabel.setText(sample);
this.sampleLabel.setForeground(c); this.sampleLabel.setForeground(c);
} catch (Exception exp) { } catch (Exception exp) {
this.sampleLabel.setForeground(Color.red); this.sampleLabel.setForeground(Color.red);
this.sampleLabel.setText(exp.getMessage()); this.sampleLabel.setText(exp.getMessage());
@ -143,12 +126,12 @@ public class DateEditorDefinePane extends DirectWriteEditorDefinePane<DateEditor
@Override @Override
protected void populateSubDirectWriteEditorBean(DateEditor e) { protected void populateSubDirectWriteEditorBean(DateEditor e) {
String formatText = e.getFormatText(); String formatText = e.getFormatText();
patternTextField.setText(formatText); dateFormatComboBox.setSelectedItem(formatText);
returnTypeComboBox.setSelectedIndex(e.isReturnDate() ? 1 : 0); returnTypeComboBox.setSelectedIndex(e.isReturnDate() ? 1 : 0);
populateStartEnd(e); populateStartEnd(e);
}; }
@Override @Override
protected DateEditor updateSubDirectWriteEditorBean() { protected DateEditor updateSubDirectWriteEditorBean() {
@ -162,10 +145,10 @@ public class DateEditorDefinePane extends DirectWriteEditorDefinePane<DateEditor
return ob; return ob;
} }
/** /**
* 初始起止日期 * 初始起止日期
* @param dateWidgetEditor 日期控件 * @param dateWidgetEditor 日期控件
*/ */
public void populateStartEnd(DateEditor dateWidgetEditor) { public void populateStartEnd(DateEditor dateWidgetEditor) {
Formula startFM = dateWidgetEditor.getStartDateFM(); Formula startFM = dateWidgetEditor.getStartDateFM();
Formula endFM = dateWidgetEditor.getEndDateFM(); Formula endFM = dateWidgetEditor.getEndDateFM();
@ -183,10 +166,10 @@ public class DateEditorDefinePane extends DirectWriteEditorDefinePane<DateEditor
} }
} }
/** /**
* 更新日期控件的起止日期 * 更新日期控件的起止日期
* @param dateWidgetEditor 日期控件 * @param dateWidgetEditor 日期控件
*/ */
public void updateStartEnd(DateEditor dateWidgetEditor) { public void updateStartEnd(DateEditor dateWidgetEditor) {
Object startObject = startDv.update(); Object startObject = startDv.update();
Object endObject = endDv.update(); Object endObject = endDv.update();
@ -204,11 +187,11 @@ public class DateEditorDefinePane extends DirectWriteEditorDefinePane<DateEditor
dateWidgetEditor.setStartDateFM(startFormula); dateWidgetEditor.setStartDateFM(startFormula);
dateWidgetEditor.setStartText(null); dateWidgetEditor.setStartText(null);
} else { } else {
try { try {
dateWidgetEditor.setStartText(startObject == null ? "" : DateUtils.getDate2Str("MM/dd/yyyy", (Date)startObject)); dateWidgetEditor.setStartText(startObject == null ? "" : DateUtils.getDate2Str("MM/dd/yyyy", (Date)startObject));
} catch(ClassCastException e) { } catch(ClassCastException e) {
//wei : TODO 说明应用的公式不能转化成日期格式,应该做些处理。 //wei : TODO 说明应用的公式不能转化成日期格式,应该做些处理。
} }
} }
if (endObject instanceof Formula) { if (endObject instanceof Formula) {
cal = Calculator.createCalculator(); cal = Calculator.createCalculator();
@ -222,20 +205,20 @@ public class DateEditorDefinePane extends DirectWriteEditorDefinePane<DateEditor
dateWidgetEditor.setEndDateFM(endFormula); dateWidgetEditor.setEndDateFM(endFormula);
dateWidgetEditor.setEndText(null); dateWidgetEditor.setEndText(null);
} else { } else {
try { try {
dateWidgetEditor.setEndText(endObject == null ? "" : DateUtils.getDate2Str("MM/dd/yyyy", (Date)endObject)); dateWidgetEditor.setEndText(endObject == null ? "" : DateUtils.getDate2Str("MM/dd/yyyy", (Date)endObject));
} catch(ClassCastException e) { } catch(ClassCastException e) {
} }
} }
} }
private SimpleDateFormat getSimpleDateFormat() { private SimpleDateFormat getSimpleDateFormat() {
String text = patternTextField.getText(); String text = (String) dateFormatComboBox.getSelectedItem();
SimpleDateFormat simpleDateFormat; SimpleDateFormat simpleDateFormat;
if (text != null && text.length() > 0) { if (text != null && text.length() > 0) {
try { try {
simpleDateFormat = new SimpleDateFormat(patternTextField.getText()); simpleDateFormat = new SimpleDateFormat(text);
this.sampleLabel.setText(simpleDateFormat.format(new Date())); this.sampleLabel.setText(simpleDateFormat.format(new Date()));
} catch (Exception exp) { } catch (Exception exp) {
simpleDateFormat = new SimpleDateFormat(""); simpleDateFormat = new SimpleDateFormat("");

4
designer_base/src/com/fr/design/hyperlink/AbstractHyperlinkPane.java

@ -63,12 +63,12 @@ public abstract class AbstractHyperlinkPane<T extends Hyperlink> extends BasicBe
newWindowConfPane.add(new UILabel(Inter.getLocText("FR-Designer_Height") + ": ")); newWindowConfPane.add(new UILabel(Inter.getLocText("FR-Designer_Height") + ": "));
heightTextFiled = new UINumberField(); heightTextFiled = new UINumberField();
heightTextFiled.setText(String.valueOf(DEFAULT_H_VALUE)); heightTextFiled.setText(String.valueOf(DEFAULT_H_VALUE));
heightTextFiled.setPreferredSize(new Dimension(60, 20)); heightTextFiled.setPreferredSize(new Dimension(40, 20));
newWindowConfPane.add(heightTextFiled); newWindowConfPane.add(heightTextFiled);
newWindowConfPane.add(new UILabel(" " + Inter.getLocText("FR-Designer_Width") + ": ")); newWindowConfPane.add(new UILabel(" " + Inter.getLocText("FR-Designer_Width") + ": "));
widthTextFiled = new UINumberField(); widthTextFiled = new UINumberField();
widthTextFiled.setText(String.valueOf(DEFAULT_V_VALUE)); widthTextFiled.setText(String.valueOf(DEFAULT_V_VALUE));
widthTextFiled.setPreferredSize(new Dimension(60, 20)); widthTextFiled.setPreferredSize(new Dimension(40, 20));
newWindowConfPane.add(widthTextFiled); newWindowConfPane.add(widthTextFiled);
JPanel centerPanel = new JPanel(new BorderLayout()); JPanel centerPanel = new JPanel(new BorderLayout());

Loading…
Cancel
Save