|
|
|
@ -1,19 +1,15 @@
|
|
|
|
|
package com.fr.design.widget.ui; |
|
|
|
|
|
|
|
|
|
import com.formdev.flatlaf.ui.FlatUIUtils; |
|
|
|
|
import com.fr.base.FRContext; |
|
|
|
|
import com.fr.data.core.FormatField; |
|
|
|
|
import com.fr.design.ExtraDesignClassManager; |
|
|
|
|
import com.fr.design.beans.BasicBeanPane; |
|
|
|
|
import com.fr.design.border.UIRoundedBorder; |
|
|
|
|
import com.fr.design.constants.UIConstants; |
|
|
|
|
import com.fr.design.designer.IntervalConstants; |
|
|
|
|
import com.fr.design.fun.WidgetAdvancedPaneProvider; |
|
|
|
|
import com.fr.design.constants.LayoutConstants; |
|
|
|
|
import com.fr.design.gui.ibutton.UIButtonGroup; |
|
|
|
|
import com.fr.design.gui.icombobox.UIComboBox; |
|
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
|
import com.fr.design.i18n.Toolkit; |
|
|
|
|
import com.fr.design.layout.FRGUIPaneFactory; |
|
|
|
|
import com.fr.design.layout.TableLayout; |
|
|
|
|
import com.fr.design.layout.TableLayoutHelper; |
|
|
|
|
import com.fr.design.widget.component.DateValuePane; |
|
|
|
|
import com.fr.design.widget.component.UIComboBoxNoArrow; |
|
|
|
|
import com.fr.design.widget.ui.designer.date.DateFormatCheckManager; |
|
|
|
@ -22,28 +18,31 @@ import com.fr.form.ui.DateEditor;
|
|
|
|
|
|
|
|
|
|
import com.fr.stable.ArrayUtils; |
|
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
|
import javax.swing.JPanel; |
|
|
|
|
import javax.swing.SwingConstants; |
|
|
|
|
import javax.swing.border.TitledBorder; |
|
|
|
|
import javax.swing.event.ChangeEvent; |
|
|
|
|
import javax.swing.event.ChangeListener; |
|
|
|
|
import java.awt.*; |
|
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
|
import java.awt.event.ActionListener; |
|
|
|
|
import java.awt.BorderLayout; |
|
|
|
|
import java.awt.CardLayout; |
|
|
|
|
import java.awt.Color; |
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.Set; |
|
|
|
|
|
|
|
|
|
import static com.fine.swing.ui.layout.Layouts.cell; |
|
|
|
|
import static com.fine.swing.ui.layout.Layouts.column; |
|
|
|
|
import static com.fine.swing.ui.layout.Layouts.row; |
|
|
|
|
import static com.fine.swing.ui.layout.Layouts.flex; |
|
|
|
|
import static com.fr.design.constants.LayoutConstants.LEFT_WEIGHT; |
|
|
|
|
import static com.fr.design.constants.LayoutConstants.RIGHT_WEIGHT; |
|
|
|
|
|
|
|
|
|
public class DateEditorDefinePane extends DirectWriteEditorDefinePane<DateEditor> { |
|
|
|
|
private UIButtonGroup returnTypeComboBox; |
|
|
|
|
private UIButtonGroup returnTypeButtonGroup; |
|
|
|
|
|
|
|
|
|
private DateValuePane startDv; |
|
|
|
|
private DateValuePane endDv; |
|
|
|
|
|
|
|
|
|
private UIComboBox currentFormatComboBox; |
|
|
|
|
private UILabel currentSamplelabel; |
|
|
|
|
private UIButtonGroup fomatHeadGroup; |
|
|
|
|
private static final int SAMPLE_LABEL_PADDING = 4; |
|
|
|
|
|
|
|
|
|
private UILabel currentSampleLabel; |
|
|
|
|
private UIButtonGroup formatButtonGroup; |
|
|
|
|
|
|
|
|
|
public DateEditorDefinePane() { |
|
|
|
|
} |
|
|
|
@ -55,33 +54,22 @@ public class DateEditorDefinePane extends DirectWriteEditorDefinePane<DateEditor
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected JPanel setSecondContentPane() { |
|
|
|
|
returnTypeComboBox = new UIButtonGroup<>(new String[] {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Date") , com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_String")}); |
|
|
|
|
returnTypeButtonGroup = new UIButtonGroup<>(new String[] {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Date") , |
|
|
|
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_String")}); |
|
|
|
|
JPanel formatHead = createFormatHead(); |
|
|
|
|
startDv = new DateValuePane(); |
|
|
|
|
endDv = new DateValuePane(); |
|
|
|
|
double f = TableLayout.FILL; |
|
|
|
|
double p = TableLayout.PREFERRED; |
|
|
|
|
UILabel formatLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Engine_Format")); |
|
|
|
|
formatLabel.setVerticalAlignment(SwingConstants.TOP); |
|
|
|
|
UILabel startDateLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_FS_Start_Date")); |
|
|
|
|
startDateLabel.setVerticalAlignment(SwingConstants.TOP); |
|
|
|
|
UILabel endDateLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_FS_End_Date")); |
|
|
|
|
endDateLabel.setVerticalAlignment(SwingConstants.TOP); |
|
|
|
|
Component[][] components = new Component[][]{ |
|
|
|
|
new Component[]{formatLabel, formatHead}, |
|
|
|
|
new Component[]{startDateLabel, startDv}, |
|
|
|
|
new Component[]{endDateLabel, endDv}, |
|
|
|
|
new Component[]{waterMarkDictPane, null}, |
|
|
|
|
new Component[]{extraPane, null}, |
|
|
|
|
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_Date_Selector_Return_Type")), returnTypeComboBox } |
|
|
|
|
}; |
|
|
|
|
double[] rowSize = {p, p, p, p, p, p, p, p}; |
|
|
|
|
double[] columnSize = {p, f}; |
|
|
|
|
int[][] rowCount = {{1, 3},{1, 1},{1, 1},{1, 1},{1, 1}, {1, 1}}; |
|
|
|
|
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_L2, IntervalConstants.INTERVAL_L1); |
|
|
|
|
|
|
|
|
|
startDv = new DateValuePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_FS_Start_Date")); |
|
|
|
|
endDv = new DateValuePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_FS_End_Date")); |
|
|
|
|
UILabel returnTypeLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Widget_Date_Selector_Return_Type")); |
|
|
|
|
|
|
|
|
|
return panel; |
|
|
|
|
return column(LayoutConstants.VERTICAL_GAP, |
|
|
|
|
cell(formatHead), |
|
|
|
|
cell(startDv), |
|
|
|
|
cell(endDv), |
|
|
|
|
cell(waterMarkDictPane), |
|
|
|
|
row( |
|
|
|
|
cell(returnTypeLabel).weight(LEFT_WEIGHT), cell(returnTypeButtonGroup).weight(RIGHT_WEIGHT) |
|
|
|
|
) |
|
|
|
|
).getComponent(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@ -90,20 +78,19 @@ public class DateEditorDefinePane extends DirectWriteEditorDefinePane<DateEditor
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private JPanel createFormatPane(UIComboBox formatComboBox, UILabel sampleLabel){ |
|
|
|
|
|
|
|
|
|
Color tipColor = FlatUIUtils.getUIColor("Label.tipColor", Color.GRAY); |
|
|
|
|
JPanel previewPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
|
TitledBorder titledBorder = new TitledBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_StyleFormat_Sample"), 4, 2, this.getFont(), UIConstants.LINE_COLOR); |
|
|
|
|
previewPane.setBorder(titledBorder); |
|
|
|
|
TitledBorder titledBorder = new TitledBorder(new UIRoundedBorder(tipColor, 1, 5), |
|
|
|
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_StyleFormat_Sample"), TitledBorder.LEADING, TitledBorder.TOP, |
|
|
|
|
this.getFont(), tipColor); |
|
|
|
|
|
|
|
|
|
JPanel sampleLabelWrapper = new JPanel(new BorderLayout()); |
|
|
|
|
sampleLabelWrapper.setBorder(BorderFactory.createEmptyBorder(0, SAMPLE_LABEL_PADDING, SAMPLE_LABEL_PADDING, SAMPLE_LABEL_PADDING)); |
|
|
|
|
sampleLabelWrapper.add(sampleLabel, BorderLayout.CENTER); |
|
|
|
|
previewPane.setBorder(titledBorder); |
|
|
|
|
previewPane.add(sampleLabel, BorderLayout.CENTER); |
|
|
|
|
return column(LayoutConstants.VERTICAL_GAP, |
|
|
|
|
cell(previewPane), |
|
|
|
|
cell(formatComboBox) |
|
|
|
|
|
|
|
|
|
previewPane.add(sampleLabelWrapper, BorderLayout.CENTER); |
|
|
|
|
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
|
jPanel.add(previewPane, BorderLayout.NORTH); |
|
|
|
|
jPanel.add(formatComboBox, BorderLayout.CENTER); |
|
|
|
|
return jPanel; |
|
|
|
|
).getComponent(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private UILabel createSamplePane(){ |
|
|
|
@ -120,53 +107,45 @@ public class DateEditorDefinePane extends DirectWriteEditorDefinePane<DateEditor
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private JPanel createFormatHead(){ |
|
|
|
|
UILabel formatLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Engine_Format")); |
|
|
|
|
String[] dateArray = FormatField.getInstance().getFormatArray(FormatField.FormatContents.DATE); |
|
|
|
|
String[] timeArray = FormatField.getInstance().getFormatArray(FormatField.FormatContents.TIME); |
|
|
|
|
final UIComboBox dateFormatComboBox = new UIComboBoxNoArrow(dateArray); |
|
|
|
|
final UIComboBox timeFormatComboBox = new UIComboBoxNoArrow(timeArray); |
|
|
|
|
dateFormatComboBox.addActionListener(new ActionListener(){ |
|
|
|
|
public void actionPerformed(ActionEvent e){ |
|
|
|
|
refreshPreviewLabel(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
timeFormatComboBox.addActionListener(new ActionListener(){ |
|
|
|
|
public void actionPerformed(ActionEvent e){ |
|
|
|
|
refreshPreviewLabel(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
dateFormatComboBox.addActionListener(e -> refreshPreviewLabel()); |
|
|
|
|
timeFormatComboBox.addActionListener(e -> refreshPreviewLabel()); |
|
|
|
|
final UILabel dateSampleLabel = createSamplePane(); |
|
|
|
|
final UILabel timeSampleLabel = createSamplePane(); |
|
|
|
|
JPanel fomatHeadPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
|
final CardLayout cardLayout = new CardLayout(); |
|
|
|
|
final JPanel customPane = new JPanel(cardLayout); |
|
|
|
|
JPanel dateFormatPane = createFormatPane(dateFormatComboBox, dateSampleLabel); |
|
|
|
|
JPanel timeFormatPane = createFormatPane(timeFormatComboBox, timeSampleLabel); |
|
|
|
|
customPane.add(dateFormatPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_StyleFormat_Date")); |
|
|
|
|
customPane.add(timeFormatPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_StyleFormat_Time")); |
|
|
|
|
final String[] tabTitles = new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_StyleFormat_Date"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_StyleFormat_Time")}; |
|
|
|
|
fomatHeadGroup = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_StyleFormat_Date"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_StyleFormat_Time")}); |
|
|
|
|
fomatHeadGroup.addChangeListener(new ChangeListener() { |
|
|
|
|
@Override |
|
|
|
|
public void stateChanged(ChangeEvent e) { |
|
|
|
|
int newSelectedIndex = fomatHeadGroup.getSelectedIndex(); |
|
|
|
|
final String[] tabTitles = new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_StyleFormat_Date"), |
|
|
|
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_StyleFormat_Time")}; |
|
|
|
|
formatButtonGroup = new UIButtonGroup<>(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_StyleFormat_Date"), |
|
|
|
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_StyleFormat_Time")}); |
|
|
|
|
formatButtonGroup.addChangeListener(e -> { |
|
|
|
|
int newSelectedIndex = formatButtonGroup.getSelectedIndex(); |
|
|
|
|
cardLayout.show(customPane, tabTitles[newSelectedIndex]); |
|
|
|
|
if(newSelectedIndex == 0){ |
|
|
|
|
currentFormatComboBox = dateFormatComboBox; |
|
|
|
|
currentSamplelabel = dateSampleLabel; |
|
|
|
|
currentSampleLabel = dateSampleLabel; |
|
|
|
|
}else{ |
|
|
|
|
currentFormatComboBox = timeFormatComboBox; |
|
|
|
|
currentSamplelabel = timeSampleLabel; |
|
|
|
|
currentSampleLabel = timeSampleLabel; |
|
|
|
|
} |
|
|
|
|
refreshPreviewLabel(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
fomatHeadPane.add(fomatHeadGroup, BorderLayout.NORTH); |
|
|
|
|
fomatHeadPane.add(customPane, BorderLayout.CENTER); |
|
|
|
|
return fomatHeadPane; |
|
|
|
|
return column(LayoutConstants.VERTICAL_GAP, |
|
|
|
|
row( |
|
|
|
|
cell(formatLabel).weight(LEFT_WEIGHT), cell(formatButtonGroup).weight(RIGHT_WEIGHT) |
|
|
|
|
), |
|
|
|
|
row(flex(LEFT_WEIGHT), cell(customPane).weight(RIGHT_WEIGHT)) |
|
|
|
|
).getComponent(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void refreshPreviewLabel() { |
|
|
|
|
String text = (String) currentFormatComboBox.getSelectedItem(); |
|
|
|
|
if (text != null && text.length() > 0) { |
|
|
|
@ -174,14 +153,14 @@ public class DateEditorDefinePane extends DirectWriteEditorDefinePane<DateEditor
|
|
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(text); |
|
|
|
|
String sample = simpleDateFormat.format(new Date()); |
|
|
|
|
DateFormatCheckResult result = DateFormatCheckManager.check(sample, text); |
|
|
|
|
currentSamplelabel.setText(result.getSample()); |
|
|
|
|
currentSamplelabel.setForeground(result.getColor()); |
|
|
|
|
currentSampleLabel.setText(result.getSample()); |
|
|
|
|
currentSampleLabel.setForeground(result.getColor()); |
|
|
|
|
} catch (Exception exp) { |
|
|
|
|
currentSamplelabel.setForeground(Color.red); |
|
|
|
|
currentSamplelabel.setText(exp.getMessage()); |
|
|
|
|
currentSampleLabel.setForeground(Color.red); |
|
|
|
|
currentSampleLabel.setText(exp.getMessage()); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
currentSamplelabel.setText(new Date().toString()); |
|
|
|
|
currentSampleLabel.setText(new Date().toString()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -201,11 +180,11 @@ public class DateEditorDefinePane extends DirectWriteEditorDefinePane<DateEditor
|
|
|
|
|
@Override |
|
|
|
|
protected void populateSubDirectWriteEditorBean(DateEditor e) { |
|
|
|
|
String formatText = e.getFormatText(); |
|
|
|
|
fomatHeadGroup.setSelectedIndex(getDateType(e)); |
|
|
|
|
fomatHeadGroup.populateBean(); |
|
|
|
|
formatButtonGroup.setSelectedIndex(getDateType(e)); |
|
|
|
|
formatButtonGroup.populateBean(); |
|
|
|
|
currentFormatComboBox.setSelectedItem(formatText); |
|
|
|
|
|
|
|
|
|
returnTypeComboBox.setSelectedIndex(e.isReturnDate() ? 0 : 1); |
|
|
|
|
returnTypeButtonGroup.setSelectedIndex(e.isReturnDate() ? 0 : 1); |
|
|
|
|
startDv.populate(e.getStartDate()); |
|
|
|
|
endDv.populate(e.getEndDate()); |
|
|
|
|
} |
|
|
|
@ -214,7 +193,7 @@ public class DateEditorDefinePane extends DirectWriteEditorDefinePane<DateEditor
|
|
|
|
|
protected DateEditor updateSubDirectWriteEditorBean() { |
|
|
|
|
DateEditor ob = new DateEditor(); |
|
|
|
|
ob.setFormatText(this.getSimpleDateFormat().toPattern()); |
|
|
|
|
ob.setReturnDate(returnTypeComboBox.getSelectedIndex() == 0); |
|
|
|
|
ob.setReturnDate(returnTypeButtonGroup.getSelectedIndex() == 0); |
|
|
|
|
ob.setStartDate(startDv.update()); |
|
|
|
|
ob.setEndDate(endDv.update()); |
|
|
|
|
|
|
|
|
|