|
|
@ -1,53 +1,41 @@ |
|
|
|
package com.fr.design.gui.date; |
|
|
|
package com.fr.design.gui.date; |
|
|
|
|
|
|
|
|
|
|
|
import com.fanruan.product.ProductConstantsBase; |
|
|
|
import com.fanruan.product.ProductConstantsBase; |
|
|
|
import com.formdev.flatlaf.ui.FlatUIUtils; |
|
|
|
import com.fine.theme.icon.LazyIcon; |
|
|
|
|
|
|
|
import com.fine.theme.light.ui.FineRoundBorder; |
|
|
|
|
|
|
|
import com.fine.theme.utils.FineUIStyle; |
|
|
|
|
|
|
|
import com.fine.theme.utils.FineUIUtils; |
|
|
|
import com.formdev.flatlaf.util.ScaledEmptyBorder; |
|
|
|
import com.formdev.flatlaf.util.ScaledEmptyBorder; |
|
|
|
import com.fr.base.BaseUtils; |
|
|
|
import com.fr.design.border.FineBorderFactory; |
|
|
|
import com.fr.base.background.GradientBackground; |
|
|
|
|
|
|
|
import com.fr.design.carton.MonthlyCartonFile; |
|
|
|
import com.fr.design.carton.MonthlyCartonFile; |
|
|
|
import com.fr.design.carton.SwitchForSwingChecker; |
|
|
|
import com.fr.design.carton.SwitchForSwingChecker; |
|
|
|
import com.fr.design.constants.UIConstants; |
|
|
|
|
|
|
|
import com.fr.design.gui.ibutton.UIButton; |
|
|
|
import com.fr.design.gui.ibutton.UIButton; |
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
import com.fr.design.gui.itextfield.UITextField; |
|
|
|
|
|
|
|
import com.fr.design.layout.FRGUIPaneFactory; |
|
|
|
import com.fr.design.layout.FRGUIPaneFactory; |
|
|
|
import com.fr.design.utils.DesignUtils; |
|
|
|
import com.fr.design.utils.DesignUtils; |
|
|
|
import com.fr.design.utils.gui.GUIPaintUtils; |
|
|
|
|
|
|
|
import com.fr.general.GeneralUtils; |
|
|
|
import com.fr.general.GeneralUtils; |
|
|
|
import com.fr.stable.Constants; |
|
|
|
|
|
|
|
import com.fr.stable.StableUtils; |
|
|
|
import com.fr.stable.StableUtils; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.BorderFactory; |
|
|
|
|
|
|
|
import javax.swing.Box; |
|
|
|
import javax.swing.Box; |
|
|
|
import javax.swing.Icon; |
|
|
|
import javax.swing.Icon; |
|
|
|
import javax.swing.JComponent; |
|
|
|
|
|
|
|
import javax.swing.JFrame; |
|
|
|
|
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.SwingConstants; |
|
|
|
import javax.swing.SwingConstants; |
|
|
|
import javax.swing.UIManager; |
|
|
|
|
|
|
|
import javax.swing.border.LineBorder; |
|
|
|
|
|
|
|
import javax.swing.event.ChangeEvent; |
|
|
|
import javax.swing.event.ChangeEvent; |
|
|
|
import javax.swing.event.ChangeListener; |
|
|
|
import javax.swing.event.ChangeListener; |
|
|
|
import javax.swing.event.EventListenerList; |
|
|
|
import javax.swing.event.EventListenerList; |
|
|
|
import java.awt.BorderLayout; |
|
|
|
import java.awt.BorderLayout; |
|
|
|
import java.awt.Color; |
|
|
|
import java.awt.Color; |
|
|
|
import java.awt.Dimension; |
|
|
|
import java.awt.Dimension; |
|
|
|
import java.awt.FlowLayout; |
|
|
|
|
|
|
|
import java.awt.Font; |
|
|
|
import java.awt.Font; |
|
|
|
import java.awt.Graphics; |
|
|
|
import java.awt.Graphics; |
|
|
|
import java.awt.Graphics2D; |
|
|
|
|
|
|
|
import java.awt.GridLayout; |
|
|
|
import java.awt.GridLayout; |
|
|
|
import java.awt.Insets; |
|
|
|
import java.awt.Insets; |
|
|
|
import java.awt.Rectangle; |
|
|
|
|
|
|
|
import java.awt.Shape; |
|
|
|
|
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
import java.awt.event.ActionListener; |
|
|
|
import java.awt.event.ActionListener; |
|
|
|
import java.awt.event.MouseAdapter; |
|
|
|
import java.awt.event.MouseAdapter; |
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
import java.awt.event.MouseListener; |
|
|
|
import java.awt.event.MouseListener; |
|
|
|
import java.awt.geom.RoundRectangle2D; |
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
import java.io.File; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.Calendar; |
|
|
|
import java.util.Calendar; |
|
|
@ -55,25 +43,24 @@ import java.util.Date; |
|
|
|
import java.util.HashSet; |
|
|
|
import java.util.HashSet; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.Set; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static com.fine.swing.ui.layout.Layouts.cell; |
|
|
|
|
|
|
|
import static com.fine.swing.ui.layout.Layouts.fix; |
|
|
|
|
|
|
|
import static com.fine.swing.ui.layout.Layouts.flex; |
|
|
|
|
|
|
|
import static com.fine.swing.ui.layout.Layouts.row; |
|
|
|
|
|
|
|
import static com.fine.theme.utils.FineUIScale.createScaleDimension; |
|
|
|
import static com.fine.theme.utils.FineUIScale.scale; |
|
|
|
import static com.fine.theme.utils.FineUIScale.scale; |
|
|
|
|
|
|
|
import static com.fine.theme.utils.FineUIStyle.STYLE_TEXT; |
|
|
|
|
|
|
|
import static com.fine.theme.utils.FineUIStyle.setStyle; |
|
|
|
|
|
|
|
|
|
|
|
public class UICalendarPanel extends JPanel { |
|
|
|
public class UICalendarPanel extends JPanel { |
|
|
|
private static final Font FONT_UI = DesignUtils.getDefaultGUIFont().applySize(scale(12)); |
|
|
|
private static final String UI_CLASS_ID = "CalendarPaneUI"; |
|
|
|
private static final Font FONT_BLACK = new Font(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Black_Font"), Font.PLAIN, scale(12)); |
|
|
|
|
|
|
|
private static final int WEEKDAY_COUNT = 7; |
|
|
|
private static final int WEEKDAY_COUNT = 7; |
|
|
|
private static final int TOTAL_DAYS_COUNT = 42; |
|
|
|
private static final int TOTAL_DAYS_COUNT = 42; |
|
|
|
|
|
|
|
protected final Insets defaultInsets = new Insets(0, 6, 0, 6); |
|
|
|
private static final int WIDTH = scale(31); |
|
|
|
|
|
|
|
private static final int HEIGHT = scale(19); |
|
|
|
|
|
|
|
private static final int START_X = scale(30); |
|
|
|
|
|
|
|
private static final int START_Y = scale(19); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//卡顿日志所在地址
|
|
|
|
//卡顿日志所在地址
|
|
|
|
private static final String JOURNAL_FILE_PATH = StableUtils.pathJoin(ProductConstantsBase.getEnvHome(), "journal_log"); |
|
|
|
private static final String JOURNAL_FILE_PATH = StableUtils.pathJoin(ProductConstantsBase.getEnvHome(), "journal_log"); |
|
|
|
protected Color selectedBackground; |
|
|
|
|
|
|
|
protected Color selectedForeground; |
|
|
|
|
|
|
|
protected Color background; |
|
|
|
|
|
|
|
protected Color foreground; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Calendar calendar = null; |
|
|
|
private Calendar calendar = null; |
|
|
|
private UILabel monthLabel = null; |
|
|
|
private UILabel monthLabel = null; |
|
|
@ -83,9 +70,11 @@ public class UICalendarPanel extends JPanel { |
|
|
|
private boolean isSupportDateChangeListener = false; |
|
|
|
private boolean isSupportDateChangeListener = false; |
|
|
|
private java.util.Date selectedDate = null; |
|
|
|
private java.util.Date selectedDate = null; |
|
|
|
private boolean isTimePicker; |
|
|
|
private boolean isTimePicker; |
|
|
|
private final Color LABEL_FORGE_GROUND = new Color(0x6F6F6); |
|
|
|
|
|
|
|
private MouseListener todayListener; |
|
|
|
private MouseListener todayListener; |
|
|
|
private UIDayLabel lbToday; |
|
|
|
private UIDayLabel lbToday; |
|
|
|
|
|
|
|
private static final int WEEK_LABEL_WIDTH = 24; |
|
|
|
|
|
|
|
private static final int WEEK_LABEL_HEIGHT = 24; |
|
|
|
|
|
|
|
private final int ICON_WIDTH = 12; |
|
|
|
/** |
|
|
|
/** |
|
|
|
* 一个int类型用于判断日历是否是专门用于处理卡顿的设计器反馈箱中的日历 |
|
|
|
* 一个int类型用于判断日历是否是专门用于处理卡顿的设计器反馈箱中的日历 |
|
|
|
* 0表示是 |
|
|
|
* 0表示是 |
|
|
@ -125,26 +114,12 @@ public class UICalendarPanel extends JPanel { |
|
|
|
this.selectedDate = selectedDate; |
|
|
|
this.selectedDate = selectedDate; |
|
|
|
this.isTimePicker = isTimerPicker; |
|
|
|
this.isTimePicker = isTimerPicker; |
|
|
|
calendar = Calendar.getInstance(); |
|
|
|
calendar = Calendar.getInstance(); |
|
|
|
|
|
|
|
|
|
|
|
selectedBackground = UIManager.getColor( |
|
|
|
|
|
|
|
"ComboBox.selectionBackground"); |
|
|
|
|
|
|
|
selectedForeground = UIManager.getColor( |
|
|
|
|
|
|
|
"ComboBox.selectionForeground"); |
|
|
|
|
|
|
|
background = UIManager.getColor("ComboBox.background"); |
|
|
|
|
|
|
|
foreground = UIManager.getColor("ComboBox.foreground"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dayBttListener = createDayBttListener(); |
|
|
|
dayBttListener = createDayBttListener(); |
|
|
|
|
|
|
|
|
|
|
|
//renderer this
|
|
|
|
|
|
|
|
setPreferredSize(scale(new Dimension(218, 179))); |
|
|
|
|
|
|
|
setBackground(FlatUIUtils.getUIColor("fill.normal", Color.WHITE)); |
|
|
|
|
|
|
|
setBorder(new LineBorder(FlatUIUtils.getUIColor("defaultBorderColor", Color.BLACK))); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
|
|
setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
|
|
add(BorderLayout.NORTH, createNorthPane()); |
|
|
|
add(BorderLayout.NORTH, createNorthPane()); |
|
|
|
add(BorderLayout.CENTER, createCenterPane()); |
|
|
|
add(BorderLayout.CENTER, createCenterPane()); |
|
|
|
if (isTimerPicker) { |
|
|
|
if (isTimerPicker) { |
|
|
|
setPreferredSize(scale(new Dimension(218, 209))); |
|
|
|
|
|
|
|
add(BorderLayout.SOUTH, createSouthPane()); |
|
|
|
add(BorderLayout.SOUTH, createSouthPane()); |
|
|
|
updateHMS(); |
|
|
|
updateHMS(); |
|
|
|
} |
|
|
|
} |
|
|
@ -158,45 +133,23 @@ public class UICalendarPanel extends JPanel { |
|
|
|
// << < yyyy/MM/dd > >>
|
|
|
|
// << < yyyy/MM/dd > >>
|
|
|
|
private JPanel createNorthPane() { |
|
|
|
private JPanel createNorthPane() { |
|
|
|
JPanel pNorth = FRGUIPaneFactory.createX_AXISBoxInnerContainer_S_Pane(); |
|
|
|
JPanel pNorth = FRGUIPaneFactory.createX_AXISBoxInnerContainer_S_Pane(); |
|
|
|
pNorth.setBackground(new Color(0xFFFFFF)); |
|
|
|
pNorth.setPreferredSize(new Dimension(pNorth.getPreferredSize().width, scale(40))); |
|
|
|
pNorth.setPreferredSize(scale(new Dimension(1, 22))); |
|
|
|
pNorth.setOpaque(false); |
|
|
|
|
|
|
|
|
|
|
|
pNorth.add(Box.createHorizontalStrut(5)); |
|
|
|
pNorth.add(Box.createHorizontalStrut(5)); |
|
|
|
pNorth.add(createSkipButton(Calendar.YEAR, -1, new Icon[]{ |
|
|
|
pNorth.add(createSkipButton(Calendar.YEAR, -1, new LazyIcon("drag_left"))); |
|
|
|
BaseUtils.readIcon("/com/fr/design/images/calender/year_reduce.png"), |
|
|
|
|
|
|
|
BaseUtils.readIcon("/com/fr/design/images/calender/year_reduce_hover.png"), |
|
|
|
|
|
|
|
BaseUtils.readIcon("/com/fr/design/images/calender/year_reduce_click.png") |
|
|
|
|
|
|
|
})); |
|
|
|
|
|
|
|
pNorth.add(Box.createHorizontalStrut(11)); |
|
|
|
pNorth.add(Box.createHorizontalStrut(11)); |
|
|
|
UILabel monthMinus = createSkipButton(Calendar.MONTH, -1, new Icon[]{ |
|
|
|
UIButton monthMinus = createSkipButton(Calendar.MONTH, -1, new LazyIcon("left_arrow")); |
|
|
|
BaseUtils.readIcon("/com/fr/design/images/calender/month_reduce.png"), |
|
|
|
|
|
|
|
BaseUtils.readIcon("/com/fr/design/images/calender/month_reduce_hover.png"), |
|
|
|
|
|
|
|
BaseUtils.readIcon("/com/fr/design/images/calender/month_reduce_click.png") |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
monthMinus.setPreferredSize(scale(new Dimension(20, 20))); |
|
|
|
|
|
|
|
pNorth.add(monthMinus); |
|
|
|
pNorth.add(monthMinus); |
|
|
|
monthLabel = new UILabel("", UILabel.CENTER); |
|
|
|
monthLabel = new UILabel("", UILabel.CENTER); |
|
|
|
monthLabel.setBackground(new Color(0xFFFFFF)); |
|
|
|
|
|
|
|
monthLabel.setForeground(new Color(0x000000)); |
|
|
|
|
|
|
|
monthLabel.setFont(FONT_UI); |
|
|
|
|
|
|
|
pNorth.add(Box.createHorizontalGlue()); |
|
|
|
pNorth.add(Box.createHorizontalGlue()); |
|
|
|
pNorth.add(monthLabel); |
|
|
|
pNorth.add(monthLabel); |
|
|
|
pNorth.add(Box.createHorizontalGlue()); |
|
|
|
pNorth.add(Box.createHorizontalGlue()); |
|
|
|
|
|
|
|
|
|
|
|
UILabel monthPlus = createSkipButton(Calendar.MONTH, 1, new Icon[]{ |
|
|
|
UIButton monthPlus = createSkipButton(Calendar.MONTH, 1, new LazyIcon("right_arrow")); |
|
|
|
BaseUtils.readIcon("/com/fr/design/images/calender/month_add.png"), |
|
|
|
|
|
|
|
BaseUtils.readIcon("/com/fr/design/images/calender/month_add_hover.png"), |
|
|
|
|
|
|
|
BaseUtils.readIcon("/com/fr/design/images/calender/month_add_click.png") |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
monthPlus.setPreferredSize(scale(new Dimension(20, 20))); |
|
|
|
|
|
|
|
monthPlus.setHorizontalAlignment(SwingConstants.RIGHT); |
|
|
|
monthPlus.setHorizontalAlignment(SwingConstants.RIGHT); |
|
|
|
pNorth.add(monthPlus); |
|
|
|
pNorth.add(monthPlus); |
|
|
|
pNorth.add(Box.createHorizontalStrut(11)); |
|
|
|
pNorth.add(Box.createHorizontalStrut(11)); |
|
|
|
pNorth.add(createSkipButton(Calendar.YEAR, 1, new Icon[]{ |
|
|
|
pNorth.add(createSkipButton(Calendar.YEAR, 1, new LazyIcon("drag_right"))); |
|
|
|
BaseUtils.readIcon("/com/fr/design/images/calender/year_add.png"), |
|
|
|
|
|
|
|
BaseUtils.readIcon("/com/fr/design/images/calender/year_add_hover.png"), |
|
|
|
|
|
|
|
BaseUtils.readIcon("/com/fr/design/images/calender/year_add_click.png") |
|
|
|
|
|
|
|
})); |
|
|
|
|
|
|
|
pNorth.add(Box.createHorizontalStrut(5)); |
|
|
|
pNorth.add(Box.createHorizontalStrut(5)); |
|
|
|
|
|
|
|
|
|
|
|
return pNorth; |
|
|
|
return pNorth; |
|
|
@ -205,10 +158,8 @@ public class UICalendarPanel extends JPanel { |
|
|
|
|
|
|
|
|
|
|
|
private JPanel createCenterPane() { |
|
|
|
private JPanel createCenterPane() { |
|
|
|
//星期日 星期一 星期二 星期三 星期四 星期五 星期六
|
|
|
|
//星期日 星期一 星期二 星期三 星期四 星期五 星期六
|
|
|
|
JPanel pWeeks = new JPanel(new GridLayout(1, 7, 1, 0)); |
|
|
|
JPanel pWeeks = new JPanel(new GridLayout(1, 7, 9, 0)); |
|
|
|
pWeeks.setPreferredSize(scale(new Dimension(216, 22))); |
|
|
|
pWeeks.setOpaque(false); |
|
|
|
pWeeks.setBackground(new Color(0xFFFFFF)); |
|
|
|
|
|
|
|
pWeeks.setOpaque(true); |
|
|
|
|
|
|
|
String[] strWeeks = new String[]{StringUtils.EMPTY, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Sun"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Mon"), |
|
|
|
String[] strWeeks = new String[]{StringUtils.EMPTY, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Sun"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Mon"), |
|
|
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tue"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Wed"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Thu"), |
|
|
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tue"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Wed"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Thu"), |
|
|
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Fri"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Sat") |
|
|
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Fri"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Sat") |
|
|
@ -216,61 +167,47 @@ public class UICalendarPanel extends JPanel { |
|
|
|
for (int i = 1; i <= WEEKDAY_COUNT; i++) { |
|
|
|
for (int i = 1; i <= WEEKDAY_COUNT; i++) { |
|
|
|
UILabel label = new UILabel(); |
|
|
|
UILabel label = new UILabel(); |
|
|
|
label.setHorizontalAlignment(UILabel.CENTER); |
|
|
|
label.setHorizontalAlignment(UILabel.CENTER); |
|
|
|
label.setForeground(new Color(0x4D4C4C)); |
|
|
|
|
|
|
|
label.setFont(FONT_BLACK); |
|
|
|
|
|
|
|
label.setText(strWeeks[i]); |
|
|
|
label.setText(strWeeks[i]); |
|
|
|
|
|
|
|
label.setPreferredSize(createScaleDimension(WEEK_LABEL_WIDTH, WEEK_LABEL_HEIGHT)); |
|
|
|
pWeeks.add(label); |
|
|
|
pWeeks.add(label); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
pWeeks.setBorder(new ScaledEmptyBorder(3, 9, 3, 9)); |
|
|
|
|
|
|
|
|
|
|
|
//中间放日期的面板
|
|
|
|
//中间放日期的面板
|
|
|
|
days = new DayPane(); |
|
|
|
days = new DayPane(); |
|
|
|
days.setOpaque(true); |
|
|
|
days.setOpaque(false); |
|
|
|
days.setPreferredSize(scale(new Dimension(216, 115))); |
|
|
|
days.setPreferredSize(new Dimension(pWeeks.getPreferredSize().width, scale(165))); |
|
|
|
JPanel pCenter = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
JPanel pCenter = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
pCenter.setOpaque(true); |
|
|
|
pCenter.setOpaque(false); |
|
|
|
pCenter.add(pWeeks, BorderLayout.NORTH); |
|
|
|
pCenter.add(pWeeks, BorderLayout.NORTH); |
|
|
|
pCenter.add(days, BorderLayout.CENTER); |
|
|
|
pCenter.add(days, BorderLayout.CENTER); |
|
|
|
|
|
|
|
|
|
|
|
//显示今天的日期,直接单击图标跳到今天
|
|
|
|
//显示今天的日期,直接单击图标跳到今天
|
|
|
|
GradientPane pToday = new GradientPane(new GradientBackground(new Color(0x097BDA), new Color(0x40A3EE), GradientBackground.TOP2BOTTOM), false); |
|
|
|
|
|
|
|
pToday.setPreferredSize(scale(new Dimension(216, 18))); |
|
|
|
|
|
|
|
pToday.setLayout(new BorderLayout()); |
|
|
|
|
|
|
|
lbToday = new UIDayLabel(new Date(), false); |
|
|
|
lbToday = new UIDayLabel(new Date(), false); |
|
|
|
lbToday.setForeground(new Color(0x000000)); |
|
|
|
lbToday.setPreferredSize(new Dimension(lbToday.getPreferredSize().width, scale(30))); |
|
|
|
todayListener = createTodayListener(pToday, lbToday); |
|
|
|
lbToday.setBorder(FineBorderFactory.createDefaultTopBorder()); |
|
|
|
|
|
|
|
todayListener = createTodayListener(lbToday); |
|
|
|
lbToday.addMouseListener(todayListener); |
|
|
|
lbToday.addMouseListener(todayListener); |
|
|
|
pToday.setBackground(new Color(0xF0F0F0)); |
|
|
|
pCenter.add(lbToday, BorderLayout.SOUTH); |
|
|
|
pToday.add(lbToday, BorderLayout.CENTER); |
|
|
|
|
|
|
|
pCenter.add(pToday, BorderLayout.SOUTH); |
|
|
|
|
|
|
|
return pCenter; |
|
|
|
return pCenter; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private JPanel createSouthPane() { |
|
|
|
private JPanel createSouthPane() { |
|
|
|
JPanel sPane = new JPanel(); |
|
|
|
JPanel sPane = new JPanel(); |
|
|
|
sPane.setPreferredSize(scale(new Dimension(216, 30))); |
|
|
|
sPane.setOpaque(false); |
|
|
|
sPane.setBackground(Color.WHITE); |
|
|
|
sPane.setLayout(new BorderLayout()); |
|
|
|
sPane.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 6)); |
|
|
|
|
|
|
|
UILabel timeLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Time") + ":"); |
|
|
|
UILabel timeLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Time") + ":"); |
|
|
|
timeLabel.setBorder(new ScaledEmptyBorder(0, 9, 0, 5)); |
|
|
|
|
|
|
|
timeLabel.setFont(FONT_UI); |
|
|
|
|
|
|
|
sPane.add(timeLabel); |
|
|
|
|
|
|
|
hms = new HMSPane(); |
|
|
|
hms = new HMSPane(); |
|
|
|
sPane.add(hms); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UILabel gap = new UILabel(); |
|
|
|
|
|
|
|
gap.setPreferredSize(scale(new Dimension(26, 1))); |
|
|
|
|
|
|
|
sPane.add(gap); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UIButton okButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_OK")) { |
|
|
|
UIButton okButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_OK")) { |
|
|
|
public Dimension getPreferredSize() { |
|
|
|
public Dimension getPreferredSize() { |
|
|
|
return scale(new Dimension(32, 18)); |
|
|
|
return createScaleDimension(48, 24); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Insets getInsets() { |
|
|
|
public Insets getInsets() { |
|
|
|
return new Insets(0, 0, 0, 0); |
|
|
|
return new Insets(0, 0, 0, 0); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
okButton.setFont(FONT_UI); |
|
|
|
|
|
|
|
okButton.setVerticalAlignment(SwingConstants.CENTER); |
|
|
|
okButton.setVerticalAlignment(SwingConstants.CENTER); |
|
|
|
okButton.addActionListener(new ActionListener() { |
|
|
|
okButton.addActionListener(new ActionListener() { |
|
|
|
|
|
|
|
|
|
|
@ -282,18 +219,11 @@ public class UICalendarPanel extends JPanel { |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
sPane.add(okButton); |
|
|
|
sPane.add(row(cell(timeLabel).weight(36), cell(hms).weight(180), flex(), cell(okButton).weight(48)).getComponent()); |
|
|
|
|
|
|
|
sPane.setBorder(new ScaledEmptyBorder(10, 12, 10, 12)); |
|
|
|
return sPane; |
|
|
|
return sPane; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void resetHMSPaneSelectedNumberField() { |
|
|
|
|
|
|
|
if (this.hms != null) { |
|
|
|
|
|
|
|
this.hms.selectedNumberField = this.hms.hField; |
|
|
|
|
|
|
|
this.hms.nextButton.requestFocus(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 创建上一月,下一月,上一年,下一年"按钮" |
|
|
|
* 创建上一月,下一月,上一年,下一年"按钮" |
|
|
|
* |
|
|
|
* |
|
|
@ -301,37 +231,20 @@ public class UICalendarPanel extends JPanel { |
|
|
|
* @param amount int |
|
|
|
* @param amount int |
|
|
|
* @return UILabel |
|
|
|
* @return UILabel |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected UILabel createSkipButton(final int field, final int amount, final Icon[] icons) { |
|
|
|
protected UIButton createSkipButton(final int field, final int amount, final Icon icon) { |
|
|
|
if (icons.length != 3) { |
|
|
|
UIButton button = new UIButton(); |
|
|
|
return new UILabel(); |
|
|
|
FineUIStyle.setStyle(button, FineUIStyle.ORIGINAL_BUTTON); |
|
|
|
} |
|
|
|
button.setIcon(icon); |
|
|
|
UILabel label = new UILabel(); |
|
|
|
button.setRequestFocusEnabled(false); |
|
|
|
label.setIcon(icons[0]); |
|
|
|
button.addMouseListener(createSkipListener(field, amount)); |
|
|
|
label.setRequestFocusEnabled(false); |
|
|
|
return button; |
|
|
|
label.addMouseListener(createSkipListener(label, field, amount, icons)); |
|
|
|
|
|
|
|
return label; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected MouseListener createSkipListener(final UILabel label, final int field, |
|
|
|
protected MouseListener createSkipListener(final int field, final int amount) { |
|
|
|
final int amount, final Icon[] icons) { |
|
|
|
|
|
|
|
return new MouseAdapter() { |
|
|
|
return new MouseAdapter() { |
|
|
|
public void mouseReleased(MouseEvent e) { |
|
|
|
public void mouseReleased(MouseEvent e) { |
|
|
|
label.setIcon(icons[1]); |
|
|
|
|
|
|
|
calendar.add(field, amount); |
|
|
|
calendar.add(field, amount); |
|
|
|
updateDays(); |
|
|
|
updateDays(); |
|
|
|
resetHMSPaneSelectedNumberField(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void mouseEntered(MouseEvent e) { |
|
|
|
|
|
|
|
label.setIcon(icons[1]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void mouseExited(MouseEvent e) { |
|
|
|
|
|
|
|
label.setIcon(icons[0]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
|
|
|
|
|
label.setIcon(icons[2]); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
@ -383,10 +296,6 @@ public class UICalendarPanel extends JPanel { |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
label.addMouseListener(dayBttListener); |
|
|
|
label.addMouseListener(dayBttListener); |
|
|
|
label.setEnabled(isCurrentMonth); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!isCurrentMonth) { |
|
|
|
|
|
|
|
label.setForeground(LABEL_FORGE_GROUND); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
/** |
|
|
|
/** |
|
|
@ -432,30 +341,23 @@ public class UICalendarPanel extends JPanel { |
|
|
|
} |
|
|
|
} |
|
|
|
for (int i = 0; i < TOTAL_DAYS_COUNT; i++) { |
|
|
|
for (int i = 0; i < TOTAL_DAYS_COUNT; i++) { |
|
|
|
setupCalendar.add(Calendar.DATE, 1); |
|
|
|
setupCalendar.add(Calendar.DATE, 1); |
|
|
|
GradientPane gp = new GradientPane(new GradientBackground(new Color(0xFEFEFE), new Color(0xF3F2F3), GradientBackground.TOP2BOTTOM), true); |
|
|
|
|
|
|
|
gp.setIndex(i); |
|
|
|
|
|
|
|
gp.setLayout(new BorderLayout()); |
|
|
|
|
|
|
|
gp.setBorder(null); |
|
|
|
|
|
|
|
UIDayLabel label = new UIDayLabel(setupCalendar.getTime()); |
|
|
|
UIDayLabel label = new UIDayLabel(setupCalendar.getTime()); |
|
|
|
label.setHorizontalAlignment(SwingConstants.RIGHT); |
|
|
|
label.setIndex(i); |
|
|
|
label.setBorder(new ScaledEmptyBorder(0, 0, 0, 9)); |
|
|
|
|
|
|
|
if ("1".equals(label.getText())) { |
|
|
|
if ("1".equals(label.getText())) { |
|
|
|
isCurrentMonth = !isCurrentMonth; |
|
|
|
isCurrentMonth = !isCurrentMonth; |
|
|
|
} |
|
|
|
} |
|
|
|
setUIDayLabel(label, isCurrentMonth, setupCalendar, logSet); |
|
|
|
setUIDayLabel(label, isCurrentMonth, setupCalendar, logSet); |
|
|
|
|
|
|
|
label.setCurrentMonth(isCurrentMonth); |
|
|
|
|
|
|
|
days.add(label); |
|
|
|
//当前选择的日期
|
|
|
|
//当前选择的日期
|
|
|
|
if (setupCalendar.get(Calendar.DAY_OF_MONTH) == selectedCalendar.get(Calendar.DAY_OF_MONTH) && isCurrentMonth) { |
|
|
|
if (setupCalendar.get(Calendar.DAY_OF_MONTH) == selectedCalendar.get(Calendar.DAY_OF_MONTH) && isCurrentMonth) { |
|
|
|
gp.setGradientBackground(new GradientBackground(new Color(0x097BD9), new Color(0x41A3EE), GradientBackground.TOP2BOTTOM)); |
|
|
|
|
|
|
|
gp.add(label, BorderLayout.CENTER); |
|
|
|
|
|
|
|
days.add(gp); |
|
|
|
|
|
|
|
days.setSelectedIndex(i); |
|
|
|
days.setSelectedIndex(i); |
|
|
|
|
|
|
|
label.setSelected(true); |
|
|
|
this.selectedDate = label.getDate(); |
|
|
|
this.selectedDate = label.getDate(); |
|
|
|
this.calendar.setTime(this.selectedDate); |
|
|
|
this.calendar.setTime(this.selectedDate); |
|
|
|
} else { |
|
|
|
|
|
|
|
gp.add(label, BorderLayout.CENTER); |
|
|
|
|
|
|
|
days.add(gp); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
days.setBorder(new ScaledEmptyBorder(3, 9, 3, 9)); |
|
|
|
days.validate(); |
|
|
|
days.validate(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -466,33 +368,11 @@ public class UICalendarPanel extends JPanel { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected MouseListener createTodayListener(final GradientPane jp, final UIDayLabel label) { |
|
|
|
protected MouseListener createTodayListener(final UIDayLabel label) { |
|
|
|
return new MouseAdapter() { |
|
|
|
return new MouseAdapter() { |
|
|
|
@Override |
|
|
|
|
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
|
|
|
|
|
jp.setBorder(BorderFactory.createLineBorder(new Color(0x3868AA))); |
|
|
|
|
|
|
|
jp.setPaintGradientBackground(true); |
|
|
|
|
|
|
|
jp.repaint(); |
|
|
|
|
|
|
|
label.setForeground(new Color(0xFFFFFF)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void mouseExited(MouseEvent e) { |
|
|
|
|
|
|
|
jp.setBackground(new Color(0xF0F0F0)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void mouseEntered(MouseEvent e) { |
|
|
|
|
|
|
|
jp.setBackground(new Color(0xC8DDEE)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void mouseReleased(MouseEvent e) { |
|
|
|
public void mouseReleased(MouseEvent e) { |
|
|
|
jp.setBackground(new Color(0xF0F0F0)); |
|
|
|
|
|
|
|
label.setForeground(new Color(0x000000)); |
|
|
|
|
|
|
|
jp.setBorder(null); |
|
|
|
|
|
|
|
jp.setPaintGradientBackground(false); |
|
|
|
|
|
|
|
jp.repaint(); |
|
|
|
|
|
|
|
if (isTimePicker) { |
|
|
|
if (isTimePicker) { |
|
|
|
UICalendarPanel.this.setSelectedDate(label.getDate()); |
|
|
|
UICalendarPanel.this.setSelectedDate(label.getDate()); |
|
|
|
updateDays(); |
|
|
|
updateDays(); |
|
|
@ -501,7 +381,6 @@ public class UICalendarPanel extends JPanel { |
|
|
|
UICalendarPanel.this.setSelectedDate(label.getDate()); |
|
|
|
UICalendarPanel.this.setSelectedDate(label.getDate()); |
|
|
|
UICalendarPanel.this.isSupportDateChangeListener = false; |
|
|
|
UICalendarPanel.this.isSupportDateChangeListener = false; |
|
|
|
} |
|
|
|
} |
|
|
|
resetHMSPaneSelectedNumberField(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
@ -511,12 +390,11 @@ public class UICalendarPanel extends JPanel { |
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
|
if (isEnabled()) { |
|
|
|
if (isEnabled()) { |
|
|
|
UIDayLabel com = (UIDayLabel) e.getComponent(); |
|
|
|
UIDayLabel com = (UIDayLabel) e.getComponent(); |
|
|
|
GradientPane gp = (GradientPane) com.getParent(); |
|
|
|
days.setSelectedIndex(com.getIndex()); |
|
|
|
if (days.selectedIndex != -1) { |
|
|
|
com.setHovered(false); |
|
|
|
((GradientPane) days.getComponent(days.selectedIndex)).setGradientBackground(new GradientBackground(new Color(0xFEFEFE), new Color(0xF3F2F3), GradientBackground.TOP2BOTTOM)); |
|
|
|
com.setPressed(true); |
|
|
|
} |
|
|
|
com.getParent().validate(); |
|
|
|
gp.setGradientBackground(new GradientBackground(new Color(0x097BD9), new Color(0x41A3EE), GradientBackground.TOP2BOTTOM)); |
|
|
|
com.getParent().repaint(); |
|
|
|
days.setSelectedIndex(gp.getIndex()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -530,31 +408,30 @@ public class UICalendarPanel extends JPanel { |
|
|
|
UICalendarPanel.this.setSelectedDate(com.getDate()); |
|
|
|
UICalendarPanel.this.setSelectedDate(com.getDate()); |
|
|
|
UICalendarPanel.this.isSupportDateChangeListener = false; |
|
|
|
UICalendarPanel.this.isSupportDateChangeListener = false; |
|
|
|
} |
|
|
|
} |
|
|
|
resetHMSPaneSelectedNumberField(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void mouseEntered(MouseEvent e) { |
|
|
|
public void mouseEntered(MouseEvent e) { |
|
|
|
if (isEnabled()) { |
|
|
|
if (isEnabled()) { |
|
|
|
JComponent com = (JComponent) e.getComponent(); |
|
|
|
UIDayLabel com = (UIDayLabel) e.getComponent(); |
|
|
|
GradientPane gp = (GradientPane) com.getParent(); |
|
|
|
com.setHovered(true); |
|
|
|
if (gp.getIndex() == days.selectedIndex) { |
|
|
|
if (com.getIndex() == days.selectedIndex) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
gp.setGradientBackground(new GradientBackground(new Color(0xFFFFFF), new Color(0xEAF4FC), GradientBackground.TOP2BOTTOM)); |
|
|
|
days.setFloatIndex(com.getIndex()); |
|
|
|
days.setFloatIndex(gp.getIndex()); |
|
|
|
com.getParent().validate(); |
|
|
|
|
|
|
|
com.getParent().repaint(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void mouseExited(MouseEvent e) { |
|
|
|
public void mouseExited(MouseEvent e) { |
|
|
|
if (isEnabled()) { |
|
|
|
if (isEnabled()) { |
|
|
|
JComponent com = (JComponent) e.getComponent(); |
|
|
|
UIDayLabel com = (UIDayLabel) e.getComponent(); |
|
|
|
GradientPane gp = (GradientPane) com.getParent(); |
|
|
|
com.setHovered(false); |
|
|
|
if (gp.getIndex() != days.selectedIndex) { |
|
|
|
com.setPressed(false); |
|
|
|
gp.setGradientBackground(new GradientBackground(new Color(0xFEFEFE), new Color(0xF3F2F3), GradientBackground.TOP2BOTTOM)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
days.setFloatIndex(-1); |
|
|
|
days.setFloatIndex(-1); |
|
|
|
days.repaint(); |
|
|
|
com.getParent().validate(); |
|
|
|
|
|
|
|
com.getParent().repaint(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
@ -596,127 +473,34 @@ public class UICalendarPanel extends JPanel { |
|
|
|
return selectedDate; |
|
|
|
return selectedDate; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private class GradientPane extends JPanel { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private int index; |
|
|
|
|
|
|
|
private boolean isGradientBackground; |
|
|
|
|
|
|
|
private GradientBackground gradientBackground; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public GradientPane() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public GradientPane(GradientBackground gradientBackground, boolean isGradientBackground) { |
|
|
|
|
|
|
|
super(); |
|
|
|
|
|
|
|
this.gradientBackground = gradientBackground; |
|
|
|
|
|
|
|
this.isGradientBackground = isGradientBackground; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void paint(Graphics g) { |
|
|
|
|
|
|
|
super.paint(g); |
|
|
|
|
|
|
|
if (isGradientBackground && gradientBackground != null) { |
|
|
|
|
|
|
|
gradientBackground.paint(g, new Rectangle(this.getWidth(), this.getHeight())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
paintChildren(g); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setPaintGradientBackground(boolean flag) { |
|
|
|
|
|
|
|
this.isGradientBackground = flag; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setGradientBackground(GradientBackground gradientBackground) { |
|
|
|
|
|
|
|
this.gradientBackground = gradientBackground; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setIndex(int i) { |
|
|
|
|
|
|
|
this.index = i; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int getIndex() { |
|
|
|
|
|
|
|
return this.index; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setForeground(Color c) { |
|
|
|
|
|
|
|
super.setForeground(c); |
|
|
|
|
|
|
|
if (getComponentCount() > 0) { |
|
|
|
|
|
|
|
getComponent(0).setForeground(c); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private class DayPane extends JPanel { |
|
|
|
private class DayPane extends JPanel { |
|
|
|
private Color floatColor = new Color(0xC5E2F9); |
|
|
|
private Color floatColor = new Color(0xC5E2F9); |
|
|
|
private Color selectedColor = new Color(0x41A3EE); |
|
|
|
|
|
|
|
private int floateIndex; |
|
|
|
private int floateIndex; |
|
|
|
private int selectedIndex; |
|
|
|
private int selectedIndex; |
|
|
|
|
|
|
|
|
|
|
|
public DayPane() { |
|
|
|
public DayPane() { |
|
|
|
floateIndex = -1; |
|
|
|
floateIndex = -1; |
|
|
|
selectedIndex = -1; |
|
|
|
selectedIndex = -1; |
|
|
|
this.setLayout(new GridLayout(6, 7, 1, 1)); |
|
|
|
this.setLayout(new GridLayout(6, 7, scale(9), scale(3))); |
|
|
|
this.setBackground(new Color(0xFFFFFF)); |
|
|
|
|
|
|
|
this.setBorder(BorderFactory.createMatteBorder(1, 0, 1, 0, new Color(0xDADADA))); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void paint(Graphics g) { |
|
|
|
public void paint(Graphics g) { |
|
|
|
super.paint(g); |
|
|
|
super.paint(g); |
|
|
|
int width = UICalendarPanel.WIDTH; |
|
|
|
|
|
|
|
int height = UICalendarPanel.HEIGHT; |
|
|
|
|
|
|
|
Color oldColor = g.getColor(); |
|
|
|
Color oldColor = g.getColor(); |
|
|
|
g.setColor(new Color(0xDADADA)); |
|
|
|
|
|
|
|
int start_x = UICalendarPanel.START_X; |
|
|
|
|
|
|
|
int start_y = UICalendarPanel.START_Y; |
|
|
|
|
|
|
|
for (int i = 0; i < 6; i++) { |
|
|
|
|
|
|
|
g.drawLine(start_x, 0, start_x, getHeight()); |
|
|
|
|
|
|
|
start_x += width; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
for (int i = 0; i < 5; i++) { |
|
|
|
|
|
|
|
g.drawLine(0, start_y, getWidth(), start_y); |
|
|
|
|
|
|
|
start_y += height; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (floateIndex > -1) { |
|
|
|
if (floateIndex > -1) { |
|
|
|
g.setColor(floatColor); |
|
|
|
g.setColor(floatColor); |
|
|
|
paintChindPane(g, floateIndex); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (selectedIndex > -1) { |
|
|
|
|
|
|
|
g.setColor(selectedColor); |
|
|
|
|
|
|
|
paintChindPane(g, selectedIndex); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
g.setColor(oldColor); |
|
|
|
g.setColor(oldColor); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void paintChindPane(Graphics g, int index) { |
|
|
|
|
|
|
|
if (index % 7 == 0) { |
|
|
|
|
|
|
|
int y1 = index / 7 * UICalendarPanel.HEIGHT; |
|
|
|
|
|
|
|
g.drawLine(0, y1, UICalendarPanel.START_X, y1); |
|
|
|
|
|
|
|
g.drawLine(0, y1 + UICalendarPanel.HEIGHT, UICalendarPanel.START_X, y1 + UICalendarPanel.HEIGHT); |
|
|
|
|
|
|
|
g.drawLine(UICalendarPanel.START_X, y1, UICalendarPanel.START_X, y1 + UICalendarPanel.HEIGHT); |
|
|
|
|
|
|
|
} else if (index % 7 == 6) { |
|
|
|
|
|
|
|
int y1 = index / 7 * UICalendarPanel.HEIGHT; |
|
|
|
|
|
|
|
g.drawLine(scale(185), y1, scale(216), y1); |
|
|
|
|
|
|
|
g.drawLine(scale(185), y1 + UICalendarPanel.HEIGHT, scale(216), y1 + UICalendarPanel.HEIGHT); |
|
|
|
|
|
|
|
g.drawLine(scale(185), y1, scale(185), y1 + UICalendarPanel.HEIGHT); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
int x1 = index % 7 * UICalendarPanel.WIDTH - 1; |
|
|
|
|
|
|
|
int y1 = index / 7 * UICalendarPanel.HEIGHT; |
|
|
|
|
|
|
|
g.drawRect(x1, y1, UICalendarPanel.WIDTH, UICalendarPanel.HEIGHT); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setFloatIndex(int index) { |
|
|
|
public void setFloatIndex(int index) { |
|
|
|
this.floateIndex = index; |
|
|
|
this.floateIndex = index; |
|
|
|
repaint(); |
|
|
|
repaint(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setSelectedIndex(int index) { |
|
|
|
public void setSelectedIndex(int index) { |
|
|
|
if (this.selectedIndex != -1 && this.selectedIndex < getComponentCount()) { |
|
|
|
|
|
|
|
this.getComponent(selectedIndex).setForeground(Color.black); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (index != -1 && index < getComponentCount()) { |
|
|
|
|
|
|
|
this.getComponent(index).setForeground(Color.WHITE); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.selectedIndex = index; |
|
|
|
this.selectedIndex = index; |
|
|
|
repaint(); |
|
|
|
repaint(); |
|
|
|
} |
|
|
|
} |
|
|
@ -725,17 +509,13 @@ public class UICalendarPanel extends JPanel { |
|
|
|
|
|
|
|
|
|
|
|
private class HMSPane extends JPanel { |
|
|
|
private class HMSPane extends JPanel { |
|
|
|
private boolean isRolOver; |
|
|
|
private boolean isRolOver; |
|
|
|
private UIButton preButton; |
|
|
|
|
|
|
|
private UIButton nextButton; |
|
|
|
|
|
|
|
private CalendarNumberField hField; |
|
|
|
private CalendarNumberField hField; |
|
|
|
private CalendarNumberField mField; |
|
|
|
private CalendarNumberField mField; |
|
|
|
private CalendarNumberField sField; |
|
|
|
private CalendarNumberField sField; |
|
|
|
private CalendarNumberField selectedNumberField; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public HMSPane() { |
|
|
|
public HMSPane() { |
|
|
|
this.setPreferredSize(scale(new Dimension(101, 18))); |
|
|
|
|
|
|
|
this.setLayout(new BorderLayout(0, 0)); |
|
|
|
this.setLayout(new BorderLayout(0, 0)); |
|
|
|
this.setBackground(null); |
|
|
|
this.setOpaque(false); |
|
|
|
|
|
|
|
|
|
|
|
initComponents(); |
|
|
|
initComponents(); |
|
|
|
initListener(); |
|
|
|
initListener(); |
|
|
@ -757,49 +537,68 @@ public class UICalendarPanel extends JPanel { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initComponents() { |
|
|
|
private void initComponents() { |
|
|
|
JPanel jp = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 2)); |
|
|
|
|
|
|
|
jp.setBackground(null); |
|
|
|
|
|
|
|
jp.setBorder(null); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hField = new CalendarNumberField(23); |
|
|
|
hField = new CalendarNumberField(23); |
|
|
|
mField = new CalendarNumberField(59); |
|
|
|
mField = new CalendarNumberField(59); |
|
|
|
sField = new CalendarNumberField(59); |
|
|
|
sField = new CalendarNumberField(59); |
|
|
|
selectedNumberField = hField; |
|
|
|
this.add(row(cell(combineFieldArrowPane(hField)), cell(createGapLabel()), cell(combineFieldArrowPane(mField)), |
|
|
|
|
|
|
|
cell(createGapLabel()), cell(combineFieldArrowPane(sField)), fix(4)).getComponent(), BorderLayout.CENTER); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private JPanel combineFieldArrowPane(CalendarNumberField field) { |
|
|
|
|
|
|
|
JPanel panel = new JPanel(new BorderLayout()); |
|
|
|
|
|
|
|
panel.setOpaque(false); |
|
|
|
|
|
|
|
Insets insets = FineUIUtils.getUIInsets("InputTextField.borderInsets", defaultInsets); |
|
|
|
|
|
|
|
field.setBorder(new ScaledEmptyBorder(insets.top, insets.left, insets.bottom, insets.right)); |
|
|
|
|
|
|
|
UIButton preButton = createArrowButton(new LazyIcon("up_arrow", ICON_WIDTH)); |
|
|
|
|
|
|
|
UIButton nextButton = createArrowButton(new LazyIcon("down_arrow", ICON_WIDTH)); |
|
|
|
|
|
|
|
JPanel arrowPane = createArrowPane(preButton, nextButton); |
|
|
|
|
|
|
|
panel.add(field, BorderLayout.CENTER); |
|
|
|
|
|
|
|
panel.add(arrowPane, BorderLayout.EAST); |
|
|
|
|
|
|
|
panel.setBorder(new FineRoundBorder()); |
|
|
|
|
|
|
|
|
|
|
|
jp.add(hField); |
|
|
|
nextButton.addActionListener(new ActionListener() { |
|
|
|
jp.add(createGapLabel()); |
|
|
|
@Override |
|
|
|
jp.add(mField); |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
jp.add(createGapLabel()); |
|
|
|
field.setValue(field.getIntValue() - 1); |
|
|
|
jp.add(sField); |
|
|
|
field.requestFocus(); |
|
|
|
|
|
|
|
field.selectAll(); |
|
|
|
|
|
|
|
|
|
|
|
this.add(jp, BorderLayout.CENTER); |
|
|
|
|
|
|
|
preButton = new UIButton(UIConstants.ARROW_UP_ICON) { |
|
|
|
|
|
|
|
public boolean shouldResponseChangeListener() { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}); |
|
|
|
preButton.setRoundBorder(true, Constants.LEFT); |
|
|
|
preButton.addActionListener(new ActionListener() { |
|
|
|
nextButton = new UIButton(UIConstants.ARROW_DOWN_ICON) { |
|
|
|
@Override |
|
|
|
public boolean shouldResponseChangeListener() { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
return false; |
|
|
|
field.setValue(field.getIntValue() + 1); |
|
|
|
|
|
|
|
field.requestFocus(); |
|
|
|
|
|
|
|
field.selectAll(); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}); |
|
|
|
nextButton.setRoundBorder(true, Constants.LEFT); |
|
|
|
return panel; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private JPanel createArrowPane(UIButton preButton, UIButton nextButton) { |
|
|
|
JPanel arrowPane = new JPanel(); |
|
|
|
JPanel arrowPane = new JPanel(); |
|
|
|
arrowPane.setPreferredSize(scale(new Dimension(11, 18))); |
|
|
|
arrowPane.setPreferredSize(createScaleDimension(12, 24)); |
|
|
|
arrowPane.setLayout(new GridLayout(2, 1)); |
|
|
|
arrowPane.setLayout(new GridLayout(2, 1)); |
|
|
|
arrowPane.add(preButton); |
|
|
|
arrowPane.add(preButton); |
|
|
|
arrowPane.add(nextButton); |
|
|
|
arrowPane.add(nextButton); |
|
|
|
this.add(arrowPane, BorderLayout.EAST); |
|
|
|
arrowPane.setOpaque(false); |
|
|
|
|
|
|
|
return arrowPane; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initListener() { |
|
|
|
private UIButton createArrowButton(Icon icon) { |
|
|
|
MouseAdapter backgroundAdapter = new MouseAdapter() { |
|
|
|
UIButton arrowButton = new UIButton(icon) { |
|
|
|
@Override |
|
|
|
public boolean shouldResponseChangeListener() { |
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
|
return false; |
|
|
|
HMSPane.this.selectedNumberField = (CalendarNumberField) e.getComponent(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
setStyle(arrowButton, STYLE_TEXT); |
|
|
|
|
|
|
|
return arrowButton; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initListener() { |
|
|
|
|
|
|
|
MouseAdapter backgroundAdapter = new MouseAdapter() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void mouseExited(MouseEvent e) { |
|
|
|
public void mouseExited(MouseEvent e) { |
|
|
|
isRolOver = false; |
|
|
|
isRolOver = false; |
|
|
@ -815,32 +614,10 @@ public class UICalendarPanel extends JPanel { |
|
|
|
hField.addMouseListener(backgroundAdapter); |
|
|
|
hField.addMouseListener(backgroundAdapter); |
|
|
|
mField.addMouseListener(backgroundAdapter); |
|
|
|
mField.addMouseListener(backgroundAdapter); |
|
|
|
sField.addMouseListener(backgroundAdapter); |
|
|
|
sField.addMouseListener(backgroundAdapter); |
|
|
|
nextButton.addActionListener(new ActionListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
|
|
|
|
HMSPane.this.selectedNumberField.setValue(HMSPane.this.selectedNumberField.getIntValue() - 1); |
|
|
|
|
|
|
|
HMSPane.this.selectedNumberField.requestFocus(); |
|
|
|
|
|
|
|
HMSPane.this.selectedNumberField.selectAll(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
preButton.addActionListener(new ActionListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
|
|
|
|
HMSPane.this.selectedNumberField.setValue(HMSPane.this.selectedNumberField.getIntValue() + 1); |
|
|
|
|
|
|
|
HMSPane.this.selectedNumberField.requestFocus(); |
|
|
|
|
|
|
|
HMSPane.this.selectedNumberField.selectAll(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private UILabel createGapLabel() { |
|
|
|
private JPanel createGapLabel() { |
|
|
|
UILabel uiLabel = new UILabel(":"); |
|
|
|
return row(fix(4), cell(new UILabel(":")), fix(4)).getComponent(); |
|
|
|
uiLabel.setHorizontalAlignment(SwingConstants.CENTER); |
|
|
|
|
|
|
|
uiLabel.setBackground(null); |
|
|
|
|
|
|
|
uiLabel.setBorder(null); |
|
|
|
|
|
|
|
uiLabel.setPreferredSize(scale(new Dimension(6, 10))); |
|
|
|
|
|
|
|
return uiLabel; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Insets getInsets() { |
|
|
|
public Insets getInsets() { |
|
|
@ -849,17 +626,6 @@ public class UICalendarPanel extends JPanel { |
|
|
|
|
|
|
|
|
|
|
|
public void paint(Graphics g) { |
|
|
|
public void paint(Graphics g) { |
|
|
|
super.paint(g); |
|
|
|
super.paint(g); |
|
|
|
paintBorder(g); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void paintBorder(Graphics g) { |
|
|
|
|
|
|
|
Graphics2D g2d = (Graphics2D) g; |
|
|
|
|
|
|
|
if (isRolOver) { |
|
|
|
|
|
|
|
Shape shape = new RoundRectangle2D.Double(1, 1, 86, 15, UIConstants.ARC, UIConstants.ARC); |
|
|
|
|
|
|
|
GUIPaintUtils.paintBorderShadow(g2d, 3, shape, UIConstants.HOVER_BLUE, Color.WHITE); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
GUIPaintUtils.drawBorder(g2d, 0, 0, 101, 18, true, 3); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void populate(Calendar calendar) { |
|
|
|
public void populate(Calendar calendar) { |
|
|
@ -875,21 +641,8 @@ public class UICalendarPanel extends JPanel { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) { |
|
|
|
@Override |
|
|
|
JFrame frame = new JFrame(); |
|
|
|
public String getUIClassID() { |
|
|
|
UICalendarPanel calendarPanel = new UICalendarPanel(); |
|
|
|
return UI_CLASS_ID; |
|
|
|
final UITextField field = new UITextField(); |
|
|
|
|
|
|
|
field.setPreferredSize(new Dimension(120, 25)); |
|
|
|
|
|
|
|
calendarPanel.addDateChangeListener(new ChangeListener() { |
|
|
|
|
|
|
|
public void stateChanged(ChangeEvent e) { |
|
|
|
|
|
|
|
Date selectedDate = (Date) e.getSource(); |
|
|
|
|
|
|
|
SimpleDateFormat f = new SimpleDateFormat("yyyy/MM/dd"); |
|
|
|
|
|
|
|
field.setText(f.format(selectedDate)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
frame.getContentPane().setLayout(FRGUIPaneFactory.createCenterFlowLayout()); |
|
|
|
|
|
|
|
frame.getContentPane().add(field); |
|
|
|
|
|
|
|
frame.getContentPane().add(calendarPanel); |
|
|
|
|
|
|
|
frame.setVisible(true); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|