Archived
0

change version of ControlsFX to 8.40.10

This commit is contained in:
iMoHax
2016-03-11 13:02:01 +03:00
parent 210e063e88
commit ce1bc2ec3c
6 changed files with 84 additions and 59 deletions

View File

@@ -2,12 +2,11 @@ package ru.trader;
import javafx.application.Application; import javafx.application.Application;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.control.ButtonType;
import javafx.scene.input.Clipboard; import javafx.scene.input.Clipboard;
import javafx.scene.input.ClipboardContent; import javafx.scene.input.ClipboardContent;
import javafx.stage.Stage; import javafx.stage.Stage;
import org.apache.log4j.PropertyConfigurator; import org.apache.log4j.PropertyConfigurator;
import org.controlsfx.control.action.Action;
import org.controlsfx.dialog.Dialog;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import ru.trader.controllers.MainController; import ru.trader.controllers.MainController;
@@ -22,6 +21,7 @@ import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.Locale; import java.util.Locale;
import java.util.Optional;
public class Main extends Application { public class Main extends Application {
private final static Logger LOG = LoggerFactory.getLogger(Main.class); private final static Logger LOG = LoggerFactory.getLogger(Main.class);
@@ -89,9 +89,9 @@ public class Main extends Application {
primaryStage.setOnCloseRequest((we) -> { primaryStage.setOnCloseRequest((we) -> {
try { try {
if (World.getMarket().isChange()) { if (World.getMarket().isChange()) {
Action res = Screeners.showConfirm(Localization.getString("dialog.confirm.save")); Optional<ButtonType> res = Screeners.showConfirm(Localization.getString("dialog.confirm.save"));
if (res == Dialog.ACTION_YES) World.save(); if (res.isPresent() && res.get() == ButtonType.YES) World.save();
else if (res == Dialog.ACTION_CANCEL) { else if (!res.isPresent() || res.get() == ButtonType.CANCEL) {
we.consume(); we.consume();
return; return;
} }

View File

@@ -25,7 +25,7 @@ public class ItemDescController {
public void setItemDesc(ItemModel itemDesc){ public void setItemDesc(ItemModel itemDesc){
item = itemDesc; item = itemDesc;
if (popup!=null) popup.setDetachedTitle(item.nameProperty().get()); if (popup!=null) popup.setTitle(item.nameProperty().get());
fill(); fill();
} }
@@ -40,7 +40,7 @@ public class ItemDescController {
if (popup != null && popup.isShowing()) return; if (popup != null && popup.isShowing()) return;
if (popup == null) { if (popup == null) {
popup = new PopOver(itemDescScreen); popup = new PopOver(itemDescScreen);
popup.setDetachedTitle(item.nameProperty().get()); popup.setTitle(item.nameProperty().get());
popup.setAutoHide(true); popup.setAutoHide(true);
} }

View File

@@ -1,13 +1,10 @@
package ru.trader.controllers; package ru.trader.controllers;
import javafx.event.ActionEvent;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.*; import javafx.scene.control.*;
import javafx.scene.layout.BorderPane; import javafx.scene.layout.BorderPane;
import javafx.stage.FileChooser; import javafx.stage.FileChooser;
import org.controlsfx.control.action.Action;
import org.controlsfx.dialog.Dialog;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
@@ -116,7 +113,7 @@ public class MainController {
profController.initEDCEBtn(); profController.initEDCEBtn();
} }
public void save(ActionEvent actionEvent) { public void save() {
try { try {
World.save(); World.save();
} catch (FileNotFoundException | UnsupportedEncodingException | XMLStreamException e) { } catch (FileNotFoundException | UnsupportedEncodingException | XMLStreamException e) {
@@ -124,7 +121,7 @@ public class MainController {
} }
} }
public void importWorld(ActionEvent actionEvent) { public void importWorld() {
try { try {
FileChooser fileChooser = new FileChooser(); FileChooser fileChooser = new FileChooser();
FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("XML bd files (*.xml)", "*.xml"); 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 { try {
FileChooser fileChooser = new FileChooser(); FileChooser fileChooser = new FileChooser();
FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("XML bd files (*.xml)", "*.xml"); FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("XML bd files (*.xml)", "*.xml");
@@ -156,49 +153,49 @@ public class MainController {
} }
} }
public void clear(ActionEvent actionEvent){ public void clear(){
Action res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), Localization.getString("market.all"))); Optional<ButtonType> res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), Localization.getString("market.all")));
if (res == Dialog.ACTION_YES) { if (res.isPresent() && res.get() == ButtonType.OK) {
market.clear(); market.clear();
reload(); reload();
} }
} }
public void clearOffers(ActionEvent actionEvent){ public void clearOffers(){
Action res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), Localization.getString("market.offers"))); Optional<ButtonType> res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), Localization.getString("market.offers")));
if (res == Dialog.ACTION_YES) { if (res.isPresent() && res.get() == ButtonType.YES) {
market.clearOffers(); market.clearOffers();
reload(); reload();
} }
} }
public void clearStations(ActionEvent actionEvent){ public void clearStations(){
Action res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), Localization.getString("market.stations"))); Optional<ButtonType> res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), Localization.getString("market.stations")));
if (res == Dialog.ACTION_YES) { if (res.isPresent() && res.get() == ButtonType.YES) {
market.clearStations(); market.clearStations();
reload(); reload();
} }
} }
public void clearSystems(ActionEvent actionEvent){ public void clearSystems(){
Action res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), Localization.getString("market.systems"))); Optional<ButtonType> res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), Localization.getString("market.systems")));
if (res == Dialog.ACTION_YES) { if (res.isPresent() && res.get() == ButtonType.YES) {
market.clearSystems(); market.clearSystems();
reload(); reload();
} }
} }
public void clearItems(ActionEvent actionEvent){ public void clearItems(){
Action res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), Localization.getString("market.items"))); Optional<ButtonType> res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), Localization.getString("market.items")));
if (res == Dialog.ACTION_YES) { if (res.isPresent() && res.get() == ButtonType.YES) {
market.clearItems(); market.clearItems();
reload(); reload();
} }
} }
public void clearGroups(ActionEvent actionEvent){ public void clearGroups(){
Action res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), Localization.getString("market.groups"))); Optional<ButtonType> res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), Localization.getString("market.groups")));
if (res == Dialog.ACTION_YES) { if (res.isPresent() && res.get() == ButtonType.YES) {
market.clearGroups(); market.clearGroups();
reload(); reload();
} }
@@ -212,47 +209,46 @@ public class MainController {
return Screeners.showAddItem(market); return Screeners.showAddItem(market);
} }
public void addSystem(){
public void addSystem(ActionEvent actionEvent){
Screeners.showSystemsEditor(null); Screeners.showSystemsEditor(null);
} }
public void editSystem(ActionEvent actionEvent){ public void editSystem(){
SystemModel system = profile.getSystem(); SystemModel system = profile.getSystem();
if (!ModelFabric.isFake(system)) { if (!ModelFabric.isFake(system)) {
Screeners.showSystemsEditor(system); Screeners.showSystemsEditor(system);
} }
} }
public void removeSystem(ActionEvent actionEvent){ public void removeSystem(){
SystemModel system = profile.getSystem(); SystemModel system = profile.getSystem();
if (!ModelFabric.isFake(system)) { if (!ModelFabric.isFake(system)) {
Action res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), system.getName())); Optional<ButtonType> res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), system.getName()));
if (res == Dialog.ACTION_YES) { if (res.isPresent() && res.get() == ButtonType.YES) {
market.remove(system); market.remove(system);
} }
} }
} }
public void addStation(ActionEvent actionEvent) { public void addStation() {
SystemModel system = profile.getSystem(); SystemModel system = profile.getSystem();
if (!ModelFabric.isFake(system)) { if (!ModelFabric.isFake(system)) {
Screeners.showAddStation(profile.getSystem()); Screeners.showAddStation(profile.getSystem());
} }
} }
public void editStation(ActionEvent actionEvent) { public void editStation() {
StationModel station = profile.getStation(); StationModel station = profile.getStation();
if (!ModelFabric.isFake(station)) { if (!ModelFabric.isFake(station)) {
Screeners.showEditStation(station); Screeners.showEditStation(station);
} }
} }
public void removeStation(ActionEvent actionEvent){ public void removeStation(){
StationModel station = profile.getStation(); StationModel station = profile.getStation();
if (!ModelFabric.isFake(station)) { if (!ModelFabric.isFake(station)) {
Action res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), station.getName())); Optional<ButtonType> res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), station.getName()));
if (res == Dialog.ACTION_YES) { if (res.isPresent() && res.get() == ButtonType.YES) {
station.getSystem().remove(station); 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 -> { chooseFile(new FileChooser.ExtensionFilter("CSV files (*.csv)", "*.csv"), file -> {
try { try {
Parser.parseSystems(file, World.getMarket()); 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 -> { chooseFile(new FileChooser.ExtensionFilter("CSV files (*.csv)", "*.csv"), file -> {
try { try {
Parser.parseStations(file, World.getMarket()); 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 -> { chooseFile(new FileChooser.ExtensionFilter("Prices files (*.prices)", "*.prices"), file -> {
try { try {
Parser.parsePrices(file, World.getMarket()); Parser.parsePrices(file, World.getMarket());

View File

@@ -5,8 +5,6 @@ import javafx.collections.FXCollections;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.*; import javafx.scene.control.*;
import javafx.scene.input.MouseButton; import javafx.scene.input.MouseButton;
import org.controlsfx.control.action.Action;
import org.controlsfx.dialog.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import ru.trader.core.SERVICE_TYPE; 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 ru.trader.view.support.autocomplete.SystemsProvider;
import java.util.List; import java.util.List;
import java.util.Optional;
public class OffersController { public class OffersController {
@@ -211,8 +210,8 @@ public class OffersController {
private void removeStation() { private void removeStation() {
StationModel s = getStation(); StationModel s = getStation();
if (!ModelFabric.isFake(s)){ if (!ModelFabric.isFake(s)){
Action res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), s.getName())); Optional<ButtonType> res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), s.getName()));
if (res == org.controlsfx.dialog.Dialog.ACTION_YES) { if (res.isPresent() && res.get() == ButtonType.YES) {
s.getSystem().remove(s); s.getSystem().remove(s);
} }
} }

View File

@@ -5,12 +5,11 @@ import javafx.fxml.FXMLLoader;
import javafx.scene.Node; import javafx.scene.Node;
import javafx.scene.Parent; import javafx.scene.Parent;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.control.Alert; import javafx.scene.control.*;
import javafx.scene.control.TextInputDialog; import javafx.scene.layout.GridPane;
import javafx.scene.layout.Priority;
import javafx.stage.Stage; import javafx.stage.Stage;
import javafx.util.Pair; import javafx.util.Pair;
import org.controlsfx.control.action.Action;
import org.controlsfx.dialog.Dialogs;
import ru.trader.EMDNUpdater; import ru.trader.EMDNUpdater;
import ru.trader.core.MarketFilter; import ru.trader.core.MarketFilter;
import ru.trader.core.VendorFilter; import ru.trader.core.VendorFilter;
@@ -20,6 +19,8 @@ import ru.trader.view.support.CustomBuilderFactory;
import ru.trader.view.support.Localization; import ru.trader.view.support.Localization;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.net.URL; import java.net.URL;
import java.util.Optional; import java.util.Optional;
@@ -175,13 +176,42 @@ public class Screeners {
mainController.getMainPane().setCenter(node); mainController.getMainPane().setCenter(node);
} }
public static void showException(Throwable e){ public static void showException(Throwable ex){
if (mainScreen!=null) Alert alert = new Alert(Alert.AlertType.ERROR);
Dialogs.create().owner(mainScreen).showException(e); 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){ public static Optional<ButtonType> showConfirm(String text){
return Dialogs.create().owner(mainScreen).message(text).showConfirm(); 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<GroupModel> showAddGroup(MarketModel market){ public static Optional<GroupModel> showAddGroup(MarketModel market){

View File

@@ -73,7 +73,7 @@
<dependency> <dependency>
<groupId>org.controlsfx</groupId> <groupId>org.controlsfx</groupId>
<artifactId>controlsfx</artifactId> <artifactId>controlsfx</artifactId>
<version>8.20.9</version> <version>8.40.10</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.sleepycat</groupId> <groupId>com.sleepycat</groupId>