diff --git a/PlayWall/.classpath b/PlayWall/.classpath index d6c36775992856017bbd4f040c3ad7f1dbb44b5d..a8ad48e81f02fb008bf288df3ca4de61c39311b2 100644 --- a/PlayWall/.classpath +++ b/PlayWall/.classpath @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry excluding="**/.DS_Store|**/.gitignore|icon.icns|icon.ico|de/tobias/playpad/viewcontroller/main/MainMenuBarController.java|de/tobias/playpad/viewcontroller/main/MainToolbarController.java|de/tobias/playpad/viewcontroller/main/MainViewController.java|de/tobias/playpad/viewcontroller/pad/PadViewController.java|de/tobias/playpad/view/PadView.java" kind="src" path="src"/> + <classpathentry excluding="**/.DS_Store|**/.gitignore|de/tobias/playpad/view/PadView.java|de/tobias/playpad/viewcontroller/pad/PadViewController.java|icon.icns|icon.ico" kind="src" path="src"/> <classpathentry excluding="**/.gitignor|de/tobias/playpad/assets/files/dialogDnD.pxm" kind="src" path="assets"/> <classpathentry kind="src" path="test"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> @@ -8,6 +8,7 @@ <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/XML"/> <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/YML"/> <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/HTML Builder"/> + <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/JNA"/> <classpathentry combineaccessrules="false" kind="src" path="/libUtils"/> <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/Plugins"/> <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/TinySound"/> 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/dialog/project/openDialog.fxml b/PlayWall/assets/de/tobias/playpad/assets/dialog/project/openDialog.fxml index f5055c1aab8683e19be3be2e3face7f8b276b2f4..256e734cd33b06858e49ef69264824019c8b02b8 100644 --- a/PlayWall/assets/de/tobias/playpad/assets/dialog/project/openDialog.fxml +++ b/PlayWall/assets/de/tobias/playpad/assets/dialog/project/openDialog.fxml @@ -24,13 +24,13 @@ <children> <VBox spacing="14.0"> <children> - <Label text="%project.label.fileSize" /> + <Label text="%project.label.profile" /> <Label text="%project.label.lastModified" /> </children> </VBox> <VBox spacing="14.0"> <children> - <Label fx:id="sizeLabel" text="100 MB" /> + <Label fx:id="profileLabel" text="Default" /> <Label fx:id="dateLabel" text="20. Dez 2015 19:45" /> </children> </VBox> diff --git a/PlayWall/assets/de/tobias/playpad/assets/lang/_de.properties b/PlayWall/assets/de/tobias/playpad/assets/lang/_de.properties index 9d1ef416099bc0f14fe5a98243cfd5bf81b02e33..cae2209260275be3c7b92c311c6080f0156b0ed4 100644 --- a/PlayWall/assets/de/tobias/playpad/assets/lang/_de.properties +++ b/PlayWall/assets/de/tobias/playpad/assets/lang/_de.properties @@ -8,7 +8,7 @@ Standard.Time.Seconds={} sek Standard.Time.Volume={} % # File - Filter -File.Filter.ZIP=Archive +File.Filter.ZIP=Archiv File.Filter.Media=Medien File.Filter.Preset=Vorlagen @@ -20,11 +20,12 @@ Pad.TimeMode.BOTH=Abgelaufende Zeit / Gesamtzeit # UI - Window - Titles UI.Dialog.Launch.Title=Projekt w�hlen... UI.Window.Main.Title=Play Wall [Projekt: {} - Profil: {}] -UI.Window.Changelog.Title=Was ist neu? +UI.Window.Changelog.Title=Versions�nderungen UI.Window.Settings.Title=Einstellungen - {} -UI.Window.GlobalSettings.Title=Programm Einstellungen -UI.Window.PadSettings.Title=Kachel Einstellungen - {} | {} -UI.Window.PadSettings.Title.Empty=Kachel Einstellungen - {} +UI.Window.ProjectSettings.Title=Projekteinstellungen +UI.Window.GlobalSettings.Title=Programmeinstellungen +UI.Window.PadSettings.Title=Kacheleinstellungen - {} | {} +UI.Window.PadSettings.Title.Empty=Kacheleinstellungen - {} UI.Dialog.DragAndDrop.Title=Drag and Drop UI.Dialog.ProjectExport.Title=Projekt exportieren UI.Dialog.ErrorSummary.Title=Fehlerbericht @@ -32,7 +33,7 @@ UI.Dialog.NewProfile.Title=Neues Profil UI.Dialog.NewProject.Title=Neues Projekt UI.Dialog.ChooseProfile.Title=Profil w�hlen UI.Dialog.ProjectManager.Title=Projektverwaltung -UI.Dialog.UpdateCenter.Title=Aktualisierungen +UI.Dialog.UpdateCenter.Title=Aktualisierung UI.Dialog.Preset.Title=Vorlagen UI.Dialog.Plugins.Title=Erweiterungen UI.Dialog.Print.Title=Drucken @@ -63,18 +64,20 @@ UI.Window.Settings.Midi.Title=Midi UI.Window.Settings.Layout.Title=Layout UI.Window.Settings.Player.Title=Player UI.Window.Settings.Audio.Title=Audio -UI.Window.Settings.Updates.Title=Updates +UI.Window.Settings.Updates.Title=Aktualisierung +UI.Window.Settings.Keys.Title=Tastenkombinationen +UI.Window.Settings.Paths.Title=Ordner -# UI - Dialog - DragAndDrop -UI.Dialog.DragAndDrop.Header=Hinweis -UI.Dialog.DragAndDrop.Content=F�r das Verschieben von Kacheln gibt es zwei M�glichkeiten: Vertauschen oder Ersetzen.\nUm die gw�hlte Kachel mit der Zielkachel zu vertauschen, muss der obere Teil der Zielkachel gew�hlt werden. Es erscheint eine blaue Umrandung. \nUm die ausgew�hlte Kachel mit der Zielkachel zu ersetzen, muss der untere Teil der Zielkachel gew�hlt werden. Es erscheint eine rote Umrandung. -UI.Dialog.DragAndDrop.Button=OK +# UI - Settings - Keys +UI.Settings.Keys.Conflict.Header=Tastenkombination bereits verwendet +UI.Settings.Keys.Conflict.Content=Diese Tastenkombination wird bereits verwendet f�r: \n{} # UI - Dialog - NewProfile 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. @@ -97,13 +100,13 @@ UI.Dialog.Info.Header= UI.Dialog.Info.Content=Version: {} (Build: {})\nAutor: {}\nGrafiken: Robert Goldmann.\n\nDieses Programm nutzt Bibliotheken. ControlsFX (8.40.10), dom4j (1.6.1), snakeyaml (1.11), guava (15.0), gagawa (1.0.1), TinySound (1.1.1), JLayer (1.0.1), JSPF (1.0.2), json-smart (1.2). \nBesonderen Dank an die Betatester: Stefan, Robert. # UI - Dialog - Feedback -UI.Dialog.Feedback.Content=Der Fehlerbericht wird �bermittelt. Dies dauert einen kleinen Moment. Bitte haben Sie etwas Geduld. Ihre Nummer wird am Ende angezeigt. +UI.Dialog.Feedback.Content=Der Fehlerbericht wird �bermittelt, dies kann einen Augenblick dauern. Ihre Nummer wird am Ende angezeigt. # UI - Placeholder UI.Placeholder.Project=Keine Projekte vorhanden UI.Placeholder.Preset=Keine Vorlagen vorhanden -UI.Placeholder.Plugins=Keine Plugins vorhanden -UI.Placeholder.Updates=Es sind keine Updates verf�gbar +UI.Placeholder.Plugins=Keine Erweiterungen vorhanden +UI.Placeholder.Updates=Es sind keine Aktualisierungen verf�gbar UI.Placeholder.ErrorSummary=Keine Fehler # Info - MIDI @@ -111,13 +114,13 @@ Info.Midi.Device.Connected=Midi-Ger # Info - Settings Info.Settings.ResetWarning=Die Einstellungen wurden zur�ckgesetzt. -Info.Settings.CacheDelete={} Dateien wurden gel�scht. +Info.Settings.CacheDelete={} Datei(en) wurden gel�scht. # Info - Print Info.Print.Header={} - Seite {} # Error - Standard -Error.Standard.Gen=Es ist ein Fehler aufgetreten. Bitte versuchen Sie es sp�ter noch einmal. ({}) +Error.Standard.Gen=Es ist ein Fehler aufgetreten. Bitte versuchen Sie es sp�ter erneut. ({}) Error.Standard.NameInUse=Der Name {} ist bereits vorhanden. Bitte w�hlen Sie einen anderen Namen. # Error - Settings @@ -129,7 +132,7 @@ Error.Profile.Create=Das Profil konnte aufgrund eines Fehlers nicht erstellt wer Error.Profile.NotFound=Das Profil konnte nicht geladen werden, da die ben�tigten Dateien fehlen. W�hlen Sie eine anderes Profile aus und �ffnen Sie das Projekt erneut. ({}) Error.Profile.Save=Das Profil konnte aufgrund eines Fehlers nicht gespeichert werden. ({}) Error.Profile.Delete=Das Projekt konnte nicht gel�scht werden. ({}) -Error.Profile.SmallScreen=Ihr Bildschirm ist f�r die gew�hlte Anzahl der Kacheln zu klein. (Maximal: {}x{}) +Error.Profile.SmallScreen=Ihr Bildschirm ist f�r die gew�hlte Anzahl der Kacheln zu klein. (Maximal: {}x{} Kacheln) # Error - Preset Error.Preset.Import=Es ist ein Fehler beim Importieren der Vorlage aufgetreten. ({}) @@ -143,6 +146,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 darf kein Unterodner des alten Medienordners sein. # Error - Pad - Enum Error.Pad.FILE_NOT_FOUND=Die Datei {} konnte nicht gefunden werden. @@ -156,15 +160,15 @@ Error.Fix.NewFile=Neue Datei w Error.Fix.Delete=Kachel l�schen # Error - Midi -Error.Midi.Settings.Unkown=F�r die ausgew�hlte Seite sind keine Midi Einstellungen aktiv. In Einstellungen -> Midi -> Presets kann dies angepasst werden. +Error.Midi.Settings.Unkown=F�r die ausgew�hlte Seite sind keine Midi Einstellungen aktiv. Gehen Sie in die Einstellungen, um Midi zu aktivieren. Error.Midi.Device.Busy=Das Midi-Ger�t wird bereits durch ein anderes Programm verwendet. ({}) Error.Midi.Device.Unavailible=Das Midi-Ger�t {} konnte nicht gefunden werden. Error.Midi.Record.Fail=Die gedr�ckte Taste wird bereits verwendet. Error.Midi.Send=Der Midi Befehl konnte nicht gesendet werden. ({}) # Error - Plugins -Error.Plugins.Download=Das Plugin {} konnte nicht geladen werden. -Error.Plugins.Avaiable=Es sind keine Plugins f�r dieses Update Kanal verf�gbar. +Error.Plugins.Download=Die Erweiterung {} konnte nicht geladen werden. +Error.Plugins.Avaiable=Es sind keine Erweiterungen f�r diesen Update-Kanal verf�gbar. #Mapper Mapper.Keyboard.Name=Tastatur @@ -174,10 +178,10 @@ Mapper.Midi.toString=Midi {} # Info - Mapper # Das ist Midi und Tastatur gemeinsam -Info.Mapper.PressKey=Dr�cken Sie eine Taste auf dem Ger�t. +Info.Mapper.PressKey=Dr�cken Sie eine Taste auf dem Midi-Ger�t. #UI - Settings - Alerts -UI.Settings.Alert.NewKeyShortcut.Text=Dr�cken Sie bitte die gew�nschte Tastenkombination. (Erlaubt sind Buchstaben, Ziffern und Funktionstasten). +UI.Settings.Alert.NewKeyShortcut.Text=Dr�cken Sie bitte die gew�nschte Tastenkombination. \nDieses kann aus Buchstaben, Ziffern und/oder den F-Tasten bestehen. # UI - Window - PadSettings UI.Window.PadSettings.General.Title=Allgemein @@ -206,9 +210,22 @@ CartAction.Mode.PLAY_STOP=Play/Stop CartAction.Mode.PLAY_PAUSE=Play/Pause CartAction.Mode.PLAY_HOLD=Play/Hold -#UI - Dialog -AutoUpdate -UI.Dialog.AutoUpdate.Header=Updates -UI.Dialog.AutoUpdate.Content=Es sind Updates verf�gbar. M�chten Sie diese jetzt installieren? (Weitere Informationen finden Sie in den Update Einstellungen.) +#UI - Dialog - AutoUpdate +UI.Dialog.AutoUpdate.Header=Aktualisierung +UI.Dialog.AutoUpdate.Content=Es sind Aktualisierungen verf�gbar. M�chten Sie diese jetzt installieren?\n{} +UI.Dialog.AutoUpdate.Title=Aktualisierung +UI.Dialog.AutoUpdate.Checkbox=Diese Aktualisierung nicht mehr anzeigen. +UI.Dialog.AutoUpdate.Button.Update=Jetzt aktualisieren +UI.Dialog.AutoUpdate.Button.Cancel=Jetzt nicht aktualisieren + +#UI - Dialog - Save +UI.Dialog.Save.Header=Speichern +UI.Dialog.Save.Content=M�chten Sie das Projekt speichern? +UI.Dialog.Save.Title=Speichern +UI.Dialog.Save.Checkbox=Immer automatisch speichern und diesen Dialog nicht mehr anzeigen. +UI.Dialog.Save.Button.Yes=Speichern +UI.Dialog.Save.Button.No=Nicht Speichern +UI.Dialog.Save.Button.Cancel=Abbrechen # Update Channel - BaseName UpdateChannel.STABLE=Stabil @@ -219,10 +236,11 @@ Error.Layout.Load=Es gab einen Fehler beim Laden des Layouts ({}) # UI - Dialog - Update UI.Dialog.Update.Cell={}: Installiert: {} - Neu: {} +UI.Dialog.Update.Info=Die Aktualisierung wird vorbereitet. Bitte schlie�en Sie nicht das Programm. \nDieser Vorgang kann wenige Minuten dauern. UI.Window.Settings.Updates.CurrentVersion={} (Build {}) # Error - Update - Downlaod -Error.Update.Download=Es ist ein Fehler beim Herunterladen des Updates aufgetreten. Bitte versuchen Sie es sp�ter erneut. ({}) +Error.Update.Download=Es ist ein Fehler beim Herunterladen der Aktualisierung aufgetreten. Bitte versuchen Sie es sp�ter erneut. ({}) # Layout Layout.Modern.Name=Modern @@ -239,4 +257,13 @@ TriggerPoint.EOF_STOP=Ende/Stop # Drag and Drop Mode DnDMode.Replace=Ersetzen -DnDMode.Move=Tauschen \ No newline at end of file +DnDMode.Move=Tauschen + +# Main Layout +MainLayout.Desktop=Desktopmodus +MainLayout.Touch=Touchmodus + +# Suche +Search.Button=Suchen +Search.Placeholder=Suche +Search.Alert.NoMatches=Keine Treffer gefunden. \ No newline at end of file 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..9438e06b62639682604ff2e1351a3afefbc41a97 100644 --- a/PlayWall/assets/de/tobias/playpad/assets/lang/ui_de.properties +++ b/PlayWall/assets/de/tobias/playpad/assets/lang/ui_de.properties @@ -1,4 +1,5 @@ #Sprachdatei f�r die Benutzeroberfl�che +#Kommentare befinden sich immer -->�BER<-- dem jeweiligen Eintrag main.menu.file=Datei main.menu.option=Optionen @@ -17,9 +18,9 @@ main.menuitem.onTop=Fenster im Vordergrund main.menuitem.plugins=Erweiterungen... main.menuitem.dnd=Bearbeitungsmodus main.menuitem.errors=Fehlerbericht anzeigen... -main.menuitem.projectSettings=Projekt Einstellungen... -main.menuitem.profileSettings=Profil Einstellungen... -main.menuitem.globalSettings=Globale (Programm) Einstellungen +main.menuitem.projectSettings=Projekteinstellungen... +main.menuitem.profileSettings=Profileinstellungen... +main.menuitem.globalSettings=Globale Einstellungen... main.menuitem.about=�ber Play Wall... main.menuitem.website=Webseite besuchen... main.menuitem.senderror=Fehler senden... @@ -76,18 +77,22 @@ settings.update.label.search=Nach Updates suchen: settings.update.label.available=Verf�gbare Updates: settings.update.button.search=Jetzt suchen settings.update.button.install=Aktualisieren und neu starten -settings.update.label.channel=Update Kanal: -settings.update.label.infoC=Program +settings.update.label.channel=Update-Kanal: +settings.update.label.infoC=Programm settings.update.label.infoE=Erweiterung settings.keys.label.headline=Tastenkombinationen settings.keys.label.name=Name: -settings.keys.label.shortcut=Kurzbefehl: -settings.keys.button.change=Neu -settings.keys.button.delete=Verbindung aufheben +settings.keys.label.shortcut=Tastenkombination: +settings.keys.button.change=�ndern +settings.keys.button.delete=L�schen settings.keys.table.name=Name -settings.keys.table.shortcut=Kurzbefehl -settings.keys.textfieldsearch=Suchen... +settings.keys.table.shortcut=Tastenkombination +settings.keys.textfield.search=Suchen... + +settings.paths.label.media=Mediendateien: +settings.paths.button.choose=W�hlen... +settings.paths.checkbox.mediaActive=Mediendateien beim Import in den Medienordner kopieren settings.button.finish=Fertig settings.checkbox.activate=Aktivieren @@ -114,6 +119,7 @@ keyboard.label.key=Taste (Tastatur): keyboard.button.new=�ndern padSettings.button.delete=L�schen +padSettings.button.path=Pfad zeigen padSettings.gen.label.title=Titel: padSettings.gen.label.volume=Lautst�rke: @@ -136,9 +142,9 @@ project.button.new=Neues Projekt project.button.duplicate=Duplizieren project.button.export=Exportieren... project.button.import=Importieren.. -project.label.export=Wenn Sie ein ge�ffnetes Projekt exportieren, wird es zuerst gespeichert. +project.label.export=Wenn Sie ein ge�ffnetes Projekt exportieren, wird dieses zuerst gespeichert. project.label.name=Name: -project.label.fileSize=Dateigr��e +project.label.profile=Profile: project.label.lastModified=Zuletzt bearbeitet: project.export.label.headline=Projekt exportieren: @@ -168,12 +174,16 @@ print.button.cancel=Abbrechen print.button.print=Drucken plugin.label.restart=Einige �nderungen werden erst nach dem Neustart des Programmes wirksam. -plugin.label.updateInfo=Plugins k�nnen in den Updateeinstellungen aktualisiert werden. +plugin.label.updateInfo=Erweiterungen k�nnen in den Aktualisierungseinstellungen aktualisiert werden. plugin.button.finish=Fertig -settings.audio.type=Ausgabe Type w�hlen: +settings.audio.type=Ausgabetype w�hlen: newProject.label.name=Name: +newProject.label.media=Medienordner: +newProject.checkbox.mediafolder=Medienordner nutzen (Importierte Dateien werden in den angegebenen Ordner kopiert) +newProject.button.media=Medienordner w�hlen + newProject.label.profile=Profil: newProject.button.newProfile=Neues Profil... newProject.button.finish=Projekt erstellen @@ -185,15 +195,15 @@ newProfile.label.midi=Midi Funktion: newProfile.button.finish=Profil erstellen newProfile.button.cancel=Abbrechen -profileChoose.label.info=Die Voreinstellungen zu diesem Projekt wurden nicht gefunden.\nBitte w�hlen Sie neue Voreinstellungen aus. +profileChoose.label.info=Das verwendete Profil wurde nicht gefunden.\nBitte w�hlen Sie ein anderes Profil aus, welches verwendet werden soll. profileChoose.button.finish=Profil w�hlen -doubleFeedback.label.colorEvent=Event Farbe: -doubleFeedback.label.colorDefault=Standard Farbe: +doubleFeedback.label.colorEvent=Eventfarbe: +doubleFeedback.label.colorDefault=Standardfarbe: cartAction.label.headline=Einstellungen zur Kachel: cartAction.label.type=Typ: -cartAction.label.autoColor=Feedback wie Layout: +cartAction.label.autoColor=Feedback-Farbe wie Layout: cartAction.checkbox.autoColor=Aktivieren action.mapper.headline=Einstellungen zum Mapping: @@ -211,7 +221,7 @@ mappingPreset.label.name=Name: errorSummary.label.headline=Fehlerzusammenfassung: errorSummary.column.cart=Kachel errorSummary.column.des=Fehlerbeschreibung -errorSummary.column.solution=L�sung +errorSummary.column.solution=L�sungsvorschl�ge errorSummary.button.close=Schlie�en tinysound.label.soundcard=Soundkarte: @@ -220,7 +230,7 @@ triggertime.label.time=Zeit vom Trigger: (Sek) carttrigger.label.action=Aktion f�r Kacheln: carttrigger.label.carts=Kacheln: -carttrigger.checkbox.all=Alle, au�er diese +carttrigger.checkbox.all=Alle anderen Kacheln volumetrigger.label.volume=Lautst�rke: -volumetrigger.label.duration=Fade Dauer: \ No newline at end of file +volumetrigger.label.duration=�berblenddauer: \ No newline at end of file diff --git a/PlayWall/assets/de/tobias/playpad/assets/style/launchDialog_style.css b/PlayWall/assets/de/tobias/playpad/assets/style/launchDialog_style.css index 5140429aa49a7b813a470a5d749b29b6df9d8810..781fca5438aa58ad11ab3f76efa5d48cf0997d58 100644 --- a/PlayWall/assets/de/tobias/playpad/assets/style/launchDialog_style.css +++ b/PlayWall/assets/de/tobias/playpad/assets/style/launchDialog_style.css @@ -70,3 +70,11 @@ -fx-background-color: derive(-fx-hover-base,+50%); } +.projectname { + -fx-font-size: 13px; +} + +.profilename { + -fx-font-size: 10px; + -fx-text-fill: gray; +} \ No newline at end of file diff --git a/PlayWall/assets/de/tobias/playpad/assets/style/touch.css b/PlayWall/assets/de/tobias/playpad/assets/style/touch.css index 8b0042dd68f072011635e896e94582bc1e428c15..7c3f13e0e822b0adf8dd956e163a68d8e29eedab 100644 --- a/PlayWall/assets/de/tobias/playpad/assets/style/touch.css +++ b/PlayWall/assets/de/tobias/playpad/assets/style/touch.css @@ -12,11 +12,11 @@ } .slider .track { - -fx-pref-height:20; + -fx-pref-height: 15; } .slider:vertical .track { - -fx-pref-width:20; + -fx-pref-width: 20; } .slider .thumb { diff --git a/PlayWall/assets/de/tobias/playpad/assets/view/main/desktop/header.fxml b/PlayWall/assets/de/tobias/playpad/assets/view/main/desktop/header.fxml index 1c152d8540b4a2c2aae51f400625b556b9d4b17e..dd7c7d2aa525e7b2093debec88e177d3f3cdc92f 100644 --- a/PlayWall/assets/de/tobias/playpad/assets/view/main/desktop/header.fxml +++ b/PlayWall/assets/de/tobias/playpad/assets/view/main/desktop/header.fxml @@ -65,9 +65,8 @@ </MenuItem> </items> </Menu> - <Menu mnemonicParsing="false" text="%main.menu.view"> + <Menu fx:id="layoutMenu" mnemonicParsing="false" text="%main.menu.view"> <items> - <Menu fx:id="layoutMenu" mnemonicParsing="false" text="%main.menuitem.layout" /> <CheckMenuItem fx:id="alwaysOnTopItem" mnemonicParsing="false" onAction="#alwaysOnTopItemHandler" text="%main.menuitem.onTop" /> <CheckMenuItem fx:id="fullScreenMenuItem" mnemonicParsing="false" onAction="#fullScreenMenuItemHandler" text="%main.menuitem.fullScreen"> <accelerator> @@ -75,6 +74,7 @@ </accelerator></CheckMenuItem> <SeparatorMenuItem mnemonicParsing="false" /> <MenuItem fx:id="searchPadMenuItem" mnemonicParsing="false" onAction="#searchPadHandler" text="%main.menuitem.searchPad" /> + <SeparatorMenuItem mnemonicParsing="false" /> </items> </Menu> <Menu fx:id="extensionMenu" mnemonicParsing="false" text="%main.menu.extension" /> diff --git a/PlayWall/assets/de/tobias/playpad/assets/view/main/mainMenu.fxml b/PlayWall/assets/de/tobias/playpad/assets/view/main/mainMenu.fxml deleted file mode 100644 index 4811fc21c824512215069318915dd99aed3ea491..0000000000000000000000000000000000000000 --- a/PlayWall/assets/de/tobias/playpad/assets/view/main/mainMenu.fxml +++ /dev/null @@ -1,76 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<?import java.lang.*?> -<?import javafx.scene.control.*?> -<?import javafx.scene.input.*?> - -<MenuBar fx:id="menuBar" prefHeight="29.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.tobias.playpad.viewcontroller.main.MainMenuBarController"> - <menus> - <Menu mnemonicParsing="false" text="%main.menu.file"> - <items> - <MenuItem mnemonicParsing="false" onAction="#newDocumentHandler" text="%main.menuitem.new"> - <accelerator> - <KeyCodeCombination alt="UP" code="N" control="UP" meta="UP" shift="UP" shortcut="DOWN" /> - </accelerator> - </MenuItem> - <Menu fx:id="recentOpenMenu" mnemonicParsing="false" text="%main.menuitem.recentFiles" /> - <MenuItem mnemonicParsing="false" onAction="#openDocumentHandler" text="%main.menuitem.project"> - <accelerator> - <KeyCodeCombination alt="UP" code="O" control="UP" meta="UP" shift="UP" shortcut="DOWN" /> - </accelerator> - </MenuItem> - <MenuItem fx:id="saveMenuItem" mnemonicParsing="false" onAction="#saveMenuHandler" text="%main.menuitem.save"> - <accelerator> - <KeyCodeCombination alt="UP" code="S" control="UP" meta="UP" shift="UP" shortcut="DOWN" /> - </accelerator> - </MenuItem> - <SeparatorMenuItem mnemonicParsing="false" /> - <MenuItem fx:id="profileMenu" mnemonicParsing="false" onAction="#profileMenuHandler" text="%main.menuitem.profile" /> - <SeparatorMenuItem mnemonicParsing="false" /> - <MenuItem mnemonicParsing="false" onAction="#printMenuHandler" text="%main.menuitem.print"> - <accelerator> - <KeyCodeCombination alt="UP" code="P" control="UP" meta="UP" shift="UP" shortcut="DOWN" /> - </accelerator></MenuItem> - </items> - </Menu> - <Menu mnemonicParsing="false" text="%main.menu.option"> - <items> - <CheckMenuItem fx:id="dndModeMenuItem" mnemonicParsing="false" onAction="#dndModeHandler" text="%main.menuitem.dnd"> - <accelerator> - <KeyCodeCombination alt="UP" code="M" control="UP" meta="UP" shift="UP" shortcut="DOWN" /> - </accelerator> - </CheckMenuItem> - <MenuItem fx:id="errorMenu" mnemonicParsing="false" onAction="#errorMenuHandler" text="%main.menuitem.errors"> - <accelerator> - <KeyCodeCombination alt="UP" code="E" control="UP" meta="UP" shift="UP" shortcut="DOWN" /> - </accelerator> - </MenuItem> - <SeparatorMenuItem mnemonicParsing="false" /> - <MenuItem mnemonicParsing="false" onAction="#pluginMenuItemHandler" text="%main.menuitem.plugins" /> - <SeparatorMenuItem mnemonicParsing="false" /> - <MenuItem fx:id="settingsMenuItem" mnemonicParsing="false" onAction="#settingsHandler" text="%main.menuitem.settings"> - <accelerator> - <KeyCodeCombination alt="UP" code="COMMA" control="UP" meta="UP" shift="UP" shortcut="DOWN" /> - </accelerator> - </MenuItem> - </items> - </Menu> - <Menu mnemonicParsing="false" text="%main.menu.view"> - <items> - <CheckMenuItem fx:id="alwaysOnTopItem" mnemonicParsing="false" onAction="#alwaysOnTopItemHandler" text="%main.menuitem.onTop" /> - <CheckMenuItem fx:id="fullScreenMenuItem" mnemonicParsing="false" onAction="#fullScreenMenuItemHandler" text="%main.menuitem.fullScreen"> - <accelerator> - <KeyCodeCombination alt="UP" code="F" control="UP" meta="UP" shift="DOWN" shortcut="DOWN" /> - </accelerator></CheckMenuItem> - </items> - </Menu> - <Menu fx:id="extensionMenu" mnemonicParsing="false" text="%main.menu.extension" /> - <Menu mnemonicParsing="false" text="%main.menu.info"> - <items> - <MenuItem mnemonicParsing="false" onAction="#aboutMenuHandler" text="%main.menuitem.about" /> - <MenuItem mnemonicParsing="false" onAction="#visiteWebsiteMenuHandler" text="%main.menuitem.website" /> - <MenuItem mnemonicParsing="false" onAction="#sendErrorMenuItem" text="%main.menuitem.senderror" /> - </items> - </Menu> - </menus> -</MenuBar> diff --git a/PlayWall/assets/de/tobias/playpad/assets/view/main/mainToolbarView.fxml b/PlayWall/assets/de/tobias/playpad/assets/view/main/mainToolbarView.fxml deleted file mode 100644 index 38c491f3c86f75ba41c1599a33c1f35317b49427..0000000000000000000000000000000000000000 --- a/PlayWall/assets/de/tobias/playpad/assets/view/main/mainToolbarView.fxml +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<?import java.lang.*?> -<?import javafx.scene.control.*?> -<?import javafx.scene.layout.*?> -<?import javafx.scene.text.*?> - -<ToolBar fx:id="toolbar" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.tobias.playpad.viewcontroller.main.MainToolbarController"> - <items> - <HBox fx:id="toolbarHBox" alignment="CENTER_LEFT" maxWidth="1.7976931348623157E308" prefHeight="28.0" prefWidth="586.0" spacing="14.0"> - <children> - <HBox fx:id="pageHBox" alignment="CENTER_LEFT" spacing="14.0" HBox.hgrow="ALWAYS" /> - <HBox fx:id="iconHbox" alignment="CENTER" spacing="14.0" /> - <HBox alignment="CENTER" spacing="7.0" HBox.hgrow="NEVER"> - <children> - <Label fx:id="volumeDownLabel"> - <font> - <Font size="24.0" /> - </font> - </Label> - <Slider fx:id="volumeSlider" focusTraversable="false" max="1.0" /> - <Label fx:id="volumeUpLabel"> - <font> - <Font size="24.0" /> - </font> - </Label> - </children> - </HBox> - </children> - </HBox> - </items> -</ToolBar> diff --git a/PlayWall/assets/de/tobias/playpad/assets/view/main/mainView.fxml b/PlayWall/assets/de/tobias/playpad/assets/view/main/mainView.fxml index 42936d2dd659548c8a2115bf5153f2c11155c90a..dbb3ca375d05f004c8b2d2ee7fa5e56651d5c719 100644 --- a/PlayWall/assets/de/tobias/playpad/assets/view/main/mainView.fxml +++ b/PlayWall/assets/de/tobias/playpad/assets/view/main/mainView.fxml @@ -10,20 +10,14 @@ <children> <VBox layoutX="-0.7071067690849304" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> <children> - <fx:include fx:id="menuBar" source="mainMenu.fxml" /> - <fx:include fx:id="toolbar" source="mainToolbarView.fxml" /> - <AnchorPane fx:id="gridContainer" layoutX="-0.7071067690849304" layoutY="68.29289245605469" AnchorPane.bottomAnchor="-0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="69.0" VBox.vgrow="ALWAYS"> + <VBox fx:id="headerBox" /> + <AnchorPane fx:id="gridContainer" VBox.vgrow="ALWAYS"> <children> - <GridPane fx:id="padGridPane" layoutX="0.7071067690849304" layoutY="0.7071075439453125" prefHeight="331.0" prefWidth="600.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> + <GridPane fx:id="padGridPane" gridLinesVisible="true" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" VBox.vgrow="ALWAYS"> </GridPane> </children> </AnchorPane> </children> </VBox> - <Label fx:id="liveLabel" alignment="CENTER" mouseTransparent="true" prefHeight="40.0" prefWidth="600.0" text="%main.label.live" textFill="RED" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="29.0"> - <font> - <Font name="System Bold" size="26.0" /> - </font> - </Label> </children> </AnchorPane> diff --git a/PlayWall/assets/de/tobias/playpad/assets/view/main/mainViewV2.fxml b/PlayWall/assets/de/tobias/playpad/assets/view/main/mainViewV2.fxml deleted file mode 100644 index dbb3ca375d05f004c8b2d2ee7fa5e56651d5c719..0000000000000000000000000000000000000000 --- a/PlayWall/assets/de/tobias/playpad/assets/view/main/mainViewV2.fxml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<?import javafx.scene.text.*?> -<?import javafx.scene.input.*?> -<?import javafx.scene.control.*?> -<?import java.lang.*?> -<?import javafx.scene.layout.*?> - -<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"> - <children> - <VBox layoutX="-0.7071067690849304" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> - <children> - <VBox fx:id="headerBox" /> - <AnchorPane fx:id="gridContainer" VBox.vgrow="ALWAYS"> - <children> - <GridPane fx:id="padGridPane" gridLinesVisible="true" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" VBox.vgrow="ALWAYS"> - </GridPane> - </children> - </AnchorPane> - </children> - </VBox> - </children> -</AnchorPane> diff --git a/PlayWall/assets/de/tobias/playpad/assets/view/main/touch/header.fxml b/PlayWall/assets/de/tobias/playpad/assets/view/main/touch/header.fxml index 97a767c4076cd823fb0e56c64fe24e18c1263580..4064a2aea4283892bda5ab3357fed8f40564699f 100644 --- a/PlayWall/assets/de/tobias/playpad/assets/view/main/touch/header.fxml +++ b/PlayWall/assets/de/tobias/playpad/assets/view/main/touch/header.fxml @@ -34,19 +34,7 @@ <Font size="24.0" /> </font> </Label> - <MenuButton focusTraversable="false" mnemonicParsing="false" text="..."> - <items> - <CheckMenuItem fx:id="fullScreenMenuItem" mnemonicParsing="false" onAction="#fullScreenMenuItemHandler" text="%main.menuitem.fullScreen"> - <accelerator> - <KeyCodeCombination alt="UP" code="F" control="UP" meta="UP" shift="DOWN" shortcut="DOWN" /> - </accelerator></CheckMenuItem> - <CheckMenuItem fx:id="alwaysOnTopItem" mnemonicParsing="false" onAction="#alwaysOnTopItemHandler" text="%main.menuitem.onTop" /> - <MenuItem fx:id="closeMenuItem" mnemonicParsing="false" onAction="#closeMenuItemHandler" text="%main.menuitem.close"> - <accelerator> - <KeyCodeCombination alt="UP" code="W" control="UP" meta="UP" shift="UP" shortcut="DOWN" /> - </accelerator></MenuItem> - </items> - </MenuButton> + <Button fx:id="closeButton" focusTraversable="false" mnemonicParsing="false" onAction="#closeMenuItemHandler" text="X" /> </children> </HBox> </children> diff --git a/PlayWall/assets/de/tobias/playpad/assets/view/option/profile/generalTab.fxml b/PlayWall/assets/de/tobias/playpad/assets/view/option/global/generalTab.fxml similarity index 99% rename from PlayWall/assets/de/tobias/playpad/assets/view/option/profile/generalTab.fxml rename to PlayWall/assets/de/tobias/playpad/assets/view/option/global/generalTab.fxml index 9682eb43e5d2c45ce766afdc21572295a7a61ebe..15dd7abda12eeed8cdce5fdd0692277fcb6df627 100644 --- a/PlayWall/assets/de/tobias/playpad/assets/view/option/profile/generalTab.fxml +++ b/PlayWall/assets/de/tobias/playpad/assets/view/option/global/generalTab.fxml @@ -58,6 +58,7 @@ <Insets left="164.0" /> </VBox.margin> </Label> + <Separator prefWidth="200.0" /> <HBox spacing="14.0"> <children> <Label alignment="BASELINE_RIGHT" maxHeight="1.7976931348623157E308" prefWidth="150.0" text="%settings.gen.cache.label" /> 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..a45b354600c1d6689acb122155077acc1c49eb42 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" /> @@ -19,13 +19,13 @@ <HBox spacing="14.0"> <children> <Label alignment="CENTER_RIGHT" prefWidth="150.0" text="%settings.keys.label.name" /> - <Label fx:id="nameLabel" prefWidth="100.0" /> + <Label fx:id="nameLabel" /> </children> </HBox> <HBox alignment="CENTER_LEFT" spacing="14.0"> <children> <Label alignment="CENTER_RIGHT" prefWidth="150.0" text="%settings.keys.label.shortcut" /> - <Label fx:id="shortcutLabel" prefWidth="100.0" /> + <Label fx:id="shortcutLabel" prefWidth="150.0" /> <Button fx:id="newShortcutButton" mnemonicParsing="false" onAction="#newShortcutButtonHandler" text="%settings.keys.button.change" /> <Button fx:id="deleteButton" mnemonicParsing="false" onAction="#deleteHandler" text="%settings.keys.button.delete" /> </children> 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/build.xml b/PlayWall/build.xml index 943ff80ec1870df04b63927711cc03326634723f..9f70f6dacf655436463692f25d7a9ae460cf5199 100644 --- a/PlayWall/build.xml +++ b/PlayWall/build.xml @@ -31,7 +31,7 @@ <upload username="p35947554-pw" password="${password}" host="p35947554.1and1-data.host"> <file type="program" localPath="/Users/tobias/Documents/Programmieren/Java/eclipse/PlayWall/build/PlayWall.jar" remotePath="/stable" remoteFileName="PlayWall.jar" /> - <file type="exe" localPath="/Users/tobias/Documents/Programmieren/Java/eclipse/PlayWall/build/PlayWall.exe" remotePath="/stable" remoteFileName="PlayWall.exe" /> + <file type="exe" localPath="/Users/tobias/Documents/Programmieren/Java/eclipse/PlayWall/dist/PlayWall.exe" remotePath="/stable" remoteFileName="PlayWall.exe" /> <file type="plugin" localPath="/Users/tobias/Documents/Programmieren/Java/eclipse/PlayWall/build/ActionPlugin.jar" remotePath="/stable/plugins" remoteFileName="ActionPlugin.jar" /> <file type="plugin" localPath="/Users/tobias/Documents/Programmieren/Java/eclipse/PlayWall/build/AwakePlugin.jar" remotePath="/stable/plugins" remoteFileName="AwakePlugin.jar" /> <file type="plugin" localPath="/Users/tobias/Documents/Programmieren/Java/eclipse/PlayWall/build/EqualizerPlugin.jar" remotePath="/stable/plugins" remoteFileName="EqualizerPlugin.jar" /> diff --git a/PlayWall/src/application.yml b/PlayWall/src/application.yml index 29f0ca1f41e61c9d00f8740f489200bbedff362f..4ed0bd37d618f8b78403b3a82be171e26e437731 100644 --- a/PlayWall/src/application.yml +++ b/PlayWall/src/application.yml @@ -1,6 +1,6 @@ name: PlayWall -version: 5.0.1 -build: 33 +version: 5.1.0 +build: 35 identifier: de.tobias.playpad main: de.tobias.playpad.PlayPadMain author: Tobias Ullerich diff --git a/PlayWall/src/de/tobias/playpad/PlayPadImpl.java b/PlayWall/src/de/tobias/playpad/PlayPadImpl.java index 122153c953b38061ea660d50a7ef86286e0d95e3..83b0ae9f158a67dd7b75e20541b165c2d9be331b 100644 --- a/PlayWall/src/de/tobias/playpad/PlayPadImpl.java +++ b/PlayWall/src/de/tobias/playpad/PlayPadImpl.java @@ -12,19 +12,31 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Optional; +import java.util.ResourceBundle; import java.util.Set; +import org.dom4j.DocumentException; + +import de.tobias.playpad.action.mapper.MapperRegistry; +import de.tobias.playpad.audio.JavaFXAudioHandler; +import de.tobias.playpad.design.modern.ModernGlobalDesign; +import de.tobias.playpad.midi.device.DeviceRegistry; +import de.tobias.playpad.midi.device.PD12; import de.tobias.playpad.plugin.PadListener; import de.tobias.playpad.plugin.SettingsListener; import de.tobias.playpad.plugin.WindowListener; import de.tobias.playpad.project.Project; +import de.tobias.playpad.registry.NoSuchComponentException; import de.tobias.playpad.settings.GlobalSettings; +import de.tobias.playpad.view.MapperOverviewViewController; import de.tobias.playpad.viewcontroller.IPadSettingsViewController; import de.tobias.playpad.viewcontroller.main.IMainViewController; -import de.tobias.playpad.viewcontroller.main.MainViewControllerV2; +import de.tobias.playpad.viewcontroller.main.MainViewController; import de.tobias.playpad.viewcontroller.option.IProfileSettingsViewController; import de.tobias.utils.application.ApplicationUtils; import de.tobias.utils.application.container.PathType; +import de.tobias.utils.util.FileUtils; +import de.tobias.utils.util.SystemUtils; import de.tobias.utils.util.Worker; import javafx.scene.image.Image; import net.xeoh.plugins.base.PluginManager; @@ -43,14 +55,14 @@ public class PlayPadImpl implements PlayPad { private PluginManager pluginManager; private Set<Path> deletedPlugins; - private MainViewControllerV2 mainViewController; + private MainViewController mainViewController; private Project currentProject; protected GlobalSettings globalSettings; public PlayPadImpl(GlobalSettings globalSettings) { pluginManager = PluginManagerFactory.createPluginManager(); deletedPlugins = new HashSet<>(); - + this.globalSettings = globalSettings; } @@ -141,6 +153,19 @@ public class PlayPadImpl implements PlayPad { @Override public void shutdown() { + // Shutdown components + PlayPadPlugin.getRegistryCollection().getAudioHandlers().getComponents().forEach(i -> + { + if (i instanceof AutoCloseable) { + try { + ((AutoCloseable) i).close(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + }); + // Delete Plugins Info Textfile --> Löschen dann beim Start. Path pluginInfoPath = ApplicationUtils.getApplication().getPath(PathType.LIBRARY, PLUGIN_INFO_TXT); try { @@ -157,6 +182,13 @@ public class PlayPadImpl implements PlayPad { e.printStackTrace(); } + try { + FileUtils.deleteDirectory(SystemUtils.getApplicationSupportDirectoryPath("de.tobias.playpad.PlayPadMain")); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + pluginManager.shutdown(); Worker.shutdown(); } @@ -172,7 +204,7 @@ public class PlayPadImpl implements PlayPad { public void openProject(Project project) { if (mainViewController == null) { - mainViewController = new MainViewControllerV2(mainViewListeners); + mainViewController = new MainViewController(mainViewListeners); } currentProject = project; mainViewController.openProject(project); @@ -181,4 +213,41 @@ public class PlayPadImpl implements PlayPad { public Project getCurrentProject() { return currentProject; } + + public void startup(ResourceBundle resourceBundle) { + registerComponents(resourceBundle); + } + + private void registerComponents(ResourceBundle resourceBundle) { + // Midi + DeviceRegistry.getFactoryInstance().registerDevice(PD12.NAME, PD12.class); + + try { + // Load Components + RegistryCollection registryCollection = PlayPadPlugin.getRegistryCollection(); + + registryCollection.getActions().loadComponentsFromFile("de/tobias/playpad/components/Actions.xml"); + registryCollection.getAudioHandlers().loadComponentsFromFile("de/tobias/playpad/components/AudioHandler.xml"); + registryCollection.getDragModes().loadComponentsFromFile("de/tobias/playpad/components/DragMode.xml"); + registryCollection.getDesigns().loadComponentsFromFile("de/tobias/playpad/components/Design.xml"); + registryCollection.getMappers().loadComponentsFromFile("de/tobias/playpad/components/Mapper.xml"); + registryCollection.getPadContents().loadComponentsFromFile("de/tobias/playpad/components/PadContent.xml"); + registryCollection.getTriggerItems().loadComponentsFromFile("de/tobias/playpad/components/Trigger.xml"); + registryCollection.getMainLayouts().loadComponentsFromFile("de/tobias/playpad/components/Layout.xml"); + + // Set Default + registryCollection.getAudioHandlers().setDefaultID(JavaFXAudioHandler.TYPE); + registryCollection.getDesigns().setDefaultID(ModernGlobalDesign.TYPE); + } catch (IllegalAccessException | ClassNotFoundException | InstantiationException | IOException | DocumentException + | NoSuchComponentException e) { + e.printStackTrace(); + } + + // Key Bindings + GlobalSettings globalSettings = PlayPadPlugin.getImplementation().getGlobalSettings(); + globalSettings.getKeyCollection().loadDefaultFromFile("de/tobias/playpad/components/Keys.xml", resourceBundle); + + // Mapper + MapperRegistry.setOverviewViewController(new MapperOverviewViewController()); + } } diff --git a/PlayWall/src/de/tobias/playpad/PlayPadMain.java b/PlayWall/src/de/tobias/playpad/PlayPadMain.java index cdec5baf549e2c510843e47d536acc7d54a639bf..924c2c8f4c3b513b8d8673ee4fc378bb77a9bfae 100644 --- a/PlayWall/src/de/tobias/playpad/PlayPadMain.java +++ b/PlayWall/src/de/tobias/playpad/PlayPadMain.java @@ -9,25 +9,15 @@ import java.util.Optional; import java.util.ResourceBundle; import java.util.UUID; -import org.dom4j.DocumentException; - -import de.tobias.playpad.action.mapper.MapperRegistry; -import de.tobias.playpad.audio.ClipAudioHandler; -import de.tobias.playpad.audio.JavaFXAudioHandler; -import de.tobias.playpad.audio.TinyAudioHandler; -import de.tobias.playpad.design.modern.ModernGlobalDesign; -import de.tobias.playpad.midi.device.DeviceRegistry; -import de.tobias.playpad.midi.device.PD12; import de.tobias.playpad.project.Project; import de.tobias.playpad.project.ProjectReference; -import de.tobias.playpad.registry.NoSuchComponentException; import de.tobias.playpad.settings.GlobalSettings; import de.tobias.playpad.settings.ProfileReference; import de.tobias.playpad.update.PlayPadUpdater; import de.tobias.playpad.update.UpdateRegistery; import de.tobias.playpad.update.Updates; -import de.tobias.playpad.view.MapperOverviewViewController; import de.tobias.playpad.viewcontroller.LaunchDialog; +import de.tobias.playpad.viewcontroller.dialog.AutoUpdateDialog; import de.tobias.playpad.viewcontroller.dialog.ChangelogDialog; import de.tobias.utils.application.App; import de.tobias.utils.application.ApplicationUtils; @@ -41,32 +31,15 @@ import de.tobias.utils.util.OS.OSType; import de.tobias.utils.util.Worker; import javafx.application.Application; import javafx.application.Platform; -import javafx.scene.control.Alert; -import javafx.scene.control.Alert.AlertType; import javafx.scene.control.ButtonType; import javafx.scene.image.Image; import javafx.stage.Stage; +import javafx.stage.Window; /* * TODOS */ -// PlayWall 5.0.0 -// FIXME XML Tags in String Konstanten - -// Common Updater für Plugins & Programme -// Changelog OK Button -// Keine Schriftgröße bei Cart Layout - -// Profile mit UUID - -// Pad System neu machen -// Neue PadViewController für jedes pad -// Midi Modell Überarbeiten -// Bei Seitenwechsel Pad auf Play lassen - -// TEST Trigger - -// PlayWall 5.1 +// Idden // FEATURE Global Volume Trigger mit x% und 100% // FEATURE Option bei Import Media auch Copy Media in Library // FEATURE lnk für Windows mit Dateiparameter @@ -87,7 +60,7 @@ public class PlayPadMain extends Application implements LocalizationDelegate { private static PlayPadImpl impl; private static PlayPadUpdater updater; - + public static ResourceBundle getUiResourceBundle() { return uiResourceBundle; } @@ -142,7 +115,8 @@ public class PlayPadMain extends Application implements LocalizationDelegate { */ updater = new PlayPadUpdater(); UpdateRegistery.registerUpdateable(updater); - registerComponents(); + + impl.startup(uiResourceBundle); // Load Plugin Path Path pluginFolder; @@ -171,28 +145,27 @@ public class PlayPadMain extends Application implements LocalizationDelegate { } } + // Zeigt Launch Stage ViewController.create(LaunchDialog.class, stage); // Check Updates - checkUpdates(impl.globalSettings); + checkUpdates(impl.globalSettings, stage); } catch (Exception e) { e.printStackTrace(); } } - private void checkUpdates(GlobalSettings globalSettings) { - if (globalSettings.isAutoUpdate()) { + private void checkUpdates(GlobalSettings globalSettings, Window owner) { + if (globalSettings.isAutoUpdate() && !globalSettings.isIgnoreUpdate()) { Worker.runLater(() -> { UpdateRegistery.lookupUpdates(globalSettings.getUpdateChannel()); if (!UpdateRegistery.getAvailableUpdates().isEmpty()) { Platform.runLater(() -> { - Alert alert = new Alert(AlertType.CONFIRMATION); - alert.setHeaderText(Localization.getString(Strings.UI_Dialog_AutoUpdate_Header)); - alert.setContentText(Localization.getString(Strings.UI_Dialog_AutoUpdate_Content)); - alert.showAndWait().filter(item -> item == ButtonType.OK).ifPresent(result -> + AutoUpdateDialog autoUpdateDialog = new AutoUpdateDialog(owner); + autoUpdateDialog.showAndWait().filter(item -> item == ButtonType.APPLY).ifPresent(result -> { try { Updates.startUpdate(); @@ -200,6 +173,9 @@ public class PlayPadMain extends Application implements LocalizationDelegate { e.printStackTrace(); } }); + if (autoUpdateDialog.isSelected()) { + globalSettings.setIgnoreUpdate(true); + } }); } }); @@ -216,50 +192,12 @@ public class PlayPadMain extends Application implements LocalizationDelegate { e.printStackTrace(); // Speichern Fehler } - // Shutdown components - // TODO use AutoCloseable - TinyAudioHandler.shutdown(); - ClipAudioHandler.shutdown(); - impl.shutdown(); Platform.exit(); System.exit(0); } - private void registerComponents() { - // Midi - DeviceRegistry.getFactoryInstance().registerDevice(PD12.NAME, PD12.class); - - try { - // Load Components - RegistryCollection registryCollection = PlayPadPlugin.getRegistryCollection(); - - registryCollection.getActions().loadComponentsFromFile("de/tobias/playpad/components/Actions.xml"); - registryCollection.getAudioHandlers().loadComponentsFromFile("de/tobias/playpad/components/AudioHandler.xml"); - registryCollection.getDragModes().loadComponentsFromFile("de/tobias/playpad/components/DragMode.xml"); - registryCollection.getDesigns().loadComponentsFromFile("de/tobias/playpad/components/Design.xml"); - registryCollection.getMappers().loadComponentsFromFile("de/tobias/playpad/components/Mapper.xml"); - registryCollection.getPadContents().loadComponentsFromFile("de/tobias/playpad/components/PadContent.xml"); - registryCollection.getTriggerItems().loadComponentsFromFile("de/tobias/playpad/components/Trigger.xml"); - registryCollection.getMainLayouts().loadComponentsFromFile("de/tobias/playpad/components/Layout.xml"); - - // Set Default - registryCollection.getAudioHandlers().setDefaultID(JavaFXAudioHandler.NAME); - registryCollection.getDesigns().setDefaultID(ModernGlobalDesign.TYPE); - } catch (IllegalAccessException | ClassNotFoundException | InstantiationException | IOException | DocumentException - | NoSuchComponentException e) { - e.printStackTrace(); - } - - // Key Bindings - GlobalSettings globalSettings = PlayPadPlugin.getImplementation().getGlobalSettings(); - globalSettings.getKeyCollection().loadDefaultFromFile("de/tobias/playpad/components/Keys.xml", uiResourceBundle); - - // Mapper - MapperRegistry.setOverviewViewController(new MapperOverviewViewController()); - } - private void setupPlugins(Path pluginPath) throws IOException, MalformedURLException { // Delete old plugins impl.deletePlugins(); diff --git a/PlayWall/src/de/tobias/playpad/Strings.java b/PlayWall/src/de/tobias/playpad/Strings.java index 7234c38e9af7f4ac4488865c2033ee586f12a52b..ecd9bf62c80aef675ee7fd54034d9ed29e3282c5 100644 --- a/PlayWall/src/de/tobias/playpad/Strings.java +++ b/PlayWall/src/de/tobias/playpad/Strings.java @@ -21,6 +21,7 @@ public class Strings { public static final String UI_Window_Main_Title = "UI.Window.Main.Title"; public static final String UI_Window_Changelog_Title = "UI.Window.Changelog.Title"; public static final String UI_Window_Settings_Title = "UI.Window.Settings.Title"; + public static final String UI_Window_ProjectSettings_Title = "UI.Window.ProjectSettings.Title"; public static final String UI_Window_GlobalSettings_Title = "UI.Window.GlobalSettings.Title"; public static final String UI_Window_PadSettings_Title = "UI.Window.PadSettings.Title"; public static final String UI_Window_PadSettings_Title_Empty = "UI.Window.PadSettings.Title.Empty"; @@ -45,6 +46,7 @@ public class Strings { // UI - Window - Main public static final String UI_Window_Main_CloseRequest = "UI.Window.Main.CloseRequest"; + @Deprecated public static final String UI_Window_Main_SaveRequest = "UI.Window.Main.SaveRequest"; public static final String UI_Window_Main_PageButton = "UI.Window.Main.PageButton"; @@ -61,17 +63,19 @@ public class Strings { public static final String UI_Window_Settings_Player_Title = "UI.Window.Settings.Player.Title"; 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 - Dialogs - DragAndDrop - public static final String UI_Dialog_DragAndDrop_Header = "UI.Dialog.DragAndDrop.Header"; - public static final String UI_Dialog_DragAndDrop_Content = "UI.Dialog.DragAndDrop.Content"; - public static final String UI_Dialog_DragAndDrop_Button = "UI.Dialog.DragAndDrop.Button"; + // UI - Settings - Keys + public static final String UI_Settings_Keys_Conflict_Header = "UI.Settings.Keys.Conflict.Header"; + public static final String UI_Settings_Keys_Conflict_Content = "UI.Settings.Keys.Conflict.Content"; // UI - Dialog - NewProfile 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 +144,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."; @@ -169,9 +174,9 @@ public class Strings { public static final String Info_Mapper_PressKey = "Info.Mapper.PressKey"; // UI - Settings - Aler - + public static final String UI_Settings_Alert_NewKeyShortcut_Text = "UI.Settings.Alert.NewKeyShortcut.Text"; - + // UI - Window - PadSettings public static final String UI_Window_PadSettings_General_Title = "UI.Window.PadSettings.General.Title"; public static final String UI_Window_PadSettings_Player_Title = "UI.Window.PadSettings.Player.Title"; @@ -199,6 +204,19 @@ public class Strings { // UI - Dialog - AutoUpdate 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_Button_Update = "UI.Dialog.AutoUpdate.Button.Update"; + public static final String UI_Dialog_AutoUpdate_Button_Cancel = "UI.Dialog.AutoUpdate.Button.Cancel"; + + // UI - Dialog - Save + public static final String UI_Dialog_Save_Header = "UI.Dialog.Save.Header"; + public static final String UI_Dialog_Save_Content = "UI.Dialog.Save.Content"; + public static final String UI_Dialog_Save_Checkbox = "UI.Dialog.Save.Checkbox"; + public static final String UI_Dialog_Save_Title = "UI.Dialog.Save.Title"; + public static final String UI_Dialog_Save_Button_Yes = "UI.Dialog.Save.Button.Yes"; + public static final String UI_Dialog_Save_Button_No = "UI.Dialog.Save.Button.No"; + public static final String UI_Dialog_Save_Button_Cancel = "UI.Dialog.Save.Button.Cancel"; // Update Channel - Basename public static final String Update_Channel_BaseName = "UpdateChannel."; @@ -208,6 +226,7 @@ public class Strings { // UI - Dialog - Update public static final String UI_Dialog_Update_Cell = "UI.Dialog.Update.Cell"; + public static final String UI_Dialog_Update_Info = "UI.Dialog.Update.Info"; public static final String UI_Window_Settings_Updates_CurrentVersion = "UI.Window.Settings.Updates.CurrentVersion"; // Error - Update - Downlaod @@ -228,4 +247,13 @@ public class Strings { // Drag and Drop Mode public static final String DnDMode_Move = "DnDMode.Move"; public static final String DnDMode_Replace = "DnDMode.Replace"; + + // Main Layout + public static final String MainLayout_Desktop = "MainLayout.Desktop"; + public static final String MainLayout_Touch = "MainLayout.Touch"; + + // Search + public static final String Search_Button = "Search.Button"; + public static final String Search_Placeholder = "Search.Placeholder"; + public static final String Search_Alert_NoMatches = "Search.Alert.NoMatches"; } diff --git a/PlayWall/src/de/tobias/playpad/action/mapper/listener/KeyboardHandler.java b/PlayWall/src/de/tobias/playpad/action/mapper/listener/KeyboardHandler.java index 7f1cee36c2cf53eda66aa443c049aa8fd576d7eb..000a86eb71df201c53943348ac2fd3109157a30c 100644 --- a/PlayWall/src/de/tobias/playpad/action/mapper/listener/KeyboardHandler.java +++ b/PlayWall/src/de/tobias/playpad/action/mapper/listener/KeyboardHandler.java @@ -22,14 +22,13 @@ public class KeyboardHandler implements EventHandler<KeyEvent> { this.project = project; this.mainViewController = mainViewController; - // TEST mainViewController.registerKeyboardListener(KeyEvent.ANY, this); } // KeyType ist nicht unterstützt. @Override public void handle(KeyEvent event) { - if (event.getTarget() instanceof Scene) { // TEST Ob Probleme da sind, wegen Fokus und so + if (event.getTarget() instanceof Scene) { if (!event.isShortcutDown()) { KeyCode code = null; InputType type = null; diff --git a/PlayWall/src/de/tobias/playpad/audio/ClipAudioHandler.java b/PlayWall/src/de/tobias/playpad/audio/ClipAudioHandler.java index 64b3de3e6334da309219d164af8d7470afe84c0e..235b0455c069d0ebd61505bf9995b1edbea28b51 100644 --- a/PlayWall/src/de/tobias/playpad/audio/ClipAudioHandler.java +++ b/PlayWall/src/de/tobias/playpad/audio/ClipAudioHandler.java @@ -18,11 +18,12 @@ import javax.sound.sampled.DataLine.Info; import javax.sound.sampled.FloatControl; import javax.sound.sampled.Mixer; +import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.pad.Pad; import de.tobias.playpad.pad.PadStatus; import de.tobias.playpad.pad.conntent.PadContent; import de.tobias.playpad.pad.content.AudioContent; -import de.tobias.playpad.settings.Profile; +import de.tobias.playpad.settings.GlobalSettings; import de.tobias.utils.util.FileUtils; import javafx.application.Platform; import javafx.beans.property.ObjectProperty; @@ -34,7 +35,7 @@ import javazoom.jl.decoder.JavaLayerException; public class ClipAudioHandler extends AudioHandler { - // TODO Change names + public static final String TYPE = "clip"; public static final String NAME = "Clip (Experimental)"; private static final String MP3 = "mp3"; @@ -84,7 +85,9 @@ public class ClipAudioHandler extends AudioHandler { } Thread.sleep(SLEEP_TIME_POSITION); - } catch (InterruptedException e) {} catch (ConcurrentModificationException e) {} catch (Exception e) { + } catch (InterruptedException e) { + } catch (ConcurrentModificationException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -208,7 +211,8 @@ public class ClipAudioHandler extends AudioHandler { // Convert wenn mp3 if (FileUtils.getFileExtention(url.getFile()).toLowerCase().endsWith(MP3)) { - Path wavPath = Profile.currentProfile().getProfileSettings().getCachePath().resolve(path.getFileName().toString() + ".wav"); + GlobalSettings globalSettings = PlayPadPlugin.getImplementation().getGlobalSettings(); + Path wavPath = globalSettings.getCachePath().resolve(path.getFileName().toString() + ".wav"); url = convertMp3ToWav(path, wavPath, getContent().getPad()); } diff --git a/PlayWall/src/de/tobias/playpad/audio/ClipAudioHandlerConnect.java b/PlayWall/src/de/tobias/playpad/audio/ClipAudioHandlerConnect.java index e78e6895cc3a546dba104369f15f6e4ae96e80ee..bb004a440ff00caa12fc400a3ab4fb9f44cdb2eb 100644 --- a/PlayWall/src/de/tobias/playpad/audio/ClipAudioHandlerConnect.java +++ b/PlayWall/src/de/tobias/playpad/audio/ClipAudioHandlerConnect.java @@ -1,7 +1,7 @@ package de.tobias.playpad.audio; import de.tobias.playpad.pad.conntent.PadContent; -import de.tobias.playpad.viewcontroller.AudioTypeViewController; +import de.tobias.playpad.viewcontroller.AudioHandlerViewController; import de.tobias.playpad.viewcontroller.audio.ClipSettingsViewController; public class ClipAudioHandlerConnect extends AudioHandlerConnect implements AutoCloseable { @@ -12,10 +12,15 @@ public class ClipAudioHandlerConnect extends AudioHandlerConnect implements Auto } @Override - public AudioTypeViewController getAudioViewController() { + public AudioHandlerViewController getAudioHandlerSettingsViewController() { return new ClipSettingsViewController(); } - + + @Override + public String getType() { + return ClipAudioHandler.TYPE; + } + @Override public void close() throws Exception { TinyAudioHandler.shutdown(); diff --git a/PlayWall/src/de/tobias/playpad/audio/JavaFXAudioHandler.java b/PlayWall/src/de/tobias/playpad/audio/JavaFXAudioHandler.java index 4792e37a92538363d0473e2ffac5a974246d8054..f9c5a4651d921efb605128d8810b0c5558da32e6 100644 --- a/PlayWall/src/de/tobias/playpad/audio/JavaFXAudioHandler.java +++ b/PlayWall/src/de/tobias/playpad/audio/JavaFXAudioHandler.java @@ -18,6 +18,7 @@ import javafx.util.Duration; public class JavaFXAudioHandler extends AudioHandler implements Equalizable { + public static final String TYPE = "JavaFx"; public static final String NAME = "Java FX Media"; private Media media; @@ -90,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); } @@ -107,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); } @@ -132,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); @@ -146,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/audio/JavaFXHandlerConnect.java b/PlayWall/src/de/tobias/playpad/audio/JavaFXHandlerConnect.java index 9a5e3fb8cfc71d87b064285e4d8057a43472639b..baca001b6e97120e49f96f5bde06800138aded15 100644 --- a/PlayWall/src/de/tobias/playpad/audio/JavaFXHandlerConnect.java +++ b/PlayWall/src/de/tobias/playpad/audio/JavaFXHandlerConnect.java @@ -1,7 +1,7 @@ package de.tobias.playpad.audio; import de.tobias.playpad.pad.conntent.PadContent; -import de.tobias.playpad.viewcontroller.AudioTypeViewController; +import de.tobias.playpad.viewcontroller.AudioHandlerViewController; public class JavaFXHandlerConnect extends AudioHandlerConnect { @@ -11,7 +11,12 @@ public class JavaFXHandlerConnect extends AudioHandlerConnect { } @Override - public AudioTypeViewController getAudioViewController() { + public AudioHandlerViewController getAudioHandlerSettingsViewController() { return null; } + + @Override + public String getType() { + return JavaFXAudioHandler.TYPE; + } } diff --git a/PlayWall/src/de/tobias/playpad/audio/TinyAudioHandler.java b/PlayWall/src/de/tobias/playpad/audio/TinyAudioHandler.java index 7bf652f8fa50e2f7dffd0d9bcec260dd2dba41f5..c25c2f83d9a86a357330e34afb167610f5a0e733 100644 --- a/PlayWall/src/de/tobias/playpad/audio/TinyAudioHandler.java +++ b/PlayWall/src/de/tobias/playpad/audio/TinyAudioHandler.java @@ -18,10 +18,12 @@ import javax.sound.sampled.LineUnavailableException; import javax.sound.sampled.Mixer.Info; import javax.sound.sampled.UnsupportedAudioFileException; +import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.pad.Pad; import de.tobias.playpad.pad.PadStatus; import de.tobias.playpad.pad.conntent.PadContent; import de.tobias.playpad.pad.content.AudioContent; +import de.tobias.playpad.settings.GlobalSettings; import de.tobias.playpad.settings.Profile; import de.tobias.utils.util.FileUtils; import javafx.application.Platform; @@ -40,8 +42,10 @@ public class TinyAudioHandler extends AudioHandler { public static final String SOUND_CARD = "SoundCard"; + public static final String TYPE = "TinyAudio"; public static final String NAME = "Java Audiostream"; private static final String MP3 = "mp3"; + private static final int SLEEP_TIME_POSITION = 50; private static ExecutorService executorService; @@ -94,7 +98,9 @@ public class TinyAudioHandler extends AudioHandler { } Thread.sleep(SLEEP_TIME_POSITION); - } catch (InterruptedException e) {} catch (ConcurrentModificationException e) {} catch (Exception e) { + } catch (InterruptedException e) { + } catch (ConcurrentModificationException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -226,7 +232,8 @@ public class TinyAudioHandler extends AudioHandler { // Convert wenn mp3 if (FileUtils.getFileExtention(url.getFile()).toLowerCase().endsWith(MP3)) { - Path wavPath = Profile.currentProfile().getProfileSettings().getCachePath().resolve(path.getFileName().toString() + ".wav"); + GlobalSettings globalSettings = PlayPadPlugin.getImplementation().getGlobalSettings(); + Path wavPath = globalSettings.getCachePath().resolve(path.getFileName().toString() + ".wav"); url = convertMp3ToWav(path, wavPath, getContent().getPad()); } diff --git a/PlayWall/src/de/tobias/playpad/audio/TinyAudioHandlerConnect.java b/PlayWall/src/de/tobias/playpad/audio/TinyAudioHandlerConnect.java index c8e8904c0b953c3dfa3e99f7e162bbe5ca7cf6c4..cf8388f1f83557cf8c9ab87b7a84c2faca1de8ee 100644 --- a/PlayWall/src/de/tobias/playpad/audio/TinyAudioHandlerConnect.java +++ b/PlayWall/src/de/tobias/playpad/audio/TinyAudioHandlerConnect.java @@ -1,7 +1,7 @@ package de.tobias.playpad.audio; import de.tobias.playpad.pad.conntent.PadContent; -import de.tobias.playpad.viewcontroller.AudioTypeViewController; +import de.tobias.playpad.viewcontroller.AudioHandlerViewController; import de.tobias.playpad.viewcontroller.audio.TinySoundSettingsViewController; public class TinyAudioHandlerConnect extends AudioHandlerConnect implements AutoCloseable { @@ -12,10 +12,15 @@ public class TinyAudioHandlerConnect extends AudioHandlerConnect implements Auto } @Override - public AudioTypeViewController getAudioViewController() { + public AudioHandlerViewController getAudioHandlerSettingsViewController() { return new TinySoundSettingsViewController(); } + @Override + public String getType() { + return TinyAudioHandler.TYPE; + } + @Override public void close() throws Exception { TinyAudioHandler.shutdown(); diff --git a/PlayWall/src/de/tobias/playpad/components/AudioHandler.xml b/PlayWall/src/de/tobias/playpad/components/AudioHandler.xml index ae4c5e196346cf29bb721eda3ca3ff88470e8ea3..f217977524027c6ea86e2d752a2bcc54852390a3 100644 --- a/PlayWall/src/de/tobias/playpad/components/AudioHandler.xml +++ b/PlayWall/src/de/tobias/playpad/components/AudioHandler.xml @@ -1,5 +1,5 @@ <Actions> - <Component id="Java FX Media">de.tobias.playpad.audio.JavaFXHandlerConnect</Component> - <Component id="Java Audiostream">de.tobias.playpad.audio.TinyAudioHandlerConnect</Component> - <Component id="Clip (Experimental)">de.tobias.playpad.audio.ClipAudioHandlerConnect</Component> + <Component id="JavaFx">de.tobias.playpad.audio.JavaFXHandlerConnect</Component> + <Component id="TinyAudio">de.tobias.playpad.audio.TinyAudioHandlerConnect</Component> + <Component id="clip">de.tobias.playpad.audio.ClipAudioHandlerConnect</Component> </Actions> \ No newline at end of file diff --git a/PlayWall/src/de/tobias/playpad/design/classic/ClassicCartDesign.java b/PlayWall/src/de/tobias/playpad/design/classic/ClassicCartDesign.java index b0acae1a9b7f62f49739778462dc7195821305fa..af5a1e1ff864e345625432827a6911c7b0c3a7bd 100644 --- a/PlayWall/src/de/tobias/playpad/design/classic/ClassicCartDesign.java +++ b/PlayWall/src/de/tobias/playpad/design/classic/ClassicCartDesign.java @@ -15,8 +15,8 @@ import de.tobias.playpad.PseudoClasses; import de.tobias.playpad.design.CartDesign; import de.tobias.playpad.design.Design; import de.tobias.playpad.design.GlobalDesign; -import de.tobias.playpad.pad.view.IPadViewV2; -import de.tobias.playpad.pad.viewcontroller.IPadViewControllerV2; +import de.tobias.playpad.pad.view.IPadView; +import de.tobias.playpad.pad.viewcontroller.IPadViewController; import de.tobias.playpad.settings.Warning; import de.tobias.utils.util.ColorXMLUtils; import javafx.application.Platform; @@ -210,8 +210,8 @@ public class ClassicCartDesign extends Design implements CartDesign { } @Override - public void handleWarning(IPadViewControllerV2 controller, Warning warning, GlobalDesign layout) { - final IPadViewV2 view = controller.getView(); + public void handleWarning(IPadViewController controller, Warning warning, GlobalDesign layout) { + final IPadView view = controller.getView(); try { while (true) { diff --git a/PlayWall/src/de/tobias/playpad/design/classic/ClassicGlobalDesign.java b/PlayWall/src/de/tobias/playpad/design/classic/ClassicGlobalDesign.java index 93bfe0763f1bf4a92c734bf80d5a80cbe0ebb37b..e317fc50cd6c4398292a962305ef26245ed71344 100644 --- a/PlayWall/src/de/tobias/playpad/design/classic/ClassicGlobalDesign.java +++ b/PlayWall/src/de/tobias/playpad/design/classic/ClassicGlobalDesign.java @@ -12,8 +12,8 @@ import de.tobias.playpad.design.Design; import de.tobias.playpad.design.GlobalDesign; import de.tobias.playpad.pad.Pad; import de.tobias.playpad.pad.PadSettings; -import de.tobias.playpad.pad.view.IPadViewV2; -import de.tobias.playpad.pad.viewcontroller.IPadViewControllerV2; +import de.tobias.playpad.pad.view.IPadView; +import de.tobias.playpad.pad.viewcontroller.IPadViewController; import de.tobias.playpad.project.Project; import de.tobias.playpad.settings.Warning; import de.tobias.playpad.viewcontroller.main.IMainViewController; @@ -345,8 +345,8 @@ public class ClassicGlobalDesign extends Design implements GlobalDesign { } @Override - public void handleWarning(IPadViewControllerV2 controller, Warning warning) { - final IPadViewV2 view = controller.getView(); + public void handleWarning(IPadViewController controller, Warning warning) { + final IPadView view = controller.getView(); try { while (true) { diff --git a/PlayWall/src/de/tobias/playpad/design/modern/ModernCartDesign.java b/PlayWall/src/de/tobias/playpad/design/modern/ModernCartDesign.java index a669ac9f977997a6a6c5102d2a520aaab1d57f0a..86fde0806c5beead2460a7394eddb8a40ccc9d97 100644 --- a/PlayWall/src/de/tobias/playpad/design/modern/ModernCartDesign.java +++ b/PlayWall/src/de/tobias/playpad/design/modern/ModernCartDesign.java @@ -10,7 +10,7 @@ import de.tobias.playpad.design.FadeableColor; import de.tobias.playpad.design.GlobalDesign; import de.tobias.playpad.pad.Pad; import de.tobias.playpad.pad.conntent.play.Durationable; -import de.tobias.playpad.pad.viewcontroller.IPadViewControllerV2; +import de.tobias.playpad.pad.viewcontroller.IPadViewController; import de.tobias.playpad.settings.Warning; import javafx.scene.paint.Color; import javafx.util.Duration; @@ -75,7 +75,7 @@ public class ModernCartDesign extends Design implements CartDesign, DesignColorA // Warn Handler -> Animation oder Blinken @Override - public void handleWarning(IPadViewControllerV2 controller, Warning warning, GlobalDesign layout) { + public void handleWarning(IPadViewController controller, Warning warning, GlobalDesign layout) { if (layout instanceof ModernGlobalDesign && ((ModernGlobalDesign) layout).isWarnAnimation()) { warnAnimation(controller, warning); } else { @@ -84,11 +84,11 @@ public class ModernCartDesign extends Design implements CartDesign, DesignColorA } @Override - public void stopWarning(IPadViewControllerV2 controller) { + public void stopWarning(IPadViewController controller) { ModernDesignAnimator.stopAnimation(controller); } - private void warnAnimation(IPadViewControllerV2 controller, Warning warning) { + private void warnAnimation(IPadViewController controller, Warning warning) { FadeableColor stopColor = new FadeableColor(this.backgroundColor.getColorHi(), this.backgroundColor.getColorLow()); FadeableColor playColor = new FadeableColor(this.playColor.getColorHi(), this.playColor.getColorLow()); diff --git a/PlayWall/src/de/tobias/playpad/design/modern/ModernDesignAnimator.java b/PlayWall/src/de/tobias/playpad/design/modern/ModernDesignAnimator.java index 95afa80a48bb990e3ab53ac4e7ae0d20fa1fed92..4d63d00aa52f650374858cd7debe77d3a8922612 100644 --- a/PlayWall/src/de/tobias/playpad/design/modern/ModernDesignAnimator.java +++ b/PlayWall/src/de/tobias/playpad/design/modern/ModernDesignAnimator.java @@ -4,8 +4,8 @@ import java.util.HashMap; import de.tobias.playpad.PseudoClasses; import de.tobias.playpad.design.FadeableColor; -import de.tobias.playpad.pad.view.IPadViewV2; -import de.tobias.playpad.pad.viewcontroller.IPadViewControllerV2; +import de.tobias.playpad.pad.view.IPadView; +import de.tobias.playpad.pad.viewcontroller.IPadViewController; import javafx.animation.KeyFrame; import javafx.animation.KeyValue; import javafx.animation.Timeline; @@ -23,7 +23,7 @@ public class ModernDesignAnimator { private static HashMap<Integer, Timeline> timelines = new HashMap<>(); - public static void animateFade(IPadViewControllerV2 padViewController, FadeableColor startColor, FadeableColor endColor, Duration duration) { + public static void animateFade(IPadViewController padViewController, FadeableColor startColor, FadeableColor endColor, Duration duration) { int index = padViewController.getPad().getIndex(); if (timelines.containsKey(index)) { @@ -57,7 +57,7 @@ public class ModernDesignAnimator { } - public static void animateWarn(IPadViewControllerV2 padViewController, FadeableColor startColor, FadeableColor endColor, Duration duration) { + public static void animateWarn(IPadViewController padViewController, FadeableColor startColor, FadeableColor endColor, Duration duration) { int index = padViewController.getPad().getIndex(); if (timelines.containsKey(index)) { @@ -95,7 +95,7 @@ public class ModernDesignAnimator { timelines.put(index, timeline); } - public static void stopAnimation(IPadViewControllerV2 controller) { + public static void stopAnimation(IPadViewController controller) { int index = controller.getPad().getIndex(); if (timelines.containsKey(index)) { @@ -103,8 +103,8 @@ public class ModernDesignAnimator { } } - public static void warnFlash(IPadViewControllerV2 controller) { - final IPadViewV2 view = controller.getView(); + public static void warnFlash(IPadViewController controller) { + final IPadView view = controller.getView(); try { while (true) { Platform.runLater(() -> diff --git a/PlayWall/src/de/tobias/playpad/design/modern/ModernGlobalDesign.java b/PlayWall/src/de/tobias/playpad/design/modern/ModernGlobalDesign.java index 1a274e589ecf717a8708ac2963d4fac6c4b77346..8a1903ab15afc82900c77eb0bca03a8d6c57f9b3 100644 --- a/PlayWall/src/de/tobias/playpad/design/modern/ModernGlobalDesign.java +++ b/PlayWall/src/de/tobias/playpad/design/modern/ModernGlobalDesign.java @@ -15,7 +15,7 @@ import de.tobias.playpad.design.GlobalDesign; import de.tobias.playpad.pad.Pad; import de.tobias.playpad.pad.PadSettings; import de.tobias.playpad.pad.conntent.play.Durationable; -import de.tobias.playpad.pad.viewcontroller.IPadViewControllerV2; +import de.tobias.playpad.pad.viewcontroller.IPadViewController; import de.tobias.playpad.project.Project; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.settings.Warning; @@ -31,7 +31,7 @@ public class ModernGlobalDesign extends Design implements GlobalDesign, DesignCo public static final String TYPE = "modern"; public static final double minWidth = 205; - public static final double minHeight = 110; + public static final double minHeight = 115; private ModernColor backgroundColor = ModernColor.GRAY1; private ModernColor playColor = ModernColor.RED3; @@ -274,7 +274,7 @@ public class ModernGlobalDesign extends Design implements GlobalDesign, DesignCo // Warn Handler -> Animation oder Blinken @Override - public void handleWarning(IPadViewControllerV2 controller, Warning warning) { + public void handleWarning(IPadViewController controller, Warning warning) { if (isWarnAnimation) { warnAnimation(controller, warning); } else { @@ -283,11 +283,11 @@ public class ModernGlobalDesign extends Design implements GlobalDesign, DesignCo } @Override - public void stopWarning(IPadViewControllerV2 controller) { + public void stopWarning(IPadViewController controller) { ModernDesignAnimator.stopAnimation(controller); } - private void warnAnimation(IPadViewControllerV2 controller, Warning warning) { + private void warnAnimation(IPadViewController controller, Warning warning) { FadeableColor stopColor = new FadeableColor(this.backgroundColor.getColorHi(), this.backgroundColor.getColorLow()); FadeableColor playColor = new FadeableColor(this.playColor.getColorHi(), this.playColor.getColorLow()); diff --git a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMainLayoutConnect.java b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMainLayoutConnect.java index e39b0662a6fded232f1cfed715e10a6432e4fe21..9d9b3657b2436e236cf07934870d735adbc84ee4 100644 --- a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMainLayoutConnect.java +++ b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMainLayoutConnect.java @@ -2,16 +2,27 @@ package de.tobias.playpad.layout.desktop; import java.util.Stack; -import de.tobias.playpad.pad.view.IPadViewV2; +import de.tobias.playpad.Strings; +import de.tobias.playpad.pad.view.IPadView; import de.tobias.playpad.view.main.MainLayoutConnect; import de.tobias.playpad.viewcontroller.main.IMainViewController; import de.tobias.playpad.viewcontroller.main.MenuToolbarViewController; +import de.tobias.utils.util.Localization; +/** + * Desktop Implmentierung des Main Layouts. + * + * @author tobias + * + * @since 5.1.0 + */ public class DesktopMainLayoutConnect implements MainLayoutConnect { + private static final String TYPE = "Desktop"; + private DesktopMenuToolbarViewController desktopMenuToolbarViewController; - private Stack<IPadViewV2> recyclingStack; + private Stack<IPadView> recyclingStack; public DesktopMainLayoutConnect() { recyclingStack = new Stack<>(); @@ -19,12 +30,12 @@ public class DesktopMainLayoutConnect implements MainLayoutConnect { @Override public String getType() { - return "Desktop"; + return TYPE; } @Override public String name() { - return "Desktop Modus"; // TODO Localize + return Localization.getString(Strings.MainLayout_Desktop); } @Override @@ -36,7 +47,7 @@ public class DesktopMainLayoutConnect implements MainLayoutConnect { } @Override - public IPadViewV2 createPadView() { + public IPadView createPadView() { if (!recyclingStack.isEmpty()) { return recyclingStack.pop(); } @@ -44,7 +55,7 @@ public class DesktopMainLayoutConnect implements MainLayoutConnect { } @Override - public void recyclePadView(IPadViewV2 padView) { + public void recyclePadView(IPadView padView) { recyclingStack.push(padView); } diff --git a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMenuToolbarViewController.java b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMenuToolbarViewController.java index adc1a04d9b370bd22cfa28997bad275ccfba4b13..6fe5003cf5241fdb29778da90997145b657d2ab7 100644 --- a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMenuToolbarViewController.java +++ b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMenuToolbarViewController.java @@ -17,11 +17,10 @@ import de.tobias.playpad.Strings; import de.tobias.playpad.midi.Midi; import de.tobias.playpad.pad.Pad; import de.tobias.playpad.pad.PadStatus; -import de.tobias.playpad.pad.view.IPadViewV2; +import de.tobias.playpad.pad.view.IPadView; import de.tobias.playpad.project.Project; 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; @@ -31,6 +30,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 +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; @@ -55,6 +52,7 @@ import de.tobias.utils.util.Localization; import de.tobias.utils.util.Worker; import de.tobias.utils.util.net.FileUpload; import javafx.application.Platform; +import javafx.beans.binding.Bindings; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.fxml.FXML; @@ -68,10 +66,8 @@ import javafx.scene.control.Label; import javafx.scene.control.Menu; import javafx.scene.control.MenuBar; import javafx.scene.control.MenuItem; -import javafx.scene.control.RadioMenuItem; import javafx.scene.control.Slider; import javafx.scene.control.TextField; -import javafx.scene.control.ToggleGroup; import javafx.scene.input.KeyCombination; import javafx.scene.layout.HBox; import javafx.stage.Modality; @@ -115,7 +111,7 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro private GlobalSettingsViewController globalSettingsViewController; public DesktopMenuToolbarViewController(IMainViewController controller) { - super("header", "de/tobias/playpad/assets/view/main/desktop/", PlayPadMain.getUiResourceBundle(), controller); + super("header", "de/tobias/playpad/assets/view/main/desktop/", PlayPadMain.getUiResourceBundle()); this.mainViewController = controller; initLayoutMenu(); @@ -127,59 +123,50 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro toolbarHBox.prefWidthProperty().bind(toolbar.widthProperty().subtract(25)); toolbarHBox.prefHeightProperty().bind(toolbar.minHeightProperty()); - showLiveInfo(false); + // Hide Extension menu then no items are in there + extensionMenu.visibleProperty().bind(Bindings.size(extensionMenu.getItems()).greaterThan(0)); + // Help Menu --> HIDDEN TODO + helpMenu.setVisible(false); helpMenu.getItems().add(new HelpMenuItem(helpMenu)); } private void initLayoutMenu() { ProfileSettings profileSettings = Profile.currentProfile().getProfileSettings(); Registry<MainLayoutConnect> mainLayouts = PlayPadPlugin.getRegistryCollection().getMainLayouts(); - ToggleGroup group = new ToggleGroup(); int index = 1; // Für Tastenkombination - for (String layoutType : mainLayouts.getTypes()) { - try { - MainLayoutConnect connect = mainLayouts.getComponent(layoutType); + for (MainLayoutConnect connect : mainLayouts.getComponents()) { + if (!connect.getType().equals(profileSettings.getMainLayoutType())) { + MenuItem item = new MenuItem(connect.name()); - RadioMenuItem item = new RadioMenuItem(connect.name()); - item.setUserData(connect); - group.getToggles().add(item); + item.setOnAction(e -> + { + mainViewController.setMainLayout(connect); + Profile.currentProfile().getProfileSettings().setMainLayoutType(connect.getType()); + }); // Key Combi if (index < 10) { item.setAccelerator(KeyCombination.keyCombination("Shortcut+" + index)); } - if (connect.getType().equals(profileSettings.getMainLayoutType())) { - item.setSelected(true); - } - layoutMenu.getItems().add(item); - } catch (NoSuchComponentException e) { - e.printStackTrace(); + index++; } - index++; } - - group.selectedToggleProperty().addListener((a, b, c) -> - { - if (c instanceof RadioMenuItem) { - RadioMenuItem menuItem = (RadioMenuItem) c; - if (menuItem.getUserData() instanceof MainLayoutConnect) { - MainLayoutConnect connect = (MainLayoutConnect) menuItem.getUserData(); - mainViewController.setMainLayout(connect); - Profile.currentProfile().getProfileSettings().setMainLayoutType(connect.getType()); - } - } - }); } @Override public void setOpenProject(Project project) { super.setOpenProject(project); - if (project != null) + + liveLabel.visibleProperty().unbind(); + + if (project != null) { createRecentDocumentMenuItems(); + liveLabel.visibleProperty().bind(project.activePlayerProperty().greaterThan(0)); + } } @Override @@ -193,6 +180,7 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro for (int i = 0; i < openProject.getSettings().getPageCount(); i++) { Button button = new Button(Localization.getString(Strings.UI_Window_Main_PageButton, (i + 1))); button.setUserData(i); + button.setOnDragOver(new PageButtonDragHandler(mainViewController, i)); button.setFocusTraversable(false); button.setOnAction(this); pageHBox.getChildren().add(button); @@ -263,8 +251,6 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro public void addMenuItem(MenuItem item, MenuType type) { if (type == MenuType.EXTENSION) { extensionMenu.getItems().add(item); - } else if (type == MenuType.SETTINGS) { - // TODO Implement } } @@ -272,18 +258,6 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro public void removeMenuItem(MenuItem item) { if (extensionMenu.getItems().contains(item)) extensionMenu.getItems().remove(item); - - // TODO Implement - } - - @Override - public boolean isAlwaysOnTopActive() { - return alwaysOnTopItem.isSelected(); - } - - @Override - public boolean isFullscreenActive() { - return fullScreenMenuItem.isSelected(); } @Override @@ -307,17 +281,12 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro // Disable Drag Mode wenn aktiv und diese Toolbar deaktiviert wird. if (dndModeMenuItem.isSelected()) { PadDragListener.setDndMode(false); - for (IPadViewV2 view : mainViewController.getPadViews()) { + for (IPadView view : mainViewController.getPadViews()) { view.enableDragAndDropDesignMode(false); } } } - @Override - public void showLiveInfo(boolean show) { - liveLabel.setVisible(show); - } - @Override public Slider getVolumeSlider() { return volumeSlider; @@ -431,20 +400,18 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro @FXML void dndModeHandler(ActionEvent event) { if (dndModeMenuItem.isSelected()) { - ProfileSettings settings = Profile.currentProfile().getProfileSettings(); + GlobalSettings settings = PlayPadPlugin.getImplementation().getGlobalSettings(); Project currentProject = PlayPadMain.getProgramInstance().getCurrentProject(); - if (settings.isLiveMode() && settings.isLiveModeDrag() && currentProject.getPlayedPlayers() > 0) { - mainViewController.showLiveInfo(); - } else { + if (settings.isLiveMode() && settings.isLiveModeDrag() && currentProject.getActivePlayers() == 0) { PadDragListener.setDndMode(true); - for (IPadViewV2 view : mainViewController.getPadViews()) { + for (IPadView view : mainViewController.getPadViews()) { view.enableDragAndDropDesignMode(true); } } } else { PadDragListener.setDndMode(false); - for (IPadViewV2 view : mainViewController.getPadViews()) { + for (IPadView view : mainViewController.getPadViews()) { view.enableDragAndDropDesignMode(false); } } @@ -453,7 +420,7 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro @FXML void errorMenuHandler(ActionEvent event) { - // TODO Implement + ErrorSummaryDialog.getInstance().getStage().show(); } @FXML @@ -467,7 +434,6 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro @FXML void projectSettingsHandler(ActionEvent event) { - Midi midi = Midi.getInstance(); Project currentProject = PlayPadMain.getProgramInstance().getCurrentProject(); if (projectSettingsViewController == null) { @@ -475,15 +441,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(); }; @@ -501,10 +459,9 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro Midi midi = Midi.getInstance(); Project currentProject = PlayPadMain.getProgramInstance().getCurrentProject(); - ProfileSettings settings = Profile.currentProfile().getProfileSettings(); + GlobalSettings settings = PlayPadPlugin.getImplementation().getGlobalSettings(); - if (settings.isLiveMode() && settings.isLiveModeSettings() && currentProject.getPlayedPlayers() > 0) { - mainViewController.showLiveInfo(); + if (settings.isLiveMode() && settings.isLiveModeSettings() && currentProject.getActivePlayers() > 0) { return; } @@ -515,18 +472,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(); }; @@ -547,15 +492,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(); }; @@ -583,9 +519,9 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro @FXML void searchPadHandler(ActionEvent event) { TextField field = TextFields.createClearableTextField(); - field.setPromptText("Suche"); // TODO i18n + field.setPromptText(Localization.getString(Strings.Search_Placeholder)); - Button button = new Button("Suchen"); // TODO i18n + Button button = new Button(Localization.getString(Strings.Search_Button)); button.setOnAction(new DesktopSearchController(field, this)); HBox box = new HBox(14, field, button); diff --git a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopPadView.java b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopPadView.java index 5d7a4f79555afdaa39ae577f8f71024c986776fa..72d74d982d3b7465e7abe24e6b4c0a58774e56ea 100644 --- a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopPadView.java +++ b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopPadView.java @@ -8,8 +8,8 @@ import de.tobias.playpad.pad.conntent.PadContent; import de.tobias.playpad.pad.conntent.PadContentConnect; import de.tobias.playpad.pad.conntent.play.Pauseable; import de.tobias.playpad.pad.view.IPadContentView; -import de.tobias.playpad.pad.view.IPadViewV2; -import de.tobias.playpad.pad.viewcontroller.IPadViewControllerV2; +import de.tobias.playpad.pad.view.IPadView; +import de.tobias.playpad.pad.viewcontroller.IPadViewController; import de.tobias.playpad.registry.NoSuchComponentException; import de.tobias.playpad.view.EmptyPadView; import de.tobias.utils.ui.icon.FontAwesomeType; @@ -30,7 +30,7 @@ import javafx.scene.layout.Region; import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; -public class DesktopPadView implements IPadViewV2 { +public class DesktopPadView implements IPadView { private Label indexLabel; private Label loopLabel; @@ -164,7 +164,7 @@ public class DesktopPadView implements IPadViewV2 { } @Override - public IPadViewControllerV2 getViewController() { + public IPadViewController getViewController() { return controller; } diff --git a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopPadViewController.java b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopPadViewController.java index 0ae505cfe09061350771520d7228e40f05bd9f70..0384a296e54b07d84224036dd1865e53d0717f57 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; @@ -19,9 +20,10 @@ import de.tobias.playpad.pad.listener.PadDurationListener; import de.tobias.playpad.pad.listener.PadLockedListener; import de.tobias.playpad.pad.listener.PadPositionListener; import de.tobias.playpad.pad.listener.PadStatusListener; -import de.tobias.playpad.pad.view.IPadViewV2; -import de.tobias.playpad.pad.viewcontroller.IPadViewControllerV2; +import de.tobias.playpad.pad.view.IPadView; +import de.tobias.playpad.pad.viewcontroller.IPadViewController; import de.tobias.playpad.registry.NoSuchComponentException; +import de.tobias.playpad.settings.GlobalSettings; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.settings.ProfileSettings; import de.tobias.playpad.view.FileDragOptionView; @@ -40,7 +42,7 @@ import javafx.stage.FileChooser.ExtensionFilter; import javafx.stage.Stage; import javafx.util.Duration; -public class DesktopPadViewController implements IPadViewControllerV2, EventHandler<ActionEvent> { +public class DesktopPadViewController implements IPadViewController, EventHandler<ActionEvent> { protected static final String CURRENT_PAGE_BUTTON = "current-page-button"; private static final String OPEN_FOLDER = "openFolder"; @@ -56,7 +58,6 @@ public class DesktopPadViewController implements IPadViewControllerV2, EventHand private IPadPositionListener padPositionListener; private PadDragListener padDragListener; - private transient PadSettingsViewController padSettingsViewController; public DesktopPadViewController(DesktopPadView padView) { this.padView = padView; @@ -67,7 +68,8 @@ public class DesktopPadViewController implements IPadViewControllerV2, EventHand padDurationListener = new PadDurationListener(this); padPositionListener = new PadPositionListener(this); - // Listener muss nur einmal hier hinzugefügt werden, weil bei einem neuen Profile, werden neue PadViewController erzeugt + // Listener muss nur einmal hier hinzugefügt werden, weil bei einem neuen Profile, werden neue PadViewController + // erzeugt ProfileSettings profileSettings = Profile.currentProfile().getProfileSettings(); profileSettings.lockedProperty().addListener(padLockedListener); } @@ -78,7 +80,7 @@ public class DesktopPadViewController implements IPadViewControllerV2, EventHand } @Override - public IPadViewV2 getView() { + public IPadView getView() { return padView; } @@ -146,6 +148,11 @@ public class DesktopPadViewController implements IPadViewControllerV2, EventHand this.padDragListener = null; this.pad = null; + + // Hide Loading Animation + if (getView() != null) + getView().showBusyView(false); + } @Override @@ -187,10 +194,9 @@ public class DesktopPadViewController implements IPadViewControllerV2, EventHand } private void onNew(ActionEvent event) throws NoSuchComponentException { - ProfileSettings settings = Profile.currentProfile().getProfileSettings(); + GlobalSettings settings = PlayPadPlugin.getImplementation().getGlobalSettings(); if (pad.getProject() != null) { - if (settings.isLiveMode() && settings.isLiveModeFile() && pad.getProject().getPlayedPlayers() > 0) { - PlayPadPlugin.getImplementation().getMainViewController().showLiveInfo(); + if (settings.isLiveMode() && settings.isLiveModeFile() && pad.getProject().getActivePlayers() > 0) { return; } } @@ -244,7 +250,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(); } @@ -252,26 +258,24 @@ public class DesktopPadViewController implements IPadViewControllerV2, EventHand } private void onSettings() { - ProfileSettings settings = Profile.currentProfile().getProfileSettings(); + GlobalSettings settings = PlayPadPlugin.getImplementation().getGlobalSettings(); IMainViewController mvc = PlayPadPlugin.getImplementation().getMainViewController(); if (mvc != null) { if (pad.getProject() != null) { - if (settings.isLiveMode() && settings.isLiveModeSettings() && pad.getProject().getPlayedPlayers() > 0) { - mvc.showLiveInfo(); + if (settings.isLiveMode() && settings.isLiveModeSettings() && pad.getProject().getActivePlayers() > 0) { return; } } Stage owner = mvc.getStage(); - if (padSettingsViewController == null) { - padSettingsViewController = new PadSettingsViewController(pad, owner); - padSettingsViewController.getStage().setOnHiding(ev -> - { - if (padView != null && pad != null) - padView.setTriggerLabelActive(pad.getPadSettings().hasTriggerItems()); - }); - } + + PadSettingsViewController padSettingsViewController = new PadSettingsViewController(pad, owner); + padSettingsViewController.getStage().setOnHiding(ev -> + { + if (padView != null && pad != null) + padView.setTriggerLabelActive(pad.getPadSettings().hasTriggerItems()); + }); padSettingsViewController.getStage().show(); } } diff --git a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopSearchController.java b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopSearchController.java index dbe3475f6d5e2b6a56eafb54f4577c7a737fe9a2..ddeb4138d48ceeb95bdbc745018e02049f0884c5 100644 --- a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopSearchController.java +++ b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopSearchController.java @@ -2,10 +2,12 @@ package de.tobias.playpad.layout.desktop; import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.PlayPadPlugin; +import de.tobias.playpad.Strings; import de.tobias.playpad.pad.Pad; import de.tobias.playpad.pad.PadStatus; import de.tobias.playpad.project.Project; import de.tobias.utils.ui.Alertable; +import de.tobias.utils.util.Localization; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.control.TextField; @@ -45,7 +47,7 @@ public class DesktopSearchController implements EventHandler<ActionEvent> { } } } - alertable.showInfoMessage("Keine weiteren Treffer gefunden.", PlayPadMain.stageIcon.orElse(null)); // TODO i18n + alertable.showInfoMessage(Localization.getString(Strings.Search_Alert_NoMatches), PlayPadMain.stageIcon.orElse(null)); currentIndex = 0; } } diff --git a/PlayWall/src/de/tobias/playpad/layout/desktop/PageButtonDragHandler.java b/PlayWall/src/de/tobias/playpad/layout/desktop/PageButtonDragHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..64b67e7204d8d147366d572b64b8d2b2954da50b --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/layout/desktop/PageButtonDragHandler.java @@ -0,0 +1,23 @@ +package de.tobias.playpad.layout.desktop; + +import de.tobias.playpad.viewcontroller.main.IMainViewController; +import javafx.event.EventHandler; +import javafx.scene.input.DragEvent; + +public class PageButtonDragHandler implements EventHandler<DragEvent> { + + private IMainViewController controller; + private int page; + + public PageButtonDragHandler(IMainViewController controller, int page) { + this.controller = controller; + this.page = page; + } + + public void handle(DragEvent event) { + if (event.getEventType() == DragEvent.DRAG_OVER) { + controller.showPage(page); + } + } + +} diff --git a/PlayWall/src/de/tobias/playpad/layout/touch/TouchMainLayoutConnect.java b/PlayWall/src/de/tobias/playpad/layout/touch/TouchMainLayoutConnect.java index be191f56a28e7532539d29cb62599978eddc4235..07126bc71dff9c20f93a7e497463b508d07d739e 100644 --- a/PlayWall/src/de/tobias/playpad/layout/touch/TouchMainLayoutConnect.java +++ b/PlayWall/src/de/tobias/playpad/layout/touch/TouchMainLayoutConnect.java @@ -2,29 +2,40 @@ package de.tobias.playpad.layout.touch; import java.util.Stack; -import de.tobias.playpad.pad.view.IPadViewV2; +import de.tobias.playpad.Strings; +import de.tobias.playpad.pad.view.IPadView; import de.tobias.playpad.view.main.MainLayoutConnect; import de.tobias.playpad.viewcontroller.main.IMainViewController; import de.tobias.playpad.viewcontroller.main.MenuToolbarViewController; +import de.tobias.utils.util.Localization; +/** + * Touch Implementierung des Main Layout. + * + * @author tobias + * + * @since 5.1.0 + */ public class TouchMainLayoutConnect implements MainLayoutConnect { + private static final String TYPE = "Touch"; + private TouchMenuToolbarViewController touchMainLayoutConnect; - private Stack<IPadViewV2> recyclingStack; + private Stack<IPadView> recyclingStack; public TouchMainLayoutConnect() { recyclingStack = new Stack<>(); } - + @Override public String getType() { - return "Touch"; + return TYPE; } @Override public String name() { - return "Touch Modus"; // TODO Localize + return Localization.getString(Strings.MainLayout_Touch); } @Override @@ -37,7 +48,7 @@ public class TouchMainLayoutConnect implements MainLayoutConnect { } @Override - public IPadViewV2 createPadView() { + public IPadView createPadView() { if (!recyclingStack.isEmpty()) { return recyclingStack.pop(); } @@ -45,7 +56,7 @@ public class TouchMainLayoutConnect implements MainLayoutConnect { } @Override - public void recyclePadView(IPadViewV2 padView) { + public void recyclePadView(IPadView padView) { recyclingStack.push(padView); } diff --git a/PlayWall/src/de/tobias/playpad/layout/touch/TouchMenuToolbarViewController.java b/PlayWall/src/de/tobias/playpad/layout/touch/TouchMenuToolbarViewController.java index 214f5b3e63ffee6df6beef812a2f009e744a4cc6..347361cd08b6c8ebde4b661e2259f438e71df8fe 100644 --- a/PlayWall/src/de/tobias/playpad/layout/touch/TouchMenuToolbarViewController.java +++ b/PlayWall/src/de/tobias/playpad/layout/touch/TouchMenuToolbarViewController.java @@ -3,6 +3,7 @@ package de.tobias.playpad.layout.touch; 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.Profile; import de.tobias.playpad.settings.keys.KeyCollection; import de.tobias.playpad.view.main.MainLayoutConnect; @@ -15,30 +16,25 @@ import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.Node; import javafx.scene.control.Button; -import javafx.scene.control.CheckMenuItem; import javafx.scene.control.Label; import javafx.scene.control.MenuItem; import javafx.scene.control.Slider; public class TouchMenuToolbarViewController extends BasicMenuToolbarViewController { - @FXML protected CheckMenuItem fullScreenMenuItem; - @FXML protected CheckMenuItem alwaysOnTopItem; - @FXML protected MenuItem closeMenuItem; + @FXML protected Button closeButton; @FXML protected Label liveLabel; private IMainViewController mainViewController; public TouchMenuToolbarViewController(IMainViewController mainViewController) { - super("header", "de/tobias/playpad/assets/view/main/touch/", PlayPadMain.getUiResourceBundle(), mainViewController); + super("header", "de/tobias/playpad/assets/view/main/touch/", PlayPadMain.getUiResourceBundle()); this.mainViewController = mainViewController; toolbarHBox.prefWidthProperty().bind(toolbar.widthProperty().subtract(25)); toolbarHBox.prefHeightProperty().bind(toolbar.minHeightProperty()); - showLiveInfo(false); - // Schriftgröße Icons FontIcon icon = (FontIcon) volumeDownLabel.getGraphic(); icon.setSize(35); @@ -64,22 +60,26 @@ public class TouchMenuToolbarViewController extends BasicMenuToolbarViewControll } @Override - public void loadKeybinding(KeyCollection keys) { + public void setOpenProject(Project project) { + super.setOpenProject(project); + liveLabel.visibleProperty().unbind(); + if (project != null) { + liveLabel.visibleProperty().bind(project.activePlayerProperty().greaterThan(0)); + } } + @Override + public void loadKeybinding(KeyCollection keys) {} + @Override public void setLocked(boolean looked) {} @Override - public void setAlwaysOnTopActive(boolean alwaysOnTopActive) { - alwaysOnTopItem.setSelected(alwaysOnTopActive); - } + public void setAlwaysOnTopActive(boolean alwaysOnTopActive) {} @Override - public void setFullScreenActive(boolean fullScreenActive) { - fullScreenMenuItem.setSelected(fullScreenActive); - } + public void setFullScreenActive(boolean fullScreenActive) {} @Override public void addToolbarItem(Node node) { @@ -97,24 +97,9 @@ public class TouchMenuToolbarViewController extends BasicMenuToolbarViewControll @Override public void removeMenuItem(MenuItem item) {} - @Override - public boolean isAlwaysOnTopActive() { - return alwaysOnTopItem.isSelected(); - } - - @Override - public boolean isFullscreenActive() { - return fullScreenMenuItem.isSelected(); - } - @Override public void deinit() {} - @Override - public void showLiveInfo(boolean show) { - liveLabel.setVisible(show); - } - private int currentPage = 0; @Override @@ -139,19 +124,6 @@ public class TouchMenuToolbarViewController extends BasicMenuToolbarViewControll } // Event Handler - @FXML - void alwaysOnTopItemHandler(ActionEvent event) { - boolean selected = alwaysOnTopItem.isSelected(); - - mainViewController.getStage().setAlwaysOnTop(selected); - Profile.currentProfile().getProfileSettings().setWindowAlwaysOnTop(selected); - } - - @FXML - void fullScreenMenuItemHandler(ActionEvent event) { - mainViewController.getStage().setFullScreen(fullScreenMenuItem.isSelected()); - } - @FXML void closeMenuItemHandler(ActionEvent event) { MainLayoutConnect defaultLayout = PlayPadPlugin.getRegistryCollection().getMainLayouts().getDefault(); diff --git a/PlayWall/src/de/tobias/playpad/layout/touch/TouchPadView.java b/PlayWall/src/de/tobias/playpad/layout/touch/TouchPadView.java index f99a12deec254cb04a0b628916524d5a88dd9746..8d68d5e6a08f27cc473292cf326b645f3d36c1ef 100644 --- a/PlayWall/src/de/tobias/playpad/layout/touch/TouchPadView.java +++ b/PlayWall/src/de/tobias/playpad/layout/touch/TouchPadView.java @@ -1,18 +1,21 @@ package de.tobias.playpad.layout.touch; +import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.PseudoClasses; import de.tobias.playpad.pad.Pad; import de.tobias.playpad.pad.conntent.PadContent; import de.tobias.playpad.pad.conntent.PadContentConnect; import de.tobias.playpad.pad.view.IPadContentView; -import de.tobias.playpad.pad.view.IPadViewV2; -import de.tobias.playpad.pad.viewcontroller.IPadViewControllerV2; +import de.tobias.playpad.pad.view.IPadView; +import de.tobias.playpad.pad.viewcontroller.IPadViewController; import de.tobias.playpad.registry.NoSuchComponentException; import de.tobias.playpad.view.EmptyPadView; import de.tobias.utils.ui.icon.FontAwesomeType; import de.tobias.utils.ui.icon.FontIcon; import de.tobias.utils.ui.scene.BusyView; +import de.tobias.utils.util.OS; +import de.tobias.utils.util.win.User32X; import javafx.beans.property.Property; import javafx.css.PseudoClass; import javafx.geometry.Pos; @@ -25,7 +28,7 @@ import javafx.scene.layout.Priority; import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; -public class TouchPadView implements IPadViewV2 { +public class TouchPadView implements IPadView { private Label indexLabel; private Label loopLabel; @@ -86,8 +89,13 @@ public class TouchPadView implements IPadViewV2 { root.getChildren().addAll(infoBox, preview, playBar); superRoot.getChildren().addAll(root); - superRoot.setOnMouseClicked(controller); - playBar.setOnMouseClicked(controller); + if (OS.isWindows() && User32X.isTouchAvailable()) { + superRoot.setOnTouchPressed(controller); + playBar.setOnTouchPressed(controller); + } else { + superRoot.setOnMouseClicked(controller); + playBar.setOnMouseClicked(controller); + } } @Override @@ -134,7 +142,7 @@ public class TouchPadView implements IPadViewV2 { } @Override - public IPadViewControllerV2 getViewController() { + public IPadViewController getViewController() { return controller; } diff --git a/PlayWall/src/de/tobias/playpad/layout/touch/TouchPadViewController.java b/PlayWall/src/de/tobias/playpad/layout/touch/TouchPadViewController.java index 0e93545f41c4711bdb416203149644d269725805..11ef9044b35d086c2f6dbcce2d21a24b8714d7e4 100644 --- a/PlayWall/src/de/tobias/playpad/layout/touch/TouchPadViewController.java +++ b/PlayWall/src/de/tobias/playpad/layout/touch/TouchPadViewController.java @@ -10,8 +10,8 @@ import de.tobias.playpad.pad.listener.PadDurationListener; import de.tobias.playpad.pad.listener.PadLockedListener; import de.tobias.playpad.pad.listener.PadPositionListener; import de.tobias.playpad.pad.listener.PadStatusListener; -import de.tobias.playpad.pad.view.IPadViewV2; -import de.tobias.playpad.pad.viewcontroller.IPadViewControllerV2; +import de.tobias.playpad.pad.view.IPadView; +import de.tobias.playpad.pad.viewcontroller.IPadViewController; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.settings.ProfileSettings; import de.tobias.playpad.viewcontroller.pad.PadDragListener; @@ -20,9 +20,10 @@ import javafx.event.Event; import javafx.event.EventHandler; import javafx.scene.input.MouseButton; import javafx.scene.input.MouseEvent; +import javafx.scene.input.TouchEvent; import javafx.util.Duration; -public class TouchPadViewController implements IPadViewControllerV2, EventHandler<Event> { +public class TouchPadViewController implements IPadViewController, EventHandler<Event> { protected static final String CURRENT_PAGE_BUTTON = "current-page-button"; private static final String DURATION_FORMAT = "%d:%02d"; @@ -47,7 +48,8 @@ public class TouchPadViewController implements IPadViewControllerV2, EventHandle padDurationListener = new PadDurationListener(this); padPositionListener = new PadPositionListener(this); - // Listener muss nur einmal hier hinzugefügt werden, weil bei einem neuen Profile, werden neue PadViewController + // Listener muss nur einmal hier hinzugefügt werden, weil bei einem + // neuen Profile, werden neue PadViewController // erzeugt ProfileSettings profileSettings = Profile.currentProfile().getProfileSettings(); profileSettings.lockedProperty().addListener(padLockedListener); @@ -59,7 +61,7 @@ public class TouchPadViewController implements IPadViewControllerV2, EventHandle } @Override - public IPadViewV2 getView() { + public IPadView getView() { return padView; } @@ -85,7 +87,9 @@ public class TouchPadViewController implements IPadViewControllerV2, EventHandle pad.statusProperty().addListener(padStatusListener); // First Listener call with new data - padContentListener.changed(null, null, pad.getContent()); // Add Duration listener + padContentListener.changed(null, null, pad.getContent()); // Add + // Duration + // listener padStatusListener.changed(null, null, pad.getStatus()); padDragListener = new PadDragListener(pad, padView); @@ -142,7 +146,12 @@ public class TouchPadViewController implements IPadViewControllerV2, EventHandle } } } - + } else if (event instanceof TouchEvent) { + if (pad.getStatus() == PadStatus.PLAY) { + onStop(); + } else { + onPlay(); + } } } diff --git a/PlayWall/src/de/tobias/playpad/pad/content/AudioContent.java b/PlayWall/src/de/tobias/playpad/pad/content/AudioContent.java index f9fc5e94ad102fa570dab5350a4af038004894ff..2d9b220013ad986e4502722119ec04c91fe980fb 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; @@ -33,7 +34,6 @@ import javafx.beans.value.ChangeListener; import javafx.scene.media.AudioEqualizer; import javafx.util.Duration; -// TODO Extract Fade in / Fade Out public class AudioContent extends PadContent implements Pauseable, Durationable, Fadeable, Equalizable, SinglePathContent { private static final String TYPE = "audio"; @@ -69,11 +69,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(); @@ -218,7 +218,7 @@ public class AudioContent extends PadContent implements Pauseable, Durationable, } @Override - public void loadMedia() throws NoSuchComponentException { + public void loadMedia() { // init audio implementation AudioRegistry audioRegistry = PlayPadPlugin.getRegistryCollection().getAudioHandlers(); audioHandler = audioRegistry.getCurrentAudioHandler().createAudioHandler(this); diff --git a/PlayWall/src/de/tobias/playpad/pad/listener/PadContentListener.java b/PlayWall/src/de/tobias/playpad/pad/listener/PadContentListener.java index cb47601c8299bedfd11902632276d79027408617..b27598ecfbac618ab3cce68b8a5172f19ac07f61 100644 --- a/PlayWall/src/de/tobias/playpad/pad/listener/PadContentListener.java +++ b/PlayWall/src/de/tobias/playpad/pad/listener/PadContentListener.java @@ -3,16 +3,16 @@ package de.tobias.playpad.pad.listener; import de.tobias.playpad.pad.Pad; import de.tobias.playpad.pad.conntent.PadContent; import de.tobias.playpad.pad.conntent.play.Durationable; -import de.tobias.playpad.pad.viewcontroller.IPadViewControllerV2; +import de.tobias.playpad.pad.viewcontroller.IPadViewController; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; public class PadContentListener implements ChangeListener<PadContent> { private Pad pad; - private IPadViewControllerV2 controller; + private IPadViewController controller; - public PadContentListener(IPadViewControllerV2 controller) { + public PadContentListener(IPadViewController controller) { this.controller = controller; } diff --git a/PlayWall/src/de/tobias/playpad/pad/listener/PadDurationListener.java b/PlayWall/src/de/tobias/playpad/pad/listener/PadDurationListener.java index 3947066c0fc29f35a9ea11a83212f6885cbf7b70..ce208522f99ec464cbe6996109ad0a4b3c9210d5 100644 --- a/PlayWall/src/de/tobias/playpad/pad/listener/PadDurationListener.java +++ b/PlayWall/src/de/tobias/playpad/pad/listener/PadDurationListener.java @@ -1,15 +1,15 @@ package de.tobias.playpad.pad.listener; -import de.tobias.playpad.pad.viewcontroller.IPadViewControllerV2; +import de.tobias.playpad.pad.viewcontroller.IPadViewController; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.util.Duration; public class PadDurationListener implements ChangeListener<Duration> { - private IPadViewControllerV2 controller; + private IPadViewController controller; - public PadDurationListener(IPadViewControllerV2 controller) { + public PadDurationListener(IPadViewController controller) { this.controller = controller; } diff --git a/PlayWall/src/de/tobias/playpad/pad/listener/PadLockedListener.java b/PlayWall/src/de/tobias/playpad/pad/listener/PadLockedListener.java index d568fc04ee64ec050ff7bbf6d6973a6fa8276b3f..702951b06dab11e634e5c4aec827a06c98638f4e 100644 --- a/PlayWall/src/de/tobias/playpad/pad/listener/PadLockedListener.java +++ b/PlayWall/src/de/tobias/playpad/pad/listener/PadLockedListener.java @@ -1,14 +1,14 @@ package de.tobias.playpad.pad.listener; -import de.tobias.playpad.pad.viewcontroller.IPadViewControllerV2; +import de.tobias.playpad.pad.viewcontroller.IPadViewController; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; public class PadLockedListener implements ChangeListener<Boolean> { - private IPadViewControllerV2 controller; + private IPadViewController controller; - public PadLockedListener(IPadViewControllerV2 controller) { + public PadLockedListener(IPadViewController controller) { this.controller = controller; } diff --git a/PlayWall/src/de/tobias/playpad/pad/listener/PadPositionListener.java b/PlayWall/src/de/tobias/playpad/pad/listener/PadPositionListener.java index 1f8b3486b4d2f35027cdffae79bc48ebf19749ed..f1ddd7d222840089fb73f7f63bbf8a69f6e783e2 100644 --- a/PlayWall/src/de/tobias/playpad/pad/listener/PadPositionListener.java +++ b/PlayWall/src/de/tobias/playpad/pad/listener/PadPositionListener.java @@ -6,7 +6,7 @@ import de.tobias.playpad.pad.PadStatus; import de.tobias.playpad.pad.conntent.PadContent; import de.tobias.playpad.pad.conntent.play.Durationable; import de.tobias.playpad.pad.conntent.play.Fadeable; -import de.tobias.playpad.pad.viewcontroller.IPadViewControllerV2; +import de.tobias.playpad.pad.viewcontroller.IPadViewController; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.settings.Warning; import javafx.beans.value.ObservableValue; @@ -15,9 +15,9 @@ import javafx.util.Duration; public class PadPositionListener implements Runnable, IPadPositionListener { private Pad pad; - private IPadViewControllerV2 controller; + private IPadViewController controller; - public PadPositionListener(IPadViewControllerV2 controller) { + public PadPositionListener(IPadViewController controller) { this.controller = controller; } diff --git a/PlayWall/src/de/tobias/playpad/pad/listener/PadStatusListener.java b/PlayWall/src/de/tobias/playpad/pad/listener/PadStatusListener.java index 493292532f4621d3d1d1342548e01ac0364c1db4..3d24039f8c78b0ebb6b23015c9eece0d68957a49 100644 --- a/PlayWall/src/de/tobias/playpad/pad/listener/PadStatusListener.java +++ b/PlayWall/src/de/tobias/playpad/pad/listener/PadStatusListener.java @@ -2,15 +2,15 @@ package de.tobias.playpad.pad.listener; import de.tobias.playpad.PseudoClasses; import de.tobias.playpad.pad.PadStatus; -import de.tobias.playpad.pad.viewcontroller.IPadViewControllerV2; +import de.tobias.playpad.pad.viewcontroller.IPadViewController; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; public class PadStatusListener implements ChangeListener<PadStatus> { - private IPadViewControllerV2 controller; + private IPadViewController controller; - public PadStatusListener(IPadViewControllerV2 controller) { + public PadStatusListener(IPadViewController controller) { this.controller = controller; } diff --git a/PlayWall/src/de/tobias/playpad/view/HelpMenuItem.java b/PlayWall/src/de/tobias/playpad/view/HelpMenuItem.java index bf8e4f9aa04fe6cdad26acecd31e36811ff70774..25a935f3accd14176f1b7b5288808a64e3a9664a 100644 --- a/PlayWall/src/de/tobias/playpad/view/HelpMenuItem.java +++ b/PlayWall/src/de/tobias/playpad/view/HelpMenuItem.java @@ -26,7 +26,7 @@ public class HelpMenuItem extends CustomMenuItem implements ChangeListener<Strin setHideOnClick(false); - Label label = new Label("Suchen nach (Beta): "); // TODO i18n + Label label = new Label("Suchen nach (Beta): "); // BETA i18n TextField textfield = new TextField(); textfield.textProperty().addListener(this); diff --git a/PlayWall/src/de/tobias/playpad/view/MapperOverviewViewController.java b/PlayWall/src/de/tobias/playpad/view/MapperOverviewViewController.java index 5b293810c01492b41bc75d75ec3fa3f0d8ca012c..5ae0d9f6a0f9de033b308e52034cb98731109147 100644 --- a/PlayWall/src/de/tobias/playpad/view/MapperOverviewViewController.java +++ b/PlayWall/src/de/tobias/playpad/view/MapperOverviewViewController.java @@ -62,7 +62,15 @@ public class MapperOverviewViewController implements IMapperOverviewViewControll Set<String> types = registry.getTypes(); types.stream().sorted().forEach(item -> { - Button button = new Button(item.toString(), new FontIcon(FontAwesomeType.PLUS_CIRCLE)); + String name = item; + try { + MapperConnect connect = registry.getComponent(item); + name = connect.toString(); + } catch (NoSuchComponentException e) { + // TODO Error Handling + e.printStackTrace(); + } + Button button = new Button(name, new FontIcon(FontAwesomeType.PLUS_CIRCLE)); button.setContentDisplay(ContentDisplay.TOP); button.setPrefWidth(150); diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/LaunchDialog.java b/PlayWall/src/de/tobias/playpad/viewcontroller/LaunchDialog.java index a1aa93939d236d0703ecfb71a8e02581e609fa3a..d659f482f881527f96cb000d17c10405ec4c776d 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/LaunchDialog.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/LaunchDialog.java @@ -77,7 +77,7 @@ public class LaunchDialog extends ViewController implements ProfileChooseable { // Load project to list projectListView.setPlaceholder(new Label(getString(Strings.UI_Placeholder_Project))); projectListView.setId("list"); - projectListView.setCellFactory(list -> new ProjectCell()); + projectListView.setCellFactory(list -> new ProjectCell(true)); // List selection listener projectListView.getSelectionModel().selectedItemProperty().addListener((a, b, c) -> diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/audio/ClipSettingsViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/audio/ClipSettingsViewController.java index 624d6c557b49d8606a58b71d5af1a82d0c29d919..1cf62dd4e5bc531cced38b433420086db33ab173 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/audio/ClipSettingsViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/audio/ClipSettingsViewController.java @@ -15,7 +15,7 @@ import javax.sound.sampled.UnsupportedAudioFileException; import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.audio.TinyAudioHandler; import de.tobias.playpad.settings.Profile; -import de.tobias.playpad.viewcontroller.AudioTypeViewController; +import de.tobias.playpad.viewcontroller.AudioHandlerViewController; import de.tobias.utils.ui.icon.FontAwesomeType; import de.tobias.utils.ui.icon.FontIcon; import de.tobias.utils.util.Worker; @@ -27,7 +27,7 @@ import javafx.scene.control.ListCell; import javafx.scene.control.ListView; import javafx.util.Callback; -public class ClipSettingsViewController extends AudioTypeViewController implements Callback<ListView<Info>, ListCell<Info>> { +public class ClipSettingsViewController extends AudioHandlerViewController implements Callback<ListView<Info>, ListCell<Info>> { @FXML private ComboBox<Info> soundCardComboBox; @FXML private Button testButton; diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/audio/TinySoundSettingsViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/audio/TinySoundSettingsViewController.java index 4429ba72ad6c5bc5b937e314e491e1248bdb7c19..799ed153cf5d716f4bb78e1ebd71903b2a759e40 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/audio/TinySoundSettingsViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/audio/TinySoundSettingsViewController.java @@ -15,7 +15,7 @@ import javax.sound.sampled.UnsupportedAudioFileException; import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.audio.TinyAudioHandler; import de.tobias.playpad.settings.Profile; -import de.tobias.playpad.viewcontroller.AudioTypeViewController; +import de.tobias.playpad.viewcontroller.AudioHandlerViewController; import de.tobias.utils.ui.icon.FontAwesomeType; import de.tobias.utils.ui.icon.FontIcon; import de.tobias.utils.util.Worker; @@ -27,7 +27,7 @@ import javafx.scene.control.ListCell; import javafx.scene.control.ListView; import javafx.util.Callback; -public class TinySoundSettingsViewController extends AudioTypeViewController implements Callback<ListView<Info>, ListCell<Info>> { +public class TinySoundSettingsViewController extends AudioHandlerViewController implements Callback<ListView<Info>, ListCell<Info>> { @FXML private ComboBox<Info> soundCardComboBox; @FXML private Button testButton; diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/cell/ProjectCell.java b/PlayWall/src/de/tobias/playpad/viewcontroller/cell/ProjectCell.java index 57d9105b5c6355ee95f0e4e0f9a9269b5d240eb9..650064aac576b12399d42c650a4b3309f3de78ae 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/cell/ProjectCell.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/cell/ProjectCell.java @@ -5,30 +5,68 @@ import java.nio.file.Path; import de.tobias.playpad.Displayable; import de.tobias.playpad.project.ProjectReference; +import de.tobias.playpad.settings.ProfileReference; import de.tobias.utils.ui.icon.FontAwesomeType; import de.tobias.utils.ui.icon.FontIcon; -import javafx.scene.control.ContentDisplay; +import javafx.geometry.Pos; +import javafx.scene.control.Label; import javafx.scene.control.ListCell; +import javafx.scene.layout.HBox; +import javafx.scene.layout.Priority; +import javafx.scene.layout.VBox; import javafx.scene.paint.Color; public class ProjectCell extends ListCell<ProjectReference> { - private Displayable ref; + private transient Displayable ref; + + private boolean showProfileName; + + public ProjectCell(boolean showProfileName) { + this.showProfileName = showProfileName; + } @Override protected void updateItem(ProjectReference ref, boolean empty) { super.updateItem(ref, empty); if (!empty) { if (this.ref == null || this.ref != ref) { + HBox rootBox = new HBox(14); + VBox nameBox = new VBox(3); + + // init + rootBox.setAlignment(Pos.CENTER_LEFT); + + // Project Name + Label projectNameLabel = new Label(); + projectNameLabel.textProperty().bind(ref.displayProperty()); + projectNameLabel.getStyleClass().add("projectname"); + nameBox.getChildren().add(projectNameLabel); + + if (showProfileName) { + // Profile name + ProfileReference profileRef = ref.getProfileReference(); + if (profileRef != null) { + String name = profileRef.getName(); + + Label label = new Label(name); + label.getStyleClass().add("profilename"); + nameBox.getChildren().add(label); + } + } + + HBox.setHgrow(nameBox, Priority.ALWAYS); + rootBox.getChildren().add(nameBox); + + // File not Exists Path path = ref.getProjectPath(); if (Files.notExists(path)) { FontIcon graphics = new FontIcon(FontAwesomeType.WARNING); graphics.setColor(Color.RED); - setGraphic(graphics); + rootBox.getChildren().add(graphics); } - setContentDisplay(ContentDisplay.RIGHT); - textProperty().bind(ref.displayProperty()); + setGraphic(rootBox); this.ref = ref; } } else { diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/cell/errordialog/FixCell.java b/PlayWall/src/de/tobias/playpad/viewcontroller/cell/errordialog/FixCell.java index 6fb968cdb2ee6d0a1904bd08ca3774f049a1db3d..2e6e65f3117abbed7dff065272484dd5180b5fba 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/cell/errordialog/FixCell.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/cell/errordialog/FixCell.java @@ -1,16 +1,9 @@ package de.tobias.playpad.viewcontroller.cell.errordialog; -import java.nio.file.Files; import java.nio.file.Path; -import de.tobias.playpad.PlayPadPlugin; -import de.tobias.playpad.pad.Pad; import de.tobias.playpad.pad.PadException; -import de.tobias.playpad.pad.conntent.PadContent; -import de.tobias.playpad.pad.conntent.PadContentConnect; -import de.tobias.playpad.registry.NoSuchComponentException; import de.tobias.playpad.view.ExceptionButton; -import de.tobias.utils.util.FileUtils; import javafx.scene.control.Button; import javafx.scene.control.Control; import javafx.scene.control.TableCell; @@ -38,33 +31,7 @@ public class FixCell extends TableCell<PadException, PadException> { case FILE_NOT_FOUND: ExceptionButton<Path> notExistsExButton = ExceptionButton.FILE_NOT_FOUND_EXCEPTION; Button notExistsButton = notExistsExButton.getButton(); - notExistsButton.setOnAction(a -> - { - Path path = notExistsExButton.getHandler().handle(item.getPad(), stage); - if (path != null) { - - Pad pad = item.getPad(); - PadContent content = item.getPad().getContent(); - try { - PadContentConnect padContentConnect = PlayPadPlugin.getRegistryCollection().getPadContents() - .getComponent(content.getType()); - - if (Files.exists(path) && PadContentConnect.isFileSupported(path, padContentConnect)) { - try { - content.handlePath(path); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - pad.setName(FileUtils.getFilenameWithoutExtention(path.getFileName())); - pad.removeException(item); - } - } catch (NoSuchComponentException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - }); + notExistsButton.setOnAction(new IOExceptionButtonListener(item, stage, notExistsExButton)); vbox.getChildren().add(notExistsButton); break; @@ -72,33 +39,7 @@ public class FixCell extends TableCell<PadException, PadException> { case CONVERT_NOT_SUPPORTED: ExceptionButton<Path> supportExButton = ExceptionButton.FILE_NOT_FOUND_EXCEPTION; Button supportButton = supportExButton.getButton(); - supportButton.setOnAction(a -> - { - Path path = supportExButton.getHandler().handle(item.getPad(), stage); - if (path != null) { - - Pad pad = item.getPad(); - PadContent content = item.getPad().getContent(); - try { - PadContentConnect padContentConnect = PlayPadPlugin.getRegistryCollection().getPadContents() - .getComponent(content.getType()); - - if (Files.exists(path) && PadContentConnect.isFileSupported(path, padContentConnect)) { - try { - content.handlePath(path); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - pad.setName(FileUtils.getFilenameWithoutExtention(path.getFileName())); - pad.removeException(item); - } - } catch (NoSuchComponentException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - }); + supportButton.setOnAction(new IOExceptionButtonListener(item, stage, supportExButton)); vbox.getChildren().add(supportButton); break; diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/cell/errordialog/IOExceptionButtonListener.java b/PlayWall/src/de/tobias/playpad/viewcontroller/cell/errordialog/IOExceptionButtonListener.java new file mode 100644 index 0000000000000000000000000000000000000000..94b61fe98861c4299b201c66436513213f2f1f4d --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/cell/errordialog/IOExceptionButtonListener.java @@ -0,0 +1,54 @@ +package de.tobias.playpad.viewcontroller.cell.errordialog; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; + +import de.tobias.playpad.PlayPadPlugin; +import de.tobias.playpad.pad.Pad; +import de.tobias.playpad.pad.PadContentRegistry; +import de.tobias.playpad.pad.PadException; +import de.tobias.playpad.pad.conntent.PadContent; +import de.tobias.playpad.pad.conntent.PadContentConnect; +import de.tobias.playpad.registry.NoSuchComponentException; +import de.tobias.playpad.view.ExceptionButton; +import de.tobias.utils.util.FileUtils; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.stage.Stage; + +public class IOExceptionButtonListener implements EventHandler<ActionEvent> { + + private PadException item; + private Stage stage; + private ExceptionButton<Path> exButton; + + public IOExceptionButtonListener(PadException item, Stage stage, ExceptionButton<Path> notExistsExButton) { + this.item = item; + this.stage = stage; + this.exButton = notExistsExButton; + } + + @Override + public void handle(ActionEvent a) { + Path path = exButton.getHandler().handle(item.getPad(), stage); + if (path != null) { + + Pad pad = item.getPad(); + PadContent content = item.getPad().getContent(); + try { + PadContentRegistry padContents = PlayPadPlugin.getRegistryCollection().getPadContents(); + PadContentConnect padContentConnect = padContents.getComponent(content.getType()); + + if (Files.exists(path) && PadContentConnect.isFileSupported(path, padContentConnect)) { + content.handlePath(path); + pad.setName(FileUtils.getFilenameWithoutExtention(path.getFileName())); + pad.removeException(item); + } + } catch (NoSuchComponentException | IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } +} diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/design/ModernCartDesignViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/design/ModernCartDesignViewController.java index c4827e9f996df327ecca9b28d914a655603e085c..fbda591aa744faa54b000b0b47622d76fbd5de94 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/design/ModernCartDesignViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/design/ModernCartDesignViewController.java @@ -8,8 +8,8 @@ import org.controlsfx.control.PopOver.ArrowLocation; import de.tobias.playpad.DisplayableColor; import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.design.CartDesign; -import de.tobias.playpad.design.modern.ModernColor; import de.tobias.playpad.design.modern.ModernCartDesign; +import de.tobias.playpad.design.modern.ModernColor; import de.tobias.playpad.view.ColorView; import de.tobias.playpad.viewcontroller.CartDesignViewController; import javafx.event.ActionEvent; diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/AutoUpdateDialog.java b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/AutoUpdateDialog.java new file mode 100644 index 0000000000000000000000000000000000000000..f3d0fb89824c60c308730e1c0a365442544023d0 --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/AutoUpdateDialog.java @@ -0,0 +1,42 @@ +package de.tobias.playpad.viewcontroller.dialog; + +import java.util.List; + +import de.tobias.playpad.PlayPadMain; +import de.tobias.playpad.Strings; +import de.tobias.playpad.update.Updatable; +import de.tobias.playpad.update.UpdateRegistery; +import de.tobias.utils.ui.AdvancedDialog; +import de.tobias.utils.util.Localization; +import javafx.scene.control.ButtonBar.ButtonData; +import javafx.scene.control.ButtonType; +import javafx.stage.Window; + +public class AutoUpdateDialog extends AdvancedDialog { + + public AutoUpdateDialog(Window owner) { + super(owner); + List<Updatable> updates = UpdateRegistery.getAvailableUpdates(); + + StringBuilder builder = new StringBuilder(); + for (Updatable update : updates) { + builder.append(update.name()); + builder.append(" "); + builder.append(update.getNewVersion()); + builder.append("\n"); + } + + setTitle(Localization.getString(Strings.UI_Dialog_AutoUpdate_Title)); + setContent(Localization.getString(Strings.UI_Dialog_AutoUpdate_Content, builder.toString())); + setHeaderText(Localization.getString(Strings.UI_Dialog_AutoUpdate_Header)); + setCheckboxText(Localization.getString(Strings.UI_Dialog_AutoUpdate_Checkbox)); + + setIcon(PlayPadMain.stageIcon); + + ButtonType updateButton = new ButtonType(Localization.getString(Strings.UI_Dialog_AutoUpdate_Button_Update), ButtonData.APPLY); + ButtonType cancelButton = new ButtonType(Localization.getString(Strings.UI_Dialog_AutoUpdate_Button_Cancel), ButtonData.CANCEL_CLOSE); + + addButtonType(updateButton); + addButtonType(cancelButton); + } +} 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/dialog/ProjectManagerDialog.java b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ProjectManagerDialog.java index 6de43dc90b92a830ef846210f318b6513ac58c83..83bf7d61f216e0d82d8b821a6256251620df9590 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ProjectManagerDialog.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ProjectManagerDialog.java @@ -13,12 +13,12 @@ import de.tobias.playpad.project.Project; import de.tobias.playpad.project.ProjectImporter; import de.tobias.playpad.project.ProjectReference; import de.tobias.playpad.settings.Profile; +import de.tobias.playpad.settings.ProfileReference; import de.tobias.playpad.viewcontroller.cell.ProjectCell; import de.tobias.utils.ui.NotificationHandler; import de.tobias.utils.ui.ViewController; import de.tobias.utils.ui.scene.NotificationPane; import de.tobias.utils.util.Localization; -import de.tobias.utils.util.NumberUtils; import de.tobias.utils.util.TimeUtils; import javafx.application.Platform; import javafx.event.ActionEvent; @@ -56,7 +56,7 @@ public class ProjectManagerDialog extends ViewController implements Notification @FXML private Button exportButton; @FXML private Label dateLabel; - @FXML private Label sizeLabel; + @FXML private Label profileLabel; private Project currentProject; @@ -85,7 +85,7 @@ public class ProjectManagerDialog extends ViewController implements Notification ((AnchorPane) getParent()).getChildren().add(notificationPane); projectList.setPlaceholder(new Label(Localization.getString(Strings.UI_Placeholder_Project))); - projectList.setCellFactory(list -> new ProjectCell()); + projectList.setCellFactory(list -> new ProjectCell(false)); projectList.setOnMouseClicked(mouseEvent -> { @@ -109,10 +109,11 @@ public class ProjectManagerDialog extends ViewController implements Notification nameTextField.setText(c.toString()); try { - sizeLabel.setText(NumberUtils.numberToString(ref.getSize())); + ProfileReference profileRef = ref.getProfileReference(); + profileLabel.setText(profileRef.getName()); dateLabel.setText(TimeUtils.getDfmLong().format(ref.getLastMofied())); } catch (Exception e) { - sizeLabel.setText("-"); + profileLabel.setText("-"); dateLabel.setText("-"); e.printStackTrace(); } @@ -130,7 +131,7 @@ public class ProjectManagerDialog extends ViewController implements Notification renameButton.setDisable(true); nameTextField.setText(null); - sizeLabel.setText("-"); + profileLabel.setText("-"); dateLabel.setText("-"); } }); @@ -141,7 +142,7 @@ public class ProjectManagerDialog extends ViewController implements Notification exportButton.setDisable(true); renameButton.setDisable(true); - sizeLabel.setText("-"); + profileLabel.setText("-"); dateLabel.setText("-"); addCloseKeyShortcut(() -> getStage().close()); diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/SaveDialog.java b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/SaveDialog.java new file mode 100644 index 0000000000000000000000000000000000000000..1cff79c55dd8a0c5d737e65d4af0d9ddf84f60ad --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/SaveDialog.java @@ -0,0 +1,31 @@ +package de.tobias.playpad.viewcontroller.dialog; + +import de.tobias.playpad.PlayPadMain; +import de.tobias.playpad.Strings; +import de.tobias.utils.ui.AdvancedDialog; +import de.tobias.utils.util.Localization; +import javafx.scene.control.ButtonBar.ButtonData; +import javafx.scene.control.ButtonType; +import javafx.stage.Window; + +public class SaveDialog extends AdvancedDialog { + + public SaveDialog(Window owner) { + super(owner); + + setTitle(Localization.getString(Strings.UI_Dialog_Save_Title)); + setContent(Localization.getString(Strings.UI_Dialog_Save_Content)); + setHeaderText(Localization.getString(Strings.UI_Dialog_Save_Header)); + setCheckboxText(Localization.getString(Strings.UI_Dialog_Save_Checkbox)); + setIcon(PlayPadMain.stageIcon); + + ButtonType saveButton = new ButtonType(Localization.getString(Strings.UI_Dialog_Save_Button_Yes), ButtonData.YES); + ButtonType notSaveButton = new ButtonType(Localization.getString(Strings.UI_Dialog_Save_Button_No), ButtonData.NO); + ButtonType cancelButton = new ButtonType(Localization.getString(Strings.UI_Dialog_Save_Button_Cancel), ButtonData.CANCEL_CLOSE); + + addButtonType(saveButton); + addButtonType(notSaveButton); + addButtonType(cancelButton); + } + +} diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/UpdaterDialog.java b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/UpdaterDialog.java index 6143bc834cdf0810172eef642d3453118feb3e44..4e7113bd89f064177f51abd5855d3af91fb2807b 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/UpdaterDialog.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/UpdaterDialog.java @@ -13,11 +13,9 @@ import javafx.stage.Window; public class UpdaterDialog extends Dialog<Void> { public UpdaterDialog(Window owner) { - setHeaderText(Localization.getString(Strings.UI_Dialog_DragAndDrop_Header)); setGraphic(new ImageView("org/controlsfx/dialog/dialog-information.png")); - Label textLabel = new Label( - "Die Aktualisierung wird vorbereitet. Bitte schließen Sie nicht das Programm. \nDieser Vorgang kann wenige Minuten dauern."); + Label textLabel = new Label(Localization.getString(Strings.UI_Dialog_Update_Info)); textLabel.setWrapText(true); textLabel.setMaxWidth(450); getDialogPane().setContent(textLabel); diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/main/BasicMenuToolbarViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/main/BasicMenuToolbarViewController.java index 04fbb3fd344ced933828caa8f7a21d832f7c7a64..7f7d2de79b4acb530ee57ef4045a2b30678d2cf7 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/main/BasicMenuToolbarViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/main/BasicMenuToolbarViewController.java @@ -3,8 +3,9 @@ package de.tobias.playpad.viewcontroller.main; import java.util.ResourceBundle; import de.tobias.playpad.PlayPadMain; +import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.project.Project; -import de.tobias.playpad.settings.Profile; +import de.tobias.playpad.settings.GlobalSettings; import de.tobias.playpad.settings.keys.Key; import de.tobias.utils.ui.icon.FontAwesomeType; import de.tobias.utils.ui.icon.FontIcon; @@ -34,12 +35,8 @@ public abstract class BasicMenuToolbarViewController extends MenuToolbarViewCont protected Project openProject; // REFERENCE zu MainViewController - // window references - private IMainViewController mainViewController; - - public BasicMenuToolbarViewController(String name, String path, ResourceBundle localization, IMainViewController mainViewController) { + public BasicMenuToolbarViewController(String name, String path, ResourceBundle localization) { super(name, path, localization); - this.mainViewController = mainViewController; } @Override @@ -57,9 +54,8 @@ public abstract class BasicMenuToolbarViewController extends MenuToolbarViewCont // Utils protected void doAction(Runnable run) { Project project = PlayPadMain.getProgramInstance().getCurrentProject(); - if (project.getPlayedPlayers() > 0 && Profile.currentProfile().getProfileSettings().isLiveMode()) { - mainViewController.showLiveInfo(); - } else { + GlobalSettings globalSettings = PlayPadPlugin.getImplementation().getGlobalSettings(); + if (!(project.getActivePlayers() > 0 && globalSettings.isLiveMode())) { run.run(); } } diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/main/MainMenuBarController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/main/MainMenuBarController.java deleted file mode 100644 index bd1b8923dc083c9525279a5934b7f9b388ca032f..0000000000000000000000000000000000000000 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/main/MainMenuBarController.java +++ /dev/null @@ -1,389 +0,0 @@ -package de.tobias.playpad.viewcontroller.main; - -import java.awt.Desktop; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.util.Optional; -import java.util.ResourceBundle; - -import de.tobias.playpad.AppUserInfoStrings; -import de.tobias.playpad.PlayPadMain; -import de.tobias.playpad.Strings; -import de.tobias.playpad.midi.Midi; -import de.tobias.playpad.pad.view.IPadViewController; -import de.tobias.playpad.project.Project; -import de.tobias.playpad.project.ProjectNotFoundException; -import de.tobias.playpad.project.ProjectReference; -import de.tobias.playpad.settings.Profile; -import de.tobias.playpad.settings.ProfileListener; -import de.tobias.playpad.settings.ProfileNotFoundException; -import de.tobias.playpad.settings.ProfileSettings; -import de.tobias.playpad.viewcontroller.SettingsTabViewController; -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; -import de.tobias.playpad.viewcontroller.dialog.PrintDialog; -import de.tobias.playpad.viewcontroller.dialog.ProfileViewController; -import de.tobias.playpad.viewcontroller.dialog.ProjectManagerDialog; -import de.tobias.playpad.viewcontroller.option.SettingsViewController; -import de.tobias.playpad.viewcontroller.pad.PadDragListener; -import de.tobias.utils.application.ApplicationInfo; -import de.tobias.utils.application.ApplicationUtils; -import de.tobias.utils.application.container.PathType; -import de.tobias.utils.util.Localization; -import de.tobias.utils.util.OS; -import de.tobias.utils.util.OS.OSType; -import de.tobias.utils.util.Worker; -import de.tobias.utils.util.net.FileUpload; -import javafx.application.Platform; -import javafx.beans.value.ChangeListener; -import javafx.beans.value.ObservableValue; -import javafx.event.ActionEvent; -import javafx.event.EventHandler; -import javafx.fxml.FXML; -import javafx.fxml.Initializable; -import javafx.scene.control.Alert; -import javafx.scene.control.Alert.AlertType; -import javafx.scene.control.CheckMenuItem; -import javafx.scene.control.Menu; -import javafx.scene.control.MenuBar; -import javafx.scene.control.MenuItem; -import javafx.stage.Modality; -import javafx.stage.Stage; - -@Deprecated -public class MainMenuBarController implements EventHandler<ActionEvent>, Initializable, ProfileListener { - - @FXML private MenuBar menuBar; - @FXML private CheckMenuItem dndModeMenuItem; - @FXML private CheckMenuItem alwaysOnTopItem; - @FXML private CheckMenuItem fullScreenMenuItem; - @FXML private Menu recentOpenMenu; - @FXML private MenuItem profileMenu; - - @FXML private CheckMenuItem quickEditMenuItem; - @FXML private MenuItem settingsMenuItem; - - @FXML private Menu extensionMenu; - - // Open Windows - private SettingsViewController settingsViewController; - private MainViewController mvc; - - private ChangeListener<Boolean> lockedListener; - - @Override - public void initialize(URL location, ResourceBundle resources) { - menuBar.setUseSystemMenuBar(true); - - if (OS.getType() == OSType.MacOSX) { - menuBar.setMaxHeight(0); - } - - ProfileSettings profileSettings = Profile.currentProfile().getProfileSettings(); - Profile.registerListener(this); // Update, wenn sich das Profil ändert (remove Listener & add Listener) - - // Listener - lockedListener = new ChangeListener<Boolean>() { - - @Override - public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { - dndModeMenuItem.setDisable(newValue); - } - }; - profileSettings.lockedProperty().addListener(lockedListener); - lockedListener.changed(profileSettings.lockedProperty(), null, profileSettings.isLocked()); - } - - // Event - @FXML - private void newDocumentHandler(ActionEvent event) { - doAction(() -> - { - NewProjectDialog dialog = new NewProjectDialog(mvc.getStage()); - dialog.getStage().showAndWait(); - - Project project = dialog.getProject(); - if (project != null) { - mvc.setProject(project); - mvc.showPage(0); - } - }); - } - - @FXML - private void openDocumentHandler(ActionEvent event) { - doAction(() -> - { - ProjectManagerDialog view = new ProjectManagerDialog(mvc.getStage(), mvc.getProject()); - Optional<ProjectReference> result = view.showAndWait(); - if (result.isPresent()) { - ProjectReference ref = result.get(); - try { - Project project = Project.load(result.get(), true, ImportDialog.getInstance(mvc.getStage())); - mvc.setProject(project); - - mvc.showPage(0); - createRecentDocumentMenuItems(); - } catch (ProfileNotFoundException e) { - e.printStackTrace(); - mvc.showErrorMessage( - Localization.getString(Strings.Error_Profile_NotFound, ref.getProfileReference(), e.getLocalizedMessage())); - - // Neues Profile wählen - Profile profile = ImportDialog.getInstance(mvc.getStage()).getUnkownProfile(); - ref.setProfileReference(profile.getRef()); - } catch (ProjectNotFoundException e) { - e.printStackTrace(); - mvc.showErrorMessage(Localization.getString(Strings.Error_Project_NotFound, ref, e.getLocalizedMessage())); - } catch (Exception e) { - e.printStackTrace(); - mvc.showErrorMessage(Localization.getString(Strings.Error_Project_Open, ref, e.getLocalizedMessage())); - } - } - }); - } - - @FXML - private void saveMenuHandler(ActionEvent event) { - try { - mvc.getProject().save(); - mvc.notify(Localization.getString(Strings.Standard_File_Save), PlayPadMain.displayTimeMillis); - } catch (IOException e) { - mvc.showError(Localization.getString(Strings.Error_Project_Save)); - e.printStackTrace(); - } - } - - // Einstellungsmenu - @FXML - private void profileMenuHandler(ActionEvent event) { - doAction(() -> - { - ProfileViewController controller = new ProfileViewController(mvc.getStage(), mvc.getProject()); - controller.getStage().showAndWait(); - mvc.setTitle(); - }); - } - - @FXML - private void settingsHandler(ActionEvent event) { - Midi midi = Midi.getInstance(); - Project project = mvc.getProject(); - ProfileSettings settings = Profile.currentProfile().getProfileSettings(); - - if (settings.isLiveMode() && settings.isLiveModeSettings() && project.getPlayedPlayers() > 0) { - mvc.showLiveInfo(); - return; - } - - if (settingsViewController == null) { - settingsViewController = new SettingsViewController(midi, mvc.getScreen(), mvc.getStage(), project, null) { - - @Override - public void updateData() { - midi.setListener(mvc.getMidiHandler()); - - boolean change = false; - for (SettingsTabViewController controller : tabs) { - if (controller.needReload()) { - change = true; - controller.reload(Profile.currentProfile(), project, mvc); - } - } - - if (change) { - PlayPadMain.getProgramInstance().getSettingsListener().forEach(l -> l.onChange(Profile.currentProfile())); - } - - settingsViewController = null; - mvc.getStage().toFront(); - } - }; - - settingsViewController.getStage().show(); - } else if (settingsViewController.getStage().isShowing()) { - settingsViewController.getStage().toFront(); - } - } - - @FXML - private void printMenuHandler(ActionEvent event) { - PrintDialog dialog = new PrintDialog(mvc.getProject(), mvc.getStage()); - dialog.getStage().show(); - } - - @FXML - private void alwaysOnTopItemHandler(ActionEvent event) { - mvc.getStage().setAlwaysOnTop(alwaysOnTopItem.isSelected()); - Profile.currentProfile().getProfileSettings().setWindowAlwaysOnTop(alwaysOnTopItem.isSelected()); - } - - @FXML - private void fullScreenMenuItemHandler(ActionEvent event) { - mvc.getStage().setFullScreen(fullScreenMenuItem.isSelected()); - } - - @FXML - private void dndModeHandler(ActionEvent event) { - if (dndModeMenuItem.isSelected()) { - ProfileSettings settings = Profile.currentProfile().getProfileSettings(); - if (settings.isLiveMode() && settings.isLiveModeDrag() && mvc.getProject().getPlayedPlayers() > 0) { - mvc.showLiveInfo(); - } else { - PadDragListener.setDndMode(true); - for (IPadViewController view : mvc.padViewList) { - view.showDnDLayout(true); - } - } - } else { - PadDragListener.setDndMode(false); - for (IPadViewController view : mvc.padViewList) { - view.showDnDLayout(false); - } - } - - } - - @FXML - private void errorMenuHandler(ActionEvent event) { - ErrorSummaryDialog.getInstance().getStage().show(); - } - - @FXML - private void aboutMenuHandler(ActionEvent event) { - ApplicationInfo info = ApplicationUtils.getApplication().getInfo(); - String message = Localization.getString(Strings.UI_Dialog_Info_Content, info.getVersion(), info.getBuild(), info.getAuthor()); - mvc.showInfoMessage(message, Localization.getString(Strings.UI_Dialog_Info_Header, info.getName()), PlayPadMain.stageIcon.orElse(null)); - } - - @FXML - private void visiteWebsiteMenuHandler(ActionEvent event) { - String website = ApplicationUtils.getApplication().getInfo().getUserInfo().getString(AppUserInfoStrings.WEBSITE); - try { - Desktop.getDesktop().browse(new URI(website)); - } catch (IOException | URISyntaxException e) { - e.printStackTrace(); - } - } - - @FXML - private void sendErrorMenuItem(ActionEvent event) { - Alert alert = new Alert(AlertType.INFORMATION); - alert.initOwner(mvc.getStage()); - alert.initModality(Modality.WINDOW_MODAL); - Stage dialog = (Stage) alert.getDialogPane().getScene().getWindow(); - PlayPadMain.stageIcon.ifPresent(dialog.getIcons()::add); - alert.setContentText(Localization.getString(Strings.UI_Dialog_Feedback_Content)); - alert.show(); - - Worker.runLater(() -> - { - try { - String response = FileUpload.fileUpload( - ApplicationUtils.getApplication().getInfo().getUserInfo().getString(AppUserInfoStrings.ERROR_URL), - ApplicationUtils.getApplication().getPath(PathType.LOG, "err.log").toFile()); - Platform.runLater(() -> alert.setContentText(response)); - } catch (IOException e) { - e.printStackTrace(); - } - }); - } - - @FXML - private void pluginMenuItemHandler(ActionEvent e) { - doAction(() -> - { - PluginViewController controller = new PluginViewController(mvc.getStage()); - controller.getStage().showAndWait(); - mvc.showPage(mvc.getPage()); - }); - } - - @Override - public void handle(ActionEvent event) { - if (event.getSource() instanceof MenuItem) { - // Zuletzt verwendete Projects - doAction(() -> - { - MenuItem item = (MenuItem) event.getSource(); - ProjectReference ref = (ProjectReference) item.getUserData(); - try { - // Speichern das alte Project in mvc.setProject(Project) - Project project = Project.load(ref, true, ImportDialog.getInstance(mvc.getStage())); - mvc.setProject(project); - mvc.showPage(0); - } catch (ProfileNotFoundException e) { - e.printStackTrace(); - mvc.showErrorMessage( - Localization.getString(Strings.Error_Profile_NotFound, ref.getProfileReference(), e.getLocalizedMessage())); - - // Neues Profile wählen - Profile profile = ImportDialog.getInstance(mvc.getStage()).getUnkownProfile(); - ref.setProfileReference(profile.getRef()); - } catch (ProjectNotFoundException e) { - e.printStackTrace(); - mvc.showErrorMessage(Localization.getString(Strings.Error_Project_NotFound, ref, e.getLocalizedMessage())); - } catch (Exception e) { - e.printStackTrace(); - mvc.showErrorMessage(Localization.getString(Strings.Error_Project_Open, ref, e.getLocalizedMessage())); - } - }); - } - } - - private void doAction(Runnable run) { - if (mvc.getProject().getPlayedPlayers() > 0 && Profile.currentProfile().getProfileSettings().isLiveMode()) { - mvc.showLiveInfo(); - } else { - run.run(); - } - } - - private final int LAST_DOCUMENT_LIMIT = 3; - - public void createRecentDocumentMenuItems() { - recentOpenMenu.getItems().clear(); - - String project = mvc.getProject().getRef().getName(); - - ProjectReference.getProjectsSorted().stream().filter(item -> !item.getName().equals(project)).limit(LAST_DOCUMENT_LIMIT).forEach(item -> - { - MenuItem menuItem = new MenuItem(item.toString()); - menuItem.setUserData(item); - menuItem.setOnAction(this); - recentOpenMenu.getItems().add(menuItem); - }); - } - - public void setMainViewController(MainViewController mvc) { - this.mvc = mvc; - } - - @Override - public void reloadSettings(Profile oldProfile, Profile currentProfile) { - if (oldProfile != null) { - oldProfile.getProfileSettings().lockedProperty().removeListener(lockedListener); - } - ProfileSettings profileSettings = currentProfile.getProfileSettings(); - profileSettings.lockedProperty().addListener(lockedListener); - lockedListener.changed(profileSettings.lockedProperty(), null, profileSettings.isLocked()); - } - - // Getter - - public CheckMenuItem getAlwaysOnTopItem() { - return alwaysOnTopItem; - } - - public Menu getExtensionMenu() { - return extensionMenu; - } - - public CheckMenuItem getFullScreenMenuItem() { - return fullScreenMenuItem; - } -} diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/main/MainToolbarController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/main/MainToolbarController.java deleted file mode 100644 index b3ba148221022f94b46a5156cf6cf4b13f43587a..0000000000000000000000000000000000000000 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/main/MainToolbarController.java +++ /dev/null @@ -1,140 +0,0 @@ -package de.tobias.playpad.viewcontroller.main; - -import java.net.URL; -import java.util.ResourceBundle; - -import de.tobias.playpad.Strings; -import de.tobias.playpad.settings.Profile; -import de.tobias.playpad.settings.ProfileListener; -import de.tobias.playpad.settings.ProfileSettings; -import de.tobias.utils.ui.icon.FontAwesomeType; -import de.tobias.utils.ui.icon.FontIcon; -import de.tobias.utils.util.Localization; -import javafx.beans.value.ChangeListener; -import javafx.beans.value.ObservableValue; -import javafx.event.ActionEvent; -import javafx.event.EventHandler; -import javafx.fxml.FXML; -import javafx.fxml.Initializable; -import javafx.scene.Node; -import javafx.scene.control.Button; -import javafx.scene.control.Label; -import javafx.scene.control.Slider; -import javafx.scene.control.ToolBar; -import javafx.scene.layout.HBox; - -@Deprecated -public class MainToolbarController implements IMainToolbarViewController, Initializable, EventHandler<ActionEvent>, ProfileListener { - - @FXML private ToolBar toolbar; - @FXML private HBox toolbarHBox; - @FXML private HBox pageHBox; - - @FXML private HBox iconHbox; - private Label lockedLabel; - - @FXML private Label volumeDownLabel; - @FXML private Slider volumeSlider; - @FXML private Label volumeUpLabel; - - private MainViewController mainViewController; - - private ChangeListener<Boolean> lockedListener; - - @Override - public void initialize(URL location, ResourceBundle resources) { - ProfileSettings profileSettings = Profile.currentProfile().getProfileSettings(); - Profile.registerListener(this); - - // Listener - lockedListener = new ChangeListener<Boolean>() { - - @Override - public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { - if (newValue) { - iconHbox.getChildren().add(lockedLabel); - } else { - iconHbox.getChildren().remove(lockedLabel); - } - } - }; - profileSettings.lockedProperty().addListener(lockedListener); - - // HBox Child wird Max Width, subtract weil sonst zu groß für Toolbar - toolbarHBox.prefWidthProperty().bind(toolbar.widthProperty().subtract(25)); - toolbarHBox.prefHeightProperty().bind(toolbar.minHeightProperty()); - - // Info Icons - lockedLabel = new Label(); - lockedLabel.setGraphic(new FontIcon(FontAwesomeType.LOCK)); - lockedListener.changed(profileSettings.lockedProperty(), null, profileSettings.isLocked()); - - // Icons Volume - volumeDownLabel.setGraphic(new FontIcon("volume-item", FontAwesomeType.VOLUME_DOWN)); - volumeUpLabel.setGraphic(new FontIcon("volume-item", FontAwesomeType.VOLUME_UP)); - - volumeSlider.setOnScroll(ev -> - { - volumeSlider.setValue(volumeSlider.getValue() - ev.getDeltaY() * 0.001); - volumeSlider.setValue(volumeSlider.getValue() + ev.getDeltaX() * 0.001); - }); - } - - public void createPageButtons() { - pageHBox.getChildren().clear(); - for (int i = 0; i < Profile.currentProfile().getProfileSettings().getPageCount(); i++) { - Button item = new Button(Localization.getString(Strings.UI_Window_Main_PageButton, (i + 1))); - item.setUserData(i); - item.setFocusTraversable(false); - item.setOnAction(this); - pageHBox.getChildren().add(item); - } - } - - public HBox getPageHBox() { - return pageHBox; - } - - public HBox getToolbarHBox() { - return toolbarHBox; - } - - public Slider getVolumeSlider() { - return volumeSlider; - } - - public void setMainViewController(MainViewController mainViewController) { - this.mainViewController = mainViewController; - } - - @Override - public void handle(ActionEvent event) { - if (event.getSource() instanceof Button) { - // Page Buttons - Button item = (Button) event.getSource(); - int number = (int) item.getUserData(); - mainViewController.showPage(number); - } - } - - @Override - public void reloadSettings(Profile oldProfile, Profile currentProfile) { - if (oldProfile != null) { - oldProfile.getProfileSettings().lockedProperty().removeListener(lockedListener); - } - ProfileSettings profileSettings = currentProfile.getProfileSettings(); - profileSettings.lockedProperty().addListener(lockedListener); - lockedListener.changed(profileSettings.lockedProperty(), null, profileSettings.isLocked()); - } - - @Override - public void showIcon(Node node) { - iconHbox.getChildren().add(node); - } - - @Override - public void hideIcon(Node node) { - iconHbox.getChildren().remove(node); - } - -} diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/main/MainViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/main/MainViewController.java index 04b6503415a452c82087fe5a35b09dc54c662b1d..c9a0df0fa17fd21bdb493a49d92f84ab90d0b264 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/main/MainViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/main/MainViewController.java @@ -1,6 +1,5 @@ package de.tobias.playpad.viewcontroller.main; -import java.io.IOException; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.List; @@ -9,35 +8,32 @@ import java.util.Optional; import javax.sound.midi.MidiUnavailableException; import de.tobias.playpad.PlayPadMain; +import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.Strings; import de.tobias.playpad.action.Mapping; -import de.tobias.playpad.action.cartaction.CartAction; -import de.tobias.playpad.action.connect.CartActionConnect; -import de.tobias.playpad.action.feedback.ColorAssociator; -import de.tobias.playpad.action.feedback.DisplayableFeedbackColor; -import de.tobias.playpad.action.feedback.FeedbackMessage; -import de.tobias.playpad.action.mapper.Mapper; -import de.tobias.playpad.action.mapper.MapperFeedbackable; import de.tobias.playpad.action.mapper.listener.KeyboardHandler; import de.tobias.playpad.action.mapper.listener.MidiHandler; -import de.tobias.playpad.design.CartDesign; -import de.tobias.playpad.design.DesignColorAssociator; import de.tobias.playpad.design.GlobalDesign; +import de.tobias.playpad.layout.desktop.DesktopMainLayoutConnect; import de.tobias.playpad.midi.Midi; +import de.tobias.playpad.midi.MidiListener; import de.tobias.playpad.pad.Pad; -import de.tobias.playpad.pad.view.IPadViewController; -import de.tobias.playpad.pad.view.IPadViewV2; +import de.tobias.playpad.pad.view.IPadView; import de.tobias.playpad.plugin.WindowListener; import de.tobias.playpad.project.Project; +import de.tobias.playpad.project.ProjectSettings; +import de.tobias.playpad.registry.DefaultRegistry; +import de.tobias.playpad.registry.NoSuchComponentException; +import de.tobias.playpad.settings.GlobalSettings; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.settings.ProfileListener; import de.tobias.playpad.settings.ProfileSettings; -import de.tobias.playpad.view.PadView; +import de.tobias.playpad.settings.keys.KeyCollection; import de.tobias.playpad.view.main.MainLayoutConnect; -import de.tobias.playpad.viewcontroller.IPadView; +import de.tobias.playpad.view.main.MainLayoutHandler; import de.tobias.playpad.viewcontroller.dialog.ErrorSummaryDialog; +import de.tobias.playpad.viewcontroller.dialog.SaveDialog; import de.tobias.playpad.viewcontroller.pad.PadDragListener; -import de.tobias.playpad.viewcontroller.pad.PadViewController; import de.tobias.utils.ui.BasicControllerSettings; import de.tobias.utils.ui.NotificationHandler; import de.tobias.utils.ui.ViewController; @@ -53,48 +49,39 @@ import javafx.event.EventType; import javafx.fxml.FXML; import javafx.scene.Group; import javafx.scene.Node; +import javafx.scene.Scene; import javafx.scene.control.Alert; import javafx.scene.control.Alert.AlertType; -import javafx.scene.control.Button; import javafx.scene.control.ButtonType; -import javafx.scene.control.Label; -import javafx.scene.control.MenuItem; -import javafx.scene.control.Slider; import javafx.scene.input.KeyCombination; import javafx.scene.input.KeyEvent; import javafx.scene.layout.AnchorPane; import javafx.scene.layout.ColumnConstraints; import javafx.scene.layout.GridPane; import javafx.scene.layout.RowConstraints; +import javafx.scene.layout.VBox; import javafx.scene.paint.Color; import javafx.scene.shape.Line; import javafx.stage.Modality; import javafx.stage.Screen; import javafx.stage.Stage; -// TODO Extract Color Adjust methodes public class MainViewController extends ViewController implements IMainViewController, NotificationHandler, ProfileListener { - private static final String CURRENT_PAGE_BUTTON = "current-page-button"; + private static final int FIRST_PAGE = 0; - // UI - @FXML protected MainMenuBarController menuBarController; - @FXML protected MainToolbarController toolbarController; + @FXML private VBox headerBox; @FXML private GridPane padGridPane; - @FXML private Label liveLabel; - @FXML private AnchorPane gridContainer; private NotificationPane notificationPane; - private ErrorSummaryDialog errorSummaryDialog; + private List<IPadView> padViews; - // Model - private Project project; - protected List<IPadViewController> padViewList = new ArrayList<>(); + private MenuToolbarViewController menuToolbarViewController; - // Current View Items - private int pageNumber; + private Project openProject; + private int currentPageShowing = -1; // Mapper private Midi midi; @@ -104,17 +91,44 @@ public class MainViewController extends ViewController implements IMainViewContr // Style private Color gridColor; - public MainViewController(Project project, List<WindowListener<IMainViewController>> listener) { + // Layout + private MainLayoutConnect mainLayout; + private List<MainLayoutHandler> layoutActions; + + // Listener + private VolumeChangeListener volumeChangeListener; + private LockedListener lockedListener; + private LayoutChangedListener layoutChangedListener; + + public MainViewController(List<WindowListener<IMainViewController>> listener) { super("mainView", "de/tobias/playpad/assets/view/main/", null, PlayPadMain.getUiResourceBundle()); + padViews = new ArrayList<>(); - // Include FXML Setup - toolbarController.setMainViewController(this); - menuBarController.setMainViewController(this); + // Init ErrorSummaryViewController + new ErrorSummaryDialog(getStage()); // Instance in ErrorSummaryViewController.getInstance() - padGridPane.setGridLinesVisible(true); + // Layout Init + layoutActions = new ArrayList<>(); + + // Init Listener + volumeChangeListener = new VolumeChangeListener(this); + lockedListener = new LockedListener(this); + layoutChangedListener = new LayoutChangedListener(); + initMapper(openProject); + + // Default Layout + setMainLayout(new DesktopMainLayoutConnect()); - // Settings Setup Profile.registerListener(this); + 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 + performLayoutDependendAction((oldToolbar, newToolbar) -> + { + if (menuToolbarViewController != null) + menuToolbarViewController.initPageButtons(); + }); /* * Gridline Color @@ -137,6 +151,18 @@ public class MainViewController extends ViewController implements IMainViewContr e.printStackTrace(); } + // Plugin Listener + listener.forEach(l -> + { + try { + l.onInit(this); + } catch (Exception e) { + e.printStackTrace(); + } + }); + } + + private void initMapper(Project project) { /* * Mapper Setup & Listener */ @@ -145,63 +171,72 @@ public class MainViewController extends ViewController implements IMainViewContr this.midi.setListener(midiHandler); this.keyboardHandler = new KeyboardHandler(project, this); - // Setup - errorSummaryDialog = new ErrorSummaryDialog(getStage()); - getStage().toFront(); - - // setup project - setProject(project); - - // Setup Settings - reloadSettings(null, Profile.currentProfile()); - - // Listener - listener.forEach(l -> l.onInit(this)); } @Override public void init() { padGridPane.getStyleClass().add("pad-grid"); - menuBarController.getExtensionMenu().setVisible(false); - - liveLabel.setVisible(false); - liveLabel.getStyleClass().add("live-label"); - notificationPane = new NotificationPane(padGridPane); notificationPane.getStyleClass().add(NotificationPane.STYLE_CLASS_DARK); gridContainer.getChildren().add(notificationPane); setAnchor(notificationPane, 0, 0, 0, 0); + } - getStage().fullScreenProperty().addListener((a, b, c) -> - { - menuBarController.getFullScreenMenuItem().setSelected(c); - }); - - // Lautstärke Veränderung - toolbarController.getVolumeSlider().valueProperty().addListener((a, b, c) -> - { - setPadVolume(c.doubleValue()); - }); + // main layout + public MainLayoutConnect getMainLayout() { + return mainLayout; } - public void setPadVolume(double volume) { - for (Pad pad : project.getPads().values()) { - if (pad != null) - pad.setMasterVolume(volume); - } + public void setMainLayout(MainLayoutConnect mainLayoutConnect) { + removePadsFromView(); + removePadViews(); + + this.mainLayout = mainLayoutConnect; + initMainLayout(); } - public void setTitle() { - if (project != null && Profile.currentProfile() != null) { - getStage().setTitle(Localization.getString(Strings.UI_Window_Main_Title, project.getRef().getName(), - Profile.currentProfile().getRef().getName())); - } else { - getStage().setTitle(Localization.getString(Strings.UI_Window_Main_Title)); + private void initMainLayout() { + ProfileSettings settings = Profile.currentProfile().getProfileSettings(); + + // Entfernt Volume listener + if (menuToolbarViewController != null) { + menuToolbarViewController.deinit(); + + menuToolbarViewController.getVolumeSlider().valueProperty().unbindBidirectional(settings.volumeProperty()); + menuToolbarViewController.getVolumeSlider().valueProperty().removeListener(volumeChangeListener); } + + // Erstellt Neue Toolbar + headerBox.getChildren().clear(); + MenuToolbarViewController newMenuToolbarViewController = mainLayout.createMenuToolbar(this); + headerBox.getChildren().add(newMenuToolbarViewController.getParent()); + + // Führt alle Listener für diesen neuen Controller aus, damit Buttons und co wieder erstellt werden können + layoutChangedListener.handle(layoutActions, this.menuToolbarViewController, newMenuToolbarViewController); + this.menuToolbarViewController = newMenuToolbarViewController; + + menuToolbarViewController.setOpenProject(openProject); + // Neue Volume listener + menuToolbarViewController.getVolumeSlider().valueProperty().bindBidirectional(settings.volumeProperty()); + menuToolbarViewController.getVolumeSlider().valueProperty().addListener(volumeChangeListener); + + // Keyboard Shortcuts + GlobalSettings globalSettings = PlayPadPlugin.getImplementation().getGlobalSettings(); + menuToolbarViewController.loadKeybinding(globalSettings.getKeyCollection()); + + // Update Locked Listener + ProfileSettings profileSettings = Profile.currentProfile().getProfileSettings(); + lockedListener.changed(profileSettings.lockedProperty(), !profileSettings.isLocked(), profileSettings.isLocked()); + + // Zeigt aktuelle Daten an + createPadViews(); + showPage(currentPageShowing); + loadUserCss(); } + // Stage Handling @Override public void initStage(Stage stage) { stage.fullScreenProperty().addListener((a, b, c) -> @@ -218,6 +253,7 @@ public class MainViewController extends ViewController implements IMainViewContr @Override protected void loadSettings(BasicControllerSettings settings) { + // Lädt die vorherigen Screen Positionen des Fenster List<Screen> screens = Screen.getScreensForRectangle(settings.getUserInfoAsDouble("x"), settings.getUserInfoAsDouble("y"), settings.width, settings.height); if (!screens.isEmpty()) { @@ -231,144 +267,176 @@ public class MainViewController extends ViewController implements IMainViewContr @Override protected void save(BasicControllerSettings settings) { + // Speichert die aktuelle Position des Fensters settings.addUserInfo("x", getStage().getX()); settings.addUserInfo("y", getStage().getY()); settings.width = getStage().getWidth(); settings.height = getStage().getHeight(); } - public void setProject(Project project) { - if (this.project != null) { - for (IPadViewController controller : padViewList) { - controller.unconnectPad(); - } - // Speichert das alte Projekt, bevor ein neues geladen wird - try { - this.project.save(); - } catch (IOException e) { - e.printStackTrace(); - showError(Localization.getString(Strings.Error_Project_Save, e.getLocalizedMessage())); - } - } - this.project = project; + @Override + public boolean closeRequest() { + ErrorSummaryDialog.getInstance().getStage().close(); - midiHandler.setProject(project); - keyboardHandler.setProject(project); - PadDragListener.setProject(project); + if (Profile.currentProfile() != null) { + ProfileSettings profilSettings = Profile.currentProfile().getProfileSettings(); + GlobalSettings globalSettings = PlayPadPlugin.getImplementation().getGlobalSettings(); - errorSummaryDialog.setProject(project); - menuBarController.createRecentDocumentMenuItems(); - setTitle(); - } + // Frag den Nutzer ob das Programm wirdklich geschlossen werden sol + // wenn ein Pad noch im Status Play ist + if (openProject.getActivePlayers() > 0 && globalSettings.isLiveMode()) { + Alert alert = new Alert(AlertType.CONFIRMATION); + alert.setContentText(Localization.getString(Strings.UI_Window_Main_CloseRequest)); - // GUI Helping Methoden - public void loadUserCss() { - Profile.currentProfile().currentLayout().applyCssMainView(this, getStage(), project); - applyColorsToMappers(); - } - - public void applyColorsToMappers() { - // Apply Layout to Mapper - List<CartAction> actions = Profile.currentProfile().getMappings().getActiveMapping().getActions(CartActionConnect.TYPE); - for (CartAction cartAction : actions) { - if (cartAction.isAutoFeedbackColors()) { - for (Mapper mapper : cartAction.getMappers()) { - if (mapper instanceof MapperFeedbackable) { - mapColorForMapper(cartAction, mapper); + alert.initOwner(getStage()); + alert.initModality(Modality.WINDOW_MODAL); + Stage alertStage = (Stage) alert.getDialogPane().getScene().getWindow(); + PlayPadMain.stageIcon.ifPresent(alertStage.getIcons()::add); + + Optional<ButtonType> result = alert.showAndWait(); + if (result.isPresent()) + if (result.get() != ButtonType.OK) + return false; + } + + // Save Dialog + if (globalSettings.isIgnoreSaveDialog()) { + saveProject(); + } else { + SaveDialog alert = new SaveDialog(getStage()); + Optional<ButtonType> result = alert.showAndWait(); + if (result.isPresent()) { + globalSettings.setIgnoreSaveDialog(alert.isSelected()); + ButtonType buttonType = result.get(); + if (buttonType == ButtonType.YES) { + // Projekt Speichern + saveProject(); + } else if (buttonType == ButtonType.CANCEL) { + return false; } } } - } - } - private void mapColorForMapper(CartAction cartAction, Mapper mapper) { - MapperFeedbackable feedbackable = (MapperFeedbackable) mapper; - if (feedbackable.supportFeedback() && mapper instanceof ColorAssociator) { - ColorAssociator colorAssociator = (ColorAssociator) mapper; + // Save Config - Its unabhängig vom Dialog, da es auch an anderen Stellen schon gespeichert wird + try { + if (Profile.currentProfile() != null) + Profile.currentProfile().save(); + } catch (Exception e) { + e.printStackTrace(); + showErrorMessage(Localization.getString(Strings.Error_Profile_Save)); + } - Pad pad = project.getPad(cartAction.getCart()); - Color layoutStdColor = null; - Color layoutEvColor = null; + // Mapper Clear Feedback + Profile.currentProfile().getMappings().getActiveMapping().clearFeedback(); - if (pad.isCustomLayout()) { - CartDesign layout = pad.getLayout(); - if (layout instanceof DesignColorAssociator) { - DesignColorAssociator associator = (DesignColorAssociator) layout; - layoutStdColor = associator.getAssociatedStandardColor(); - layoutEvColor = associator.getAssociatedEventColor(); - } - } else { - GlobalDesign layout = Profile.currentProfile().currentLayout(); - if (layout instanceof DesignColorAssociator) { - DesignColorAssociator associator = (DesignColorAssociator) layout; - layoutStdColor = associator.getAssociatedStandardColor(); - layoutEvColor = associator.getAssociatedEventColor(); + // MIDI Shutdown + // Der schließt MIDI, da er es auch öffnet und verantwortlich ist + if (profilSettings.isMidiActive()) { + try { + midi.close(); + } catch (MidiUnavailableException e1) { + e1.printStackTrace(); } } + } - if (layoutStdColor != null) { - DisplayableFeedbackColor associator = Mapper.searchColor(colorAssociator, FeedbackMessage.STANDARD, layoutStdColor); - colorAssociator.setColor(FeedbackMessage.STANDARD, associator.midiVelocity()); - } + if (getStage().isIconified()) { + getStage().setIconified(false); + } + + // Verbindung von Pad und PadView wird getrennt. Zudem wird bei PLAY + // oder PAUSE auf STOP gesetzt + removePadsFromView(); - if (layoutEvColor != null) { - DisplayableFeedbackColor associator = Mapper.searchColor(colorAssociator, FeedbackMessage.EVENT, layoutEvColor); - colorAssociator.setColor(FeedbackMessage.EVENT, associator.midiVelocity()); + saveSettings(); + return true; + } + + private void saveProject() { + try { + if (openProject.getRef() != null) { + openProject.save(); + System.out.println("Saved Project: " + openProject); } + } catch (Exception e) { + e.printStackTrace(); + showErrorMessage(Localization.getString(Strings.Error_Project_Save)); } } + // project /** - * Erstellt Constraints von GridView, Erstellt PadViews, Lädt CSS, Set Min Size vom Fendster + * Öffnet ein Project. Das akutelle project ist in PlayPadImpl gespeichert. + * + * @param project + * neues Project */ + public void openProject(Project project) { + removePadsFromView(); + + if (project != null) + removePadsFromView(); + + openProject = project; + + midiHandler.setProject(project); + keyboardHandler.setProject(project); + + midiHandler.setProject(project); + keyboardHandler.setProject(project); + PadDragListener.setProject(project); + ErrorSummaryDialog.getInstance().setProject(openProject); + + menuToolbarViewController.setOpenProject(openProject); + + createPadViews(); + showPage(FIRST_PAGE); + loadUserCss(); + updateWindowTitle(); + } + + // Pad, Pages + @Override public void createPadViews() { - ProfileSettings profileSettings = Profile.currentProfile().getProfileSettings(); + if (openProject == null) { + return; + } + ProjectSettings projectSettings = openProject.getSettings(); // Table padGridPane.getColumnConstraints().clear(); - double xPercentage = 1.0 / (double) profileSettings.getColumns(); - for (int i = 0; i < profileSettings.getColumns(); i++) { + double xPercentage = 1.0 / (double) projectSettings.getColumns(); + for (int i = 0; i < projectSettings.getColumns(); i++) { ColumnConstraints c = new ColumnConstraints(); c.setPercentWidth(xPercentage * 100); padGridPane.getColumnConstraints().add(c); } padGridPane.getRowConstraints().clear(); - double yPercentage = 1.0 / (double) profileSettings.getRows(); - for (int i = 0; i < profileSettings.getRows(); i++) { + double yPercentage = 1.0 / (double) projectSettings.getRows(); + for (int i = 0; i < projectSettings.getRows(); i++) { RowConstraints c = new RowConstraints(); c.setPercentHeight(yPercentage * 100); padGridPane.getRowConstraints().add(c); } - // Pads - Remove Old PadViews - padGridPane.getChildren().removeIf(t -> - { - if (t instanceof PadView) { - ((PadView) t).getController().unconnectPad(); - return true; - } else { - return false; - } - }); - padViewList.clear(); + // Pads - Remove alte PadViews, falls noch welche vorhanden + if (!padViews.isEmpty()) + removePadViews(); // Neue PadViews - for (int y = 0; y < profileSettings.getRows(); y++) { - for (int x = 0; x < profileSettings.getColumns(); x++) { - IPadViewController controller = new PadViewController(); - IPadView node = controller.getParent(); - if (node instanceof PadView) { - padGridPane.add((Node) node, x, y); - padViewList.add(controller); - } + for (int y = 0; y < projectSettings.getRows(); y++) { + for (int x = 0; x < projectSettings.getColumns(); x++) { + IPadView padView = mainLayout.createPadView(); + padGridPane.add(padView.getRootNode(), x, y); + padViews.add(padView); } } // Min Size of window GlobalDesign currentLayout = Profile.currentProfile().currentLayout(); - double minWidth = currentLayout.getMinWidth(profileSettings.getColumns()); - double minHeight = currentLayout.getMinHeight(profileSettings.getRows()); + double minWidth = currentLayout.getMinWidth(projectSettings.getColumns()); + double minHeight = currentLayout.getMinHeight(projectSettings.getRows()); getStage().setMinWidth(minWidth); if (OS.getType() == OSType.MacOSX) { @@ -376,188 +444,174 @@ public class MainViewController extends ViewController implements IMainViewContr } else { getStage().setMinHeight(minHeight + 150); } + + menuToolbarViewController.initPageButtons(); + } + + private void removePadViews() { + padViews.forEach(view -> + { + padGridPane.getChildren().remove(view.getRootNode()); + mainLayout.recyclePadView(view); + }); + padViews.clear(); } /** - * Setzt die Pads in die Views und Cleared die alten Views. Lädt für die neuen Pads das Layout neu. - * - * @param newPage + * Zeigt die aktuellen Pads von einem Profil zu einer Seite in den entsprechenden Views an. */ - public synchronized void showPage(int newPage) { - ProfileSettings profileSettings = Profile.currentProfile().getProfileSettings(); + private void addPadsToView() { + ProjectSettings settings = openProject.getSettings(); - if (!(newPage >= 0 && newPage < profileSettings.getPageCount())) { - return; - } + int index = currentPageShowing * settings.getRows() * settings.getColumns(); + for (int i = 0; i < settings.getRows() * settings.getColumns(); i++) { + if (padViews.size() > i) { + IPadView view = padViews.get(i); + Pad pad = openProject.getPad(index); - ProfileSettings settings = Profile.currentProfile().getProfileSettings(); - if (settings.isLiveMode() && settings.isLiveModePage() && getProject().getPlayedPlayers() > 0) { - showLiveInfo(); - return; + view.getViewController().setupPad(pad); + } + index++; } + } - // Button in Toolbar - Button oldButton = (Button) toolbarController.getPageHBox().getChildren().get(pageNumber); // Der Aktuell - // andersfarbende - // Button - oldButton.getStyleClass().remove(CURRENT_PAGE_BUTTON); - - this.pageNumber = newPage; + /** + * Entfernt alle Pads auf den Views. + */ + private void removePadsFromView() { + // Clean old pads + for (IPadView padView : padViews) { + padView.getViewController().removePad(); + } + } - // alte Pads weg - padViewList.forEach(i -> i.unconnectPad()); + @Override + public boolean showPage(int page) { + if (openProject == null) { + return false; + } + ProjectSettings projectSettings = openProject.getSettings(); - // Neue Pads anzeigen - int index = pageNumber * profileSettings.getRows() * profileSettings.getColumns(); - for (int i = 0; i < profileSettings.getRows() * profileSettings.getColumns(); i++) { - if (padViewList.size() > i) { - IPadViewController view = padViewList.get(i); - view.setPad(project.getPad(index)); - } - index++; + if (page < 0 || page >= projectSettings.getPageCount()) { + return false; } - // Button in Toolbar anders färben - Button newButton = (Button) toolbarController.getPageHBox().getChildren().get(pageNumber); - newButton.getStyleClass().add(CURRENT_PAGE_BUTTON); + // Clean + removePadsFromView(); + this.currentPageShowing = page; + addPadsToView(); - // Handle Mapper - if (Profile.currentProfile() != null) { - Profile.currentProfile().getMappings().getActiveMapping().showFeedback(project, this); + if (menuToolbarViewController != null) { + menuToolbarViewController.highlightPageButton(page); } - - // GUI Styling - loadUserCss(); + return true; } - public Slider getVolumeSlider() { - return toolbarController.getVolumeSlider(); + @Override + public int getPage() { + return currentPageShowing; } - // TODO REDO @Override - public boolean closeRequest() { - if (errorSummaryDialog != null) - errorSummaryDialog.getStage().close(); + public void setGlobalVolume(double volume) { + if (openProject != null) { + for (Pad pad : openProject.getPads().values()) { + if (pad != null) + pad.setMasterVolume(volume); + } + } + } - if (Profile.currentProfile() != null) { - ProfileSettings profilSettings = Profile.currentProfile().getProfileSettings(); + // Settings + @Override + public void reloadSettings(Profile old, Profile currentProfile) { + createPadViews(); - // Frag den Nutzer ob das Programm wirdklich geschlossen werden sol - // wenn ein Pad noch im Status Play ist - if (project.getPlayedPlayers() > 0 && profilSettings.isLiveMode()) { - Alert alert = new Alert(AlertType.CONFIRMATION); - alert.setContentText(Localization.getString(Strings.UI_Window_Main_CloseRequest)); + final DoubleProperty volumeFaderValueProperty = menuToolbarViewController.getVolumeSlider().valueProperty(); - alert.initOwner(getStage()); - alert.initModality(Modality.WINDOW_MODAL); - Stage alertStage = (Stage) alert.getDialogPane().getScene().getWindow(); - PlayPadMain.stageIcon.ifPresent(alertStage.getIcons()::add); + if (old != null) { + // Unbind Volume Slider + volumeFaderValueProperty.unbindBidirectional(old.getProfileSettings().volumeProperty()); + volumeFaderValueProperty.removeListener(volumeChangeListener); - Optional<ButtonType> result = alert.showAndWait(); - if (result.isPresent()) - if (result.get() != ButtonType.OK) - return false; - } + // Clear Feedback on Devie (LaunchPad Light off) + old.getMappings().getActiveMapping().getActions().forEach(action -> action.clearFeedback()); - Alert alert = new Alert(AlertType.CONFIRMATION); - alert.setContentText(Localization.getString(Strings.UI_Window_Main_SaveRequest)); - alert.getButtonTypes().setAll(ButtonType.CANCEL, ButtonType.NO, ButtonType.YES); - - Button yesButton = (Button) alert.getDialogPane().lookupButton(ButtonType.YES); - yesButton.defaultButtonProperty().bind(yesButton.focusedProperty()); - - Button noButton = (Button) alert.getDialogPane().lookupButton(ButtonType.NO); - noButton.defaultButtonProperty().bind(noButton.focusedProperty()); - - Button cancelButton = (Button) alert.getDialogPane().lookupButton(ButtonType.CANCEL); - cancelButton.defaultButtonProperty().bind(cancelButton.focusedProperty()); - - alert.initOwner(getStage()); - alert.initModality(Modality.WINDOW_MODAL); - Stage alertStage = (Stage) alert.getDialogPane().getScene().getWindow(); - PlayPadMain.stageIcon.ifPresent(alertStage.getIcons()::add); - - Optional<ButtonType> result = alert.showAndWait(); - if (result.isPresent()) { - ButtonType buttonType = result.get(); - if (buttonType == ButtonType.YES) { - // Projekt Speichern - try { - if (project.getRef() != null) { - project.save(); - System.out.println("Saved Project: " + project); - } - } catch (Exception e) { - e.printStackTrace(); - showErrorMessage(Localization.getString(Strings.Error_Project_Save)); - } - } else if (buttonType == ButtonType.CANCEL) { - return false; - } - } + // LockedListener + old.getProfileSettings().lockedProperty().removeListener(lockedListener); + } - // Save Config - Its unabhängig vom Dialog, da es auch an anderen Stellen schon gespeichert wird - try { - if (Profile.currentProfile() != null) - Profile.currentProfile().save(); - } catch (Exception e) { - e.printStackTrace(); - showErrorMessage(Localization.getString(Strings.Error_Profile_Save)); - } + // Volume + volumeFaderValueProperty.bindBidirectional(currentProfile.getProfileSettings().volumeProperty()); + volumeFaderValueProperty.addListener(volumeChangeListener); - // Mapper Clear Feedback - Profile.currentProfile().getMappings().getActiveMapping().clearFeedback(); + final ProfileSettings profileSettings = currentProfile.getProfileSettings(); + final Mapping activeMapping = currentProfile.getMappings().getActiveMapping(); - // MIDI Shutdown - // Der schließt MIDI, da er es auch öffnet und verantwortlich ist - if (profilSettings.isMidiActive()) { - try { - midi.close(); - } catch (MidiUnavailableException e1) { - e1.printStackTrace(); - } - } - } + // LockedListener + profileSettings.lockedProperty().addListener(lockedListener); - if ( + // MIDI + if (profileSettings.isMidiActive() && profileSettings.getMidiDevice() != null) { + // Load known MIDI Device + Worker.runLater(() -> + { + loadMidiDevice(profileSettings.getMidiDevice()); + Profile.currentProfile().getMappings().getActiveMapping().adjustPadColorToMapper(openProject); - getStage().isIconified()) { - getStage().setIconified(false); + Platform.runLater(() -> + { + // Handle Mapper + if (Profile.currentProfile() != null) { + activeMapping.initFeedback(); + activeMapping.showFeedback(openProject); + } + }); + }); } - // Verbindung von Pad und PadView wird getrennt. Zudem wird bei PLAY - // oder PAUSE auf STOP gesetzt - padViewList.forEach(padView -> padView.unconnectPad()); + try { + DefaultRegistry<MainLayoutConnect> registry = PlayPadPlugin.getRegistryCollection().getMainLayouts(); + MainLayoutConnect connect = registry.getComponent(currentProfile.getProfileSettings().getMainLayoutType()); + setMainLayout(connect); + } catch (NoSuchComponentException e) { + // TODO Error Handling + e.printStackTrace(); + } - saveSettings(); - return true; + loadUserCss(); + if (old != null && currentProfile != null) { + showPage(currentPageShowing); + } } - /* - * MIDI - */ + @Override + public void loadKeybinding(KeyCollection keys) { + if (menuToolbarViewController != null) { + menuToolbarViewController.loadKeybinding(keys); + } + } - /** - * Init MIDI Device by using the Midi Class and show some feedback the user. - * - * @param name - * Device Name - * - * @see Midi#lookupMidiDevice(String) - */ - private void loadMidiDevice(String name) { + @Override + public void setGridColor(Color color) { + this.gridColor = color; try { - midi.lookupMidiDevice(name); - notificationPane.showAndHide(Localization.getString(Strings.Info_Midi_Device_Connected, name), PlayPadMain.displayTimeMillis); - } catch (NullPointerException e) { - showError(Localization.getString(Strings.Error_Midi_Device_Unavailible, name)); - } catch (IllegalArgumentException | MidiUnavailableException e) { - showError(Localization.getString(Strings.Error_Midi_Device_Busy, e.getLocalizedMessage())); + Field field = padGridPane.getClass().getDeclaredField("gridLines"); + field.setAccessible(true); + Group group = (Group) field.get(padGridPane); + if (group != null) { + for (Node node : group.getChildren()) { + if (node instanceof Line) { + ((Line) node).setStroke(gridColor); + } + } + } + } catch (Exception e) { e.printStackTrace(); } } + // Notification @Override public void notify(String text, long duration) { if (Platform.isFxApplicationThread()) { @@ -594,152 +648,85 @@ public class MainViewController extends ViewController implements IMainViewContr } } + // Utils @Override - public int getPage() { - return pageNumber; - } - - private boolean shown = false; - - public void showLiveInfo() { - if (!shown) { - toolbarController.getToolbarHBox().setOpacity(0.5); - liveLabel.setVisible(true); - shown = true; - Worker.runLater(() -> - { - try { - Thread.sleep(PlayPadMain.displayTimeMillis * 2); - } catch (Exception e) {} - Platform.runLater(() -> - { - toolbarController.getToolbarHBox().setOpacity(1); - liveLabel.setVisible(false); - shown = false; - }); - }); - } + public void registerKeyboardListener(EventType<KeyEvent> eventType, EventHandler<KeyEvent> listener) { + getParent().getScene().addEventHandler(eventType, listener); } @Override - public void reloadSettings(Profile old, Profile currentProfile) { - final DoubleProperty valueProperty = toolbarController.getVolumeSlider().valueProperty(); - - if (old != null) { - // Unbind Volume Slider - valueProperty.unbindBidirectional(old.getProfileSettings().volumeProperty()); - // Clear Feedback on Devie (LaunchPad Light off) - old.getMappings().getActiveMapping().getActions().forEach(action -> action.clearFeedback()); - } - - // Pad iund Page GUI - createPadViews(); - toolbarController.createPageButtons(); - - // Volume - valueProperty.bindBidirectional(currentProfile.getProfileSettings().volumeProperty()); - - final ProfileSettings profilSettings = currentProfile.getProfileSettings(); - final Mapping activeMapping = currentProfile.getMappings().getActiveMapping(); - - // MIDI - if (profilSettings.isMidiActive() && profilSettings.getMidiDevice() != null) { - // Load known MIDI Device - Worker.runLater(() -> - { - loadMidiDevice(profilSettings.getMidiDevice()); + public void loadUserCss() { + Scene scene = getStage().getScene(); - applyColorsToMappers(); + // Clear Old + scene.getStylesheets().clear(); - Platform.runLater(() -> - { - // Handle Mapper - if (Profile.currentProfile() != null) { - activeMapping.initFeedback(); - activeMapping.showFeedback(project); - } - }); - }); + // Layout Spezifisches CSS (Base) + if (mainLayout.getStylesheet() != null) { + scene.getStylesheets().add(mainLayout.getStylesheet()); } - // WINDOW Settings - menuBarController.getAlwaysOnTopItem().setSelected(profilSettings.isWindowAlwaysOnTop()); - getStage().setAlwaysOnTop(profilSettings.isWindowAlwaysOnTop()); - - setTitle(); - showPage(pageNumber); // Show Mapper Feedback und apply css und zeigt pads - } - - public Project getProject() { - return project; - } - - public MidiHandler getMidiHandler() { - return midiHandler; - } + // design spezific css + if (openProject != null) { + Profile.currentProfile().currentLayout().applyCssMainView(this, getStage(), openProject); + } - public MainToolbarController getToolbarController() { - return toolbarController; + Profile.currentProfile().getMappings().getActiveMapping().adjustPadColorToMapper(openProject); } - // Plugins /** - * Fügt ein MenuItem ins Menu hinzu + * Init MIDI Device by using the Midi Class and show some feedback the user. * - * @param item + * @param name + * Device Name * - * @since 2.0.0 + * @see Midi#lookupMidiDevice(String) */ - public void addMenuItem(MenuItem item) { - menuBarController.getExtensionMenu().getItems().add(item); - if (!menuBarController.getExtensionMenu().isVisible()) { - menuBarController.getExtensionMenu().setVisible(true); + private void loadMidiDevice(String name) { + try { + midi.lookupMidiDevice(name); + notificationPane.showAndHide(Localization.getString(Strings.Info_Midi_Device_Connected, name), PlayPadMain.displayTimeMillis); + } catch (NullPointerException e) { + e.printStackTrace(); + showError(Localization.getString(Strings.Error_Midi_Device_Unavailible, name)); + } catch (IllegalArgumentException | MidiUnavailableException e) { + showError(Localization.getString(Strings.Error_Midi_Device_Busy, e.getLocalizedMessage())); + e.printStackTrace(); } } - public void setGridColor(Color gridColor) { - this.gridColor = gridColor; - try { - Field field = padGridPane.getClass().getDeclaredField("gridLines"); - field.setAccessible(true); - Group group = (Group) field.get(padGridPane); - if (group != null) { - for (Node node : group.getChildren()) { - if (node instanceof Line) { - ((Line) node).setStroke(gridColor); - } - } - } - } catch (Exception e) { - e.printStackTrace(); + public void updateWindowTitle() { + if (openProject != null && Profile.currentProfile() != null) { + getStage().setTitle(Localization.getString(Strings.UI_Window_Main_Title, openProject.getRef().getName(), + Profile.currentProfile().getRef().getName())); + } else { + getStage().setTitle(Localization.getString(Strings.UI_Window_Main_Title)); } } @Override - public void registerKeyboardListener(EventType<KeyEvent> eventType, EventHandler<KeyEvent> listener) { - getParent().getScene().addEventHandler(eventType, listener); + public List<IPadView> getPadViews() { + return padViews; } @Override - public List<IPadViewV2> getPadViews() { - // TODO Auto-generated method stub - return null; + public MidiListener getMidiHandler() { + return midiHandler; } @Override public MenuToolbarViewController getMenuToolbarController() { - // TODO Auto-generated method stub - return null; + return menuToolbarViewController; } @Override - public void setMainLayout(MainLayoutConnect mainLayoutConnect) { - // TODO Auto-generated method stub + public void performLayoutDependendAction(MainLayoutHandler runnable) { + runnable.handle(null, menuToolbarViewController); + layoutActions.add(runnable); } @Override - public void performLayoutDependendAction(Runnable runnable) { - // TODO Auto-generated method stub - + public NotificationPane getNotificationPane() { + return notificationPane; } } diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/main/MainViewControllerV2.java b/PlayWall/src/de/tobias/playpad/viewcontroller/main/MainViewControllerV2.java deleted file mode 100644 index 0025fa6d3f608793ee0a0676261f41577b8d3a46..0000000000000000000000000000000000000000 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/main/MainViewControllerV2.java +++ /dev/null @@ -1,753 +0,0 @@ -package de.tobias.playpad.viewcontroller.main; - -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -import javax.sound.midi.MidiUnavailableException; - -import de.tobias.playpad.PlayPadMain; -import de.tobias.playpad.PlayPadPlugin; -import de.tobias.playpad.Strings; -import de.tobias.playpad.action.Mapping; -import de.tobias.playpad.action.mapper.listener.KeyboardHandler; -import de.tobias.playpad.action.mapper.listener.MidiHandler; -import de.tobias.playpad.design.GlobalDesign; -import de.tobias.playpad.layout.desktop.DesktopMainLayoutConnect; -import de.tobias.playpad.midi.Midi; -import de.tobias.playpad.midi.MidiListener; -import de.tobias.playpad.pad.Pad; -import de.tobias.playpad.pad.view.IPadViewV2; -import de.tobias.playpad.plugin.WindowListener; -import de.tobias.playpad.project.Project; -import de.tobias.playpad.project.ProjectSettings; -import de.tobias.playpad.registry.DefaultRegistry; -import de.tobias.playpad.registry.NoSuchComponentException; -import de.tobias.playpad.settings.GlobalSettings; -import de.tobias.playpad.settings.Profile; -import de.tobias.playpad.settings.ProfileListener; -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.pad.PadDragListener; -import de.tobias.utils.ui.BasicControllerSettings; -import de.tobias.utils.ui.NotificationHandler; -import de.tobias.utils.ui.ViewController; -import de.tobias.utils.ui.scene.NotificationPane; -import de.tobias.utils.util.Localization; -import de.tobias.utils.util.OS; -import de.tobias.utils.util.OS.OSType; -import de.tobias.utils.util.Worker; -import javafx.application.Platform; -import javafx.beans.property.DoubleProperty; -import javafx.event.EventHandler; -import javafx.event.EventType; -import javafx.fxml.FXML; -import javafx.scene.Group; -import javafx.scene.Node; -import javafx.scene.Scene; -import javafx.scene.control.Alert; -import javafx.scene.control.Alert.AlertType; -import javafx.scene.control.Button; -import javafx.scene.control.ButtonType; -import javafx.scene.input.KeyCombination; -import javafx.scene.input.KeyEvent; -import javafx.scene.layout.AnchorPane; -import javafx.scene.layout.ColumnConstraints; -import javafx.scene.layout.GridPane; -import javafx.scene.layout.RowConstraints; -import javafx.scene.layout.VBox; -import javafx.scene.paint.Color; -import javafx.scene.shape.Line; -import javafx.stage.Modality; -import javafx.stage.Screen; -import javafx.stage.Stage; - -public class MainViewControllerV2 extends ViewController implements IMainViewController, NotificationHandler, ProfileListener { - - private static final int FIRST_PAGE = 0; - - @FXML private VBox headerBox; - @FXML private GridPane padGridPane; - - @FXML private AnchorPane gridContainer; - private NotificationPane notificationPane; - - private List<IPadViewV2> padViews; - - private MenuToolbarViewController menuToolbarViewController; - - private Project openProject; - private int currentPageShowing = -1; - - // Mapper - private Midi midi; - private MidiHandler midiHandler; - private KeyboardHandler keyboardHandler; - - // Style - private Color gridColor; - - // Layout - private MainLayoutConnect mainLayout; - private List<MainLayoutHandler> layoutActions; - - // Listener - private VolumeChangeListener volumeChangeListener; - private LockedListener lockedListener; - private LayoutChangedListener layoutChangedListener; - - public MainViewControllerV2(List<WindowListener<IMainViewController>> listener) { - super("mainViewV2", "de/tobias/playpad/assets/view/main/", null, PlayPadMain.getUiResourceBundle()); - padViews = new ArrayList<>(); - - // Layout Init - layoutActions = new ArrayList<>(); - - // Init Listener - volumeChangeListener = new VolumeChangeListener(this); - lockedListener = new LockedListener(this); - layoutChangedListener = new LayoutChangedListener(); - - setMainLayout(new DesktopMainLayoutConnect()); // DEBUG - - Profile.registerListener(this); - 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 - performLayoutDependendAction((oldToolbar, newToolbar) -> - { - if (menuToolbarViewController != null) - menuToolbarViewController.initPageButtons(); - }); - - /* - * Gridline Color - */ - try { - Field field = padGridPane.getClass().getDeclaredField("gridLines"); - field.setAccessible(true); - Group group = (Group) field.get(padGridPane); - if (group != null) { - group.getChildren().addListener((javafx.collections.ListChangeListener.Change<? extends Node> c) -> - { - for (Node node : group.getChildren()) { - if (node instanceof Line) { - ((Line) node).setStroke(gridColor); - } - } - }); - } - } catch (Exception e) { - e.printStackTrace(); - } - - // Plugin Listener - listener.forEach(l -> - { - try { - l.onInit(this); - } catch (Exception e) { - e.printStackTrace(); - } - }); - } - - private void initMapper(Project project) { - /* - * Mapper Setup & Listener - */ - this.midi = Midi.getInstance(); - this.midiHandler = new MidiHandler(midi, this, project); - this.midi.setListener(midiHandler); - this.keyboardHandler = new KeyboardHandler(project, this); - - } - - @Override - public void init() { - padGridPane.getStyleClass().add("pad-grid"); - - notificationPane = new NotificationPane(padGridPane); - notificationPane.getStyleClass().add(NotificationPane.STYLE_CLASS_DARK); - - gridContainer.getChildren().add(notificationPane); - setAnchor(notificationPane, 0, 0, 0, 0); - } - - // main layout - public MainLayoutConnect getMainLayout() { - return mainLayout; - } - - public void setMainLayout(MainLayoutConnect mainLayoutConnect) { - removePadsFromView(); - removePadViews(); - - this.mainLayout = mainLayoutConnect; - initMainLayout(); - } - - private void initMainLayout() { - ProfileSettings settings = Profile.currentProfile().getProfileSettings(); - - if (menuToolbarViewController != null) { - menuToolbarViewController.deinit(); - - menuToolbarViewController.getVolumeSlider().valueProperty().unbindBidirectional(settings.volumeProperty()); - menuToolbarViewController.getVolumeSlider().valueProperty().removeListener(volumeChangeListener); - } - - headerBox.getChildren().clear(); - MenuToolbarViewController newMenuToolbarViewController = mainLayout.createMenuToolbar(this); - headerBox.getChildren().add(newMenuToolbarViewController.getParent()); - - // Kopiert alte Einstellungen - if (menuToolbarViewController != null) { - newMenuToolbarViewController.setAlwaysOnTopActive(this.menuToolbarViewController.isAlwaysOnTopActive()); - newMenuToolbarViewController.setFullScreenActive(this.menuToolbarViewController.isFullscreenActive()); - } - - layoutChangedListener.handle(layoutActions, this.menuToolbarViewController, newMenuToolbarViewController); - this.menuToolbarViewController = newMenuToolbarViewController; - - menuToolbarViewController.getVolumeSlider().valueProperty().bindBidirectional(settings.volumeProperty()); - menuToolbarViewController.getVolumeSlider().valueProperty().addListener(volumeChangeListener); - - // Keyboard Shortcuts - GlobalSettings globalSettings = PlayPadPlugin.getImplementation().getGlobalSettings(); - menuToolbarViewController.loadKeybinding(globalSettings.getKeyCollection()); - - // Update Locked Listener - ProfileSettings profileSettings = Profile.currentProfile().getProfileSettings(); - lockedListener.changed(profileSettings.lockedProperty(), !profileSettings.isLocked(), profileSettings.isLocked()); - - createPadViews(); - showPage(currentPageShowing); - - loadUserCss(); - } - - // Stage Handling - @Override - public void initStage(Stage stage) { - stage.fullScreenProperty().addListener((a, b, c) -> - { - if (Profile.currentProfile() != null) - stage.setAlwaysOnTop(Profile.currentProfile().getProfileSettings().isWindowAlwaysOnTop()); - }); - - PlayPadMain.stageIcon.ifPresent(stage.getIcons()::add); - stage.setFullScreenExitKeyCombination(KeyCombination.keyCombination(KeyCombination.SHIFT_DOWN + "+Esc")); - stage.setTitle(Localization.getString(Strings.UI_Window_Main_Title)); - stage.show(); - } - - @Override - protected void loadSettings(BasicControllerSettings settings) { - // Lädt die vorherigen Screen Positionen des Fenster - List<Screen> screens = Screen.getScreensForRectangle(settings.getUserInfoAsDouble("x"), settings.getUserInfoAsDouble("y"), - settings.width, settings.height); - if (!screens.isEmpty()) { - getStage().setX(settings.getUserInfoAsDouble("x")); - getStage().setY(settings.getUserInfoAsDouble("y")); - } - - getStage().setWidth(settings.width); - getStage().setHeight(settings.height); - } - - @Override - protected void save(BasicControllerSettings settings) { - // Speichert die aktuelle Position des Fensters - settings.addUserInfo("x", getStage().getX()); - settings.addUserInfo("y", getStage().getY()); - settings.width = getStage().getWidth(); - settings.height = getStage().getHeight(); - } - - @Override - public boolean closeRequest() { - // TODO Close Error Window - - if (Profile.currentProfile() != null) { - ProfileSettings profilSettings = Profile.currentProfile().getProfileSettings(); - - // Frag den Nutzer ob das Programm wirdklich geschlossen werden sol - // wenn ein Pad noch im Status Play ist - if (openProject.getPlayedPlayers() > 0 && profilSettings.isLiveMode()) { - Alert alert = new Alert(AlertType.CONFIRMATION); - alert.setContentText(Localization.getString(Strings.UI_Window_Main_CloseRequest)); - - alert.initOwner(getStage()); - alert.initModality(Modality.WINDOW_MODAL); - Stage alertStage = (Stage) alert.getDialogPane().getScene().getWindow(); - PlayPadMain.stageIcon.ifPresent(alertStage.getIcons()::add); - - Optional<ButtonType> result = alert.showAndWait(); - if (result.isPresent()) - if (result.get() != ButtonType.OK) - return false; - } - - Alert alert = new Alert(AlertType.CONFIRMATION); - alert.setContentText(Localization.getString(Strings.UI_Window_Main_SaveRequest)); - alert.getButtonTypes().setAll(ButtonType.CANCEL, ButtonType.NO, ButtonType.YES); - - Button yesButton = (Button) alert.getDialogPane().lookupButton(ButtonType.YES); - yesButton.defaultButtonProperty().bind(yesButton.focusedProperty()); - - Button noButton = (Button) alert.getDialogPane().lookupButton(ButtonType.NO); - noButton.defaultButtonProperty().bind(noButton.focusedProperty()); - - Button cancelButton = (Button) alert.getDialogPane().lookupButton(ButtonType.CANCEL); - cancelButton.defaultButtonProperty().bind(cancelButton.focusedProperty()); - - alert.initOwner(getStage()); - alert.initModality(Modality.WINDOW_MODAL); - Stage alertStage = (Stage) alert.getDialogPane().getScene().getWindow(); - PlayPadMain.stageIcon.ifPresent(alertStage.getIcons()::add); - - Optional<ButtonType> result = alert.showAndWait(); - if (result.isPresent()) { - ButtonType buttonType = result.get(); - if (buttonType == ButtonType.YES) { - // Projekt Speichern - try { - if (openProject.getRef() != null) { - openProject.save(); - System.out.println("Saved Project: " + openProject); - } - } catch (Exception e) { - e.printStackTrace(); - showErrorMessage(Localization.getString(Strings.Error_Project_Save)); - } - } else if (buttonType == ButtonType.CANCEL) { - return false; - } - } - - // Save Config - Its unabhängig vom Dialog, da es auch an anderen Stellen schon gespeichert wird - try { - if (Profile.currentProfile() != null) - Profile.currentProfile().save(); - } catch (Exception e) { - e.printStackTrace(); - showErrorMessage(Localization.getString(Strings.Error_Profile_Save)); - } - - // Mapper Clear Feedback - Profile.currentProfile().getMappings().getActiveMapping().clearFeedback(); - - // MIDI Shutdown - // Der schließt MIDI, da er es auch öffnet und verantwortlich ist - if (profilSettings.isMidiActive()) { - try { - midi.close(); - } catch (MidiUnavailableException e1) { - e1.printStackTrace(); - } - } - } - - if (getStage().isIconified()) { - getStage().setIconified(false); - } - - // Verbindung von Pad und PadView wird getrennt. Zudem wird bei PLAY - // oder PAUSE auf STOP gesetzt - removePadsFromView(); - - saveSettings(); - return true; - } - - // project - /** - * Öffnet ein Project. Das akutelle project ist in PlayPadImpl gespeichert. - * - * @param project - * neues Project - */ - public void openProject(Project project) { - removePadsFromView(); - - if (project != null) - removePadsFromView(); - - openProject = project; - - initMapper(project); - - midiHandler.setProject(project); - keyboardHandler.setProject(project); - PadDragListener.setProject(project); - - menuToolbarViewController.setOpenProject(openProject); - - createPadViews(); - showPage(FIRST_PAGE); - loadUserCss(); - updateWindowTitle(); - } - - // Pad, Pages - @Override - public void createPadViews() { - if (openProject == null) { - return; - } - ProjectSettings projectSettings = openProject.getSettings(); - - // Table - padGridPane.getColumnConstraints().clear(); - double xPercentage = 1.0 / (double) projectSettings.getColumns(); - for (int i = 0; i < projectSettings.getColumns(); i++) { - ColumnConstraints c = new ColumnConstraints(); - c.setPercentWidth(xPercentage * 100); - padGridPane.getColumnConstraints().add(c); - } - - padGridPane.getRowConstraints().clear(); - double yPercentage = 1.0 / (double) projectSettings.getRows(); - for (int i = 0; i < projectSettings.getRows(); i++) { - RowConstraints c = new RowConstraints(); - c.setPercentHeight(yPercentage * 100); - padGridPane.getRowConstraints().add(c); - } - - // Pads - Remove alte PadViews, falls noch welche vorhanden - if (!padViews.isEmpty()) - removePadViews(); - - // Neue PadViews - for (int y = 0; y < projectSettings.getRows(); y++) { - for (int x = 0; x < projectSettings.getColumns(); x++) { - IPadViewV2 padView = mainLayout.createPadView(); - padGridPane.add(padView.getRootNode(), x, y); - padViews.add(padView); - } - } - - // Min Size of window - GlobalDesign currentLayout = Profile.currentProfile().currentLayout(); - double minWidth = currentLayout.getMinWidth(projectSettings.getColumns()); - double minHeight = currentLayout.getMinHeight(projectSettings.getRows()); - - getStage().setMinWidth(minWidth); - if (OS.getType() == OSType.MacOSX) { - getStage().setMinHeight(minHeight + 100); - } else { - getStage().setMinHeight(minHeight + 150); - } - - menuToolbarViewController.initPageButtons(); - } - - private void removePadViews() { - padViews.forEach(view -> - { - padGridPane.getChildren().remove(view.getRootNode()); - mainLayout.recyclePadView(view); - }); - padViews.clear(); - } - - /** - * Zeigt die aktuellen Pads von einem Profil zu einer Seite in den entsprechenden Views an. - */ - private void addPadsToView() { - ProjectSettings settings = openProject.getSettings(); - - int index = currentPageShowing * settings.getRows() * settings.getColumns(); - for (int i = 0; i < settings.getRows() * settings.getColumns(); i++) { - if (padViews.size() > i) { - IPadViewV2 view = padViews.get(i); - Pad pad = openProject.getPad(index); - - view.getViewController().setupPad(pad); - } - index++; - } - } - - /** - * Entfernt alle Pads auf den Views. - */ - private void removePadsFromView() { - // Clean old pads - for (IPadViewV2 padView : padViews) { - padView.getViewController().removePad(); - } - } - - @Override - public boolean showPage(int page) { - if (openProject == null) { - return false; - } - ProjectSettings projectSettings = openProject.getSettings(); - - if (page < 0 || page >= projectSettings.getPageCount()) { - return false; - } - - // Clean - removePadsFromView(); - this.currentPageShowing = page; - addPadsToView(); - - if (menuToolbarViewController != null) { - menuToolbarViewController.highlightPageButton(page); - } - return true; - } - - @Override - public int getPage() { - return currentPageShowing; - } - - @Override - public void setGlobalVolume(double volume) { - if (openProject != null) { - for (Pad pad : openProject.getPads().values()) { - if (pad != null) - pad.setMasterVolume(volume); - } - } - } - - private boolean shown = false; - - @Override - public void showLiveInfo() { - if (!shown && menuToolbarViewController != null) { - menuToolbarViewController.showLiveInfo(true); - shown = true; - Worker.runLater(() -> - { - try { - Thread.sleep(PlayPadMain.displayTimeMillis * 2); - } catch (Exception e) {} - Platform.runLater(() -> - { - if (menuToolbarViewController != null) - menuToolbarViewController.showLiveInfo(false); - shown = false; - }); - }); - } - } - - // Settings - @Override - public void reloadSettings(Profile old, Profile currentProfile) { - createPadViews(); - - final DoubleProperty volumeFaderValueProperty = menuToolbarViewController.getVolumeSlider().valueProperty(); - - if (old != null) { - // Unbind Volume Slider - volumeFaderValueProperty.unbindBidirectional(old.getProfileSettings().volumeProperty()); - volumeFaderValueProperty.removeListener(volumeChangeListener); - - // Clear Feedback on Devie (LaunchPad Light off) - old.getMappings().getActiveMapping().getActions().forEach(action -> action.clearFeedback()); - - // LockedListener - old.getProfileSettings().lockedProperty().removeListener(lockedListener); - } - - // Volume - volumeFaderValueProperty.bindBidirectional(currentProfile.getProfileSettings().volumeProperty()); - volumeFaderValueProperty.addListener(volumeChangeListener); - - final ProfileSettings profileSettings = currentProfile.getProfileSettings(); - final Mapping activeMapping = currentProfile.getMappings().getActiveMapping(); - - // LockedListener - profileSettings.lockedProperty().addListener(lockedListener); - - // MIDI - if (profileSettings.isMidiActive() && profileSettings.getMidiDevice() != null) { - // Load known MIDI Device - Worker.runLater(() -> - { - loadMidiDevice(profileSettings.getMidiDevice()); - Profile.currentProfile().getMappings().getActiveMapping().adjustPadColorToMapper(openProject); - - Platform.runLater(() -> - { - // Handle Mapper - if (Profile.currentProfile() != null) { - activeMapping.initFeedback(); - activeMapping.showFeedback(openProject); - } - }); - }); - } - - try { - DefaultRegistry<MainLayoutConnect> registry = PlayPadPlugin.getRegistryCollection().getMainLayouts(); - MainLayoutConnect connect = registry.getComponent(currentProfile.getProfileSettings().getMainLayoutType()); - setMainLayout(connect); - } catch (NoSuchComponentException e) { - // TODO Error Handling - e.printStackTrace(); - } - - loadUserCss(); - if (old != null && currentProfile != null) { - showPage(currentPageShowing); - } - } - - @Override - public void loadKeybinding(KeyCollection keys) { - if (menuToolbarViewController != null) { - menuToolbarViewController.loadKeybinding(keys); - } - } - - @Override - public void setGridColor(Color color) { - this.gridColor = color; - try { - Field field = padGridPane.getClass().getDeclaredField("gridLines"); - field.setAccessible(true); - Group group = (Group) field.get(padGridPane); - if (group != null) { - for (Node node : group.getChildren()) { - if (node instanceof Line) { - ((Line) node).setStroke(gridColor); - } - } - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - // Notification - @Override - public void notify(String text, long duration) { - if (Platform.isFxApplicationThread()) { - notificationPane.showAndHide(text, duration); - } else { - Platform.runLater(() -> notificationPane.showAndHide(text, duration)); - } - } - - @Override - public void notify(String text, long duration, Runnable finish) { - if (Platform.isFxApplicationThread()) { - notificationPane.showAndHide(text, duration, finish); - } else { - Platform.runLater(() -> notificationPane.showAndHide(text, duration, finish)); - } - } - - @Override - public void showError(String message) { - if (Platform.isFxApplicationThread()) { - notificationPane.showError(message); - } else { - Platform.runLater(() -> notificationPane.showError(message)); - } - } - - @Override - public void hide() { - if (Platform.isFxApplicationThread()) { - notificationPane.hide(); - } else { - Platform.runLater(() -> notificationPane.hide()); - } - } - - // Utils - @Override - public void registerKeyboardListener(EventType<KeyEvent> eventType, EventHandler<KeyEvent> listener) { - getParent().getScene().addEventHandler(eventType, listener); - } - - @Override - public void loadUserCss() { - Scene scene = getStage().getScene(); - - // Clear Old - scene.getStylesheets().clear(); - - // Layout Spezifisches CSS (Base) - if (mainLayout.getStylesheet() != null) { - scene.getStylesheets().add(mainLayout.getStylesheet()); - } - - // design spezific css - if (openProject != null) { - Profile.currentProfile().currentLayout().applyCssMainView(this, getStage(), openProject); - } - - Profile.currentProfile().getMappings().getActiveMapping().adjustPadColorToMapper(openProject); - } - - /** - * Init MIDI Device by using the Midi Class and show some feedback the user. - * - * @param name - * Device Name - * - * @see Midi#lookupMidiDevice(String) - */ - private void loadMidiDevice(String name) { - try { - midi.lookupMidiDevice(name); - notificationPane.showAndHide(Localization.getString(Strings.Info_Midi_Device_Connected, name), PlayPadMain.displayTimeMillis); - } catch (NullPointerException e) { - showError(Localization.getString(Strings.Error_Midi_Device_Unavailible, name)); - } catch (IllegalArgumentException | MidiUnavailableException e) { - showError(Localization.getString(Strings.Error_Midi_Device_Busy, e.getLocalizedMessage())); - e.printStackTrace(); - } - } - - public void updateWindowTitle() { - if (openProject != null && Profile.currentProfile() != null) { - getStage().setTitle(Localization.getString(Strings.UI_Window_Main_Title, openProject.getRef().getName(), - Profile.currentProfile().getRef().getName())); - } else { - getStage().setTitle(Localization.getString(Strings.UI_Window_Main_Title)); - } - } - - @Override - public List<IPadViewV2> getPadViews() { - return padViews; - } - - @Override - public MidiListener getMidiHandler() { - return midiHandler; - } - - @Override - public MenuToolbarViewController getMenuToolbarController() { - return menuToolbarViewController; - } - - @Override - public void performLayoutDependendAction(MainLayoutHandler runnable) { - runnable.handle(null, menuToolbarViewController); - layoutActions.add(runnable); - } - - @Override - public NotificationPane getNotificationPane() { - return notificationPane; - } -} diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/mapper/MidiMapperViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/mapper/MidiMapperViewController.java index 126dc8164e89e64ef7937a0d5145827f208af573..52d5caca51388b4f65b9ec92f0622ee4da70e479 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/mapper/MidiMapperViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/mapper/MidiMapperViewController.java @@ -80,7 +80,7 @@ public class MidiMapperViewController extends MapperViewController implements Mi @FXML private void midiInputRecordButtonHandler(ActionEvent event) { canceled = false; - + currentListener = Midi.getInstance().getListener(); Midi.getInstance().setListener(this); @@ -124,7 +124,7 @@ public class MidiMapperViewController extends MapperViewController implements Mi @Override public boolean showInputMapperUI() { midiInputRecordButtonHandler(null); - return canceled; // TEST Ob das funktioniert mit dem Return + return !canceled; } public void setMapper(MidiMapper midiMapper) { 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..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,17 +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; @@ -37,6 +47,7 @@ public class GlobalSettingsViewController extends ViewController implements IGlo getStage().initOwner(owner); + addTab(new GeneralTabViewController(this)); addTab(new KeysTabViewController()); addTab(new UpdateTabViewController()); @@ -118,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/KeysConflictDialog.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/global/KeysConflictDialog.java new file mode 100644 index 0000000000000000000000000000000000000000..c0df4125f1f51dfd7c8215b511526f33b1883254 --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/global/KeysConflictDialog.java @@ -0,0 +1,33 @@ +package de.tobias.playpad.viewcontroller.option.global; + +import java.util.List; + +import de.tobias.playpad.PlayPadMain; +import de.tobias.playpad.Strings; +import de.tobias.playpad.settings.keys.Key; +import de.tobias.playpad.settings.keys.KeyCollection; +import de.tobias.utils.util.Localization; +import javafx.scene.control.Alert; +import javafx.stage.Modality; +import javafx.stage.Stage; + +public class KeysConflictDialog extends Alert { + + public KeysConflictDialog(List<Key> conflicts, KeyCollection collection) { + super(AlertType.ERROR); + + String keys = ""; + for (int i = 0; i < conflicts.size(); i++) { + keys += "- " + collection.getName(conflicts.get(i).getId()); + if (i + 1 < conflicts.size()) { + keys += "\n"; + } + } + setHeaderText(Localization.getString(Strings.UI_Settings_Keys_Conflict_Header)); + setContentText(Localization.getString(Strings.UI_Settings_Keys_Conflict_Content, keys)); + + Stage dialogStage = (Stage) getDialogPane().getScene().getWindow(); + PlayPadMain.stageIcon.ifPresent(dialogStage.getIcons()::add); + initModality(Modality.WINDOW_MODAL); + } +} 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..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,11 +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; @@ -15,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; @@ -28,9 +30,10 @@ import javafx.scene.control.TableRow; import javafx.scene.control.TableView; import javafx.scene.control.TextField; 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; @@ -134,20 +137,27 @@ public class KeysTabViewController extends GlobalSettingsTabViewController { Key newKey = new Key(currentKey.getId(), key, ev.isControlDown(), ev.isAltDown(), ev.isMetaDown(), ev.isShiftDown()); GlobalSettings globalSettings = PlayPadPlugin.getImplementation().getGlobalSettings(); - boolean conflict = globalSettings.getKeyCollection().keysConflict(newKey); + KeyCollection keyCollection = globalSettings.getKeyCollection(); + + boolean conflict = keyCollection.keysConflict(newKey); if (!conflict) { - globalSettings.getKeyCollection().editKey(newKey); + keyCollection.editKey(newKey); shortcutLabel.setText(currentKey.toString()); Platform.runLater(() -> ((Stage) scene.getWindow()).close()); } else { - showErrorMessage("Konflikt"); // TODO Localize + KeysConflictDialog dialog = new KeysConflictDialog(keyCollection.getConflicts(newKey), keyCollection); + dialog.initOwner(getStage()); + dialog.showAndWait(); } } }); alert.getButtonTypes().add(ButtonType.CANCEL); alert.initOwner(getWindow()); + alert.initModality(Modality.WINDOW_MODAL); + Stage alertStage = (Stage) alert.getDialogPane().getScene().getWindow(); + PlayPadMain.stageIcon.ifPresent(alertStage.getIcons()::add); alert.showAndWait(); } @@ -168,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 @@ -179,8 +198,7 @@ public class KeysTabViewController extends GlobalSettingsTabViewController { @Override public String name() { - // TODO Auto-generated method stub - return "Keyboard (I18N)"; + return Localization.getString(Strings.UI_Window_Settings_Keys_Title); } private void search() { diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/global/UpdateTabViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/global/UpdateTabViewController.java index d457d9475fb51e867940fb3a8729824ae1603cf9..bc7aeddd7ec4750cb9aae7cd1b5ec6614a03a483 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/global/UpdateTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/global/UpdateTabViewController.java @@ -120,6 +120,9 @@ public class UpdateTabViewController extends GlobalSettingsTabViewController { UpdaterDialog dialog = new UpdaterDialog(getStage()); dialog.show(); + GlobalSettings settings = PlayPadPlugin.getImplementation().getGlobalSettings(); + settings.setIgnoreUpdate(false); + Worker.runLater(() -> { try { diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/PadSettingsViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/PadSettingsViewController.java index e599ddc3be389da33591e968d1859fc083ef117e..468c689d0beae454669725b3c0e072e37c87c4a1 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/PadSettingsViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/PadSettingsViewController.java @@ -86,7 +86,7 @@ public class PadSettingsViewController extends ViewController implements IPadSet PadContent content = pad.getContent(); // nur EIN Path if (content instanceof SinglePathContent) { - Button button = new Button("Show Path"); + Button button = new Button(PlayPadMain.getUiResourceBundle().getString("padSettings.button.path")); // Referenz auf das Model Path path = ((SinglePathContent) content).getPath(); @@ -97,7 +97,7 @@ public class PadSettingsViewController extends ViewController implements IPadSet // Setzt globales Feld pathLookupButton = button; } else if (content instanceof MultiPathContent) { - MenuButton button = new MenuButton(PlayPadMain.getUiResourceBundle().getString("")); + MenuButton button = new MenuButton(PlayPadMain.getUiResourceBundle().getString("padSettings.button.path")); List<Path> paths = ((MultiPathContent) content).getPaths(); for (Path path : paths) { diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/PathLookupListener.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/PathLookupListener.java index 30e00be88e57f2d9d04b64eb7cd07bb41c6dd3b0..c397e4e397e471a2bd578e654599b4d6f901cdd0 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/PathLookupListener.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/PathLookupListener.java @@ -42,7 +42,8 @@ public class PathLookupListener implements EventHandler<ActionEvent> { try { Desktop.getDesktop().browse(path.getParent().toUri()); } catch (IOException e) { - alertable.showErrorMessage(Localization.getString(Strings.Error_Standard_Gen), PlayPadPlugin.getImplementation().getIcon()); + String string = Localization.getString(Strings.Error_Standard_Gen, e.getMessage()); + alertable.showErrorMessage(string, PlayPadPlugin.getImplementation().getIcon()); e.printStackTrace(); } } 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..e83f9a002ea0c3e33e757e3d006526d0b062a5b4 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/AudioTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/AudioTabViewController.java @@ -8,21 +8,22 @@ 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.AudioTypeViewController; +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; @FXML private AnchorPane audioUserInfoSettings; - private AudioTypeViewController audioViewController; + private AudioHandlerViewController audioViewController; private boolean changeAudioSettings; public AudioTabViewController(boolean playerActive) { @@ -63,7 +64,7 @@ public class AudioTabViewController extends ProfileSettingsTabViewController { try { AudioRegistry audioHandlerRegistry = PlayPadPlugin.getRegistryCollection().getAudioHandlers(); - audioViewController = audioHandlerRegistry.getComponent(classID).getAudioViewController(); + audioViewController = audioHandlerRegistry.getComponent(classID).getAudioHandlerSettingsViewController(); if (audioViewController != null) { audioUserInfoSettings.getChildren().add(audioViewController.getParent()); @@ -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/GeneralTabViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/GeneralTabViewController.java index ee87703044bfdd6fdef7ae6c52e638a24f0a42cc..406d947c691833217248ecd7e64f507ec7658425 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/GeneralTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/GeneralTabViewController.java @@ -2,15 +2,16 @@ package de.tobias.playpad.viewcontroller.option.profile; import java.io.File; import java.io.IOException; +import java.nio.file.DirectoryStream; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import de.tobias.playpad.PlayPadMain; +import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.Strings; -import de.tobias.playpad.settings.Profile; -import de.tobias.playpad.settings.ProfileSettings; -import de.tobias.playpad.viewcontroller.option.ProfileSettingsTabViewController; +import de.tobias.playpad.settings.GlobalSettings; +import de.tobias.playpad.viewcontroller.option.GlobalSettingsTabViewController; import de.tobias.utils.application.ApplicationUtils; import de.tobias.utils.application.container.PathType; import de.tobias.utils.ui.Alertable; @@ -25,7 +26,7 @@ import javafx.scene.control.TextField; import javafx.scene.control.ToggleGroup; import javafx.stage.DirectoryChooser; -public class GeneralTabViewController extends ProfileSettingsTabViewController { +public class GeneralTabViewController extends GlobalSettingsTabViewController { @FXML private CheckBox liveModeCheckBox; @@ -50,7 +51,7 @@ public class GeneralTabViewController extends ProfileSettingsTabViewController { private Alertable alertable; public GeneralTabViewController(Alertable alertable) { - super("generalTab", "de/tobias/playpad/assets/view/option/profile/", PlayPadMain.getUiResourceBundle()); + super("generalTab", "de/tobias/playpad/assets/view/option/global/", PlayPadMain.getUiResourceBundle()); this.alertable = alertable; calcCacheSize(); @@ -90,7 +91,8 @@ public class GeneralTabViewController extends ProfileSettingsTabViewController { File folder = chooser.showDialog(getStage()); if (folder != null) { Path folderPath = folder.toPath(); - Profile.currentProfile().getProfileSettings().setCachePath(folderPath); + GlobalSettings globalSettings = PlayPadPlugin.getImplementation().getGlobalSettings(); + globalSettings.setCachePath(folderPath); cacheTextField.setText(folderPath.toString()); } } @@ -126,13 +128,16 @@ public class GeneralTabViewController extends ProfileSettingsTabViewController { private void calcCacheSize() { try { double size = 0; - Path path = Profile.currentProfile().getProfileSettings().getCachePath(); + GlobalSettings globalSettings = PlayPadPlugin.getImplementation().getGlobalSettings(); + Path path = globalSettings.getCachePath(); if (Files.notExists(path)) Files.createDirectories(path); - for (Path item : Files.newDirectoryStream(Profile.currentProfile().getProfileSettings().getCachePath())) { + DirectoryStream<Path> directoryStream = Files.newDirectoryStream(globalSettings.getCachePath()); + for (Path item : directoryStream) { size += Files.size(item); } + directoryStream.close(); cacheSizeLabel.setText(Localization.getString(Strings.UI_Window_Settings_Gen_CacheSize, NumberUtils.numberToString(size))); } catch (IOException e) { e.printStackTrace(); @@ -141,46 +146,43 @@ public class GeneralTabViewController extends ProfileSettingsTabViewController { } @Override - public void loadSettings(Profile profile) { - ProfileSettings profileSettings = profile.getProfileSettings(); + public void loadSettings(GlobalSettings settings) { - liveModeCheckBox.setSelected(profileSettings.isLiveMode()); - cacheTextField.setText(profileSettings.getCachePath().toString()); + liveModeCheckBox.setSelected(settings.isLiveMode()); + cacheTextField.setText(settings.getCachePath().toString()); - if (profileSettings.isLiveModePage() == true) + if (settings.isLiveModePage() == true) pageEnable.setSelected(true); else pageDisable.setSelected(true); - if (profileSettings.isLiveModeDrag() == true) + if (settings.isLiveModeDrag() == true) dragEnable.setSelected(true); else dragDisable.setSelected(true); - if (profileSettings.isLiveModeFile() == true) + if (settings.isLiveModeFile() == true) fileEnable.setSelected(true); else fileDisable.setSelected(true); - if (profileSettings.isLiveModeSettings() == true) + if (settings.isLiveModeSettings() == true) settingsEnable.setSelected(true); else settingsDisable.setSelected(true); - disableLiveSettings(profileSettings.isLiveMode()); + disableLiveSettings(settings.isLiveMode()); } @Override - public void saveSettings(Profile profile) { - ProfileSettings profileSettings = profile.getProfileSettings(); - - profileSettings.setLiveMode(liveModeCheckBox.isSelected()); - profileSettings.setCachePath(Paths.get(cacheTextField.getText())); - - profileSettings.setLiveModePage(pageEnable.isSelected()); - profileSettings.setLiveModeDrag(dragEnable.isSelected()); - profileSettings.setLiveModeFile(fileEnable.isSelected()); - profileSettings.setLiveModeSettings(settingsEnable.isSelected()); + public void saveSettings(GlobalSettings settings) { + settings.setLiveMode(liveModeCheckBox.isSelected()); + settings.setCachePath(Paths.get(cacheTextField.getText())); + + settings.setLiveModePage(pageEnable.isSelected()); + settings.setLiveModeDrag(dragEnable.isSelected()); + settings.setLiveModeFile(fileEnable.isSelected()); + settings.setLiveModeSettings(settingsEnable.isSelected()); } @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..5d37af62d3c566b6d4f338ed640dc0eb79ddcc04 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; @@ -42,9 +50,8 @@ public class ProfileSettingsViewController extends ViewController implements IPr super("settingsView", "de/tobias/playpad/assets/view/option/profile/", null, PlayPadMain.getUiResourceBundle()); this.onFinish = onFinish; - boolean activePlayer = project.hasPlayedPlayers(); + boolean activePlayer = project.hasActivePlayers(); - addTab(new GeneralTabViewController(this)); addTab(new MappingTabViewController()); addTab(new MidiTabViewController()); addTab(new DesignTabViewController()); @@ -159,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..551b2d4cba545afd719ada399446cf3d4b94edae --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/PathsTabViewController.java @@ -0,0 +1,174 @@ +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 | 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..6d284bb6d5a013c3a4bdb4fac3ff82cc37c8de99 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(); + boolean activePlayer = project.hasActivePlayers(); addTab(new GeneralTabViewController(currentScreen, this, activePlayer)); + addTab(new PathsTabViewController()); + + getStage().initOwner(owner); // Show Current Settings - loadTabs(settings); + loadTabs(project.getSettings()); } @Override @@ -60,8 +70,8 @@ public class ProjectSettingsViewController extends ViewController implements IPr PlayPadMain.stageIcon.ifPresent(stage.getIcons()::add); stage.setMinWidth(715); - stage.setMinHeight(700); - stage.setTitle(Localization.getString(Strings.UI_Window_GlobalSettings_Title)); + stage.setMinHeight(500); + stage.setTitle(Localization.getString(Strings.UI_Window_ProjectSettings_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 2c86eb3ae252bdddaba728b9d7eb2fb6e32acfb3..abbbf607050a5f6e31bef72c3a5fabdffb387c21 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; @@ -10,11 +11,11 @@ import de.tobias.playpad.pad.PadContentRegistry; import de.tobias.playpad.pad.conntent.PadContent; import de.tobias.playpad.pad.conntent.PadContentConnect; import de.tobias.playpad.pad.drag.PadDragMode; -import de.tobias.playpad.pad.view.IPadViewV2; +import de.tobias.playpad.pad.view.IPadView; import de.tobias.playpad.project.Project; import de.tobias.playpad.registry.NoSuchComponentException; +import de.tobias.playpad.settings.GlobalSettings; import de.tobias.playpad.settings.Profile; -import de.tobias.playpad.settings.ProfileSettings; import de.tobias.playpad.view.FileDragOptionView; import de.tobias.playpad.view.PadDragOptionView; import de.tobias.utils.util.FileUtils; @@ -40,7 +41,7 @@ public class PadDragListener { private PadDragOptionView padHud; private FileDragOptionView fileHud; - public PadDragListener(Pad pad, IPadViewV2 view) { + public PadDragListener(Pad pad, IPadView view) { this.sourcePad = pad; this.view = view.getRootNode(); @@ -58,10 +59,11 @@ public class PadDragListener { if (event.getGestureSource() != this && event.getDragboard().hasFiles()) { if (event.getDragboard().getFiles().get(0).isFile()) { - ProfileSettings settings = Profile.currentProfile().getProfileSettings(); + + GlobalSettings globalSettings = PlayPadPlugin.getImplementation().getGlobalSettings(); + if (sourcePad.getProject() != null) { - if (settings.isLiveMode() && settings.isLiveModeFile() && sourcePad.getProject().getPlayedPlayers() > 0) { - PlayPadPlugin.getImplementation().getMainViewController().showLiveInfo(); + if (globalSettings.isLiveMode() && globalSettings.isLiveModeFile() && sourcePad.getProject().getActivePlayers() > 0) { return; } } @@ -133,7 +135,7 @@ public class PadDragListener { try { content.handlePath(file.toPath()); - } catch (NoSuchComponentException e) { + } catch (NoSuchComponentException | IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } @@ -141,7 +143,7 @@ public class PadDragListener { this.sourcePad.setName(FileUtils.getFilenameWithoutExtention(file.toPath().getFileName())); if (sourcePad.getController() != null) { - IPadViewV2 padView = sourcePad.getController().getView(); + IPadView padView = sourcePad.getController().getView(); padView.setContentView(sourcePad); padView.addDefaultElement(sourcePad); } @@ -165,10 +167,10 @@ public class PadDragListener { private void dragDetacted(MouseEvent event) { if (dndMode) { - ProfileSettings settings = Profile.currentProfile().getProfileSettings(); + GlobalSettings globalSettings = PlayPadPlugin.getImplementation().getGlobalSettings(); + if (sourcePad.getProject() != null) { - if (settings.isLiveMode() && settings.isLiveModeDrag() && sourcePad.getProject().getPlayedPlayers() > 0) { - PlayPadPlugin.getImplementation().getMainViewController().showLiveInfo(); + if (globalSettings.isLiveMode() && globalSettings.isLiveModeDrag() && sourcePad.getProject().getActivePlayers() > 0) { return; } } diff --git a/PlayWallCore/src/de/tobias/playpad/Updatable.java b/PlayWallCore/src/de/tobias/playpad/Updatable.java index ed92769831efcf8816e8202cc6d0384ab0dec2e5..8d3b80e9f9bc64c26dd4b5d711ec78e30884304b 100644 --- a/PlayWallCore/src/de/tobias/playpad/Updatable.java +++ b/PlayWallCore/src/de/tobias/playpad/Updatable.java @@ -11,6 +11,8 @@ import java.nio.file.Path; * * @since 5.0.0 */ + +@Deprecated public interface Updatable { /** diff --git a/PlayWallCore/src/de/tobias/playpad/action/Mapping.java b/PlayWallCore/src/de/tobias/playpad/action/Mapping.java index c1292c49ffa5d34cc8630e73225d97ba9b0defea..434731682345ce9d284b5199e0a180e1f16e7385 100644 --- a/PlayWallCore/src/de/tobias/playpad/action/Mapping.java +++ b/PlayWallCore/src/de/tobias/playpad/action/Mapping.java @@ -13,7 +13,6 @@ import de.tobias.playpad.action.mapper.Mapper; import de.tobias.playpad.action.mapper.MapperConnect; import de.tobias.playpad.action.mapper.MapperConnectFeedbackable; import de.tobias.playpad.project.Project; -import de.tobias.playpad.registry.NoSuchComponentException; import de.tobias.playpad.registry.Registry; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.viewcontroller.main.IMainViewController; @@ -112,13 +111,8 @@ public class Mapping implements Cloneable, ActionDisplayable { public void initActionType(Profile profile) { Registry<ActionConnect> actions = PlayPadPlugin.getRegistryCollection().getActions(); - for (String type : actions.getTypes()) { - try { - actions.getComponent(type).initActionType(this, profile); // TODO - } catch (NoSuchComponentException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + for (ActionConnect component : actions.getComponents()) { + component.initActionType(this, profile); } } @@ -131,16 +125,10 @@ public class Mapping implements Cloneable, ActionDisplayable { } public void initFeedback() { - Registry<MapperConnect> mappers = PlayPadPlugin.getRegistryCollection().getMappers(); - for (String mapperType : mappers.getTypes()) { - try { - MapperConnect mapper = mappers.getComponent(mapperType); - if (mapper instanceof MapperConnectFeedbackable) { - ((MapperConnectFeedbackable) mapper).initFeedbackType(); - } - } catch (NoSuchComponentException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + Registry<MapperConnect> registry = PlayPadPlugin.getRegistryCollection().getMappers(); + for (MapperConnect mapper : registry.getComponents()) { + if (mapper instanceof MapperConnectFeedbackable) { + ((MapperConnectFeedbackable) mapper).initFeedbackType(); } } } @@ -163,18 +151,13 @@ public class Mapping implements Cloneable, ActionDisplayable { } public void clearFeedback() { - Registry<MapperConnect> mappers = PlayPadPlugin.getRegistryCollection().getMappers(); - for (String mapperType : mappers.getTypes()) { - try { - MapperConnect mapper = mappers.getComponent(mapperType); - if (mapper instanceof MapperConnectFeedbackable) { - ((MapperConnectFeedbackable) mapper).clearFeedbackType(); - } - } catch (NoSuchComponentException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + Registry<MapperConnect> registry = PlayPadPlugin.getRegistryCollection().getMappers(); + for (MapperConnect mapper : registry.getComponents()) { + if (mapper instanceof MapperConnectFeedbackable) { + ((MapperConnectFeedbackable) mapper).clearFeedbackType(); } } + getActions().forEach(action -> action.clearFeedback()); } diff --git a/PlayWallCore/src/de/tobias/playpad/audio/AudioHandler.java b/PlayWallCore/src/de/tobias/playpad/audio/AudioHandler.java index 7b0f8aeb949969c2f0e3cb0bbd04cca3faa5e570..dee8a0e13d6a7268720ec5a9c093099a4c2e4ab9 100644 --- a/PlayWallCore/src/de/tobias/playpad/audio/AudioHandler.java +++ b/PlayWallCore/src/de/tobias/playpad/audio/AudioHandler.java @@ -13,7 +13,6 @@ public abstract class AudioHandler { private PadContent content; public AudioHandler(PadContent content) { - super(); this.content = content; } diff --git a/PlayWallCore/src/de/tobias/playpad/audio/AudioHandlerConnect.java b/PlayWallCore/src/de/tobias/playpad/audio/AudioHandlerConnect.java index 5a35082ebab80875af6b917782db1239ebb861a6..0d280a36ffd3d4af4f52975cd8cf2f4c1c577c85 100644 --- a/PlayWallCore/src/de/tobias/playpad/audio/AudioHandlerConnect.java +++ b/PlayWallCore/src/de/tobias/playpad/audio/AudioHandlerConnect.java @@ -1,12 +1,38 @@ package de.tobias.playpad.audio; import de.tobias.playpad.pad.conntent.PadContent; -import de.tobias.playpad.viewcontroller.AudioTypeViewController; +import de.tobias.playpad.viewcontroller.AudioHandlerViewController; +/** + * Audio Handler Interface zur Verwaltung einer AudioHandler Implementierung. Für Aktionen beim schließen des + * Programmes, muss der AudioHandler AutoClosable implementieren. + * + * @author tobias + * + * @since 5.0.0 + */ public abstract class AudioHandlerConnect { + /** + * Erstellt für eine Kachel ein neunes AudioInterface + * + * @param content + * Content des Pads + * @return AudioHandler + */ public abstract AudioHandler createAudioHandler(PadContent content); - public abstract AudioTypeViewController getAudioViewController(); + /** + * Gibt den Settings View Controller für die Audio Schnittstelle zurück.s + * + * @return neuer ViewContoller + */ + public abstract AudioHandlerViewController getAudioHandlerSettingsViewController(); + /** + * Gibt den Type des AudioHandlers zurück. + * + * @return Type + */ + public abstract String getType(); } diff --git a/PlayWallCore/src/de/tobias/playpad/audio/AudioRegistry.java b/PlayWallCore/src/de/tobias/playpad/audio/AudioRegistry.java index 9247dfa9cdc523d6462d14e6218ba0467318200f..bb44d27af8784edf2e56d18dc88e87265644501b 100644 --- a/PlayWallCore/src/de/tobias/playpad/audio/AudioRegistry.java +++ b/PlayWallCore/src/de/tobias/playpad/audio/AudioRegistry.java @@ -10,7 +10,11 @@ public class AudioRegistry extends DefaultComponentRegistry<AudioHandlerConnect> super("Audio Handler"); } - public AudioHandlerConnect getCurrentAudioHandler() throws NoSuchComponentException { - return getComponent(Profile.currentProfile().getProfileSettings().getAudioClass()); + public AudioHandlerConnect getCurrentAudioHandler() { + try { + return getComponent(Profile.currentProfile().getProfileSettings().getAudioClass()); + } catch (NoSuchComponentException e) { + return getDefault(); + } } } diff --git a/PlayWallCore/src/de/tobias/playpad/design/CartDesign.java b/PlayWallCore/src/de/tobias/playpad/design/CartDesign.java index 0e9027f1986d948e18707d25d41882387ee27393..12d6f3a81c062d1bfc85fa226e8800cd59306396 100644 --- a/PlayWallCore/src/de/tobias/playpad/design/CartDesign.java +++ b/PlayWallCore/src/de/tobias/playpad/design/CartDesign.java @@ -2,7 +2,7 @@ package de.tobias.playpad.design; import org.dom4j.Element; -import de.tobias.playpad.pad.viewcontroller.IPadViewControllerV2; +import de.tobias.playpad.pad.viewcontroller.IPadViewController; import de.tobias.playpad.settings.Warning; public interface CartDesign { @@ -22,9 +22,9 @@ public interface CartDesign { /* * Wird in einem neuen Thread aufgerufen */ - public abstract void handleWarning(IPadViewControllerV2 controller, Warning warning, GlobalDesign animate); + public abstract void handleWarning(IPadViewController controller, Warning warning, GlobalDesign animate); - public default void stopWarning(IPadViewControllerV2 controller) {} + public default void stopWarning(IPadViewController controller) {} public void reset(); diff --git a/PlayWallCore/src/de/tobias/playpad/design/GlobalDesign.java b/PlayWallCore/src/de/tobias/playpad/design/GlobalDesign.java index 8936f501e0897706b5e7cb40e41dbc323c4f5b8e..de0fe92c4eed206e06e9191ff8feb511f58a134e 100644 --- a/PlayWallCore/src/de/tobias/playpad/design/GlobalDesign.java +++ b/PlayWallCore/src/de/tobias/playpad/design/GlobalDesign.java @@ -15,7 +15,7 @@ import org.dom4j.io.SAXReader; import org.dom4j.io.XMLWriter; import de.tobias.playpad.PlayPadPlugin; -import de.tobias.playpad.pad.viewcontroller.IPadViewControllerV2; +import de.tobias.playpad.pad.viewcontroller.IPadViewController; import de.tobias.playpad.project.Project; import de.tobias.playpad.registry.DefaultRegistry; import de.tobias.playpad.registry.NoSuchComponentException; @@ -50,9 +50,9 @@ public interface GlobalDesign { /* * Wird in einem neuen Thread aufgerufen */ - public void handleWarning(IPadViewControllerV2 controller, Warning warning); + public void handleWarning(IPadViewController controller, Warning warning); - public default void stopWarning(IPadViewControllerV2 controller) {} + public default void stopWarning(IPadViewController controller) {} public void reset(); diff --git a/PlayWallCore/src/de/tobias/playpad/pad/Pad.java b/PlayWallCore/src/de/tobias/playpad/pad/Pad.java index 06cb57b8ae656c046100a24aced0b592c3315dd5..33993d3376e81ec3c9febde2ab568e1732b7496f 100644 --- a/PlayWallCore/src/de/tobias/playpad/pad/Pad.java +++ b/PlayWallCore/src/de/tobias/playpad/pad/Pad.java @@ -7,7 +7,7 @@ import de.tobias.playpad.pad.conntent.play.Pauseable; import de.tobias.playpad.pad.listener.trigger.PadTriggerContentListener; import de.tobias.playpad.pad.listener.trigger.PadTriggerDurationListener; import de.tobias.playpad.pad.listener.trigger.PadTriggerStatusListener; -import de.tobias.playpad.pad.viewcontroller.IPadViewControllerV2; +import de.tobias.playpad.pad.viewcontroller.IPadViewController; import de.tobias.playpad.project.Project; import de.tobias.playpad.registry.NoSuchComponentException; import javafx.beans.property.DoubleProperty; @@ -47,7 +47,7 @@ public class Pad { // Utils private transient boolean eof; - private transient IPadViewControllerV2 controller; + private transient IPadViewController controller; private transient Project project; public Pad(Project project) { @@ -223,11 +223,11 @@ public class Pad { return controller != null; } - public IPadViewControllerV2 getController() { + public IPadViewController getController() { return controller; } - public void setController(IPadViewControllerV2 controller) { + public void setController(IPadViewController controller) { this.controller = controller; } diff --git a/PlayWallCore/src/de/tobias/playpad/pad/PadSerializer.java b/PlayWallCore/src/de/tobias/playpad/pad/PadSerializer.java index 44b42cd8190563ed3ba1685112cbb0d0dd90afbb..b17681ae4f70b0f907b8c84b34dc113d70f3658f 100644 --- a/PlayWallCore/src/de/tobias/playpad/pad/PadSerializer.java +++ b/PlayWallCore/src/de/tobias/playpad/pad/PadSerializer.java @@ -166,11 +166,11 @@ public class PadSerializer implements XMLSerializer<Pad>, XMLDeserializer<Pad> { settingsElement.addElement(VOLUME_ELEMENT).addText(String.valueOf(padSettings.getVolume())); settingsElement.addElement(LOOP_ELEMENT).addText(String.valueOf(padSettings.isLoop())); - if (padSettings.getTimeMode() != null) + if (padSettings.isCustomTimeMode()) settingsElement.addElement(TIMEMODE_ELEMENT).addText(String.valueOf(padSettings.getTimeMode())); - if (padSettings.isCustomWarning() != false) + if (padSettings.isCustomWarning()) padSettings.getWarning().save(settingsElement.addElement(WARNING_ELEMENT)); - if (padSettings.getFade() != null) + if (padSettings.isCustomFade()) padSettings.getFade().save(settingsElement.addElement(FADE_ELEMENT)); // Layout diff --git a/PlayWallCore/src/de/tobias/playpad/pad/PadStatusListener.java b/PlayWallCore/src/de/tobias/playpad/pad/PadStatusListener.java index f5ba2d87b1daa75260b4ff1ada33466082ec8f06..4b35b1dda9738148de908b7ea9e990a397337d82 100644 --- a/PlayWallCore/src/de/tobias/playpad/pad/PadStatusListener.java +++ b/PlayWallCore/src/de/tobias/playpad/pad/PadStatusListener.java @@ -27,10 +27,11 @@ public class PadStatusListener implements ChangeListener<PadStatus> { if (newValue == PadStatus.PLAY) { if (pad.getContent() != null) { PlayPadPlugin.getImplementation().getPadListener().forEach(listener -> listener.onPlay(pad)); + pad.getProject().increaseActivePlayers(); // bei Single Pad Playing wird das alte Pad beendet. if (!profileSettings.isMultiplePlayer()) { - if (currentPlayingPad != null) { + if (currentPlayingPad != null && currentPlayingPad != pad) { if (currentPlayingPad.getStatus() == PadStatus.PLAY || currentPlayingPad.getStatus() == PadStatus.PAUSE) { currentPlayingPad.setStatus(PadStatus.STOP); } @@ -61,6 +62,7 @@ public class PadStatusListener implements ChangeListener<PadStatus> { } else if (newValue == PadStatus.STOP) { if (pad.getContent() != null) { PlayPadPlugin.getImplementation().getPadListener().forEach(listener -> listener.onStop(pad)); + pad.getProject().dereaseActivePlayers(); if (pad.getContent() instanceof Fadeable && !pad.isEof() && padSettings.getFade().isFadeOutStop()) { // Fade nur wenn Pad // nicht am ende ist diff --git a/PlayWallCore/src/de/tobias/playpad/pad/conntent/PadContent.java b/PlayWallCore/src/de/tobias/playpad/pad/conntent/PadContent.java index 5e8df0ee7a58a6c0beb59751d29896c069b57a64..d54338010dd6d7fbfbfff67f804816004e186d3f 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; @@ -44,16 +48,15 @@ public abstract class PadContent { * path * @throws NoSuchComponentException * 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 */ - public abstract void loadMedia() throws NoSuchComponentException; + public abstract void loadMedia(); /** * Entfernt die Medien aus dem Speicher (lässt diese aber im Pad). @@ -86,4 +89,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/pad/view/IPadViewV2.java b/PlayWallCore/src/de/tobias/playpad/pad/view/IPadView.java similarity index 94% rename from PlayWallCore/src/de/tobias/playpad/pad/view/IPadViewV2.java rename to PlayWallCore/src/de/tobias/playpad/pad/view/IPadView.java index db3369ebf25d267a6899d7374e3d0247227c5acf..67c3ce99cb1b6a3956df92cea0d6a50783f68d39 100644 --- a/PlayWallCore/src/de/tobias/playpad/pad/view/IPadViewV2.java +++ b/PlayWallCore/src/de/tobias/playpad/pad/view/IPadView.java @@ -1,7 +1,7 @@ package de.tobias.playpad.pad.view; import de.tobias.playpad.pad.Pad; -import de.tobias.playpad.pad.viewcontroller.IPadViewControllerV2; +import de.tobias.playpad.pad.viewcontroller.IPadViewController; import javafx.css.PseudoClass; import javafx.scene.layout.Pane; @@ -13,7 +13,7 @@ import javafx.scene.layout.Pane; * @since 5.1.0 * */ -public interface IPadViewV2 { +public interface IPadView { /** * Gibt die aktuelle Vorschau für den Content eines Pads zurück. @@ -35,7 +35,7 @@ public interface IPadViewV2 { * * @return ViewController des Pad */ - public IPadViewControllerV2 getViewController(); + public IPadViewController getViewController(); /** * Gibt das oberste GUI Element zurück, welche im MainView verwendet wird. diff --git a/PlayWallCore/src/de/tobias/playpad/pad/view/IPadViewController.java b/PlayWallCore/src/de/tobias/playpad/pad/view/IPadViewController.java deleted file mode 100644 index 67eff6bce7fdbb36b3bff26af2509227c5d72958..0000000000000000000000000000000000000000 --- a/PlayWallCore/src/de/tobias/playpad/pad/view/IPadViewController.java +++ /dev/null @@ -1,20 +0,0 @@ -package de.tobias.playpad.pad.view; - -import de.tobias.playpad.pad.Pad; -import de.tobias.playpad.viewcontroller.IPadView; - -@Deprecated -public interface IPadViewController { - - public IPadView getParent(); - - public Pad getPad(); - - public void setPad(Pad pad); - - public void connectPad(); - - public void unconnectPad(); - - public void showDnDLayout(boolean b); -} diff --git a/PlayWallCore/src/de/tobias/playpad/pad/viewcontroller/IPadViewControllerV2.java b/PlayWallCore/src/de/tobias/playpad/pad/viewcontroller/IPadViewController.java similarity index 89% rename from PlayWallCore/src/de/tobias/playpad/pad/viewcontroller/IPadViewControllerV2.java rename to PlayWallCore/src/de/tobias/playpad/pad/viewcontroller/IPadViewController.java index ff96e4628045cba6fb7d324f88b29bc46b45168b..563272c8cec50647a64cb38fb109744f09395687 100644 --- a/PlayWallCore/src/de/tobias/playpad/pad/viewcontroller/IPadViewControllerV2.java +++ b/PlayWallCore/src/de/tobias/playpad/pad/viewcontroller/IPadViewController.java @@ -2,7 +2,7 @@ package de.tobias.playpad.pad.viewcontroller; import de.tobias.playpad.pad.Pad; import de.tobias.playpad.pad.listener.IPadPositionListener; -import de.tobias.playpad.pad.view.IPadViewV2; +import de.tobias.playpad.pad.view.IPadView; import javafx.beans.value.ChangeListener; import javafx.util.Duration; @@ -13,7 +13,7 @@ import javafx.util.Duration; * * @since 5.1.0 */ -public interface IPadViewControllerV2 { +public interface IPadViewController { /** * Gibt das Pad zurück, welches er verwaltet. (Das Datenmodel) @@ -27,7 +27,7 @@ public interface IPadViewControllerV2 { * * @return View */ - public IPadViewV2 getView(); + public IPadView getView(); /** * Setzt ein Pad für ein View. Hier werden die Datein mittels ViewController der View bekannt gemacht. diff --git a/PlayWallCore/src/de/tobias/playpad/project/Project.java b/PlayWallCore/src/de/tobias/playpad/project/Project.java index 5d7b13afa3f7f5566c448eeb5d98632e9e4484b5..10b45bc009216506f6e2fbda522e74ca48fd5178 100644 --- a/PlayWallCore/src/de/tobias/playpad/project/Project.java +++ b/PlayWallCore/src/de/tobias/playpad/project/Project.java @@ -15,12 +15,14 @@ import org.dom4j.Element; import de.tobias.playpad.pad.Pad; import de.tobias.playpad.pad.PadException; import de.tobias.playpad.pad.PadSerializer; -import de.tobias.playpad.pad.PadStatus; import de.tobias.playpad.registry.NoSuchComponentException; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.settings.ProfileNotFoundException; import de.tobias.utils.xml.XMLHandler; import javafx.application.Platform; +import javafx.beans.property.IntegerProperty; +import javafx.beans.property.ReadOnlyIntegerProperty; +import javafx.beans.property.SimpleIntegerProperty; import javafx.collections.FXCollections; import javafx.collections.ObservableList; @@ -35,7 +37,7 @@ public class Project { /** * Pattern für den Namen des Projekts */ - public static final String PROJECT_NAME_PATTERN = "\\w{1}[\\w\\s-_]{0,}"; + public static final String PROJECT_NAME_PATTERN = "[\\p{L},0-9]{1}[\\p{L}\\s-_]{0,}"; /** * Dateiendung für eine projekt Datei */ @@ -57,6 +59,8 @@ public class Project { */ private transient ObservableList<PadException> exceptions; + private transient IntegerProperty activePlayers; + /** * Erstellt ein neues leeres Projekt mit einer Referenz. * @@ -69,6 +73,7 @@ public class Project { this.settings = new ProjectSettings(); this.exceptions = FXCollections.observableArrayList(); + this.activePlayers = new SimpleIntegerProperty(); } /** @@ -151,7 +156,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()); } @@ -203,18 +209,25 @@ public class Project { return pads; } - public int getPlayedPlayers() { - int count = 0; - for (Pad pad : pads.values()) { - if (pad.getStatus() == PadStatus.PLAY || pad.getStatus() == PadStatus.PAUSE) { - count++; - } - } - return count; + public int getActivePlayers() { + return activePlayers.get(); + } + + public boolean hasActivePlayers() { + return getActivePlayers() > 0; + } + + public void increaseActivePlayers() { + activePlayers.set(getActivePlayers() + 1); } - public boolean hasPlayedPlayers() { - return getPlayedPlayers() > 0; + public void dereaseActivePlayers() { + if (activePlayers.greaterThan(0).get()) + activePlayers.set(getActivePlayers() - 1); + } + + public ReadOnlyIntegerProperty activePlayerProperty() { + return activePlayers; } // Exceptions @@ -274,4 +287,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/ProjectReference.java b/PlayWallCore/src/de/tobias/playpad/project/ProjectReference.java index dfd5aae6d7eda62b48cd2844b12a514a3528df5f..eb7855d0a5e04341fd69d46ad86f607cd11027b8 100644 --- a/PlayWallCore/src/de/tobias/playpad/project/ProjectReference.java +++ b/PlayWallCore/src/de/tobias/playpad/project/ProjectReference.java @@ -125,8 +125,8 @@ public class ProjectReference implements Displayable { } private static void duplicateFiles(ProjectReference currentProject, ProjectReference newProjectReference) throws IOException { - Path oldPath = ApplicationUtils.getApplication().getPath(PathType.DOCUMENTS, currentProject.getName()); - Path newPath = ApplicationUtils.getApplication().getPath(PathType.DOCUMENTS, newProjectReference.getName()); + Path oldPath = ApplicationUtils.getApplication().getPath(PathType.DOCUMENTS, currentProject.getFileName()); + Path newPath = ApplicationUtils.getApplication().getPath(PathType.DOCUMENTS, newProjectReference.getFileName()); Files.copy(oldPath, newPath, StandardCopyOption.COPY_ATTRIBUTES); } diff --git a/PlayWallCore/src/de/tobias/playpad/project/ProjectReferenceList.java b/PlayWallCore/src/de/tobias/playpad/project/ProjectReferenceList.java index a9d7ea8412887f1f5173b1a3416018271e59a29b..a9a172d9097d6b2646fefd35b3084a34fada0123 100644 --- a/PlayWallCore/src/de/tobias/playpad/project/ProjectReferenceList.java +++ b/PlayWallCore/src/de/tobias/playpad/project/ProjectReferenceList.java @@ -16,19 +16,22 @@ final class ProjectReferenceList extends UniqList<ProjectReference> { public boolean contains(Object o) { if (o instanceof String) { - for (ProjectReference reference : this) { - if (reference.getName().equals(o)) { + for (ProjectReference item : this) { + if (item.getName().equals(o)) { return true; - } else if (reference.toString().equals(o)) { + } else if (item.toString().equals(o)) { return true; } } } else if (o instanceof ProjectReference) { - for (ProjectReference reference : this) { - if (reference.getName() == o) { - return true; - } else if (reference.getName().equals(((ProjectReference) o).getName())) { // TODO Check + for (ProjectReference item : this) { + if (item.getName() == o) { return true; + } else { + ProjectReference projectRef = (ProjectReference) o; + if (item.getName().equals(projectRef.getName())) { + return true; + } } } } 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/settings/Fade.java b/PlayWallCore/src/de/tobias/playpad/settings/Fade.java index 73d9ba15ff65457e984f61d95bb43b9981af6b97..48c9d864b835df013f86031d27131dfbf4a77cb4 100644 --- a/PlayWallCore/src/de/tobias/playpad/settings/Fade.java +++ b/PlayWallCore/src/de/tobias/playpad/settings/Fade.java @@ -18,7 +18,7 @@ public class Fade { fadeIn = Duration.ZERO; fadeOut = Duration.ZERO; - fadeInStart = true; + fadeInStart = false; fadeInPause = true; fadeOutPause = true; fadeOutStop = true; diff --git a/PlayWallCore/src/de/tobias/playpad/settings/GlobalSettings.java b/PlayWallCore/src/de/tobias/playpad/settings/GlobalSettings.java index d597901378ecdc7230d8730573dd5f7ba58d0590..3caa9fa0d669543ae5b71f6e3b9734c14f5a2233 100644 --- a/PlayWallCore/src/de/tobias/playpad/settings/GlobalSettings.java +++ b/PlayWallCore/src/de/tobias/playpad/settings/GlobalSettings.java @@ -4,6 +4,7 @@ import java.io.IOException; import java.io.UnsupportedEncodingException; import java.nio.file.Files; import java.nio.file.Path; +import java.nio.file.Paths; import org.dom4j.Document; import org.dom4j.DocumentException; @@ -16,6 +17,9 @@ import org.dom4j.io.XMLWriter; import de.tobias.playpad.PlayPad; import de.tobias.playpad.settings.keys.KeyCollection; import de.tobias.playpad.update.UpdateChannel; +import de.tobias.utils.application.ApplicationUtils; +import de.tobias.utils.application.container.PathType; +import de.tobias.utils.settings.Storable; /** * Globale Einstellungen für das Programm. Eine Instanz von diesen Einstellungen wird in {@link PlayPad} verwaltet. @@ -31,11 +35,30 @@ public class GlobalSettings { private Path savePath; + // Key Binding private KeyCollection keyCollection = new KeyCollection(); + // Update private boolean autoUpdate = true; + private boolean ignoreUpdate = false; private UpdateChannel updateChannel = UpdateChannel.STABLE; + // Live Mode + @Storable private boolean liveMode = true; + @Storable private boolean liveModePage = true; + @Storable private boolean liveModeDrag = true; + @Storable private boolean liveModeFile = true; + @Storable private boolean liveModeSettings = true; + + // Paths + @Storable private Path cachePath = ApplicationUtils.getApplication().getPath(PathType.CACHE); + + // Dialogs + @Storable private boolean ignoreSaveDialog = false; + + public GlobalSettings() { + } + // Getter public boolean isAutoUpdate() { return autoUpdate; @@ -45,10 +68,42 @@ public class GlobalSettings { return updateChannel; } + public boolean isIgnoreUpdate() { + return ignoreUpdate; + } + public KeyCollection getKeyCollection() { return keyCollection; } + public boolean isLiveMode() { + return liveMode; + } + + public boolean isLiveModeDrag() { + return liveModeDrag; + } + + public boolean isLiveModeFile() { + return liveModeFile; + } + + public boolean isLiveModePage() { + return liveModePage; + } + + public boolean isLiveModeSettings() { + return liveModeSettings; + } + + public Path getCachePath() { + return cachePath; + } + + public boolean isIgnoreSaveDialog() { + return ignoreSaveDialog; + } + // Setter public void setAutoUpdate(boolean autoUpdate) { this.autoUpdate = autoUpdate; @@ -58,9 +113,51 @@ public class GlobalSettings { this.updateChannel = updateChannel; } + public void setIgnoreUpdate(boolean ignoreUpdate) { + this.ignoreUpdate = ignoreUpdate; + } + + public void setLiveMode(boolean liveMode) { + this.liveMode = liveMode; + } + + public void setLiveModeDrag(boolean liveModeDrag) { + this.liveModeDrag = liveModeDrag; + } + + public void setLiveModeFile(boolean liveModeFile) { + this.liveModeFile = liveModeFile; + } + + public void setLiveModePage(boolean liveModePage) { + this.liveModePage = liveModePage; + } + + public void setLiveModeSettings(boolean liveModeSettings) { + this.liveModeSettings = liveModeSettings; + } + + public void setCachePath(Path cachePath) { + this.cachePath = cachePath; + } + + public void setIgnoreSaveDialog(boolean ignoreSaveDialog) { + this.ignoreSaveDialog = ignoreSaveDialog; + } + + // Save & Load Data + private static final String KEYS_ELEMENT = "Keys"; private static final String AUTO_UPDATE_ELEMENT = "AutoUpdate"; + private static final String IGNORE_UPDATE_ELEMENT = "IgnoreUpdate"; private static final String UPDATE_CHANNEL_ELEMENT = "UpdateChannel"; + private static final String LIVE_MODE_ELEMENT = "LiveMode"; + private static final String LIVE_MODE_PAGE_ATTR = "page"; + private static final String LIVE_MODE_DRAG_ATTR = "drag"; + private static final String LIVE_MODE_FILE_ATTR = "file"; + private static final String LIVE_MODE_SETTINGS_ATTR = "settings"; + private static final String CACHE_PATH_ELEMENT = "Cache-Path"; + private static final String IGNORE_SAVE_DIALOG_ELEMENT = "IgnoreSaveDialog"; /** * Lädt eine neue Instanz der Globalen Einstellungen. @@ -87,9 +184,39 @@ public class GlobalSettings { settings.setAutoUpdate(Boolean.valueOf(root.element(AUTO_UPDATE_ELEMENT).getStringValue())); } + if (root.element(IGNORE_UPDATE_ELEMENT) != null) { + settings.setIgnoreUpdate(Boolean.valueOf(root.element(IGNORE_UPDATE_ELEMENT).getStringValue())); + } + if (root.element(UPDATE_CHANNEL_ELEMENT) != null) { settings.setUpdateChannel(UpdateChannel.valueOf(root.element(UPDATE_CHANNEL_ELEMENT).getStringValue())); } + + Element liveElement = root.element(LIVE_MODE_ELEMENT); + if (liveElement != null) { + settings.setLiveMode(Boolean.valueOf(liveElement.getStringValue())); + if (liveElement.attributeValue(LIVE_MODE_PAGE_ATTR) != null) { + settings.setLiveModePage(Boolean.valueOf(liveElement.attributeValue(LIVE_MODE_PAGE_ATTR))); + } + if (liveElement.attributeValue(LIVE_MODE_DRAG_ATTR) != null) { + settings.setLiveModeDrag(Boolean.valueOf(liveElement.attributeValue(LIVE_MODE_DRAG_ATTR))); + } + if (liveElement.attributeValue(LIVE_MODE_FILE_ATTR) != null) { + settings.setLiveModeFile(Boolean.valueOf(liveElement.attributeValue(LIVE_MODE_FILE_ATTR))); + } + if (liveElement.attributeValue(LIVE_MODE_SETTINGS_ATTR) != null) { + settings.setLiveModeSettings(Boolean.valueOf(liveElement.attributeValue(LIVE_MODE_SETTINGS_ATTR))); + } + } + + if (root.element(CACHE_PATH_ELEMENT) != null) { + settings.setCachePath(Paths.get(root.element(CACHE_PATH_ELEMENT).getStringValue())); + } + + // Dialogs + if (root.element(IGNORE_SAVE_DIALOG_ELEMENT) != null) { + settings.setIgnoreSaveDialog(Boolean.valueOf(root.element(IGNORE_SAVE_DIALOG_ELEMENT).getStringValue())); + } } return settings; } @@ -112,8 +239,23 @@ public class GlobalSettings { // Update root.addElement(AUTO_UPDATE_ELEMENT).addText(String.valueOf(autoUpdate)); + root.addElement(IGNORE_UPDATE_ELEMENT).addText(String.valueOf(ignoreUpdate)); root.addElement(UPDATE_CHANNEL_ELEMENT).addText(updateChannel.name()); + // Live Mode + Element liveElement = root.addElement(LIVE_MODE_ELEMENT); + liveElement.addText(String.valueOf(liveMode)); + liveElement.addAttribute(LIVE_MODE_PAGE_ATTR, String.valueOf(liveModePage)); + liveElement.addAttribute(LIVE_MODE_DRAG_ATTR, String.valueOf(liveModeDrag)); + liveElement.addAttribute(LIVE_MODE_FILE_ATTR, String.valueOf(liveModeFile)); + liveElement.addAttribute(LIVE_MODE_SETTINGS_ATTR, String.valueOf(liveModeSettings)); + + // Paths + root.addElement(CACHE_PATH_ELEMENT).addText(cachePath.toString()); + + // Dialogs + root.addElement(IGNORE_SAVE_DIALOG_ELEMENT).addText(String.valueOf(ignoreSaveDialog)); + XMLWriter writer = new XMLWriter(Files.newOutputStream(savePath), OutputFormat.createPrettyPrint()); writer.write(document); writer.close(); diff --git a/PlayWallCore/src/de/tobias/playpad/settings/Profile.java b/PlayWallCore/src/de/tobias/playpad/settings/Profile.java index 4a1e2e9ccfe32200cab44281ea33b4c34897ae21..2516305ee7b7e610aa892aeb91666cbbbabcd942 100644 --- a/PlayWallCore/src/de/tobias/playpad/settings/Profile.java +++ b/PlayWallCore/src/de/tobias/playpad/settings/Profile.java @@ -26,7 +26,7 @@ public class Profile { private static final String MAPPING_XML = "Mapping.xml"; private static final String LAYOUT_XML = "Layout.xml"; - public static final String profileNameEx = "\\w{1}[\\w\\s-_]{0,}"; + public static final String profileNameEx = "[\\p{L},0-9]{1}[\\p{L}\\s-_]{0,}"; private static List<ProfileListener> listeners = new ArrayList<>(); private static Profile currentProfile; diff --git a/PlayWallCore/src/de/tobias/playpad/settings/ProfileSettings.java b/PlayWallCore/src/de/tobias/playpad/settings/ProfileSettings.java index 017e3777c90bfad7cd487b2d8a5849d600c8784c..0c3e79c73f2dfd192423ee37cc4f9993ed28b021 100644 --- a/PlayWallCore/src/de/tobias/playpad/settings/ProfileSettings.java +++ b/PlayWallCore/src/de/tobias/playpad/settings/ProfileSettings.java @@ -4,7 +4,6 @@ import java.io.IOException; import java.io.UnsupportedEncodingException; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.HashMap; import org.dom4j.Document; @@ -17,8 +16,6 @@ import org.dom4j.io.XMLWriter; import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.pad.TimeMode; -import de.tobias.utils.application.ApplicationUtils; -import de.tobias.utils.application.container.PathType; import de.tobias.utils.settings.SettingsSerializable; import de.tobias.utils.settings.Storable; import de.tobias.utils.settings.UserDefaults; @@ -36,26 +33,21 @@ public class ProfileSettings implements SettingsSerializable { // MIDI @Storable private String midiDevice; + @Storable private boolean midiActive = false; // Audio Output - // TODO Rewrite @Storable private String audioClass = PlayPadPlugin.getRegistryCollection().getAudioHandlers().getDefaultID(); @Storable private HashMap<String, Object> audioUserInfo = new HashMap<>(); // Layout - @Storable private String layoutType = PlayPadPlugin.getRegistryCollection().getDesigns().getDefaultID(); // Rather DesignType + @Storable private String layoutType = PlayPadPlugin.getRegistryCollection().getDesigns().getDefaultID(); // Rather + // DesignType @Storable private String mainLayoutType = PlayPadPlugin.getRegistryCollection().getMainLayouts().getDefaultID(); // Cart Settings @Storable private boolean multiplePlayer = true; @Storable private Warning warningFeedback = new Warning(Duration.seconds(5)); - @Storable private boolean midiActive = false; - @Storable private boolean liveMode = true; - @Storable private boolean liveModePage = true; - @Storable private boolean liveModeDrag = true; - @Storable private boolean liveModeFile = true; - @Storable private boolean liveModeSettings = true; @Storable private DoubleProperty volumeProperty = new SimpleDoubleProperty(1.0); @Storable private boolean windowAlwaysOnTop = false; @@ -63,9 +55,6 @@ public class ProfileSettings implements SettingsSerializable { @Storable private Fade fade = new Fade(); @Storable private TimeMode player_timeDisplayMode = TimeMode.REST; - // Folder - @Storable private Path cachePath = ApplicationUtils.getApplication().getPath(PathType.CACHE); - public boolean isLocked() { return lockedProperty.get(); } @@ -83,10 +72,6 @@ public class ProfileSettings implements SettingsSerializable { return midiDevice; } - public Path getCachePath() { - return cachePath; - } - public String getLayoutType() { return layoutType; } @@ -103,26 +88,6 @@ public class ProfileSettings implements SettingsSerializable { return midiActive; } - public boolean isLiveMode() { - return liveMode; - } - - public boolean isLiveModeDrag() { - return liveModeDrag; - } - - public boolean isLiveModeFile() { - return liveModeFile; - } - - public boolean isLiveModePage() { - return liveModePage; - } - - public boolean isLiveModeSettings() { - return liveModeSettings; - } - public double getVolume() { return volumeProperty.get(); } @@ -156,10 +121,6 @@ public class ProfileSettings implements SettingsSerializable { this.midiDevice = midiDevice; } - public void setCachePath(Path cachePath) { - this.cachePath = cachePath; - } - public void setLayoutType(String layoutType) { this.layoutType = layoutType; } @@ -176,26 +137,6 @@ public class ProfileSettings implements SettingsSerializable { this.midiActive = midiActive; } - public void setLiveMode(boolean liveMode) { - this.liveMode = liveMode; - } - - public void setLiveModeDrag(boolean liveModeDrag) { - this.liveModeDrag = liveModeDrag; - } - - public void setLiveModeFile(boolean liveModeFile) { - this.liveModeFile = liveModeFile; - } - - public void setLiveModePage(boolean liveModePage) { - this.liveModePage = liveModePage; - } - - public void setLiveModeSettings(boolean liveModeSettings) { - this.liveModeSettings = liveModeSettings; - } - public void setVolume(double volume) { this.volumeProperty.set(volume); } @@ -227,18 +168,12 @@ public class ProfileSettings implements SettingsSerializable { private static final String LOCKED_ELEMENT = "Locked"; private static final String ITEM_ELEMENT = "Item"; - private static final String CACHE_PATH_ELEMENT = "Cache-Path"; private static final String VOLUME_ELEMENT = "Volume"; private static final String KEY_ATTRIBUTE = "key"; private static final String AUDIO_USER_INFO_ELEMENT = "AudioUserInfo"; private static final String AUDIO_CLASS_ELEMENT = "AudioClass"; private static final String WINDOW_ALWAYS_ON_TOP_ELEMENT = "WindowAlwaysOnTop"; private static final String MULTIPLE_PLAYER_ELEMENT = "MultiplePlayer"; - private static final String LIVE_MODE_ELEMENT = "LiveMode"; - private static final String LIVE_MODE_PAGE_ATTR = "page"; - private static final String LIVE_MODE_DRAG_ATTR = "drag"; - private static final String LIVE_MODE_FILE_ATTR = "file"; - private static final String LIVE_MODE_SETTINGS_ATTR = "settings"; private static final String TIME_DISPLAY_ELEMENT = "TimeDisplay"; private static final String FADE_ELEMENT = "Fade"; private static final String WARNING_ELEMENT = "Warning"; @@ -295,23 +230,6 @@ public class ProfileSettings implements SettingsSerializable { } } - Element liveElement = root.element(LIVE_MODE_ELEMENT); - if (liveElement != null) { - profileSettings.setLiveMode(Boolean.valueOf(liveElement.getStringValue())); - if (liveElement.attributeValue(LIVE_MODE_PAGE_ATTR) != null) { - profileSettings.setLiveModePage(Boolean.valueOf(liveElement.attributeValue(LIVE_MODE_PAGE_ATTR))); - } - if (liveElement.attributeValue(LIVE_MODE_DRAG_ATTR) != null) { - profileSettings.setLiveModeDrag(Boolean.valueOf(liveElement.attributeValue(LIVE_MODE_DRAG_ATTR))); - } - if (liveElement.attributeValue(LIVE_MODE_FILE_ATTR) != null) { - profileSettings.setLiveModeFile(Boolean.valueOf(liveElement.attributeValue(LIVE_MODE_FILE_ATTR))); - } - if (liveElement.attributeValue(LIVE_MODE_SETTINGS_ATTR) != null) { - profileSettings.setLiveModeSettings(Boolean.valueOf(liveElement.attributeValue(LIVE_MODE_SETTINGS_ATTR))); - } - } - if (root.element(WINDOW_ALWAYS_ON_TOP_ELEMENT) != null) profileSettings.setWindowAlwaysOnTop(Boolean.valueOf(root.element(WINDOW_ALWAYS_ON_TOP_ELEMENT).getStringValue())); if (root.element(AUDIO_CLASS_ELEMENT) != null) @@ -330,10 +248,6 @@ public class ProfileSettings implements SettingsSerializable { } if (root.element(VOLUME_ELEMENT) != null) profileSettings.setVolume(Double.valueOf(root.element(VOLUME_ELEMENT).getStringValue())); - - if (root.element(CACHE_PATH_ELEMENT) != null) { - profileSettings.setCachePath(Paths.get(root.element(CACHE_PATH_ELEMENT).getStringValue())); - } } return profileSettings; } @@ -358,13 +272,6 @@ public class ProfileSettings implements SettingsSerializable { root.addElement(MULTIPLE_PLAYER_ELEMENT).addText(String.valueOf(multiplePlayer)); - Element liveElement = root.addElement(LIVE_MODE_ELEMENT); - liveElement.addText(String.valueOf(liveMode)); - liveElement.addAttribute(LIVE_MODE_PAGE_ATTR, String.valueOf(liveModePage)); - liveElement.addAttribute(LIVE_MODE_DRAG_ATTR, String.valueOf(liveModeDrag)); - liveElement.addAttribute(LIVE_MODE_FILE_ATTR, String.valueOf(liveModeFile)); - liveElement.addAttribute(LIVE_MODE_SETTINGS_ATTR, String.valueOf(liveModeSettings)); - root.addElement(WINDOW_ALWAYS_ON_TOP_ELEMENT).addText(String.valueOf(windowAlwaysOnTop)); // Audio @@ -376,9 +283,6 @@ public class ProfileSettings implements SettingsSerializable { } root.addElement(VOLUME_ELEMENT).addText(String.valueOf(volumeProperty.get())); - // Paths - root.addElement(CACHE_PATH_ELEMENT).addText(cachePath.toString()); - XMLWriter writer = new XMLWriter(Files.newOutputStream(path), OutputFormat.createPrettyPrint()); writer.write(document); writer.close(); diff --git a/PlayWallCore/src/de/tobias/playpad/settings/keys/KeyCollection.java b/PlayWallCore/src/de/tobias/playpad/settings/keys/KeyCollection.java index 080d0e6a606fea3db9cc9a02ae002188dd1231d1..4c209a3b8b0dedb397a6371e8ea1e08f48412ea5 100644 --- a/PlayWallCore/src/de/tobias/playpad/settings/keys/KeyCollection.java +++ b/PlayWallCore/src/de/tobias/playpad/settings/keys/KeyCollection.java @@ -1,5 +1,6 @@ package de.tobias.playpad.settings.keys; +import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.List; @@ -73,6 +74,16 @@ public class KeyCollection { } return false; } + + public List<Key> getConflicts(Key key) { + List<Key> conflicts = new ArrayList<>(); + for (Key k : keys.values()) { + if (k.getKeyCode().equals(key.getKeyCode())) { + conflicts.add(k); + } + } + return conflicts; + } private static final String KEY_ELEMENT = "Key"; diff --git a/PlayWallCore/src/de/tobias/playpad/view/main/MainLayoutConnect.java b/PlayWallCore/src/de/tobias/playpad/view/main/MainLayoutConnect.java index 2bec2f288326cc45f96bf0d22adfe5ea80a08fbd..b8a88aa78514af5227bfe7290a8ff84d780ff548 100644 --- a/PlayWallCore/src/de/tobias/playpad/view/main/MainLayoutConnect.java +++ b/PlayWallCore/src/de/tobias/playpad/view/main/MainLayoutConnect.java @@ -1,7 +1,7 @@ package de.tobias.playpad.view.main; -import de.tobias.playpad.pad.view.IPadViewV2; -import de.tobias.playpad.pad.viewcontroller.IPadViewControllerV2; +import de.tobias.playpad.pad.view.IPadView; +import de.tobias.playpad.pad.viewcontroller.IPadViewController; import de.tobias.playpad.viewcontroller.main.IMainViewController; import de.tobias.playpad.viewcontroller.main.MenuToolbarViewController; @@ -43,10 +43,10 @@ public interface MainLayoutConnect { * * @return Pad * - * @see IPadViewV2 notwendige Methoden für ein Pad - * @see IPadViewControllerV2 ViewController zum Pad + * @see IPadView notwendige Methoden für ein Pad + * @see IPadViewController ViewController zum Pad */ - public IPadViewV2 createPadView(); + public IPadView createPadView(); /** * Recycelt eine PadView, damit nicht immer neue erstellt werden müssen. @@ -54,7 +54,7 @@ public interface MainLayoutConnect { * @param padView * alte PadView */ - public void recyclePadView(IPadViewV2 padView); + public void recyclePadView(IPadView padView); /** * Gibt das Layout sepzifische Stylesheet zurück. diff --git a/PlayWallCore/src/de/tobias/playpad/view/main/MenuType.java b/PlayWallCore/src/de/tobias/playpad/view/main/MenuType.java index edcb7f5f3b4bb8ab646db90c585ee740ecc5525f..14080aec095ee64fe3c2d589a486cf754a4b7d5a 100644 --- a/PlayWallCore/src/de/tobias/playpad/view/main/MenuType.java +++ b/PlayWallCore/src/de/tobias/playpad/view/main/MenuType.java @@ -3,5 +3,4 @@ package de.tobias.playpad.view.main; public enum MenuType { EXTENSION, - SETTINGS; } diff --git a/PlayWallCore/src/de/tobias/playpad/viewcontroller/AudioTypeViewController.java b/PlayWallCore/src/de/tobias/playpad/viewcontroller/AudioHandlerViewController.java similarity index 80% rename from PlayWallCore/src/de/tobias/playpad/viewcontroller/AudioTypeViewController.java rename to PlayWallCore/src/de/tobias/playpad/viewcontroller/AudioHandlerViewController.java index ee065a8d8fa59a2b0b69508894b1eea223b718dd..ba5e4d0af5824208ba515155ddd68e2fe7a70397 100644 --- a/PlayWallCore/src/de/tobias/playpad/viewcontroller/AudioTypeViewController.java +++ b/PlayWallCore/src/de/tobias/playpad/viewcontroller/AudioHandlerViewController.java @@ -12,7 +12,7 @@ import de.tobias.utils.ui.ContentViewController; * * @see AudioHandlerConnect */ -public abstract class AudioTypeViewController extends ContentViewController { +public abstract class AudioHandlerViewController extends ContentViewController { /** * Neuer ViewController. @@ -24,7 +24,7 @@ public abstract class AudioTypeViewController extends ContentViewController { * @param localization * Localization */ - public AudioTypeViewController(String name, String path, ResourceBundle localization) { + public AudioHandlerViewController(String name, String path, ResourceBundle localization) { super(name, path, localization); } diff --git a/PlayWallCore/src/de/tobias/playpad/viewcontroller/IPadView.java b/PlayWallCore/src/de/tobias/playpad/viewcontroller/IPadView.java deleted file mode 100644 index d134ca726741335447dce2763dce9b1d0b3ce3ea..0000000000000000000000000000000000000000 --- a/PlayWallCore/src/de/tobias/playpad/viewcontroller/IPadView.java +++ /dev/null @@ -1,44 +0,0 @@ -package de.tobias.playpad.viewcontroller; - -import de.tobias.playpad.pad.Pad; -import de.tobias.playpad.pad.view.IPadContentView; -import javafx.css.PseudoClass; -import javafx.scene.Node; -import javafx.scene.Parent; -import javafx.scene.control.Button; -import javafx.scene.control.ProgressBar; - -@Deprecated -public interface IPadView { - - public void setBusy(boolean busy); - - public void pseudoClassState(PseudoClass pseudoClass, boolean active); - - public void setStyle(String string); - - public Node getNewButton(); - - public Button getPlayButton(); - - public Button getPauseButton(); - - public Button getStopButton(); - - public ProgressBar getPlayBar(); - - public Parent getParent(); - - public void showPlaybar(boolean b); - - public void setPreviewContent(Pad pad); - - public void addDefaultButton(Pad pad); - - public void setErrorLabelActive(boolean b); - - public void setTriggerLabelActive(boolean b); - - public IPadContentView getPadContentView(); - -} diff --git a/PlayWallCore/src/de/tobias/playpad/viewcontroller/main/IMainViewController.java b/PlayWallCore/src/de/tobias/playpad/viewcontroller/main/IMainViewController.java index 9a39e8f621ae3d2d0e4b71fe59139025a68b3bd7..4a6bb28d49299a18a4dac4725e04e72fe68ddf06 100644 --- a/PlayWallCore/src/de/tobias/playpad/viewcontroller/main/IMainViewController.java +++ b/PlayWallCore/src/de/tobias/playpad/viewcontroller/main/IMainViewController.java @@ -3,7 +3,7 @@ package de.tobias.playpad.viewcontroller.main; import java.util.List; import de.tobias.playpad.midi.MidiListener; -import de.tobias.playpad.pad.view.IPadViewV2; +import de.tobias.playpad.pad.view.IPadView; import de.tobias.playpad.settings.keys.KeyCollection; import de.tobias.playpad.view.main.MainLayoutConnect; import de.tobias.playpad.view.main.MainLayoutHandler; @@ -104,20 +104,12 @@ public interface IMainViewController extends NotificationHandler { */ public void loadUserCss(); - /** - * Zeigt einen Hinweis, wenn eine Aktion versucht wird zu machen, wie während der Wiedergabe eines Pads nicht erlaubt ist. Die Methode - * delegiert an die Toolbar weiter. - * - * @see MenuToolbarViewController#showLiveInfo(boolean) - */ - public void showLiveInfo(); - /** * Gibt die PadViews zurück. * * @return Liste der PadViews */ - List<IPadViewV2> getPadViews(); + List<IPadView> getPadViews(); /** * Gibt den MIDI Handler des Hauptfensters für die Kacheln zurück. diff --git a/PlayWallCore/src/de/tobias/playpad/viewcontroller/main/MenuToolbarViewController.java b/PlayWallCore/src/de/tobias/playpad/viewcontroller/main/MenuToolbarViewController.java index 2df87e3723b44664544e0e5f1310bcac558a7b39..d6606a8ae9bca7dc1b29260b908c0b9493066cb7 100644 --- a/PlayWallCore/src/de/tobias/playpad/viewcontroller/main/MenuToolbarViewController.java +++ b/PlayWallCore/src/de/tobias/playpad/viewcontroller/main/MenuToolbarViewController.java @@ -126,20 +126,6 @@ public abstract class MenuToolbarViewController extends ContentViewController { * Getter */ - /** - * Gibt die Einstellung zurück, ob AlwaysOnTop Aktiv ist. - * - * @return <code>true</code> Aktiv - */ - public abstract boolean isAlwaysOnTopActive(); - - /** - * Gibt die Einstellung zurück, ob Fullscreen Aktiv ist. - * - * @return <code>true</code> Aktiv - */ - public abstract boolean isFullscreenActive(); - /** * Deinitialisiert den Controller. */ @@ -154,14 +140,6 @@ public abstract class MenuToolbarViewController extends ContentViewController { // Utils - /** - * Zeigt den Hinweis LiveModus, und signalisiert dem Nutzer, das eine Aktion blokciert ist. - * - * @param show - * <code>true</code> Hinweis Aktiv - */ - public abstract void showLiveInfo(boolean show); - /** * Hebt dem Page Button der Aktiv ist hervor. Gleichzeitig wird der vorherige Button nicht mehr Hervorgehebt. * @@ -183,7 +161,8 @@ public abstract class MenuToolbarViewController extends ContentViewController { /** * Setzt eine Refernce des aktuellen Projectes auf den ViewController. * - * @param project neues Project + * @param project + * neues Project */ public abstract void setOpenProject(Project project); } 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/awakeplugin/de/tobias/playpad/awakeplugin/impl/AwakePluginImpl.java b/PlayWallPlugins/awakeplugin/de/tobias/playpad/awakeplugin/impl/AwakePluginImpl.java index 7d6d16465bad2fdad250431fbe30d5e6b1cb3393..ead13c66e180a23982c29bc06f9354e0d6fd2059 100644 --- a/PlayWallPlugins/awakeplugin/de/tobias/playpad/awakeplugin/impl/AwakePluginImpl.java +++ b/PlayWallPlugins/awakeplugin/de/tobias/playpad/awakeplugin/impl/AwakePluginImpl.java @@ -25,10 +25,10 @@ import de.tobias.utils.ui.icon.FontAwesomeType; import de.tobias.utils.ui.icon.FontIcon; import de.tobias.utils.util.AwakeUtils; import de.tobias.utils.util.IOUtils; -import de.tobias.utils.util.Kernel32; import de.tobias.utils.util.Localization; import de.tobias.utils.util.OS; import de.tobias.utils.util.OS.OSType; +import de.tobias.utils.util.win.Kernel32; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.control.CheckMenuItem; 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(); }