diff --git a/pom.xml b/pom.xml index c129d9e..2156eeb 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.fi0x.edct EliteDangerousCarrierTrader - 1.6.9.9 + 1.7.10.9 UTF-8 diff --git a/setup.iss b/setup.iss index 131791c..dca0262 100644 --- a/setup.iss +++ b/setup.iss @@ -3,7 +3,7 @@ ; TODO: Update Version info #define MyAppName "Elite Dangerous Carrier Trader" -#define MyAppVersion "1.6.9.9" +#define MyAppVersion "1.7.10.9" #define MyAppPublisher "Fi0x" #define MyAppURL "https://github.com/Fi0x/EDCT" #define MyAppExeName "EDCT.exe" diff --git a/src/main/java/com/fi0x/edct/Main.java b/src/main/java/com/fi0x/edct/Main.java index 11bf227..91e42a7 100644 --- a/src/main/java/com/fi0x/edct/Main.java +++ b/src/main/java/com/fi0x/edct/Main.java @@ -37,7 +37,7 @@ public class Main public static File reddit; public static File discord; //TODO: Update version information - public static final String version = "1.6.9.9";//All.GUI.Logic.Hotfix + public static final String version = "1.7.10.9";//All.GUI.Logic.Hotfix public static final VersionType versionType = VersionType.INSTALLER; public static void main(String[] args) diff --git a/src/main/java/com/fi0x/edct/gui/controller/Settings.java b/src/main/java/com/fi0x/edct/gui/controller/Settings.java index b7d036c..de91738 100644 --- a/src/main/java/com/fi0x/edct/gui/controller/Settings.java +++ b/src/main/java/com/fi0x/edct/gui/controller/Settings.java @@ -10,10 +10,7 @@ import com.fi0x.edct.logic.threads.Updater; import javafx.fxml.FXML; import javafx.fxml.Initializable; -import javafx.scene.control.Button; -import javafx.scene.control.ChoiceBox; -import javafx.scene.control.TextField; -import javafx.scene.control.Tooltip; +import javafx.scene.control.*; import javafx.scene.layout.VBox; import org.apache.commons.io.FileUtils; @@ -181,7 +178,23 @@ private void clearLogs() private void clearDB() { MixpanelHandler.addMessage(MixpanelHandler.EVENT.BUTTON_CLICKED, MixpanelHandler.getButtonProperty("clear-DB")); + + int stationEntries = DBHandler.countStationEntries(); + int tradeEntries = DBHandler.countTradeEntries(); + + String alertText = "Are you sure you want to clear the database?"; + if(stationEntries > 0) alertText += " It contains " + stationEntries + " stations"; + else if(tradeEntries > 0) alertText += " It contains " + tradeEntries + " trades"; + if(stationEntries > 0 && tradeEntries > 0) alertText += " and " + tradeEntries + " trades"; + + Alert alert = new Alert(Alert.AlertType.WARNING, alertText, ButtonType.YES, ButtonType.CANCEL); + alert.showAndWait(); + + if(alert.getResult() == ButtonType.CANCEL) + return; + DBHandler.removeTradeData(); + DBHandler.removeStationDATA(); if(Main.eddn != null) Main.eddn.interrupt(); if(Main.updater != null) Main.updater.interrupt(); @@ -192,16 +205,19 @@ private void clearDB() @FXML private void openBlacklist() { + MixpanelHandler.addMessage(MixpanelHandler.EVENT.BUTTON_CLICKED, MixpanelHandler.getButtonProperty("open-blacklist")); ExternalProgram.openNotepad(Main.blacklist); } @FXML private void openRedditConfig() { + MixpanelHandler.addMessage(MixpanelHandler.EVENT.BUTTON_CLICKED, MixpanelHandler.getButtonProperty("open-reddit-config")); ExternalProgram.openNotepad(Main.reddit); } @FXML private void openDiscordConfig() { + MixpanelHandler.addMessage(MixpanelHandler.EVENT.BUTTON_CLICKED, MixpanelHandler.getButtonProperty("open-discord-config")); ExternalProgram.openNotepad(Main.discord); } diff --git a/src/main/java/com/fi0x/edct/gui/controller/Station.java b/src/main/java/com/fi0x/edct/gui/controller/Station.java index a2e16aa..bd2ed69 100644 --- a/src/main/java/com/fi0x/edct/gui/controller/Station.java +++ b/src/main/java/com/fi0x/edct/gui/controller/Station.java @@ -1,6 +1,7 @@ package com.fi0x.edct.gui.controller; import com.fi0x.edct.logging.Logger; +import com.fi0x.edct.logging.MixpanelHandler; import com.fi0x.edct.logic.database.DBHandler; import com.fi0x.edct.logic.filesystem.BlacklistHandler; import com.fi0x.edct.logic.helper.ConvertToString; @@ -76,6 +77,8 @@ public void initialize(URL url, ResourceBundle resourceBundle) btnReddit.addEventHandler(MouseEvent.MOUSE_CLICKED, e -> { + MixpanelHandler.addMessage(MixpanelHandler.EVENT.BUTTON_CLICKED, MixpanelHandler.getButtonProperty("copy-reddit-string")); + TRADE station = isBuying ? resultsController.getCurrentBuyStation() : resultsController.getCurrentSellStation(); String text; if(e.getButton() == MouseButton.SECONDARY) text = ConvertToString.redditContent(resultsController, station, isBuying); @@ -91,6 +94,8 @@ public void initialize(URL url, ResourceBundle resourceBundle) }); btnDiscord.addEventHandler(MouseEvent.MOUSE_CLICKED, e -> { + MixpanelHandler.addMessage(MixpanelHandler.EVENT.BUTTON_CLICKED, MixpanelHandler.getButtonProperty("copy-discord-string")); + TRADE station = isBuying ? resultsController.getCurrentBuyStation() : resultsController.getCurrentSellStation(); String text = ConvertToString.discordText(resultsController, station, isBuying); @@ -136,6 +141,8 @@ private void previousStation() @FXML private void reloadStation() { + MixpanelHandler.addMessage(MixpanelHandler.EVENT.BUTTON_CLICKED, MixpanelHandler.getButtonProperty("reload-station-data")); + TRADE currentTrade = isBuying ? resultsController.getCurrentBuyStation() : resultsController.getCurrentSellStation(); InaraStation.updateSingleStationTrades(stationName, stationSystem, currentTrade); resultsController.displayResults(); @@ -143,6 +150,8 @@ private void reloadStation() @FXML private void addToBlacklist() { + MixpanelHandler.addMessage(MixpanelHandler.EVENT.BUTTON_CLICKED, MixpanelHandler.getButtonProperty("add-station-to-blacklist")); + TRADE s = isBuying ? resultsController.getCurrentBuyStation() : resultsController.getCurrentSellStation(); BlacklistHandler.addSystemToBlacklist(s.STATION.SYSTEM); resultsController.mainController.updateFilters(); @@ -150,6 +159,8 @@ private void addToBlacklist() @FXML private void removeStation() { + MixpanelHandler.addMessage(MixpanelHandler.EVENT.BUTTON_CLICKED, MixpanelHandler.getButtonProperty("remove-station-temporary")); + TRADE s = isBuying ? resultsController.getCurrentBuyStation() : resultsController.getCurrentSellStation(); int commodityID = DBHandler.getCommodityIDByName(resultsController.getCurrentTrade().NAME); DBHandler.removeStationEntry(commodityID, s.STATION.NAME, s.STATION.SYSTEM, !isBuying); diff --git a/src/main/java/com/fi0x/edct/logic/database/DBHandler.java b/src/main/java/com/fi0x/edct/logic/database/DBHandler.java index bc5fd99..33f9fe0 100644 --- a/src/main/java/com/fi0x/edct/logic/database/DBHandler.java +++ b/src/main/java/com/fi0x/edct/logic/database/DBHandler.java @@ -423,10 +423,47 @@ public static void removeOldEntries() "WHERE Age < " + validTime); } + public static int countStationEntries() + { + ResultSet results = getQueryResults("SELECT COUNT(StarDistance) " + + "FROM Stations"); + + try + { + if(results != null && results.next()) + return results.getInt(1); + } catch(SQLException e) + { + Logger.WARNING("Could not count the rows of the Stations table", e); + } + + return -1; + } + public static int countTradeEntries() + { + ResultSet results = getQueryResults("SELECT COUNT(InaraID) " + + "FROM Trades"); + + try + { + if(results != null && results.next()) + return results.getInt(1); + } catch(SQLException e) + { + Logger.WARNING("Could not count the rows of the Trades table", e); + } + + return -1; + } + public static void removeTradeData() { sendStatement("DELETE FROM Trades"); } + public static void removeStationDATA() + { + sendStatement("DELETE FROM Stations"); + } private static synchronized void sendStatement(String command) {