From 7c9b7dee5145fc873aa11da7f8ba9f01e379e460 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Sun, 29 Sep 2024 18:19:55 -0500 Subject: [PATCH] Remove unused era constants in DateChooser Eliminated the obsolete era-related constants from DateChooser to clean up the codebase. Updated the button action listener to use the setDate method and dispose of the dialog afterward. --- MekHQ/src/mekhq/gui/dialog/DateChooser.java | 38 +++++++-------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/MekHQ/src/mekhq/gui/dialog/DateChooser.java b/MekHQ/src/mekhq/gui/dialog/DateChooser.java index 99dcf4e02c..4c6163fe64 100644 --- a/MekHQ/src/mekhq/gui/dialog/DateChooser.java +++ b/MekHQ/src/mekhq/gui/dialog/DateChooser.java @@ -39,26 +39,26 @@ /** * Hovanes Gambaryan Henry Demirchian CSUN, CS 585 Professor Mike Barnes * December 06, 2000 - * + *

* DateChooser class is a general GUI based date chooser. It allows the user to * select an instance of LocalDate defined in java.time package. - * + *

* Programming API is similar to JFC's JColorChooser or JFileChooser. This class * can be used in any application to enable the user to select a date from a * visually displayed calendar. - * + *

* There is a lot of improvements that can be done over this class in areas of * functionality, usability, and appearance. But as is, the class can be easily * used from within any Java program. - * + *

* Typical usage is like: - * + *

* // initial date LocalDate date = LocalDate.now() - * + *

* // The owner is the JFrame of the application ("AppClass.this") - * + *

* // show the date chooser DateChooser dc = new DateChooser(owner, date); - * + *

* // user can either choose a date or cancel by closing if * (dc.showDateChooser() * == DateChooser.OK_OPTION) { date = dc.getDate(); } @@ -68,20 +68,6 @@ public class DateChooser extends JDialog implements ActionListener, FocusListene public static final int OK_OPTION = 1; public static final int CANCEL_OPTION = 2; - - private static final int ERA_AGE_OF_WAR = 0; - private static final int ERA_STAR_LEAGUE = 1; - private static final int ERA_EARLY_SUCCESSION_WAR = 2; - private static final int ERA_LATE_SUCCESSION_WAR_LOSTECH = 3; - private static final int ERA_LATE_SUCCESSION_WAR_RENAISSANCE = 4; - private static final int ERA_CLAN_INVASION = 5; - private static final int ERA_CIVIL_WAR = 6; - private static final int ERA_JIHAD = 7; - private static final int ERA_EARLY_REPUBLIC = 8; - private static final int ERA_LATE_REPUBLIC = 9; - private static final int ERA_DARK_AGE = 10; - private static final int ERA_ILCLAN = 11; - private static String RESOURCE_PACKAGE = "mekhq/resources/DateChooser"; private static final ResourceBundle resources = ResourceBundle.getBundle(RESOURCE_PACKAGE, MekHQ.getMHQOptions().getLocale()); @@ -696,11 +682,11 @@ private JButton createEraButton(int era) { JButton button = new JButton(label); button.setToolTipText(wordWrap(eraTooltip)); button.setHorizontalAlignment(SwingConstants.CENTER); - button.addActionListener(e -> dateField.setText( - MekHQ.getMHQOptions().getDisplayFormattedDate( - LocalDate.of(eraYears.get(era), 1, 1)))); + button.addActionListener(e -> { + setDate(LocalDate.of(eraYears.get(era), 1, 1)); + dispose();}); - // Return the list of buttons + // Return the button return button; } }