|
|
|
@ -31,7 +31,7 @@ public class DateEditorDefinePane extends DirectWriteEditorDefinePane<DateEditor
|
|
|
|
|
private UIComboBox returnTypeComboBox; |
|
|
|
|
private UILabel sampleLabel;// preview
|
|
|
|
|
// content
|
|
|
|
|
private UITextField patternTextField = null; |
|
|
|
|
private UIComboBox dateFormatComboBox; |
|
|
|
|
private ValueEditorPane startDv; |
|
|
|
|
private ValueEditorPane endDv; |
|
|
|
|
|
|
|
|
@ -63,25 +63,21 @@ public class DateEditorDefinePane extends DirectWriteEditorDefinePane<DateEditor
|
|
|
|
|
|
|
|
|
|
// sample pane
|
|
|
|
|
sampleLabel = new UILabel(""); |
|
|
|
|
// samplePane.add(sampleLabel, BorderLayout.CENTER);
|
|
|
|
|
sampleLabel.setBorder(BorderFactory.createEmptyBorder(2, 4, 4, 4)); |
|
|
|
|
sampleLabel.setHorizontalAlignment(SwingConstants.CENTER); |
|
|
|
|
sampleLabel.setFont(FRContext.getDefaultValues().getFRFont()); |
|
|
|
|
|
|
|
|
|
// content pane
|
|
|
|
|
patternTextField = new UITextField(); |
|
|
|
|
patternTextField.getDocument().addDocumentListener(patternTextDocumentListener); |
|
|
|
|
|
|
|
|
|
String[] arr = getDateFormateArray(); |
|
|
|
|
final UIComboBox comboBox = new UIComboBox(arr); |
|
|
|
|
comboBox.setPreferredSize(new Dimension(150,20)); |
|
|
|
|
comboBox.addActionListener(new ActionListener(){ |
|
|
|
|
dateFormatComboBox = new UIComboBox(arr); |
|
|
|
|
dateFormatComboBox.setPreferredSize(new Dimension(150,20)); |
|
|
|
|
dateFormatComboBox.addActionListener(new ActionListener(){ |
|
|
|
|
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)); |
|
|
|
|
otherContentPane.add(secondPanel); |
|
|
|
|
otherContentPane.add(initStartEndDatePane(), BorderLayout.SOUTH); |
|
|
|
@ -104,22 +100,9 @@ public class DateEditorDefinePane extends DirectWriteEditorDefinePane<DateEditor
|
|
|
|
|
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() { |
|
|
|
|
String text = patternTextField.getText(); |
|
|
|
|
String text = (String) dateFormatComboBox.getSelectedItem(); |
|
|
|
|
if (text != null && text.length() > 0) { |
|
|
|
|
try { |
|
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(text); |
|
|
|
@ -143,12 +126,12 @@ public class DateEditorDefinePane extends DirectWriteEditorDefinePane<DateEditor
|
|
|
|
|
@Override |
|
|
|
|
protected void populateSubDirectWriteEditorBean(DateEditor e) { |
|
|
|
|
String formatText = e.getFormatText(); |
|
|
|
|
patternTextField.setText(formatText); |
|
|
|
|
dateFormatComboBox.setSelectedItem(formatText); |
|
|
|
|
|
|
|
|
|
returnTypeComboBox.setSelectedIndex(e.isReturnDate() ? 1 : 0); |
|
|
|
|
|
|
|
|
|
populateStartEnd(e); |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected DateEditor updateSubDirectWriteEditorBean() { |
|
|
|
@ -231,11 +214,11 @@ public class DateEditorDefinePane extends DirectWriteEditorDefinePane<DateEditor
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private SimpleDateFormat getSimpleDateFormat() { |
|
|
|
|
String text = patternTextField.getText(); |
|
|
|
|
String text = (String) dateFormatComboBox.getSelectedItem(); |
|
|
|
|
SimpleDateFormat simpleDateFormat; |
|
|
|
|
if (text != null && text.length() > 0) { |
|
|
|
|
try { |
|
|
|
|
simpleDateFormat = new SimpleDateFormat(patternTextField.getText()); |
|
|
|
|
simpleDateFormat = new SimpleDateFormat(text); |
|
|
|
|
this.sampleLabel.setText(simpleDateFormat.format(new Date())); |
|
|
|
|
} catch (Exception exp) { |
|
|
|
|
simpleDateFormat = new SimpleDateFormat(""); |
|
|
|
|