From 75fa7c63cc2f82374960dac7889463f42306506d Mon Sep 17 00:00:00 2001 From: nutritiousemployee Date: Mon, 23 Oct 2023 18:38:12 +0200 Subject: [PATCH 1/6] Children filter --- MekHQ/src/mekhq/gui/dialog/PersonnelMarketDialog.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MekHQ/src/mekhq/gui/dialog/PersonnelMarketDialog.java b/MekHQ/src/mekhq/gui/dialog/PersonnelMarketDialog.java index ff91e99b9a..038b4ddbad 100644 --- a/MekHQ/src/mekhq/gui/dialog/PersonnelMarketDialog.java +++ b/MekHQ/src/mekhq/gui/dialog/PersonnelMarketDialog.java @@ -419,7 +419,7 @@ private void filterPersonnel() { sorter.setRowFilter(new RowFilter<>() { @Override public boolean include(Entry entry) { - return nGroup.getFilteredInformation(entry.getModel().getPerson(entry.getIdentifier())); + return nGroup.getFilteredInformation(entry.getModel().getPerson(entry.getIdentifier()),hqView.getCampaign().getLocalDate()); } }); } From d490139876317308024affa733ce638834e9c76b Mon Sep 17 00:00:00 2001 From: nutritiousemployee Date: Mon, 23 Oct 2023 18:38:34 +0200 Subject: [PATCH 2/6] Children filter --- .../resources/mekhq/resources/GUI.properties | 2 + MekHQ/src/mekhq/gui/PersonnelTab.java | 706 ++++++------- .../gui/dialog/RetirementDefectionDialog.java | 2 +- .../src/mekhq/gui/enums/PersonnelFilter.java | 929 +++++++++--------- 4 files changed, 824 insertions(+), 815 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/GUI.properties b/MekHQ/resources/mekhq/resources/GUI.properties index 41f981b216..2aa1b7ed6b 100644 --- a/MekHQ/resources/mekhq/resources/GUI.properties +++ b/MekHQ/resources/mekhq/resources/GUI.properties @@ -762,6 +762,8 @@ PersonnelFilter.ADMINISTRATOR_TRANSPORT.text=Administrators (Transport) PersonnelFilter.ADMINISTRATOR_TRANSPORT.toolTipText=Display transport-focused administrators PersonnelFilter.ADMINISTRATOR_HR.text=Administrators (HR) PersonnelFilter.ADMINISTRATOR_HR.toolTipText=Display human resources-focused administrators +PersonnelFilter.KIDS.text=Children +PersonnelFilter.KIDS.toolTipText=Display all personnel under 13. PersonnelFilter.DEPENDENT.text=Dependents PersonnelFilter.DEPENDENT.toolTipText=Display active personnel with the Dependent primary role. PersonnelFilter.FOUNDER.text=Founders diff --git a/MekHQ/src/mekhq/gui/PersonnelTab.java b/MekHQ/src/mekhq/gui/PersonnelTab.java index f1f25989ec..12725f0cec 100644 --- a/MekHQ/src/mekhq/gui/PersonnelTab.java +++ b/MekHQ/src/mekhq/gui/PersonnelTab.java @@ -51,377 +51,377 @@ * Tab for interacting with all personnel */ public final class PersonnelTab extends CampaignGuiTab { - public static final int PERSONNEL_VIEW_WIDTH = 500; - - private JSplitPane splitPersonnel; - private JTable personnelTable; - private MMComboBox choicePerson; - private MMComboBox choicePersonView; - private JScrollPane scrollPersonnelView; - private JCheckBox chkGroupByUnit; - - private PersonnelTableModel personModel; - private TableRowSorter personnelSorter; - - //region Constructors - public PersonnelTab(CampaignGUI gui, String name) { - super(gui, name); - MekHQ.registerHandler(this); - setUserPreferences(); - } - //endregion Constructors - - @Override - public MHQTabType tabType() { - return MHQTabType.PERSONNEL; - } - - /* - * (non-Javadoc) - * - * @see mekhq.gui.CampaignGuiTab#initTab() - */ - @Override - public void initTab() { - final ResourceBundle resourceMap = ResourceBundle.getBundle("mekhq.resources.CampaignGUI", - MekHQ.getMHQOptions().getLocale()); - GridBagConstraints gridBagConstraints; - - setLayout(new GridBagLayout()); - - gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridx = 0; - gridBagConstraints.gridy = 0; - gridBagConstraints.weightx = 0.0; - gridBagConstraints.anchor = GridBagConstraints.WEST; - gridBagConstraints.insets = new Insets(5, 5, 0, 0); - add(new JLabel(resourceMap.getString("lblPersonChoice.text")), gridBagConstraints); - - choicePerson = new MMComboBox<>("choicePerson", createPersonGroupModel()); - choicePerson.setSelectedItem(PersonnelFilter.ACTIVE); - choicePerson.setRenderer(new DefaultListCellRenderer() { - @Override - public Component getListCellRendererComponent(final JList list, final Object value, - final int index, final boolean isSelected, - final boolean cellHasFocus) { - super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - if (value instanceof PersonnelFilter) { - list.setToolTipText(((PersonnelFilter) value).getToolTipText()); - } - return this; - } - }); - choicePerson.addActionListener(ev -> filterPersonnel()); - gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridx = 1; - gridBagConstraints.gridy = 0; - gridBagConstraints.fill = GridBagConstraints.NONE; - gridBagConstraints.weightx = 0.0; - gridBagConstraints.weighty = 0.0; - gridBagConstraints.anchor = GridBagConstraints.WEST; - gridBagConstraints.insets = new Insets(5, 5, 0, 0); - add(choicePerson, gridBagConstraints); - - gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridx = 2; - gridBagConstraints.gridy = 0; - gridBagConstraints.fill = GridBagConstraints.NONE; - gridBagConstraints.weightx = 0.0; - gridBagConstraints.weighty = 0.0; - gridBagConstraints.anchor = GridBagConstraints.WEST; - gridBagConstraints.insets = new Insets(5, 5, 0, 0); - add(new JLabel(resourceMap.getString("lblPersonView.text")), gridBagConstraints); - - choicePersonView = new MMComboBox<>("choicePersonView", PersonnelTabView.values()); - choicePersonView.setSelectedItem(PersonnelTabView.GENERAL); - choicePersonView.setRenderer(new DefaultListCellRenderer() { - @Override - public Component getListCellRendererComponent(final JList list, final Object value, - final int index, final boolean isSelected, - final boolean cellHasFocus) { - super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - if (value instanceof PersonnelTabView) { - list.setToolTipText(((PersonnelTabView) value).getToolTipText()); - } - return this; - } - }); - choicePersonView.addActionListener(ev -> changePersonnelView()); - gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridx = 3; - gridBagConstraints.gridy = 0; - gridBagConstraints.fill = GridBagConstraints.NONE; - gridBagConstraints.weightx = 0.0; - gridBagConstraints.weighty = 0.0; - gridBagConstraints.anchor = GridBagConstraints.WEST; - gridBagConstraints.insets = new Insets(5, 5, 0, 0); - add(choicePersonView, gridBagConstraints); - - chkGroupByUnit = new JCheckBox(resourceMap.getString("chkGroupByUnit.text")); - chkGroupByUnit.setToolTipText(resourceMap.getString("chkGroupByUnit.toolTipText")); - chkGroupByUnit.addActionListener(e -> { - personModel.setGroupByUnit(chkGroupByUnit.isSelected()); - personModel.refreshData(); - }); - gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridx = 4; - gridBagConstraints.gridy = 0; - gridBagConstraints.fill = GridBagConstraints.NONE; - gridBagConstraints.weightx = 1.0; - gridBagConstraints.weighty = 0.0; - gridBagConstraints.anchor = GridBagConstraints.WEST; - gridBagConstraints.insets = new Insets(5, 5, 0, 0); - add(chkGroupByUnit, gridBagConstraints); - - personModel = new PersonnelTableModel(getCampaign()); - personnelTable = new JTable(personModel); - personnelTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - personnelTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); - XTableColumnModel personColumnModel = new XTableColumnModel(); - personnelTable.setColumnModel(personColumnModel); - personnelTable.createDefaultColumnsFromModel(); - personnelSorter = new TableRowSorter<>(personModel); - final ArrayList sortKeys = new ArrayList<>(); - for (final PersonnelTableModelColumn column : PersonnelTableModel.PERSONNEL_COLUMNS) { - final Comparator comparator = column.getComparator(getCampaign()); - if (comparator != null) { - personnelSorter.setComparator(column.ordinal(), comparator); - } - final SortOrder sortOrder = column.getDefaultSortOrder(); - if (sortOrder != null) { - sortKeys.add(new RowSorter.SortKey(column.ordinal(), sortOrder)); - } + public static final int PERSONNEL_VIEW_WIDTH = 500; + + private JSplitPane splitPersonnel; + private JTable personnelTable; + private MMComboBox choicePerson; + private MMComboBox choicePersonView; + private JScrollPane scrollPersonnelView; + private JCheckBox chkGroupByUnit; + + private PersonnelTableModel personModel; + private TableRowSorter personnelSorter; + + //region Constructors + public PersonnelTab(CampaignGUI gui, String name) { + super(gui, name); + MekHQ.registerHandler(this); + setUserPreferences(); + } + //endregion Constructors + + @Override + public MHQTabType tabType() { + return MHQTabType.PERSONNEL; + } + + /* + * (non-Javadoc) + * + * @see mekhq.gui.CampaignGuiTab#initTab() + */ + @Override + public void initTab() { + final ResourceBundle resourceMap = ResourceBundle.getBundle("mekhq.resources.CampaignGUI", + MekHQ.getMHQOptions().getLocale()); + GridBagConstraints gridBagConstraints; + + setLayout(new GridBagLayout()); + + gridBagConstraints = new GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 0; + gridBagConstraints.weightx = 0.0; + gridBagConstraints.anchor = GridBagConstraints.WEST; + gridBagConstraints.insets = new Insets(5, 5, 0, 0); + add(new JLabel(resourceMap.getString("lblPersonChoice.text")), gridBagConstraints); + + choicePerson = new MMComboBox<>("choicePerson", createPersonGroupModel()); + choicePerson.setSelectedItem(PersonnelFilter.ACTIVE); + choicePerson.setRenderer(new DefaultListCellRenderer() { + @Override + public Component getListCellRendererComponent(final JList list, final Object value, + final int index, final boolean isSelected, + final boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + if (value instanceof PersonnelFilter) { + list.setToolTipText(((PersonnelFilter) value).getToolTipText()); } - personnelSorter.setSortKeys(sortKeys); - personnelTable.setRowSorter(personnelSorter); - personnelTable.setIntercellSpacing(new Dimension(0, 0)); - personnelTable.setShowGrid(false); - changePersonnelView(); - personnelTable.getSelectionModel().addListSelectionListener(ev -> refreshPersonnelView()); - - scrollPersonnelView = new JScrollPane(); - scrollPersonnelView.setMinimumSize(new Dimension(PERSONNEL_VIEW_WIDTH, 600)); - scrollPersonnelView.setPreferredSize(new Dimension(PERSONNEL_VIEW_WIDTH, 600)); - scrollPersonnelView.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); - scrollPersonnelView.setViewportView(null); - - JScrollPane scrollPersonnelTable = new JScrollPane(personnelTable); - splitPersonnel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scrollPersonnelTable, - scrollPersonnelView); - splitPersonnel.setOneTouchExpandable(true); - splitPersonnel.setResizeWeight(1.0); - splitPersonnel.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, ev -> refreshPersonnelView()); - gridBagConstraints.gridx = 0; - gridBagConstraints.gridy = 1; - gridBagConstraints.gridwidth = 5; - gridBagConstraints.fill = GridBagConstraints.BOTH; - gridBagConstraints.weightx = 1.0; - gridBagConstraints.weighty = 1.0; - add(splitPersonnel, gridBagConstraints); - - PersonnelTableMouseAdapter.connect(getCampaignGui(), personnelTable, personModel, splitPersonnel); - - filterPersonnel(); - } - - private DefaultComboBoxModel createPersonGroupModel() { - final DefaultComboBoxModel personGroupModel = new DefaultComboBoxModel<>(); - for (PersonnelFilter filter : MekHQ.getMHQOptions().getPersonnelFilterStyle().getFilters(false)) { - personGroupModel.addElement(filter); + return this; + } + }); + choicePerson.addActionListener(ev -> filterPersonnel()); + gridBagConstraints = new GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 0; + gridBagConstraints.fill = GridBagConstraints.NONE; + gridBagConstraints.weightx = 0.0; + gridBagConstraints.weighty = 0.0; + gridBagConstraints.anchor = GridBagConstraints.WEST; + gridBagConstraints.insets = new Insets(5, 5, 0, 0); + add(choicePerson, gridBagConstraints); + + gridBagConstraints = new GridBagConstraints(); + gridBagConstraints.gridx = 2; + gridBagConstraints.gridy = 0; + gridBagConstraints.fill = GridBagConstraints.NONE; + gridBagConstraints.weightx = 0.0; + gridBagConstraints.weighty = 0.0; + gridBagConstraints.anchor = GridBagConstraints.WEST; + gridBagConstraints.insets = new Insets(5, 5, 0, 0); + add(new JLabel(resourceMap.getString("lblPersonView.text")), gridBagConstraints); + + choicePersonView = new MMComboBox<>("choicePersonView", PersonnelTabView.values()); + choicePersonView.setSelectedItem(PersonnelTabView.GENERAL); + choicePersonView.setRenderer(new DefaultListCellRenderer() { + @Override + public Component getListCellRendererComponent(final JList list, final Object value, + final int index, final boolean isSelected, + final boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + if (value instanceof PersonnelTabView) { + list.setToolTipText(((PersonnelTabView) value).getToolTipText()); } - return personGroupModel; + return this; + } + }); + choicePersonView.addActionListener(ev -> changePersonnelView()); + gridBagConstraints = new GridBagConstraints(); + gridBagConstraints.gridx = 3; + gridBagConstraints.gridy = 0; + gridBagConstraints.fill = GridBagConstraints.NONE; + gridBagConstraints.weightx = 0.0; + gridBagConstraints.weighty = 0.0; + gridBagConstraints.anchor = GridBagConstraints.WEST; + gridBagConstraints.insets = new Insets(5, 5, 0, 0); + add(choicePersonView, gridBagConstraints); + + chkGroupByUnit = new JCheckBox(resourceMap.getString("chkGroupByUnit.text")); + chkGroupByUnit.setToolTipText(resourceMap.getString("chkGroupByUnit.toolTipText")); + chkGroupByUnit.addActionListener(e -> { + personModel.setGroupByUnit(chkGroupByUnit.isSelected()); + personModel.refreshData(); + }); + gridBagConstraints = new GridBagConstraints(); + gridBagConstraints.gridx = 4; + gridBagConstraints.gridy = 0; + gridBagConstraints.fill = GridBagConstraints.NONE; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 0.0; + gridBagConstraints.anchor = GridBagConstraints.WEST; + gridBagConstraints.insets = new Insets(5, 5, 0, 0); + add(chkGroupByUnit, gridBagConstraints); + + personModel = new PersonnelTableModel(getCampaign()); + personnelTable = new JTable(personModel); + personnelTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + personnelTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); + XTableColumnModel personColumnModel = new XTableColumnModel(); + personnelTable.setColumnModel(personColumnModel); + personnelTable.createDefaultColumnsFromModel(); + personnelSorter = new TableRowSorter<>(personModel); + final ArrayList sortKeys = new ArrayList<>(); + for (final PersonnelTableModelColumn column : PersonnelTableModel.PERSONNEL_COLUMNS) { + final Comparator comparator = column.getComparator(getCampaign()); + if (comparator != null) { + personnelSorter.setComparator(column.ordinal(), comparator); + } + final SortOrder sortOrder = column.getDefaultSortOrder(); + if (sortOrder != null) { + sortKeys.add(new RowSorter.SortKey(column.ordinal(), sortOrder)); + } } - - @Deprecated // These need to be migrated to the Suite Constants / Suite Options Setup - private void setUserPreferences() { - try { - PreferencesNode preferences = MekHQ.getMHQPreferences().forClass(PersonnelTab.class); - this.setName("dialog"); - - choicePerson.setName("personnelType"); - preferences.manage(new JComboBoxPreference(choicePerson)); - - choicePersonView.setName("personnelView"); - preferences.manage(new JComboBoxPreference(choicePersonView)); - - chkGroupByUnit.setName("groupByUnit"); - preferences.manage(new JToggleButtonPreference(chkGroupByUnit)); - - personnelTable.setName("personnelTable"); - preferences.manage(new JTablePreference(personnelTable)); - } catch (Exception ex) { - LogManager.getLogger().error("Failed to set user preferences", ex); - } + personnelSorter.setSortKeys(sortKeys); + personnelTable.setRowSorter(personnelSorter); + personnelTable.setIntercellSpacing(new Dimension(0, 0)); + personnelTable.setShowGrid(false); + changePersonnelView(); + personnelTable.getSelectionModel().addListSelectionListener(ev -> refreshPersonnelView()); + + scrollPersonnelView = new JScrollPane(); + scrollPersonnelView.setMinimumSize(new Dimension(PERSONNEL_VIEW_WIDTH, 600)); + scrollPersonnelView.setPreferredSize(new Dimension(PERSONNEL_VIEW_WIDTH, 600)); + scrollPersonnelView.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + scrollPersonnelView.setViewportView(null); + + JScrollPane scrollPersonnelTable = new JScrollPane(personnelTable); + splitPersonnel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scrollPersonnelTable, + scrollPersonnelView); + splitPersonnel.setOneTouchExpandable(true); + splitPersonnel.setResizeWeight(1.0); + splitPersonnel.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, ev -> refreshPersonnelView()); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 1; + gridBagConstraints.gridwidth = 5; + gridBagConstraints.fill = GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + add(splitPersonnel, gridBagConstraints); + + PersonnelTableMouseAdapter.connect(getCampaignGui(), personnelTable, personModel, splitPersonnel); + + filterPersonnel(); + } + + private DefaultComboBoxModel createPersonGroupModel() { + final DefaultComboBoxModel personGroupModel = new DefaultComboBoxModel<>(); + for (PersonnelFilter filter : MekHQ.getMHQOptions().getPersonnelFilterStyle().getFilters(false)) { + personGroupModel.addElement(filter); } + return personGroupModel; + } - /* For export */ - public JTable getPersonnelTable() { - return personnelTable; - } + @Deprecated // These need to be migrated to the Suite Constants / Suite Options Setup + private void setUserPreferences() { + try { + PreferencesNode preferences = MekHQ.getMHQPreferences().forClass(PersonnelTab.class); + this.setName("dialog"); - public PersonnelTableModel getPersonModel() { - return personModel; - } + choicePerson.setName("personnelType"); + preferences.manage(new JComboBoxPreference(choicePerson)); - /* - * (non-Javadoc) - * - * @see mekhq.gui.CampaignGuiTab#refreshAll() - */ - @Override - public void refreshAll() { - refreshPersonnelList(); - changePersonnelView(); - } + choicePersonView.setName("personnelView"); + preferences.manage(new JComboBoxPreference(choicePersonView)); - public void filterPersonnel() { - final PersonnelFilter filter = (choicePerson.getSelectedItem() == null) - ? PersonnelFilter.ACTIVE : choicePerson.getSelectedItem(); - personnelSorter.setRowFilter(new RowFilter<>() { - @Override - public boolean include(Entry entry) { - return filter.getFilteredInformation(entry.getModel().getPerson(entry.getIdentifier())); - } - }); - } + chkGroupByUnit.setName("groupByUnit"); + preferences.manage(new JToggleButtonPreference(chkGroupByUnit)); - private void changePersonnelView() { - final PersonnelTabView view = (choicePersonView.getSelectedItem() == null) - ? PersonnelTabView.GENERAL : choicePersonView.getSelectedItem(); - final XTableColumnModel columnModel = (XTableColumnModel) getPersonnelTable().getColumnModel(); - getPersonnelTable().setRowHeight(15); - - // set the renderer - for (final PersonnelTableModelColumn column : PersonnelTableModel.PERSONNEL_COLUMNS) { - final TableColumn tableColumn = columnModel.getColumnByModelIndex(column.ordinal()); - tableColumn.setCellRenderer(getPersonModel().getRenderer(choicePersonView.getSelectedItem())); - tableColumn.setPreferredWidth(column.getWidth()); - columnModel.setColumnVisible(tableColumn, - column.isVisible(getCampaign(), view, getPersonnelTable())); - } + personnelTable.setName("personnelTable"); + preferences.manage(new JTablePreference(personnelTable)); + } catch (Exception ex) { + LogManager.getLogger().error("Failed to set user preferences", ex); } - - public void focusOnPerson(UUID id) { - splitPersonnel.resetToPreferredSizes(); - int row = -1; - for (int i = 0; i < personnelTable.getRowCount(); i++) { - if (personModel.getPerson(personnelTable.convertRowIndexToModel(i)).getId().equals(id)) { - row = i; - break; - } - } - if (row == -1) { - // try expanding the filter to all units - choicePerson.setSelectedIndex(0); - for (int i = 0; i < personnelTable.getRowCount(); i++) { - if (personModel.getPerson(personnelTable.convertRowIndexToModel(i)).getId().equals(id)) { - row = i; - break; - } - } - - } - if (row != -1) { - personnelTable.setRowSelectionInterval(row, row); - personnelTable.scrollRectToVisible(personnelTable.getCellRect(row, 0, true)); - } + } + + /* For export */ + public JTable getPersonnelTable() { + return personnelTable; + } + + public PersonnelTableModel getPersonModel() { + return personModel; + } + + /* + * (non-Javadoc) + * + * @see mekhq.gui.CampaignGuiTab#refreshAll() + */ + @Override + public void refreshAll() { + refreshPersonnelList(); + changePersonnelView(); + } + + public void filterPersonnel() { + final PersonnelFilter filter = (choicePerson.getSelectedItem() == null) + ? PersonnelFilter.ACTIVE : choicePerson.getSelectedItem(); + personnelSorter.setRowFilter(new RowFilter<>() { + @Override + public boolean include(Entry entry) { + return filter.getFilteredInformation(entry.getModel().getPerson(entry.getIdentifier()),getCampaignGui().getCampaign().getLocalDate()); + } + }); + } + + private void changePersonnelView() { + final PersonnelTabView view = (choicePersonView.getSelectedItem() == null) + ? PersonnelTabView.GENERAL : choicePersonView.getSelectedItem(); + final XTableColumnModel columnModel = (XTableColumnModel) getPersonnelTable().getColumnModel(); + getPersonnelTable().setRowHeight(15); + + // set the renderer + for (final PersonnelTableModelColumn column : PersonnelTableModel.PERSONNEL_COLUMNS) { + final TableColumn tableColumn = columnModel.getColumnByModelIndex(column.ordinal()); + tableColumn.setCellRenderer(getPersonModel().getRenderer(choicePersonView.getSelectedItem())); + tableColumn.setPreferredWidth(column.getWidth()); + columnModel.setColumnVisible(tableColumn, + column.isVisible(getCampaign(), view, getPersonnelTable())); } - - /** - * Refreshes personnel table model. - */ - public void refreshPersonnelList() { - UUID selectedUUID = null; - int selectedRow = personnelTable.getSelectedRow(); - if (selectedRow != -1) { - Person p = personModel.getPerson(personnelTable.convertRowIndexToModel(selectedRow)); - if (null != p) { - selectedUUID = p.getId(); - } - } - personModel.refreshData(); - // try to put the focus back on same person if they are still available - for (int row = 0; row < personnelTable.getRowCount(); row++) { - Person p = personModel.getPerson(personnelTable.convertRowIndexToModel(row)); - if (p.getId().equals(selectedUUID)) { - personnelTable.setRowSelectionInterval(row, row); - refreshPersonnelView(); - break; - } - } - filterPersonnel(); + } + + public void focusOnPerson(UUID id) { + splitPersonnel.resetToPreferredSizes(); + int row = -1; + for (int i = 0; i < personnelTable.getRowCount(); i++) { + if (personModel.getPerson(personnelTable.convertRowIndexToModel(i)).getId().equals(id)) { + row = i; + break; + } } - - public void refreshPersonnelView() { - int row = personnelTable.getSelectedRow(); - if (row < 0) { - scrollPersonnelView.setViewportView(null); - return; + if (row == -1) { + // try expanding the filter to all units + choicePerson.setSelectedIndex(0); + for (int i = 0; i < personnelTable.getRowCount(); i++) { + if (personModel.getPerson(personnelTable.convertRowIndexToModel(i)).getId().equals(id)) { + row = i; + break; } - Person selectedPerson = personModel.getPerson(personnelTable.convertRowIndexToModel(row)); - scrollPersonnelView.setViewportView(new PersonViewPanel(selectedPerson, getCampaign(), getCampaignGui())); - // This odd code is to make sure that the scrollbar stays at the top - // I can't just call it here, because it ends up getting reset somewhere later - SwingUtilities.invokeLater(() -> scrollPersonnelView.getVerticalScrollBar().setValue(0)); - } - - private ActionScheduler personnelListScheduler = new ActionScheduler(this::refreshPersonnelList); - private ActionScheduler filterPersonnelScheduler = new ActionScheduler(this::filterPersonnel); - - @Subscribe - public void handle(OptionsChangedEvent ev) { - changePersonnelView(); - personnelListScheduler.schedule(); - } - - @Subscribe - public void handle(MHQOptionsChangedEvent evt) { - choicePerson.setModel(createPersonGroupModel()); - personnelListScheduler.schedule(); - } - - @Subscribe - public void handle(DeploymentChangedEvent ev) { - filterPersonnelScheduler.schedule(); - } + } - @Subscribe - public void handle(PersonChangedEvent ev) { - personnelListScheduler.schedule(); } - - @Subscribe - public void handle(PersonNewEvent ev) { - personnelListScheduler.schedule(); + if (row != -1) { + personnelTable.setRowSelectionInterval(row, row); + personnelTable.scrollRectToVisible(personnelTable.getCellRect(row, 0, true)); } - - @Subscribe - public void handle(PersonRemovedEvent ev) { - personnelListScheduler.schedule(); + } + + /** + * Refreshes personnel table model. + */ + public void refreshPersonnelList() { + UUID selectedUUID = null; + int selectedRow = personnelTable.getSelectedRow(); + if (selectedRow != -1) { + Person p = personModel.getPerson(personnelTable.convertRowIndexToModel(selectedRow)); + if (null != p) { + selectedUUID = p.getId(); + } } - - @Subscribe - public void handle(PersonLogEvent ev) { + personModel.refreshData(); + // try to put the focus back on same person if they are still available + for (int row = 0; row < personnelTable.getRowCount(); row++) { + Person p = personModel.getPerson(personnelTable.convertRowIndexToModel(row)); + if (p.getId().equals(selectedUUID)) { + personnelTable.setRowSelectionInterval(row, row); refreshPersonnelView(); + break; + } } - - @Subscribe - public void handle(ScenarioResolvedEvent ev) { - personnelListScheduler.schedule(); - } - - @Subscribe - public void handle(UnitRemovedEvent ev) { - filterPersonnelScheduler.schedule(); - } - - @Subscribe - public void handle(PartWorkEvent ev) { - filterPersonnelScheduler.schedule(); - } - - @Subscribe - public void handle(OvertimeModeEvent ev) { - filterPersonnelScheduler.schedule(); + filterPersonnel(); + } + + public void refreshPersonnelView() { + int row = personnelTable.getSelectedRow(); + if (row < 0) { + scrollPersonnelView.setViewportView(null); + return; } + Person selectedPerson = personModel.getPerson(personnelTable.convertRowIndexToModel(row)); + scrollPersonnelView.setViewportView(new PersonViewPanel(selectedPerson, getCampaign(), getCampaignGui())); + // This odd code is to make sure that the scrollbar stays at the top + // I can't just call it here, because it ends up getting reset somewhere later + SwingUtilities.invokeLater(() -> scrollPersonnelView.getVerticalScrollBar().setValue(0)); + } + + private ActionScheduler personnelListScheduler = new ActionScheduler(this::refreshPersonnelList); + private ActionScheduler filterPersonnelScheduler = new ActionScheduler(this::filterPersonnel); + + @Subscribe + public void handle(OptionsChangedEvent ev) { + changePersonnelView(); + personnelListScheduler.schedule(); + } + + @Subscribe + public void handle(MHQOptionsChangedEvent evt) { + choicePerson.setModel(createPersonGroupModel()); + personnelListScheduler.schedule(); + } + + @Subscribe + public void handle(DeploymentChangedEvent ev) { + filterPersonnelScheduler.schedule(); + } + + @Subscribe + public void handle(PersonChangedEvent ev) { + personnelListScheduler.schedule(); + } + + @Subscribe + public void handle(PersonNewEvent ev) { + personnelListScheduler.schedule(); + } + + @Subscribe + public void handle(PersonRemovedEvent ev) { + personnelListScheduler.schedule(); + } + + @Subscribe + public void handle(PersonLogEvent ev) { + refreshPersonnelView(); + } + + @Subscribe + public void handle(ScenarioResolvedEvent ev) { + personnelListScheduler.schedule(); + } + + @Subscribe + public void handle(UnitRemovedEvent ev) { + filterPersonnelScheduler.schedule(); + } + + @Subscribe + public void handle(PartWorkEvent ev) { + filterPersonnelScheduler.schedule(); + } + + @Subscribe + public void handle(OvertimeModeEvent ev) { + filterPersonnelScheduler.schedule(); + } } diff --git a/MekHQ/src/mekhq/gui/dialog/RetirementDefectionDialog.java b/MekHQ/src/mekhq/gui/dialog/RetirementDefectionDialog.java index a2e7e2e295..acc54d3db8 100644 --- a/MekHQ/src/mekhq/gui/dialog/RetirementDefectionDialog.java +++ b/MekHQ/src/mekhq/gui/dialog/RetirementDefectionDialog.java @@ -590,7 +590,7 @@ public boolean include(Entry && !rdTracker.getRetirees(contract).contains(person.getId())) { return false; } else { - return nGroup.getFilteredInformation(person); + return nGroup.getFilteredInformation(person,hqView.getCampaign().getLocalDate()); } } }); diff --git a/MekHQ/src/mekhq/gui/enums/PersonnelFilter.java b/MekHQ/src/mekhq/gui/enums/PersonnelFilter.java index 828cd03f20..db4373681e 100644 --- a/MekHQ/src/mekhq/gui/enums/PersonnelFilter.java +++ b/MekHQ/src/mekhq/gui/enums/PersonnelFilter.java @@ -19,9 +19,13 @@ package mekhq.gui.enums; import mekhq.MekHQ; +import mekhq.campaign.Campaign; import mekhq.campaign.personnel.Person; import mekhq.campaign.personnel.enums.PersonnelRole; +import mekhq.gui.CampaignGUI; +import mekhq.gui.dialog.GMToolsDialog; +import java.time.LocalDate; import java.util.Arrays; import java.util.List; import java.util.ResourceBundle; @@ -29,466 +33,469 @@ import java.util.stream.Stream; public enum PersonnelFilter { - //region Enum Declarations - //region Standard Personnel Filters - ALL("PersonnelFilter.ALL.text", "PersonnelFilter.ALL.toolTipText"), - ACTIVE("PersonnelFilter.ACTIVE.text", "PersonnelFilter.ACTIVE.toolTipText"), - COMBAT("PersonnelFilter.COMBAT.text", "PersonnelFilter.COMBAT.toolTipText"), - SUPPORT("PersonnelFilter.SUPPORT.text", "PersonnelFilter.SUPPORT.toolTipText"), - MECHWARRIORS("PersonnelFilter.MECHWARRIORS.text", "PersonnelFilter.MECHWARRIORS.toolTipText", true, false), - MECHWARRIOR("PersonnelFilter.MECHWARRIOR.text", "PersonnelFilter.MECHWARRIOR.toolTipText", false, true), - LAM_PILOT("PersonnelFilter.LAM_PILOT.text", "PersonnelFilter.LAM_PILOT.toolTipText", false, true), - VEHICLE_CREWMEMBER("PersonnelFilter.VEHICLE_CREWMEMBER.text", "PersonnelFilter.VEHICLE_CREWMEMBER.toolTipText", true, false), - GROUND_VEHICLE_DRIVER("PersonnelFilter.GROUND_VEHICLE_DRIVER.text", "PersonnelFilter.GROUND_VEHICLE_DRIVER.toolTipText", false, true), - NAVAL_VEHICLE_DRIVER("PersonnelFilter.NAVAL_VEHICLE_DRIVER.text", "PersonnelFilter.NAVAL_VEHICLE_DRIVER.toolTipText", false, true), - VTOL_PILOT("PersonnelFilter.VTOL_PILOT.text", "PersonnelFilter.VTOL_PILOT.toolTipText", false, true), - VEHICLE_GUNNER("PersonnelFilter.VEHICLE_GUNNER.text", "PersonnelFilter.VEHICLE_GUNNER.toolTipText", false, true), - VEHICLE_CREW("PersonnelFilter.VEHICLE_CREW.text", "PersonnelFilter.VEHICLE_CREW.toolTipText", false, true), - AEROSPACE_PILOT("PersonnelFilter.AEROSPACE_PILOT.text", "PersonnelFilter.AEROSPACE_PILOT.toolTipText"), - CONVENTIONAL_AIRCRAFT_PILOT("PersonnelFilter.CONVENTIONAL_AIRCRAFT_PILOT.text", "PersonnelFilter.CONVENTIONAL_AIRCRAFT_PILOT.toolTipText"), - PROTOMECH_PILOT("PersonnelFilter.PROTOMECH_PILOT.text", "PersonnelFilter.PROTOMECH_PILOT.toolTipText"), - BATTLE_ARMOUR("PersonnelFilter.BATTLE_ARMOUR.text", "PersonnelFilter.BATTLE_ARMOUR.toolTipText"), - SOLDIER("PersonnelFilter.SOLDIER.text", "PersonnelFilter.SOLDIER.toolTipText"), - VESSEL_CREWMEMBER("PersonnelFilter.VESSEL_CREWMEMBER.text", "PersonnelFilter.VESSEL_CREWMEMBER.toolTipText", true, false), - VESSEL_PILOT("PersonnelFilter.VESSEL_PILOT.text", "PersonnelFilter.VESSEL_PILOT.toolTipText", false, true), - VESSEL_GUNNER("PersonnelFilter.VESSEL_GUNNER.text", "PersonnelFilter.VESSEL_GUNNER.toolTipText", false, true), - VESSEL_CREW("PersonnelFilter.VESSEL_CREW.text", "PersonnelFilter.VESSEL_CREW.toolTipText", false, true), - VESSEL_NAVIGATOR("PersonnelFilter.VESSEL_NAVIGATOR.text", "PersonnelFilter.VESSEL_NAVIGATOR.toolTipText", false, true), - TECH("PersonnelFilter.TECH.text", "PersonnelFilter.TECH.toolTipText", true, false), - MECH_TECH("PersonnelFilter.MECH_TECH.text", "PersonnelFilter.MECH_TECH.toolTipText", false, true), - MECHANIC("PersonnelFilter.MECHANIC.text", "PersonnelFilter.MECHANIC.toolTipText", false, true), - AERO_TECH("PersonnelFilter.AERO_TECH.text", "PersonnelFilter.AERO_TECH.toolTipText", false, true), - BA_TECH("PersonnelFilter.BA_TECH.text", "PersonnelFilter.BA_TECH.toolTipText", false, true), - ASTECH("PersonnelFilter.ASTECH.text", "PersonnelFilter.ASTECH.toolTipText", false, true), - MEDICAL("PersonnelFilter.MEDICAL.text", "PersonnelFilter.MEDICAL.toolTipText", true, false), - DOCTOR("PersonnelFilter.DOCTOR.text", "PersonnelFilter.DOCTOR.toolTipText", false, true), - MEDIC("PersonnelFilter.MEDIC.text", "PersonnelFilter.MEDIC.toolTipText", false, true), - ADMINISTRATOR("PersonnelFilter.ADMINISTRATOR.text", "PersonnelFilter.ADMINISTRATOR.toolTipText", true, false), - ADMINISTRATOR_COMMAND("PersonnelFilter.ADMINISTRATOR_COMMAND.text", "PersonnelFilter.ADMINISTRATOR_COMMAND.toolTipText", false, true), - ADMINISTRATOR_LOGISTICS("PersonnelFilter.ADMINISTRATOR_LOGISTICS.text", "PersonnelFilter.ADMINISTRATOR_LOGISTICS.toolTipText", false, true), - ADMINISTRATOR_TRANSPORT("PersonnelFilter.ADMINISTRATOR_TRANSPORT.text", "PersonnelFilter.ADMINISTRATOR_TRANSPORT.toolTipText", false, true), - ADMINISTRATOR_HR("PersonnelFilter.ADMINISTRATOR_HR.text", "PersonnelFilter.ADMINISTRATOR_HR.toolTipText", false, true), - DEPENDENT("PersonnelFilter.DEPENDENT.text", "PersonnelFilter.DEPENDENT.toolTipText"), - //endregion Standard Personnel Filters - - //region Expanded Personnel Tab Filters - FOUNDER("PersonnelFilter.FOUNDER.text", "PersonnelFilter.FOUNDER.toolTipText", false, false), - PRISONER("PersonnelFilter.PRISONER.text", "PersonnelFilter.PRISONER.toolTipText", false, false), - INACTIVE("PersonnelFilter.INACTIVE.text", "PersonnelFilter.INACTIVE.toolTipText", false, false), - MIA("PersonnelFilter.MIA.text", "PersonnelFilter.MIA.toolTipText", false, false), - RETIRED("PersonnelFilter.RETIRED.text", "PersonnelFilter.RETIRED.toolTipText", false, false), - DESERTED("PersonnelFilter.DESERTED.text", "PersonnelFilter.DESERTED.toolTipText", false, false), - KIA("PersonnelFilter.KIA.text", "PersonnelFilter.KIA.toolTipText", false, false), - DEAD("PersonnelFilter.DEAD.text", "PersonnelFilter.DEAD.toolTipText", false, false); - //endregion Expanded Personnel Tab Filters - //endregion Enum Declarations - - //region Variable Declarations - private final String name; - private final String toolTipText; - private final boolean baseline; - private final boolean standard; - private final boolean individualRole; - //endregion Variable Declarations - - //region Constructors - PersonnelFilter(final String name, final String toolTipText) { - this(name, toolTipText, true, true, true); - } - - PersonnelFilter(final String name, final String toolTipText, final boolean standard, - final boolean individualRole) { - this(name, toolTipText, false, standard, individualRole); - } - - PersonnelFilter(final String name, final String toolTipText, final boolean baseline, - final boolean standard, final boolean individualRole) { - final ResourceBundle resources = ResourceBundle.getBundle("mekhq.resources.GUI", - MekHQ.getMHQOptions().getLocale()); - this.name = resources.getString(name); - this.toolTipText = resources.getString(toolTipText); - this.baseline = baseline; - this.standard = standard; - this.individualRole = individualRole; - } - //endregion Constructors - - //region Getters - public String getToolTipText() { - return toolTipText; - } - - public boolean isBaseline() { - return baseline; - } - - public boolean isStandard() { - return standard; - } - - public boolean isIndividualRole() { - return individualRole; - } - //endregion Getters - - //region Boolean Comparison Methods - public boolean isAll() { - return this == ALL; - } - - public boolean isActive() { - return this == ACTIVE; - } - - public boolean isCombat() { - return this == COMBAT; - } - - public boolean isSupport() { - return this == SUPPORT; - } - - public boolean isMechWarriors() { - return this == MECHWARRIORS; - } - - public boolean isMechWarrior() { - return this == MECHWARRIOR; - } - - public boolean isLAMPilot() { - return this == LAM_PILOT; - } - - public boolean isVehicleCrewmember() { - return this == VEHICLE_CREWMEMBER; - } - - public boolean isGroundVehicleDriver() { - return this == GROUND_VEHICLE_DRIVER; - } - - public boolean isNavalVehicleDriver() { - return this == NAVAL_VEHICLE_DRIVER; - } - - public boolean isVTOLPilot() { - return this == VTOL_PILOT; - } - - public boolean isVehicleGunner() { - return this == VEHICLE_GUNNER; - } - - public boolean isVehicleCrew() { - return this == VEHICLE_CREW; - } - - public boolean isAerospacePilot() { - return this == AEROSPACE_PILOT; - } - - public boolean isConventionalAircraftPilot() { - return this == CONVENTIONAL_AIRCRAFT_PILOT; - } - - public boolean isProtoMechPilot() { - return this == PROTOMECH_PILOT; - } - - public boolean isBattleArmor() { - return this == BATTLE_ARMOUR; - } - - public boolean isSoldier() { - return this == SOLDIER; - } - - public boolean isVesselCrewmember() { - return this == VESSEL_CREWMEMBER; - } - - public boolean isVesselPilot() { - return this == VESSEL_PILOT; - } - - public boolean isVesselGunner() { - return this == VESSEL_GUNNER; - } - - public boolean isVesselCrew() { - return this == VESSEL_CREW; - } - - public boolean isVesselNavigator() { - return this == VESSEL_NAVIGATOR; - } - - public boolean isTech() { - return this == TECH; - } - - public boolean isMechTech() { - return this == MECH_TECH; - } - - public boolean isMechanic() { - return this == MECHANIC; - } - - public boolean isAeroTech() { - return this == AERO_TECH; - } - - public boolean isBATech() { - return this == BA_TECH; - } - - public boolean isAstech() { - return this == ASTECH; - } - - public boolean isMedical() { - return this == MEDICAL; - } - - public boolean isDoctor() { - return this == DOCTOR; - } - - public boolean isMedic() { - return this == MEDIC; - } - - public boolean isAdministrator() { - return this == ADMINISTRATOR; - } - - public boolean isAdministratorCommand() { - return this == ADMINISTRATOR_COMMAND; - } - - public boolean isAdministratorLogistics() { - return this == ADMINISTRATOR_LOGISTICS; - } - - public boolean isAdministratorTransport() { - return this == ADMINISTRATOR_TRANSPORT; - } - - public boolean isAdministratorHR() { - return this == ADMINISTRATOR_HR; - } - - public boolean isDependent() { - return this == DEPENDENT; - } - - public boolean isFounder() { - return this == FOUNDER; - } - - public boolean isPrisoner() { - return this == PRISONER; - } - - public boolean isInactive() { - return this == INACTIVE; - } - - public boolean isMIA() { - return this == MIA; - } - - public boolean isRetired() { - return this == RETIRED; - } - - public boolean isDeserted() { - return this == DESERTED; - } - - public boolean isKIA() { - return this == KIA; - } - - public boolean isDead() { - return this == DEAD; - } - //endregion Boolean Comparison Methods + //region Enum Declarations + //region Standard Personnel Filters + ALL("PersonnelFilter.ALL.text", "PersonnelFilter.ALL.toolTipText"), + ACTIVE("PersonnelFilter.ACTIVE.text", "PersonnelFilter.ACTIVE.toolTipText"), + COMBAT("PersonnelFilter.COMBAT.text", "PersonnelFilter.COMBAT.toolTipText"), + SUPPORT("PersonnelFilter.SUPPORT.text", "PersonnelFilter.SUPPORT.toolTipText"), + MECHWARRIORS("PersonnelFilter.MECHWARRIORS.text", "PersonnelFilter.MECHWARRIORS.toolTipText", true, false), + MECHWARRIOR("PersonnelFilter.MECHWARRIOR.text", "PersonnelFilter.MECHWARRIOR.toolTipText", false, true), + LAM_PILOT("PersonnelFilter.LAM_PILOT.text", "PersonnelFilter.LAM_PILOT.toolTipText", false, true), + VEHICLE_CREWMEMBER("PersonnelFilter.VEHICLE_CREWMEMBER.text", "PersonnelFilter.VEHICLE_CREWMEMBER.toolTipText", true, false), + GROUND_VEHICLE_DRIVER("PersonnelFilter.GROUND_VEHICLE_DRIVER.text", "PersonnelFilter.GROUND_VEHICLE_DRIVER.toolTipText", false, true), + NAVAL_VEHICLE_DRIVER("PersonnelFilter.NAVAL_VEHICLE_DRIVER.text", "PersonnelFilter.NAVAL_VEHICLE_DRIVER.toolTipText", false, true), + VTOL_PILOT("PersonnelFilter.VTOL_PILOT.text", "PersonnelFilter.VTOL_PILOT.toolTipText", false, true), + VEHICLE_GUNNER("PersonnelFilter.VEHICLE_GUNNER.text", "PersonnelFilter.VEHICLE_GUNNER.toolTipText", false, true), + VEHICLE_CREW("PersonnelFilter.VEHICLE_CREW.text", "PersonnelFilter.VEHICLE_CREW.toolTipText", false, true), + AEROSPACE_PILOT("PersonnelFilter.AEROSPACE_PILOT.text", "PersonnelFilter.AEROSPACE_PILOT.toolTipText"), + CONVENTIONAL_AIRCRAFT_PILOT("PersonnelFilter.CONVENTIONAL_AIRCRAFT_PILOT.text", "PersonnelFilter.CONVENTIONAL_AIRCRAFT_PILOT.toolTipText"), + PROTOMECH_PILOT("PersonnelFilter.PROTOMECH_PILOT.text", "PersonnelFilter.PROTOMECH_PILOT.toolTipText"), + BATTLE_ARMOUR("PersonnelFilter.BATTLE_ARMOUR.text", "PersonnelFilter.BATTLE_ARMOUR.toolTipText"), + SOLDIER("PersonnelFilter.SOLDIER.text", "PersonnelFilter.SOLDIER.toolTipText"), + VESSEL_CREWMEMBER("PersonnelFilter.VESSEL_CREWMEMBER.text", "PersonnelFilter.VESSEL_CREWMEMBER.toolTipText", true, false), + VESSEL_PILOT("PersonnelFilter.VESSEL_PILOT.text", "PersonnelFilter.VESSEL_PILOT.toolTipText", false, true), + VESSEL_GUNNER("PersonnelFilter.VESSEL_GUNNER.text", "PersonnelFilter.VESSEL_GUNNER.toolTipText", false, true), + VESSEL_CREW("PersonnelFilter.VESSEL_CREW.text", "PersonnelFilter.VESSEL_CREW.toolTipText", false, true), + VESSEL_NAVIGATOR("PersonnelFilter.VESSEL_NAVIGATOR.text", "PersonnelFilter.VESSEL_NAVIGATOR.toolTipText", false, true), + TECH("PersonnelFilter.TECH.text", "PersonnelFilter.TECH.toolTipText", true, false), + MECH_TECH("PersonnelFilter.MECH_TECH.text", "PersonnelFilter.MECH_TECH.toolTipText", false, true), + MECHANIC("PersonnelFilter.MECHANIC.text", "PersonnelFilter.MECHANIC.toolTipText", false, true), + AERO_TECH("PersonnelFilter.AERO_TECH.text", "PersonnelFilter.AERO_TECH.toolTipText", false, true), + BA_TECH("PersonnelFilter.BA_TECH.text", "PersonnelFilter.BA_TECH.toolTipText", false, true), + ASTECH("PersonnelFilter.ASTECH.text", "PersonnelFilter.ASTECH.toolTipText", false, true), + MEDICAL("PersonnelFilter.MEDICAL.text", "PersonnelFilter.MEDICAL.toolTipText", true, false), + DOCTOR("PersonnelFilter.DOCTOR.text", "PersonnelFilter.DOCTOR.toolTipText", false, true), + MEDIC("PersonnelFilter.MEDIC.text", "PersonnelFilter.MEDIC.toolTipText", false, true), + ADMINISTRATOR("PersonnelFilter.ADMINISTRATOR.text", "PersonnelFilter.ADMINISTRATOR.toolTipText", true, false), + ADMINISTRATOR_COMMAND("PersonnelFilter.ADMINISTRATOR_COMMAND.text", "PersonnelFilter.ADMINISTRATOR_COMMAND.toolTipText", false, true), + ADMINISTRATOR_LOGISTICS("PersonnelFilter.ADMINISTRATOR_LOGISTICS.text", "PersonnelFilter.ADMINISTRATOR_LOGISTICS.toolTipText", false, true), + ADMINISTRATOR_TRANSPORT("PersonnelFilter.ADMINISTRATOR_TRANSPORT.text", "PersonnelFilter.ADMINISTRATOR_TRANSPORT.toolTipText", false, true), + ADMINISTRATOR_HR("PersonnelFilter.ADMINISTRATOR_HR.text", "PersonnelFilter.ADMINISTRATOR_HR.toolTipText", false, true), + DEPENDENT("PersonnelFilter.DEPENDENT.text", "PersonnelFilter.DEPENDENT.toolTipText"), + //endregion Standard Personnel Filters + + KIDS("PersonnelFilter.KIDS.text", "PersonnelFilter.KIDS.toolTipText"), + //region Expanded Personnel Tab Filters + FOUNDER("PersonnelFilter.FOUNDER.text", "PersonnelFilter.FOUNDER.toolTipText", false, false), + PRISONER("PersonnelFilter.PRISONER.text", "PersonnelFilter.PRISONER.toolTipText", false, false), + INACTIVE("PersonnelFilter.INACTIVE.text", "PersonnelFilter.INACTIVE.toolTipText", false, false), + MIA("PersonnelFilter.MIA.text", "PersonnelFilter.MIA.toolTipText", false, false), + RETIRED("PersonnelFilter.RETIRED.text", "PersonnelFilter.RETIRED.toolTipText", false, false), + DESERTED("PersonnelFilter.DESERTED.text", "PersonnelFilter.DESERTED.toolTipText", false, false), + KIA("PersonnelFilter.KIA.text", "PersonnelFilter.KIA.toolTipText", false, false), + DEAD("PersonnelFilter.DEAD.text", "PersonnelFilter.DEAD.toolTipText", false, false); + //endregion Expanded Personnel Tab Filters + //endregion Enum Declarations + + //region Variable Declarations + private final String name; + private final String toolTipText; + private final boolean baseline; + private final boolean standard; + private final boolean individualRole; + //endregion Variable Declarations + + //region Constructors + PersonnelFilter(final String name, final String toolTipText) { + this(name, toolTipText, true, true, true); + } + + PersonnelFilter(final String name, final String toolTipText, final boolean standard, + final boolean individualRole) { + this(name, toolTipText, false, standard, individualRole); + } + + PersonnelFilter(final String name, final String toolTipText, final boolean baseline, + final boolean standard, final boolean individualRole) { + final ResourceBundle resources = ResourceBundle.getBundle("mekhq.resources.GUI", + MekHQ.getMHQOptions().getLocale()); + this.name = resources.getString(name); + this.toolTipText = resources.getString(toolTipText); + this.baseline = baseline; + this.standard = standard; + this.individualRole = individualRole; + } + //endregion Constructors + + //region Getters + public String getToolTipText() { + return toolTipText; + } + + public boolean isBaseline() { + return baseline; + } + + public boolean isStandard() { + return standard; + } + + public boolean isIndividualRole() { + return individualRole; + } + //endregion Getters + + //region Boolean Comparison Methods + public boolean isAll() { + return this == ALL; + } + + public boolean isActive() { + return this == ACTIVE; + } + + public boolean isCombat() { + return this == COMBAT; + } + + public boolean isSupport() { + return this == SUPPORT; + } + + public boolean isMechWarriors() { + return this == MECHWARRIORS; + } + + public boolean isMechWarrior() { + return this == MECHWARRIOR; + } + + public boolean isLAMPilot() { + return this == LAM_PILOT; + } + + public boolean isVehicleCrewmember() { + return this == VEHICLE_CREWMEMBER; + } + + public boolean isGroundVehicleDriver() { + return this == GROUND_VEHICLE_DRIVER; + } + + public boolean isNavalVehicleDriver() { + return this == NAVAL_VEHICLE_DRIVER; + } + + public boolean isVTOLPilot() { + return this == VTOL_PILOT; + } + + public boolean isVehicleGunner() { + return this == VEHICLE_GUNNER; + } + + public boolean isVehicleCrew() { + return this == VEHICLE_CREW; + } + + public boolean isAerospacePilot() { + return this == AEROSPACE_PILOT; + } + + public boolean isConventionalAircraftPilot() { + return this == CONVENTIONAL_AIRCRAFT_PILOT; + } + + public boolean isProtoMechPilot() { + return this == PROTOMECH_PILOT; + } + + public boolean isBattleArmor() { + return this == BATTLE_ARMOUR; + } + + public boolean isSoldier() { + return this == SOLDIER; + } + + public boolean isVesselCrewmember() { + return this == VESSEL_CREWMEMBER; + } + + public boolean isVesselPilot() { + return this == VESSEL_PILOT; + } - public static List getStandardPersonnelFilters() { - return Stream.of(values()).filter(filter -> filter.isBaseline() || filter.isStandard()) - .collect(Collectors.toList()); - } - - public static List getExpandedPersonnelFilters() { - return Stream.of(values()).filter(filter -> filter.isBaseline() || !filter.isIndividualRole()) - .collect(Collectors.toList()); - } - - public static List getIndividualRolesStandardPersonnelFilters() { - return Stream.of(values()).filter(filter -> filter.isBaseline() || filter.isIndividualRole()) - .collect(Collectors.toList()); - } - - public static List getIndividualRolesExpandedPersonnelFilters() { - return Stream.of(values()) - .filter(filter -> filter.isBaseline() || !filter.isStandard() || filter.isIndividualRole()) - .collect(Collectors.toList()); - } - - public static List getAllStandardFilters() { - return Stream.of(values()) - .filter(filter -> filter.isBaseline() || filter.isStandard() || filter.isIndividualRole()) - .collect(Collectors.toList()); - } - - public static List getAllIndividualRoleFilters() { - return Arrays.asList(values()); - } - - public boolean getFilteredInformation(final Person person) { - final boolean active = person.getStatus().isActive() && !person.getPrisonerStatus().isCurrentPrisoner(); - switch (this) { - case ALL: - return true; - case ACTIVE: - return active; - case COMBAT: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isCombat() : person.hasCombatRole()); - case SUPPORT: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? !person.getPrimaryRole().isCombat() : person.hasSupportRole(true)); - case MECHWARRIORS: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isMechWarriorGrouping() - : (person.getPrimaryRole().isMechWarriorGrouping() || person.getSecondaryRole().isMechWarriorGrouping())); - case MECHWARRIOR: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isMechWarrior() : person.hasRole(PersonnelRole.MECHWARRIOR)); - case LAM_PILOT: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isLAMPilot() : person.hasRole(PersonnelRole.LAM_PILOT)); - case VEHICLE_CREWMEMBER: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isVehicleCrewmember() - : (person.getPrimaryRole().isVehicleCrewmember() || person.getSecondaryRole().isVehicleCrewmember())); - case GROUND_VEHICLE_DRIVER: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isGroundVehicleDriver() : person.hasRole(PersonnelRole.GROUND_VEHICLE_DRIVER)); - case NAVAL_VEHICLE_DRIVER: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isNavalVehicleDriver() : person.hasRole(PersonnelRole.NAVAL_VEHICLE_DRIVER)); - case VEHICLE_GUNNER: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isVehicleGunner() : person.hasRole(PersonnelRole.VEHICLE_GUNNER)); - case VEHICLE_CREW: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isVehicleCrew() : person.hasRole(PersonnelRole.VEHICLE_CREW)); - case VTOL_PILOT: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isVTOLPilot() : person.hasRole(PersonnelRole.VTOL_PILOT)); - case AEROSPACE_PILOT: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isAerospacePilot() : person.hasRole(PersonnelRole.AEROSPACE_PILOT)); - case CONVENTIONAL_AIRCRAFT_PILOT: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isConventionalAircraftPilot() : person.hasRole(PersonnelRole.CONVENTIONAL_AIRCRAFT_PILOT)); - case PROTOMECH_PILOT: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isProtoMechPilot() : person.hasRole(PersonnelRole.PROTOMECH_PILOT)); - case BATTLE_ARMOUR: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isBattleArmour() : person.hasRole(PersonnelRole.BATTLE_ARMOUR)); - case SOLDIER: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isSoldier() : person.hasRole(PersonnelRole.SOLDIER)); - case VESSEL_CREWMEMBER: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isVesselCrewmember() - : (person.getPrimaryRole().isVesselCrewmember() || person.getSecondaryRole().isVesselCrewmember())); - case VESSEL_PILOT: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isVesselPilot() : person.hasRole(PersonnelRole.VESSEL_PILOT)); - case VESSEL_CREW: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isVesselCrew() : person.hasRole(PersonnelRole.VESSEL_CREW)); - case VESSEL_GUNNER: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isVesselGunner() : person.hasRole(PersonnelRole.VESSEL_GUNNER)); - case VESSEL_NAVIGATOR: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isVesselNavigator() : person.hasRole(PersonnelRole.VESSEL_NAVIGATOR)); - case TECH: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isTech() : person.isTech()); - case MECH_TECH: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isMechTech() : person.hasRole(PersonnelRole.MECH_TECH)); - case MECHANIC: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isMechanic() : person.hasRole(PersonnelRole.MECHANIC)); - case AERO_TECH: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isAeroTech() : person.hasRole(PersonnelRole.AERO_TECH)); - case BA_TECH: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isBATech() : person.hasRole(PersonnelRole.BA_TECH)); - case ASTECH: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isAstech() : person.hasRole(PersonnelRole.ASTECH)); - case MEDICAL: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isMedicalStaff() - : (person.getPrimaryRole().isMedicalStaff() || person.getSecondaryRole().isMedicalStaff())); - case DOCTOR: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isDoctor() : person.hasRole(PersonnelRole.DOCTOR)); - case MEDIC: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isMedic() : person.hasRole(PersonnelRole.MEDIC)); - case ADMINISTRATOR: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isAdministrator() : person.isAdministrator()); - case ADMINISTRATOR_COMMAND: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isAdministratorCommand() : person.hasRole(PersonnelRole.ADMINISTRATOR_COMMAND)); - case ADMINISTRATOR_LOGISTICS: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isAdministratorLogistics() : person.hasRole(PersonnelRole.ADMINISTRATOR_LOGISTICS)); - case ADMINISTRATOR_TRANSPORT: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isAdministratorTransport() : person.hasRole(PersonnelRole.ADMINISTRATOR_TRANSPORT)); - case ADMINISTRATOR_HR: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isAdministratorHR() : person.hasRole(PersonnelRole.ADMINISTRATOR_HR)); - case DEPENDENT: - return active && person.getPrimaryRole().isDependent(); - case FOUNDER: - return person.isFounder(); - case PRISONER: - return person.getPrisonerStatus().isCurrentPrisoner() || person.getPrisonerStatus().isBondsman(); - case INACTIVE: - return !person.getStatus().isActive(); - case MIA: - return person.getStatus().isMIA(); - case RETIRED: - return person.getStatus().isRetired(); - case DESERTED: - return person.getStatus().isDeserted(); - case KIA: - return person.getStatus().isKIA(); - case DEAD: - return person.getStatus().isDead(); - default: - return false; - } - } - - @Override - public String toString() { - return name; - } + public boolean isVesselGunner() { + return this == VESSEL_GUNNER; + } + + public boolean isVesselCrew() { + return this == VESSEL_CREW; + } + + public boolean isVesselNavigator() { + return this == VESSEL_NAVIGATOR; + } + + public boolean isTech() { + return this == TECH; + } + + public boolean isMechTech() { + return this == MECH_TECH; + } + + public boolean isMechanic() { + return this == MECHANIC; + } + + public boolean isAeroTech() { + return this == AERO_TECH; + } + + public boolean isBATech() { + return this == BA_TECH; + } + + public boolean isAstech() { + return this == ASTECH; + } + + public boolean isMedical() { + return this == MEDICAL; + } + + public boolean isDoctor() { + return this == DOCTOR; + } + + public boolean isMedic() { + return this == MEDIC; + } + + public boolean isAdministrator() { + return this == ADMINISTRATOR; + } + + public boolean isAdministratorCommand() { + return this == ADMINISTRATOR_COMMAND; + } + + public boolean isAdministratorLogistics() { + return this == ADMINISTRATOR_LOGISTICS; + } + + public boolean isAdministratorTransport() { + return this == ADMINISTRATOR_TRANSPORT; + } + + public boolean isAdministratorHR() { + return this == ADMINISTRATOR_HR; + } + + public boolean isDependent() { + return this == DEPENDENT; + } + + public boolean isFounder() { + return this == FOUNDER; + } + + public boolean isPrisoner() { + return this == PRISONER; + } + + public boolean isInactive() { + return this == INACTIVE; + } + + public boolean isMIA() { + return this == MIA; + } + + public boolean isRetired() { + return this == RETIRED; + } + + public boolean isDeserted() { + return this == DESERTED; + } + + public boolean isKIA() { + return this == KIA; + } + + public boolean isDead() { + return this == DEAD; + } + //endregion Boolean Comparison Methods + + public static List getStandardPersonnelFilters() { + return Stream.of(values()).filter(filter -> filter.isBaseline() || filter.isStandard()) + .collect(Collectors.toList()); + } + + public static List getExpandedPersonnelFilters() { + return Stream.of(values()).filter(filter -> filter.isBaseline() || !filter.isIndividualRole()) + .collect(Collectors.toList()); + } + + public static List getIndividualRolesStandardPersonnelFilters() { + return Stream.of(values()).filter(filter -> filter.isBaseline() || filter.isIndividualRole()) + .collect(Collectors.toList()); + } + + public static List getIndividualRolesExpandedPersonnelFilters() { + return Stream.of(values()) + .filter(filter -> filter.isBaseline() || !filter.isStandard() || filter.isIndividualRole()) + .collect(Collectors.toList()); + } + + public static List getAllStandardFilters() { + return Stream.of(values()) + .filter(filter -> filter.isBaseline() || filter.isStandard() || filter.isIndividualRole()) + .collect(Collectors.toList()); + } + + public static List getAllIndividualRoleFilters() { + return Arrays.asList(values()); + } + + public boolean getFilteredInformation(final Person person, LocalDate currentDate) { + final boolean active = person.getStatus().isActive() && !person.getPrisonerStatus().isCurrentPrisoner(); + switch (this) { + case ALL: + return true; + case ACTIVE: + return active; + case COMBAT: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isCombat() : person.hasCombatRole()); + case SUPPORT: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? !person.getPrimaryRole().isCombat() : person.hasSupportRole(true)); + case MECHWARRIORS: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isMechWarriorGrouping() + : (person.getPrimaryRole().isMechWarriorGrouping() || person.getSecondaryRole().isMechWarriorGrouping())); + case MECHWARRIOR: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isMechWarrior() : person.hasRole(PersonnelRole.MECHWARRIOR)); + case LAM_PILOT: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isLAMPilot() : person.hasRole(PersonnelRole.LAM_PILOT)); + case VEHICLE_CREWMEMBER: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isVehicleCrewmember() + : (person.getPrimaryRole().isVehicleCrewmember() || person.getSecondaryRole().isVehicleCrewmember())); + case GROUND_VEHICLE_DRIVER: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isGroundVehicleDriver() : person.hasRole(PersonnelRole.GROUND_VEHICLE_DRIVER)); + case NAVAL_VEHICLE_DRIVER: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isNavalVehicleDriver() : person.hasRole(PersonnelRole.NAVAL_VEHICLE_DRIVER)); + case VEHICLE_GUNNER: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isVehicleGunner() : person.hasRole(PersonnelRole.VEHICLE_GUNNER)); + case VEHICLE_CREW: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isVehicleCrew() : person.hasRole(PersonnelRole.VEHICLE_CREW)); + case VTOL_PILOT: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isVTOLPilot() : person.hasRole(PersonnelRole.VTOL_PILOT)); + case AEROSPACE_PILOT: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isAerospacePilot() : person.hasRole(PersonnelRole.AEROSPACE_PILOT)); + case CONVENTIONAL_AIRCRAFT_PILOT: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isConventionalAircraftPilot() : person.hasRole(PersonnelRole.CONVENTIONAL_AIRCRAFT_PILOT)); + case PROTOMECH_PILOT: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isProtoMechPilot() : person.hasRole(PersonnelRole.PROTOMECH_PILOT)); + case BATTLE_ARMOUR: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isBattleArmour() : person.hasRole(PersonnelRole.BATTLE_ARMOUR)); + case SOLDIER: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isSoldier() : person.hasRole(PersonnelRole.SOLDIER)); + case VESSEL_CREWMEMBER: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isVesselCrewmember() + : (person.getPrimaryRole().isVesselCrewmember() || person.getSecondaryRole().isVesselCrewmember())); + case VESSEL_PILOT: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isVesselPilot() : person.hasRole(PersonnelRole.VESSEL_PILOT)); + case VESSEL_CREW: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isVesselCrew() : person.hasRole(PersonnelRole.VESSEL_CREW)); + case VESSEL_GUNNER: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isVesselGunner() : person.hasRole(PersonnelRole.VESSEL_GUNNER)); + case VESSEL_NAVIGATOR: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isVesselNavigator() : person.hasRole(PersonnelRole.VESSEL_NAVIGATOR)); + case TECH: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isTech() : person.isTech()); + case MECH_TECH: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isMechTech() : person.hasRole(PersonnelRole.MECH_TECH)); + case MECHANIC: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isMechanic() : person.hasRole(PersonnelRole.MECHANIC)); + case AERO_TECH: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isAeroTech() : person.hasRole(PersonnelRole.AERO_TECH)); + case BA_TECH: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isBATech() : person.hasRole(PersonnelRole.BA_TECH)); + case ASTECH: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isAstech() : person.hasRole(PersonnelRole.ASTECH)); + case MEDICAL: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isMedicalStaff() + : (person.getPrimaryRole().isMedicalStaff() || person.getSecondaryRole().isMedicalStaff())); + case DOCTOR: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isDoctor() : person.hasRole(PersonnelRole.DOCTOR)); + case MEDIC: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isMedic() : person.hasRole(PersonnelRole.MEDIC)); + case ADMINISTRATOR: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isAdministrator() : person.isAdministrator()); + case ADMINISTRATOR_COMMAND: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isAdministratorCommand() : person.hasRole(PersonnelRole.ADMINISTRATOR_COMMAND)); + case ADMINISTRATOR_LOGISTICS: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isAdministratorLogistics() : person.hasRole(PersonnelRole.ADMINISTRATOR_LOGISTICS)); + case ADMINISTRATOR_TRANSPORT: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isAdministratorTransport() : person.hasRole(PersonnelRole.ADMINISTRATOR_TRANSPORT)); + case ADMINISTRATOR_HR: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isAdministratorHR() : person.hasRole(PersonnelRole.ADMINISTRATOR_HR)); + case KIDS: + return person.isChild(currentDate); + case DEPENDENT: + return active && person.getPrimaryRole().isDependent(); + case FOUNDER: + return person.isFounder(); + case PRISONER: + return person.getPrisonerStatus().isCurrentPrisoner() || person.getPrisonerStatus().isBondsman(); + case INACTIVE: + return !person.getStatus().isActive(); + case MIA: + return person.getStatus().isMIA(); + case RETIRED: + return person.getStatus().isRetired(); + case DESERTED: + return person.getStatus().isDeserted(); + case KIA: + return person.getStatus().isKIA(); + case DEAD: + return person.getStatus().isDead(); + default: + return false; + } + } + + @Override + public String toString() { + return name; + } } From e890feffe153bed956154b179afe873dd7da2997 Mon Sep 17 00:00:00 2001 From: nutritiousemployee Date: Tue, 24 Oct 2023 11:57:16 +0200 Subject: [PATCH 3/6] Children filter - moved additions below founders --- MekHQ/src/mekhq/gui/enums/PersonnelFilter.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MekHQ/src/mekhq/gui/enums/PersonnelFilter.java b/MekHQ/src/mekhq/gui/enums/PersonnelFilter.java index db4373681e..8ef212839b 100644 --- a/MekHQ/src/mekhq/gui/enums/PersonnelFilter.java +++ b/MekHQ/src/mekhq/gui/enums/PersonnelFilter.java @@ -75,9 +75,9 @@ public enum PersonnelFilter { DEPENDENT("PersonnelFilter.DEPENDENT.text", "PersonnelFilter.DEPENDENT.toolTipText"), //endregion Standard Personnel Filters - KIDS("PersonnelFilter.KIDS.text", "PersonnelFilter.KIDS.toolTipText"), //region Expanded Personnel Tab Filters FOUNDER("PersonnelFilter.FOUNDER.text", "PersonnelFilter.FOUNDER.toolTipText", false, false), + KIDS("PersonnelFilter.KIDS.text", "PersonnelFilter.KIDS.toolTipText"), PRISONER("PersonnelFilter.PRISONER.text", "PersonnelFilter.PRISONER.toolTipText", false, false), INACTIVE("PersonnelFilter.INACTIVE.text", "PersonnelFilter.INACTIVE.toolTipText", false, false), MIA("PersonnelFilter.MIA.text", "PersonnelFilter.MIA.toolTipText", false, false), @@ -469,12 +469,12 @@ public boolean getFilteredInformation(final Person person, LocalDate currentDate case ADMINISTRATOR_HR: return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() ? person.getPrimaryRole().isAdministratorHR() : person.hasRole(PersonnelRole.ADMINISTRATOR_HR)); - case KIDS: - return person.isChild(currentDate); case DEPENDENT: return active && person.getPrimaryRole().isDependent(); case FOUNDER: return person.isFounder(); + case KIDS: + return person.isChild(currentDate); case PRISONER: return person.getPrisonerStatus().isCurrentPrisoner() || person.getPrisonerStatus().isBondsman(); case INACTIVE: From c5464ec5291eba9adf34d6a62bcf8b5a095ed449 Mon Sep 17 00:00:00 2001 From: nutritiousemployee Date: Tue, 24 Oct 2023 19:56:52 +0200 Subject: [PATCH 4/6] Children filter - moved additions below founders --- MekHQ/src/mekhq/gui/PersonnelTab.java | 2 +- MekHQ/src/mekhq/gui/dialog/PersonnelMarketDialog.java | 2 +- MekHQ/src/mekhq/gui/dialog/RetirementDefectionDialog.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MekHQ/src/mekhq/gui/PersonnelTab.java b/MekHQ/src/mekhq/gui/PersonnelTab.java index 12725f0cec..a9901e05ad 100644 --- a/MekHQ/src/mekhq/gui/PersonnelTab.java +++ b/MekHQ/src/mekhq/gui/PersonnelTab.java @@ -280,7 +280,7 @@ public void filterPersonnel() { personnelSorter.setRowFilter(new RowFilter<>() { @Override public boolean include(Entry entry) { - return filter.getFilteredInformation(entry.getModel().getPerson(entry.getIdentifier()),getCampaignGui().getCampaign().getLocalDate()); + return filter.getFilteredInformation(entry.getModel().getPerson(entry.getIdentifier()), getCampaignGui().getCampaign().getLocalDate()); } }); } diff --git a/MekHQ/src/mekhq/gui/dialog/PersonnelMarketDialog.java b/MekHQ/src/mekhq/gui/dialog/PersonnelMarketDialog.java index 038b4ddbad..c605fa6bd9 100644 --- a/MekHQ/src/mekhq/gui/dialog/PersonnelMarketDialog.java +++ b/MekHQ/src/mekhq/gui/dialog/PersonnelMarketDialog.java @@ -419,7 +419,7 @@ private void filterPersonnel() { sorter.setRowFilter(new RowFilter<>() { @Override public boolean include(Entry entry) { - return nGroup.getFilteredInformation(entry.getModel().getPerson(entry.getIdentifier()),hqView.getCampaign().getLocalDate()); + return nGroup.getFilteredInformation(entry.getModel().getPerson(entry.getIdentifier()), hqView.getCampaign().getLocalDate()); } }); } diff --git a/MekHQ/src/mekhq/gui/dialog/RetirementDefectionDialog.java b/MekHQ/src/mekhq/gui/dialog/RetirementDefectionDialog.java index acc54d3db8..869409deae 100644 --- a/MekHQ/src/mekhq/gui/dialog/RetirementDefectionDialog.java +++ b/MekHQ/src/mekhq/gui/dialog/RetirementDefectionDialog.java @@ -590,7 +590,7 @@ public boolean include(Entry && !rdTracker.getRetirees(contract).contains(person.getId())) { return false; } else { - return nGroup.getFilteredInformation(person,hqView.getCampaign().getLocalDate()); + return nGroup.getFilteredInformation(person, hqView.getCampaign().getLocalDate()); } } }); From 2bb5a4dbf439370e9e1aa7a34c1ffc9076538b3f Mon Sep 17 00:00:00 2001 From: nutritiousemployee Date: Tue, 24 Oct 2023 23:35:04 +0200 Subject: [PATCH 5/6] Children filter - setting tabs back to 4 --- MekHQ/src/mekhq/gui/PersonnelTab.java | 10 +- .../src/mekhq/gui/enums/PersonnelFilter.java | 97 +++++++++---------- 2 files changed, 52 insertions(+), 55 deletions(-) diff --git a/MekHQ/src/mekhq/gui/PersonnelTab.java b/MekHQ/src/mekhq/gui/PersonnelTab.java index a9901e05ad..c137ab885e 100644 --- a/MekHQ/src/mekhq/gui/PersonnelTab.java +++ b/MekHQ/src/mekhq/gui/PersonnelTab.java @@ -84,7 +84,7 @@ public MHQTabType tabType() { @Override public void initTab() { final ResourceBundle resourceMap = ResourceBundle.getBundle("mekhq.resources.CampaignGUI", - MekHQ.getMHQOptions().getLocale()); + MekHQ.getMHQOptions().getLocale()); GridBagConstraints gridBagConstraints; setLayout(new GridBagLayout()); @@ -207,7 +207,7 @@ public Component getListCellRendererComponent(final JList list, final Object JScrollPane scrollPersonnelTable = new JScrollPane(personnelTable); splitPersonnel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scrollPersonnelTable, - scrollPersonnelView); + scrollPersonnelView); splitPersonnel.setOneTouchExpandable(true); splitPersonnel.setResizeWeight(1.0); splitPersonnel.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, ev -> refreshPersonnelView()); @@ -276,7 +276,7 @@ public void refreshAll() { public void filterPersonnel() { final PersonnelFilter filter = (choicePerson.getSelectedItem() == null) - ? PersonnelFilter.ACTIVE : choicePerson.getSelectedItem(); + ? PersonnelFilter.ACTIVE : choicePerson.getSelectedItem(); personnelSorter.setRowFilter(new RowFilter<>() { @Override public boolean include(Entry entry) { @@ -287,7 +287,7 @@ public boolean include(Entry e private void changePersonnelView() { final PersonnelTabView view = (choicePersonView.getSelectedItem() == null) - ? PersonnelTabView.GENERAL : choicePersonView.getSelectedItem(); + ? PersonnelTabView.GENERAL : choicePersonView.getSelectedItem(); final XTableColumnModel columnModel = (XTableColumnModel) getPersonnelTable().getColumnModel(); getPersonnelTable().setRowHeight(15); @@ -297,7 +297,7 @@ private void changePersonnelView() { tableColumn.setCellRenderer(getPersonModel().getRenderer(choicePersonView.getSelectedItem())); tableColumn.setPreferredWidth(column.getWidth()); columnModel.setColumnVisible(tableColumn, - column.isVisible(getCampaign(), view, getPersonnelTable())); + column.isVisible(getCampaign(), view, getPersonnelTable())); } } diff --git a/MekHQ/src/mekhq/gui/enums/PersonnelFilter.java b/MekHQ/src/mekhq/gui/enums/PersonnelFilter.java index 8ef212839b..bab7a9935d 100644 --- a/MekHQ/src/mekhq/gui/enums/PersonnelFilter.java +++ b/MekHQ/src/mekhq/gui/enums/PersonnelFilter.java @@ -19,11 +19,8 @@ package mekhq.gui.enums; import mekhq.MekHQ; -import mekhq.campaign.Campaign; import mekhq.campaign.personnel.Person; import mekhq.campaign.personnel.enums.PersonnelRole; -import mekhq.gui.CampaignGUI; -import mekhq.gui.dialog.GMToolsDialog; import java.time.LocalDate; import java.util.Arrays; @@ -109,7 +106,7 @@ public enum PersonnelFilter { PersonnelFilter(final String name, final String toolTipText, final boolean baseline, final boolean standard, final boolean individualRole) { final ResourceBundle resources = ResourceBundle.getBundle("mekhq.resources.GUI", - MekHQ.getMHQOptions().getLocale()); + MekHQ.getMHQOptions().getLocale()); this.name = resources.getString(name); this.toolTipText = resources.getString(toolTipText); this.baseline = baseline; @@ -324,29 +321,29 @@ public boolean isDead() { public static List getStandardPersonnelFilters() { return Stream.of(values()).filter(filter -> filter.isBaseline() || filter.isStandard()) - .collect(Collectors.toList()); + .collect(Collectors.toList()); } public static List getExpandedPersonnelFilters() { return Stream.of(values()).filter(filter -> filter.isBaseline() || !filter.isIndividualRole()) - .collect(Collectors.toList()); + .collect(Collectors.toList()); } public static List getIndividualRolesStandardPersonnelFilters() { return Stream.of(values()).filter(filter -> filter.isBaseline() || filter.isIndividualRole()) - .collect(Collectors.toList()); + .collect(Collectors.toList()); } public static List getIndividualRolesExpandedPersonnelFilters() { return Stream.of(values()) - .filter(filter -> filter.isBaseline() || !filter.isStandard() || filter.isIndividualRole()) - .collect(Collectors.toList()); + .filter(filter -> filter.isBaseline() || !filter.isStandard() || filter.isIndividualRole()) + .collect(Collectors.toList()); } public static List getAllStandardFilters() { return Stream.of(values()) - .filter(filter -> filter.isBaseline() || filter.isStandard() || filter.isIndividualRole()) - .collect(Collectors.toList()); + .filter(filter -> filter.isBaseline() || filter.isStandard() || filter.isIndividualRole()) + .collect(Collectors.toList()); } public static List getAllIndividualRoleFilters() { @@ -362,113 +359,113 @@ public boolean getFilteredInformation(final Person person, LocalDate currentDate return active; case COMBAT: return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isCombat() : person.hasCombatRole()); + ? person.getPrimaryRole().isCombat() : person.hasCombatRole()); case SUPPORT: return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? !person.getPrimaryRole().isCombat() : person.hasSupportRole(true)); + ? !person.getPrimaryRole().isCombat() : person.hasSupportRole(true)); case MECHWARRIORS: return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isMechWarriorGrouping() - : (person.getPrimaryRole().isMechWarriorGrouping() || person.getSecondaryRole().isMechWarriorGrouping())); + ? person.getPrimaryRole().isMechWarriorGrouping() + : (person.getPrimaryRole().isMechWarriorGrouping() || person.getSecondaryRole().isMechWarriorGrouping())); case MECHWARRIOR: return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isMechWarrior() : person.hasRole(PersonnelRole.MECHWARRIOR)); + ? person.getPrimaryRole().isMechWarrior() : person.hasRole(PersonnelRole.MECHWARRIOR)); case LAM_PILOT: return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isLAMPilot() : person.hasRole(PersonnelRole.LAM_PILOT)); + ? person.getPrimaryRole().isLAMPilot() : person.hasRole(PersonnelRole.LAM_PILOT)); case VEHICLE_CREWMEMBER: return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isVehicleCrewmember() - : (person.getPrimaryRole().isVehicleCrewmember() || person.getSecondaryRole().isVehicleCrewmember())); + ? person.getPrimaryRole().isVehicleCrewmember() + : (person.getPrimaryRole().isVehicleCrewmember() || person.getSecondaryRole().isVehicleCrewmember())); case GROUND_VEHICLE_DRIVER: return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isGroundVehicleDriver() : person.hasRole(PersonnelRole.GROUND_VEHICLE_DRIVER)); + ? person.getPrimaryRole().isGroundVehicleDriver() : person.hasRole(PersonnelRole.GROUND_VEHICLE_DRIVER)); case NAVAL_VEHICLE_DRIVER: return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isNavalVehicleDriver() : person.hasRole(PersonnelRole.NAVAL_VEHICLE_DRIVER)); + ? person.getPrimaryRole().isNavalVehicleDriver() : person.hasRole(PersonnelRole.NAVAL_VEHICLE_DRIVER)); case VEHICLE_GUNNER: return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isVehicleGunner() : person.hasRole(PersonnelRole.VEHICLE_GUNNER)); + ? person.getPrimaryRole().isVehicleGunner() : person.hasRole(PersonnelRole.VEHICLE_GUNNER)); case VEHICLE_CREW: return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isVehicleCrew() : person.hasRole(PersonnelRole.VEHICLE_CREW)); + ? person.getPrimaryRole().isVehicleCrew() : person.hasRole(PersonnelRole.VEHICLE_CREW)); case VTOL_PILOT: return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isVTOLPilot() : person.hasRole(PersonnelRole.VTOL_PILOT)); + ? person.getPrimaryRole().isVTOLPilot() : person.hasRole(PersonnelRole.VTOL_PILOT)); case AEROSPACE_PILOT: return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isAerospacePilot() : person.hasRole(PersonnelRole.AEROSPACE_PILOT)); + ? person.getPrimaryRole().isAerospacePilot() : person.hasRole(PersonnelRole.AEROSPACE_PILOT)); case CONVENTIONAL_AIRCRAFT_PILOT: return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isConventionalAircraftPilot() : person.hasRole(PersonnelRole.CONVENTIONAL_AIRCRAFT_PILOT)); + ? person.getPrimaryRole().isConventionalAircraftPilot() : person.hasRole(PersonnelRole.CONVENTIONAL_AIRCRAFT_PILOT)); case PROTOMECH_PILOT: return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isProtoMechPilot() : person.hasRole(PersonnelRole.PROTOMECH_PILOT)); + ? person.getPrimaryRole().isProtoMechPilot() : person.hasRole(PersonnelRole.PROTOMECH_PILOT)); case BATTLE_ARMOUR: return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isBattleArmour() : person.hasRole(PersonnelRole.BATTLE_ARMOUR)); + ? person.getPrimaryRole().isBattleArmour() : person.hasRole(PersonnelRole.BATTLE_ARMOUR)); case SOLDIER: return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isSoldier() : person.hasRole(PersonnelRole.SOLDIER)); + ? person.getPrimaryRole().isSoldier() : person.hasRole(PersonnelRole.SOLDIER)); case VESSEL_CREWMEMBER: return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isVesselCrewmember() - : (person.getPrimaryRole().isVesselCrewmember() || person.getSecondaryRole().isVesselCrewmember())); + ? person.getPrimaryRole().isVesselCrewmember() + : (person.getPrimaryRole().isVesselCrewmember() || person.getSecondaryRole().isVesselCrewmember())); case VESSEL_PILOT: return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isVesselPilot() : person.hasRole(PersonnelRole.VESSEL_PILOT)); + ? person.getPrimaryRole().isVesselPilot() : person.hasRole(PersonnelRole.VESSEL_PILOT)); case VESSEL_CREW: return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isVesselCrew() : person.hasRole(PersonnelRole.VESSEL_CREW)); + ? person.getPrimaryRole().isVesselCrew() : person.hasRole(PersonnelRole.VESSEL_CREW)); case VESSEL_GUNNER: return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isVesselGunner() : person.hasRole(PersonnelRole.VESSEL_GUNNER)); + ? person.getPrimaryRole().isVesselGunner() : person.hasRole(PersonnelRole.VESSEL_GUNNER)); case VESSEL_NAVIGATOR: return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isVesselNavigator() : person.hasRole(PersonnelRole.VESSEL_NAVIGATOR)); + ? person.getPrimaryRole().isVesselNavigator() : person.hasRole(PersonnelRole.VESSEL_NAVIGATOR)); case TECH: return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isTech() : person.isTech()); + ? person.getPrimaryRole().isTech() : person.isTech()); case MECH_TECH: return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isMechTech() : person.hasRole(PersonnelRole.MECH_TECH)); + ? person.getPrimaryRole().isMechTech() : person.hasRole(PersonnelRole.MECH_TECH)); case MECHANIC: return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isMechanic() : person.hasRole(PersonnelRole.MECHANIC)); + ? person.getPrimaryRole().isMechanic() : person.hasRole(PersonnelRole.MECHANIC)); case AERO_TECH: return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isAeroTech() : person.hasRole(PersonnelRole.AERO_TECH)); + ? person.getPrimaryRole().isAeroTech() : person.hasRole(PersonnelRole.AERO_TECH)); case BA_TECH: return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isBATech() : person.hasRole(PersonnelRole.BA_TECH)); + ? person.getPrimaryRole().isBATech() : person.hasRole(PersonnelRole.BA_TECH)); case ASTECH: return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isAstech() : person.hasRole(PersonnelRole.ASTECH)); + ? person.getPrimaryRole().isAstech() : person.hasRole(PersonnelRole.ASTECH)); case MEDICAL: return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isMedicalStaff() - : (person.getPrimaryRole().isMedicalStaff() || person.getSecondaryRole().isMedicalStaff())); + ? person.getPrimaryRole().isMedicalStaff() + : (person.getPrimaryRole().isMedicalStaff() || person.getSecondaryRole().isMedicalStaff())); case DOCTOR: return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isDoctor() : person.hasRole(PersonnelRole.DOCTOR)); + ? person.getPrimaryRole().isDoctor() : person.hasRole(PersonnelRole.DOCTOR)); case MEDIC: return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isMedic() : person.hasRole(PersonnelRole.MEDIC)); + ? person.getPrimaryRole().isMedic() : person.hasRole(PersonnelRole.MEDIC)); case ADMINISTRATOR: return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isAdministrator() : person.isAdministrator()); + ? person.getPrimaryRole().isAdministrator() : person.isAdministrator()); case ADMINISTRATOR_COMMAND: return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isAdministratorCommand() : person.hasRole(PersonnelRole.ADMINISTRATOR_COMMAND)); + ? person.getPrimaryRole().isAdministratorCommand() : person.hasRole(PersonnelRole.ADMINISTRATOR_COMMAND)); case ADMINISTRATOR_LOGISTICS: return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isAdministratorLogistics() : person.hasRole(PersonnelRole.ADMINISTRATOR_LOGISTICS)); + ? person.getPrimaryRole().isAdministratorLogistics() : person.hasRole(PersonnelRole.ADMINISTRATOR_LOGISTICS)); case ADMINISTRATOR_TRANSPORT: return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isAdministratorTransport() : person.hasRole(PersonnelRole.ADMINISTRATOR_TRANSPORT)); + ? person.getPrimaryRole().isAdministratorTransport() : person.hasRole(PersonnelRole.ADMINISTRATOR_TRANSPORT)); case ADMINISTRATOR_HR: return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isAdministratorHR() : person.hasRole(PersonnelRole.ADMINISTRATOR_HR)); + ? person.getPrimaryRole().isAdministratorHR() : person.hasRole(PersonnelRole.ADMINISTRATOR_HR)); case DEPENDENT: return active && person.getPrimaryRole().isDependent(); case FOUNDER: From df54613f5122b9d305e1ece613e6881af1dc539a Mon Sep 17 00:00:00 2001 From: nutritiousemployee Date: Tue, 24 Oct 2023 23:45:36 +0200 Subject: [PATCH 6/6] Children filter - setting tabs back to 4 --- MekHQ/src/mekhq/gui/PersonnelTab.java | 706 ++++++------- .../src/mekhq/gui/enums/PersonnelFilter.java | 928 +++++++++--------- 2 files changed, 817 insertions(+), 817 deletions(-) diff --git a/MekHQ/src/mekhq/gui/PersonnelTab.java b/MekHQ/src/mekhq/gui/PersonnelTab.java index c137ab885e..5f038d8e16 100644 --- a/MekHQ/src/mekhq/gui/PersonnelTab.java +++ b/MekHQ/src/mekhq/gui/PersonnelTab.java @@ -51,377 +51,377 @@ * Tab for interacting with all personnel */ public final class PersonnelTab extends CampaignGuiTab { - public static final int PERSONNEL_VIEW_WIDTH = 500; - - private JSplitPane splitPersonnel; - private JTable personnelTable; - private MMComboBox choicePerson; - private MMComboBox choicePersonView; - private JScrollPane scrollPersonnelView; - private JCheckBox chkGroupByUnit; - - private PersonnelTableModel personModel; - private TableRowSorter personnelSorter; - - //region Constructors - public PersonnelTab(CampaignGUI gui, String name) { - super(gui, name); - MekHQ.registerHandler(this); - setUserPreferences(); - } - //endregion Constructors - - @Override - public MHQTabType tabType() { - return MHQTabType.PERSONNEL; - } - - /* - * (non-Javadoc) - * - * @see mekhq.gui.CampaignGuiTab#initTab() - */ - @Override - public void initTab() { - final ResourceBundle resourceMap = ResourceBundle.getBundle("mekhq.resources.CampaignGUI", - MekHQ.getMHQOptions().getLocale()); - GridBagConstraints gridBagConstraints; - - setLayout(new GridBagLayout()); - - gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridx = 0; - gridBagConstraints.gridy = 0; - gridBagConstraints.weightx = 0.0; - gridBagConstraints.anchor = GridBagConstraints.WEST; - gridBagConstraints.insets = new Insets(5, 5, 0, 0); - add(new JLabel(resourceMap.getString("lblPersonChoice.text")), gridBagConstraints); - - choicePerson = new MMComboBox<>("choicePerson", createPersonGroupModel()); - choicePerson.setSelectedItem(PersonnelFilter.ACTIVE); - choicePerson.setRenderer(new DefaultListCellRenderer() { - @Override - public Component getListCellRendererComponent(final JList list, final Object value, - final int index, final boolean isSelected, - final boolean cellHasFocus) { - super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - if (value instanceof PersonnelFilter) { - list.setToolTipText(((PersonnelFilter) value).getToolTipText()); + public static final int PERSONNEL_VIEW_WIDTH = 500; + + private JSplitPane splitPersonnel; + private JTable personnelTable; + private MMComboBox choicePerson; + private MMComboBox choicePersonView; + private JScrollPane scrollPersonnelView; + private JCheckBox chkGroupByUnit; + + private PersonnelTableModel personModel; + private TableRowSorter personnelSorter; + + //region Constructors + public PersonnelTab(CampaignGUI gui, String name) { + super(gui, name); + MekHQ.registerHandler(this); + setUserPreferences(); + } + //endregion Constructors + + @Override + public MHQTabType tabType() { + return MHQTabType.PERSONNEL; + } + + /* + * (non-Javadoc) + * + * @see mekhq.gui.CampaignGuiTab#initTab() + */ + @Override + public void initTab() { + final ResourceBundle resourceMap = ResourceBundle.getBundle("mekhq.resources.CampaignGUI", + MekHQ.getMHQOptions().getLocale()); + GridBagConstraints gridBagConstraints; + + setLayout(new GridBagLayout()); + + gridBagConstraints = new GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 0; + gridBagConstraints.weightx = 0.0; + gridBagConstraints.anchor = GridBagConstraints.WEST; + gridBagConstraints.insets = new Insets(5, 5, 0, 0); + add(new JLabel(resourceMap.getString("lblPersonChoice.text")), gridBagConstraints); + + choicePerson = new MMComboBox<>("choicePerson", createPersonGroupModel()); + choicePerson.setSelectedItem(PersonnelFilter.ACTIVE); + choicePerson.setRenderer(new DefaultListCellRenderer() { + @Override + public Component getListCellRendererComponent(final JList list, final Object value, + final int index, final boolean isSelected, + final boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + if (value instanceof PersonnelFilter) { + list.setToolTipText(((PersonnelFilter) value).getToolTipText()); + } + return this; + } + }); + choicePerson.addActionListener(ev -> filterPersonnel()); + gridBagConstraints = new GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 0; + gridBagConstraints.fill = GridBagConstraints.NONE; + gridBagConstraints.weightx = 0.0; + gridBagConstraints.weighty = 0.0; + gridBagConstraints.anchor = GridBagConstraints.WEST; + gridBagConstraints.insets = new Insets(5, 5, 0, 0); + add(choicePerson, gridBagConstraints); + + gridBagConstraints = new GridBagConstraints(); + gridBagConstraints.gridx = 2; + gridBagConstraints.gridy = 0; + gridBagConstraints.fill = GridBagConstraints.NONE; + gridBagConstraints.weightx = 0.0; + gridBagConstraints.weighty = 0.0; + gridBagConstraints.anchor = GridBagConstraints.WEST; + gridBagConstraints.insets = new Insets(5, 5, 0, 0); + add(new JLabel(resourceMap.getString("lblPersonView.text")), gridBagConstraints); + + choicePersonView = new MMComboBox<>("choicePersonView", PersonnelTabView.values()); + choicePersonView.setSelectedItem(PersonnelTabView.GENERAL); + choicePersonView.setRenderer(new DefaultListCellRenderer() { + @Override + public Component getListCellRendererComponent(final JList list, final Object value, + final int index, final boolean isSelected, + final boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + if (value instanceof PersonnelTabView) { + list.setToolTipText(((PersonnelTabView) value).getToolTipText()); + } + return this; + } + }); + choicePersonView.addActionListener(ev -> changePersonnelView()); + gridBagConstraints = new GridBagConstraints(); + gridBagConstraints.gridx = 3; + gridBagConstraints.gridy = 0; + gridBagConstraints.fill = GridBagConstraints.NONE; + gridBagConstraints.weightx = 0.0; + gridBagConstraints.weighty = 0.0; + gridBagConstraints.anchor = GridBagConstraints.WEST; + gridBagConstraints.insets = new Insets(5, 5, 0, 0); + add(choicePersonView, gridBagConstraints); + + chkGroupByUnit = new JCheckBox(resourceMap.getString("chkGroupByUnit.text")); + chkGroupByUnit.setToolTipText(resourceMap.getString("chkGroupByUnit.toolTipText")); + chkGroupByUnit.addActionListener(e -> { + personModel.setGroupByUnit(chkGroupByUnit.isSelected()); + personModel.refreshData(); + }); + gridBagConstraints = new GridBagConstraints(); + gridBagConstraints.gridx = 4; + gridBagConstraints.gridy = 0; + gridBagConstraints.fill = GridBagConstraints.NONE; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 0.0; + gridBagConstraints.anchor = GridBagConstraints.WEST; + gridBagConstraints.insets = new Insets(5, 5, 0, 0); + add(chkGroupByUnit, gridBagConstraints); + + personModel = new PersonnelTableModel(getCampaign()); + personnelTable = new JTable(personModel); + personnelTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + personnelTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); + XTableColumnModel personColumnModel = new XTableColumnModel(); + personnelTable.setColumnModel(personColumnModel); + personnelTable.createDefaultColumnsFromModel(); + personnelSorter = new TableRowSorter<>(personModel); + final ArrayList sortKeys = new ArrayList<>(); + for (final PersonnelTableModelColumn column : PersonnelTableModel.PERSONNEL_COLUMNS) { + final Comparator comparator = column.getComparator(getCampaign()); + if (comparator != null) { + personnelSorter.setComparator(column.ordinal(), comparator); + } + final SortOrder sortOrder = column.getDefaultSortOrder(); + if (sortOrder != null) { + sortKeys.add(new RowSorter.SortKey(column.ordinal(), sortOrder)); + } } - return this; - } - }); - choicePerson.addActionListener(ev -> filterPersonnel()); - gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridx = 1; - gridBagConstraints.gridy = 0; - gridBagConstraints.fill = GridBagConstraints.NONE; - gridBagConstraints.weightx = 0.0; - gridBagConstraints.weighty = 0.0; - gridBagConstraints.anchor = GridBagConstraints.WEST; - gridBagConstraints.insets = new Insets(5, 5, 0, 0); - add(choicePerson, gridBagConstraints); - - gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridx = 2; - gridBagConstraints.gridy = 0; - gridBagConstraints.fill = GridBagConstraints.NONE; - gridBagConstraints.weightx = 0.0; - gridBagConstraints.weighty = 0.0; - gridBagConstraints.anchor = GridBagConstraints.WEST; - gridBagConstraints.insets = new Insets(5, 5, 0, 0); - add(new JLabel(resourceMap.getString("lblPersonView.text")), gridBagConstraints); - - choicePersonView = new MMComboBox<>("choicePersonView", PersonnelTabView.values()); - choicePersonView.setSelectedItem(PersonnelTabView.GENERAL); - choicePersonView.setRenderer(new DefaultListCellRenderer() { - @Override - public Component getListCellRendererComponent(final JList list, final Object value, - final int index, final boolean isSelected, - final boolean cellHasFocus) { - super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - if (value instanceof PersonnelTabView) { - list.setToolTipText(((PersonnelTabView) value).getToolTipText()); + personnelSorter.setSortKeys(sortKeys); + personnelTable.setRowSorter(personnelSorter); + personnelTable.setIntercellSpacing(new Dimension(0, 0)); + personnelTable.setShowGrid(false); + changePersonnelView(); + personnelTable.getSelectionModel().addListSelectionListener(ev -> refreshPersonnelView()); + + scrollPersonnelView = new JScrollPane(); + scrollPersonnelView.setMinimumSize(new Dimension(PERSONNEL_VIEW_WIDTH, 600)); + scrollPersonnelView.setPreferredSize(new Dimension(PERSONNEL_VIEW_WIDTH, 600)); + scrollPersonnelView.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + scrollPersonnelView.setViewportView(null); + + JScrollPane scrollPersonnelTable = new JScrollPane(personnelTable); + splitPersonnel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scrollPersonnelTable, + scrollPersonnelView); + splitPersonnel.setOneTouchExpandable(true); + splitPersonnel.setResizeWeight(1.0); + splitPersonnel.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, ev -> refreshPersonnelView()); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 1; + gridBagConstraints.gridwidth = 5; + gridBagConstraints.fill = GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + add(splitPersonnel, gridBagConstraints); + + PersonnelTableMouseAdapter.connect(getCampaignGui(), personnelTable, personModel, splitPersonnel); + + filterPersonnel(); + } + + private DefaultComboBoxModel createPersonGroupModel() { + final DefaultComboBoxModel personGroupModel = new DefaultComboBoxModel<>(); + for (PersonnelFilter filter : MekHQ.getMHQOptions().getPersonnelFilterStyle().getFilters(false)) { + personGroupModel.addElement(filter); } - return this; - } - }); - choicePersonView.addActionListener(ev -> changePersonnelView()); - gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridx = 3; - gridBagConstraints.gridy = 0; - gridBagConstraints.fill = GridBagConstraints.NONE; - gridBagConstraints.weightx = 0.0; - gridBagConstraints.weighty = 0.0; - gridBagConstraints.anchor = GridBagConstraints.WEST; - gridBagConstraints.insets = new Insets(5, 5, 0, 0); - add(choicePersonView, gridBagConstraints); - - chkGroupByUnit = new JCheckBox(resourceMap.getString("chkGroupByUnit.text")); - chkGroupByUnit.setToolTipText(resourceMap.getString("chkGroupByUnit.toolTipText")); - chkGroupByUnit.addActionListener(e -> { - personModel.setGroupByUnit(chkGroupByUnit.isSelected()); - personModel.refreshData(); - }); - gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridx = 4; - gridBagConstraints.gridy = 0; - gridBagConstraints.fill = GridBagConstraints.NONE; - gridBagConstraints.weightx = 1.0; - gridBagConstraints.weighty = 0.0; - gridBagConstraints.anchor = GridBagConstraints.WEST; - gridBagConstraints.insets = new Insets(5, 5, 0, 0); - add(chkGroupByUnit, gridBagConstraints); - - personModel = new PersonnelTableModel(getCampaign()); - personnelTable = new JTable(personModel); - personnelTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - personnelTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); - XTableColumnModel personColumnModel = new XTableColumnModel(); - personnelTable.setColumnModel(personColumnModel); - personnelTable.createDefaultColumnsFromModel(); - personnelSorter = new TableRowSorter<>(personModel); - final ArrayList sortKeys = new ArrayList<>(); - for (final PersonnelTableModelColumn column : PersonnelTableModel.PERSONNEL_COLUMNS) { - final Comparator comparator = column.getComparator(getCampaign()); - if (comparator != null) { - personnelSorter.setComparator(column.ordinal(), comparator); - } - final SortOrder sortOrder = column.getDefaultSortOrder(); - if (sortOrder != null) { - sortKeys.add(new RowSorter.SortKey(column.ordinal(), sortOrder)); - } + return personGroupModel; } - personnelSorter.setSortKeys(sortKeys); - personnelTable.setRowSorter(personnelSorter); - personnelTable.setIntercellSpacing(new Dimension(0, 0)); - personnelTable.setShowGrid(false); - changePersonnelView(); - personnelTable.getSelectionModel().addListSelectionListener(ev -> refreshPersonnelView()); - - scrollPersonnelView = new JScrollPane(); - scrollPersonnelView.setMinimumSize(new Dimension(PERSONNEL_VIEW_WIDTH, 600)); - scrollPersonnelView.setPreferredSize(new Dimension(PERSONNEL_VIEW_WIDTH, 600)); - scrollPersonnelView.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); - scrollPersonnelView.setViewportView(null); - - JScrollPane scrollPersonnelTable = new JScrollPane(personnelTable); - splitPersonnel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scrollPersonnelTable, - scrollPersonnelView); - splitPersonnel.setOneTouchExpandable(true); - splitPersonnel.setResizeWeight(1.0); - splitPersonnel.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, ev -> refreshPersonnelView()); - gridBagConstraints.gridx = 0; - gridBagConstraints.gridy = 1; - gridBagConstraints.gridwidth = 5; - gridBagConstraints.fill = GridBagConstraints.BOTH; - gridBagConstraints.weightx = 1.0; - gridBagConstraints.weighty = 1.0; - add(splitPersonnel, gridBagConstraints); - - PersonnelTableMouseAdapter.connect(getCampaignGui(), personnelTable, personModel, splitPersonnel); - - filterPersonnel(); - } - - private DefaultComboBoxModel createPersonGroupModel() { - final DefaultComboBoxModel personGroupModel = new DefaultComboBoxModel<>(); - for (PersonnelFilter filter : MekHQ.getMHQOptions().getPersonnelFilterStyle().getFilters(false)) { - personGroupModel.addElement(filter); + + @Deprecated // These need to be migrated to the Suite Constants / Suite Options Setup + private void setUserPreferences() { + try { + PreferencesNode preferences = MekHQ.getMHQPreferences().forClass(PersonnelTab.class); + this.setName("dialog"); + + choicePerson.setName("personnelType"); + preferences.manage(new JComboBoxPreference(choicePerson)); + + choicePersonView.setName("personnelView"); + preferences.manage(new JComboBoxPreference(choicePersonView)); + + chkGroupByUnit.setName("groupByUnit"); + preferences.manage(new JToggleButtonPreference(chkGroupByUnit)); + + personnelTable.setName("personnelTable"); + preferences.manage(new JTablePreference(personnelTable)); + } catch (Exception ex) { + LogManager.getLogger().error("Failed to set user preferences", ex); + } } - return personGroupModel; - } - @Deprecated // These need to be migrated to the Suite Constants / Suite Options Setup - private void setUserPreferences() { - try { - PreferencesNode preferences = MekHQ.getMHQPreferences().forClass(PersonnelTab.class); - this.setName("dialog"); + /* For export */ + public JTable getPersonnelTable() { + return personnelTable; + } - choicePerson.setName("personnelType"); - preferences.manage(new JComboBoxPreference(choicePerson)); + public PersonnelTableModel getPersonModel() { + return personModel; + } - choicePersonView.setName("personnelView"); - preferences.manage(new JComboBoxPreference(choicePersonView)); + /* + * (non-Javadoc) + * + * @see mekhq.gui.CampaignGuiTab#refreshAll() + */ + @Override + public void refreshAll() { + refreshPersonnelList(); + changePersonnelView(); + } - chkGroupByUnit.setName("groupByUnit"); - preferences.manage(new JToggleButtonPreference(chkGroupByUnit)); + public void filterPersonnel() { + final PersonnelFilter filter = (choicePerson.getSelectedItem() == null) + ? PersonnelFilter.ACTIVE : choicePerson.getSelectedItem(); + personnelSorter.setRowFilter(new RowFilter<>() { + @Override + public boolean include(Entry entry) { + return filter.getFilteredInformation(entry.getModel().getPerson(entry.getIdentifier()), getCampaignGui().getCampaign().getLocalDate()); + } + }); + } - personnelTable.setName("personnelTable"); - preferences.manage(new JTablePreference(personnelTable)); - } catch (Exception ex) { - LogManager.getLogger().error("Failed to set user preferences", ex); + private void changePersonnelView() { + final PersonnelTabView view = (choicePersonView.getSelectedItem() == null) + ? PersonnelTabView.GENERAL : choicePersonView.getSelectedItem(); + final XTableColumnModel columnModel = (XTableColumnModel) getPersonnelTable().getColumnModel(); + getPersonnelTable().setRowHeight(15); + + // set the renderer + for (final PersonnelTableModelColumn column : PersonnelTableModel.PERSONNEL_COLUMNS) { + final TableColumn tableColumn = columnModel.getColumnByModelIndex(column.ordinal()); + tableColumn.setCellRenderer(getPersonModel().getRenderer(choicePersonView.getSelectedItem())); + tableColumn.setPreferredWidth(column.getWidth()); + columnModel.setColumnVisible(tableColumn, + column.isVisible(getCampaign(), view, getPersonnelTable())); + } } - } - - /* For export */ - public JTable getPersonnelTable() { - return personnelTable; - } - - public PersonnelTableModel getPersonModel() { - return personModel; - } - - /* - * (non-Javadoc) - * - * @see mekhq.gui.CampaignGuiTab#refreshAll() - */ - @Override - public void refreshAll() { - refreshPersonnelList(); - changePersonnelView(); - } - - public void filterPersonnel() { - final PersonnelFilter filter = (choicePerson.getSelectedItem() == null) - ? PersonnelFilter.ACTIVE : choicePerson.getSelectedItem(); - personnelSorter.setRowFilter(new RowFilter<>() { - @Override - public boolean include(Entry entry) { - return filter.getFilteredInformation(entry.getModel().getPerson(entry.getIdentifier()), getCampaignGui().getCampaign().getLocalDate()); - } - }); - } - - private void changePersonnelView() { - final PersonnelTabView view = (choicePersonView.getSelectedItem() == null) - ? PersonnelTabView.GENERAL : choicePersonView.getSelectedItem(); - final XTableColumnModel columnModel = (XTableColumnModel) getPersonnelTable().getColumnModel(); - getPersonnelTable().setRowHeight(15); - - // set the renderer - for (final PersonnelTableModelColumn column : PersonnelTableModel.PERSONNEL_COLUMNS) { - final TableColumn tableColumn = columnModel.getColumnByModelIndex(column.ordinal()); - tableColumn.setCellRenderer(getPersonModel().getRenderer(choicePersonView.getSelectedItem())); - tableColumn.setPreferredWidth(column.getWidth()); - columnModel.setColumnVisible(tableColumn, - column.isVisible(getCampaign(), view, getPersonnelTable())); + + public void focusOnPerson(UUID id) { + splitPersonnel.resetToPreferredSizes(); + int row = -1; + for (int i = 0; i < personnelTable.getRowCount(); i++) { + if (personModel.getPerson(personnelTable.convertRowIndexToModel(i)).getId().equals(id)) { + row = i; + break; + } + } + if (row == -1) { + // try expanding the filter to all units + choicePerson.setSelectedIndex(0); + for (int i = 0; i < personnelTable.getRowCount(); i++) { + if (personModel.getPerson(personnelTable.convertRowIndexToModel(i)).getId().equals(id)) { + row = i; + break; + } + } + + } + if (row != -1) { + personnelTable.setRowSelectionInterval(row, row); + personnelTable.scrollRectToVisible(personnelTable.getCellRect(row, 0, true)); + } } - } - - public void focusOnPerson(UUID id) { - splitPersonnel.resetToPreferredSizes(); - int row = -1; - for (int i = 0; i < personnelTable.getRowCount(); i++) { - if (personModel.getPerson(personnelTable.convertRowIndexToModel(i)).getId().equals(id)) { - row = i; - break; - } + + /** + * Refreshes personnel table model. + */ + public void refreshPersonnelList() { + UUID selectedUUID = null; + int selectedRow = personnelTable.getSelectedRow(); + if (selectedRow != -1) { + Person p = personModel.getPerson(personnelTable.convertRowIndexToModel(selectedRow)); + if (null != p) { + selectedUUID = p.getId(); + } + } + personModel.refreshData(); + // try to put the focus back on same person if they are still available + for (int row = 0; row < personnelTable.getRowCount(); row++) { + Person p = personModel.getPerson(personnelTable.convertRowIndexToModel(row)); + if (p.getId().equals(selectedUUID)) { + personnelTable.setRowSelectionInterval(row, row); + refreshPersonnelView(); + break; + } + } + filterPersonnel(); } - if (row == -1) { - // try expanding the filter to all units - choicePerson.setSelectedIndex(0); - for (int i = 0; i < personnelTable.getRowCount(); i++) { - if (personModel.getPerson(personnelTable.convertRowIndexToModel(i)).getId().equals(id)) { - row = i; - break; + + public void refreshPersonnelView() { + int row = personnelTable.getSelectedRow(); + if (row < 0) { + scrollPersonnelView.setViewportView(null); + return; } - } + Person selectedPerson = personModel.getPerson(personnelTable.convertRowIndexToModel(row)); + scrollPersonnelView.setViewportView(new PersonViewPanel(selectedPerson, getCampaign(), getCampaignGui())); + // This odd code is to make sure that the scrollbar stays at the top + // I can't just call it here, because it ends up getting reset somewhere later + SwingUtilities.invokeLater(() -> scrollPersonnelView.getVerticalScrollBar().setValue(0)); + } + + private ActionScheduler personnelListScheduler = new ActionScheduler(this::refreshPersonnelList); + private ActionScheduler filterPersonnelScheduler = new ActionScheduler(this::filterPersonnel); + + @Subscribe + public void handle(OptionsChangedEvent ev) { + changePersonnelView(); + personnelListScheduler.schedule(); + } + + @Subscribe + public void handle(MHQOptionsChangedEvent evt) { + choicePerson.setModel(createPersonGroupModel()); + personnelListScheduler.schedule(); + } + + @Subscribe + public void handle(DeploymentChangedEvent ev) { + filterPersonnelScheduler.schedule(); + } + @Subscribe + public void handle(PersonChangedEvent ev) { + personnelListScheduler.schedule(); } - if (row != -1) { - personnelTable.setRowSelectionInterval(row, row); - personnelTable.scrollRectToVisible(personnelTable.getCellRect(row, 0, true)); + + @Subscribe + public void handle(PersonNewEvent ev) { + personnelListScheduler.schedule(); } - } - - /** - * Refreshes personnel table model. - */ - public void refreshPersonnelList() { - UUID selectedUUID = null; - int selectedRow = personnelTable.getSelectedRow(); - if (selectedRow != -1) { - Person p = personModel.getPerson(personnelTable.convertRowIndexToModel(selectedRow)); - if (null != p) { - selectedUUID = p.getId(); - } + + @Subscribe + public void handle(PersonRemovedEvent ev) { + personnelListScheduler.schedule(); } - personModel.refreshData(); - // try to put the focus back on same person if they are still available - for (int row = 0; row < personnelTable.getRowCount(); row++) { - Person p = personModel.getPerson(personnelTable.convertRowIndexToModel(row)); - if (p.getId().equals(selectedUUID)) { - personnelTable.setRowSelectionInterval(row, row); + + @Subscribe + public void handle(PersonLogEvent ev) { refreshPersonnelView(); - break; - } } - filterPersonnel(); - } - - public void refreshPersonnelView() { - int row = personnelTable.getSelectedRow(); - if (row < 0) { - scrollPersonnelView.setViewportView(null); - return; + + @Subscribe + public void handle(ScenarioResolvedEvent ev) { + personnelListScheduler.schedule(); + } + + @Subscribe + public void handle(UnitRemovedEvent ev) { + filterPersonnelScheduler.schedule(); + } + + @Subscribe + public void handle(PartWorkEvent ev) { + filterPersonnelScheduler.schedule(); + } + + @Subscribe + public void handle(OvertimeModeEvent ev) { + filterPersonnelScheduler.schedule(); } - Person selectedPerson = personModel.getPerson(personnelTable.convertRowIndexToModel(row)); - scrollPersonnelView.setViewportView(new PersonViewPanel(selectedPerson, getCampaign(), getCampaignGui())); - // This odd code is to make sure that the scrollbar stays at the top - // I can't just call it here, because it ends up getting reset somewhere later - SwingUtilities.invokeLater(() -> scrollPersonnelView.getVerticalScrollBar().setValue(0)); - } - - private ActionScheduler personnelListScheduler = new ActionScheduler(this::refreshPersonnelList); - private ActionScheduler filterPersonnelScheduler = new ActionScheduler(this::filterPersonnel); - - @Subscribe - public void handle(OptionsChangedEvent ev) { - changePersonnelView(); - personnelListScheduler.schedule(); - } - - @Subscribe - public void handle(MHQOptionsChangedEvent evt) { - choicePerson.setModel(createPersonGroupModel()); - personnelListScheduler.schedule(); - } - - @Subscribe - public void handle(DeploymentChangedEvent ev) { - filterPersonnelScheduler.schedule(); - } - - @Subscribe - public void handle(PersonChangedEvent ev) { - personnelListScheduler.schedule(); - } - - @Subscribe - public void handle(PersonNewEvent ev) { - personnelListScheduler.schedule(); - } - - @Subscribe - public void handle(PersonRemovedEvent ev) { - personnelListScheduler.schedule(); - } - - @Subscribe - public void handle(PersonLogEvent ev) { - refreshPersonnelView(); - } - - @Subscribe - public void handle(ScenarioResolvedEvent ev) { - personnelListScheduler.schedule(); - } - - @Subscribe - public void handle(UnitRemovedEvent ev) { - filterPersonnelScheduler.schedule(); - } - - @Subscribe - public void handle(PartWorkEvent ev) { - filterPersonnelScheduler.schedule(); - } - - @Subscribe - public void handle(OvertimeModeEvent ev) { - filterPersonnelScheduler.schedule(); - } } diff --git a/MekHQ/src/mekhq/gui/enums/PersonnelFilter.java b/MekHQ/src/mekhq/gui/enums/PersonnelFilter.java index bab7a9935d..be403695ca 100644 --- a/MekHQ/src/mekhq/gui/enums/PersonnelFilter.java +++ b/MekHQ/src/mekhq/gui/enums/PersonnelFilter.java @@ -30,469 +30,469 @@ import java.util.stream.Stream; public enum PersonnelFilter { - //region Enum Declarations - //region Standard Personnel Filters - ALL("PersonnelFilter.ALL.text", "PersonnelFilter.ALL.toolTipText"), - ACTIVE("PersonnelFilter.ACTIVE.text", "PersonnelFilter.ACTIVE.toolTipText"), - COMBAT("PersonnelFilter.COMBAT.text", "PersonnelFilter.COMBAT.toolTipText"), - SUPPORT("PersonnelFilter.SUPPORT.text", "PersonnelFilter.SUPPORT.toolTipText"), - MECHWARRIORS("PersonnelFilter.MECHWARRIORS.text", "PersonnelFilter.MECHWARRIORS.toolTipText", true, false), - MECHWARRIOR("PersonnelFilter.MECHWARRIOR.text", "PersonnelFilter.MECHWARRIOR.toolTipText", false, true), - LAM_PILOT("PersonnelFilter.LAM_PILOT.text", "PersonnelFilter.LAM_PILOT.toolTipText", false, true), - VEHICLE_CREWMEMBER("PersonnelFilter.VEHICLE_CREWMEMBER.text", "PersonnelFilter.VEHICLE_CREWMEMBER.toolTipText", true, false), - GROUND_VEHICLE_DRIVER("PersonnelFilter.GROUND_VEHICLE_DRIVER.text", "PersonnelFilter.GROUND_VEHICLE_DRIVER.toolTipText", false, true), - NAVAL_VEHICLE_DRIVER("PersonnelFilter.NAVAL_VEHICLE_DRIVER.text", "PersonnelFilter.NAVAL_VEHICLE_DRIVER.toolTipText", false, true), - VTOL_PILOT("PersonnelFilter.VTOL_PILOT.text", "PersonnelFilter.VTOL_PILOT.toolTipText", false, true), - VEHICLE_GUNNER("PersonnelFilter.VEHICLE_GUNNER.text", "PersonnelFilter.VEHICLE_GUNNER.toolTipText", false, true), - VEHICLE_CREW("PersonnelFilter.VEHICLE_CREW.text", "PersonnelFilter.VEHICLE_CREW.toolTipText", false, true), - AEROSPACE_PILOT("PersonnelFilter.AEROSPACE_PILOT.text", "PersonnelFilter.AEROSPACE_PILOT.toolTipText"), - CONVENTIONAL_AIRCRAFT_PILOT("PersonnelFilter.CONVENTIONAL_AIRCRAFT_PILOT.text", "PersonnelFilter.CONVENTIONAL_AIRCRAFT_PILOT.toolTipText"), - PROTOMECH_PILOT("PersonnelFilter.PROTOMECH_PILOT.text", "PersonnelFilter.PROTOMECH_PILOT.toolTipText"), - BATTLE_ARMOUR("PersonnelFilter.BATTLE_ARMOUR.text", "PersonnelFilter.BATTLE_ARMOUR.toolTipText"), - SOLDIER("PersonnelFilter.SOLDIER.text", "PersonnelFilter.SOLDIER.toolTipText"), - VESSEL_CREWMEMBER("PersonnelFilter.VESSEL_CREWMEMBER.text", "PersonnelFilter.VESSEL_CREWMEMBER.toolTipText", true, false), - VESSEL_PILOT("PersonnelFilter.VESSEL_PILOT.text", "PersonnelFilter.VESSEL_PILOT.toolTipText", false, true), - VESSEL_GUNNER("PersonnelFilter.VESSEL_GUNNER.text", "PersonnelFilter.VESSEL_GUNNER.toolTipText", false, true), - VESSEL_CREW("PersonnelFilter.VESSEL_CREW.text", "PersonnelFilter.VESSEL_CREW.toolTipText", false, true), - VESSEL_NAVIGATOR("PersonnelFilter.VESSEL_NAVIGATOR.text", "PersonnelFilter.VESSEL_NAVIGATOR.toolTipText", false, true), - TECH("PersonnelFilter.TECH.text", "PersonnelFilter.TECH.toolTipText", true, false), - MECH_TECH("PersonnelFilter.MECH_TECH.text", "PersonnelFilter.MECH_TECH.toolTipText", false, true), - MECHANIC("PersonnelFilter.MECHANIC.text", "PersonnelFilter.MECHANIC.toolTipText", false, true), - AERO_TECH("PersonnelFilter.AERO_TECH.text", "PersonnelFilter.AERO_TECH.toolTipText", false, true), - BA_TECH("PersonnelFilter.BA_TECH.text", "PersonnelFilter.BA_TECH.toolTipText", false, true), - ASTECH("PersonnelFilter.ASTECH.text", "PersonnelFilter.ASTECH.toolTipText", false, true), - MEDICAL("PersonnelFilter.MEDICAL.text", "PersonnelFilter.MEDICAL.toolTipText", true, false), - DOCTOR("PersonnelFilter.DOCTOR.text", "PersonnelFilter.DOCTOR.toolTipText", false, true), - MEDIC("PersonnelFilter.MEDIC.text", "PersonnelFilter.MEDIC.toolTipText", false, true), - ADMINISTRATOR("PersonnelFilter.ADMINISTRATOR.text", "PersonnelFilter.ADMINISTRATOR.toolTipText", true, false), - ADMINISTRATOR_COMMAND("PersonnelFilter.ADMINISTRATOR_COMMAND.text", "PersonnelFilter.ADMINISTRATOR_COMMAND.toolTipText", false, true), - ADMINISTRATOR_LOGISTICS("PersonnelFilter.ADMINISTRATOR_LOGISTICS.text", "PersonnelFilter.ADMINISTRATOR_LOGISTICS.toolTipText", false, true), - ADMINISTRATOR_TRANSPORT("PersonnelFilter.ADMINISTRATOR_TRANSPORT.text", "PersonnelFilter.ADMINISTRATOR_TRANSPORT.toolTipText", false, true), - ADMINISTRATOR_HR("PersonnelFilter.ADMINISTRATOR_HR.text", "PersonnelFilter.ADMINISTRATOR_HR.toolTipText", false, true), - DEPENDENT("PersonnelFilter.DEPENDENT.text", "PersonnelFilter.DEPENDENT.toolTipText"), - //endregion Standard Personnel Filters - - //region Expanded Personnel Tab Filters - FOUNDER("PersonnelFilter.FOUNDER.text", "PersonnelFilter.FOUNDER.toolTipText", false, false), - KIDS("PersonnelFilter.KIDS.text", "PersonnelFilter.KIDS.toolTipText"), - PRISONER("PersonnelFilter.PRISONER.text", "PersonnelFilter.PRISONER.toolTipText", false, false), - INACTIVE("PersonnelFilter.INACTIVE.text", "PersonnelFilter.INACTIVE.toolTipText", false, false), - MIA("PersonnelFilter.MIA.text", "PersonnelFilter.MIA.toolTipText", false, false), - RETIRED("PersonnelFilter.RETIRED.text", "PersonnelFilter.RETIRED.toolTipText", false, false), - DESERTED("PersonnelFilter.DESERTED.text", "PersonnelFilter.DESERTED.toolTipText", false, false), - KIA("PersonnelFilter.KIA.text", "PersonnelFilter.KIA.toolTipText", false, false), - DEAD("PersonnelFilter.DEAD.text", "PersonnelFilter.DEAD.toolTipText", false, false); - //endregion Expanded Personnel Tab Filters - //endregion Enum Declarations - - //region Variable Declarations - private final String name; - private final String toolTipText; - private final boolean baseline; - private final boolean standard; - private final boolean individualRole; - //endregion Variable Declarations - - //region Constructors - PersonnelFilter(final String name, final String toolTipText) { - this(name, toolTipText, true, true, true); - } - - PersonnelFilter(final String name, final String toolTipText, final boolean standard, - final boolean individualRole) { - this(name, toolTipText, false, standard, individualRole); - } - - PersonnelFilter(final String name, final String toolTipText, final boolean baseline, - final boolean standard, final boolean individualRole) { - final ResourceBundle resources = ResourceBundle.getBundle("mekhq.resources.GUI", - MekHQ.getMHQOptions().getLocale()); - this.name = resources.getString(name); - this.toolTipText = resources.getString(toolTipText); - this.baseline = baseline; - this.standard = standard; - this.individualRole = individualRole; - } - //endregion Constructors - - //region Getters - public String getToolTipText() { - return toolTipText; - } - - public boolean isBaseline() { - return baseline; - } - - public boolean isStandard() { - return standard; - } - - public boolean isIndividualRole() { - return individualRole; - } - //endregion Getters - - //region Boolean Comparison Methods - public boolean isAll() { - return this == ALL; - } - - public boolean isActive() { - return this == ACTIVE; - } - - public boolean isCombat() { - return this == COMBAT; - } - - public boolean isSupport() { - return this == SUPPORT; - } - - public boolean isMechWarriors() { - return this == MECHWARRIORS; - } - - public boolean isMechWarrior() { - return this == MECHWARRIOR; - } - - public boolean isLAMPilot() { - return this == LAM_PILOT; - } - - public boolean isVehicleCrewmember() { - return this == VEHICLE_CREWMEMBER; - } - - public boolean isGroundVehicleDriver() { - return this == GROUND_VEHICLE_DRIVER; - } - - public boolean isNavalVehicleDriver() { - return this == NAVAL_VEHICLE_DRIVER; - } - - public boolean isVTOLPilot() { - return this == VTOL_PILOT; - } - - public boolean isVehicleGunner() { - return this == VEHICLE_GUNNER; - } - - public boolean isVehicleCrew() { - return this == VEHICLE_CREW; - } - - public boolean isAerospacePilot() { - return this == AEROSPACE_PILOT; - } - - public boolean isConventionalAircraftPilot() { - return this == CONVENTIONAL_AIRCRAFT_PILOT; - } - - public boolean isProtoMechPilot() { - return this == PROTOMECH_PILOT; - } - - public boolean isBattleArmor() { - return this == BATTLE_ARMOUR; - } - - public boolean isSoldier() { - return this == SOLDIER; - } - - public boolean isVesselCrewmember() { - return this == VESSEL_CREWMEMBER; - } - - public boolean isVesselPilot() { - return this == VESSEL_PILOT; - } + //region Enum Declarations + //region Standard Personnel Filters + ALL("PersonnelFilter.ALL.text", "PersonnelFilter.ALL.toolTipText"), + ACTIVE("PersonnelFilter.ACTIVE.text", "PersonnelFilter.ACTIVE.toolTipText"), + COMBAT("PersonnelFilter.COMBAT.text", "PersonnelFilter.COMBAT.toolTipText"), + SUPPORT("PersonnelFilter.SUPPORT.text", "PersonnelFilter.SUPPORT.toolTipText"), + MECHWARRIORS("PersonnelFilter.MECHWARRIORS.text", "PersonnelFilter.MECHWARRIORS.toolTipText", true, false), + MECHWARRIOR("PersonnelFilter.MECHWARRIOR.text", "PersonnelFilter.MECHWARRIOR.toolTipText", false, true), + LAM_PILOT("PersonnelFilter.LAM_PILOT.text", "PersonnelFilter.LAM_PILOT.toolTipText", false, true), + VEHICLE_CREWMEMBER("PersonnelFilter.VEHICLE_CREWMEMBER.text", "PersonnelFilter.VEHICLE_CREWMEMBER.toolTipText", true, false), + GROUND_VEHICLE_DRIVER("PersonnelFilter.GROUND_VEHICLE_DRIVER.text", "PersonnelFilter.GROUND_VEHICLE_DRIVER.toolTipText", false, true), + NAVAL_VEHICLE_DRIVER("PersonnelFilter.NAVAL_VEHICLE_DRIVER.text", "PersonnelFilter.NAVAL_VEHICLE_DRIVER.toolTipText", false, true), + VTOL_PILOT("PersonnelFilter.VTOL_PILOT.text", "PersonnelFilter.VTOL_PILOT.toolTipText", false, true), + VEHICLE_GUNNER("PersonnelFilter.VEHICLE_GUNNER.text", "PersonnelFilter.VEHICLE_GUNNER.toolTipText", false, true), + VEHICLE_CREW("PersonnelFilter.VEHICLE_CREW.text", "PersonnelFilter.VEHICLE_CREW.toolTipText", false, true), + AEROSPACE_PILOT("PersonnelFilter.AEROSPACE_PILOT.text", "PersonnelFilter.AEROSPACE_PILOT.toolTipText"), + CONVENTIONAL_AIRCRAFT_PILOT("PersonnelFilter.CONVENTIONAL_AIRCRAFT_PILOT.text", "PersonnelFilter.CONVENTIONAL_AIRCRAFT_PILOT.toolTipText"), + PROTOMECH_PILOT("PersonnelFilter.PROTOMECH_PILOT.text", "PersonnelFilter.PROTOMECH_PILOT.toolTipText"), + BATTLE_ARMOUR("PersonnelFilter.BATTLE_ARMOUR.text", "PersonnelFilter.BATTLE_ARMOUR.toolTipText"), + SOLDIER("PersonnelFilter.SOLDIER.text", "PersonnelFilter.SOLDIER.toolTipText"), + VESSEL_CREWMEMBER("PersonnelFilter.VESSEL_CREWMEMBER.text", "PersonnelFilter.VESSEL_CREWMEMBER.toolTipText", true, false), + VESSEL_PILOT("PersonnelFilter.VESSEL_PILOT.text", "PersonnelFilter.VESSEL_PILOT.toolTipText", false, true), + VESSEL_GUNNER("PersonnelFilter.VESSEL_GUNNER.text", "PersonnelFilter.VESSEL_GUNNER.toolTipText", false, true), + VESSEL_CREW("PersonnelFilter.VESSEL_CREW.text", "PersonnelFilter.VESSEL_CREW.toolTipText", false, true), + VESSEL_NAVIGATOR("PersonnelFilter.VESSEL_NAVIGATOR.text", "PersonnelFilter.VESSEL_NAVIGATOR.toolTipText", false, true), + TECH("PersonnelFilter.TECH.text", "PersonnelFilter.TECH.toolTipText", true, false), + MECH_TECH("PersonnelFilter.MECH_TECH.text", "PersonnelFilter.MECH_TECH.toolTipText", false, true), + MECHANIC("PersonnelFilter.MECHANIC.text", "PersonnelFilter.MECHANIC.toolTipText", false, true), + AERO_TECH("PersonnelFilter.AERO_TECH.text", "PersonnelFilter.AERO_TECH.toolTipText", false, true), + BA_TECH("PersonnelFilter.BA_TECH.text", "PersonnelFilter.BA_TECH.toolTipText", false, true), + ASTECH("PersonnelFilter.ASTECH.text", "PersonnelFilter.ASTECH.toolTipText", false, true), + MEDICAL("PersonnelFilter.MEDICAL.text", "PersonnelFilter.MEDICAL.toolTipText", true, false), + DOCTOR("PersonnelFilter.DOCTOR.text", "PersonnelFilter.DOCTOR.toolTipText", false, true), + MEDIC("PersonnelFilter.MEDIC.text", "PersonnelFilter.MEDIC.toolTipText", false, true), + ADMINISTRATOR("PersonnelFilter.ADMINISTRATOR.text", "PersonnelFilter.ADMINISTRATOR.toolTipText", true, false), + ADMINISTRATOR_COMMAND("PersonnelFilter.ADMINISTRATOR_COMMAND.text", "PersonnelFilter.ADMINISTRATOR_COMMAND.toolTipText", false, true), + ADMINISTRATOR_LOGISTICS("PersonnelFilter.ADMINISTRATOR_LOGISTICS.text", "PersonnelFilter.ADMINISTRATOR_LOGISTICS.toolTipText", false, true), + ADMINISTRATOR_TRANSPORT("PersonnelFilter.ADMINISTRATOR_TRANSPORT.text", "PersonnelFilter.ADMINISTRATOR_TRANSPORT.toolTipText", false, true), + ADMINISTRATOR_HR("PersonnelFilter.ADMINISTRATOR_HR.text", "PersonnelFilter.ADMINISTRATOR_HR.toolTipText", false, true), + DEPENDENT("PersonnelFilter.DEPENDENT.text", "PersonnelFilter.DEPENDENT.toolTipText"), + //endregion Standard Personnel Filters + + //region Expanded Personnel Tab Filters + FOUNDER("PersonnelFilter.FOUNDER.text", "PersonnelFilter.FOUNDER.toolTipText", false, false), + KIDS("PersonnelFilter.KIDS.text", "PersonnelFilter.KIDS.toolTipText"), + PRISONER("PersonnelFilter.PRISONER.text", "PersonnelFilter.PRISONER.toolTipText", false, false), + INACTIVE("PersonnelFilter.INACTIVE.text", "PersonnelFilter.INACTIVE.toolTipText", false, false), + MIA("PersonnelFilter.MIA.text", "PersonnelFilter.MIA.toolTipText", false, false), + RETIRED("PersonnelFilter.RETIRED.text", "PersonnelFilter.RETIRED.toolTipText", false, false), + DESERTED("PersonnelFilter.DESERTED.text", "PersonnelFilter.DESERTED.toolTipText", false, false), + KIA("PersonnelFilter.KIA.text", "PersonnelFilter.KIA.toolTipText", false, false), + DEAD("PersonnelFilter.DEAD.text", "PersonnelFilter.DEAD.toolTipText", false, false); + //endregion Expanded Personnel Tab Filters + //endregion Enum Declarations + + //region Variable Declarations + private final String name; + private final String toolTipText; + private final boolean baseline; + private final boolean standard; + private final boolean individualRole; + //endregion Variable Declarations + + //region Constructors + PersonnelFilter(final String name, final String toolTipText) { + this(name, toolTipText, true, true, true); + } + + PersonnelFilter(final String name, final String toolTipText, final boolean standard, + final boolean individualRole) { + this(name, toolTipText, false, standard, individualRole); + } + + PersonnelFilter(final String name, final String toolTipText, final boolean baseline, + final boolean standard, final boolean individualRole) { + final ResourceBundle resources = ResourceBundle.getBundle("mekhq.resources.GUI", + MekHQ.getMHQOptions().getLocale()); + this.name = resources.getString(name); + this.toolTipText = resources.getString(toolTipText); + this.baseline = baseline; + this.standard = standard; + this.individualRole = individualRole; + } + //endregion Constructors + + //region Getters + public String getToolTipText() { + return toolTipText; + } + + public boolean isBaseline() { + return baseline; + } + + public boolean isStandard() { + return standard; + } + + public boolean isIndividualRole() { + return individualRole; + } + //endregion Getters + + //region Boolean Comparison Methods + public boolean isAll() { + return this == ALL; + } + + public boolean isActive() { + return this == ACTIVE; + } + + public boolean isCombat() { + return this == COMBAT; + } + + public boolean isSupport() { + return this == SUPPORT; + } + + public boolean isMechWarriors() { + return this == MECHWARRIORS; + } + + public boolean isMechWarrior() { + return this == MECHWARRIOR; + } + + public boolean isLAMPilot() { + return this == LAM_PILOT; + } + + public boolean isVehicleCrewmember() { + return this == VEHICLE_CREWMEMBER; + } + + public boolean isGroundVehicleDriver() { + return this == GROUND_VEHICLE_DRIVER; + } + + public boolean isNavalVehicleDriver() { + return this == NAVAL_VEHICLE_DRIVER; + } + + public boolean isVTOLPilot() { + return this == VTOL_PILOT; + } + + public boolean isVehicleGunner() { + return this == VEHICLE_GUNNER; + } + + public boolean isVehicleCrew() { + return this == VEHICLE_CREW; + } + + public boolean isAerospacePilot() { + return this == AEROSPACE_PILOT; + } + + public boolean isConventionalAircraftPilot() { + return this == CONVENTIONAL_AIRCRAFT_PILOT; + } + + public boolean isProtoMechPilot() { + return this == PROTOMECH_PILOT; + } + + public boolean isBattleArmor() { + return this == BATTLE_ARMOUR; + } + + public boolean isSoldier() { + return this == SOLDIER; + } + + public boolean isVesselCrewmember() { + return this == VESSEL_CREWMEMBER; + } + + public boolean isVesselPilot() { + return this == VESSEL_PILOT; + } + + public boolean isVesselGunner() { + return this == VESSEL_GUNNER; + } + + public boolean isVesselCrew() { + return this == VESSEL_CREW; + } + + public boolean isVesselNavigator() { + return this == VESSEL_NAVIGATOR; + } + + public boolean isTech() { + return this == TECH; + } + + public boolean isMechTech() { + return this == MECH_TECH; + } + + public boolean isMechanic() { + return this == MECHANIC; + } + + public boolean isAeroTech() { + return this == AERO_TECH; + } + + public boolean isBATech() { + return this == BA_TECH; + } + + public boolean isAstech() { + return this == ASTECH; + } + + public boolean isMedical() { + return this == MEDICAL; + } + + public boolean isDoctor() { + return this == DOCTOR; + } + + public boolean isMedic() { + return this == MEDIC; + } + + public boolean isAdministrator() { + return this == ADMINISTRATOR; + } + + public boolean isAdministratorCommand() { + return this == ADMINISTRATOR_COMMAND; + } + + public boolean isAdministratorLogistics() { + return this == ADMINISTRATOR_LOGISTICS; + } + + public boolean isAdministratorTransport() { + return this == ADMINISTRATOR_TRANSPORT; + } + + public boolean isAdministratorHR() { + return this == ADMINISTRATOR_HR; + } + + public boolean isDependent() { + return this == DEPENDENT; + } + + public boolean isFounder() { + return this == FOUNDER; + } + + public boolean isPrisoner() { + return this == PRISONER; + } + + public boolean isInactive() { + return this == INACTIVE; + } + + public boolean isMIA() { + return this == MIA; + } + + public boolean isRetired() { + return this == RETIRED; + } + + public boolean isDeserted() { + return this == DESERTED; + } + + public boolean isKIA() { + return this == KIA; + } + + public boolean isDead() { + return this == DEAD; + } + //endregion Boolean Comparison Methods - public boolean isVesselGunner() { - return this == VESSEL_GUNNER; - } - - public boolean isVesselCrew() { - return this == VESSEL_CREW; - } - - public boolean isVesselNavigator() { - return this == VESSEL_NAVIGATOR; - } - - public boolean isTech() { - return this == TECH; - } - - public boolean isMechTech() { - return this == MECH_TECH; - } - - public boolean isMechanic() { - return this == MECHANIC; - } - - public boolean isAeroTech() { - return this == AERO_TECH; - } - - public boolean isBATech() { - return this == BA_TECH; - } - - public boolean isAstech() { - return this == ASTECH; - } - - public boolean isMedical() { - return this == MEDICAL; - } - - public boolean isDoctor() { - return this == DOCTOR; - } - - public boolean isMedic() { - return this == MEDIC; - } - - public boolean isAdministrator() { - return this == ADMINISTRATOR; - } - - public boolean isAdministratorCommand() { - return this == ADMINISTRATOR_COMMAND; - } - - public boolean isAdministratorLogistics() { - return this == ADMINISTRATOR_LOGISTICS; - } - - public boolean isAdministratorTransport() { - return this == ADMINISTRATOR_TRANSPORT; - } - - public boolean isAdministratorHR() { - return this == ADMINISTRATOR_HR; - } - - public boolean isDependent() { - return this == DEPENDENT; - } - - public boolean isFounder() { - return this == FOUNDER; - } - - public boolean isPrisoner() { - return this == PRISONER; - } - - public boolean isInactive() { - return this == INACTIVE; - } - - public boolean isMIA() { - return this == MIA; - } - - public boolean isRetired() { - return this == RETIRED; - } - - public boolean isDeserted() { - return this == DESERTED; - } - - public boolean isKIA() { - return this == KIA; - } - - public boolean isDead() { - return this == DEAD; - } - //endregion Boolean Comparison Methods - - public static List getStandardPersonnelFilters() { - return Stream.of(values()).filter(filter -> filter.isBaseline() || filter.isStandard()) - .collect(Collectors.toList()); - } - - public static List getExpandedPersonnelFilters() { - return Stream.of(values()).filter(filter -> filter.isBaseline() || !filter.isIndividualRole()) - .collect(Collectors.toList()); - } - - public static List getIndividualRolesStandardPersonnelFilters() { - return Stream.of(values()).filter(filter -> filter.isBaseline() || filter.isIndividualRole()) - .collect(Collectors.toList()); - } - - public static List getIndividualRolesExpandedPersonnelFilters() { - return Stream.of(values()) - .filter(filter -> filter.isBaseline() || !filter.isStandard() || filter.isIndividualRole()) - .collect(Collectors.toList()); - } - - public static List getAllStandardFilters() { - return Stream.of(values()) - .filter(filter -> filter.isBaseline() || filter.isStandard() || filter.isIndividualRole()) - .collect(Collectors.toList()); - } - - public static List getAllIndividualRoleFilters() { - return Arrays.asList(values()); - } - - public boolean getFilteredInformation(final Person person, LocalDate currentDate) { - final boolean active = person.getStatus().isActive() && !person.getPrisonerStatus().isCurrentPrisoner(); - switch (this) { - case ALL: - return true; - case ACTIVE: - return active; - case COMBAT: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isCombat() : person.hasCombatRole()); - case SUPPORT: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? !person.getPrimaryRole().isCombat() : person.hasSupportRole(true)); - case MECHWARRIORS: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isMechWarriorGrouping() - : (person.getPrimaryRole().isMechWarriorGrouping() || person.getSecondaryRole().isMechWarriorGrouping())); - case MECHWARRIOR: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isMechWarrior() : person.hasRole(PersonnelRole.MECHWARRIOR)); - case LAM_PILOT: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isLAMPilot() : person.hasRole(PersonnelRole.LAM_PILOT)); - case VEHICLE_CREWMEMBER: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isVehicleCrewmember() - : (person.getPrimaryRole().isVehicleCrewmember() || person.getSecondaryRole().isVehicleCrewmember())); - case GROUND_VEHICLE_DRIVER: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isGroundVehicleDriver() : person.hasRole(PersonnelRole.GROUND_VEHICLE_DRIVER)); - case NAVAL_VEHICLE_DRIVER: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isNavalVehicleDriver() : person.hasRole(PersonnelRole.NAVAL_VEHICLE_DRIVER)); - case VEHICLE_GUNNER: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isVehicleGunner() : person.hasRole(PersonnelRole.VEHICLE_GUNNER)); - case VEHICLE_CREW: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isVehicleCrew() : person.hasRole(PersonnelRole.VEHICLE_CREW)); - case VTOL_PILOT: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isVTOLPilot() : person.hasRole(PersonnelRole.VTOL_PILOT)); - case AEROSPACE_PILOT: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isAerospacePilot() : person.hasRole(PersonnelRole.AEROSPACE_PILOT)); - case CONVENTIONAL_AIRCRAFT_PILOT: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isConventionalAircraftPilot() : person.hasRole(PersonnelRole.CONVENTIONAL_AIRCRAFT_PILOT)); - case PROTOMECH_PILOT: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isProtoMechPilot() : person.hasRole(PersonnelRole.PROTOMECH_PILOT)); - case BATTLE_ARMOUR: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isBattleArmour() : person.hasRole(PersonnelRole.BATTLE_ARMOUR)); - case SOLDIER: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isSoldier() : person.hasRole(PersonnelRole.SOLDIER)); - case VESSEL_CREWMEMBER: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isVesselCrewmember() - : (person.getPrimaryRole().isVesselCrewmember() || person.getSecondaryRole().isVesselCrewmember())); - case VESSEL_PILOT: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isVesselPilot() : person.hasRole(PersonnelRole.VESSEL_PILOT)); - case VESSEL_CREW: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isVesselCrew() : person.hasRole(PersonnelRole.VESSEL_CREW)); - case VESSEL_GUNNER: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isVesselGunner() : person.hasRole(PersonnelRole.VESSEL_GUNNER)); - case VESSEL_NAVIGATOR: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isVesselNavigator() : person.hasRole(PersonnelRole.VESSEL_NAVIGATOR)); - case TECH: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isTech() : person.isTech()); - case MECH_TECH: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isMechTech() : person.hasRole(PersonnelRole.MECH_TECH)); - case MECHANIC: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isMechanic() : person.hasRole(PersonnelRole.MECHANIC)); - case AERO_TECH: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isAeroTech() : person.hasRole(PersonnelRole.AERO_TECH)); - case BA_TECH: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isBATech() : person.hasRole(PersonnelRole.BA_TECH)); - case ASTECH: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isAstech() : person.hasRole(PersonnelRole.ASTECH)); - case MEDICAL: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isMedicalStaff() - : (person.getPrimaryRole().isMedicalStaff() || person.getSecondaryRole().isMedicalStaff())); - case DOCTOR: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isDoctor() : person.hasRole(PersonnelRole.DOCTOR)); - case MEDIC: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isMedic() : person.hasRole(PersonnelRole.MEDIC)); - case ADMINISTRATOR: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isAdministrator() : person.isAdministrator()); - case ADMINISTRATOR_COMMAND: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isAdministratorCommand() : person.hasRole(PersonnelRole.ADMINISTRATOR_COMMAND)); - case ADMINISTRATOR_LOGISTICS: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isAdministratorLogistics() : person.hasRole(PersonnelRole.ADMINISTRATOR_LOGISTICS)); - case ADMINISTRATOR_TRANSPORT: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isAdministratorTransport() : person.hasRole(PersonnelRole.ADMINISTRATOR_TRANSPORT)); - case ADMINISTRATOR_HR: - return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() - ? person.getPrimaryRole().isAdministratorHR() : person.hasRole(PersonnelRole.ADMINISTRATOR_HR)); - case DEPENDENT: - return active && person.getPrimaryRole().isDependent(); - case FOUNDER: - return person.isFounder(); - case KIDS: - return person.isChild(currentDate); - case PRISONER: - return person.getPrisonerStatus().isCurrentPrisoner() || person.getPrisonerStatus().isBondsman(); - case INACTIVE: - return !person.getStatus().isActive(); - case MIA: - return person.getStatus().isMIA(); - case RETIRED: - return person.getStatus().isRetired(); - case DESERTED: - return person.getStatus().isDeserted(); - case KIA: - return person.getStatus().isKIA(); - case DEAD: - return person.getStatus().isDead(); - default: - return false; - } - } - - @Override - public String toString() { - return name; - } + public static List getStandardPersonnelFilters() { + return Stream.of(values()).filter(filter -> filter.isBaseline() || filter.isStandard()) + .collect(Collectors.toList()); + } + + public static List getExpandedPersonnelFilters() { + return Stream.of(values()).filter(filter -> filter.isBaseline() || !filter.isIndividualRole()) + .collect(Collectors.toList()); + } + + public static List getIndividualRolesStandardPersonnelFilters() { + return Stream.of(values()).filter(filter -> filter.isBaseline() || filter.isIndividualRole()) + .collect(Collectors.toList()); + } + + public static List getIndividualRolesExpandedPersonnelFilters() { + return Stream.of(values()) + .filter(filter -> filter.isBaseline() || !filter.isStandard() || filter.isIndividualRole()) + .collect(Collectors.toList()); + } + + public static List getAllStandardFilters() { + return Stream.of(values()) + .filter(filter -> filter.isBaseline() || filter.isStandard() || filter.isIndividualRole()) + .collect(Collectors.toList()); + } + + public static List getAllIndividualRoleFilters() { + return Arrays.asList(values()); + } + + public boolean getFilteredInformation(final Person person, LocalDate currentDate) { + final boolean active = person.getStatus().isActive() && !person.getPrisonerStatus().isCurrentPrisoner(); + switch (this) { + case ALL: + return true; + case ACTIVE: + return active; + case COMBAT: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isCombat() : person.hasCombatRole()); + case SUPPORT: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? !person.getPrimaryRole().isCombat() : person.hasSupportRole(true)); + case MECHWARRIORS: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isMechWarriorGrouping() + : (person.getPrimaryRole().isMechWarriorGrouping() || person.getSecondaryRole().isMechWarriorGrouping())); + case MECHWARRIOR: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isMechWarrior() : person.hasRole(PersonnelRole.MECHWARRIOR)); + case LAM_PILOT: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isLAMPilot() : person.hasRole(PersonnelRole.LAM_PILOT)); + case VEHICLE_CREWMEMBER: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isVehicleCrewmember() + : (person.getPrimaryRole().isVehicleCrewmember() || person.getSecondaryRole().isVehicleCrewmember())); + case GROUND_VEHICLE_DRIVER: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isGroundVehicleDriver() : person.hasRole(PersonnelRole.GROUND_VEHICLE_DRIVER)); + case NAVAL_VEHICLE_DRIVER: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isNavalVehicleDriver() : person.hasRole(PersonnelRole.NAVAL_VEHICLE_DRIVER)); + case VEHICLE_GUNNER: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isVehicleGunner() : person.hasRole(PersonnelRole.VEHICLE_GUNNER)); + case VEHICLE_CREW: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isVehicleCrew() : person.hasRole(PersonnelRole.VEHICLE_CREW)); + case VTOL_PILOT: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isVTOLPilot() : person.hasRole(PersonnelRole.VTOL_PILOT)); + case AEROSPACE_PILOT: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isAerospacePilot() : person.hasRole(PersonnelRole.AEROSPACE_PILOT)); + case CONVENTIONAL_AIRCRAFT_PILOT: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isConventionalAircraftPilot() : person.hasRole(PersonnelRole.CONVENTIONAL_AIRCRAFT_PILOT)); + case PROTOMECH_PILOT: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isProtoMechPilot() : person.hasRole(PersonnelRole.PROTOMECH_PILOT)); + case BATTLE_ARMOUR: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isBattleArmour() : person.hasRole(PersonnelRole.BATTLE_ARMOUR)); + case SOLDIER: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isSoldier() : person.hasRole(PersonnelRole.SOLDIER)); + case VESSEL_CREWMEMBER: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isVesselCrewmember() + : (person.getPrimaryRole().isVesselCrewmember() || person.getSecondaryRole().isVesselCrewmember())); + case VESSEL_PILOT: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isVesselPilot() : person.hasRole(PersonnelRole.VESSEL_PILOT)); + case VESSEL_CREW: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isVesselCrew() : person.hasRole(PersonnelRole.VESSEL_CREW)); + case VESSEL_GUNNER: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isVesselGunner() : person.hasRole(PersonnelRole.VESSEL_GUNNER)); + case VESSEL_NAVIGATOR: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isVesselNavigator() : person.hasRole(PersonnelRole.VESSEL_NAVIGATOR)); + case TECH: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isTech() : person.isTech()); + case MECH_TECH: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isMechTech() : person.hasRole(PersonnelRole.MECH_TECH)); + case MECHANIC: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isMechanic() : person.hasRole(PersonnelRole.MECHANIC)); + case AERO_TECH: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isAeroTech() : person.hasRole(PersonnelRole.AERO_TECH)); + case BA_TECH: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isBATech() : person.hasRole(PersonnelRole.BA_TECH)); + case ASTECH: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isAstech() : person.hasRole(PersonnelRole.ASTECH)); + case MEDICAL: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isMedicalStaff() + : (person.getPrimaryRole().isMedicalStaff() || person.getSecondaryRole().isMedicalStaff())); + case DOCTOR: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isDoctor() : person.hasRole(PersonnelRole.DOCTOR)); + case MEDIC: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isMedic() : person.hasRole(PersonnelRole.MEDIC)); + case ADMINISTRATOR: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isAdministrator() : person.isAdministrator()); + case ADMINISTRATOR_COMMAND: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isAdministratorCommand() : person.hasRole(PersonnelRole.ADMINISTRATOR_COMMAND)); + case ADMINISTRATOR_LOGISTICS: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isAdministratorLogistics() : person.hasRole(PersonnelRole.ADMINISTRATOR_LOGISTICS)); + case ADMINISTRATOR_TRANSPORT: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isAdministratorTransport() : person.hasRole(PersonnelRole.ADMINISTRATOR_TRANSPORT)); + case ADMINISTRATOR_HR: + return active && (MekHQ.getMHQOptions().getPersonnelFilterOnPrimaryRole() + ? person.getPrimaryRole().isAdministratorHR() : person.hasRole(PersonnelRole.ADMINISTRATOR_HR)); + case DEPENDENT: + return active && person.getPrimaryRole().isDependent(); + case FOUNDER: + return person.isFounder(); + case KIDS: + return person.isChild(currentDate); + case PRISONER: + return person.getPrisonerStatus().isCurrentPrisoner() || person.getPrisonerStatus().isBondsman(); + case INACTIVE: + return !person.getStatus().isActive(); + case MIA: + return person.getStatus().isMIA(); + case RETIRED: + return person.getStatus().isRetired(); + case DESERTED: + return person.getStatus().isDeserted(); + case KIA: + return person.getStatus().isKIA(); + case DEAD: + return person.getStatus().isDead(); + default: + return false; + } + } + + @Override + public String toString() { + return name; + } }