Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Sorter for Maintenance Column in Hangar Tab #4940

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 13 additions & 20 deletions MekHQ/src/mekhq/gui/HangarTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,6 @@
*/
package mekhq.gui;

import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.util.ArrayList;
import java.util.List;
import java.util.ResourceBundle;
import java.util.UUID;

import javax.swing.*;
import javax.swing.RowSorter.SortKey;
import javax.swing.table.TableColumn;
import javax.swing.table.TableRowSorter;

import megamek.client.ui.models.XTableColumnModel;
import megamek.client.ui.preferences.JComboBoxPreference;
import megamek.client.ui.preferences.JTablePreference;
Expand All @@ -48,13 +34,19 @@
import mekhq.gui.adapter.UnitTableMouseAdapter;
import mekhq.gui.enums.MHQTabType;
import mekhq.gui.model.UnitTableModel;
import mekhq.gui.sorter.FormattedNumberSorter;
import mekhq.gui.sorter.PersonTitleStringSorter;
import mekhq.gui.sorter.UnitStatusSorter;
import mekhq.gui.sorter.UnitTypeSorter;
import mekhq.gui.sorter.WeightClassSorter;
import mekhq.gui.sorter.*;
import mekhq.gui.view.UnitViewPanel;

import javax.swing.*;
import javax.swing.RowSorter.SortKey;
import javax.swing.table.TableColumn;
import javax.swing.table.TableRowSorter;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
import java.util.ResourceBundle;
import java.util.UUID;

/**
* Displays a table of all units in the force.
*/
Expand All @@ -79,7 +71,7 @@ public final class HangarTab extends CampaignGuiTab {
private UnitTableModel unitModel;
private TableRowSorter<UnitTableModel> unitSorter;

private static final transient ResourceBundle resourceMap = ResourceBundle.getBundle("mekhq.resources.CampaignGUI",
private static final ResourceBundle resourceMap = ResourceBundle.getBundle("mekhq.resources.CampaignGUI",
MekHQ.getMHQOptions().getLocale());

// region Constructors
Expand Down Expand Up @@ -170,6 +162,7 @@ public void initTab() {
unitSorter.setComparator(UnitTableModel.COL_STATUS, new UnitStatusSorter());
unitSorter.setComparator(UnitTableModel.COL_PILOT, new PersonTitleStringSorter(getCampaign()));
unitSorter.setComparator(UnitTableModel.COL_TECH_CRW, new PersonTitleStringSorter(getCampaign()));
unitSorter.setComparator(UnitTableModel.COL_MAINTAIN, new FormattedNumberSorter());
unitTable.setRowSorter(unitSorter);
List<SortKey> sortKeys = new ArrayList<>();
sortKeys.add(new SortKey(UnitTableModel.COL_TYPE, SortOrder.DESCENDING));
Expand Down