Skip to content

Commit

Permalink
misc updates, comments
Browse files Browse the repository at this point in the history
  • Loading branch information
SJuliez committed Oct 22, 2024
1 parent da365f1 commit 0877241
Show file tree
Hide file tree
Showing 15 changed files with 83 additions and 133 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 - The MegaMek Team. All Rights Reserved.
* Copyright (c) 2022, 2024 - The MegaMek Team. All Rights Reserved.
*
* This file is part of MegaMek.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@
import java.awt.*;

/**
* This is a (new) dialog for advanced unit filtering, mostly for the unit selector. It contains the old
* TW advanced search in one tab and the new AlphaStrike search in another tab. Both searches can be used
* simultaneously.
* This is the dialog for advanced unit filtering, mostly for the unit selector. It contains the TW advanced search in one tab and the
* AlphaStrike search in another tab. Both searches can be used simultaneously.
*/
public class AdvancedSearchDialog2 extends AbstractButtonDialog {

final int year;
private final int year;
private final TWAdvancedSearchPanel totalWarTab;
private final ASAdvancedSearchPanel alphaStrikeTab = new ASAdvancedSearchPanel();
private final JTabbedPane advancedSearchPane = new JTabbedPane();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@ public class AndFilterToken extends OperatorFT {
public AndFilterToken() {
super(MekSearchFilter.BoolOp.AND);
}

@Override
public String toString() {
return "and";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* You should have received a copy of the GNU General Public License
* along with MegaMek. If not, see <http://www.gnu.org/licenses/>.
*/

package megamek.client.ui.advancedsearch;

import javax.swing.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class EquipmentTableModel extends AbstractTableModel {

private final TWAdvancedSearchPanel twAdvancedSearchPanel;
private int[] qty;
private List<EquipmentType> equipment = new ArrayList<>();
private final List<EquipmentType> equipment = new ArrayList<>();

public EquipmentTableModel(TWAdvancedSearchPanel twAdvancedSearchPanel) {
this.twAdvancedSearchPanel = twAdvancedSearchPanel;
Expand Down Expand Up @@ -91,7 +91,8 @@ public boolean isCellEditable(int row, int col) {
}

public void setData(List<EquipmentType> eq) {
equipment = eq;
equipment.clear();
equipment.addAll(eq);
qty = new int[eq.size()];
Arrays.fill(qty, 1);
fireTableDataChanged();
Expand Down
18 changes: 18 additions & 0 deletions megamek/src/megamek/client/ui/advancedsearch/EquipmentTypeFT.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
* Copyright (c) 2024 - The MegaMek Team. All Rights Reserved.
*
* This file is part of MegaMek.
*
* MegaMek is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MegaMek is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MegaMek. If not, see <http://www.gnu.org/licenses/>.
*/
package megamek.client.ui.advancedsearch;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
* Copyright (c) 2024 - The MegaMek Team. All Rights Reserved.
*
Expand All @@ -22,19 +21,16 @@
import javax.swing.*;

class NoSelectionModel extends DefaultListSelectionModel {

@Override
public void setAnchorSelectionIndex(final int anchorIndex) {
}
public void setAnchorSelectionIndex(final int anchorIndex) { }

@Override
public void setLeadAnchorNotificationEnabled(final boolean flag) {
}
public void setLeadAnchorNotificationEnabled(final boolean flag) { }

@Override
public void setLeadSelectionIndex(final int leadIndex) {
}
public void setLeadSelectionIndex(final int leadIndex) { }

@Override
public void setSelectionInterval(final int index0, final int index1) {
}
public void setSelectionInterval(final int index0, final int index1) { }
}
27 changes: 18 additions & 9 deletions megamek/src/megamek/client/ui/advancedsearch/OperatorFT.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
* Copyright (c) 2024 - The MegaMek Team. All Rights Reserved.
*
* This file is part of MegaMek.
*
* MegaMek is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MegaMek is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MegaMek. If not, see <http://www.gnu.org/licenses/>.
*/
package megamek.client.ui.advancedsearch;

import megamek.common.MekSearchFilter;
Expand All @@ -14,13 +32,4 @@ public abstract class OperatorFT implements FilterToken {
protected OperatorFT(MekSearchFilter.BoolOp o) {
op = o;
}

@Override
public String toString() {
return switch (op) {
case AND -> "and";
case OR -> "or";
default -> "";
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@ public class OrFilterToken extends OperatorFT {
public OrFilterToken() {
super(MekSearchFilter.BoolOp.OR);
}

@Override
public String toString() {
return "or";
}
}
19 changes: 19 additions & 0 deletions megamek/src/megamek/client/ui/advancedsearch/ParensFT.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
* Copyright (c) 2024 - The MegaMek Team. All Rights Reserved.
*
* This file is part of MegaMek.
*
* MegaMek is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MegaMek is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MegaMek. If not, see <http://www.gnu.org/licenses/>.
*/
package megamek.client.ui.advancedsearch;

/**
Expand All @@ -6,6 +24,7 @@
* @author Arlith
*/
public abstract class ParensFT implements FilterToken {

public String parens;

public ParensFT(String p) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

class QuirksSearchTab extends JPanel {

// Quirks
JButton btnQuirksClear = new JButton(Messages.getString("MekSelectorDialog.ClearTab"));
JLabel lblQuirkInclude = new JLabel("\u2611");
JComboBox<String> cQuirkInclue = new JComboBox<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
*/
package megamek.client.ui.advancedsearch;

/**
* Represents a filter token for a weapon class.
*/
public class WeaponClassFT extends EquipmentFilterToken {

public WeaponClass weaponClass;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import javax.swing.border.EmptyBorder;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableColumn;
import javax.swing.table.TableRowSorter;
import java.awt.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ public class WeaponsTableModel extends AbstractTableModel {

private final TWAdvancedSearchPanel twAdvancedSearchPanel;
private int[] qty;

private List<WeaponType> weapons = new ArrayList<>();
private final List<WeaponType> weapons = new ArrayList<>();

public WeaponsTableModel(TWAdvancedSearchPanel twAdvancedSearchPanel) {
this.twAdvancedSearchPanel = twAdvancedSearchPanel;
Expand Down Expand Up @@ -100,7 +99,8 @@ public boolean isCellEditable(int row, int col) {
}

public void setData(List<WeaponType> wps) {
weapons = wps;
weapons.clear();
weapons.addAll(wps);
qty = new int[wps.size()];
Arrays.fill(qty, 1);
fireTableDataChanged();
Expand Down

0 comments on commit 0877241

Please sign in to comment.