Skip to content

Commit

Permalink
Bug Fix: Tracker add new locations selected is never saved (Issue#488)
Browse files Browse the repository at this point in the history
Merge main
  • Loading branch information
GoldenGnu committed Oct 6, 2024
2 parents 04b7a9f + e7cab5f commit 7c20e9b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ private enum TrackerAction {
//Dialog
private final JTrackerEditDialog jEditDialog;
private final JSelectionDialog<String> jSelectionDialog;
private final TrackerFilterDialog filterDialog;
private final TrackerWalletFilterDialog walletFilterDialog;
private final TrackerAssetFilterDialog assetFilterDialog;
private final TrackerSkillPointsFilterDialog skillPointsFilterDialog;
private final JCustomFileChooser jFileChooser;
Expand All @@ -238,7 +238,7 @@ private enum TrackerAction {
public TrackerTab(Program program) {
super(program, NAME, TabsTracker.get().title(), Images.TOOL_TRACKER.getIcon(), true);

filterDialog = new TrackerFilterDialog(program);
walletFilterDialog = new TrackerWalletFilterDialog(program);
assetFilterDialog = new TrackerAssetFilterDialog(program);
skillPointsFilterDialog = new TrackerSkillPointsFilterDialog(program);
TrackerSettings trackerSettings = Settings.get().getTrackerSettings();
Expand Down Expand Up @@ -1287,7 +1287,7 @@ private void updateSettings() {
for (CheckBoxNode checkBoxNode : accountNodes.values()) {
Settings.get().getTrackerSettings().getFilters().put(checkBoxNode.getNodeID(), checkBoxNode.isSelected());
}
Settings.get().getTrackerSettings().setSelectNew(filterDialog.isSelectNew());
Settings.get().getTrackerSettings().setSelectNew(assetFilterDialog.isSelectNew());
Settings.unlock("Tracker Filters: Update");
program.saveSettings("Tracker Filters: Update");
}
Expand Down Expand Up @@ -1455,6 +1455,11 @@ private void showLocationFilter() {
updateSettings();
createData();
updateButtonIcons();
} else if (assetFilterDialog.isSelectNew() != Settings.get().getTrackerSettings().isSelectNew()) {
Settings.lock("Tracker Filters: Update");
Settings.get().getTrackerSettings().setSelectNew(assetFilterDialog.isSelectNew());
Settings.unlock("Tracker Filters: Update");
program.saveSettings("Tracker Filters: Update");
}
}

Expand Down Expand Up @@ -1636,7 +1641,7 @@ public void actionPerformed(ActionEvent e) {
}
updateData();
} else if (TrackerAction.FILTER_WALLET_BALANCE.name().equals(e.getActionCommand())) {
boolean save = filterDialog.showWallet(accountNodes);
boolean save = walletFilterDialog.showWallet(accountNodes);
if (save) { //Need refilter
updateSettings();
createData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.util.TreeMap;
import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JScrollPane;
import javax.swing.JTree;
Expand All @@ -38,7 +37,6 @@
import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;
import net.nikr.eve.jeveasset.Program;
import net.nikr.eve.jeveasset.data.settings.Settings;
import net.nikr.eve.jeveasset.gui.images.Images;
import net.nikr.eve.jeveasset.gui.shared.components.CheckBoxNode;
import net.nikr.eve.jeveasset.gui.shared.components.CheckBoxNodeEditor;
Expand All @@ -48,16 +46,15 @@
import net.nikr.eve.jeveasset.i18n.TabsTracker;


public class TrackerFilterDialog extends JDialogCentered {
public class TrackerWalletFilterDialog extends JDialogCentered {

private final JTree jTree;
private final JCheckBox jNewSelected;
private final DefaultMutableTreeNode rootNode;
private final DefaultTreeModel treeModel;

private boolean save = false;

public TrackerFilterDialog(Program program) {
public TrackerWalletFilterDialog(Program program) {
super(program, TabsTracker.get().filterTitle(), Images.TOOL_TRACKER.getImage());

rootNode = new DefaultMutableTreeNode(DialoguesSettings.get().root());
Expand All @@ -74,9 +71,6 @@ public TrackerFilterDialog(Program program) {
jTree.setCellEditor(new CheckBoxNodeEditor(jTree));
jTree.setEditable(true);

jNewSelected = new JCheckBox(TabsTracker.get().newSelected());
jNewSelected.setSelected(Settings.get().getTrackerSettings().isSelectNew());

JButton jOK = new JButton(TabsTracker.get().ok());
jOK.addActionListener(new ActionListener() {
@Override
Expand All @@ -100,7 +94,6 @@ public void actionPerformed(ActionEvent e) {
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(jTreeScroll, 0, GroupLayout.PREFERRED_SIZE, 600)
.addGroup(layout.createSequentialGroup()
.addComponent(jNewSelected)
.addGap(0, 0, Integer.MAX_VALUE)
.addComponent(jOK, Program.getButtonsWidth(), Program.getButtonsWidth(), Program.getButtonsWidth())
.addComponent(jCancel, Program.getButtonsWidth(), Program.getButtonsWidth(), Program.getButtonsWidth())
Expand All @@ -110,7 +103,6 @@ public void actionPerformed(ActionEvent e) {
layout.createSequentialGroup()
.addComponent(jTreeScroll, 0, GroupLayout.PREFERRED_SIZE, 500)
.addGroup(layout.createParallelGroup()
.addComponent(jNewSelected)
.addComponent(jOK, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
.addComponent(jCancel, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
)
Expand Down Expand Up @@ -160,25 +152,12 @@ protected void windowShown() { }
@Override
protected void save() { }

public boolean isSelectNew() {
return jNewSelected.isSelected();
}

public boolean showLocations(Map<String, CheckBoxNode> nodes) {
return show(nodes, true);
}

public boolean showWallet(Map<String, CheckBoxNode> nodes) {
return show(nodes, false);
}

private boolean show(Map<String, CheckBoxNode> nodes, boolean selected) {
save = false;
rootNode.removeAllChildren();
treeModel.reload();
jTree.setVisibleRowCount(0);
jNewSelected.setVisible(selected);


Map<String, CheckBoxNode> cloneList = cloneList(nodes);

Map<String, DefaultMutableTreeNode> cache = new HashMap<>();
Expand Down

0 comments on commit 7c20e9b

Please sign in to comment.