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.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<ButtonType> 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;
}

View File

@@ -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);
}

View File

@@ -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<ButtonType> 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<ButtonType> 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<ButtonType> 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<ButtonType> 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<ButtonType> 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<ButtonType> 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<ButtonType> 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<ButtonType> 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());

View File

@@ -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<ButtonType> res = Screeners.showConfirm(String.format(Localization.getString("dialog.confirm.remove"), s.getName()));
if (res.isPresent() && res.get() == ButtonType.YES) {
s.getSystem().remove(s);
}
}

View File

@@ -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<ButtonType> 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<GroupModel> showAddGroup(MarketModel market){