fix: Trying to save a game view without any filters shows an error message instead of an exception.
This commit is contained in:
parent
b1edc907ea
commit
ff05c9c251
|
@ -72,22 +72,40 @@ public class GameViewManager
|
|||
|
||||
private boolean okToSave(GameView gameView)
|
||||
{
|
||||
String title = "Invalid name";
|
||||
String title = "No filters";
|
||||
if (gameView.getViewFilters().isEmpty())
|
||||
{
|
||||
JOptionPane.showMessageDialog(MainWindow.getInstance(),
|
||||
"The gamelist view have no filters defined, add a filter and try again.",
|
||||
title,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
return false;
|
||||
}
|
||||
|
||||
title = "Invalid name";
|
||||
//Check name towards all other available gameviews, no duplicates. Also minimum two characters
|
||||
if (gameView.getName().length() < 2)
|
||||
{
|
||||
JOptionPane.showMessageDialog(MainWindow.getInstance(), "The gamelist view name is too short, give it a different name.", title, JOptionPane.ERROR_MESSAGE);
|
||||
JOptionPane.showMessageDialog(MainWindow.getInstance(),
|
||||
"The gamelist view name is too short, give it a different name.",
|
||||
title,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < uiModel.getGameViewModel().getSize(); i++)
|
||||
{
|
||||
GameView currentView = uiModel.getGameViewModel().getElementAt(i);
|
||||
if (currentView.getGameViewId() != gameView.getGameViewId() && currentView.getName().equalsIgnoreCase(gameView.getName()))
|
||||
if (currentView.getGameViewId() != gameView.getGameViewId() &&
|
||||
currentView.getName().equalsIgnoreCase(gameView.getName()))
|
||||
{
|
||||
JOptionPane.showMessageDialog(MainWindow.getInstance(), "A gamelist view with the same name aleady exists, give it a different name.", title, JOptionPane.ERROR_MESSAGE);
|
||||
JOptionPane.showMessageDialog(MainWindow.getInstance(),
|
||||
"A gamelist view with the same name aleady exists, give it a different name.",
|
||||
title,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue