diff --git a/src/main/java/se/lantz/db/DbConnector.java b/src/main/java/se/lantz/db/DbConnector.java index 3f8f1c6..dca97ff 100644 --- a/src/main/java/se/lantz/db/DbConnector.java +++ b/src/main/java/se/lantz/db/DbConnector.java @@ -239,10 +239,10 @@ public class DbConnector Integer.toString(rs.getInt("rowid")), rs.getInt("Favorite"), viewTag != null && viewTag.contains("GIS:")); - //Filter out all info slots that are not supposed to be shown in "all games" - if (data.isInfoSlot() && view.getGameViewId() == -1 && !viewTag.equalsIgnoreCase("GIS:-1")) + + if (data.isInfoSlot() && !viewTag.equalsIgnoreCase("GIS:" + view.getGameViewId())) { - //Ignore all info slots not created for "all games" + //Ignore all info slots not created for this specific view } else { @@ -446,6 +446,8 @@ public class DbConnector } insertViewFilterstmnt.executeUpdate(); } + //Make sure SQL statement is updated correctly for new views + view.setViewFilters(view.getViewFilters()); } catch (SQLException e) { @@ -1094,13 +1096,17 @@ public class DbConnector { String viewFilterSql = "DELETE FROM viewfilter WHERE gameview = " + view.getGameViewId(); String gameViewSql = "DELETE FROM gameview WHERE viewId = " + view.getGameViewId(); + String infoSlotSql = "DELETE FROM gameinfo WHERE viewTag LIKE 'GIS:" + view.getGameViewId() + "'"; try (Connection conn = this.connect(); PreparedStatement viewFilterstmt = conn.prepareStatement(viewFilterSql); - PreparedStatement gameViewStmt = conn.prepareStatement(gameViewSql)) + PreparedStatement gameViewStmt = conn.prepareStatement(gameViewSql); + PreparedStatement infoSlotStmt = conn.prepareStatement(infoSlotSql)) { int value = viewFilterstmt.executeUpdate(); - logger.debug("Executed successfully, value = {}", value); + logger.debug("{} Executed successfully, value = {}", viewFilterSql, value); value = gameViewStmt.executeUpdate(); - logger.debug("Executed successfully, value = {}", value); + logger.debug("{} Executed successfully, value = {}", gameViewSql, value); + value = infoSlotStmt.executeUpdate(); + logger.debug("{} Executed successfully, value = {}", infoSlotSql, value); } catch (SQLException e) { diff --git a/src/main/java/se/lantz/gui/gameview/GameViewManager.java b/src/main/java/se/lantz/gui/gameview/GameViewManager.java index e39691a..e492199 100644 --- a/src/main/java/se/lantz/gui/gameview/GameViewManager.java +++ b/src/main/java/se/lantz/gui/gameview/GameViewManager.java @@ -2,10 +2,8 @@ package se.lantz.gui.gameview; import javax.swing.JComboBox; import javax.swing.JOptionPane; -import javax.swing.SwingUtilities; import se.lantz.gui.ListPanel; -import se.lantz.gui.MainPanel; import se.lantz.gui.MainWindow; import se.lantz.model.MainViewModel; import se.lantz.model.data.GameView; @@ -15,7 +13,7 @@ public class GameViewManager private JComboBox viewCombobox; private final MainViewModel uiModel; private ListPanel mainPanel; - + public GameViewManager(ListPanel mainPanel, MainViewModel uiModel) { this.mainPanel = mainPanel; @@ -59,11 +57,12 @@ public class GameViewManager } } } - + public void deleteView(GameView view) { String message = "Do you want to delete the gamelist view \"" + view.getName() + "\"?"; - int value = JOptionPane.showConfirmDialog(MainWindow.getInstance().getMainPanel(), message, "Delete gamelist view", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); + int value = JOptionPane.showConfirmDialog(MainWindow.getInstance() + .getMainPanel(), message, "Delete gamelist view", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (value == JOptionPane.YES_OPTION) { uiModel.deleteGameView(view);