From ce1bc2ec3c469bf34f53d37eeab019c5020011e3 Mon Sep 17 00:00:00 2001 From: iMoHax Date: Fri, 11 Mar 2016 13:02:01 +0300 Subject: [PATCH] change version of ControlsFX to 8.40.10 --- client/src/main/java/ru/trader/Main.java | 10 +-- .../controllers/ItemDescController.java | 4 +- .../ru/trader/controllers/MainController.java | 72 +++++++++---------- .../trader/controllers/OffersController.java | 7 +- .../java/ru/trader/controllers/Screeners.java | 48 ++++++++++--- pom.xml | 2 +- 6 files changed, 84 insertions(+), 59 deletions(-) diff --git a/client/src/main/java/ru/trader/Main.java b/client/src/main/java/ru/trader/Main.java index 04c49f0..96ff8e1 100644 --- a/client/src/main/java/ru/trader/Main.java +++ b/client/src/main/java/ru/trader/Main.java @@ -2,12 +2,11 @@ package ru.trader; import javafx.application.Application; import javafx.scene.Scene; +import javafx.scene.control.ButtonType; import javafx.scene.input.Clipboard; import javafx.scene.input.ClipboardContent; import javafx.stage.Stage; import org.apache.log4j.PropertyConfigurator; -import org.controlsfx.control.action.Action; -import org.controlsfx.dialog.Dialog; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import ru.trader.controllers.MainController; @@ -22,6 +21,7 @@ import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; import java.net.URL; import java.util.Locale; +import java.util.Optional; public class Main extends Application { private final static Logger LOG = LoggerFactory.getLogger(Main.class); @@ -89,9 +89,9 @@ public class Main extends Application { primaryStage.setOnCloseRequest((we) -> { try { if (World.getMarket().isChange()) { - Action res = Screeners.showConfirm(Localization.getString("dialog.confirm.save")); - if (res == Dialog.ACTION_YES) World.save(); - else if (res == Dialog.ACTION_CANCEL) { + Optional res = Screeners.showConfirm(Localization.getString("dialog.confirm.save")); + if (res.isPresent() && res.get() == ButtonType.YES) World.save(); + else if (!res.isPresent() || res.get() == ButtonType.CANCEL) { we.consume(); return; } diff --git a/client/src/main/java/ru/trader/controllers/ItemDescController.java b/client/src/main/java/ru/trader/controllers/ItemDescController.java index fc274c2..f211891 100644 --- a/client/src/main/java/ru/trader/controllers/ItemDescController.java +++ b/client/src/main/java/ru/trader/controllers/ItemDescController.java @@ -25,7 +25,7 @@ public class ItemDescController { public void setItemDesc(ItemModel itemDesc){ item = itemDesc; - if (popup!=null) popup.setDetachedTitle(item.nameProperty().get()); + if (popup!=null) popup.setTitle(item.nameProperty().get()); fill(); } @@ -40,7 +40,7 @@ public class ItemDescController { if (popup != null && popup.isShowing()) return; if (popup == null) { popup = new PopOver(itemDescScreen); - popup.setDetachedTitle(item.nameProperty().get()); + popup.setTitle(item.nameProperty().get()); popup.setAutoHide(true); } diff --git a/client/src/main/java/ru/trader/controllers/MainController.java b/client/src/main/java/ru/trader/controllers/MainController.java index f0cee70..06b9e8d 100644 --- a/client/src/main/java/ru/trader/controllers/MainController.java +++ b/client/src/main/java/ru/trader/controllers/MainController.java @@ -1,13 +1,10 @@ package ru.trader.controllers; -import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.control.*; import javafx.scene.layout.BorderPane; import javafx.stage.FileChooser; -import org.controlsfx.control.action.Action; -import org.controlsfx.dialog.Dialog; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.xml.sax.SAXException; @@ -116,7 +113,7 @@ public class MainController { profController.initEDCEBtn(); } - public void save(ActionEvent actionEvent) { + public void save() { try { World.save(); } catch (FileNotFoundException | UnsupportedEncodingException | XMLStreamException e) { @@ -124,7 +121,7 @@ public class MainController { } } - public void importWorld(ActionEvent actionEvent) { + public void importWorld() { try { FileChooser fileChooser = new FileChooser(); FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("XML bd files (*.xml)", "*.xml"); @@ -140,7 +137,7 @@ public class MainController { } } - public void exportWorld(ActionEvent actionEvent) { + public void exportWorld() { try { FileChooser fileChooser = new FileChooser(); FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("XML bd files (*.xml)", "*.xml"); @@ -156,49 +153,49 @@ public class MainController { } } - public void clear(ActionEvent actionEvent){ - Action res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), Localization.getString("market.all"))); - if (res == Dialog.ACTION_YES) { + public void clear(){ + Optional res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), Localization.getString("market.all"))); + if (res.isPresent() && res.get() == ButtonType.OK) { market.clear(); reload(); } } - public void clearOffers(ActionEvent actionEvent){ - Action res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), Localization.getString("market.offers"))); - if (res == Dialog.ACTION_YES) { + public void clearOffers(){ + Optional res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), Localization.getString("market.offers"))); + if (res.isPresent() && res.get() == ButtonType.YES) { market.clearOffers(); reload(); } } - public void clearStations(ActionEvent actionEvent){ - Action res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), Localization.getString("market.stations"))); - if (res == Dialog.ACTION_YES) { + public void clearStations(){ + Optional res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), Localization.getString("market.stations"))); + if (res.isPresent() && res.get() == ButtonType.YES) { market.clearStations(); reload(); } } - public void clearSystems(ActionEvent actionEvent){ - Action res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), Localization.getString("market.systems"))); - if (res == Dialog.ACTION_YES) { + public void clearSystems(){ + Optional res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), Localization.getString("market.systems"))); + if (res.isPresent() && res.get() == ButtonType.YES) { market.clearSystems(); reload(); } } - public void clearItems(ActionEvent actionEvent){ - Action res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), Localization.getString("market.items"))); - if (res == Dialog.ACTION_YES) { + public void clearItems(){ + Optional res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), Localization.getString("market.items"))); + if (res.isPresent() && res.get() == ButtonType.YES) { market.clearItems(); reload(); } } - public void clearGroups(ActionEvent actionEvent){ - Action res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), Localization.getString("market.groups"))); - if (res == Dialog.ACTION_YES) { + public void clearGroups(){ + Optional res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), Localization.getString("market.groups"))); + if (res.isPresent() && res.get() == ButtonType.YES) { market.clearGroups(); reload(); } @@ -212,47 +209,46 @@ public class MainController { return Screeners.showAddItem(market); } - - public void addSystem(ActionEvent actionEvent){ + public void addSystem(){ Screeners.showSystemsEditor(null); } - public void editSystem(ActionEvent actionEvent){ + public void editSystem(){ SystemModel system = profile.getSystem(); if (!ModelFabric.isFake(system)) { Screeners.showSystemsEditor(system); } } - public void removeSystem(ActionEvent actionEvent){ + public void removeSystem(){ SystemModel system = profile.getSystem(); if (!ModelFabric.isFake(system)) { - Action res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), system.getName())); - if (res == Dialog.ACTION_YES) { + Optional res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), system.getName())); + if (res.isPresent() && res.get() == ButtonType.YES) { market.remove(system); } } } - public void addStation(ActionEvent actionEvent) { + public void addStation() { SystemModel system = profile.getSystem(); if (!ModelFabric.isFake(system)) { Screeners.showAddStation(profile.getSystem()); } } - public void editStation(ActionEvent actionEvent) { + public void editStation() { StationModel station = profile.getStation(); if (!ModelFabric.isFake(station)) { Screeners.showEditStation(station); } } - public void removeStation(ActionEvent actionEvent){ + public void removeStation(){ StationModel station = profile.getStation(); if (!ModelFabric.isFake(station)) { - Action res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), station.getName())); - if (res == Dialog.ACTION_YES) { + Optional res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), station.getName())); + if (res.isPresent() && res.get() == ButtonType.YES) { station.getSystem().remove(station); } } @@ -268,7 +264,7 @@ public class MainController { } } - public void impMadSystems(ActionEvent actionEvent) { + public void impMadSystems() { chooseFile(new FileChooser.ExtensionFilter("CSV files (*.csv)", "*.csv"), file -> { try { Parser.parseSystems(file, World.getMarket()); @@ -279,7 +275,7 @@ public class MainController { }); } - public void impMadStations(ActionEvent actionEvent) { + public void impMadStations() { chooseFile(new FileChooser.ExtensionFilter("CSV files (*.csv)", "*.csv"), file -> { try { Parser.parseStations(file, World.getMarket()); @@ -290,7 +286,7 @@ public class MainController { }); } - public void impMadOffers(ActionEvent actionEvent) { + public void impMadOffers() { chooseFile(new FileChooser.ExtensionFilter("Prices files (*.prices)", "*.prices"), file -> { try { Parser.parsePrices(file, World.getMarket()); diff --git a/client/src/main/java/ru/trader/controllers/OffersController.java b/client/src/main/java/ru/trader/controllers/OffersController.java index ab65f0d..5ea9871 100644 --- a/client/src/main/java/ru/trader/controllers/OffersController.java +++ b/client/src/main/java/ru/trader/controllers/OffersController.java @@ -5,8 +5,6 @@ import javafx.collections.FXCollections; import javafx.fxml.FXML; import javafx.scene.control.*; import javafx.scene.input.MouseButton; -import org.controlsfx.control.action.Action; -import org.controlsfx.dialog.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import ru.trader.core.SERVICE_TYPE; @@ -22,6 +20,7 @@ import ru.trader.view.support.autocomplete.CachedSuggestionProvider; import ru.trader.view.support.autocomplete.SystemsProvider; import java.util.List; +import java.util.Optional; public class OffersController { @@ -211,8 +210,8 @@ public class OffersController { private void removeStation() { StationModel s = getStation(); if (!ModelFabric.isFake(s)){ - Action res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), s.getName())); - if (res == org.controlsfx.dialog.Dialog.ACTION_YES) { + Optional res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), s.getName())); + if (res.isPresent() && res.get() == ButtonType.YES) { s.getSystem().remove(s); } } diff --git a/client/src/main/java/ru/trader/controllers/Screeners.java b/client/src/main/java/ru/trader/controllers/Screeners.java index ecff217..4a4142a 100644 --- a/client/src/main/java/ru/trader/controllers/Screeners.java +++ b/client/src/main/java/ru/trader/controllers/Screeners.java @@ -5,12 +5,11 @@ import javafx.fxml.FXMLLoader; import javafx.scene.Node; import javafx.scene.Parent; import javafx.scene.Scene; -import javafx.scene.control.Alert; -import javafx.scene.control.TextInputDialog; +import javafx.scene.control.*; +import javafx.scene.layout.GridPane; +import javafx.scene.layout.Priority; import javafx.stage.Stage; import javafx.util.Pair; -import org.controlsfx.control.action.Action; -import org.controlsfx.dialog.Dialogs; import ru.trader.EMDNUpdater; import ru.trader.core.MarketFilter; import ru.trader.core.VendorFilter; @@ -20,6 +19,8 @@ import ru.trader.view.support.CustomBuilderFactory; import ru.trader.view.support.Localization; import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; import java.net.URL; import java.util.Optional; @@ -175,13 +176,42 @@ public class Screeners { mainController.getMainPane().setCenter(node); } - public static void showException(Throwable e){ - if (mainScreen!=null) - Dialogs.create().owner(mainScreen).showException(e); + public static void showException(Throwable ex){ + Alert alert = new Alert(Alert.AlertType.ERROR); + alert.setTitle("Exception Dialog"); + alert.setHeaderText(ex.getLocalizedMessage()); + + // Create expandable Exception. + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + ex.printStackTrace(pw); + String exceptionText = sw.toString(); + + Label label = new Label("The exception stacktrace was:"); + TextArea textArea = new TextArea(exceptionText); + textArea.setEditable(false); + textArea.setWrapText(true); + + textArea.setMaxWidth(Double.MAX_VALUE); + textArea.setMaxHeight(Double.MAX_VALUE); + GridPane.setVgrow(textArea, Priority.ALWAYS); + GridPane.setHgrow(textArea, Priority.ALWAYS); + + GridPane expContent = new GridPane(); + expContent.setMaxWidth(Double.MAX_VALUE); + expContent.add(label, 0, 0); + expContent.add(textArea, 0, 1); + + alert.getDialogPane().setExpandableContent(expContent); + alert.showAndWait(); } - public static Action showConfirm(String text){ - return Dialogs.create().owner(mainScreen).message(text).showConfirm(); + public static Optional showConfirm(String text){ + Alert alert = new Alert(Alert.AlertType.CONFIRMATION); + alert.setTitle("Confirmation Dialog"); + alert.setHeaderText(text); + alert.getButtonTypes().setAll(ButtonType.YES, ButtonType.NO, ButtonType.CANCEL); + return alert.showAndWait(); } public static Optional showAddGroup(MarketModel market){ diff --git a/pom.xml b/pom.xml index c6434c5..72affd9 100644 --- a/pom.xml +++ b/pom.xml @@ -73,7 +73,7 @@ org.controlsfx controlsfx - 8.20.9 + 8.40.10 com.sleepycat