Skip to content

Commit

Permalink
Remove unused era constants in DateChooser
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
IllianiCBT committed Sep 29, 2024
1 parent 66af6c3 commit 7c9b7de
Showing 1 changed file with 12 additions and 26 deletions.
38 changes: 12 additions & 26 deletions MekHQ/src/mekhq/gui/dialog/DateChooser.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,26 @@
/**
* Hovanes Gambaryan Henry Demirchian CSUN, CS 585 Professor Mike Barnes
* December 06, 2000
*
* <p>
* DateChooser class is a general GUI based date chooser. It allows the user to
* select an instance of LocalDate defined in java.time package.
*
* <p>
* 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.
*
* <p>
* 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.
*
* <p>
* Typical usage is like:
*
* <p>
* // initial date LocalDate date = LocalDate.now()
*
* <p>
* // The owner is the JFrame of the application ("AppClass.this")
*
* <p>
* // show the date chooser DateChooser dc = new DateChooser(owner, date);
*
* <p>
* // user can either choose a date or cancel by closing if
* (dc.showDateChooser()
* == DateChooser.OK_OPTION) { date = dc.getDate(); }
Expand All @@ -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());
Expand Down Expand Up @@ -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;
}
}

0 comments on commit 7c9b7de

Please sign in to comment.