fix: adding a new game works again

The search text field is disabled when unsaved data is available for the currently selected game.
This commit is contained in:
lantzelot-swe 2023-09-08 23:16:07 +02:00
parent 5651e86a2c
commit 96ce48d4c8
1 changed files with 34 additions and 21 deletions

View File

@ -61,6 +61,8 @@ public class ListPanel extends JPanel
private boolean delayDetailsUpdate = false;
private boolean pageButtonPressed = false;
private boolean filterEnabled = true;
private boolean isFiltering = false;
private ListDataListener listDataListener = new ListDataListener()
{
@ -105,6 +107,8 @@ public class ListPanel extends JPanel
}
private void filter()
{
if (filterEnabled)
{
isFiltering = true;
GameListModel listModel = uiModel.getGameListModel();
@ -132,6 +136,7 @@ public class ListPanel extends JPanel
updateViewInfoLabel();
isFiltering = false;
}
}
};
public ListPanel(final MainPanel mainPanel, final MainViewModel uiModel)
@ -621,10 +626,17 @@ public class ListPanel extends JPanel
{
getListViewComboBox().setEnabled(!uiModel.isDataChanged());
getListViewEditButton().setEnabled(!uiModel.isDataChanged());
if (!getFilterTextField().hasFocus())
{
getFilterTextField().setEnabled(!uiModel.isDataChanged());
}
filterEnabled = !uiModel.isDataChanged();
}
public void addNewGame()
{
getFilterTextField().setText("");
filterEnabled = false;
//Add new entry and select in the list
uiModel.addNewGameListData();
int rowToSelect = getList().getModel().getSize() - 1;
@ -632,6 +644,7 @@ public class ListPanel extends JPanel
getList().ensureIndexIsVisible(rowToSelect);
mainPanel.getGameDetailsBackgroundPanel().updateSelectedGame(list.getSelectedValue());
mainPanel.getGameDetailsBackgroundPanel().focusTitleField();
getFilterTextField().setEnabled(false);
}
public void addNewInfoSlot()