diff --git a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMenuToolbarViewController.java b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMenuToolbarViewController.java index f7d817b5155e611268fe95e7f1049a01f5e35969..c12d9a8df7dd8bca20e6eac127788f1da8ae7622 100644 --- a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMenuToolbarViewController.java +++ b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMenuToolbarViewController.java @@ -23,7 +23,6 @@ import de.tobias.playpad.project.ProjectNotFoundException; import de.tobias.playpad.project.ProjectReference; import de.tobias.playpad.registry.NoSuchComponentException; import de.tobias.playpad.registry.Registry; -import de.tobias.playpad.settings.GlobalSettings; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.settings.ProfileNotFoundException; import de.tobias.playpad.settings.ProfileSettings; @@ -40,9 +39,6 @@ import de.tobias.playpad.viewcontroller.dialog.ProfileViewController; import de.tobias.playpad.viewcontroller.dialog.ProjectManagerDialog; import de.tobias.playpad.viewcontroller.main.BasicMenuToolbarViewController; import de.tobias.playpad.viewcontroller.main.IMainViewController; -import de.tobias.playpad.viewcontroller.option.GlobalSettingsTabViewController; -import de.tobias.playpad.viewcontroller.option.ProfileSettingsTabViewController; -import de.tobias.playpad.viewcontroller.option.ProjectSettingsTabViewController; import de.tobias.playpad.viewcontroller.option.global.GlobalSettingsViewController; import de.tobias.playpad.viewcontroller.option.profile.ProfileSettingsViewController; import de.tobias.playpad.viewcontroller.option.project.ProjectSettingsViewController; @@ -475,12 +471,6 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro Runnable onFinish = () -> { - for (ProjectSettingsTabViewController controller : projectSettingsViewController.getTabs()) { - if (controller.needReload()) { - controller.reload(currentProject.getSettings(), currentProject, mainViewController); - } - } - projectSettingsViewController = null; mainStage.toFront(); }; @@ -513,18 +503,6 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro { midi.setListener(mainViewController.getMidiHandler()); - boolean change = false; - for (ProfileSettingsTabViewController controller : profileSettingsViewController.getTabs()) { - if (controller.needReload()) { - change = true; - controller.reload(Profile.currentProfile(), currentProject, mainViewController); - } - } - - if (change) { - PlayPadMain.getProgramInstance().getSettingsListener().forEach(l -> l.onChange(Profile.currentProfile())); - } - profileSettingsViewController = null; mainStage.toFront(); }; @@ -545,15 +523,6 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro Stage mainStage = mainViewController.getStage(); Runnable onFinish = () -> { - Project currentProject = PlayPadMain.getProgramInstance().getCurrentProject(); - GlobalSettings globalSettings = PlayPadPlugin.getImplementation().getGlobalSettings(); - - for (GlobalSettingsTabViewController controller : globalSettingsViewController.getTabs()) { - if (controller.needReload()) { - controller.reload(globalSettings, currentProject, mainViewController); - } - } - globalSettingsViewController = null; mainStage.toFront(); }; diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/global/GlobalSettingsViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/global/GlobalSettingsViewController.java index 6534d2976f3b068c46f230e869c673b065712604..f3e4c210d2991e39df07b040a837b16417351e4e 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/global/GlobalSettingsViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/global/GlobalSettingsViewController.java @@ -3,17 +3,26 @@ package de.tobias.playpad.viewcontroller.option.global; import java.util.ArrayList; import java.util.List; +import org.controlsfx.control.TaskProgressView; + +import de.tobias.playpad.PlayPadImpl; import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.Strings; import de.tobias.playpad.settings.GlobalSettings; import de.tobias.playpad.settings.Profile; +import de.tobias.playpad.viewcontroller.main.IMainViewController; import de.tobias.playpad.viewcontroller.option.GlobalSettingsTabViewController; +import de.tobias.playpad.viewcontroller.option.IGlobalReloadTask; import de.tobias.playpad.viewcontroller.option.IGlobalSettingsViewController; import de.tobias.utils.ui.ViewController; import de.tobias.utils.util.Localization; +import de.tobias.utils.util.Worker; +import javafx.beans.Observable; +import javafx.concurrent.Task; import javafx.event.ActionEvent; import javafx.fxml.FXML; +import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Tab; import javafx.scene.control.TabPane; @@ -118,9 +127,42 @@ public class GlobalSettingsViewController extends ViewController implements IGlo saveTabs(); if (onFinish != null) onFinish.run(); // Reload MainViewController Settings + + PlayPadImpl programInstance = PlayPadMain.getProgramInstance(); + IMainViewController mainController = programInstance.getMainViewController(); + GlobalSettings settings = programInstance.getGlobalSettings(); + showProgressDialog(settings, mainController); + return true; } + private void showProgressDialog(GlobalSettings settings, IMainViewController mainController) { + TaskProgressView<Task<Void>> taskView = new TaskProgressView<>(); + + for (GlobalSettingsTabViewController controller : tabs) { + if (controller instanceof IGlobalReloadTask) { + if (controller.needReload()) { + Task<Void> task = ((IGlobalReloadTask) controller).getTask(settings, mainController); + taskView.getTasks().add(task); + Worker.runLater(task); + } + } + } + + if (!taskView.getTasks().isEmpty()) { + Scene scene = new Scene(taskView); + Stage stage = new Stage(); + taskView.getTasks().addListener((Observable observable) -> + { + if (taskView.getTasks().isEmpty()) { + stage.close(); + } + }); + stage.setScene(scene); + stage.showAndWait(); + } + } + @Override public void addTab(GlobalSettingsTabViewController controller) { tabs.add(controller); diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/global/KeysTabViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/global/KeysTabViewController.java index c6132c91e319ce4ea2d54fcbb48d80a0d5fa2db2..ea2c874f381e4c2a8e8dce94b229c761f82378ca 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/global/KeysTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/global/KeysTabViewController.java @@ -3,11 +3,11 @@ package de.tobias.playpad.viewcontroller.option.global; import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.Strings; -import de.tobias.playpad.project.Project; import de.tobias.playpad.settings.GlobalSettings; import de.tobias.playpad.settings.keys.Key; import de.tobias.playpad.viewcontroller.main.IMainViewController; import de.tobias.playpad.viewcontroller.option.GlobalSettingsTabViewController; +import de.tobias.playpad.viewcontroller.option.IGlobalReloadTask; import de.tobias.utils.util.Localization; import de.tobias.utils.util.OS; import javafx.application.Platform; @@ -15,6 +15,7 @@ import javafx.beans.property.SimpleStringProperty; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.collections.transformation.FilteredList; +import javafx.concurrent.Task; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.Scene; @@ -30,7 +31,7 @@ import javafx.scene.control.TextField; import javafx.scene.input.KeyCode; import javafx.stage.Stage; -public class KeysTabViewController extends GlobalSettingsTabViewController { +public class KeysTabViewController extends GlobalSettingsTabViewController implements IGlobalReloadTask { @FXML private TextField searchTextField; @@ -168,8 +169,17 @@ public class KeysTabViewController extends GlobalSettingsTabViewController { } @Override - public void reload(GlobalSettings settings, Project project, IMainViewController controller) { - controller.loadKeybinding(settings.getKeyCollection()); + public Task<Void> getTask(GlobalSettings settings, IMainViewController controller) { + return new Task<Void>() { + @Override + protected Void call() throws Exception { + updateTitle(name()); + updateProgress(-1, -1); + + controller.loadKeybinding(settings.getKeyCollection()); + return null; + } + }; } @Override diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/AudioTabViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/AudioTabViewController.java index 7faa367ac3794cff8f7517b603693eaef7a4803a..beb9b84cb331f7caf4e64d1454facdbb0fd7cb42 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/AudioTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/AudioTabViewController.java @@ -10,14 +10,15 @@ import de.tobias.playpad.settings.Profile; import de.tobias.playpad.settings.ProfileSettings; import de.tobias.playpad.viewcontroller.AudioTypeViewController; import de.tobias.playpad.viewcontroller.main.IMainViewController; +import de.tobias.playpad.viewcontroller.option.IProfileReloadTask; import de.tobias.playpad.viewcontroller.option.ProfileSettingsTabViewController; import de.tobias.utils.util.Localization; -import de.tobias.utils.util.Worker; +import javafx.concurrent.Task; import javafx.fxml.FXML; import javafx.scene.control.ComboBox; import javafx.scene.layout.AnchorPane; -public class AudioTabViewController extends ProfileSettingsTabViewController { +public class AudioTabViewController extends ProfileSettingsTabViewController implements IProfileReloadTask { // Audio @FXML private ComboBox<String> audioTypeComboBox; @@ -101,11 +102,17 @@ public class AudioTabViewController extends ProfileSettingsTabViewController { } @Override - public void reload(Profile profile, Project project, IMainViewController controller) { - Worker.runLater(() -> - { - project.loadPadsContent(); - }); + public Task<Void> getTask(ProfileSettings settings, Project project, IMainViewController controller) { + return new Task<Void>() { + @Override + protected Void call() throws Exception { + updateTitle(name()); + updateProgress(-1, -1); + + project.loadPadsContent(); + return null; + } + }; } @Override diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/DesignTabViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/DesignTabViewController.java index 3953f127976fb179b61a7928ea5ddc74acab193d..467fc9a984cc705bbf1fa861b91c0cff3321371b 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/DesignTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/DesignTabViewController.java @@ -8,16 +8,19 @@ import de.tobias.playpad.design.DesignConnect; import de.tobias.playpad.project.Project; import de.tobias.playpad.registry.NoSuchComponentException; import de.tobias.playpad.settings.Profile; +import de.tobias.playpad.settings.ProfileSettings; import de.tobias.playpad.viewcontroller.GlobalDesignViewController; import de.tobias.playpad.viewcontroller.cell.DisplayableCell; import de.tobias.playpad.viewcontroller.main.IMainViewController; +import de.tobias.playpad.viewcontroller.option.IProfileReloadTask; import de.tobias.playpad.viewcontroller.option.ProfileSettingsTabViewController; import de.tobias.utils.util.Localization; +import javafx.concurrent.Task; import javafx.fxml.FXML; import javafx.scene.control.ComboBox; import javafx.scene.layout.VBox; -public class DesignTabViewController extends ProfileSettingsTabViewController { +public class DesignTabViewController extends ProfileSettingsTabViewController implements IProfileReloadTask { @FXML private VBox layoutContainer; @FXML private ComboBox<DesignConnect> layoutTypeComboBox; @@ -68,10 +71,12 @@ public class DesignTabViewController extends ProfileSettingsTabViewController { } @Override - public void loadSettings(Profile profile) {} + public void loadSettings(Profile profile) { + } @Override - public void saveSettings(Profile profile) {} + public void saveSettings(Profile profile) { + } @Override public boolean needReload() { @@ -79,8 +84,17 @@ public class DesignTabViewController extends ProfileSettingsTabViewController { } @Override - public void reload(Profile profile, Project project, IMainViewController controller) { - controller.loadUserCss(); + public Task<Void> getTask(ProfileSettings settings, Project project, IMainViewController controller) { + return new Task<Void>() { + @Override + protected Void call() throws Exception { + updateTitle(name()); + updateProgress(-1, -1); + + controller.loadUserCss(); + return null; + } + }; } @Override diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/MappingTabViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/MappingTabViewController.java index 56ad791cd0f81208d28171649802074b90505989..f1fe20a9a9946fd2a2b116faa07548bcbdde439a 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/MappingTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/MappingTabViewController.java @@ -16,15 +16,18 @@ import de.tobias.playpad.action.mapper.MapperRegistry; import de.tobias.playpad.project.Project; import de.tobias.playpad.registry.NoSuchComponentException; import de.tobias.playpad.settings.Profile; +import de.tobias.playpad.settings.ProfileSettings; import de.tobias.playpad.viewcontroller.IMapperOverviewViewController; import de.tobias.playpad.viewcontroller.IMappingTabViewController; import de.tobias.playpad.viewcontroller.cell.DisplayableCell; import de.tobias.playpad.viewcontroller.cell.DisplayableTreeCell; import de.tobias.playpad.viewcontroller.dialog.MappingListViewController; import de.tobias.playpad.viewcontroller.main.IMainViewController; +import de.tobias.playpad.viewcontroller.option.IProfileReloadTask; import de.tobias.playpad.viewcontroller.option.ProfileSettingsTabViewController; import de.tobias.utils.ui.ContentViewController; import de.tobias.utils.util.Localization; +import javafx.concurrent.Task; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.control.Button; @@ -33,7 +36,7 @@ import javafx.scene.control.TreeItem; import javafx.scene.control.TreeView; import javafx.scene.layout.VBox; -public class MappingTabViewController extends ProfileSettingsTabViewController implements IMappingTabViewController { +public class MappingTabViewController extends ProfileSettingsTabViewController implements IMappingTabViewController, IProfileReloadTask { @FXML private ComboBox<Mapping> mappingComboBox; @FXML private Button editMappingsButton; @@ -162,15 +165,24 @@ public class MappingTabViewController extends ProfileSettingsTabViewController i } @Override - public void reload(Profile profile, Project project, IMainViewController controller) { - Project currentProject = PlayPadMain.getProgramInstance().getCurrentProject(); - Profile.currentProfile().getMappings().getActiveMapping().adjustPadColorToMapper(currentProject); - - Mapping activeMapping = Profile.currentProfile().getMappings().getActiveMapping(); - - oldMapping.clearFeedback(); - activeMapping.showFeedback(project); - activeMapping.initFeedback(); + public Task<Void> getTask(ProfileSettings settings, Project project, IMainViewController controller) { + return new Task<Void>() { + @Override + protected Void call() throws Exception { + updateTitle(name()); + updateProgress(-1, -1); + + Project currentProject = PlayPadMain.getProgramInstance().getCurrentProject(); + Profile.currentProfile().getMappings().getActiveMapping().adjustPadColorToMapper(currentProject); + + Mapping activeMapping = Profile.currentProfile().getMappings().getActiveMapping(); + + oldMapping.clearFeedback(); + activeMapping.showFeedback(project); + activeMapping.initFeedback(); + return null; + } + }; } @Override diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/MidiTabViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/MidiTabViewController.java index 5f1b14a0b74a0677fa40bd45acec780958183c6d..efedbd16a858c01b42deb8a4b802b7f3ac8483ef 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/MidiTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/MidiTabViewController.java @@ -6,10 +6,8 @@ import javax.sound.midi.MidiUnavailableException; import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.Strings; import de.tobias.playpad.midi.Midi; -import de.tobias.playpad.project.Project; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.settings.ProfileSettings; -import de.tobias.playpad.viewcontroller.main.IMainViewController; import de.tobias.playpad.viewcontroller.option.ProfileSettingsTabViewController; import de.tobias.utils.util.Localization; import javafx.event.ActionEvent; @@ -112,11 +110,6 @@ public class MidiTabViewController extends ProfileSettingsTabViewController { return true; } - @Override - public void reload(Profile profile, Project project, IMainViewController controller) { - - } - @Override public String name() { return Localization.getString(Strings.UI_Window_Settings_Midi_Title); diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/PlayerTabViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/PlayerTabViewController.java index 46ac63ee69628e47f7d03cbd121c2578d29d7c57..a903758d2d2b638087854631368945c007643c19 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/PlayerTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/PlayerTabViewController.java @@ -3,11 +3,9 @@ package de.tobias.playpad.viewcontroller.option.profile; import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.Strings; import de.tobias.playpad.pad.TimeMode; -import de.tobias.playpad.project.Project; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.settings.ProfileSettings; import de.tobias.playpad.viewcontroller.cell.EnumCell; -import de.tobias.playpad.viewcontroller.main.IMainViewController; import de.tobias.playpad.viewcontroller.option.ProfileSettingsTabViewController; import de.tobias.playpad.viewcontroller.settings.FadeViewController; import de.tobias.playpad.viewcontroller.settings.WarningFeedbackViewController; @@ -74,9 +72,6 @@ public class PlayerTabViewController extends ProfileSettingsTabViewController { return false; } - @Override - public void reload(Profile profile, Project project, IMainViewController controller) {} - @Override public boolean validSettings() { return true; diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/ProfileSettingsViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/ProfileSettingsViewController.java index e24d1316bf4a65ef2549a4f37374007e1c24291f..1ab694da4f58816fd339da901b1e130c3c71ff93 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/ProfileSettingsViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/ProfileSettingsViewController.java @@ -3,6 +3,8 @@ package de.tobias.playpad.viewcontroller.option.profile; import java.util.ArrayList; import java.util.List; +import org.controlsfx.control.TaskProgressView; + import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.Strings; @@ -12,14 +14,21 @@ import de.tobias.playpad.project.Project; import de.tobias.playpad.registry.NoSuchComponentException; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.settings.ProfileSettings; +import de.tobias.playpad.viewcontroller.main.IMainViewController; +import de.tobias.playpad.viewcontroller.option.IProfileReloadTask; import de.tobias.playpad.viewcontroller.option.IProfileSettingsViewController; +import de.tobias.playpad.viewcontroller.option.IProjectReloadTask; import de.tobias.playpad.viewcontroller.option.ProfileSettingsTabViewController; import de.tobias.utils.ui.ViewController; import de.tobias.utils.ui.icon.FontAwesomeType; import de.tobias.utils.ui.icon.FontIcon; import de.tobias.utils.util.Localization; +import de.tobias.utils.util.Worker; +import javafx.beans.Observable; +import javafx.concurrent.Task; import javafx.event.ActionEvent; import javafx.fxml.FXML; +import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Tab; import javafx.scene.control.TabPane; @@ -159,9 +168,46 @@ public class ProfileSettingsViewController extends ViewController implements IPr saveTabs(); if (onFinish != null) onFinish.run(); // Reload MainViewController Settings + + IMainViewController mainController = PlayPadMain.getProgramInstance().getMainViewController(); + Profile profile = Profile.currentProfile(); + Project project = PlayPadMain.getProgramInstance().getCurrentProject(); + + showProgressDialog(profile.getProfileSettings(), project, mainController); + return true; } + private void showProgressDialog(ProfileSettings settings, Project project, IMainViewController mainController) { + TaskProgressView<Task<Void>> taskView = new TaskProgressView<>(); + + for (ProfileSettingsTabViewController controller : tabs) { + if (controller instanceof IProjectReloadTask) { + if (controller.needReload()) { + Task<Void> task = ((IProfileReloadTask) controller).getTask(settings, project, mainController); + taskView.getTasks().add(task); + Worker.runLater(task); + } + } + } + + if (!taskView.getTasks().isEmpty()) { + // Run Listener + PlayPadMain.getProgramInstance().getSettingsListener().forEach(l -> l.onChange(Profile.currentProfile())); + + Scene scene = new Scene(taskView); + Stage stage = new Stage(); + taskView.getTasks().addListener((Observable observable) -> + { + if (taskView.getTasks().isEmpty()) { + stage.close(); + } + }); + stage.setScene(scene); + stage.showAndWait(); + } + } + /** * Aktiviert/Deaktiviert den Look Button. * diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/GeneralTabViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/GeneralTabViewController.java index a94a860b87f80a995373fb90159dcca41048f905..24fe811955fbb7b5e7e7d5d3d1bc00ec5b09bcfb 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/GeneralTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/GeneralTabViewController.java @@ -8,20 +8,17 @@ import de.tobias.playpad.project.Project; import de.tobias.playpad.project.ProjectSettings; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.viewcontroller.main.IMainViewController; +import de.tobias.playpad.viewcontroller.option.IProjectReloadTask; import de.tobias.playpad.viewcontroller.option.ProjectSettingsTabViewController; import de.tobias.utils.ui.Alertable; import de.tobias.utils.util.Localization; -import de.tobias.utils.util.Worker; import javafx.application.Platform; +import javafx.concurrent.Task; import javafx.fxml.FXML; -import javafx.scene.control.Alert; -import javafx.scene.control.Alert.AlertType; import javafx.scene.control.TextField; -import javafx.stage.Modality; import javafx.stage.Screen; -import javafx.stage.Stage; -public class GeneralTabViewController extends ProjectSettingsTabViewController { +public class GeneralTabViewController extends ProjectSettingsTabViewController implements IProjectReloadTask { private static final String DIGIT_POSITIV = "^[1-9]\\d*$"; @@ -101,7 +98,8 @@ public class GeneralTabViewController extends ProjectSettingsTabViewController { if (neededHeight <= height && neededWidth <= width) return true; - } catch (NumberFormatException e) {} + } catch (NumberFormatException e) { + } return false; } @@ -145,30 +143,27 @@ public class GeneralTabViewController extends ProjectSettingsTabViewController { return changeSettings; } - @Override - public void reload(ProjectSettings settings, Project project, IMainViewController controller) { - Alert alert = new Alert(AlertType.INFORMATION); - alert.setContentText(Localization.getString(Strings.UI_Window_Settings_Gen_Wait)); - - alert.getButtonTypes().clear(); - alert.initOwner(controller.getStage()); - alert.initModality(Modality.WINDOW_MODAL); - Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); - PlayPadMain.stageIcon.ifPresent(stage.getIcons()::add); - - alert.show(); - - Worker.runLater(() -> - { - Platform.runLater(() -> - { - controller.getMenuToolbarController().initPageButtons(); - controller.createPadViews(); - controller.showPage(controller.getPage()); - stage.close(); - }); - }); - } + // @Override + // public void reload(ProjectSettings settings, Project project, IMainViewController controller) { + // Alert alert = new Alert(AlertType.INFORMATION); + // alert.setContentText(Localization.getString(Strings.UI_Window_Settings_Gen_Wait)); + // + // alert.getButtonTypes().clear(); + // alert.initOwner(controller.getStage()); + // alert.initModality(Modality.WINDOW_MODAL); + // Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); + // PlayPadMain.stageIcon.ifPresent(stage.getIcons()::add); + // + // alert.show(); + // + // Worker.runLater(() -> + // { + // Platform.runLater(() -> + // { + // + // }); + // }); + // } @Override public boolean validSettings() { @@ -193,4 +188,22 @@ public class GeneralTabViewController extends ProjectSettingsTabViewController { return Localization.getString(Strings.UI_Window_Settings_Gen_Title); } + @Override + public Task<Void> getTask(ProjectSettings settings, Project project, IMainViewController controller) { + return new Task<Void>() { + @Override + protected Void call() throws Exception { + updateTitle(name()); + updateProgress(-1, -1); + + Platform.runLater(() -> + { + controller.getMenuToolbarController().initPageButtons(); + controller.createPadViews(); + controller.showPage(controller.getPage()); + }); + return null; + } + }; + } } diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/PathsTabViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/PathsTabViewController.java index e857d85a4b8fce9d403f043b6642028d34abee62..f4ac4dbfd10066977566d686b323fc478fd77fe3 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/PathsTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/PathsTabViewController.java @@ -5,8 +5,12 @@ import java.nio.file.Path; import java.nio.file.Paths; import de.tobias.playpad.PlayPadMain; +import de.tobias.playpad.project.Project; import de.tobias.playpad.project.ProjectSettings; +import de.tobias.playpad.viewcontroller.main.IMainViewController; +import de.tobias.playpad.viewcontroller.option.IProjectReloadTask; import de.tobias.playpad.viewcontroller.option.ProjectSettingsTabViewController; +import javafx.concurrent.Task; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.control.Button; @@ -14,16 +18,17 @@ import javafx.scene.control.CheckBox; import javafx.scene.control.TextField; import javafx.stage.DirectoryChooser; -public class PathsTabViewController extends ProjectSettingsTabViewController { +public class PathsTabViewController extends ProjectSettingsTabViewController implements IProjectReloadTask { // Media Path @FXML private TextField mediaPathTextField; @FXML private Button mediaPathChooseButton; @FXML private CheckBox useMediaPath; + private transient boolean changedMediaPath = false; + public PathsTabViewController() { super("pathTab.fxml", "de/tobias/playpad/assets/view/option/project/", PlayPadMain.getUiResourceBundle()); - // TODO Auto-generated constructor stub } @FXML @@ -46,18 +51,18 @@ public class PathsTabViewController extends ProjectSettingsTabViewController { @Override public void saveSettings(ProjectSettings settings) { + Path newPath = Paths.get(mediaPathTextField.getText()); + if (!settings.getMediaPath().equals(newPath)) { + changedMediaPath = true; + } + if (useMediaPath.isSelected()) { - settings.setMediaPath(Paths.get(mediaPathTextField.getText())); + settings.setMediaPath(newPath); } settings.setUseMediaPath(useMediaPath.isSelected()); } - @Override - public boolean needReload() { - return false; - } - @Override public boolean validSettings() { return true; @@ -68,4 +73,25 @@ public class PathsTabViewController extends ProjectSettingsTabViewController { return "Pfade (i18n)"; // TODO } + // Reload Data + + @Override + public boolean needReload() { + return changedMediaPath; + } + + @Override + public Task<Void> getTask(ProjectSettings settings, Project project, IMainViewController controller) { + return new Task<Void>() { + @Override + protected Void call() throws Exception { + updateTitle(name()); + for (int i = 0; i < 100; i++) { + Thread.sleep(10); + updateProgress(i, 100); + } + return null; + } + }; + } } diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/ProjectSettingsViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/ProjectSettingsViewController.java index 64b2fe038a96d10a6711ffda84b7d258f0b47585..8152b54d1efb2a4cebe74a18b03d69efa009056f 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/ProjectSettingsViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/ProjectSettingsViewController.java @@ -3,17 +3,25 @@ package de.tobias.playpad.viewcontroller.option.project; import java.util.ArrayList; import java.util.List; +import org.controlsfx.control.TaskProgressView; + import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.Strings; import de.tobias.playpad.project.Project; import de.tobias.playpad.project.ProjectSettings; import de.tobias.playpad.settings.Profile; +import de.tobias.playpad.viewcontroller.main.IMainViewController; import de.tobias.playpad.viewcontroller.option.IProjectSettingsViewController; +import de.tobias.playpad.viewcontroller.option.IProjectReloadTask; import de.tobias.playpad.viewcontroller.option.ProjectSettingsTabViewController; import de.tobias.utils.ui.ViewController; import de.tobias.utils.util.Localization; +import de.tobias.utils.util.Worker; +import javafx.beans.Observable; +import javafx.concurrent.Task; import javafx.event.ActionEvent; import javafx.fxml.FXML; +import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Tab; import javafx.scene.control.TabPane; @@ -29,23 +37,24 @@ public class ProjectSettingsViewController extends ViewController implements IPr @FXML private Button finishButton; protected List<ProjectSettingsTabViewController> tabs = new ArrayList<>(); - private ProjectSettings settings; + private Project project; private Runnable onFinish; public ProjectSettingsViewController(Screen currentScreen, Window owner, Project project, Runnable onFinish) { super("projectSettingsView", "de/tobias/playpad/assets/view/option/project/", null, PlayPadMain.getUiResourceBundle()); this.onFinish = onFinish; - this.settings = project.getSettings(); + this.project = project; - getStage().initOwner(owner); boolean activePlayer = project.hasPlayedPlayers(); addTab(new GeneralTabViewController(currentScreen, this, activePlayer)); addTab(new PathsTabViewController()); + getStage().initOwner(owner); + // Show Current Settings - loadTabs(settings); + loadTabs(project.getSettings()); } @Override @@ -109,12 +118,43 @@ public class ProjectSettingsViewController extends ViewController implements IPr } } - saveTabs(settings); + saveTabs(project.getSettings()); if (onFinish != null) onFinish.run(); // Reload MainViewController Settings + + IMainViewController mainController = PlayPadMain.getProgramInstance().getMainViewController(); + showProgressDialog(project.getSettings(), project, mainController); + return true; } + private void showProgressDialog(ProjectSettings settings, Project project, IMainViewController mainController) { + TaskProgressView<Task<Void>> taskView = new TaskProgressView<>(); + + for (ProjectSettingsTabViewController controller : tabs) { + if (controller instanceof IProjectReloadTask) { + if (controller.needReload()) { + Task<Void> task = ((IProjectReloadTask) controller).getTask(settings, project, mainController); + taskView.getTasks().add(task); + Worker.runLater(task); + } + } + } + + if (!taskView.getTasks().isEmpty()) { + Scene scene = new Scene(taskView); + Stage stage = new Stage(); + taskView.getTasks().addListener((Observable observable) -> + { + if (taskView.getTasks().isEmpty()) { + stage.close(); + } + }); + stage.setScene(scene); + stage.showAndWait(); + } + } + @Override public void addTab(ProjectSettingsTabViewController controller) { tabs.add(controller); diff --git a/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/GlobalSettingsTabViewController.java b/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/GlobalSettingsTabViewController.java index d68501939df07675382c8c8e3b00e02ad73cc37b..daff746be12628d5f8bafcbd01cd254dd914acdf 100644 --- a/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/GlobalSettingsTabViewController.java +++ b/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/GlobalSettingsTabViewController.java @@ -41,27 +41,16 @@ public abstract class GlobalSettingsTabViewController extends ContentViewControl public abstract void saveSettings(GlobalSettings settings); /** - * Gibt <code>true</code> zurück, wenn im Hauptprogramm etwas neu geladen werden muss. Der eigentliche Reload wird in - * {@link #reload(Profile, Project, IMainViewController)} ausgeführt. + * Gibt <code>true</code> zurück, wenn im Hauptprogramm etwas neu geladen werden muss. Der eigentliche Reload wird + * in {@link #reload(Profile, Project, IMainViewController)} ausgeführt. * * @return <code>true</code> Benötigt Reload */ public abstract boolean needReload(); /** - * Lädt gestimmte Einstellungen für die GUI neu. - * - * @param settings - * Aktuelles GlobalSettings - * @param project - * Aktuelles Projekt - * @param controller - * Main View Controller - */ - public void reload(GlobalSettings settings, Project project, IMainViewController controller) {} - - /** - * Prüft ob die eingetragen Einstellungen erlaubt sind. Bei falschen Eingaben können die Einstellungen nicht geschlossen werden. + * Prüft ob die eingetragen Einstellungen erlaubt sind. Bei falschen Eingaben können die Einstellungen nicht + * geschlossen werden. * * @return <code>true</code> Einstellungen erlaubt. <code>false</code> Einstellungen fehlerhaft. */ diff --git a/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/IGlobalReloadTask.java b/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/IGlobalReloadTask.java new file mode 100644 index 0000000000000000000000000000000000000000..1f3cda80a8a376dc4572a7917cefc1b60f4f95f4 --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/IGlobalReloadTask.java @@ -0,0 +1,18 @@ +package de.tobias.playpad.viewcontroller.option; + +import de.tobias.playpad.settings.GlobalSettings; +import de.tobias.playpad.viewcontroller.main.IMainViewController; +import javafx.concurrent.Task; + +/** + * * Schnittstelle, um das ein Task zum Laden der Einstellungen angezeigt werden kann. + * + * @author tobias + * + * @since 5.1.0 + * + */ +public interface IGlobalReloadTask { + + public Task<Void> getTask(GlobalSettings settings, IMainViewController controller); +} diff --git a/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/IProfileReloadTask.java b/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/IProfileReloadTask.java new file mode 100644 index 0000000000000000000000000000000000000000..8506a37a394284791e6ed151914fedcdb75ef811 --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/IProfileReloadTask.java @@ -0,0 +1,19 @@ +package de.tobias.playpad.viewcontroller.option; + +import de.tobias.playpad.project.Project; +import de.tobias.playpad.settings.ProfileSettings; +import de.tobias.playpad.viewcontroller.main.IMainViewController; +import javafx.concurrent.Task; + +/** + * * Schnittstelle, um das ein Task zum Laden der Einstellungen angezeigt werden kann. + * + * @author tobias + * + * @since 5.1.0 + * + */ +public interface IProfileReloadTask { + + public Task<Void> getTask(ProfileSettings settings, Project project, IMainViewController controller); +} diff --git a/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/IProjectReloadTask.java b/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/IProjectReloadTask.java new file mode 100644 index 0000000000000000000000000000000000000000..880c93e1213fd2acbb3ce02d5d8fdde66522ccab --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/IProjectReloadTask.java @@ -0,0 +1,19 @@ +package de.tobias.playpad.viewcontroller.option; + +import de.tobias.playpad.project.Project; +import de.tobias.playpad.project.ProjectSettings; +import de.tobias.playpad.viewcontroller.main.IMainViewController; +import javafx.concurrent.Task; + +/** + * * Schnittstelle, um das ein Task zum Laden der Einstellungen angezeigt werden kann. + * + * @author tobias + * + * @since 5.1.0 + * + */ +public interface IProjectReloadTask { + + public Task<Void> getTask(ProjectSettings settings, Project project, IMainViewController controller); +} diff --git a/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/ProfileSettingsTabViewController.java b/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/ProfileSettingsTabViewController.java index 345e903f580781eff3f5d32689ae6d2e498908fc..36ac6c870f9e2bdfcefbeb0421d2aba9141570a6 100644 --- a/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/ProfileSettingsTabViewController.java +++ b/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/ProfileSettingsTabViewController.java @@ -48,27 +48,16 @@ public abstract class ProfileSettingsTabViewController extends ContentViewContro public abstract void saveSettings(Profile profile); /** - * Gibt <code>true</code> zurück, wenn im Hauptprogramm etwas neu geladen werden muss. Der eigentliche Reload wird in - * {@link #reload(Profile, Project, IMainViewController)} ausgeführt. + * Gibt <code>true</code> zurück, wenn im Hauptprogramm etwas neu geladen werden muss. Der eigentliche Reload wird + * in {@link #reload(Profile, Project, IMainViewController)} ausgeführt. * * @return <code>true</code> Benötigt Reload */ public abstract boolean needReload(); /** - * Lädt gestimmte Einstellungen für die GUI neu. - * - * @param profile - * Aktuelles Profile - * @param project - * Aktuelles Projekt - * @param controller - * Main View Controller - */ - public void reload(Profile profile, Project project, IMainViewController controller) {} - - /** - * Prüft ob die eingetragen Einstellungen erlaubt sind. Bei falschen Eingaben können die Einstellungen nicht geschlossen werden. + * Prüft ob die eingetragen Einstellungen erlaubt sind. Bei falschen Eingaben können die Einstellungen nicht + * geschlossen werden. * * @return <code>true</code> Einstellungen erlaubt. <code>false</code> Einstellungen fehlerhaft. */ diff --git a/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/ProjectSettingsTabViewController.java b/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/ProjectSettingsTabViewController.java index c8db54b8640b575c10303d1bfcef8452a2211175..0f4b33e9383b26ce94cae26baf12f54670534fe2 100644 --- a/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/ProjectSettingsTabViewController.java +++ b/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/ProjectSettingsTabViewController.java @@ -50,27 +50,16 @@ public abstract class ProjectSettingsTabViewController extends ContentViewContro public abstract void saveSettings(ProjectSettings settings); /** - * Gibt <code>true</code> zurück, wenn im Hauptprogramm etwas neu geladen werden muss. Der eigentliche Reload wird in - * {@link #reload(Profile, Project, IMainViewController)} ausgeführt. + * Gibt <code>true</code> zurück, wenn im Hauptprogramm etwas neu geladen werden muss. Der eigentliche Reload wird + * in {@link #reload(Profile, Project, IMainViewController)} ausgeführt. * * @return <code>true</code> Benötigt Reload */ public abstract boolean needReload(); /** - * Lädt gestimmte Einstellungen für die GUI neu. - * - * @param settings - * Aktuelles Project Settings - * @param project - * Aktuelles Projekt - * @param controller - * Main View Controller - */ - public void reload(ProjectSettings settings, Project project, IMainViewController controller) {} - - /** - * Prüft ob die eingetragen Einstellungen erlaubt sind. Bei falschen Eingaben können die Einstellungen nicht geschlossen werden. + * Prüft ob die eingetragen Einstellungen erlaubt sind. Bei falschen Eingaben können die Einstellungen nicht + * geschlossen werden. * * @return <code>true</code> Einstellungen erlaubt. <code>false</code> Einstellungen fehlerhaft. */