diff --git a/PlayWall/assets/de/tobias/playpad/assets/dialog/newProjectDialog.fxml b/PlayWall/assets/de/tobias/playpad/assets/dialog/newProjectDialog.fxml index f209b7e315ec0401af8b174d867a6bc170ea6843..162fda0c62bb99b01d77e2793e70e267bd42093b 100644 --- a/PlayWall/assets/de/tobias/playpad/assets/dialog/newProjectDialog.fxml +++ b/PlayWall/assets/de/tobias/playpad/assets/dialog/newProjectDialog.fxml @@ -13,6 +13,24 @@ <TextField fx:id="nameTextField" prefWidth="200.0" HBox.hgrow="ALWAYS" /> </children> </HBox> + <Separator prefWidth="200.0" /> + <HBox spacing="14.0"> + <children> + <Label alignment="CENTER_RIGHT" minWidth="100.0" prefWidth="100.0" text="%newProject.label.media" /> + <VBox spacing="14.0"> + <children> + <CheckBox fx:id="mediaPathCheckbox" mnemonicParsing="false" text="%newProject.checkbox.mediafolder" /> + <HBox alignment="CENTER_LEFT" spacing="14.0"> + <children> + <Button fx:id="mediaButtonChoose" minWidth="-Infinity" mnemonicParsing="false" onAction="#mediaButtonHandler" text="%newProject.button.media" /> + <Label fx:id="mediaPathLabel" textOverrun="CENTER_ELLIPSIS" HBox.hgrow="ALWAYS" /> + </children> + </HBox> + </children> + </VBox> + </children> + </HBox> + <Separator prefWidth="200.0" /> <HBox alignment="CENTER_LEFT" spacing="14.0"> <children> <Label alignment="CENTER_RIGHT" minWidth="100.0" prefWidth="100.0" text="%newProject.label.profile" HBox.hgrow="NEVER" /> diff --git a/PlayWall/assets/de/tobias/playpad/assets/lang/_de.properties b/PlayWall/assets/de/tobias/playpad/assets/lang/_de.properties index ddbb0286d0c45be64a1a3dcacf60dc4f2f62810b..a6c8a6b2bfe18dce564df0c0f1f690cfd289565b 100644 --- a/PlayWall/assets/de/tobias/playpad/assets/lang/_de.properties +++ b/PlayWall/assets/de/tobias/playpad/assets/lang/_de.properties @@ -65,6 +65,7 @@ UI.Window.Settings.Player.Title=Player UI.Window.Settings.Audio.Title=Audio UI.Window.Settings.Updates.Title=Updates UI.Window.Settings.Keys.Title=Tastaturbefehle +UI.Window.Settings.Paths.Title=Ordner # UI - Settings - Keys UI.Settings.Keys.Conflict.Header=Konflikt @@ -74,7 +75,8 @@ UI.Settings.Keys.Conflict.Content=Es gibt bereits Aktionen, bei denen diese Tast UI.Dialog.NewProfile.Content=Geben Sie einen Namen f�r das neue Profil ein: # UI - Dialog - NewProject -UI.Dialog.NewProject.Content=Geben Sie einen Namen f�r das neue Projekt ein. +UI.Dialog.NewProject.Content=Geben Sie einen Namen f�r das neue Projekt ein: +UI.Dialog.NewProject.MediaPath=Sie m�ssen erst einen Ordner f�r die Mediendateien festlegen, bevor das Projekt erstellt werden kann. # UI - Dialog - Import UI.Dialog.Import.ReplaceProfile.Content=Es gibt bereits eine Profil mit dem Namen {}. Bitte geben Sie einen anderen Namen ein. @@ -143,6 +145,7 @@ Error.Project.Save=Das Projekt {} konnte nicht gespeichert werden. ({}) Error.Project.Rename=Das Projekt konnte nicht umbenannt werden. ({}) Error.Project.Delete=Das Projekt konnte nicht gel�scht werden. ({}) Error.Project.Export=Das Projekt {} konnte nicht exportiert werden. ({}) +Error.Project.MediaPath=Der neue Ordner muss au�erhalb des alten Medienordners liegen. # Error - Pad - Enum Error.Pad.FILE_NOT_FOUND=Die Datei {} konnte nicht gefunden werden. diff --git a/PlayWall/assets/de/tobias/playpad/assets/lang/ui_de.properties b/PlayWall/assets/de/tobias/playpad/assets/lang/ui_de.properties index 743131ffeb32c10365d8f37d3c50d3da483ecdd4..60b6e8199cdf6dc0962bcd1243b5fcb732984e07 100644 --- a/PlayWall/assets/de/tobias/playpad/assets/lang/ui_de.properties +++ b/PlayWall/assets/de/tobias/playpad/assets/lang/ui_de.properties @@ -87,7 +87,11 @@ settings.keys.button.change=Neu settings.keys.button.delete=Verbindung aufheben settings.keys.table.name=Name settings.keys.table.shortcut=Kurzbefehl -settings.keys.textfieldsearch=Suchen... +settings.keys.textfield.search=Suchen... + +settings.paths.label.media=Mediendateien: +settings.paths.button.choose=W�hlen... +settings.paths.checkbox.mediaActive=Mediendateien in Medienordner kopieren (oder am Orgenialpfad lassen) settings.button.finish=Fertig settings.checkbox.activate=Aktivieren @@ -174,6 +178,10 @@ plugin.button.finish=Fertig settings.audio.type=Ausgabe Type w�hlen: newProject.label.name=Name: +newProject.label.media=Media Ordner: +newProject.checkbox.mediafolder=Media Ordner nutzen (Benutze Dateien werden dort hin kopiert) +newProject.button.media=Media Ordner w�hlen + newProject.label.profile=Profil: newProject.button.newProfile=Neues Profil... newProject.button.finish=Projekt erstellen diff --git a/PlayWall/assets/de/tobias/playpad/assets/view/option/global/keysTab.fxml b/PlayWall/assets/de/tobias/playpad/assets/view/option/global/keysTab.fxml index 212bd54968ca3e43d5ead3b8b70c621bcf57ea6d..53e304a2ca82097275dcc20a3149382b430c72a4 100644 --- a/PlayWall/assets/de/tobias/playpad/assets/view/option/global/keysTab.fxml +++ b/PlayWall/assets/de/tobias/playpad/assets/view/option/global/keysTab.fxml @@ -8,7 +8,7 @@ <VBox maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" spacing="14.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"> <children> <Label text="%settings.keys.label.headline" underline="true" /> - <TextField fx:id="searchTextField" promptText="%settings.keys.textfieldsearch" /> + <TextField fx:id="searchTextField" promptText="%settings.keys.textfield.search" /> <TableView fx:id="table" prefHeight="200.0" prefWidth="200.0" VBox.vgrow="ALWAYS"> <columns> <TableColumn fx:id="nameTableColumn" editable="false" prefWidth="378.0" text="%settings.keys.table.name" /> diff --git a/PlayWall/assets/de/tobias/playpad/assets/view/option/project/pathTab.fxml b/PlayWall/assets/de/tobias/playpad/assets/view/option/project/pathTab.fxml new file mode 100644 index 0000000000000000000000000000000000000000..1929289e8115c9135468c201d11e071917ee1b8c --- /dev/null +++ b/PlayWall/assets/de/tobias/playpad/assets/view/option/project/pathTab.fxml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.geometry.*?> +<?import javafx.scene.control.*?> +<?import java.lang.*?> +<?import javafx.scene.layout.*?> + +<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" spacing="14.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"> + <children> + <HBox alignment="CENTER_LEFT" spacing="14.0"> + <children> + <Label prefWidth="150.0" text="%settings.paths.label.media" /> + <TextField fx:id="mediaPathTextField" editable="false" HBox.hgrow="ALWAYS" /> + <Button fx:id="mediaPathChooseButton" mnemonicParsing="false" onAction="#mediaPathChooseHandler" text="%settings.paths.button.choose" /> + </children> + </HBox> + <HBox spacing="14.0"> + <children> + <CheckBox fx:id="useMediaPath" mnemonicParsing="false" text="%settings.paths.checkbox.mediaActive"> + <HBox.margin> + <Insets left="164.0" /> + </HBox.margin> + </CheckBox> + </children> + </HBox> + </children> + <padding> + <Insets bottom="14.0" left="14.0" right="14.0" top="14.0" /> + </padding> +</VBox> diff --git a/PlayWall/src/de/tobias/playpad/Strings.java b/PlayWall/src/de/tobias/playpad/Strings.java index f74fa5674aece104c8cd025d208372b9fe745e06..c8bbdc92a51d05fc1ba435420fba392675835475 100644 --- a/PlayWall/src/de/tobias/playpad/Strings.java +++ b/PlayWall/src/de/tobias/playpad/Strings.java @@ -62,6 +62,7 @@ public class Strings { public static final String UI_Window_Settings_Audio_Title = "UI.Window.Settings.Audio.Title"; public static final String UI_Window_Settings_Updates_Title = "UI.Window.Settings.Updates.Title"; public static final String UI_Window_Settings_Keys_Title = "UI.Window.Settings.Keys.Title"; + public static final String UI_Window_Settings_Paths_Title = "UI.Window.Settings.Paths.Title"; // UI - Settings - Keys public static final String UI_Settings_Keys_Conflict_Header = "UI.Settings.Keys.Conflict.Header"; @@ -71,7 +72,8 @@ public class Strings { public static final String UI_Dialog_NewProfile_Content = "UI.Dialog.NewProfile.Content"; // UI - Dialog - NewProject - public static final String UI_Dialog_NewProject_Content = "UI.Dialog.NewProject.Content"; + public static final String UI_Dialog_NewProject_Content = "UI.Dialog.NewProject.Content"; // Duplicate Project + public static final String UI_Dialog_NewProject_Media = "UI.Dialog.NewProject.MediaPath"; // Create Project // UI - Dialog - Import public static final String UI_Dialog_Import_ReplaceProfile_Content = "UI.Dialog.Import.ReplaceProfile.Content"; @@ -140,6 +142,7 @@ public class Strings { public static final String Error_Project_Rename = "Error.Project.Rename"; public static final String Error_Project_Delete = "Error.Project.Delete"; public static final String Error_Project_Export = "Error.Project.Export"; + public static final String Error_Project_MediaPath = "Error.Project.MediaPath"; // Error - Pad public static final String Error_Pad_BaseName = "Error.Pad."; @@ -200,7 +203,7 @@ public class Strings { public static final String UI_Dialog_AutoUpdate_Header = "UI.Dialog.AutoUpdate.Header"; public static final String UI_Dialog_AutoUpdate_Content = "UI.Dialog.AutoUpdate.Content"; public static final String UI_Dialog_AutoUpdate_Checkbox = "UI.Dialog.AutoUpdate.Checkbox"; - public static final String UI_Dialog_AutoUpdate_Title= "UI.Dialog.AutoUpdate.Title"; + public static final String UI_Dialog_AutoUpdate_Title = "UI.Dialog.AutoUpdate.Title"; public static final String UI_Dialog_AutoUpdate_Butto_Update = "UI.Dialog.AutoUpdate.Butto.Update"; public static final String UI_Dialog_AutoUpdate_Butto_Cancel = "UI.Dialog.AutoUpdate.Butto.Cancel"; diff --git a/PlayWall/src/de/tobias/playpad/audio/JavaFXAudioHandler.java b/PlayWall/src/de/tobias/playpad/audio/JavaFXAudioHandler.java index d961972a6eec022d974274e512c2ca2e2ccd6cc4..f9c5a4651d921efb605128d8810b0c5558da32e6 100644 --- a/PlayWall/src/de/tobias/playpad/audio/JavaFXAudioHandler.java +++ b/PlayWall/src/de/tobias/playpad/audio/JavaFXAudioHandler.java @@ -91,8 +91,7 @@ public class JavaFXAudioHandler extends AudioHandler implements Equalizable { @Override public void loadMedia(Path[] paths) { - Platform.runLater(() -> - { + Platform.runLater(() -> { if (getContent().getPad().isPadVisible()) { getContent().getPad().getController().getView().showBusyView(true); } @@ -108,24 +107,20 @@ public class JavaFXAudioHandler extends AudioHandler implements Equalizable { player = new MediaPlayer(media); // Player Listener - player.setOnReady(() -> - { + player.setOnReady(() -> { durationProperty.set(player.getTotalDuration()); getContent().getPad().setStatus(PadStatus.READY); loadedProperty.set(true); - Platform.runLater(() -> - { + Platform.runLater(() -> { if (getContent().getPad().isPadVisible()) { getContent().getPad().getController().getView().showBusyView(false); } }); }); - player.setOnError(() -> - { - Platform.runLater(() -> - { + player.setOnError(() -> { + Platform.runLater(() -> { if (getContent().getPad().isPadVisible()) { getContent().getPad().getController().getView().showBusyView(false); } @@ -133,8 +128,7 @@ public class JavaFXAudioHandler extends AudioHandler implements Equalizable { loadedProperty.set(false); getContent().getPad().throwException(path, player.getError()); }); - player.setOnEndOfMedia(() -> - { + player.setOnEndOfMedia(() -> { if (!getContent().getPad().getPadSettings().isLoop()) { getContent().getPad().setEof(true); getContent().getPad().setStatus(PadStatus.STOP); @@ -147,6 +141,8 @@ public class JavaFXAudioHandler extends AudioHandler implements Equalizable { @Override public void unloadMedia() { + if (player != null) + player.dispose(); player = null; media = null; durationProperty.set(null); diff --git a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMenuToolbarViewController.java b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMenuToolbarViewController.java index 3b6b7e0c9aa9347c84d92f00ccc325da0367250b..1d58a7655dd299e8971bc61662671b14a2704709 100644 --- a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMenuToolbarViewController.java +++ b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMenuToolbarViewController.java @@ -31,6 +31,7 @@ import de.tobias.playpad.settings.keys.KeyCollection; import de.tobias.playpad.view.HelpMenuItem; import de.tobias.playpad.view.main.MainLayoutConnect; import de.tobias.playpad.view.main.MenuType; +import de.tobias.playpad.viewcontroller.dialog.ErrorSummaryDialog; import de.tobias.playpad.viewcontroller.dialog.ImportDialog; import de.tobias.playpad.viewcontroller.dialog.NewProjectDialog; import de.tobias.playpad.viewcontroller.dialog.PluginViewController; @@ -39,9 +40,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; @@ -444,7 +442,7 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro @FXML void errorMenuHandler(ActionEvent event) { - // TODO Implement + ErrorSummaryDialog.getInstance().getStage().show(); } @FXML @@ -458,7 +456,6 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro @FXML void projectSettingsHandler(ActionEvent event) { - Midi midi = Midi.getInstance(); Project currentProject = PlayPadMain.getProgramInstance().getCurrentProject(); if (projectSettingsViewController == null) { @@ -466,15 +463,7 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro Runnable onFinish = () -> { - midi.setListener(mainViewController.getMidiHandler()); - - for (ProjectSettingsTabViewController controller : projectSettingsViewController.getTabs()) { - if (controller.needReload()) { - controller.reload(currentProject.getSettings(), currentProject, mainViewController); - } - } - - profileSettingsViewController = null; + projectSettingsViewController = null; mainStage.toFront(); }; @@ -506,18 +495,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(); }; @@ -538,15 +515,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/layout/desktop/DesktopPadViewController.java b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopPadViewController.java index e58c3935c028df526f9f80d8cc377db691955956..4b8ad7f5d8e78a4ec3202bf26d02b0c11a6a61ce 100644 --- a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopPadViewController.java +++ b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopPadViewController.java @@ -1,6 +1,7 @@ package de.tobias.playpad.layout.desktop; import java.io.File; +import java.io.IOException; import java.nio.file.Path; import java.util.Set; @@ -246,7 +247,7 @@ public class DesktopPadViewController implements IPadViewControllerV2, EventHand try { content.handlePath(file.toPath()); - } catch (NoSuchComponentException e) { + } catch (NoSuchComponentException | IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } diff --git a/PlayWall/src/de/tobias/playpad/pad/content/AudioContent.java b/PlayWall/src/de/tobias/playpad/pad/content/AudioContent.java index f9fc5e94ad102fa570dab5350a4af038004894ff..5983e6d5c7086995533cd2fe33a81feccf60935d 100644 --- a/PlayWall/src/de/tobias/playpad/pad/content/AudioContent.java +++ b/PlayWall/src/de/tobias/playpad/pad/content/AudioContent.java @@ -1,6 +1,7 @@ package de.tobias.playpad.pad.content; import java.io.FileNotFoundException; +import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -69,11 +70,11 @@ public class AudioContent extends PadContent implements Pauseable, Durationable, } @Override - public void handlePath(Path path) throws NoSuchComponentException { + public void handlePath(Path path) throws NoSuchComponentException, IOException { // handle old media unloadMedia(); - this.path = path; + this.path = getRealPath(path); // handle new media loadMedia(); diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/NewProjectDialog.java b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/NewProjectDialog.java index 3a887b229e59c956c3f867761ca6f30de3e581af..47352aa2fb1383ef5cc6ab84be004c91033714d5 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/NewProjectDialog.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/NewProjectDialog.java @@ -1,6 +1,8 @@ package de.tobias.playpad.viewcontroller.dialog; +import java.io.File; import java.io.IOException; +import java.nio.file.Path; import java.util.UUID; import org.dom4j.DocumentException; @@ -17,8 +19,11 @@ import de.tobias.utils.util.Localization; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.control.Button; +import javafx.scene.control.CheckBox; import javafx.scene.control.ComboBox; +import javafx.scene.control.Label; import javafx.scene.control.TextField; +import javafx.stage.DirectoryChooser; import javafx.stage.Modality; import javafx.stage.Stage; import javafx.stage.Window; @@ -35,10 +40,16 @@ public class NewProjectDialog extends ViewController { @FXML private ComboBox<ProfileReference> profileComboBox; @FXML private Button newProfileButton; + // Media Path + @FXML private CheckBox mediaPathCheckbox; + @FXML private Button mediaButtonChoose; + @FXML private Label mediaPathLabel; + @FXML private Button finishButton; @FXML private Button cancelButton; private Project project; + private Path newMediaPath; // Ausgewählter Ordner (temp) public NewProjectDialog(Window owner) { super("newProjectDialog", "de/tobias/playpad/assets/dialog/", null, PlayPadMain.getUiResourceBundle()); @@ -66,6 +77,16 @@ public class NewProjectDialog extends ViewController { }); finishButton.setDisable(true); + mediaPathCheckbox.selectedProperty().addListener((a, b, c) -> + { + mediaButtonChoose.setDisable(!c); + if (!c) { + mediaPathLabel.setText(""); + newMediaPath = null; + } + }); + mediaButtonChoose.setDisable(true); + addCloseKeyShortcut(() -> getStage().close()); } @@ -75,10 +96,10 @@ public class NewProjectDialog extends ViewController { stage.setTitle(Localization.getString(Strings.UI_Dialog_NewProject_Title)); stage.setWidth(560); - stage.setHeight(250); + stage.setHeight(380); stage.setMinWidth(560); - stage.setMinHeight(250); + stage.setMinHeight(380); stage.setMaxWidth(560); @@ -87,17 +108,34 @@ public class NewProjectDialog extends ViewController { } } + @FXML + private void mediaButtonHandler(ActionEvent event) { + if (mediaPathCheckbox.isSelected()) { + DirectoryChooser chooser = new DirectoryChooser(); + File file = chooser.showDialog(getStage()); + if (file != null) { + newMediaPath = file.toPath(); + mediaPathLabel.setText(newMediaPath.toString()); + } + } + } + @FXML private void finishButtonHandler(ActionEvent evenet) { + if (mediaPathCheckbox.isSelected() && newMediaPath == null) { + showInfoMessage(Localization.getString(Strings.UI_Dialog_NewProject_Content)); + return; + } + try { Profile profile = Profile.load(profileComboBox.getSelectionModel().getSelectedItem()); - String name = nameTextField.getText(); UUID uuid = UUID.randomUUID(); ProjectReference projectReference = new ProjectReference(uuid, name, profile.getRef()); - project = new Project(projectReference); + project.getSettings().setUseMediaPath(mediaPathCheckbox.isSelected()); + project.getSettings().setMediaPath(newMediaPath); project.save(); ProjectReference.addProject(projectReference); diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/main/MainViewControllerV2.java b/PlayWall/src/de/tobias/playpad/viewcontroller/main/MainViewControllerV2.java index 365d35bf5a8da9221687645b99e365376fea0f40..d84bcfc58f5804ce43a61e758813722d3b75f1de 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/main/MainViewControllerV2.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/main/MainViewControllerV2.java @@ -31,6 +31,7 @@ import de.tobias.playpad.settings.ProfileSettings; import de.tobias.playpad.settings.keys.KeyCollection; import de.tobias.playpad.view.main.MainLayoutConnect; import de.tobias.playpad.view.main.MainLayoutHandler; +import de.tobias.playpad.viewcontroller.dialog.ErrorSummaryDialog; import de.tobias.playpad.viewcontroller.pad.PadDragListener; import de.tobias.utils.ui.BasicControllerSettings; import de.tobias.utils.ui.NotificationHandler; @@ -103,6 +104,9 @@ public class MainViewControllerV2 extends ViewController implements IMainViewCon super("mainViewV2", "de/tobias/playpad/assets/view/main/", null, PlayPadMain.getUiResourceBundle()); padViews = new ArrayList<>(); + // Init ErrorSummaryViewController + new ErrorSummaryDialog(getStage()); // Instance in ErrorSummaryViewController.getInstance() + // Layout Init layoutActions = new ArrayList<>(); @@ -118,8 +122,7 @@ public class MainViewControllerV2 extends ViewController implements IMainViewCon reloadSettings(null, Profile.currentProfile()); // Wenn sich die Toolbar ändert werden die Button neu erstellt. Das ist hier, weil es nur einmal als Listener da - // sein muss. Die - // Methode wird aber an unterschiedlichen stellen mehrmals aufgerufen + // sein muss. Die Methode wird aber an unterschiedlichen stellen mehrmals aufgerufen performLayoutDependendAction((oldToolbar, newToolbar) -> { if (menuToolbarViewController != null) @@ -272,7 +275,7 @@ public class MainViewControllerV2 extends ViewController implements IMainViewCon @Override public boolean closeRequest() { - // TODO Close Error Window + ErrorSummaryDialog.getInstance().getStage().close(); if (Profile.currentProfile() != null) { ProfileSettings profilSettings = Profile.currentProfile().getProfileSettings(); @@ -388,6 +391,7 @@ public class MainViewControllerV2 extends ViewController implements IMainViewCon midiHandler.setProject(project); keyboardHandler.setProject(project); PadDragListener.setProject(project); + ErrorSummaryDialog.getInstance().setProject(openProject); menuToolbarViewController.setOpenProject(openProject); 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 7174491636a0a1767f83bb9fb5195f045791d0b3..e7551ff2c858cff00df4d0e07478cc898948bfec 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/global/GlobalSettingsViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/global/GlobalSettingsViewController.java @@ -3,18 +3,27 @@ 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.playpad.viewcontroller.option.profile.GeneralTabViewController; 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; @@ -120,9 +129,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 db63105828e12ced20b8e68e9e06577c7a3ddecb..58f00e1ddc268cb85ca0b0abbe8a423682efe2df 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/global/KeysTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/global/KeysTabViewController.java @@ -3,12 +3,12 @@ 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.settings.keys.KeyCollection; 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; @@ -16,6 +16,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; @@ -32,7 +33,7 @@ import javafx.scene.input.KeyCode; import javafx.stage.Modality; import javafx.stage.Stage; -public class KeysTabViewController extends GlobalSettingsTabViewController { +public class KeysTabViewController extends GlobalSettingsTabViewController implements IGlobalReloadTask { @FXML private TextField searchTextField; @@ -177,8 +178,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 1972fd9b8b99293d4375a2a6f854946a16ec656e..e83f9a002ea0c3e33e757e3d006526d0b062a5b4 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.AudioHandlerViewController; 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..d0585f047370d9990842adf8841c03fa03fe450e 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,20 @@ 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.application.Platform; +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 +72,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 +85,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); + + Platform.runLater(() -> 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 9b74262ca0f66055a466242eae158eefbfc3e057..ae379cc3e200dd8050a7ae2e9e41885f9874b7bb 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,20 @@ 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.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; @@ -158,9 +166,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 IProfileReloadTask) { + 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 new file mode 100644 index 0000000000000000000000000000000000000000..f755db2f957ed176db10b58954a8e7fb724b929c --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/PathsTabViewController.java @@ -0,0 +1,177 @@ +package de.tobias.playpad.viewcontroller.option.project; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.util.List; +import java.util.Optional; + +import de.tobias.playpad.PlayPadMain; +import de.tobias.playpad.Strings; +import de.tobias.playpad.pad.Pad; +import de.tobias.playpad.pad.PadStatus; +import de.tobias.playpad.pad.conntent.PadContent; +import de.tobias.playpad.pad.conntent.path.MultiPathContent; +import de.tobias.playpad.pad.conntent.path.SinglePathContent; +import de.tobias.playpad.project.Project; +import de.tobias.playpad.project.ProjectSettings; +import de.tobias.playpad.registry.NoSuchComponentException; +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.util.FileUtils; +import de.tobias.utils.util.Localization; +import javafx.application.Platform; +import javafx.concurrent.Task; +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.scene.control.Button; +import javafx.scene.control.CheckBox; +import javafx.scene.control.TextField; +import javafx.stage.DirectoryChooser; + +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; + private transient Optional<Path> currentMediaPath = Optional.empty(); + private transient Optional<Path> oldMediaPath = Optional.empty(); + + public PathsTabViewController() { + super("pathTab.fxml", "de/tobias/playpad/assets/view/option/project/", PlayPadMain.getUiResourceBundle()); + } + + @FXML + void mediaPathChooseHandler(ActionEvent event) { + DirectoryChooser chooser = new DirectoryChooser(); + File folder = chooser.showDialog(getStage()); + if (folder != null) { + Path path = folder.toPath(); + + if (currentMediaPath.isPresent()) { + boolean subDirectory = FileUtils.isSubDirectory(currentMediaPath.get(), path); + if (subDirectory) { + showErrorMessage(Localization.getString(Strings.Error_Project_MediaPath)); + return; + } + } + + mediaPathTextField.setText(path.toString()); + } + } + + @Override + public void loadSettings(ProjectSettings settings) { + if (settings.isUseMediaPath()) { + mediaPathTextField.setText(settings.getMediaPath().toString()); + currentMediaPath = Optional.of(settings.getMediaPath()); + } + useMediaPath.setSelected(settings.isUseMediaPath()); + + } + + @Override + public void saveSettings(ProjectSettings settings) { + Path newPath = Paths.get(mediaPathTextField.getText()); + if (settings.getMediaPath() != null) { + if (!settings.getMediaPath().equals(newPath)) { + if (settings.getMediaPath() != null && !settings.getMediaPath().toString().isEmpty()) { + changedMediaPath = true; + oldMediaPath = Optional.of(settings.getMediaPath()); + } + } + } + if (useMediaPath.isSelected()) { + settings.setMediaPath(newPath); + } + settings.setUseMediaPath(useMediaPath.isSelected()); + } + + @Override + public boolean validSettings() { + return true; + } + + @Override + public String name() { + return Localization.getString(Strings.UI_Window_Settings_Paths_Title); + } + + // 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()); + Path newMediaPath = settings.getMediaPath(); + + project.closeFile(); + + for (Pad pad : project.getPads().values()) { + try { + if (pad.getStatus() != PadStatus.EMPTY) { + PadContent content = pad.getContent(); + if (content instanceof SinglePathContent) { + Path path = ((SinglePathContent) content).getPath(); + Path copiedFile = newMediaPath.resolve(path.getFileName()); + + Files.copy(path, copiedFile, StandardCopyOption.REPLACE_EXISTING); + + Platform.runLater(() -> + { + try { + content.handlePath(copiedFile); + } catch (NoSuchComponentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + }); + } else if (content instanceof MultiPathContent) { + MultiPathContent pathHandler = (MultiPathContent) content; + List<Path> paths = pathHandler.getPaths(); + // TEST handle Paths in PadContent + + pathHandler.clearPaths(); + + for (Path path : paths) { + Path copiedFile = newMediaPath.resolve(path.getFileName()); + + Files.copy(path, copiedFile, StandardCopyOption.REPLACE_EXISTING); + content.handlePath(copiedFile); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + if (oldMediaPath.isPresent()) + try { + FileUtils.deleteDirectory(oldMediaPath.get()); + } catch (IOException e) { + e.printStackTrace(); + } + 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 455df6387579b36758fa7a28dc6cbf4a5ed3ae4d..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,22 +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 @@ -60,7 +70,7 @@ public class ProjectSettingsViewController extends ViewController implements IPr PlayPadMain.stageIcon.ifPresent(stage.getIcons()::add); stage.setMinWidth(715); - stage.setMinHeight(700); + stage.setMinHeight(500); stage.setTitle(Localization.getString(Strings.UI_Window_GlobalSettings_Title)); Profile.currentProfile().currentLayout().applyCss(getStage()); @@ -70,7 +80,6 @@ public class ProjectSettingsViewController extends ViewController implements IPr * Zeigt die aktuellen Einstellungen für die Tabs an. */ private void loadTabs(ProjectSettings settings) { - for (ProjectSettingsTabViewController controller : tabs) { controller.loadSettings(settings); } @@ -85,6 +94,7 @@ public class ProjectSettingsViewController extends ViewController implements IPr } } + @Override public boolean closeRequest() { return onFinish(); } @@ -108,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/PlayWall/src/de/tobias/playpad/viewcontroller/pad/PadDragListener.java b/PlayWall/src/de/tobias/playpad/viewcontroller/pad/PadDragListener.java index 9a43a47f5d3b897e07aa2adf78146ea3f760f8cf..39b3ccfd6c2a3b3c3be5cd36973a9e608d995dfe 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/pad/PadDragListener.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/pad/PadDragListener.java @@ -1,6 +1,7 @@ package de.tobias.playpad.viewcontroller.pad; import java.io.File; +import java.io.IOException; import java.util.Collection; import java.util.Set; @@ -135,7 +136,7 @@ public class PadDragListener { try { content.handlePath(file.toPath()); - } catch (NoSuchComponentException e) { + } catch (NoSuchComponentException | IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } diff --git a/PlayWallCore/src/de/tobias/playpad/pad/conntent/PadContent.java b/PlayWallCore/src/de/tobias/playpad/pad/conntent/PadContent.java index 5e8df0ee7a58a6c0beb59751d29896c069b57a64..f0c6f6e74533e0cecab21db1b6a77887f808e4e7 100644 --- a/PlayWallCore/src/de/tobias/playpad/pad/conntent/PadContent.java +++ b/PlayWallCore/src/de/tobias/playpad/pad/conntent/PadContent.java @@ -1,10 +1,14 @@ package de.tobias.playpad.pad.conntent; +import java.io.IOException; +import java.nio.file.Files; import java.nio.file.Path; +import java.nio.file.StandardCopyOption; import org.dom4j.Element; import de.tobias.playpad.pad.Pad; +import de.tobias.playpad.project.ProjectSettings; import de.tobias.playpad.registry.NoSuchComponentException; import de.tobias.utils.util.ZipFile; @@ -43,15 +47,19 @@ public abstract class PadContent { * @param path * path * @throws NoSuchComponentException - * Wird geworfen, wenn ein Pad eine Componenten nicht laden kann. Beispiel bei Audio das richtige Soundsystem + * Wird geworfen, wenn ein Pad eine Componenten nicht laden kann. Beispiel bei Audio das richtige + * Soundsystem + * @throws IOException + * IO Fehler */ - public abstract void handlePath(Path path) throws NoSuchComponentException; + public abstract void handlePath(Path path) throws NoSuchComponentException, IOException; /** * Lädt die Medien, sodass sie auf abruf verfügbar sind. * * @throws NoSuchComponentException - * Wird geworfen, wenn ein Pad eine Componenten nicht laden kann. Beispiel bei Audio das richtige Soundsystem + * Wird geworfen, wenn ein Pad eine Componenten nicht laden kann. Beispiel bei Audio das richtige + * Soundsystem */ public abstract void loadMedia() throws NoSuchComponentException; @@ -86,4 +94,30 @@ public abstract class PadContent { public abstract void exportMedia(ZipFile zip, Element element); + /** + * Gibt den richtigen Pfad einer Datei zurück, basierend auf den Einstellungen. + * + * @param orrginal + * orginal path + * @return new path + * @throws IOException + * IO Fehler + * @since 5.1.0 + */ + public Path getRealPath(Path orginal) throws IOException { + ProjectSettings settings = getPad().getProject().getSettings(); + if (settings.isUseMediaPath()) { + Path mediaFolder = settings.getMediaPath(); + Path newPath = mediaFolder.resolve(orginal.getFileName()); + + if (Files.notExists(mediaFolder)) { + Files.createDirectories(mediaFolder); + } + + Files.copy(orginal, newPath, StandardCopyOption.REPLACE_EXISTING); + return newPath; + } + return orginal; + } + } \ No newline at end of file diff --git a/PlayWallCore/src/de/tobias/playpad/pad/conntent/path/MultiPathContent.java b/PlayWallCore/src/de/tobias/playpad/pad/conntent/path/MultiPathContent.java index 6f62b246257d96bda64073465dfe142b0bacf455..e10aa8b85e4e09a56b0e53e810fe03b8700bace9 100644 --- a/PlayWallCore/src/de/tobias/playpad/pad/conntent/path/MultiPathContent.java +++ b/PlayWallCore/src/de/tobias/playpad/pad/conntent/path/MultiPathContent.java @@ -6,4 +6,6 @@ import java.util.List; public interface MultiPathContent { public List<Path> getPaths(); + + public void clearPaths(); } diff --git a/PlayWallCore/src/de/tobias/playpad/project/Project.java b/PlayWallCore/src/de/tobias/playpad/project/Project.java index bdbb2b48c3d8729b5b6c8407da11392e937896b2..3baccb5b62dc8b132692af7a6f3ec9bd1c554533 100644 --- a/PlayWallCore/src/de/tobias/playpad/project/Project.java +++ b/PlayWallCore/src/de/tobias/playpad/project/Project.java @@ -151,7 +151,8 @@ public class Project { if (ref.getProfileReference() != null) { Profile.load(ref.getProfileReference()); // Lädt das entsprechende Profile und aktiviert es } else { - Profile profile = profileChooseable.getUnkownProfile(); // Lädt Profile / Erstellt neues und hat es gleich im Speicher + Profile profile = profileChooseable.getUnkownProfile(); // Lädt Profile / Erstellt neues und hat es + // gleich im Speicher ref.setProfileReference(profile.getRef()); } @@ -274,4 +275,12 @@ public class Project { public int getPadCount() { return pads.size(); } + + public void closeFile() { + pads.values().forEach(pad -> + { + if (pad.getContent() != null) + pad.getContent().unloadMedia(); + }); + } } diff --git a/PlayWallCore/src/de/tobias/playpad/project/ProjectSettings.java b/PlayWallCore/src/de/tobias/playpad/project/ProjectSettings.java index 36bff9faf9d91baac19e74b26be963bf73a742b9..31e1cc9e2a50f208f91ee9065d44a8aa7c44b371 100644 --- a/PlayWallCore/src/de/tobias/playpad/project/ProjectSettings.java +++ b/PlayWallCore/src/de/tobias/playpad/project/ProjectSettings.java @@ -1,5 +1,8 @@ package de.tobias.playpad.project; +import java.nio.file.Path; +import java.nio.file.Paths; + import org.dom4j.Element; import de.tobias.utils.settings.Storable; @@ -14,6 +17,9 @@ public class ProjectSettings { @Storable private int columns = 6; @Storable private int rows = 5; + private boolean useMediaPath = false; + private Path mediaPath = null; + public int getPageCount() { return pageCount; } @@ -36,6 +42,14 @@ public class ProjectSettings { return rows; } + public Path getMediaPath() { + return mediaPath; + } + + public boolean isUseMediaPath() { + return useMediaPath; + } + public void setPageCount(int pageCount) { if (pageCount > MAX_PAGES) pageCount = MAX_PAGES; @@ -54,10 +68,21 @@ public class ProjectSettings { this.rows = rows; } + public void setMediaPath(Path mediaPath) { + this.mediaPath = mediaPath; + } + + public void setUseMediaPath(boolean useMediaPath) { + this.useMediaPath = useMediaPath; + } + private static final String ROWS_ELEMENT = "Rows"; private static final String COLUMNS_ELEMENT = "Columns"; private static final String PAGE_COUNT_ELEMENT = "PageCount"; + private static final String MEDIA_PATH_ELEMENT = "MediaPath"; + private static final String MEDIA_PATH_ACTIVE_ATTR = "active"; + public static ProjectSettings load(Element element) { ProjectSettings settings = new ProjectSettings(); if (element.element(PAGE_COUNT_ELEMENT) != null) @@ -67,6 +92,12 @@ public class ProjectSettings { if (element.element(ROWS_ELEMENT) != null) settings.setRows(Integer.valueOf(element.element(ROWS_ELEMENT).getStringValue())); + Element mediaElement = element.element(MEDIA_PATH_ELEMENT); + if (mediaElement != null) { + settings.setMediaPath(Paths.get(mediaElement.getStringValue())); + settings.setUseMediaPath(Boolean.valueOf(mediaElement.attributeValue(MEDIA_PATH_ACTIVE_ATTR))); + } + return settings; } @@ -74,5 +105,10 @@ public class ProjectSettings { element.addElement(PAGE_COUNT_ELEMENT).addText(String.valueOf(pageCount)); element.addElement(COLUMNS_ELEMENT).addText(String.valueOf(columns)); element.addElement(ROWS_ELEMENT).addText(String.valueOf(rows)); + + Element mediaPath = element.addElement(MEDIA_PATH_ELEMENT); + if (this.mediaPath != null) + mediaPath.addText(this.mediaPath.toString()); + mediaPath.addAttribute(MEDIA_PATH_ACTIVE_ATTR, String.valueOf(useMediaPath)); } } 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. */ diff --git a/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/image/ImageContent.java b/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/image/ImageContent.java index 2aacbe894c4c1683e45cce88f0089b1ba7a26475..9c310081e55225e2ea8fd37d05ddd2526ef9c891 100644 --- a/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/image/ImageContent.java +++ b/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/image/ImageContent.java @@ -1,6 +1,7 @@ package de.tobias.playpad.mediaplugin.image; import java.io.FileNotFoundException; +import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -37,14 +38,15 @@ public class ImageContent extends PadContent { } @Override - public void handlePath(Path path) { + public void handlePath(Path path) throws IOException { unloadMedia(); - setPath(path); + setPath(getRealPath(path)); loadMedia(); } @Override - public void setMasterVolume(double masterVolume) {} + public void setMasterVolume(double masterVolume) { + } @Override public String getType() { diff --git a/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/main/impl/MediaSettingsTabViewController.java b/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/main/impl/MediaSettingsTabViewController.java index 8fc2e1df62a431ddc0152c9075458638119e28b7..d3451a5e691f47b44b6fc4d628be9cc9ef9f3c64 100644 --- a/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/main/impl/MediaSettingsTabViewController.java +++ b/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/main/impl/MediaSettingsTabViewController.java @@ -7,8 +7,11 @@ import java.util.ResourceBundle; import de.tobias.playpad.mediaplugin.main.VideoSettings; 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.IProfileReloadTask; import de.tobias.playpad.viewcontroller.option.ProfileSettingsTabViewController; +import javafx.concurrent.Task; import javafx.fxml.FXML; import javafx.scene.control.CheckBox; import javafx.scene.control.ComboBox; @@ -19,7 +22,7 @@ import javafx.scene.paint.Color; import javafx.scene.shape.Rectangle; import javafx.stage.Screen; -public class MediaSettingsTabViewController extends ProfileSettingsTabViewController { +public class MediaSettingsTabViewController extends ProfileSettingsTabViewController implements IProfileReloadTask { @FXML private Pane screenViewPane; @FXML private ComboBox<Integer> screenComboBox; @@ -118,13 +121,22 @@ public class MediaSettingsTabViewController extends ProfileSettingsTabViewContro } @Override - public void reload(Profile profile, Project project, IMainViewController controller) { - MediaPluginImpl.getInstance().getVideoViewController().reloadSettings(); + public boolean validSettings() { + return true; } @Override - public boolean validSettings() { - return true; + public Task<Void> getTask(ProfileSettings settings, Project project, IMainViewController controller) { + return new Task<Void>() { + @Override + protected Void call() throws Exception { + updateProgress(-1, -1); + updateTitle(name()); + + MediaPluginImpl.getInstance().getVideoViewController().reloadSettings(); + return null; + } + }; } @Override diff --git a/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/video/VideoContent.java b/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/video/VideoContent.java index 5e5a41d2ebe57715a5140edab8251b7447ee0df7..b4a36a3aac7c1defa53feeed5d9985fc40a6292c 100644 --- a/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/video/VideoContent.java +++ b/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/video/VideoContent.java @@ -1,5 +1,6 @@ package de.tobias.playpad.mediaplugin.video; +import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -70,9 +71,9 @@ public class VideoContent extends PadContent implements Pauseable, Durationable } @Override - public void handlePath(Path path) { + public void handlePath(Path path) throws IOException { unloadMedia(); - setPath(path); + setPath(getRealPath(path)); loadMedia(); }